@oneplatformdev/ui 0.1.99-beta.245 → 0.1.99-beta.247
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.
- package/.storybook/Wrappers.js.map +1 -1
- package/Accordion/Accordion.js.map +1 -1
- package/Alert/Alert.js.map +1 -1
- package/Alert/alertVariants.js.map +1 -1
- package/AlertDialog/AlertDialog.js.map +1 -1
- package/AlertDialog/AlertDialog.stories.js +4 -2
- package/AlertDialog/AlertDialog.stories.js.map +1 -1
- package/AlertDialog/AlertDialogRoot.js +20 -18
- package/AlertDialog/AlertDialogRoot.js.map +1 -1
- package/AreaChart/AreaChart.js.map +1 -1
- package/Aside/Aside.js.map +1 -1
- package/Aside/AsideSidebar.js.map +1 -1
- package/AspectRatio/AspectRatio.js.map +1 -1
- package/Avatar/Avatar.js.map +1 -1
- package/Badge/Badge.js.map +1 -1
- package/Badge/badgeVariants.js.map +1 -1
- package/Breadcrumb/Breadcrumb.js.map +1 -1
- package/Button/Button.js +11 -10
- package/Button/Button.js.map +1 -1
- package/Button/Button.stories.js.map +1 -1
- package/Button/Button.utils.js.map +1 -1
- package/Button/ButtonCounterBadge.js.map +1 -1
- package/Button/buttonVariants.js.map +1 -1
- package/ButtonIcon/ButtonIcon.js +22 -19
- package/ButtonIcon/ButtonIcon.js.map +1 -1
- package/ButtonIcon/ButtonIcon.stories.js.map +1 -1
- package/ButtonIcon/buttonIconVariants.js.map +1 -1
- package/CHANGELOG.md +3265 -3241
- package/Calendar/Calendar.js +6 -4
- package/Calendar/Calendar.js.map +1 -1
- package/Card/Card.js.map +1 -1
- package/Carousel/Carousel.js +7 -6
- package/Carousel/Carousel.js.map +1 -1
- package/Chart/Chart.js.map +1 -1
- package/Checkbox/Checkbox.js +1 -0
- package/Checkbox/Checkbox.js.map +1 -1
- package/Checkbox/Checkbox.stories.js.map +1 -1
- package/Collapsible/Collapsible.js.map +1 -1
- package/Combobox/Combobox.js +10 -10
- package/Combobox/Combobox.js.map +1 -1
- package/Combobox/Combobox.stories.js.map +1 -1
- package/Combobox/Combobox.types.js.map +1 -1
- package/Combobox/ComboboxOptionItem.js +20 -19
- package/Combobox/ComboboxOptionItem.js.map +1 -1
- package/Combobox/ComboboxRenderContent.js +15 -14
- package/Combobox/ComboboxRenderContent.js.map +1 -1
- package/Combobox/ComboboxRenderOptions.js +5 -5
- package/Combobox/ComboboxRenderOptions.js.map +1 -1
- package/Combobox/ComboboxRenderTrigger.js +30 -28
- package/Combobox/ComboboxRenderTrigger.js.map +1 -1
- package/Command/Command.js +22 -21
- package/Command/Command.js.map +1 -1
- package/ContextPopover/ContextDropdownMenu.js.map +1 -1
- package/ContextPopover/ContextPopover.js.map +1 -1
- package/ContextPopover/useContextPopoverHandler.js.map +1 -1
- package/DataTable/DataTable.js +26 -24
- package/DataTable/DataTable.js.map +1 -1
- package/DataTable/DataTableColumnFilter.js +7 -6
- package/DataTable/DataTableColumnFilter.js.map +1 -1
- package/DataTable/useDataTable.js.map +1 -1
- package/DatePicker/DatePicker.js +13 -12
- package/DatePicker/DatePicker.js.map +1 -1
- package/Dialog/Dialog.js +17 -16
- package/Dialog/Dialog.js.map +1 -1
- package/Dialog/Dialog.stories.js +15 -14
- package/Dialog/Dialog.stories.js.map +1 -1
- package/Dialog/DialogOverlayScope.js.map +1 -1
- package/Drawer/Drawer.js.map +1 -1
- package/DropdownMenu/DropdownMenu.js.map +1 -1
- package/Dropzone/Dropzone.js.map +1 -1
- package/Dropzone/Dropzone.stories.js.map +1 -1
- package/Dropzone/Dropzone.types.js.map +1 -1
- package/Dropzone/DropzoneFilePreview.js.map +1 -1
- package/Dropzone/DropzoneSinglePickPreview.js.map +1 -1
- package/Dropzone/DropzoneUtils.js.map +1 -1
- package/Form/Form.js +15 -14
- package/Form/Form.js.map +1 -1
- package/Form/FormRenderControl.d.ts.map +1 -1
- package/Form/FormRenderControl.js +17 -15
- package/Form/FormRenderControl.js.map +1 -1
- package/Form/FormRenderControl.types.d.ts +1 -0
- package/Form/FormRenderControl.types.d.ts.map +1 -1
- package/Form/Form_old.js +5 -4
- package/Form/Form_old.js.map +1 -1
- package/FormCheckbox/FormCheckbox.js +4 -4
- package/FormCheckbox/FormCheckbox.js.map +1 -1
- package/FormCombobox/FormCombobox.js +4 -4
- package/FormCombobox/FormCombobox.js.map +1 -1
- package/FormDatePicker/FormDatePicker.js +4 -4
- package/FormDatePicker/FormDatePicker.js.map +1 -1
- package/FormDropzone/FormDropzone.js +3 -3
- package/FormDropzone/FormDropzone.js.map +1 -1
- package/FormInput/FormInput.js +6 -6
- package/FormInput/FormInput.js.map +1 -1
- package/FormInput/FormInput.stories.js.map +1 -1
- package/FormRadio/FormRadio.js.map +1 -1
- package/FormSelect/FormSelect.js +9 -6
- package/FormSelect/FormSelect.js.map +1 -1
- package/FormTextarea/FormTextarea.js +4 -4
- package/FormTextarea/FormTextarea.js.map +1 -1
- package/Header/Header.js.map +1 -1
- package/HoverCard/HoverCard.js.map +1 -1
- package/InfoBlock/InfoBlock.js.map +1 -1
- package/InfoBlock/InfoBlock.stories.js.map +1 -1
- package/InfoBlock/infoBlockVariants.js.map +1 -1
- package/Input/Input.js.map +1 -1
- package/Input/Input.stories.js.map +1 -1
- package/Input/inputVariants.js.map +1 -1
- package/InputOTP/InputOTP.d.ts.map +1 -1
- package/InputOTP/InputOTP.js.map +1 -1
- package/LICENSE +21 -21
- package/Label/Label.js.map +1 -1
- package/Label/labelVariants.js.map +1 -1
- package/LazyLoader/LazyLoader.js +5 -4
- package/LazyLoader/LazyLoader.js.map +1 -1
- package/LoadedIcon/LoadedIcon.js.map +1 -1
- package/LoadingMask/LoadingMask.js.map +1 -1
- package/LoadingMask/RenderLoadingMask.js.map +1 -1
- package/LoadingProgress/LoadingProgress.js.map +1 -1
- package/LoadingProgress/loadingProgressVariants.js.map +1 -1
- package/Menubar/Menubar.js.map +1 -1
- package/NavigationMenu/NavigationMenu.js.map +1 -1
- package/NavigationMenu/navigationMenuVariants.js.map +1 -1
- package/Pagination/Pagination.js +1 -0
- package/Pagination/Pagination.js.map +1 -1
- package/Popover/Popover.js.map +1 -1
- package/Progress/Progress.js.map +1 -1
- package/README.md +7 -7
- package/Radio/Radio.js.map +1 -1
- package/RadioGroup/RadioGroup.js.map +1 -1
- package/Resizable/Resizable.js.map +1 -1
- package/Resizable/Resizable.stories.js.map +1 -1
- package/ScrollArea/ScrollArea.js.map +1 -1
- package/Search/Search.js +9 -9
- package/Search/Search.js.map +1 -1
- package/Search/Search.stories.js.map +1 -1
- package/Select/Select.js +7 -6
- package/Select/Select.js.map +1 -1
- package/Select/Select.stories.js.map +1 -1
- package/Select/SelectRoot.js.map +1 -1
- package/Separator/Separator.js.map +1 -1
- package/Sheet/Sheet.js.map +1 -1
- package/Sidebar/Sidebar.js +21 -20
- package/Sidebar/Sidebar.js.map +1 -1
- package/Skeleton/Skeleton.js.map +1 -1
- package/Slider/Slider.js.map +1 -1
- package/Sonner/Sonner.js.map +1 -1
- package/Switch/Switch.d.ts.map +1 -1
- package/Switch/Switch.js +19 -7
- package/Switch/Switch.js.map +1 -1
- package/Switch/Switch.stories.js +62 -0
- package/Switch/Switch.stories.js.map +1 -0
- package/Table/Table.js.map +1 -1
- package/TablePagination/TablePagination.js +26 -21
- package/TablePagination/TablePagination.js.map +1 -1
- package/Tabs/Tabs.js.map +1 -1
- package/Tabs/TabsRoot.js.map +1 -1
- package/Textarea/Textarea.js.map +1 -1
- package/Textarea/Textarea.stories.js.map +1 -1
- package/Textarea/useAutosizeTextArea.js.map +1 -1
- package/Theme/ThemeModeToggle.js +4 -3
- package/Theme/ThemeModeToggle.js.map +1 -1
- package/Theme/ThemeProvider.js.map +1 -1
- package/Toast/Toast.js.map +1 -1
- package/Toast/toast.constants.js.map +1 -1
- package/Toast/toastVariants.js.map +1 -1
- package/Toast/useToast.js.map +1 -1
- package/Toaster/Toaster.js.map +1 -1
- package/Toggle/Toggle.js.map +1 -1
- package/ToggleGroup/ToggleGroup.js.map +1 -1
- package/Tooltip/Tooltip.js.map +1 -1
- package/Tooltip/TooltipRoot.js.map +1 -1
- package/Tooltip/tooltipVariants.js.map +1 -1
- package/index.js +286 -286
- package/package.json +4 -4
package/Form/Form.js
CHANGED
|
@@ -4,9 +4,10 @@ import { Slot as f } from "@radix-ui/react-slot";
|
|
|
4
4
|
import { Controller as u, useFormContext as F, useFormState as x, FormProvider as I } from "react-hook-form";
|
|
5
5
|
import { cn as a } from "@oneplatformdev/utils";
|
|
6
6
|
import { Label as p } from "../Label/Label.js";
|
|
7
|
-
|
|
7
|
+
import "../Label/labelVariants.js";
|
|
8
|
+
const $ = I, c = s.createContext(
|
|
8
9
|
{}
|
|
9
|
-
),
|
|
10
|
+
), D = ({
|
|
10
11
|
...e
|
|
11
12
|
}) => /* @__PURE__ */ m(c.Provider, { value: { name: e.name }, children: /* @__PURE__ */ m(u, { ...e }) }), d = () => {
|
|
12
13
|
const e = s.useContext(c), t = s.useContext(l), { getFieldState: r } = F(), o = x({ name: e.name }), n = r(e.name, o);
|
|
@@ -24,7 +25,7 @@ const S = I, c = s.createContext(
|
|
|
24
25
|
}, l = s.createContext(
|
|
25
26
|
{}
|
|
26
27
|
);
|
|
27
|
-
function
|
|
28
|
+
function M({ className: e, ...t }) {
|
|
28
29
|
const r = s.useId();
|
|
29
30
|
return /* @__PURE__ */ m(l.Provider, { value: { id: r }, children: /* @__PURE__ */ m(
|
|
30
31
|
"div",
|
|
@@ -35,7 +36,7 @@ function D({ className: e, ...t }) {
|
|
|
35
36
|
}
|
|
36
37
|
) });
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function N({
|
|
39
40
|
className: e,
|
|
40
41
|
...t
|
|
41
42
|
}) {
|
|
@@ -51,7 +52,7 @@ function M({
|
|
|
51
52
|
}
|
|
52
53
|
);
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function w({ ...e }) {
|
|
55
56
|
const { error: t, formItemId: r, formDescriptionId: o, formMessageId: n } = d();
|
|
56
57
|
return /* @__PURE__ */ m(
|
|
57
58
|
f,
|
|
@@ -64,7 +65,7 @@ function N({ ...e }) {
|
|
|
64
65
|
}
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
+
function P({ className: e, ...t }) {
|
|
68
69
|
const { formDescriptionId: r } = d();
|
|
69
70
|
return /* @__PURE__ */ m(
|
|
70
71
|
"p",
|
|
@@ -76,7 +77,7 @@ function w({ className: e, ...t }) {
|
|
|
76
77
|
}
|
|
77
78
|
);
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
+
function y({ className: e, ...t }) {
|
|
80
81
|
const { error: r, formMessageId: o } = d(), n = r ? String(r?.message ?? "") : t.children;
|
|
81
82
|
return n ? /* @__PURE__ */ m(
|
|
82
83
|
"p",
|
|
@@ -90,13 +91,13 @@ function P({ className: e, ...t }) {
|
|
|
90
91
|
) : null;
|
|
91
92
|
}
|
|
92
93
|
export {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
$ as Form,
|
|
95
|
+
w as FormControl,
|
|
96
|
+
P as FormDescription,
|
|
97
|
+
D as FormField,
|
|
98
|
+
M as FormItem,
|
|
99
|
+
N as FormLabel,
|
|
100
|
+
y as FormMessage,
|
|
100
101
|
d as useFormField
|
|
101
102
|
};
|
|
102
103
|
//# sourceMappingURL=Form.js.map
|
package/Form/Form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../src/Form/Form.tsx"],"sourcesContent":["\"use client\"\
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../src/Form/Form.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { Label } from \"../Label\"\n\nconst Form = FormProvider\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue\n)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n }: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState } = useFormContext()\n const formState = useFormState({ name: fieldContext.name })\n const fieldState = getFieldState(fieldContext.name, formState)\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n }\n}\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue\n)\n\nfunction FormItem({ className, ...props }: React.ComponentProps<\"div\">) {\n const id = React.useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n data-slot=\"form-item\"\n className={cn(\"flex flex-col gap-2\", className)}\n {...props}\n />\n </FormItemContext.Provider>\n )\n}\n\nfunction FormLabel({\n className,\n ...props\n }: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { error, formItemId } = useFormField()\n\n return (\n <Label\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\"data-[error=true]:text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n )\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n )\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<\"p\">) {\n const { formDescriptionId } = useFormField()\n\n return (\n <p\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n )\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<\"p\">) {\n const { error, formMessageId } = useFormField()\n const body = error ? String(error?.message ?? \"\") : props.children\n\n if (!body) {\n return null\n }\n\n return (\n <p\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn(\"text-destructive text-sm\", className)}\n {...props}\n >\n {body}\n </p>\n )\n}\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n}\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","body"],"mappings":";;;;;;;AAkBA,MAAMA,IAAOC,GASPC,IAAmBC,EAAM;AAAA,EAC7B,CAAA;AACF,GAEMC,IAAY,CAGhB;AAAA,EACE,GAAGC;AACL,MAEE,gBAAAC,EAACJ,EAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAMG,EAAM,KAAA,GAC9C,UAAA,gBAAAC,EAACC,GAAA,EAAY,GAAGF,GAAO,GACzB,GAIEG,IAAe,MAAM;AACzB,QAAMC,IAAeN,EAAM,WAAWD,CAAgB,GAChDQ,IAAcP,EAAM,WAAWQ,CAAe,GAC9C,EAAE,eAAAC,EAAA,IAAkBC,EAAA,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V,IAAIL;AAAA,MACJ,oBACGD,IAEG,GAAGI,CAAiB,IAAIC,CAAa,KADrC,GAAGD,CAAiB;AAAA,MAG1B,gBAAc,CAAC,CAACJ;AAAA,MACf,GAAGjB;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASwB,EAAgB,EAAE,WAAAV,GAAW,GAAGd,KAAoC;AAC3E,QAAM,EAAE,mBAAAqB,EAAA,IAAsBlB,EAAA;AAE9B,SACE,gBAAAF;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,IAAIoB;AAAA,MACJ,WAAWN,EAAG,iCAAiCD,CAAS;AAAA,MACvD,GAAGd;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASyB,EAAY,EAAE,WAAAX,GAAW,GAAGd,KAAoC;AACvE,QAAM,EAAE,OAAAiB,GAAO,eAAAK,EAAA,IAAkBnB,EAAA,GAC3BuB,IAAOT,IAAQ,OAAOA,GAAO,WAAW,EAAE,IAAIjB,EAAM;AAE1D,SAAK0B,IAKH,gBAAAzB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,IAAIqB;AAAA,MACJ,WAAWP,EAAG,4BAA4BD,CAAS;AAAA,MAClD,GAAGd;AAAA,MAEH,UAAA0B;AAAA,IAAA;AAAA,EAAA,IAVI;AAaX;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormRenderControl.d.ts","sourceRoot":"","sources":["../../src/Form/FormRenderControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAqCnE,eAAO,MAAM,iBAAiB,GAC5B,IAAI,SAAS,WAAW,GAAG,WAAW,EAEtC,OAAO,sBAAsB,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"FormRenderControl.d.ts","sourceRoot":"","sources":["../../src/Form/FormRenderControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAqCnE,eAAO,MAAM,iBAAiB,GAC5B,IAAI,SAAS,WAAW,GAAG,WAAW,EAEtC,OAAO,sBAAsB,CAAC,IAAI,CAAC,4CAgDpC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { FormField as
|
|
3
|
-
import
|
|
1
|
+
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { FormField as h, FormItem as d, FormMessage as f, FormLabel as F } from "./Form.js";
|
|
3
|
+
import "@radix-ui/react-tooltip";
|
|
4
4
|
import { cn as l } from "@oneplatformdev/utils";
|
|
5
5
|
import { Tooltip as P } from "../Tooltip/Tooltip.js";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { cloneElement as b } from "react";
|
|
7
|
+
const N = (n) => {
|
|
8
|
+
const { label: t, tooltip: s, tooltipProps: r } = n, o = /* @__PURE__ */ e(F, { children: t });
|
|
8
9
|
return t ? s ? /* @__PURE__ */ e(
|
|
9
10
|
P,
|
|
10
11
|
{
|
|
@@ -20,10 +21,10 @@ const b = (n) => {
|
|
|
20
21
|
...r?.triggerProps,
|
|
21
22
|
className: l("cursor-help", r?.triggerProps?.className)
|
|
22
23
|
},
|
|
23
|
-
children:
|
|
24
|
+
children: b(o, { className: l("cursor-help", o.props.classNames) })
|
|
24
25
|
}
|
|
25
26
|
) : o : null;
|
|
26
|
-
},
|
|
27
|
+
}, L = (n) => {
|
|
27
28
|
const {
|
|
28
29
|
form: t,
|
|
29
30
|
name: s,
|
|
@@ -32,30 +33,31 @@ const b = (n) => {
|
|
|
32
33
|
tooltipProps: i,
|
|
33
34
|
render: m,
|
|
34
35
|
containerProps: p = {},
|
|
35
|
-
|
|
36
|
+
showErrorMessages: c = !0,
|
|
37
|
+
...a
|
|
36
38
|
} = n;
|
|
37
39
|
return /* @__PURE__ */ e(
|
|
38
|
-
|
|
40
|
+
h,
|
|
39
41
|
{
|
|
40
42
|
control: t.control,
|
|
41
43
|
name: s,
|
|
42
|
-
render: (
|
|
44
|
+
render: (g) => /* @__PURE__ */ u(d, { ...p, children: [
|
|
43
45
|
/* @__PURE__ */ e(
|
|
44
|
-
|
|
46
|
+
N,
|
|
45
47
|
{
|
|
46
48
|
label: r,
|
|
47
49
|
tooltip: o,
|
|
48
50
|
tooltipProps: i
|
|
49
51
|
}
|
|
50
52
|
),
|
|
51
|
-
m(
|
|
52
|
-
/* @__PURE__ */ e(f, {})
|
|
53
|
+
m(g),
|
|
54
|
+
c && /* @__PURE__ */ e(f, {})
|
|
53
55
|
] }),
|
|
54
|
-
...
|
|
56
|
+
...a
|
|
55
57
|
}
|
|
56
58
|
);
|
|
57
59
|
};
|
|
58
60
|
export {
|
|
59
|
-
|
|
61
|
+
L as FormRenderControl
|
|
60
62
|
};
|
|
61
63
|
//# sourceMappingURL=FormRenderControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormRenderControl.js","sources":["../../src/Form/FormRenderControl.tsx"],"sourcesContent":["import { FieldValues } from \"react-hook-form\";\
|
|
1
|
+
{"version":3,"file":"FormRenderControl.js","sources":["../../src/Form/FormRenderControl.tsx"],"sourcesContent":["import { FieldValues } from \"react-hook-form\";\n\nimport { FormField, FormItem, FormLabel, FormMessage } from \"./Form\";\nimport { FormRenderControlProps } from \"./FormRenderControl.types\";\nimport { Tooltip } from \"../Tooltip\";\nimport { cloneElement } from \"react\";\nimport { cn } from \"@oneplatformdev/utils\";\n\ninterface IFormLabelWithTooltipProps<\n Data extends FieldValues = FieldValues,\n> extends Pick<FormRenderControlProps<Data>, 'label' | 'tooltip' | 'tooltipProps'> {\n}\n\nconst FormLabelWithTooltip = <\n Data extends FieldValues = FieldValues,\n>(props: IFormLabelWithTooltipProps<Data>) => {\n const { label, tooltip, tooltipProps } = props;\n const cmp = <FormLabel>{label}</FormLabel>;\n if (!label) return null;\n if (!tooltip) return cmp;\n return (\n <Tooltip\n message={tooltip}\n showQuestionMark\n questionIconSize=\"sm\"\n contentProps={{\n side: \"right\",\n align: \"center\"\n }}\n {...tooltipProps}\n triggerProps={{\n ...tooltipProps?.triggerProps,\n className: cn('cursor-help', tooltipProps?.triggerProps?.className),\n }}\n >\n {cloneElement(cmp, { className: cn('cursor-help', cmp.props.classNames) })}\n </Tooltip>\n )\n}\n\nexport const FormRenderControl = <\n Data extends FieldValues = FieldValues,\n>(\n props: FormRenderControlProps<Data>\n) => {\n const {\n form,\n name,\n label,\n tooltip,\n tooltipProps,\n render,\n containerProps = {},\n showErrorMessages = true,\n ...rest\n } = props;\n return (\n <FormField\n control={form.control}\n name={name}\n render={(params) => (\n <FormItem {...containerProps}>\n <FormLabelWithTooltip\n label={label}\n tooltip={tooltip}\n tooltipProps={tooltipProps}\n />\n {/*{(label || tooltip) && (*/}\n {/* <FormLabel className={cn(\"flex items-center gap-1\")}>*/}\n {/* {label && <span>{label}</span>}*/}\n {/* {tooltip && (*/}\n {/* <Tooltip*/}\n {/* message={tooltip}*/}\n {/* showQuestionMark*/}\n {/* questionIconSize=\"xs\"*/}\n {/* contentProps={{*/}\n {/* side: \"right\",*/}\n {/* align: \"center\"*/}\n {/* }}*/}\n {/* {...props.tooltipProps}*/}\n {/* />*/}\n {/* )}*/}\n {/* </FormLabel>*/}\n {/*)}*/}\n {render(params)}\n {showErrorMessages && <FormMessage/>}\n </FormItem>\n )}\n {...rest}\n />\n );\n};\n"],"names":["FormLabelWithTooltip","props","label","tooltip","tooltipProps","cmp","jsx","FormLabel","Tooltip","cn","cloneElement","FormRenderControl","form","name","render","containerProps","showErrorMessages","rest","FormField","params","jsxs","FormItem","FormMessage"],"mappings":";;;;;;AAaA,MAAMA,IAAuB,CAE3BC,MAA4C;AAC5C,QAAM,EAAE,OAAAC,GAAO,SAAAC,GAAS,cAAAC,EA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ieldValues>
|
|
|
14
14
|
tooltipProps?: Omit<TooltipProps, "message">;
|
|
15
15
|
render: FormRenderProps<Data>;
|
|
16
16
|
containerProps?: HTMLAttributes<HTMLDivElement>;
|
|
17
|
+
showErrorMessages?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export type FormRenderControlExtendProps<Data extends FieldValues = FieldValues> = Omit<FormRenderControlProps<Data>, 'render'>;
|
|
19
20
|
//# sourceMappingURL=FormRenderControl.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormRenderControl.types.d.ts","sourceRoot":"","sources":["../../src/Form/FormRenderControl.types.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,WAAW,EACX,aAAa,EACb,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,WAAW,IAAI,CAAC,EACvD,KAAK,EACL,UAAU,EACV,SAAS,GACV,EAAE;IACD,KAAK,EAAE,qBAAqB,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,UAAU,EAAE,oBAAoB,CAAC;IACjC,SAAS,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;CACrC,KAAK,YAAY,CAAC;AAEnB,MAAM,WAAW,sBAAsB,CACrC,IAAI,SAAS,WAAW,GAAG,WAAW;IAEtC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS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AAI,SAAS,WAAW,GAAG,WAAW,IACpC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAA"}
|
package/Form/Form_old.js
CHANGED
|
@@ -4,9 +4,10 @@ import { Slot as F } from "@radix-ui/react-slot";
|
|
|
4
4
|
import { useFormContext as u, FormProvider as p, Controller as x } from "react-hook-form";
|
|
5
5
|
import { cn as a } from "@oneplatformdev/utils";
|
|
6
6
|
import { Label as I } from "../Label/Label.js";
|
|
7
|
-
|
|
7
|
+
import "../Label/labelVariants.js";
|
|
8
|
+
const M = p, l = m.createContext(
|
|
8
9
|
{}
|
|
9
|
-
),
|
|
10
|
+
), S = ({
|
|
10
11
|
...e
|
|
11
12
|
}) => /* @__PURE__ */ n(l.Provider, { value: { name: e.name }, children: /* @__PURE__ */ n(x, { ...e }) }), c = () => {
|
|
12
13
|
const e = m.useContext(l), t = m.useContext(f), { getFieldState: o, formState: r } = u(), i = o(e.name, r);
|
|
@@ -86,10 +87,10 @@ const w = m.forwardRef(({ className: e, children: t, ...o }, r) => {
|
|
|
86
87
|
});
|
|
87
88
|
w.displayName = "FormMessage";
|
|
88
89
|
export {
|
|
89
|
-
|
|
90
|
+
M as Form,
|
|
90
91
|
g as FormControl,
|
|
91
92
|
N as FormDescription,
|
|
92
|
-
|
|
93
|
+
S as FormField,
|
|
93
94
|
v as FormItem,
|
|
94
95
|
C as FormLabel,
|
|
95
96
|
w as FormMessage,
|
package/Form/Form_old.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form_old.js","sources":["../../src/Form/Form_old.tsx"],"sourcesContent":["'use client';\
|
|
1
|
+
{"version":3,"file":"Form_old.js","sources":["../../src/Form/Form_old.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as LabelPrimitive from '@radix-ui/react-label';\nimport { Slot } from '@radix-ui/react-slot';\nimport {\n Controller,\n ControllerProps,\n FieldPath,\n FieldValues,\n FormProvider,\n useFormContext,\n} from 'react-hook-form';\n\nimport { cn } from '@oneplatformdev/utils';\nimport { Label } from '../Label';\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue\n)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n const fieldState = getFieldState(fieldContext.name, formState)\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n }\n}\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue\n)\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const id = React.useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(\"space-y-1\", className)} {...props} />\n </FormItemContext.Provider>\n )\n})\nFormItem.displayName = \"FormItem\"\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField()\n\n return (\n <Label\n ref={ref}\n data-state={error ? \"invalid\" : \"valid\"}\n className={cn(error && \"text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n )\n})\nFormLabel.displayName = \"FormLabel\"\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ className, ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n data-state={error ? \"invalid\" : \"valid\"}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n className={cn('group/form-control', className)}\n {...props}\n />\n )\n})\nFormControl.displayName = \"FormControl\"\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn(\"text-[0.8rem] text-muted-foreground\", className)}\n {...props}\n />\n )\n})\nFormDescription.displayName = \"FormDescription\"\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField()\n const body = error ? String(error?.message) : children\n\n if (!body) {\n return null\n }\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn(\"text-[0.8rem] font-medium text-destructive\", className)}\n {...props}\n >\n {body}\n </p>\n )\n})\nFormMessage.displayName = \"FormMessage\"\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n}\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body"],"mappings":";;;;;;;AAiBA,MAAMA,IAAOC,G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AO,IAAIS;AAE9C,SAAKC,IAKH,gBAAA1B;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAa;AAAA,MACA,IAAIQ;AAAA,MACJ,WAAWP,EAAG,8CAA8CF,CAAS;AAAA,MACpE,GAAGb;AAAA,MAEH,UAAA2B;AAAA,IAAA;AAAA,EAAA,IAVI;AAaX,CAAC;AACDF,EAAY,cAAc;"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { FormControl as a } from "../Form/Form.js";
|
|
3
|
+
import { FormRenderControl as l } from "../Form/FormRenderControl.js";
|
|
4
4
|
import { CheckboxLabel as k } from "../Checkbox/Checkbox.js";
|
|
5
5
|
const f = (m) => {
|
|
6
6
|
const { form: t, label: c, name: h, onCheckedChange: C, ...r } = m;
|
|
7
7
|
return /* @__PURE__ */ e(
|
|
8
|
-
|
|
8
|
+
l,
|
|
9
9
|
{
|
|
10
10
|
form: t,
|
|
11
11
|
name: h,
|
|
12
|
-
render: ({ field: o }) => /* @__PURE__ */ e(
|
|
12
|
+
render: ({ field: o }) => /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(
|
|
13
13
|
k,
|
|
14
14
|
{
|
|
15
15
|
...o,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormCheckbox.js","sources":["../../src/FormCheckbox/FormCheckbox.tsx"],"sourcesContent":["import { FieldValues } from 'react-hook-form';\
|
|
1
|
+
{"version":3,"file":"FormCheckbox.js","sources":["../../src/FormCheckbox/FormCheckbox.tsx"],"sourcesContent":["import { FieldValues } from 'react-hook-form';\n\nimport { FormControl, FormRenderControl } from '../Form';\n\nimport { FormCheckboxProps } from './FormCheckbox.types';\nimport { CheckboxLabel } from '../Checkbox';\n\n// TODO: move to @oneplatformdev/ui/FormCheckbox\nexport const FormCheckbox = <Data extends FieldValues>(\n\tprops: FormCheckboxProps<Data>\n) => {\n\tconst { form, label, name, onCheckedChange, ...rest } = props;\n\treturn (\n\t\t<FormRenderControl\n\t\t\tform={form}\n\t\t\tname={name}\n\t\t\trender={({ field }) => (\n\t\t\t\t<FormControl>\n\t\t\t\t\t<CheckboxLabel\n\t\t\t\t\t\t{...field}\n\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\tlabel={label}\n\t\t\t\t\t\tchecked={field.value || false}\n\t\t\t\t\t\tonCheckedChange={(v) => {\n\t\t\t\t\t\t\tfield.onChange(v);\n\t\t\t\t\t\t\tonCheckedChange?.(v);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</FormControl>\n\t\t\t)}\n\t\t\t{...rest}\n\t\t/>\n\t);\n};\n"],"names":["FormCheckbox","props","form","label","name","onCheckedChange","rest","jsx","FormRenderControl","field","FormControl","CheckboxLabel","v"],"mappings":";;;;AAQO,MAAMA,IAAe,CAC3BC,MACI;AACJ,QAAM,EAAE,MAAAC,GAAM,OAAAC,GAAO,MAAAC,GAAM,iBAAAC,GAAiB,GAAGC,MAASL;AACxD,SACC,gBAAAM;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,MAAAN;AAAA,MACA,MAAAE;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAK,EAAA,wBACTC,GAAA,EACA,UAAA,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACC,GAAGF;AAAA,UACH,GAAGH;AAAA,UACJ,OAAAH;AAAA,UACA,SAASM,EAAM,SAAS;AAAA,UACxB,iBAAiB,CAACG,MAAM;AACvB,YAAAH,EAAM,SAASG,CAAC,GAChBP,IAAkBO,CAAC;AAAA,UACpB;AAAA,QAAA;AAAA,MAAA,GAEF;AAAA,MAEA,GAAGN;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { FormControl as s } from "../Form/Form.js";
|
|
3
|
+
import { FormRenderControl as b } from "../Form/FormRenderControl.js";
|
|
2
4
|
import { Combobox as m } from "../Combobox/Combobox.js";
|
|
3
|
-
import { FormRenderControl as s } from "../Form/FormRenderControl.js";
|
|
4
|
-
import { FormControl as b } from "../Form/Form.js";
|
|
5
5
|
function x(t) {
|
|
6
6
|
const { form: i, label: p, tooltip: l, tooltipProps: C, name: a, imperativeRef: n, ...e } = t, g = t.type ?? "single";
|
|
7
7
|
return /* @__PURE__ */ r(
|
|
8
|
-
|
|
8
|
+
b,
|
|
9
9
|
{
|
|
10
10
|
form: i,
|
|
11
11
|
label: p,
|
|
12
12
|
tooltip: l,
|
|
13
13
|
tooltipProps: C,
|
|
14
14
|
name: a,
|
|
15
|
-
render: ({ field: o }) => /* @__PURE__ */ r(
|
|
15
|
+
render: ({ field: o }) => /* @__PURE__ */ r(s, { children: g === "multi" ? /* @__PURE__ */ r(
|
|
16
16
|
m,
|
|
17
17
|
{
|
|
18
18
|
...e,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormCombobox.js","sources":["../../src/FormCombobox/FormCombobox.tsx"],"sourcesContent":["import { FormControl, FormRenderControl } from '../Form';\
|
|
1
|
+
{"version":3,"file":"FormCombobox.js","sources":["../../src/FormCombobox/FormCombobox.tsx"],"sourcesContent":["import { FormControl, FormRenderControl } from '../Form';\nimport { Combobox, ComboboxSelectedType } from '../Combobox';\nimport {\n FormComboboxMultiProps, FormComboboxProps,\n FormComboboxSingleProps\n} from './FormCombobox.types';\nimport { FieldValues } from 'react-hook-form';\nimport { JSX } from \"react\";\n\ntype RestOmitedType<T> = Omit<T, 'form' | 'label' | 'tooltip' | 'tooltipProps' | 'name'>;\n\ntype RestPropsType<\n T extends ComboboxSelectedType,\n Data extends FieldValues,\n Node extends object = object,\n> = T extends 'single'\n ? RestOmitedType<FormComboboxSingleProps<Data, Node>>\n : RestOmitedType<FormComboboxMultiProps<Data, Node>>\n\nexport function FormCombobox<\n Data extends FieldValues,\n Node extends object = object\n>(props: FormComboboxSingleProps<Data, Node>): JSX.Element;\nexport function FormCombobox<\n Data extends FieldValues,\n Node extends object = object\n>(props: FormComboboxMultiProps<Data, Node>): JSX.Element;\n\nexport function FormCombobox<\n Data extends object = object,\n Node extends object = object\n>(\n props: FormComboboxProps<Data, Node>\n): JSX.Element {\n const { form, label, tooltip, tooltipProps, name, imperativeRef, ...rest } = props;\n const type = (props.type ?? 'single') as 'single' | 'multi';\n return (\n <FormRenderControl\n form={form}\n label={label}\n tooltip={tooltip}\n tooltipProps={tooltipProps}\n name={name}\n render={({ field }) => (\n <FormControl>\n {type === 'multi' ? (\n <Combobox<Node>\n {...(rest as RestPropsType<'multi', Data, Node>)}\n {...field}\n type=\"multi\"\n imperativeRef={imperativeRef}\n onChange={field.onChange}\n />\n ) : (\n <Combobox<Node>\n {...(rest as RestPropsType<'single', Data, Node>)}\n {...field}\n type=\"single\"\n imperativeRef={imperativeRef}\n onChange={field.onChange}\n />\n )}\n </FormControl>\n )}\n />\n );\n};\n"],"names":["FormCombobox","props","form","label","tooltip","tooltipProps","name","imperativeRef","rest","type","jsx","FormRenderControl","field","FormControl","Combobox"],"mappings":";;;;AA4BO,SAASA,EAIdC,GACa;AACb,QAAM,EAAE,MAAAC,GAAM,OAAAC,GAAO,SAAAC,GAAS,cAAAC,GAAc,MAAAC,GAAM,eAAAC,GAAe,GAAGC,EAAA,IAASP,GACvEQ,IAAQR,EAAM,QAAQ;AAC5B,SACE,gBAAAS;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAT;AAAA,MACA,OAAAC;AAAA,MACA,SAAAC;AAAA,MACA,cAAAC;AAAA,MACA,MAAAC;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAM,EAAA,MACT,gBAAAF,EAACG,GAAA,EACE,gBAAS,UACR,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACE,GAAIN;AAAA,UACJ,GAAGI;AAAA,UACJ,MAAK;AAAA,UACL,eAAAL;AAAA,UACA,UAAUK,EAAM;AAAA,QAAA;AAAA,MAAA,IAGlB,gBAAAF;AAAA,QAACI;AAAA,QAAA;AAAA,UACE,GAAIN;AAAA,UACJ,GAAGI;AAAA,UACJ,MAAK;AAAA,UACL,eAAAL;AAAA,UACA,UAAUK,EAAM;AAAA,QAAA;AAAA,MAAA,EAClB,CAEJ;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { DatePicker as s } from "../DatePicker/DatePicker.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FormControl as C } from "../Form/Form.js";
|
|
4
|
+
import { FormRenderControl as D } from "../Form/FormRenderControl.js";
|
|
5
5
|
const P = (t) => {
|
|
6
6
|
const { form: n, name: m, tooltip: a, tooltipProps: p, label: i, onDateChange: l, ...c } = t;
|
|
7
7
|
return /* @__PURE__ */ r(
|
|
8
|
-
|
|
8
|
+
D,
|
|
9
9
|
{
|
|
10
10
|
form: n,
|
|
11
11
|
name: m,
|
|
12
12
|
tooltip: a,
|
|
13
13
|
tooltipProps: p,
|
|
14
14
|
label: i,
|
|
15
|
-
render: ({ field: o }) => /* @__PURE__ */ r(
|
|
15
|
+
render: ({ field: o }) => /* @__PURE__ */ r(C, { children: /* @__PURE__ */ r(
|
|
16
16
|
s,
|
|
17
17
|
{
|
|
18
18
|
...o,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormDatePicker.js","sources":["../../src/FormDatePicker/FormDatePicker.tsx"],"sourcesContent":["'use client';\
|
|
1
|
+
{"version":3,"file":"FormDatePicker.js","sources":["../../src/FormDatePicker/FormDatePicker.tsx"],"sourcesContent":["'use client';\n\nimport { DatePicker } from '../DatePicker';\nimport { FormControl, FormRenderControl } from '../Form';\nimport { FieldValues } from 'react-hook-form';\nimport { FormDatePickerProps } from './FormDatePicker.types';\n\n// TODO: add description\nexport const FormDatePicker = <Data extends FieldValues>(\n props: FormDatePickerProps<Data>\n) => {\n const { form, name, tooltip, tooltipProps, label, onDateChange, ...rest } = props;\n return (\n <FormRenderControl\n form={form}\n name={name}\n tooltip={tooltip}\n tooltipProps={tooltipProps}\n label={label}\n render={({ field }) => (\n <FormControl>\n <DatePicker\n { ...field }\n { ...rest }\n selectedDate={field.value}\n onDateChange={(date: Date | undefined) => {\n field.onChange(date);\n onDateChange?.(date);\n }}\n />\n </FormControl>\n )}\n />\n );\n};\n"],"names":["FormDatePicker","props","form","name","tooltip","tooltipProps","label","onDateChange","rest","jsx","FormRenderControl","field","FormControl","DatePicker","date"],"mappings":";;;;AAQO,MAAMA,IAAiB,CAC5BC,MACG;AACH,QAAM,EAAE,MAAAC,GAAM,MAAAC,GAAM,SAAAC,GAAS,cAAAC,GAAc,OAAAC,GAAO,cAAAC,GAAc,GAAGC,EAAA,IAASP;AAC5E,SACE,gBAAAQ;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAR;AAAA,MACA,MAAAC;AAAA,MACA,SAAAC;AAAA,MACA,cAAAC;AAAA,MACA,OAAAC;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAK,EAAA,wBACRC,GAAA,EACC,UAAA,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACG,GAAGF;AAAA,UACH,GAAGH;AAAA,UACL,cAAcG,EAAM;AAAA,UACpB,cAAc,CAACG,MAA2B;AACxC,YAAAH,EAAM,SAASG,CAAI,GACnBP,IAAeO,CAAI;AAAA,UACrB;AAAA,QAAA;AAAA,MAAA,EACF,CACF;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { FormControl as a } from "../Form/Form.js";
|
|
3
3
|
import { FormRenderControl as s } from "../Form/FormRenderControl.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Dropzone as f } from "../Dropzone/Dropzone.js";
|
|
5
5
|
const d = (n) => {
|
|
6
6
|
const { form: t, label: e, tooltip: m, tooltipProps: p, name: l, ...i } = n;
|
|
7
7
|
return /* @__PURE__ */ o(
|
|
@@ -12,7 +12,7 @@ const d = (n) => {
|
|
|
12
12
|
tooltip: m,
|
|
13
13
|
tooltipProps: p,
|
|
14
14
|
name: l,
|
|
15
|
-
render: ({ field: r }) => /* @__PURE__ */ o(
|
|
15
|
+
render: ({ field: r }) => /* @__PURE__ */ o(a, { children: /* @__PURE__ */ o(f, { ...i, ...r, onChangeValue: r.onChange }) })
|
|
16
16
|
}
|
|
17
17
|
);
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormDropzone.js","sources":["../../src/FormDropzone/FormDropzone.tsx"],"sourcesContent":["import { FormControl, FormRenderControl } from '../Form';\
|
|
1
|
+
{"version":3,"file":"FormDropzone.js","sources":["../../src/FormDropzone/FormDropzone.tsx"],"sourcesContent":["import { FormControl, FormRenderControl } from '../Form';\nimport { Dropzone } from '../Dropzone';\nimport { FieldValues } from 'react-hook-form';\nimport { FormDropzoneProps } from './FormDropzone.types';\n\nexport const FormDropzone = <Data extends FieldValues>(\n props: FormDropzoneProps<Data>\n) => {\n const { form, label, tooltip, tooltipProps, name, ...rest } = props;\n\n return (\n <FormRenderControl\n form={form}\n label={label}\n tooltip={tooltip}\n tooltipProps={tooltipProps}\n name={name}\n render={({ field }) => (\n <FormControl>\n <Dropzone {...rest} {...field} onChangeValue={field.onChange} />\n </FormControl>\n )}\n />\n );\n};\n"],"names":["FormDropzone","props","form","label","tooltip","tooltipProps","name","rest","jsx","FormRenderControl","field","FormControl","Dropzone"],"mappings":";;;;AAKO,MAAMA,IAAe,CAC1BC,MACG;AACH,QAAM,EAAE,MAAAC,GAAM,OAAAC,GAAO,SAAAC,GAAS,cAAAC,GAAc,MAAAC,GAAM,GAAGC,MAASN;AAE9D,SACE,gBAAAO;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAP;AAAA,MACA,OAAAC;AAAA,MACA,SAAAC;AAAA,MACA,cAAAC;AAAA,MACA,MAAAC;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAI,EAAA,wBACRC,GAAA,EACC,UAAA,gBAAAH,EAACI,GAAA,EAAU,GAAGL,GAAO,GAAGG,GAAO,eAAeA,EAAM,UAAU,EAAA,CAChE;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
package/FormInput/FormInput.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { FormControl as S } from "../Form/Form.js";
|
|
3
3
|
import { FormRenderControl as V } from "../Form/FormRenderControl.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Input as j } from "../Input/Input.js";
|
|
5
|
+
import { forwardRef as q } from "react";
|
|
6
6
|
function w(D, o) {
|
|
7
7
|
const { form: a, tooltip: x, tooltipProps: P, label: b, name: u, maxLength: s, counter: y, onChange: C, onBlur: F, onPaste: A, style: I, onPastePrepare: p, ...B } = D;
|
|
8
8
|
return /* @__PURE__ */ m(
|
|
@@ -13,8 +13,8 @@ function w(D, o) {
|
|
|
13
13
|
tooltip: x,
|
|
14
14
|
tooltipProps: P,
|
|
15
15
|
label: b,
|
|
16
|
-
render: ({ field: n, fieldState: R }) => /* @__PURE__ */ m(
|
|
17
|
-
|
|
16
|
+
render: ({ field: n, fieldState: R }) => /* @__PURE__ */ m(S, { children: /* @__PURE__ */ m(
|
|
17
|
+
j,
|
|
18
18
|
{
|
|
19
19
|
...n,
|
|
20
20
|
...B,
|
|
@@ -62,7 +62,7 @@ function w(D, o) {
|
|
|
62
62
|
}
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
-
const G =
|
|
65
|
+
const G = q(w);
|
|
66
66
|
export {
|
|
67
67
|
G as FormInput
|
|
68
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormInput.js","sources":["../../src/FormInput/FormInput.tsx"],"sourcesContent":["import { FormControl, FormRenderControl } from '../Form';\
|
|
1
|
+
{"version":3,"file":"FormInput.js","sources":["../../src/FormInput/FormInput.tsx"],"sourcesContent":["import { FormControl, FormRenderControl } from '../Form';\nimport { Input } from '../Input';\nimport { FormInputProps } from './FormInput.types';\nimport { FieldValues, Path, PathValue } from 'react-hook-form';\nimport { forwardRef, ReactElement, Ref, RefObject } from 'react';\n\n// TODO: add description\n// export const FormInput = <Data extends FieldValues>(\n// props: FormInputProps<Data> & { inputRef?: Ref<HTMLInputElement> }\n// ) => {\n// const { inputRef, form, label, name, onChange, onBlur, style, ...rest } =\n// props;\n// return (\n// <FormRenderControl\n// form={form}\n// name={name}\n// label={label}\n// render={({ field }) => (\n// <FormControl>\n// <Input\n// {...field}\n// {...rest}\n// ref={(el) => {\n// field.ref(el);\n// if (typeof inputRef === 'function') {\n// inputRef(el);\n// } else if (inputRef) {\n// (inputRef as RefObject<HTMLInputElement | null>).current = el;\n// }\n// }}\n// style={style}\n// value={field.value || ''}\n// onChange={(...rest) => {\n// field.onChange?.(...rest);\n// onChange?.(...rest);\n// }}\n// onBlur={(...rest) => {\n// field.onBlur?.();\n// onBlur?.(...rest);\n// }}\n// />\n// </FormControl>\n// )}\n// />\n// );\n// };\n\nfunction FormInputInner<Data extends FieldValues>(\n props: FormInputProps<Data>,\n ref: Ref<HTMLInputElement>\n) {\n const { form, tooltip, tooltipProps, label, name, maxLength, counter, onChange, onBlur, onPaste, style, onPastePrepare, ...rest } = props;\n return (\n <FormRenderControl\n form={form}\n name={name}\n tooltip={tooltip}\n tooltipProps={tooltipProps}\n label={label}\n render={({ field, fieldState }) => (\n <FormControl>\n <Input\n {...field}\n {...rest}\n counter={!!fieldState.error ? false : counter}\n maxLength={maxLength}\n ref={(el) => {\n field.ref(el);\n if (typeof ref === 'function') {\n ref(el);\n } else if (ref) {\n (ref as RefObject<HTMLInputElement | null>).current = el;\n }\n }}\n style={style}\n value={field.value || ''}\n onChange={(...rest) => {\n field.onChange?.(...rest);\n onChange?.(...rest);\n }}\n onPaste={(e) => {\n const pasted = e.clipboardData.getData('text');\n const input = e.currentTarget;\n\n const start = input.selectionStart ?? input.value.length;\n const end = input.selectionEnd ?? input.value.length;\n\n const current = input.value;\n\n let next = current.slice(0, start) + pasted + current.slice(end);\n\n if (onPastePrepare) {\n next = onPastePrepare(next, e);\n }\n\n if (typeof maxLength !== 'number') {\n e.preventDefault();\n\n form.setValue(name, next as PathValue<Data, Path<Data>>, {\n shouldDirty: true,\n shouldTouch: true,\n });\n\n return;\n }\n\n const before = current.slice(0, start);\n const after = current.slice(end);\n\n const available = maxLength - (before.length + after.length);\n\n if (available <= 0) {\n e.preventDefault();\n return;\n }\n\n const limitedPaste = pasted.slice(0, available);\n const limitedNext = before + limitedPaste + after;\n\n e.preventDefault();\n\n form.setValue(name, limitedNext as PathValue<Data, Path<Data>>, {\n shouldDirty: true,\n shouldTouch: true,\n });\n\n requestAnimationFrame(() => {\n input.setSelectionRange(\n before.length + limitedPaste.length,\n before.length + limitedPaste.length\n );\n });\n }}\n onBlur={(...rest) => {\n field.onBlur?.();\n onBlur?.(...rest);\n }}\n />\n </FormControl>\n )}\n />\n );\n}\n\nexport const FormInput = forwardRef(FormInputInner) as <Data extends FieldValues>(\n props: FormInputProps<Data> & { ref?: Ref<HTMLInputElement> }\n) => ReactElement;\n"],"names":["FormInputInner","props","ref","form","tooltip","tooltipProps","label","name","maxLength","counter","onChange","onBlur","onPaste","style","onPastePrepare","rest","jsx","FormRenderControl","field","fieldState","FormControl","Input","el","e","pasted","input","start","end","current","next","before","after","available","limitedPaste","limitedNext","FormInput","forwardRef"],"mappings":";;;;;AA+CA,SAASA,EACPC,GACAC,GACA;AACA,QAAM,EAAE,MAAAC,GAAM,SAAAC,GAAS,cAAAC,GAAc,OAAAC,GAAO,MAAAC,GAAM,WAAAC,GAAW,SAAAC,GAAS,UAAAC,GAAU,QAAAC,GAAQ,SAAAC,GAAS,OAAAC,GAAO,gBAAAC,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AG,GAEzBK,IAAYxB,KAAasB,EAAO,SAASC,EAAM;AAErD,gBAAIC,KAAa,GAAG;AAClB,cAAAT,EAAE,eAAA;AACF;AAAA,YACF;AAEA,kBAAMU,IAAeT,EAAO,MAAM,GAAGQ,CAAS,GACxCE,IAAcJ,IAASG,IAAeF;AAE5C,YAAAR,EAAE,eAAA,GAEFpB,EAAK,SAASI,GAAM2B,GAA4C;AAAA,cAC9D,aAAa;AAAA,cACb,aAAa;AAAA,YAAA,CACd,GAED,sBAAsB,MAAM;AAC1B,cAAAT,EAAM;AAAA,gBACJK,EAAO,SAASG,EAAa;AAAA,gBAC7BH,EAAO,SAASG,EAAa;AAAA,cAAA;AAAA,YAEjC,CAAC;AAAA,UACH;AAAA,UACA,QAAQ,IAAIlB,MAAS;AACnB,YAAAG,EAAM,SAAA,GACNP,IAAS,GAAGI,CAAI;AAAA,UAClB;AAAA,QAAA;AAAA,MAAA,EACF,CACF;AAAA,IAAA;AAAA,EAAA;AAIR;AAEO,MAAMoB,IAAYC,EAAWpC,CAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormInput.stories.js","sources":["../../src/FormInput/FormInput.stories.tsx"],"sourcesContent":["import React from 'react';\
|
|
1
|
+
{"version":3,"file":"FormInput.stories.js","sources":["../../src/FormInput/FormInput.stories.tsx"],"sourcesContent":["import React from 'react';\nimport type { Meta, StoryObj } from '@storybook/react';\nimport { FormProvider, useForm } from 'react-hook-form';\n\nimport { FormInput } from './FormInput';\n\ntype FormValues = {\n name: string;\n};\n\ntype ControlledProps = Omit<\n React.ComponentProps<typeof FormInput<FormValues>>,\n 'form' | 'name'\n> & {\n initialValue?: string;\n};\n\nfunction ControlledFormInput({ initialValue = '', ...args }: ControlledProps) {\n const form = useForm<FormValues>({\n defaultValues: {\n name: initialValue,\n },\n });\n\n const value = form.watch('name');\n const tooltip = \"UX/UI принципи, композиція, типографіка, колір, дизайн-системи та робота з інтерфейсами\"\n return (\n <FormProvider {...form}>\n <div className=\"max-w-sm space-y-3\">\n <FormInput<FormValues>\n form={form}\n name=\"name\"\n counter\n maxLength={255}\n tooltip={tooltip}\n label={\"Label\"}\n />\n\n <div className=\"text-xs text-muted-foreground\">\n value: <span className=\"font-mono\">{value}</span>\n </div>\n\n <div className=\"text-xs text-muted-foreground\">\n length: <span className=\"font-mono\">\n {value?.length ?? 0}\n </span>\n </div>\n </div>\n </FormProvider>\n );\n}\n\nconst meta = {\n title: 'FormInput',\n component: FormInput,\n parameters: {\n layout: 'centered',\n },\n args: {\n label: 'Input label',\n placeholder: 'Type something...',\n disabled: false,\n },\n argTypes: {\n form: { control: false },\n name: { control: false },\n onChange: { control: false },\n onBlur: { control: false },\n onPaste: { control: false },\n onPastePrepare: { control: false },\n },\n decorators: [\n (Story) => (\n <div className=\"p-6 w-[420px]\">\n <Story />\n </div>\n ),\n ],\n} satisfies Meta<typeof FormInput>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {\n render: (args) => <ControlledFormInput {...args} />,\n};\n"],"names":["ControlledFormInput","initialValue","args","form","useForm","value","FormProvider","jsxs","jsx","FormInput","meta","Story","Default"],"mappings":";;;AAiBA,SAASA,EAAoB,EAAE,cAAAC,IAAe,IAAI,GAAGC,KAAyB;AAC5E,QAAMC,IAAOC,EAAoB;AAAA,IAC/B,eAAe;AAAA,MACb,MAAMH;AAAA,IAAA;AAAA,EACR,CACD,GAEKI,IAAQF,EAAK,MAAM,MAAM;AAE/B,2BACGG,GAAA,EAAc,GAAGH,GAChB,UAAA,gBAAAI,EAAC,OAAA,EAAI,WAAU,sBACb,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAAN;AAAA,QACA,MAAK;AAAA,QACL,SAAO;AAAA,QACP,WAAW;AAAA,QACX,SATQ;AAAA,QAUR,OAAO;AAAA,MAAA;AAAA,IAAA;AAAA,IAGT,gBAAAI,EAAC,OAAA,EAAI,WAAU,iCAAgC,UAAA;AAAA,MAAA;AAAA,MACtC,gBAAAC,EAAC,QAAA,EAAK,WAAU,aAAa,UAAAH,EAAA,CAAM;AAAA,IAAA,GAC5C;AAAA,IAEA,gBAAAE,EAAC,OAAA,EAAI,WAAU,iCAAgC,UAAA;AAAA,MAAA;AAAA,wBACpC,QAAA,EAAK,WAAU,aACrB,UAAAF,GAAO,UAAU,EAAA,CACpB;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ;AAEA,MAAMK,IAAO;AAAA,EACX,OAAO;AAAA,EACP,WAAWD;AAAA,EACX,YAAY;AAAA,IACV,QAAQ;AAAA,EAAA;AAAA,EAEV,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,EAAA;AAAA,EAEZ,UAAU;AAAA,IACR,MAAM,EAAE,SAAS,GAAA;AAAA,IACjB,MAAM,EAAE,SAAS,GAAA;AAAA,IACjB,UAAU,EAAE,SAAS,GAAA;AAAA,IACrB,QAAQ,EAAE,SAAS,GAAA;AAAA,IACnB,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,gBAAgB,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAEnC,YAAY;AAAA,IACV,CAACE,MACC,gBAAAH,EAAC,OAAA,EAAI,WAAU,iBACb,UAAA,gBAAAA,EAACG,KAAM,EAAA,CACT;AAAA,EAAA;AAGN,GAMaC,IAAiB;AAAA,EAC5B,QAAQ,CAACV,MAAS,gBAAAM,EAACR,GAAA,EAAqB,GAAGE,EAAA,CAAM;AACnD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormRadio.js","sources":["../../src/FormRadio/FormRadio.tsx"],"sourcesContent":["import { FieldValues } from 'react-hook-form';\
|
|
1
|
+
{"version":3,"file":"FormRadio.js","sources":["../../src/FormRadio/FormRadio.tsx"],"sourcesContent":["import { FieldValues } from 'react-hook-form';\n\nimport { FormControl, FormItem } from '../Form/Form';\nimport { FormRenderControl } from '../Form/FormRenderControl';\nimport { Radio } from '../Radio';\n\nimport type { FormRadioGroupProps } from './FormRadio.types.ts';\n\nexport const FormRadio = <Data extends FieldValues>(\n props: FormRadioGroupProps<Data>\n) => {\n const {\n form,\n name,\n label,\n onValueChange,\n value,\n defaultValue,\n renderOption,\n ...rest\n } = props;\n return (\n <FormRenderControl\n form={form}\n name={name}\n label={label}\n render={({ field }) => (\n <FormControl>\n <Radio\n {...field}\n {...rest}\n defaultValue={defaultValue || field.value}\n value={value || field.value}\n onValueChange={(value) => {\n field.onChange(value);\n onValueChange?.(value);\n }}\n renderOption={(option, DefaultOptionComponent) => {\n return (\n <FormItem key={option.value}>\n <FormControl>\n {renderOption?.(option, DefaultOptionComponent) || (\n <DefaultOptionComponent {...option} />\n )}\n </FormControl>\n </FormItem>\n );\n }}\n />\n </FormControl>\n )}\n />\n );\n};\n"],"names":["FormRadio","props","form","name","label","onValueChange","value","defaultValue","renderOption","rest","jsx","FormRenderControl","field","FormControl","Radio","option","DefaultOptionComponent","FormItem"],"mappings":";;;;AAQO,MAAMA,IAAY,CACvBC,MACG;AACH,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,eAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,IACDR;AACJ,SACE,gBAAAS;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAT;AAAA,MACA,MAAAC;AAAA,MACA,OAAAC;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAQ,EAAA,wBACRC,GAAA,EACC,UAAA,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACE,GAAGF;AAAA,UACH,GAAGH;AAAA,UACJ,cAAcF,KAAgBK,EAAM;AAAA,UACpC,OAAON,KAASM,EAAM;AAAA,UACtB,eAAe,CAACN,MAAU;AACxB,YAAAM,EAAM,SAASN,CAAK,GACpBD,IAAgBC,CAAK;AAAA,UACvB;AAAA,UACA,cAAc,CAACS,GAAQC,MAEnB,gBAAAN,EAACO,GAAA,EACC,UAAA,gBAAAP,EAACG,GAAA,EACE,cAAeE,GAAQC,CAAsB,KAC5C,gBAAAN,EAACM,KAAwB,GAAGD,EAAA,CAAQ,GAExC,EAAA,GALaA,EAAO,KAMtB;AAAA,QAEJ;AAAA,MAAA,EACF,CACF;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|