@syscore/ui-library 2.0.0-beta-publish-workflow-beta.15 → 2.0.0-beta-publish-workflow-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -41,6 +41,7 @@ export type DropdownProps = Omit<
|
|
|
41
41
|
"onChange"
|
|
42
42
|
> & {
|
|
43
43
|
label?: string;
|
|
44
|
+
required?: boolean;
|
|
44
45
|
placeholder?: string;
|
|
45
46
|
options?: DropdownOption[];
|
|
46
47
|
value?: string;
|
|
@@ -94,6 +95,7 @@ const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
|
|
|
94
95
|
{
|
|
95
96
|
className,
|
|
96
97
|
label = "Label",
|
|
98
|
+
required = false,
|
|
97
99
|
placeholder = "Placeholder",
|
|
98
100
|
options = [],
|
|
99
101
|
value: valueProp,
|
|
@@ -255,6 +257,12 @@ const Dropdown = React.forwardRef<HTMLDivElement, DropdownProps>(
|
|
|
255
257
|
<div className="dropdown-label-row">
|
|
256
258
|
<label className="dropdown-label overline-medium" htmlFor={inputId}>
|
|
257
259
|
{label}
|
|
260
|
+
{required ? (
|
|
261
|
+
<span className="label__required-mark" aria-hidden="true">
|
|
262
|
+
{" "}
|
|
263
|
+
*
|
|
264
|
+
</span>
|
|
265
|
+
) : null}
|
|
258
266
|
</label>
|
|
259
267
|
{onClearTags ? (
|
|
260
268
|
<span className="dropdown-label-actions">
|
|
@@ -86,7 +86,7 @@ FormItem.displayName = "FormItem";
|
|
|
86
86
|
|
|
87
87
|
const FormLabel = React.forwardRef<
|
|
88
88
|
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
89
|
-
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & { required?: boolean }
|
|
90
90
|
>(({ className, ...props }, ref) => {
|
|
91
91
|
const { error, formItemId } = useFormField();
|
|
92
92
|
|
|
@@ -9,16 +9,33 @@ const labelVariants = cva("label");
|
|
|
9
9
|
const Label = React.forwardRef<
|
|
10
10
|
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
11
11
|
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
12
|
-
VariantProps<typeof labelVariants>
|
|
13
|
-
>(({ className, children, ...props }, ref) => (
|
|
12
|
+
VariantProps<typeof labelVariants> & { required?: boolean }
|
|
13
|
+
>(({ className, children, required, ...props }, ref) => (
|
|
14
14
|
<LabelPrimitive.Root
|
|
15
15
|
ref={ref}
|
|
16
16
|
className={cn(labelVariants(), className)}
|
|
17
17
|
{...props}
|
|
18
18
|
>
|
|
19
|
-
<div className="overline-medium">
|
|
19
|
+
<div className="overline-medium">
|
|
20
|
+
{" "}
|
|
21
|
+
{children}
|
|
22
|
+
{required ? (
|
|
23
|
+
<span className="label__required-mark" aria-hidden="true">
|
|
24
|
+
{" "}
|
|
25
|
+
*
|
|
26
|
+
</span>
|
|
27
|
+
) : null}
|
|
28
|
+
</div>
|
|
20
29
|
</LabelPrimitive.Root>
|
|
21
30
|
));
|
|
22
31
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
23
32
|
|
|
24
|
-
|
|
33
|
+
/** Standalone required-field asterisk, for call sites that build their own label (e.g. a fieldset legend in `Copy`) instead of using `Label`/`FormLabel` directly — same mark, same color, so every required indicator in the app matches. */
|
|
34
|
+
const RequiredAsterisk = () => (
|
|
35
|
+
<span className="label__required-mark" aria-hidden="true">
|
|
36
|
+
{" "}
|
|
37
|
+
*
|
|
38
|
+
</span>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export { Label, RequiredAsterisk };
|