@ensi-platform/admin-ui 0.10.0 → 0.11.0
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/dist/{Component-BjITARbg.js → Component-6rieHJdg.js} +2 -2
- package/dist/{Component-BjITARbg.js.map → Component-6rieHJdg.js.map} +1 -1
- package/dist/{Component-DxkpQKZ9.js → Component-BH5skHn_.js} +2 -2
- package/dist/{Component-DxkpQKZ9.js.map → Component-BH5skHn_.js.map} +1 -1
- package/dist/{Component-D9cY4WmP.js → Component-BZqLGwzc.js} +2 -2
- package/dist/{Component-D9cY4WmP.js.map → Component-BZqLGwzc.js.map} +1 -1
- package/dist/{Component-DcSDEfYC.js → Component-C4vHIDMZ.js} +3 -3
- package/dist/{Component-DcSDEfYC.js.map → Component-C4vHIDMZ.js.map} +1 -1
- package/dist/{Component-c2va6Tzq.js → Component-CkazNd13.js} +2 -2
- package/dist/{Component-c2va6Tzq.js.map → Component-CkazNd13.js.map} +1 -1
- package/dist/{Component-BO5LvfoO.js → Component-DH7wdC3G.js} +3 -3
- package/dist/{Component-BO5LvfoO.js.map → Component-DH7wdC3G.js.map} +1 -1
- package/dist/{Component-Cxk1CLsH.js → Component-DOlDNQnu.js} +3 -3
- package/dist/{Component-Cxk1CLsH.js.map → Component-DOlDNQnu.js.map} +1 -1
- package/dist/{Component-BMol_xnR.js → Component-DpACJ8IJ.js} +2 -2
- package/dist/{Component-BMol_xnR.js.map → Component-DpACJ8IJ.js.map} +1 -1
- package/dist/{Component-CD81ynoG.js → Component-IFlvrceZ.js} +3 -3
- package/dist/{Component-CD81ynoG.js.map → Component-IFlvrceZ.js.map} +1 -1
- package/dist/Upload-Bi4Xl-j5.js +120 -0
- package/dist/Upload-Bi4Xl-j5.js.map +1 -0
- package/dist/action-popup/index.js +2 -2
- package/dist/active-filters/index.js +2 -2
- package/dist/arrangement-settings/index.js +2 -2
- package/dist/assets/index.css +1 -1
- package/dist/assets/index15.css +1 -1
- package/dist/assets/index16.css +1 -1
- package/dist/assets/index17.css +1 -1
- package/dist/assets/index18.css +1 -1
- package/dist/assets/index19.css +1 -1
- package/dist/assets/index20.css +1 -1
- package/dist/assets/index21.css +1 -1
- package/dist/assets/index22.css +1 -1
- package/dist/assets/index23.css +1 -1
- package/dist/assets/index24.css +1 -1
- package/dist/assets/index25.css +1 -1
- package/dist/assets/index26.css +1 -1
- package/dist/assets/index27.css +1 -1
- package/dist/assets/index28.css +1 -1
- package/dist/assets/index29.css +1 -1
- package/dist/assets/index30.css +1 -1
- package/dist/assets/index31.css +1 -1
- package/dist/assets/index32.css +1 -0
- package/dist/assets/index33.css +1 -0
- package/dist/assets/index8.css +1 -1
- package/dist/assets/index9.css +1 -1
- package/dist/autocomplete/index.js +2 -2
- package/dist/autocomplete-async/index.js +2 -2
- package/dist/bottom-sheet/index.js +2 -2
- package/dist/cascade-menu/index.js +3 -3
- package/dist/checkbox/index.js +1 -1
- package/dist/checkbox-group/index.js +1 -1
- package/dist/color-picker/Component.d.ts +5 -0
- package/dist/color-picker/Component.d.ts.map +1 -0
- package/dist/color-picker/FormColorPicker.d.ts +6 -0
- package/dist/color-picker/FormColorPicker.d.ts.map +1 -0
- package/dist/color-picker/index.d.ts +4 -0
- package/dist/color-picker/index.d.ts.map +1 -0
- package/dist/color-picker/index.js +347 -0
- package/dist/color-picker/index.js.map +1 -0
- package/dist/color-picker/theme.d.ts +6 -0
- package/dist/color-picker/theme.d.ts.map +1 -0
- package/dist/color-picker/types.d.ts +58 -0
- package/dist/color-picker/types.d.ts.map +1 -0
- package/dist/color-picker/utils.d.ts +23 -0
- package/dist/color-picker/utils.d.ts.map +1 -0
- package/dist/combobox/index.js +4 -4
- package/dist/copy-button/index.js +1 -1
- package/dist/data-table/index.js +3 -3
- package/dist/date-picker/index.js +4 -4
- package/dist/date-range-picker/index.js +4 -4
- package/dist/drawer/index.js +1 -1
- package/dist/dropzone/Component.d.ts +14 -0
- package/dist/dropzone/Component.d.ts.map +1 -0
- package/dist/dropzone/FormDropzone.d.ts +6 -0
- package/dist/dropzone/FormDropzone.d.ts.map +1 -0
- package/dist/dropzone/__tests__/helpers.d.ts +37 -0
- package/dist/dropzone/__tests__/helpers.d.ts.map +1 -0
- package/dist/dropzone/components/Action/index.d.ts +14 -0
- package/dist/dropzone/components/Action/index.d.ts.map +1 -0
- package/dist/dropzone/components/ActionSlot/index.d.ts +10 -0
- package/dist/dropzone/components/ActionSlot/index.d.ts.map +1 -0
- package/dist/dropzone/components/FileCopy/index.d.ts +7 -0
- package/dist/dropzone/components/FileCopy/index.d.ts.map +1 -0
- package/dist/dropzone/components/FileListDrag/index.d.ts +11 -0
- package/dist/dropzone/components/FileListDrag/index.d.ts.map +1 -0
- package/dist/dropzone/components/FileRows/index.d.ts +9 -0
- package/dist/dropzone/components/FileRows/index.d.ts.map +1 -0
- package/dist/dropzone/components/FileSkeletons/index.d.ts +8 -0
- package/dist/dropzone/components/FileSkeletons/index.d.ts.map +1 -0
- package/dist/dropzone/components/GridItem/index.d.ts +7 -0
- package/dist/dropzone/components/GridItem/index.d.ts.map +1 -0
- package/dist/dropzone/components/GridList/index.d.ts +7 -0
- package/dist/dropzone/components/GridList/index.d.ts.map +1 -0
- package/dist/dropzone/components/Grip/index.d.ts +7 -0
- package/dist/dropzone/components/Grip/index.d.ts.map +1 -0
- package/dist/dropzone/components/Item/index.d.ts +7 -0
- package/dist/dropzone/components/Item/index.d.ts.map +1 -0
- package/dist/dropzone/components/ItemRoot/index.d.ts +8 -0
- package/dist/dropzone/components/ItemRoot/index.d.ts.map +1 -0
- package/dist/dropzone/components/List/index.d.ts +7 -0
- package/dist/dropzone/components/List/index.d.ts.map +1 -0
- package/dist/dropzone/components/Preview/index.d.ts +6 -0
- package/dist/dropzone/components/Preview/index.d.ts.map +1 -0
- package/dist/dropzone/components/Progress/index.d.ts +7 -0
- package/dist/dropzone/components/Progress/index.d.ts.map +1 -0
- package/dist/dropzone/components/Quota/index.d.ts +9 -0
- package/dist/dropzone/components/Quota/index.d.ts.map +1 -0
- package/dist/dropzone/components/SelectionMark/index.d.ts +5 -0
- package/dist/dropzone/components/SelectionMark/index.d.ts.map +1 -0
- package/dist/dropzone/components/TypeMark/index.d.ts +5 -0
- package/dist/dropzone/components/TypeMark/index.d.ts.map +1 -0
- package/dist/dropzone/components/Zone/index.d.ts +34 -0
- package/dist/dropzone/components/Zone/index.d.ts.map +1 -0
- package/dist/dropzone/components/ZoneSkeleton/index.d.ts +3 -0
- package/dist/dropzone/components/ZoneSkeleton/index.d.ts.map +1 -0
- package/dist/dropzone/hooks/useDropzoneFiles.d.ts +30 -0
- package/dist/dropzone/hooks/useDropzoneFiles.d.ts.map +1 -0
- package/dist/dropzone/hooks/useDropzoneFocus.d.ts +18 -0
- package/dist/dropzone/hooks/useDropzoneFocus.d.ts.map +1 -0
- package/dist/dropzone/hooks/useDropzoneSelection.d.ts +15 -0
- package/dist/dropzone/hooks/useDropzoneSelection.d.ts.map +1 -0
- package/dist/dropzone/hooks/useDropzoneUploads.d.ts +27 -0
- package/dist/dropzone/hooks/useDropzoneUploads.d.ts.map +1 -0
- package/dist/dropzone/hooks/useFileList/index.d.ts +23 -0
- package/dist/dropzone/hooks/useFileList/index.d.ts.map +1 -0
- package/dist/dropzone/index.d.ts +4 -0
- package/dist/dropzone/index.d.ts.map +1 -0
- package/dist/dropzone/index.js +1516 -0
- package/dist/dropzone/index.js.map +1 -0
- package/dist/dropzone/theme.d.ts +6 -0
- package/dist/dropzone/theme.d.ts.map +1 -0
- package/dist/dropzone/types.d.ts +240 -0
- package/dist/dropzone/types.d.ts.map +1 -0
- package/dist/dropzone/utils.d.ts +123 -0
- package/dist/dropzone/utils.d.ts.map +1 -0
- package/dist/filters/index.js +1 -1
- package/dist/form/hooks/useFieldHook.d.ts +4 -2
- package/dist/form/hooks/useFieldHook.d.ts.map +1 -1
- package/dist/form/index.js +2 -2
- package/dist/grid-layout/index.js +1 -1
- package/dist/hooks-CekMiYbX.js +91 -0
- package/dist/hooks-CekMiYbX.js.map +1 -0
- package/dist/icons/File.d.ts +7 -0
- package/dist/icons/File.d.ts.map +1 -0
- package/dist/icons/ListChecks.d.ts +8 -0
- package/dist/icons/ListChecks.d.ts.map +1 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/icons/index.js +83 -145
- package/dist/icons/index.js.map +1 -1
- package/dist/{index-BXlN61PG.js → index-BccXGF9t.js} +2 -2
- package/dist/{index-BXlN61PG.js.map → index-BccXGF9t.js.map} +1 -1
- package/dist/{index-CDCqZ3um.js → index-C_oo7Xm5.js} +3 -3
- package/dist/{index-CDCqZ3um.js.map → index-C_oo7Xm5.js.map} +1 -1
- package/dist/{index-CdAE-ZaU.js → index-DxsuVBkE.js} +4 -4
- package/dist/{index-CdAE-ZaU.js.map → index-DxsuVBkE.js.map} +1 -1
- package/dist/input/index.js +2 -2
- package/dist/loader/index.js +2 -2
- package/dist/menu-list/index.js +1 -1
- package/dist/{metrics-B5YsELiI.js → metrics-Cv_jrA15.js} +2 -2
- package/dist/{metrics-B5YsELiI.js.map → metrics-Cv_jrA15.js.map} +1 -1
- package/dist/modal/index.js +1 -1
- package/dist/multi-autocomplete/index.js +2 -2
- package/dist/multi-autocomplete-async/index.js +2 -2
- package/dist/multi-select/index.js +4 -4
- package/dist/number-input/index.js +2 -2
- package/dist/number-range/index.js +2 -2
- package/dist/provider/context.d.ts.map +1 -1
- package/dist/provider/index.js +2 -2
- package/dist/provider/types.d.ts +76 -0
- package/dist/provider/types.d.ts.map +1 -1
- package/dist/select/index.js +2 -2
- package/dist/slider/index.js +2 -2
- package/dist/suggest-checklist/index.js +3 -3
- package/dist/switch/index.js +1 -1
- package/dist/table/index.js +1 -1
- package/dist/tabs/index.js +1 -1
- package/dist/tag/index.js +1 -1
- package/dist/textarea/index.js +3 -3
- package/dist/time-field/index.js +2 -2
- package/dist/toast/index.js +2 -2
- package/dist/typography/index.js +1 -1
- package/dist/useFieldHook-o47pjrRg.js +56 -0
- package/dist/useFieldHook-o47pjrRg.js.map +1 -0
- package/dist/{utils-Dj_u-w0s.js → utils-DrTtzDsS.js} +3 -3
- package/dist/{utils-Dj_u-w0s.js.map → utils-DrTtzDsS.js.map} +1 -1
- package/dist/vertical-tabs/index.js +1 -1
- package/package.json +10 -1
- package/src/color-picker/docs/Description.md +45 -0
- package/src/color-picker/docs/Example.md +5 -0
- package/src/color-picker/docs/cssVariables.ts +40 -0
- package/src/color-picker/types.ts +67 -0
- package/src/dropzone/docs/Description.md +73 -0
- package/src/dropzone/docs/Example.md +17 -0
- package/src/dropzone/docs/cssVariables.ts +32 -0
- package/src/dropzone/types.ts +268 -0
- package/src/provider/types.ts +76 -0
- package/dist/hooks-BlX5Y4Zt.js +0 -53
- package/dist/hooks-BlX5Y4Zt.js.map +0 -1
- package/dist/useFieldHook-Bt9nST7g.js +0 -52
- package/dist/useFieldHook-Bt9nST7g.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFieldHook-o47pjrRg.js","sources":["../src/form/context.ts","../src/form/utils.ts","../src/form/hooks/useFieldHook.ts"],"sourcesContent":["import { type BaseSyntheticEvent, createContext, useContext } from 'react';\n\nimport { type NativeFieldValue } from 'react-hook-form';\n\nimport { type TFormFieldFlag } from './types';\n\nexport interface IFormContextValue {\n onChange: (key: string, value: NativeFieldValue) => void;\n onBlur: (key: string, value: NativeFieldValue) => void;\n onSubmitHandler: (event?: BaseSyntheticEvent) => void;\n disabled?: TFormFieldFlag;\n readOnly?: TFormFieldFlag;\n}\n\nexport const FormContext = createContext<IFormContextValue | undefined>(undefined);\n\nexport const useAuiForm = (): IFormContextValue => {\n const context = useContext(FormContext);\n\n if (!context) {\n throw new Error('This component must be used within a <Form> component');\n }\n\n return context;\n};\n","import { type FieldError } from 'react-hook-form';\n\nimport { type TFormFieldFlag } from './types';\n\nexport const getError = (value?: FieldError) => (Array.isArray(value) ? value[0] : value);\n\n/** Resolves a form-level boolean or a per-field map. Keys are exact RHF names. */\nexport const resolveFieldFlag = (flag: TFormFieldFlag | undefined, name: string): boolean => {\n if (typeof flag === 'boolean') {\n return flag;\n }\n\n if (flag == null) {\n return false;\n }\n\n return flag[name] ?? false;\n};\n","import { type FocusEvent, type SyntheticEvent, useCallback } from 'react';\n\nimport { type NativeFieldValue, type UseControllerProps, useController, useFormContext } from 'react-hook-form';\n\nimport { useAuiForm } from '../context';\nimport { type IFormFieldComponent } from '../types';\nimport { resolveFieldFlag } from '../utils';\n\n/** Builds controlled field wiring by `name` for FormInput / FormSelect / …. */\nexport const useFieldHook = <TElement extends HTMLElement = HTMLElement>({\n name,\n rules,\n}: IFormFieldComponent & { rules?: UseControllerProps['rules'] }) => {\n const { onChange, onBlur: onFormBlur, disabled, readOnly } = useAuiForm();\n const { control, setValue } = useFormContext();\n\n const { field, fieldState } = useController({\n name,\n control,\n rules,\n });\n\n const onBlurHandler = useCallback(\n (e?: FocusEvent<TElement>) => {\n field.onBlur();\n const target = e?.currentTarget;\n const value = target && 'value' in target && typeof target.value === 'string' ? target.value : field.value;\n onFormBlur(name, value);\n },\n [field, name, onFormBlur]\n );\n\n const inputProps = {\n name,\n onBlur: onBlurHandler,\n disabled: resolveFieldFlag(disabled, name),\n readOnly: resolveFieldFlag(readOnly, name) || undefined,\n };\n\n const setFieldValue = useCallback(\n (value: NativeFieldValue) => {\n field.onChange(value);\n onChange(name, value);\n },\n [field, name, onChange]\n );\n\n const onChangeHandler = useCallback(\n <T extends HTMLInputElement | HTMLTextAreaElement, E extends Event>(\n e?: SyntheticEvent<T, E>,\n val?: NativeFieldValue\n ) => {\n if (val !== undefined) {\n setFieldValue(val);\n return;\n }\n\n if (!e) {\n return;\n }\n\n field.onChange(e);\n const target = e.currentTarget;\n const { value } = target as HTMLInputElement | HTMLTextAreaElement;\n onChange(name, value);\n },\n [field, name, onChange, setFieldValue]\n );\n\n return { field, onChange, setValue, fieldState, inputProps, setFieldValue, onChangeHandler, onBlurHandler };\n};\n"],"names":["FormContext","createContext","useAuiForm","context","useContext","getError","value","resolveFieldFlag","flag","name","useFieldHook","rules","onChange","onFormBlur","disabled","readOnly","control","setValue","useFormContext","field","fieldState","useController","onBlurHandler","useCallback","e","target","inputProps","setFieldValue","onChangeHandler","val"],"mappings":";;AAcO,MAAMA,IAAcC,EAA6C,MAAS,GAEpEC,IAAa,MAAyB;AAC/C,QAAMC,IAAUC,EAAWJ,CAAW;AAEtC,MAAI,CAACG;AACD,UAAM,IAAI,MAAM,uDAAuD;AAG3E,SAAOA;AACX,GCpBaE,IAAW,CAACC,MAAwB,MAAM,QAAQA,CAAK,IAAIA,EAAM,CAAC,IAAIA,GAGtEC,IAAmB,CAACC,GAAkCC,MAC3D,OAAOD,KAAS,YACTA,IAGPA,KAAQ,OACD,KAGJA,EAAKC,CAAI,KAAK,ICPZC,IAAe,CAA6C;AAAA,EACrE,MAAAD;AAAA,EACA,OAAAE;AACJ,MAAqE;AACjE,QAAM,EAAE,UAAAC,GAAU,QAAQC,GAAY,UAAAC,GAAU,UAAAC,EAAA,IAAab,EAAA,GACvD,EAAE,SAAAc,GAAS,UAAAC,EAAA,IAAaC,EAAA,GAExB,EAAE,OAAAC,GAAO,YAAAC,EAAA,IAAeC,EAAc;AAAA,IACxC,MAAAZ;AAAA,IACA,SAAAO;AAAA,IACA,OAAAL;AAAA,EAAA,CACH,GAEKW,IAAgBC;AAAA,IAClB,CAACC,MAA6B;AAC1B,MAAAL,EAAM,OAAA;AACN,YAAMM,IAASD,GAAG,eACZlB,IAAQmB,KAAU,WAAWA,KAAU,OAAOA,EAAO,SAAU,WAAWA,EAAO,QAAQN,EAAM;AACrG,MAAAN,EAAWJ,GAAMH,CAAK;AAAA,IAC1B;AAAA,IACA,CAACa,GAAOV,GAAMI,CAAU;AAAA,EAAA,GAGtBa,IAAa;AAAA,IACf,MAAAjB;AAAA,IACA,QAAQa;AAAA,IACR,UAAUf,EAAiBO,GAAUL,CAAI;AAAA,IACzC,UAAUF,EAAiBQ,GAAUN,CAAI,KAAK;AAAA,EAAA,GAG5CkB,IAAgBJ;AAAA,IAClB,CAACjB,MAA4B;AACzB,MAAAa,EAAM,SAASb,CAAK,GACpBM,EAASH,GAAMH,CAAK;AAAA,IACxB;AAAA,IACA,CAACa,GAAOV,GAAMG,CAAQ;AAAA,EAAA,GAGpBgB,IAAkBL;AAAA,IACpB,CACIC,GACAK,MACC;AACD,UAAIA,MAAQ,QAAW;AACnB,QAAAF,EAAcE,CAAG;AACjB;AAAA,MACJ;AAEA,UAAI,CAACL;AACD;AAGJ,MAAAL,EAAM,SAASK,CAAC;AAChB,YAAMC,IAASD,EAAE,eACX,EAAE,OAAAlB,MAAUmB;AAClB,MAAAb,EAASH,GAAMH,CAAK;AAAA,IACxB;AAAA,IACA,CAACa,GAAOV,GAAMG,GAAUe,CAAa;AAAA,EAAA;AAGzC,SAAO,EAAE,OAAAR,GAAO,UAAAP,GAAU,UAAAK,GAAU,YAAAG,GAAY,YAAAM,GAAY,eAAAC,GAAe,iBAAAC,GAAiB,eAAAN,EAAA;AAChG;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as f, Fragment as P, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { useContext as d } from "react";
|
|
3
3
|
import { Popover as k, Virtualizer as A, ListLayout as w, ListBox as K, Collection as j, ListBoxItem as O, ListBoxLoadMoreItem as T, SelectStateContext as v, ComboBoxStateContext as S } from "react-aria-components";
|
|
4
|
-
import { u as N } from "./hooks-
|
|
4
|
+
import { u as N } from "./hooks-CekMiYbX.js";
|
|
5
5
|
import { C as H } from "./Check-deng4Zns.js";
|
|
6
|
-
import { u as q, C as D } from "./metrics-
|
|
6
|
+
import { u as q, C as D } from "./metrics-Cv_jrA15.js";
|
|
7
7
|
import { cva as b } from "class-variance-authority";
|
|
8
8
|
import _ from "classnames";
|
|
9
9
|
import { typographyStyles as p } from "./typography/index.js";
|
|
@@ -220,4 +220,4 @@ export {
|
|
|
220
220
|
Mt as r,
|
|
221
221
|
Pt as t
|
|
222
222
|
};
|
|
223
|
-
//# sourceMappingURL=utils-
|
|
223
|
+
//# sourceMappingURL=utils-DrTtzDsS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-Dj_u-w0s.js","sources":["../src/combobox/components/Item/theme.ts","../src/combobox/components/Item/index.tsx","../src/combobox/components/Popover/theme.ts","../src/combobox/components/Popover/index.tsx","../src/combobox/components/List/theme.ts","../src/combobox/components/List/index.tsx","../src/field-clear-button/theme.ts","../src/field-clear-button/Component.tsx","../src/field-clear-button/adapters.tsx","../src/combobox/utils.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\n\nimport styles from './styles.module.css';\n\nexport const comboboxItemVariants = cva(styles.root, {\n variants: {\n size: {\n sm: styles.sm,\n md: styles.md,\n lg: styles.lg,\n },\n variant: {\n primary: styles.primary,\n },\n },\n defaultVariants: {\n size: 'md',\n variant: 'primary',\n },\n});\n","import { Check } from '@/icons';\n\nimport styles from './styles.module.css';\n\nexport { comboboxItemVariants } from './theme';\n\nexport interface IComboboxItemContentProps {\n label: string;\n}\n\nexport const ComboboxItemContent = ({ label }: IComboboxItemContentProps) => (\n <>\n <span className={styles.label}>{label}</span>\n <Check className={styles.check} />\n </>\n);\n\nComboboxItemContent.displayName = 'ComboboxItemContent';\n","import { cva } from 'class-variance-authority';\n\nimport styles from './styles.module.css';\n\nexport const comboboxPopoverVariants = cva(styles.root, {\n variants: {\n variant: {\n primary: styles.primary,\n },\n },\n defaultVariants: {\n variant: 'primary',\n },\n});\n","import { type ReactNode, type RefObject } from 'react';\n\nimport { Popover as RacPopover } from 'react-aria-components';\n\nimport { type TComboboxVariant } from '../../types';\n\nimport { comboboxPopoverVariants } from './theme';\n\nexport interface IComboboxPopoverProps {\n triggerRef: RefObject<HTMLElement | null>;\n variant: TComboboxVariant;\n children: ReactNode;\n}\n\nexport const ComboboxPopover = ({ triggerRef, variant, children }: IComboboxPopoverProps) => (\n <RacPopover triggerRef={triggerRef} className={comboboxPopoverVariants({ variant })} offset={4}>\n {children}\n </RacPopover>\n);\n\nComboboxPopover.displayName = 'ComboboxPopover';\n","import { cva } from 'class-variance-authority';\nimport cn from 'classnames';\n\nimport { typographyStyles } from '@ds/typography';\n\nimport styles from './styles.module.css';\n\nexport const comboboxListBoxVariants = cva(styles.root, {\n variants: {\n size: {\n sm: cn(styles.sm, typographyStyles.bodyS),\n md: cn(styles.md, typographyStyles.bodyM),\n lg: cn(styles.lg, typographyStyles.bodyL),\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n","import { type RefObject } from 'react';\n\nimport { Collection, ListBox, ListBoxItem, ListBoxLoadMoreItem, ListLayout, Virtualizer } from 'react-aria-components';\n\nimport { useAuiLabels } from '@/provider';\n\nimport { type IComboboxOption, type TComboboxSize, type TComboboxVariant } from '../../types';\nimport { ComboboxItemContent, comboboxItemVariants } from '../Item';\nimport { ComboboxListStatus } from '../ListStatus';\nimport { ComboboxPopover } from '../Popover';\n\nimport { useComboboxListMetrics } from './metrics';\nimport { comboboxListBoxVariants } from './theme';\n\nimport styles from './styles.module.css';\n\nconst LoadMoreStatus = () => {\n const { loadingSuggestions } = useAuiLabels();\n\n return (\n <span className={styles.more} role=\"status\">\n {loadingSuggestions}\n </span>\n );\n};\n\nexport interface IComboboxListProps {\n triggerRef: RefObject<HTMLElement | null>;\n options: IComboboxOption[];\n size: TComboboxSize;\n variant: TComboboxVariant;\n isLoading?: boolean;\n isError?: boolean;\n /** When true, empty options show ListStatus empty chrome (autocomplete). */\n showEmptyStatus?: boolean;\n /** Further pages exist. Renders a sentinel at the end of the virtual list. */\n hasMore?: boolean;\n /** Fetch the next page. Called when the sentinel nears the viewport. */\n onLoadMore?: () => void;\n /** True while a later page is loading. Keeps already shown options. */\n isLoadingMore?: boolean;\n}\n\nexport const ComboboxList = ({\n triggerRef,\n options,\n size,\n variant,\n isLoading = false,\n isError = false,\n showEmptyStatus = false,\n hasMore = false,\n onLoadMore,\n isLoadingMore = false,\n}: IComboboxListProps) => {\n const { rowSize, padding } = useComboboxListMetrics(size);\n const showStatus = isLoading || (isError && options.length === 0) || (showEmptyStatus && options.length === 0);\n const showItems = !isLoading && !(isError && options.length === 0) && (!showEmptyStatus || options.length > 0);\n const showMore = showItems && (hasMore || isLoadingMore) && onLoadMore != null;\n\n return (\n <ComboboxPopover triggerRef={triggerRef} variant={variant}>\n {showStatus ? (\n <ComboboxListStatus isLoading={isLoading} isError={isError} isEmpty={!isLoading && !isError} />\n ) : null}\n {showItems ? (\n <Virtualizer layout={ListLayout} layoutOptions={{ rowSize, padding, loaderSize: rowSize }}>\n <ListBox className={comboboxListBoxVariants({ size })}>\n <Collection items={options}>\n {(item: IComboboxOption) => (\n <ListBoxItem\n id={item.value}\n textValue={item.label}\n isDisabled={item.disabled}\n className={comboboxItemVariants({ size, variant })}\n >\n <ComboboxItemContent label={item.label} />\n </ListBoxItem>\n )}\n </Collection>\n {showMore ? (\n <ListBoxLoadMoreItem isLoading={isLoadingMore} onLoadMore={onLoadMore}>\n {isLoadingMore ? <LoadMoreStatus /> : null}\n </ListBoxLoadMoreItem>\n ) : null}\n </ListBox>\n </Virtualizer>\n ) : null}\n </ComboboxPopover>\n );\n};\n\nComboboxList.displayName = 'ComboboxList';\n","import { cva } from 'class-variance-authority';\n\nimport styles from './styles.module.css';\n\nexport const fieldClearVariants = cva(styles.clear, {\n variants: {\n size: {\n sm: styles.sm,\n md: styles.md,\n lg: styles.lg,\n },\n variant: {\n primary: styles.primary,\n },\n },\n defaultVariants: {\n size: 'md',\n variant: 'primary',\n },\n});\n","import { Clear } from '@/icons';\nimport { useAuiLabels } from '@/provider';\n\nimport { fieldClearVariants } from './theme';\nimport { type IFieldClearButtonProps } from './types';\n\nimport styles from './styles.module.css';\n\n/** Presentational clear button for field triggers. */\nexport const FieldClearButton = ({ isDisabled, size, variant, onClear }: IFieldClearButtonProps) => {\n const { clear } = useAuiLabels();\n\n return (\n <button\n type=\"button\"\n className={fieldClearVariants({ size, variant })}\n aria-label={clear}\n disabled={isDisabled}\n onPointerDown={event => {\n event.preventDefault();\n event.stopPropagation();\n }}\n onClick={event => {\n event.preventDefault();\n event.stopPropagation();\n onClear();\n }}\n >\n <Clear className={styles.root} />\n </button>\n );\n};\n\nFieldClearButton.displayName = 'FieldClearButton';\n","import { useContext } from 'react';\n\nimport { ComboBoxStateContext, SelectStateContext } from 'react-aria-components';\n\nimport { FieldClearButton } from './Component';\nimport { type TFieldClearSize, type TFieldClearVariant } from './types';\n\nconst isEmptyMultiValue = (value: unknown): boolean => {\n if (value == null) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n\n return false;\n};\n\ninterface IAdapterProps {\n isDisabled: boolean;\n size: TFieldClearSize;\n variant: TFieldClearVariant;\n}\n\n/** Clear for single Select (SelectStateContext). */\nexport const FieldSelectClearButton = ({ isDisabled, size, variant }: IAdapterProps) => {\n const state = useContext(SelectStateContext);\n\n if (!state || state.selectedKey == null || isDisabled) {\n return null;\n }\n\n return (\n <FieldClearButton\n isDisabled={isDisabled}\n size={size}\n variant={variant}\n onClear={() => {\n state.setSelectedKey(null);\n }}\n />\n );\n};\n\nFieldSelectClearButton.displayName = 'FieldSelectClearButton';\n\n/** Clear for multi Select. */\nexport const FieldMultiSelectClearButton = ({ isDisabled, size, variant }: IAdapterProps) => {\n const state = useContext(SelectStateContext);\n\n if (!state || isEmptyMultiValue(state.value) || isDisabled) {\n return null;\n }\n\n return (\n <FieldClearButton\n isDisabled={isDisabled}\n size={size}\n variant={variant}\n onClear={() => {\n state.setValue([]);\n }}\n />\n );\n};\n\nFieldMultiSelectClearButton.displayName = 'FieldMultiSelectClearButton';\n\n/** Clear for single ComboBox. */\nexport const FieldComboBoxClearButton = ({ isDisabled, size, variant }: IAdapterProps) => {\n const state = useContext(ComboBoxStateContext);\n const selected = state?.value;\n\n if (!state || selected == null || selected === '' || isDisabled) {\n return null;\n }\n\n return (\n <FieldClearButton\n isDisabled={isDisabled}\n size={size}\n variant={variant}\n onClear={() => {\n state.setValue(null);\n state.setInputValue('');\n }}\n />\n );\n};\n\nFieldComboBoxClearButton.displayName = 'FieldComboBoxClearButton';\n\n/** Clear for multi ComboBox. */\nexport const FieldMultiComboBoxClearButton = ({ isDisabled, size, variant }: IAdapterProps) => {\n const state = useContext(ComboBoxStateContext);\n\n if (!state || isEmptyMultiValue(state.value) || isDisabled) {\n return null;\n }\n\n return (\n <FieldClearButton\n isDisabled={isDisabled}\n size={size}\n variant={variant}\n onClear={() => {\n state.setValue([]);\n state.setInputValue('');\n }}\n />\n );\n};\n\nFieldMultiComboBoxClearButton.displayName = 'FieldMultiComboBoxClearButton';\n","import { type Key } from 'react-aria-components';\n\nimport { type IComboboxOption, type TComboboxValue } from './types';\n\n/**\n * Resolves selected keys to options in key order.\n * Missing keys fall back to `{ value, label: String(key) }`.\n */\nexport const resolveSelectedOptions = (\n keys: readonly Key[],\n optionsByValue: ReadonlyMap<TComboboxValue, IComboboxOption>\n): IComboboxOption[] =>\n keys.map(key => {\n const value = key as TComboboxValue;\n const found = optionsByValue.get(value);\n\n if (found) {\n return found;\n }\n\n return { value, label: String(key) };\n });\n\n/** True when click originated from remove / nested button chrome (not tag body). */\nexport const isInteractiveTarget = (target: EventTarget | null) => {\n if (!(target instanceof HTMLElement)) {\n return false;\n }\n\n return Boolean(target.closest('[slot=\"remove\"], button'));\n};\n\n/** Normalize RAC value to a key list for tag remove / clear. */\nexport const toKeyList = (value: unknown): Key[] => (Array.isArray(value) ? value : []);\n"],"names":["comboboxItemVariants","cva","styles","ComboboxItemContent","label","jsxs","Fragment","jsx","Check","comboboxPopoverVariants","ComboboxPopover","triggerRef","variant","children","RacPopover","comboboxListBoxVariants","cn","typographyStyles","LoadMoreStatus","loadingSuggestions","useAuiLabels","ComboboxList","options","size","isLoading","isError","showEmptyStatus","hasMore","onLoadMore","isLoadingMore","rowSize","padding","useComboboxListMetrics","showStatus","showItems","showMore","ComboboxListStatus","Virtualizer","ListLayout","ListBox","Collection","item","ListBoxItem","ListBoxLoadMoreItem","fieldClearVariants","FieldClearButton","isDisabled","onClear","clear","event","Clear","isEmptyMultiValue","value","FieldSelectClearButton","state","useContext","SelectStateContext","FieldMultiSelectClearButton","FieldComboBoxClearButton","ComboBoxStateContext","selected","FieldMultiComboBoxClearButton","resolveSelectedOptions","keys","optionsByValue","key","found","isInteractiveTarget","target","toKeyList"],"mappings":";;;;;;;;;;;;;;;;;;GAIaA,IAAuBC,EAAIC,EAAO,MAAM;AAAA,EACjD,UAAU;AAAA,IACN,MAAM;AAAA,MACF,IAAIA,EAAO;AAAA,MACX,IAAIA,EAAO;AAAA,MACX,IAAIA,EAAO;AAAA,IAAA;AAAA,IAEf,SAAS;AAAA,MACL,SAASA,EAAO;AAAA,IAAA;AAAA,EACpB;AAAA,EAEJ,iBAAiB;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,EAAA;AAEjB,CAAC,GCTYC,IAAsB,CAAC,EAAE,OAAAC,EAAA,MAClC,gBAAAC,EAAAC,GAAA,EACI,UAAA;AAAA,EAAA,gBAAAC,EAAC,QAAA,EAAK,WAAWL,EAAO,OAAQ,UAAAE,GAAM;AAAA,EACtC,gBAAAG,EAACC,GAAA,EAAM,WAAWN,EAAO,MAAA,CAAO;AAAA,EAAA,CACpC;AAGJC,EAAoB,cAAc;;;;GCbrBM,KAA0BR,EAAIC,EAAO,MAAM;AAAA,EACpD,UAAU;AAAA,IACN,SAAS;AAAA,MACL,SAASA,EAAO;AAAA,IAAA;AAAA,EACpB;AAAA,EAEJ,iBAAiB;AAAA,IACb,SAAS;AAAA,EAAA;AAEjB,CAAC,GCCYQ,IAAkB,CAAC,EAAE,YAAAC,GAAY,SAAAC,GAAS,UAAAC,EAAA,MACnD,gBAAAN,EAACO,GAAA,EAAW,YAAAH,GAAwB,WAAWF,GAAwB,EAAE,SAAAG,EAAA,CAAS,GAAG,QAAQ,GACxF,UAAAC,EAAA,CACL;AAGJH,EAAgB,cAAc;;;;;;;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src/combobox/components/Item/theme.ts","../src/combobox/components/Item/index.tsx","../src/combobox/components/Popover/theme.ts","../src/combobox/components/Popover/index.tsx","../src/combobox/components/List/theme.ts","../src/combobox/components/List/index.tsx","../src/field-clear-button/theme.ts","../src/field-clear-button/Component.tsx","../src/field-clear-button/adapters.tsx","../src/combobox/utils.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\n\nimport styles from './styles.module.css';\n\nexport const comboboxItemVariants = cva(styles.root, {\n variants: {\n size: {\n sm: styles.sm,\n md: styles.md,\n lg: styles.lg,\n },\n variant: {\n primary: styles.primary,\n },\n },\n defaultVariants: {\n size: 'md',\n variant: 'primary',\n },\n});\n","import { Check } from '@/icons';\n\nimport styles from './styles.module.css';\n\nexport { comboboxItemVariants } from './theme';\n\nexport interface IComboboxItemContentProps {\n label: string;\n}\n\nexport const ComboboxItemContent = ({ label }: IComboboxItemContentProps) => (\n <>\n <span className={styles.label}>{label}</span>\n <Check className={styles.check} />\n </>\n);\n\nComboboxItemContent.displayName = 'ComboboxItemContent';\n","import { cva } from 'class-variance-authority';\n\nimport styles from './styles.module.css';\n\nexport const comboboxPopoverVariants = cva(styles.root, {\n variants: {\n variant: {\n primary: styles.primary,\n },\n },\n defaultVariants: {\n variant: 'primary',\n },\n});\n","import { type ReactNode, type RefObject } from 'react';\n\nimport { Popover as RacPopover } from 'react-aria-components';\n\nimport { type TComboboxVariant } from '../../types';\n\nimport { comboboxPopoverVariants } from './theme';\n\nexport interface IComboboxPopoverProps {\n triggerRef: RefObject<HTMLElement | null>;\n variant: TComboboxVariant;\n children: ReactNode;\n}\n\nexport const ComboboxPopover = ({ triggerRef, variant, children }: IComboboxPopoverProps) => (\n <RacPopover triggerRef={triggerRef} className={comboboxPopoverVariants({ variant })} offset={4}>\n {children}\n </RacPopover>\n);\n\nComboboxPopover.displayName = 'ComboboxPopover';\n","import { cva } from 'class-variance-authority';\nimport cn from 'classnames';\n\nimport { typographyStyles } from '@ds/typography';\n\nimport styles from './styles.module.css';\n\nexport const comboboxListBoxVariants = cva(styles.root, {\n variants: {\n size: {\n sm: cn(styles.sm, typographyStyles.bodyS),\n md: cn(styles.md, typographyStyles.bodyM),\n lg: cn(styles.lg, typographyStyles.bodyL),\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n","import { type RefObject } from 'react';\n\nimport { Collection, ListBox, ListBoxItem, ListBoxLoadMoreItem, ListLayout, Virtualizer } from 'react-aria-components';\n\nimport { useAuiLabels } from '@/provider';\n\nimport { type IComboboxOption, type TComboboxSize, type TComboboxVariant } from '../../types';\nimport { ComboboxItemContent, comboboxItemVariants } from '../Item';\nimport { ComboboxListStatus } from '../ListStatus';\nimport { ComboboxPopover } from '../Popover';\n\nimport { useComboboxListMetrics } from './metrics';\nimport { comboboxListBoxVariants } from './theme';\n\nimport styles from './styles.module.css';\n\nconst LoadMoreStatus = () => {\n const { loadingSuggestions } = useAuiLabels();\n\n return (\n <span className={styles.more} role=\"status\">\n {loadingSuggestions}\n </span>\n );\n};\n\nexport interface IComboboxListProps {\n triggerRef: RefObject<HTMLElement | null>;\n options: IComboboxOption[];\n size: TComboboxSize;\n variant: TComboboxVariant;\n isLoading?: boolean;\n isError?: boolean;\n /** When true, empty options show ListStatus empty chrome (autocomplete). */\n showEmptyStatus?: boolean;\n /** Further pages exist. Renders a sentinel at the end of the virtual list. */\n hasMore?: boolean;\n /** Fetch the next page. Called when the sentinel nears the viewport. */\n onLoadMore?: () => void;\n /** True while a later page is loading. Keeps already shown options. */\n isLoadingMore?: boolean;\n}\n\nexport const ComboboxList = ({\n triggerRef,\n options,\n size,\n variant,\n isLoading = false,\n isError = false,\n showEmptyStatus = false,\n hasMore = false,\n onLoadMore,\n isLoadingMore = false,\n}: IComboboxListProps) => {\n const { rowSize, padding } = useComboboxListMetrics(size);\n const showStatus = isLoading || (isError && options.length === 0) || (showEmptyStatus && options.length === 0);\n const showItems = !isLoading && !(isError && options.length === 0) && (!showEmptyStatus || options.length > 0);\n const showMore = showItems && (hasMore || isLoadingMore) && onLoadMore != null;\n\n return (\n <ComboboxPopover triggerRef={triggerRef} variant={variant}>\n {showStatus ? (\n <ComboboxListStatus isLoading={isLoading} isError={isError} isEmpty={!isLoading && !isError} />\n ) : null}\n {showItems ? (\n <Virtualizer layout={ListLayout} layoutOptions={{ rowSize, padding, loaderSize: rowSize }}>\n <ListBox className={comboboxListBoxVariants({ size })}>\n <Collection items={options}>\n {(item: IComboboxOption) => (\n <ListBoxItem\n id={item.value}\n textValue={item.label}\n isDisabled={item.disabled}\n className={comboboxItemVariants({ size, variant })}\n >\n <ComboboxItemContent label={item.label} />\n </ListBoxItem>\n )}\n </Collection>\n {showMore ? (\n <ListBoxLoadMoreItem isLoading={isLoadingMore} onLoadMore={onLoadMore}>\n {isLoadingMore ? <LoadMoreStatus /> : null}\n </ListBoxLoadMoreItem>\n ) : null}\n </ListBox>\n </Virtualizer>\n ) : null}\n </ComboboxPopover>\n );\n};\n\nComboboxList.displayName = 'ComboboxList';\n","import { cva } from 'class-variance-authority';\n\nimport styles from './styles.module.css';\n\nexport const fieldClearVariants = cva(styles.clear, {\n variants: {\n size: {\n sm: styles.sm,\n md: styles.md,\n lg: styles.lg,\n },\n variant: {\n primary: styles.primary,\n },\n },\n defaultVariants: {\n size: 'md',\n variant: 'primary',\n },\n});\n","import { Clear } from '@/icons';\nimport { useAuiLabels } from '@/provider';\n\nimport { fieldClearVariants } from './theme';\nimport { type IFieldClearButtonProps } from './types';\n\nimport styles from './styles.module.css';\n\n/** Presentational clear button for field triggers. */\nexport const FieldClearButton = ({ isDisabled, size, variant, onClear }: IFieldClearButtonProps) => {\n const { clear } = useAuiLabels();\n\n return (\n <button\n type=\"button\"\n className={fieldClearVariants({ size, variant })}\n aria-label={clear}\n disabled={isDisabled}\n onPointerDown={event => {\n event.preventDefault();\n event.stopPropagation();\n }}\n onClick={event => {\n event.preventDefault();\n event.stopPropagation();\n onClear();\n }}\n >\n <Clear className={styles.root} />\n </button>\n );\n};\n\nFieldClearButton.displayName = 'FieldClearButton';\n","import { useContext } from 'react';\n\nimport { ComboBoxStateContext, SelectStateContext } from 'react-aria-components';\n\nimport { FieldClearButton } from './Component';\nimport { type TFieldClearSize, type TFieldClearVariant } from './types';\n\nconst isEmptyMultiValue = (value: unknown): boolean => {\n if (value == null) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n\n return false;\n};\n\ninterface IAdapterProps {\n isDisabled: boolean;\n size: TFieldClearSize;\n variant: TFieldClearVariant;\n}\n\n/** Clear for single Select (SelectStateContext). */\nexport const FieldSelectClearButton = ({ isDisabled, size, variant }: IAdapterProps) => {\n const state = useContext(SelectStateContext);\n\n if (!state || state.selectedKey == null || isDisabled) {\n return null;\n }\n\n return (\n <FieldClearButton\n isDisabled={isDisabled}\n size={size}\n variant={variant}\n onClear={() => {\n state.setSelectedKey(null);\n }}\n />\n );\n};\n\nFieldSelectClearButton.displayName = 'FieldSelectClearButton';\n\n/** Clear for multi Select. */\nexport const FieldMultiSelectClearButton = ({ isDisabled, size, variant }: IAdapterProps) => {\n const state = useContext(SelectStateContext);\n\n if (!state || isEmptyMultiValue(state.value) || isDisabled) {\n return null;\n }\n\n return (\n <FieldClearButton\n isDisabled={isDisabled}\n size={size}\n variant={variant}\n onClear={() => {\n state.setValue([]);\n }}\n />\n );\n};\n\nFieldMultiSelectClearButton.displayName = 'FieldMultiSelectClearButton';\n\n/** Clear for single ComboBox. */\nexport const FieldComboBoxClearButton = ({ isDisabled, size, variant }: IAdapterProps) => {\n const state = useContext(ComboBoxStateContext);\n const selected = state?.value;\n\n if (!state || selected == null || selected === '' || isDisabled) {\n return null;\n }\n\n return (\n <FieldClearButton\n isDisabled={isDisabled}\n size={size}\n variant={variant}\n onClear={() => {\n state.setValue(null);\n state.setInputValue('');\n }}\n />\n );\n};\n\nFieldComboBoxClearButton.displayName = 'FieldComboBoxClearButton';\n\n/** Clear for multi ComboBox. */\nexport const FieldMultiComboBoxClearButton = ({ isDisabled, size, variant }: IAdapterProps) => {\n const state = useContext(ComboBoxStateContext);\n\n if (!state || isEmptyMultiValue(state.value) || isDisabled) {\n return null;\n }\n\n return (\n <FieldClearButton\n isDisabled={isDisabled}\n size={size}\n variant={variant}\n onClear={() => {\n state.setValue([]);\n state.setInputValue('');\n }}\n />\n );\n};\n\nFieldMultiComboBoxClearButton.displayName = 'FieldMultiComboBoxClearButton';\n","import { type Key } from 'react-aria-components';\n\nimport { type IComboboxOption, type TComboboxValue } from './types';\n\n/**\n * Resolves selected keys to options in key order.\n * Missing keys fall back to `{ value, label: String(key) }`.\n */\nexport const resolveSelectedOptions = (\n keys: readonly Key[],\n optionsByValue: ReadonlyMap<TComboboxValue, IComboboxOption>\n): IComboboxOption[] =>\n keys.map(key => {\n const value = key as TComboboxValue;\n const found = optionsByValue.get(value);\n\n if (found) {\n return found;\n }\n\n return { value, label: String(key) };\n });\n\n/** True when click originated from remove / nested button chrome (not tag body). */\nexport const isInteractiveTarget = (target: EventTarget | null) => {\n if (!(target instanceof HTMLElement)) {\n return false;\n }\n\n return Boolean(target.closest('[slot=\"remove\"], button'));\n};\n\n/** Normalize RAC value to a key list for tag remove / clear. */\nexport const toKeyList = (value: unknown): Key[] => (Array.isArray(value) ? value : []);\n"],"names":["comboboxItemVariants","cva","styles","ComboboxItemContent","label","jsxs","Fragment","jsx","Check","comboboxPopoverVariants","ComboboxPopover","triggerRef","variant","children","RacPopover","comboboxListBoxVariants","cn","typographyStyles","LoadMoreStatus","loadingSuggestions","useAuiLabels","ComboboxList","options","size","isLoading","isError","showEmptyStatus","hasMore","onLoadMore","isLoadingMore","rowSize","padding","useComboboxListMetrics","showStatus","showItems","showMore","ComboboxListStatus","Virtualizer","ListLayout","ListBox","Collection","item","ListBoxItem","ListBoxLoadMoreItem","fieldClearVariants","FieldClearButton","isDisabled","onClear","clear","event","Clear","isEmptyMultiValue","value","FieldSelectClearButton","state","useContext","SelectStateContext","FieldMultiSelectClearButton","FieldComboBoxClearButton","ComboBoxStateContext","selected","FieldMultiComboBoxClearButton","resolveSelectedOptions","keys","optionsByValue","key","found","isInteractiveTarget","target","toKeyList"],"mappings":";;;;;;;;;;;;;;;;;;GAIaA,IAAuBC,EAAIC,EAAO,MAAM;AAAA,EACjD,UAAU;AAAA,IACN,MAAM;AAAA,MACF,IAAIA,EAAO;AAAA,MACX,IAAIA,EAAO;AAAA,MACX,IAAIA,EAAO;AAAA,IAAA;AAAA,IAEf,SAAS;AAAA,MACL,SAASA,EAAO;AAAA,IAAA;AAAA,EACpB;AAAA,EAEJ,iBAAiB;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,EAAA;AAEjB,CAAC,GCTYC,IAAsB,CAAC,EAAE,OAAAC,EAAA,MAClC,gBAAAC,EAAAC,GAAA,EACI,UAAA;AAAA,EAAA,gBAAAC,EAAC,QAAA,EAAK,WAAWL,EAAO,OAAQ,UAAAE,GAAM;AAAA,EACtC,gBAAAG,EAACC,GAAA,EAAM,WAAWN,EAAO,MAAA,CAAO;AAAA,EAAA,CACpC;AAGJC,EAAoB,cAAc;;;;GCbrBM,KAA0BR,EAAIC,EAAO,MAAM;AAAA,EACpD,UAAU;AAAA,IACN,SAAS;AAAA,MACL,SAASA,EAAO;AAAA,IAAA;AAAA,EACpB;AAAA,EAEJ,iBAAiB;AAAA,IACb,SAAS;AAAA,EAAA;AAEjB,CAAC,GCCYQ,IAAkB,CAAC,EAAE,YAAAC,GAAY,SAAAC,GAAS,UAAAC,EAAA,MACnD,gBAAAN,EAACO,GAAA,EAAW,YAAAH,GAAwB,WAAWF,GAAwB,EAAE,SAAAG,EAAA,CAAS,GAAG,QAAQ,GACxF,UAAAC,EAAA,CACL;AAGJH,EAAgB,cAAc;;;;;;;GCbjBK,KAA0Bd,EAAIC,EAAO,MAAM;AAAA,EACpD,UAAU;AAAA,IACN,MAAM;AAAA,MACF,IAAIc,EAAGd,EAAO,IAAIe,EAAiB,KAAK;AAAA,MACxC,IAAID,EAAGd,EAAO,IAAIe,EAAiB,KAAK;AA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1C,OAIP,gBAAAvC;AAAA,IAACsC;AAAA,IAAA;AAAA,MACG,YAAAC;AAAA,MACA,MAAAvB;AAAA,MACA,SAAAX;AAAA,MACA,SAAS,MAAM;AACX,QAAA0C,EAAM,SAAS,IAAI,GACnBA,EAAM,cAAc,EAAE;AAAA,MAC1B;AAAA,IAAA;AAAA,EAAA;AAGZ;AAEAI,GAAyB,cAAc;AAGhC,MAAMG,KAAgC,CAAC,EAAE,YAAAf,GAAY,MAAAvB,GAAM,SAAAX,QAA6B;AAC3F,QAAM0C,IAAQC,EAAWI,CAAoB;AAE7C,SAAI,CAACL,KAASH,EAAkBG,EAAM,KAAK,KAAKR,IACrC,OAIP,gBAAAvC;AAAA,IAACsC;AAAA,IAAA;AAAA,MACG,YAAAC;AAAA,MACA,MAAAvB;AAAA,MACA,SAAAX;AAAA,MACA,SAAS,MAAM;AACX,QAAA0C,EAAM,SAAS,EAAE,GACjBA,EAAM,cAAc,EAAE;AAAA,MAC1B;AAAA,IAAA;AAAA,EAAA;AAGZ;AAEAO,GAA8B,cAAc;AC1GrC,MAAMC,KAAyB,CAClCC,GACAC,MAEAD,EAAK,IAAI,CAAAE,MAAO;AACZ,QAAMb,IAAQa,GACRC,IAAQF,EAAe,IAAIZ,CAAK;AAEtC,SAAIc,KAIG,EAAE,OAAAd,GAAO,OAAO,OAAOa,CAAG,EAAA;AACrC,CAAC,GAGQE,KAAsB,CAACC,MAC1BA,aAAkB,cAIjB,EAAQA,EAAO,QAAQ,yBAAyB,IAH5C,IAOFC,KAAY,CAACjB,MAA2B,MAAM,QAAQA,CAAK,IAAIA,IAAQ,CAAA;"}
|
|
@@ -5,7 +5,7 @@ import { SelectionIndicator as w, Tab as D, TabList as K, TabPanel as M, TabPane
|
|
|
5
5
|
import { s as _ } from "../index-h8z54aFR.js";
|
|
6
6
|
import { typographyStyles as b } from "../typography/index.js";
|
|
7
7
|
import { cva as p } from "class-variance-authority";
|
|
8
|
-
import '../assets/
|
|
8
|
+
import '../assets/index29.css';const V = C(void 0), g = () => {
|
|
9
9
|
const t = L(V);
|
|
10
10
|
if (!t)
|
|
11
11
|
throw new Error("This component must be used within a <VerticalTabs> component");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ensi-platform/admin-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Admin UI for Ensi admin panel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"classnames": "2.5.1",
|
|
45
45
|
"react-aria": "3.52.1",
|
|
46
46
|
"react-aria-components": "^1.21.1",
|
|
47
|
+
"react-dropzone": "^20.1.4",
|
|
47
48
|
"react-fast-compare": "^3.2.2",
|
|
48
49
|
"usehooks-ts": "^3.1.1"
|
|
49
50
|
},
|
|
@@ -106,6 +107,10 @@
|
|
|
106
107
|
"types": "./dist/checkbox-group/index.d.ts",
|
|
107
108
|
"import": "./dist/checkbox-group/index.js"
|
|
108
109
|
},
|
|
110
|
+
"./color-picker": {
|
|
111
|
+
"types": "./dist/color-picker/index.d.ts",
|
|
112
|
+
"import": "./dist/color-picker/index.js"
|
|
113
|
+
},
|
|
109
114
|
"./combobox": {
|
|
110
115
|
"types": "./dist/combobox/index.d.ts",
|
|
111
116
|
"import": "./dist/combobox/index.js"
|
|
@@ -134,6 +139,10 @@
|
|
|
134
139
|
"types": "./dist/drawer/index.d.ts",
|
|
135
140
|
"import": "./dist/drawer/index.js"
|
|
136
141
|
},
|
|
142
|
+
"./dropzone": {
|
|
143
|
+
"types": "./dist/dropzone/index.d.ts",
|
|
144
|
+
"import": "./dist/dropzone/index.js"
|
|
145
|
+
},
|
|
137
146
|
"./field": {
|
|
138
147
|
"types": "./dist/field/index.d.ts",
|
|
139
148
|
"import": "./dist/field/index.js"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
A color field: the swatch opens a palette, and the hex sits beside it.
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
import { ColorPicker, FormColorPicker } from '@ensi-platform/admin-ui/color-picker';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- one opaque color: a badge, a status, a product attribute
|
|
10
|
+
- the code is already known — type it without opening the palette
|
|
11
|
+
- a short list of allowed colors — the `presets` prop
|
|
12
|
+
- a date or a time — see `DatePicker` and `TimeField`
|
|
13
|
+
|
|
14
|
+
## API (short)
|
|
15
|
+
|
|
16
|
+
### ColorPicker
|
|
17
|
+
|
|
18
|
+
| Prop | Values | Default | Description |
|
|
19
|
+
| -------------------- | -------------------- | --------- | -------------------------------------------------------------------- |
|
|
20
|
+
| `value` / `onChange` | `string` | — | `''` or `#rrggbb`. The color object stays inside |
|
|
21
|
+
| `defaultValue` | `string` | `''` | initial value without external state |
|
|
22
|
+
| `presets` | `string[]` | — | swatches in the panel. Strings that are not colors are dropped |
|
|
23
|
+
| `clear` | `boolean` | `false` | clear button |
|
|
24
|
+
| `size` | `sm` \| `md` \| `lg` | `md` | size |
|
|
25
|
+
| `variant` | `primary` | `primary` | visual variant |
|
|
26
|
+
| `invalid` | `boolean` | `false` | error. An unrecognized `value` marks the field too |
|
|
27
|
+
| `disabled` | `boolean` | `false` | disabled |
|
|
28
|
+
| `block` | `boolean` | `true` | full width |
|
|
29
|
+
| `dataTestId` | `string` | — | `data-test-id` attribute |
|
|
30
|
+
|
|
31
|
+
Six digits are published immediately. Three digits (`#abc`) expand to `#aabbcc` on blur or Enter. Enter does not submit the form. A drag on the area publishes when the pointer is released; arrow keys on the hue slider publish on each step.
|
|
32
|
+
|
|
33
|
+
### FormColorPicker
|
|
34
|
+
|
|
35
|
+
| Prop | Values | Default | Description |
|
|
36
|
+
| ---------- | -------------------- | --------- | ------------------ |
|
|
37
|
+
| `name` | `string` | — | field name in `Form` |
|
|
38
|
+
| `label` | `ReactNode` | — | label |
|
|
39
|
+
| `hint` | `ReactNode` | — | hint |
|
|
40
|
+
| `clear` | `boolean` | — | clear button |
|
|
41
|
+
| `presets` | `string[]` | — | preset swatches |
|
|
42
|
+
| `size` | `sm` \| `md` \| `lg` | `md` | size |
|
|
43
|
+
| `variant` | `primary` | `primary` | visual variant |
|
|
44
|
+
| `disabled` | `boolean` | — | disabled |
|
|
45
|
+
| `block` | `boolean` | `true` | full width |
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* CSS variables — ColorPicker (--aui-color-picker-*) */
|
|
2
|
+
export const docsCssVariables = `--aui-color-picker-bg-primary: var(--aui-input-bg-primary); /* field fill */
|
|
3
|
+
--aui-color-picker-fg-primary: var(--aui-input-fg-primary); /* field foreground */
|
|
4
|
+
--aui-color-picker-fg-muted: var(--aui-input-fg-muted); /* placeholder and empty mark */
|
|
5
|
+
--aui-color-picker-border-primary: var(--aui-input-border-primary); /* field border */
|
|
6
|
+
--aui-color-picker-border-focus: var(--aui-input-border-focus); /* focus border */
|
|
7
|
+
--aui-color-picker-border-danger: var(--aui-input-border-danger); /* invalid border */
|
|
8
|
+
--aui-color-picker-radius-md: var(--aui-input-radius-md); /* field and area radius */
|
|
9
|
+
--aui-color-picker-h-sm: var(--aui-input-h-sm); /* height sm */
|
|
10
|
+
--aui-color-picker-h-md: var(--aui-input-h-md); /* height md */
|
|
11
|
+
--aui-color-picker-h-lg: var(--aui-input-h-lg); /* height lg */
|
|
12
|
+
--aui-color-picker-pad-x-sm: var(--aui-input-pad-x-sm); /* padding-x sm */
|
|
13
|
+
--aui-color-picker-pad-x-md: var(--aui-input-pad-x-md); /* padding-x md */
|
|
14
|
+
--aui-color-picker-pad-x-lg: var(--aui-input-pad-x-lg); /* padding-x lg */
|
|
15
|
+
--aui-color-picker-gap-md: var(--aui-spacing-8); /* gap inside the field and the panel */
|
|
16
|
+
--aui-color-picker-icon-size: var(--aui-spacing-16); /* clear icon size */
|
|
17
|
+
--aui-color-picker-icon-hit: var(--aui-spacing-24); /* clear icon hit area */
|
|
18
|
+
--aui-color-picker-clear-radius: var(--aui-control-radius-sm); /* clear button radius */
|
|
19
|
+
--aui-color-picker-swatch-sm: var(--aui-spacing-16); /* trigger swatch sm */
|
|
20
|
+
--aui-color-picker-swatch-md: var(--aui-spacing-20); /* trigger swatch md */
|
|
21
|
+
--aui-color-picker-swatch-lg: var(--aui-spacing-24); /* trigger swatch lg */
|
|
22
|
+
--aui-color-picker-swatch-radius: var(--aui-control-radius-sm); /* swatch radius */
|
|
23
|
+
--aui-color-picker-area: calc(var(--aui-spacing) * 48); /* saturation area size */
|
|
24
|
+
--aui-color-picker-slider-h: var(--aui-spacing-16); /* hue slider height */
|
|
25
|
+
--aui-color-picker-thumb: var(--aui-spacing-16); /* thumb size */
|
|
26
|
+
--aui-color-picker-thumb-ring: 2px; /* thumb ring width */
|
|
27
|
+
--aui-color-picker-empty-inset: 3px; /* empty swatch slash inset */
|
|
28
|
+
--aui-color-picker-thumb-border: var(--aui-surface-bg-elevated); /* thumb ring */
|
|
29
|
+
--aui-color-picker-preset: var(--aui-spacing-24); /* preset swatch size */
|
|
30
|
+
--aui-color-picker-popover-bg: var(--aui-surface-bg-elevated); /* panel fill */
|
|
31
|
+
--aui-color-picker-popover-border: var(--aui-surface-border-primary); /* panel border */
|
|
32
|
+
--aui-color-picker-popover-radius: var(--aui-control-radius-md); /* panel radius */
|
|
33
|
+
--aui-color-picker-popover-pad: var(--aui-spacing-12); /* panel padding */
|
|
34
|
+
--aui-color-picker-popover-border-w: 1px; /* panel border width */
|
|
35
|
+
--aui-color-picker-popover-w: calc(var(--aui-color-picker-area) + 2 * var(--aui-color-picker-popover-pad) + 2 * var(--aui-color-picker-popover-border-w)); /* panel width, flush with the area */
|
|
36
|
+
--aui-color-picker-popover-shadow: var(--aui-shadow-sm); /* panel shadow */
|
|
37
|
+
--aui-color-picker-popover-z: var(--aui-z-dropdown); /* panel z-index */
|
|
38
|
+
--aui-color-picker-duration-fast: var(--aui-control-duration-fast); /* transition duration */
|
|
39
|
+
--aui-color-picker-ease-out: var(--aui-control-ease-out); /* transition easing */
|
|
40
|
+
`;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type Ref } from 'react';
|
|
2
|
+
|
|
3
|
+
import { type IDataTestIdProps } from '@ds/common';
|
|
4
|
+
|
|
5
|
+
import { type IFieldStateProps } from '@/field/types';
|
|
6
|
+
import { type IFormFieldLayoutProps } from '@/form/types';
|
|
7
|
+
|
|
8
|
+
/** ColorPicker size. */
|
|
9
|
+
export type TColorPickerSize = 'sm' | 'md' | 'lg';
|
|
10
|
+
|
|
11
|
+
/** Visual variant. */
|
|
12
|
+
export type TColorPickerVariant = 'primary';
|
|
13
|
+
|
|
14
|
+
/** Theme inputs. */
|
|
15
|
+
export interface IColorPickerThemeProps {
|
|
16
|
+
/** Control size. Inside Field, inherits `Field.size` when omitted. */
|
|
17
|
+
size?: TColorPickerSize;
|
|
18
|
+
/** Visual variant. */
|
|
19
|
+
variant?: TColorPickerVariant;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Own / chrome props (not from RAC). */
|
|
23
|
+
export interface IColorPickerOwnProps extends IDataTestIdProps {
|
|
24
|
+
/** Clear button for the current value. */
|
|
25
|
+
clear?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Preset swatches inside the popover.
|
|
28
|
+
* Values that are not colors are dropped. No row when empty.
|
|
29
|
+
*/
|
|
30
|
+
presets?: string[];
|
|
31
|
+
/** Class name on the root. */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** Ref to the field group (React 19 prop). */
|
|
34
|
+
ref?: Ref<HTMLDivElement>;
|
|
35
|
+
/** Ref to the hex input (React 19 prop). */
|
|
36
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
37
|
+
id?: string;
|
|
38
|
+
'aria-label'?: string;
|
|
39
|
+
'aria-labelledby'?: string;
|
|
40
|
+
'aria-describedby'?: string;
|
|
41
|
+
'aria-invalid'?: boolean | 'true' | 'false';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Control state (our names, not RAC). */
|
|
45
|
+
export interface IColorPickerControlProps {
|
|
46
|
+
/** `#rrggbb` or `''`. */
|
|
47
|
+
value?: string;
|
|
48
|
+
/** `#rrggbb` or `''`. */
|
|
49
|
+
defaultValue?: string;
|
|
50
|
+
/** `''` or canonical `#rrggbb`. */
|
|
51
|
+
onChange?: (value: string) => void;
|
|
52
|
+
onBlur?: () => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface IColorPickerBaseProps
|
|
56
|
+
extends IColorPickerThemeProps, IFieldStateProps, IColorPickerOwnProps, IColorPickerControlProps {}
|
|
57
|
+
|
|
58
|
+
export interface IColorPickerProps extends IColorPickerBaseProps {}
|
|
59
|
+
|
|
60
|
+
/** Content slice for FormColorPicker. */
|
|
61
|
+
export interface IColorPickerContentProps {
|
|
62
|
+
clear?: boolean;
|
|
63
|
+
presets?: string[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface IFormColorPickerProps
|
|
67
|
+
extends IFormFieldLayoutProps, Pick<IColorPickerThemeProps, 'variant'>, IColorPickerContentProps {}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
File field: click, drag, and paste.
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
import { Dropzone, FormDropzone } from '@ensi-platform/admin-ui/dropzone';
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- attachments on an entity (several files, order matters)
|
|
10
|
+
- a single image (logo, avatar) — `maxFiles={1}` and an `accept` map whose keys are all `image/`
|
|
11
|
+
- a file import — the same primitive with `maxFiles={1}`
|
|
12
|
+
|
|
13
|
+
## API (short)
|
|
14
|
+
|
|
15
|
+
The value is `{ id, name, size, type, file?, url? }[]`. A new file gets `id` and `file`. A server file arrives with `id` and `url`. Rejection text is not part of the value. `title` and `description` sit above a large zone with an upload icon, and the files sit under the zone. Accepted types and the per-file limit sit in the zone, and `hint` is appended to that line. `validate` returns a refusal reason or nothing: a reason keeps the file out of the list. Count and total size sit on a line under the zone. At the count limit the zone says the limit is reached and does not take another file. `maxFiles={1}` keeps the zone open: the new file replaces the current one. `onChange` runs before `onRemove` of the file that left. `layout="grid"` renders cards: an image gets a preview, anything else gets a type icon. Retry and remove are buttons on the row. `upload` sends the file immediately; it enters the value after the response, with `id` and `url` and without `file`.
|
|
16
|
+
|
|
17
|
+
### Dropzone
|
|
18
|
+
|
|
19
|
+
| Prop | Values | Default | Description |
|
|
20
|
+
| --- | --- | --- | --- |
|
|
21
|
+
| `title` | `ReactNode` | — | heading above the zone |
|
|
22
|
+
| `description` | `ReactNode` | — | text under the heading |
|
|
23
|
+
| `hint` | `ReactNode` | — | extra rule on the zone line, after types and the per-file limit |
|
|
24
|
+
| `validate` | `(file) => string \| null \| Promise<...>` | — | empty keeps the file, a string is the refusal reason |
|
|
25
|
+
| `value` | `IDropzoneFile[]` | — | selected files; without it the list is kept inside |
|
|
26
|
+
| `defaultValue` | `IDropzoneFile[]` | — | initial list when `value` is omitted |
|
|
27
|
+
| `onChange` | `(files) => void` | — | next list |
|
|
28
|
+
| `onRemove` | `(file) => void` | — | after removal; the argument still has `id` |
|
|
29
|
+
| `renderAction` | `(file) => ReactNode` | — | extra control next to remove; `Dropzone.Action` is that button, with `icon` and `hidden` |
|
|
30
|
+
| `accept` | `Record<mime, string[]>` | — | allowed types |
|
|
31
|
+
| `maxSize` | `number` | — | max bytes per file |
|
|
32
|
+
| `maxTotalSize` | `number` | — | max bytes for the list plus files still uploading |
|
|
33
|
+
| `maxFiles` | `number` | — | count limit; `1` replaces the current file |
|
|
34
|
+
| `maxFileNameLength` | `number` | — | max name length |
|
|
35
|
+
| `paste` | `boolean` | `false` | paste into the focused zone |
|
|
36
|
+
| `loading` | `boolean` | `false` | zone stays and rejects files; skeleton rows replace the list |
|
|
37
|
+
| `layout` | `list` \| `grid` | `list` | rows or cards; picks `list` and `item` when those are omitted |
|
|
38
|
+
| `list` | `ComponentType<IFileListProps>` | from `layout` | custom file list |
|
|
39
|
+
| `item` | `ComponentType<IDropzoneItem>` | from `layout` | file element; the list receives it |
|
|
40
|
+
| `upload` | `(file, { onProgress, signal }) => Promise<{ id, url }>` | — | send immediately; `onProgress` moves the bar, `signal` cancels the row |
|
|
41
|
+
| `disabled` | `boolean \| { add?, remove?, reorder? }` | `false` | `true` blocks adding, removal, and reorder. An object blocks only keys set to `true`; the remove control stays in place |
|
|
42
|
+
| `invalid` | `boolean` | `false` | field error |
|
|
43
|
+
| `size` | `sm` \| `md` \| `lg` | `md` | size; inside Field inherits `Field.size` |
|
|
44
|
+
| `dataTestId` | `string` | — | `data-test-id` for tests |
|
|
45
|
+
|
|
46
|
+
A rejected file is not added. Valid files from the same batch are. The reason is a line under the field; the next batch with no rejections clears it. A click adds a row to the selection, and a second click on that row removes only it. Selection exists when there is more than one file and removal is allowed. A mouse drag starts from anywhere on the row except its buttons, and a click selects it. The grip stays for the keyboard and for touch. Dropping highlights the whole row under the pointer, and the file takes that row's place. The size sits under the name. While something is selected, that hint is replaced by a count on the left and icon buttons on the right: select all and delete selected. Select all is hidden when every file is selected. A second click, Escape, or a click outside the list clears the selection; Delete, Backspace, and Escape work only while focus is inside this dropzone. On touch a tap toggles a row. An in-flight row has Cancel: the row goes away and `onRemove` is not called. Without `onProgress` the bar has no number. A failed upload stays on the row, with the rejection text in place of the size, or the generic caption when that text is empty. It can be retried or discarded.
|
|
47
|
+
|
|
48
|
+
No `as`.
|
|
49
|
+
|
|
50
|
+
### FormDropzone
|
|
51
|
+
|
|
52
|
+
| Prop | Values | Default | Description |
|
|
53
|
+
| --- | --- | --- | --- |
|
|
54
|
+
| `name` | `string` | — | field name in `Form` |
|
|
55
|
+
| `label` | `ReactNode` | — | label (`Field.Label`) |
|
|
56
|
+
| `hint` | `ReactNode` | — | hint |
|
|
57
|
+
| `size` | `sm` \| `md` \| `lg` | `md` | size (on Field) |
|
|
58
|
+
| `disabled` | `boolean \| { add?, remove?, reorder? }` | — | same as Dropzone; `true` also disables Field |
|
|
59
|
+
| `accept` | `Record<mime, string[]>` | — | allowed types |
|
|
60
|
+
| `maxSize` | `number` | — | max bytes per file |
|
|
61
|
+
| `maxTotalSize` | `number` | — | max bytes for the sum |
|
|
62
|
+
| `maxFiles` | `number` | — | count limit; `1` replaces the file |
|
|
63
|
+
| `maxFileNameLength` | `number` | — | max name length |
|
|
64
|
+
| `paste` | `boolean` | `false` | paste |
|
|
65
|
+
| `loading` | `boolean` | `false` | skeleton instead of the list |
|
|
66
|
+
| `layout` | `list` \| `grid` | `list` | rows or cards |
|
|
67
|
+
| `upload` | `(file, { onProgress, signal }) => Promise<{ id, url }>` | — | send immediately |
|
|
68
|
+
| `validate` | `(file) => string \| null \| Promise<...>` | — | empty keeps the file, a string is the refusal reason |
|
|
69
|
+
| `onRemove` | `(file) => void` | — | after removal |
|
|
70
|
+
| `renderAction` | `(file) => ReactNode` | — | extra control, `Dropzone.Action` |
|
|
71
|
+
| `dataTestId` | `string` | — | `data-test-id` for tests |
|
|
72
|
+
|
|
73
|
+
The schema message and the rejection line share one slot under the field. A file rejection does not set a form error: submit stays available when the schema accepts the files already kept. Submit is blocked while a file is uploading or a failed upload is still in the list.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## Example
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
<Dropzone
|
|
5
|
+
title="Attachments"
|
|
6
|
+
description="PDF, up to 5 MB"
|
|
7
|
+
accept={{ 'application/pdf': ['.pdf'] }}
|
|
8
|
+
maxFiles={5}
|
|
9
|
+
maxSize={5 * 1024 * 1024}
|
|
10
|
+
upload={(file, _context) => Promise.resolve({ id: file.name, url: `/files/${file.name}` })}
|
|
11
|
+
/>
|
|
12
|
+
|
|
13
|
+
<Form initialValues={{ files: [] }} validationSchema={schema} onSubmit={save}>
|
|
14
|
+
<FormDropzone name="files" label="Attachments" hint="PDF, up to 5 MB" accept={{ 'application/pdf': ['.pdf'] }} />
|
|
15
|
+
<Button type="submit">Save</Button>
|
|
16
|
+
</Form>
|
|
17
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Dropzone CSS variables from semantic tokens (--aui-dropzone-*). */
|
|
2
|
+
export const docsCssVariables = `/* CSS variables — Dropzone (--aui-dropzone-*) */
|
|
3
|
+
--aui-dropzone-bg-primary: var(--aui-input-bg-primary); /* zone fill */
|
|
4
|
+
--aui-dropzone-bg-target: var(--aui-surface-bg-muted); /* drop target, quota track */
|
|
5
|
+
--aui-dropzone-bg-selected: var(--aui-surface-bg-muted-hover); /* selected row */
|
|
6
|
+
--aui-dropzone-fg-primary: var(--aui-input-fg-primary); /* primary foreground */
|
|
7
|
+
--aui-dropzone-fg-muted: var(--aui-input-fg-muted); /* muted foreground */
|
|
8
|
+
--aui-dropzone-fg-danger: var(--aui-field-error-fg); /* rejection foreground */
|
|
9
|
+
--aui-dropzone-border-primary: var(--aui-input-border-primary); /* zone border */
|
|
10
|
+
--aui-dropzone-border-focus: var(--aui-input-border-focus); /* focus border */
|
|
11
|
+
--aui-dropzone-border-selected: var(--aui-dropzone-border-focus); /* selected row border */
|
|
12
|
+
--aui-dropzone-fg-selected: var(--aui-dropzone-border-focus); /* selection check */
|
|
13
|
+
--aui-dropzone-border-danger: var(--aui-input-border-danger); /* invalid border */
|
|
14
|
+
--aui-dropzone-radius-sm: var(--aui-control-radius-sm); /* check inner corners */
|
|
15
|
+
--aui-dropzone-radius-md: var(--aui-input-radius-md); /* zone radius */
|
|
16
|
+
--aui-dropzone-pad-sm: var(--aui-spacing-12); /* padding sm */
|
|
17
|
+
--aui-dropzone-pad-md: var(--aui-spacing-16); /* padding md */
|
|
18
|
+
--aui-dropzone-pad-lg: var(--aui-spacing-24); /* padding lg */
|
|
19
|
+
--aui-dropzone-gap: var(--aui-spacing-8); /* gap between zone, list, and rejection */
|
|
20
|
+
--aui-dropzone-icon-size: var(--aui-spacing-20); /* row icon size */
|
|
21
|
+
--aui-dropzone-tile-size: var(--aui-spacing-32); /* file type tile */
|
|
22
|
+
--aui-dropzone-mark-size: var(--aui-spacing-32); /* zone upload icon size */
|
|
23
|
+
--aui-dropzone-hit: var(--aui-spacing-24); /* icon button hit target */
|
|
24
|
+
--aui-dropzone-row-h-sm: calc(var(--aui-spacing) * 11); /* file row height sm */
|
|
25
|
+
--aui-dropzone-row-h-md: calc(var(--aui-spacing) * 14); /* file row height md */
|
|
26
|
+
--aui-dropzone-row-h-lg: calc(var(--aui-spacing) * 18); /* file row height lg */
|
|
27
|
+
--aui-dropzone-preview-w: calc(var(--aui-spacing) * 28); /* image preview width */
|
|
28
|
+
--aui-dropzone-preview-h: var(--aui-dropzone-preview-w); /* image preview height */
|
|
29
|
+
--aui-dropzone-progress-h: var(--aui-spacing-4); /* upload progress height */
|
|
30
|
+
--aui-dropzone-duration-fast: var(--aui-input-duration-fast); /* transition duration (fast) */
|
|
31
|
+
--aui-dropzone-duration-normal: var(--aui-duration-normal); /* row move duration */
|
|
32
|
+
--aui-dropzone-ease-out: var(--aui-input-ease-out); /* transition easing */`;
|