Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 7f38649

Browse files
committed
feat(form-label): move to tsx
1 parent 69871fe commit 7f38649

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

packages/c-form-control/src/c-form-label.tsx

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineComponent, computed, h } from "vue"
22
import {
33
chakra,
44
ComponentWithProps,
5+
DeepPartial,
56
HTMLChakraProps,
67
ThemingProps,
78
useStyleConfig,
@@ -24,7 +25,7 @@ export const CFormLabel = defineComponent({
2425
if (slots.indicator) {
2526
return slots.indicator?.()
2627
} else {
27-
return h(CRequiredIndicator)
28+
return <CRequiredIndicator />
2829
}
2930
})
3031

@@ -52,24 +53,25 @@ export interface CRequiredIndicatorProps extends HTMLChakraProps<"span"> {}
5253
* Used to show a "required" text or an asterisks (*) to indicate that
5354
* a field is required.
5455
*/
55-
export const CRequiredIndicator: ComponentWithProps<CRequiredIndicatorProps> =
56-
defineComponent({
57-
name: "CRequiredIndicator",
58-
setup(_, { attrs }) {
59-
const field = useFormControlContext()
60-
const styles = useStyles()
56+
export const CRequiredIndicator: ComponentWithProps<
57+
DeepPartial<CRequiredIndicatorProps>
58+
> = defineComponent({
59+
name: "CRequiredIndicator",
60+
setup(_, { attrs }) {
61+
const field = useFormControlContext()
62+
const styles = useStyles()
6163

62-
if (!field?.value?.isRequired?.value) return null
64+
if (!field?.value?.isRequired?.value) return null
6365

64-
return () => (
65-
<chakra.span
66-
{...field?.value?.requiredIndicatorProps.value}
67-
__css={styles.value.requiredIndicator}
68-
__label="form__required-indicator"
69-
{...attrs}
70-
>
71-
*
72-
</chakra.span>
73-
)
74-
},
75-
})
66+
return () => (
67+
<chakra.span
68+
{...field?.value?.requiredIndicatorProps.value}
69+
__css={styles.value.requiredIndicator}
70+
__label="form__required-indicator"
71+
{...attrs}
72+
>
73+
*
74+
</chakra.span>
75+
)
76+
},
77+
})

0 commit comments

Comments
 (0)