@lerianstudio/sindarian-ui 1.2.0-beta.3 → 1.2.0-beta.5
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.
|
@@ -22,7 +22,7 @@ const ComboBoxField = ({ name, label, placeholder, emptyMessage, required, child
|
|
|
22
22
|
const getDisplayValue = react_1.default.useCallback((value) => {
|
|
23
23
|
return options.find((option) => option.value === value)?.label ?? null;
|
|
24
24
|
}, [options]);
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { name: name, ...others, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: required, children: [label && (0, jsx_runtime_1.jsx)(form_1.FormLabel, { children: label }), (0, jsx_runtime_1.jsxs)(popover_1.Popover, { open: readOnly ? false : open, onOpenChange: readOnly ? () => { } : setOpen, children: [(0, jsx_runtime_1.jsx)(popover_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsxs)(button_1.Button, { variant: "outline", role: "combobox", "aria-expanded": readOnly ? false : open, readOnly: readOnly, tabIndex: 0, className: (0, utils_1.cn)('border-border bg-input hover:bg-input h-10 w-full justify-between rounded-md border px-4 py-2 pl-6 text-left text-sm font-normal focus:
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(form_1.FormField, { name: name, ...others, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(form_1.FormItem, { required: required, children: [label && (0, jsx_runtime_1.jsx)(form_1.FormLabel, { children: label }), (0, jsx_runtime_1.jsxs)(popover_1.Popover, { open: readOnly ? false : open, onOpenChange: readOnly ? () => { } : setOpen, children: [(0, jsx_runtime_1.jsx)(popover_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsxs)(button_1.Button, { variant: "outline", role: "combobox", "aria-expanded": readOnly ? false : open, readOnly: readOnly, tabIndex: 0, className: (0, utils_1.cn)('border-input-border bg-input hover:bg-input h-10 w-full justify-between rounded-md border px-4 py-2 pl-6 text-left text-sm font-normal focus:ring-2 focus:ring-offset-0 focus:outline-none', !field.value && 'text-muted-foreground'), children: [getDisplayValue(field.value) ?? placeholder, !readOnly && ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" }))] }) }), (0, jsx_runtime_1.jsx)(popover_1.PopoverContent, { className: "w-(--radix-popover-trigger-width) p-0", children: (0, jsx_runtime_1.jsxs)(command_1.Command, { children: [(0, jsx_runtime_1.jsx)(command_1.CommandInput, { placeholder: placeholder }), (0, jsx_runtime_1.jsxs)(command_1.CommandList, { children: [(0, jsx_runtime_1.jsx)(command_1.CommandEmpty, { children: emptyMessage }), (0, jsx_runtime_1.jsx)(command_1.CommandGroup, { children: react_1.default.Children.map(react_1.default.Children.toArray(children), (child) => react_1.default.isValidElement(child)
|
|
26
26
|
? react_1.default.cloneElement(child, {
|
|
27
27
|
keywords: [child.props.children],
|
|
28
28
|
onSelect: (value) => {
|
|
@@ -14,7 +14,7 @@ const SelectField = ({ name, label, tooltip, labelExtra, required, placeholder,
|
|
|
14
14
|
}, disabled: disabled, ...field, children: [(0, jsx_runtime_1.jsx)(multiple_select_1.MultipleSelectTrigger, { readOnly: readOnly, children: (0, jsx_runtime_1.jsx)(multiple_select_1.MultipleSelectValue, { placeholder: placeholder }) }), (0, jsx_runtime_1.jsx)(multiple_select_1.MultipleSelectContent, { children: children })] })) : ((0, jsx_runtime_1.jsxs)(select_1.Select, { onValueChange: (value) => {
|
|
15
15
|
field.onChange(value);
|
|
16
16
|
onChange?.(value);
|
|
17
|
-
}, value: field.value, disabled: disabled, open: readOnly ? false : undefined, onOpenChange: readOnly ? () => { } : undefined, children: [(0, jsx_runtime_1.jsx)(form_1.FormControl, { children: (0, jsx_runtime_1.jsx)(select_1.SelectTrigger, { className: (0, utils_1.cn)(disabled && 'bg-shadcn-100'), readOnly: readOnly, "data-testid": others['data-testid'], children: (0, jsx_runtime_1.jsx)(select_1.SelectValue, { placeholder: placeholder }) }) }), (0, jsx_runtime_1.jsxs)(select_1.SelectContent, { children: [(0, jsx_runtime_1.jsx)(select_1.SelectEmpty, { children: emptyMessage }), children] })] })), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {}), description && (0, jsx_runtime_1.jsx)(form_1.FormDescription, { children: description })] }));
|
|
17
|
+
}, value: field.value ?? '', disabled: disabled, open: readOnly ? false : undefined, onOpenChange: readOnly ? () => { } : undefined, children: [(0, jsx_runtime_1.jsx)(form_1.FormControl, { children: (0, jsx_runtime_1.jsx)(select_1.SelectTrigger, { className: (0, utils_1.cn)(disabled && 'bg-shadcn-100'), readOnly: readOnly, "data-testid": others['data-testid'], children: (0, jsx_runtime_1.jsx)(select_1.SelectValue, { placeholder: placeholder }) }) }), (0, jsx_runtime_1.jsxs)(select_1.SelectContent, { children: [(0, jsx_runtime_1.jsx)(select_1.SelectEmpty, { children: emptyMessage }), children] })] })), (0, jsx_runtime_1.jsx)(form_1.FormMessage, {}), description && (0, jsx_runtime_1.jsx)(form_1.FormDescription, { children: description })] }));
|
|
18
18
|
} }));
|
|
19
19
|
};
|
|
20
20
|
exports.SelectField = SelectField;
|
|
@@ -31,7 +31,7 @@ function StateComboBox({ value, placeholder, onChange, countryName, emptyMessage
|
|
|
31
31
|
const getDisplayValue = react_1.default.useCallback((value) => {
|
|
32
32
|
return options.find((option) => option.value === value)?.label ?? null;
|
|
33
33
|
}, [options]);
|
|
34
|
-
return ((0, jsx_runtime_1.jsxs)(popover_1.Popover, { open: readOnly ? false : open, onOpenChange: readOnly ? () => { } : setOpen, children: [(0, jsx_runtime_1.jsx)(popover_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsxs)(button_1.Button, { variant: "outline", role: "combobox", "aria-expanded": readOnly ? false : open, readOnly: readOnly, tabIndex: 0, className: (0, utils_1.cn)('border-border bg-input hover:bg-input h-10 w-full justify-between rounded-md border px-4 py-2 pl-6 text-left text-sm font-normal focus:
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)(popover_1.Popover, { open: readOnly ? false : open, onOpenChange: readOnly ? () => { } : setOpen, children: [(0, jsx_runtime_1.jsx)(popover_1.PopoverTrigger, { asChild: true, children: (0, jsx_runtime_1.jsxs)(button_1.Button, { variant: "outline", role: "combobox", "aria-expanded": readOnly ? false : open, readOnly: readOnly, tabIndex: 0, className: (0, utils_1.cn)('border-input-border bg-input hover:bg-input h-10 w-full justify-between rounded-md border px-4 py-2 pl-6 text-left text-sm font-normal focus:ring-2 focus:ring-offset-0 focus:outline-none', !value && 'text-muted-foreground'), children: [getDisplayValue(value) ?? placeholder, !readOnly && ((0, jsx_runtime_1.jsx)(lucide_react_1.ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" }))] }) }), (0, jsx_runtime_1.jsx)(popover_1.PopoverContent, { className: "w-(--radix-popover-trigger-width) p-0", children: (0, jsx_runtime_1.jsxs)(command_1.Command, { children: [(0, jsx_runtime_1.jsx)(command_1.CommandInput, { placeholder: placeholder }), (0, jsx_runtime_1.jsxs)(command_1.CommandList, { children: [(0, jsx_runtime_1.jsx)(command_1.CommandEmpty, { children: emptyMessage }), (0, jsx_runtime_1.jsx)(command_1.CommandGroup, { children: options.map((option) => ((0, jsx_runtime_1.jsx)(command_1.CommandItem, { value: option.value, keywords: [option.label], onSelect: (currentValue) => {
|
|
35
35
|
onChange?.(value !== currentValue ? currentValue : '');
|
|
36
36
|
setOpen(false);
|
|
37
37
|
}, children: option.label }, option.value))) })] })] }) })] }));
|