jaci-ui 0.9.4 → 1.0.2
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/CHANGELOG.md +25 -0
- package/README.md +11 -1
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/components/accordion/accordion.cjs.map +1 -1
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert/alert.cjs.map +1 -1
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.cjs.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/aspect-ratio/aspect-ratio.cjs.map +1 -1
- package/dist/components/avatar/avatar.cjs.map +1 -1
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.cjs.map +1 -1
- package/dist/components/button/button.cjs +1 -0
- package/dist/components/button/button.cjs.map +1 -1
- package/dist/components/button/button.d.cts +2 -1
- package/dist/components/button/button.d.ts +2 -1
- package/dist/components/button/button.js +1 -0
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button-group/button-group.cjs.map +1 -1
- package/dist/components/calendar/calendar.cjs +4 -6
- package/dist/components/calendar/calendar.cjs.map +1 -1
- package/dist/components/calendar/calendar.js +4 -6
- package/dist/components/calendar/calendar.js.map +1 -1
- package/dist/components/card/card.cjs.map +1 -1
- package/dist/components/carousel/carousel.cjs.map +1 -1
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.cjs +7 -3
- package/dist/components/checkbox-group/checkbox-group.cjs.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.js +7 -3
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
- package/dist/components/code/code.cjs.map +1 -1
- package/dist/components/code/code.js.map +1 -1
- package/dist/components/collapsible/collapsible.cjs.map +1 -1
- package/dist/components/collapsible/collapsible.js.map +1 -1
- package/dist/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/components/color-picker/color-picker.js.map +1 -1
- package/dist/components/color-picker/color-utils.cjs +5 -3
- package/dist/components/color-picker/color-utils.cjs.map +1 -1
- package/dist/components/color-picker/color-utils.js +5 -3
- package/dist/components/color-picker/color-utils.js.map +1 -1
- package/dist/components/color-swatch/color-swatch.cjs.map +1 -1
- package/dist/components/combobox/combobox.cjs +2 -1
- package/dist/components/combobox/combobox.cjs.map +1 -1
- package/dist/components/combobox/combobox.js +2 -1
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/command/command.cjs.map +1 -1
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/context-menu/context-menu.cjs.map +1 -1
- package/dist/components/context-menu/context-menu.d.cts +2 -2
- package/dist/components/context-menu/context-menu.d.ts +2 -2
- package/dist/components/controls/checkbox.cjs.map +1 -1
- package/dist/components/controls/checkbox.js.map +1 -1
- package/dist/components/controls/input.cjs.map +1 -1
- package/dist/components/controls/input.js.map +1 -1
- package/dist/components/controls/radio.cjs.map +1 -1
- package/dist/components/controls/switch.cjs.map +1 -1
- package/dist/components/controls/switch.js.map +1 -1
- package/dist/components/controls/textarea.cjs.map +1 -1
- package/dist/components/controls/textarea.js.map +1 -1
- package/dist/components/copyable/copyable.cjs.map +1 -1
- package/dist/components/copyable/copyable.js.map +1 -1
- package/dist/components/data-toolbar/data-toolbar.cjs.map +1 -1
- package/dist/components/data-toolbar/data-toolbar.js.map +1 -1
- package/dist/components/data-view/data-view.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.cjs +4 -7
- package/dist/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.js +4 -7
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.cjs +4 -6
- package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +4 -6
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/dialog/dialog.cjs.map +1 -1
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/download-trigger/download-trigger.cjs.map +1 -1
- package/dist/components/drawer/drawer.cjs.map +1 -1
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/empty-state/empty-state.cjs.map +1 -1
- package/dist/components/feedback/badge.cjs.map +1 -1
- package/dist/components/field/field.cjs.map +1 -1
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/fieldset/fieldset.cjs.map +1 -1
- package/dist/components/figure/figure.cjs.map +1 -1
- package/dist/components/figure/figure.js.map +1 -1
- package/dist/components/form/form.cjs.map +1 -1
- package/dist/components/form/form.js.map +1 -1
- package/dist/components/icon-button/icon-button.cjs.map +1 -1
- package/dist/components/icon-button/icon-button.js.map +1 -1
- package/dist/components/image/image.cjs.map +1 -1
- package/dist/components/image/image.js.map +1 -1
- package/dist/components/input-group/input-group.cjs.map +1 -1
- package/dist/components/kbd/kbd.cjs.map +1 -1
- package/dist/components/layout/index.cjs.map +1 -1
- package/dist/components/list/list.cjs.map +1 -1
- package/dist/components/menu/menu.cjs.map +1 -1
- package/dist/components/menu/menu.d.cts +2 -2
- package/dist/components/menu/menu.d.ts +2 -2
- package/dist/components/menubar/menubar.cjs.map +1 -1
- package/dist/components/menubar/menubar.d.cts +2 -2
- package/dist/components/menubar/menubar.d.ts +2 -2
- package/dist/components/menubar/menubar.js.map +1 -1
- package/dist/components/meter/meter.cjs.map +1 -1
- package/dist/components/meter/meter.js.map +1 -1
- package/dist/components/navigation/navigation.cjs.map +1 -1
- package/dist/components/navigation/navigation.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.cjs.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/number-field/number-field.cjs +2 -1
- package/dist/components/number-field/number-field.cjs.map +1 -1
- package/dist/components/number-field/number-field.js +2 -1
- package/dist/components/number-field/number-field.js.map +1 -1
- package/dist/components/option-selector/option-selector.cjs.map +1 -1
- package/dist/components/option-selector/option-selector.js.map +1 -1
- package/dist/components/pagination/pagination.cjs.map +1 -1
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/pin-input/pin-input.cjs.map +1 -1
- package/dist/components/pin-input/pin-input.js.map +1 -1
- package/dist/components/popover/popover.cjs.map +1 -1
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/progress/progress.cjs.map +1 -1
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/qr-code/qr-code.cjs.map +1 -1
- package/dist/components/qr-code/qr-code.js.map +1 -1
- package/dist/components/quote/quote.cjs.map +1 -1
- package/dist/components/quote/quote.js.map +1 -1
- package/dist/components/radio-group/radio-group.cjs +7 -3
- package/dist/components/radio-group/radio-group.cjs.map +1 -1
- package/dist/components/radio-group/radio-group.js +7 -3
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/range-slider/range-slider.cjs.map +1 -1
- package/dist/components/range-slider/range-slider.js.map +1 -1
- package/dist/components/scroll-area/scroll-area.cjs.map +1 -1
- package/dist/components/select/select.cjs.map +1 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/skeleton/skeleton.cjs.map +1 -1
- package/dist/components/slider/slider.cjs.map +1 -1
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/spacer/spacer.cjs.map +1 -1
- package/dist/components/stat/stat.cjs.map +1 -1
- package/dist/components/stat/stat.js.map +1 -1
- package/dist/components/stepper/stepper.cjs +2 -1
- package/dist/components/stepper/stepper.cjs.map +1 -1
- package/dist/components/stepper/stepper.js +2 -1
- package/dist/components/stepper/stepper.js.map +1 -1
- package/dist/components/table/table.cjs.map +1 -1
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.cjs.map +1 -1
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/tags-input/tags-input.cjs +10 -9
- package/dist/components/tags-input/tags-input.cjs.map +1 -1
- package/dist/components/tags-input/tags-input.js +10 -9
- package/dist/components/tags-input/tags-input.js.map +1 -1
- package/dist/components/toast/toast.cjs.map +1 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toggle/toggle.cjs.map +1 -1
- package/dist/components/toggle-group/toggle-group.cjs.map +1 -1
- package/dist/components/toolbar/toolbar.cjs.map +1 -1
- package/dist/components/tooltip/tooltip.cjs.map +1 -1
- package/dist/components/tree-view/tree-view.cjs.map +1 -1
- package/dist/components/tree-view/tree-view.js.map +1 -1
- package/dist/components/typography/heading.cjs.map +1 -1
- package/dist/components/typography/link.cjs.map +1 -1
- package/dist/components/typography/paragraph.cjs.map +1 -1
- package/dist/components/typography/text.cjs.map +1 -1
- package/dist/components/upload/upload.cjs +2 -2
- package/dist/components/upload/upload.cjs.map +1 -1
- package/dist/components/upload/upload.js +2 -2
- package/dist/components/upload/upload.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.cjs.map +1 -1
- package/dist/panda-preset.cjs.map +1 -1
- package/dist/styles/theme.cjs +18 -18
- package/dist/styles/theme.cjs.map +1 -1
- package/dist/styles/theme.js +18 -18
- package/dist/styles/theme.js.map +1 -1
- package/dist/styles.css +12 -21
- package/dist/theme/theme-provider.cjs.map +1 -1
- package/dist/theme/theme-provider.js.map +1 -1
- package/dist/theme/theme-scope.cjs.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.cjs","names":["BaseTooltip","withRecipeClassName","tooltip","useThemePortalProps"],"sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport { Tooltip as BaseTooltip } from \"@base-ui/react/tooltip\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { TooltipRoot as BaseTooltipRoot } from \"@base-ui/react/tooltip\";\n\nimport { tooltip } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\n/** Preserves Base UI's controlled `open` API and uncontrolled `defaultOpen` API. */\nexport type TooltipRootProps<Payload = unknown> = BaseTooltipRoot.Props<Payload>;\n\nexport function TooltipRoot<Payload = unknown>(props: TooltipRootProps<Payload>) {\n return <BaseTooltip.Root {...props} />;\n}\n\nexport type TooltipTriggerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Trigger>;\n\nexport const TooltipTrigger = forwardRef<HTMLButtonElement, TooltipTriggerProps>(\n function TooltipTrigger({ className, ...props }, ref) {\n return (\n <BaseTooltip.Trigger\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().trigger, className)}\n data-jaci-component=\"tooltip\"\n data-slot=\"tooltip-trigger\"\n />\n );\n },\n);\n\n/** Preserves Base UI's optional portal container and mount controls. */\nexport function TooltipPortal(props: ComponentPropsWithoutRef<typeof BaseTooltip.Portal>) {\n return <BaseTooltip.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type TooltipPositionerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Positioner>;\n\nexport const TooltipPositioner = forwardRef<HTMLDivElement, TooltipPositionerProps>(\n function TooltipPositioner({ className, ...props }, ref) {\n return (\n <BaseTooltip.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().positioner, className)}\n data-slot=\"tooltip-positioner\"\n />\n );\n },\n);\n\nexport type TooltipPopupProps = ComponentPropsWithoutRef<typeof BaseTooltip.Popup>;\n\nexport const TooltipPopup = forwardRef<HTMLDivElement, TooltipPopupProps>(function TooltipPopup(\n { className, ...props },\n ref,\n) {\n return (\n <BaseTooltip.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().popup, className)}\n data-jaci-component=\"tooltip\"\n data-slot=\"tooltip-popup\"\n />\n );\n});\n\nexport type TooltipArrowProps = ComponentPropsWithoutRef<typeof BaseTooltip.Arrow>;\n\nexport const TooltipArrow = forwardRef<HTMLDivElement, TooltipArrowProps>(function TooltipArrow(\n { className, ...props },\n ref,\n) {\n return (\n <BaseTooltip.Arrow\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().arrow, className)}\n data-slot=\"tooltip-arrow\"\n />\n );\n});\n\nexport const Tooltip = {\n Root: TooltipRoot,\n Trigger: TooltipTrigger,\n Portal: TooltipPortal,\n Positioner: TooltipPositioner,\n Popup: TooltipPopup,\n Arrow: TooltipArrow,\n createHandle: BaseTooltip.createHandle,\n};\n"],"mappings":";;;;;;;;AAcA,SAAgB,YAA+B,OAAkC;CAC/E,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,uBAAAA,QAAY,MAAb,EAAkB,GAAI,MAAQ,CAAA;AACvC;AAIA,MAAa,kBAAA,
|
|
1
|
+
{"version":3,"file":"tooltip.cjs","names":["BaseTooltip","forwardRef","withRecipeClassName","tooltip","useThemePortalProps"],"sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport { Tooltip as BaseTooltip } from \"@base-ui/react/tooltip\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { TooltipRoot as BaseTooltipRoot } from \"@base-ui/react/tooltip\";\n\nimport { tooltip } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\n/** Preserves Base UI's controlled `open` API and uncontrolled `defaultOpen` API. */\nexport type TooltipRootProps<Payload = unknown> = BaseTooltipRoot.Props<Payload>;\n\nexport function TooltipRoot<Payload = unknown>(props: TooltipRootProps<Payload>) {\n return <BaseTooltip.Root {...props} />;\n}\n\nexport type TooltipTriggerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Trigger>;\n\nexport const TooltipTrigger = forwardRef<HTMLButtonElement, TooltipTriggerProps>(\n function TooltipTrigger({ className, ...props }, ref) {\n return (\n <BaseTooltip.Trigger\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().trigger, className)}\n data-jaci-component=\"tooltip\"\n data-slot=\"tooltip-trigger\"\n />\n );\n },\n);\n\n/** Preserves Base UI's optional portal container and mount controls. */\nexport function TooltipPortal(props: ComponentPropsWithoutRef<typeof BaseTooltip.Portal>) {\n return <BaseTooltip.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type TooltipPositionerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Positioner>;\n\nexport const TooltipPositioner = forwardRef<HTMLDivElement, TooltipPositionerProps>(\n function TooltipPositioner({ className, ...props }, ref) {\n return (\n <BaseTooltip.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().positioner, className)}\n data-slot=\"tooltip-positioner\"\n />\n );\n },\n);\n\nexport type TooltipPopupProps = ComponentPropsWithoutRef<typeof BaseTooltip.Popup>;\n\nexport const TooltipPopup = forwardRef<HTMLDivElement, TooltipPopupProps>(function TooltipPopup(\n { className, ...props },\n ref,\n) {\n return (\n <BaseTooltip.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().popup, className)}\n data-jaci-component=\"tooltip\"\n data-slot=\"tooltip-popup\"\n />\n );\n});\n\nexport type TooltipArrowProps = ComponentPropsWithoutRef<typeof BaseTooltip.Arrow>;\n\nexport const TooltipArrow = forwardRef<HTMLDivElement, TooltipArrowProps>(function TooltipArrow(\n { className, ...props },\n ref,\n) {\n return (\n <BaseTooltip.Arrow\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().arrow, className)}\n data-slot=\"tooltip-arrow\"\n />\n );\n});\n\nexport const Tooltip = {\n Root: TooltipRoot,\n Trigger: TooltipTrigger,\n Portal: TooltipPortal,\n Positioner: TooltipPositioner,\n Popup: TooltipPopup,\n Arrow: TooltipArrow,\n createHandle: BaseTooltip.createHandle,\n};\n"],"mappings":";;;;;;;;AAcA,SAAgB,YAA+B,OAAkC;CAC/E,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,uBAAAA,QAAY,MAAb,EAAkB,GAAI,MAAQ,CAAA;AACvC;AAIA,MAAa,kBAAA,GAAiBC,MAAAA,WAAAA,CAC5B,SAAS,eAAe,EAAE,WAAW,GA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AAS;CACT,QAAQ;CACR,YAAY;CACZ,OAAO;CACP,OAAO;CACP,cAAcH,uBAAAA,QAAY;AAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-view.cjs","names":["treeView","cx","Children"],"sources":["../../../src/components/tree-view/tree-view.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Children, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { treeView } from \"../../styled-system/recipes\";\n\nexport type TreeViewSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TreeViewSelection = string | readonly string[] | null;\n\ninterface TreeNodeRecord {\n id: string;\n parentId: string | undefined;\n disabled: boolean;\n hasChildren: boolean;\n loading: boolean;\n selectable: boolean;\n order: number;\n element: HTMLDivElement | null;\n}\n\ninterface TreeViewContextValue {\n disabled: boolean;\n loopFocus: boolean;\n selectionMode: TreeViewSelectionMode;\n expanded: ReadonlySet<string>;\n selected: ReadonlySet<string>;\n nodes: readonly TreeNodeRecord[];\n registerNode: (node: TreeNodeRecord) => () => void;\n setNodeElement: (id: string, element: HTMLDivElement | null) => void;\n isVisible: (id: string) => boolean;\n hasChildren: (id: string) => boolean;\n getDepth: (id: string) => number;\n getSiblings: (id: string) => readonly TreeNodeRecord[];\n toggleExpanded: (id: string) => void;\n selectNode: (id: string) => void;\n focusNode: (id: string) => void;\n handleKeyDown: (id: string, event: KeyboardEvent<HTMLDivElement>) => void;\n activeId: string | null;\n setActiveId: (id: string) => void;\n}\n\nconst TreeViewContext = createContext<TreeViewContextValue | null>(null);\nconst TreeParentContext = createContext<string | undefined>(undefined);\nconst TreeItemContext = createContext<string | null>(null);\n\nfunction useTreeViewContext() {\n const context = useContext(TreeViewContext);\n if (!context) throw new Error(\"TreeView parts must be rendered inside TreeView.Root.\");\n return context;\n}\n\nfunction asSet(value: string | readonly string[] | null | undefined, mode: TreeViewSelectionMode) {\n if (mode === \"multiple\") return new Set(Array.isArray(value) ? value : value ? [value] : []);\n return new Set(typeof value === \"string\" ? [value] : []);\n}\n\nexport interface TreeViewRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n expanded?: readonly string[];\n defaultExpanded?: readonly string[];\n onExpandedChange?: (expanded: string[]) => void;\n selected?: TreeViewSelection;\n defaultSelected?: TreeViewSelection;\n onSelectedChange?: (selected: TreeViewSelection) => void;\n selectionMode?: TreeViewSelectionMode;\n loopFocus?: boolean;\n disabled?: boolean;\n children?: ReactNode;\n}\n\nexport const TreeViewRoot = forwardRef<HTMLDivElement, TreeViewRootProps>(function TreeViewRoot(\n {\n children,\n className,\n defaultExpanded = [],\n defaultSelected = null,\n disabled = false,\n expanded: controlledExpanded,\n loopFocus = true,\n onExpandedChange,\n onSelectedChange,\n selected: controlledSelected,\n selectionMode = \"single\",\n ...props\n },\n ref,\n) {\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpanded));\n const [uncontrolledSelected, setUncontrolledSelected] = useState(() =>\n asSet(defaultSelected, selectionMode),\n );\n const [activeId, setActiveId] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const nodesRef = useRef(new Map<string, TreeNodeRecord>());\n const orderRef = useRef(0);\n const styles = treeView();\n const expanded = useMemo(\n () => new Set(controlledExpanded ?? uncontrolledExpanded),\n [controlledExpanded, uncontrolledExpanded],\n );\n const selected = useMemo(\n () =>\n controlledSelected === undefined\n ? uncontrolledSelected\n : asSet(controlledSelected, selectionMode),\n [controlledSelected, selectionMode, uncontrolledSelected],\n );\n const nodes = Array.from(nodesRef.current.values()).sort((a, b) => a.order - b.order);\n\n const registerNode = useCallback((node: TreeNodeRecord) => {\n const registeredNode = { ...node, order: orderRef.current++ };\n nodesRef.current.set(node.id, registeredNode);\n setVersion((current) => current + 1);\n return () => {\n if (nodesRef.current.get(node.id) === registeredNode) nodesRef.current.delete(node.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setNodeElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const node = nodesRef.current.get(id);\n if (node) node.element = element;\n }, []);\n\n const hasChildren = useCallback(\n (id: string) =>\n nodes.some((node) => node.parentId === id) ||\n Boolean(nodes.find((node) => node.id === id)?.hasChildren),\n [nodes],\n );\n const isVisible = useCallback(\n (id: string) => {\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n if (!expanded.has(current.parentId)) return false;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return true;\n },\n [expanded, nodes],\n );\n const getDepth = useCallback(\n (id: string) => {\n let depth = 1;\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n depth += 1;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return depth;\n },\n [nodes],\n );\n const getSiblings = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n return nodes.filter((candidate) => candidate.parentId === node?.parentId);\n },\n [nodes],\n );\n\n const toggleExpanded = useCallback(\n (id: string) => {\n if (disabled || !hasChildren(id)) return;\n const next = new Set(expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledExpanded === undefined) setUncontrolledExpanded(next);\n onExpandedChange?.(Array.from(next));\n },\n [controlledExpanded, disabled, expanded, hasChildren, onExpandedChange],\n );\n\n const selectNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (disabled || !node || node.disabled || !node.selectable || selectionMode === \"none\")\n return;\n const next = new Set(selected);\n if (selectionMode === \"single\") {\n next.clear();\n next.add(id);\n } else if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledSelected === undefined) setUncontrolledSelected(next);\n onSelectedChange?.(\n selectionMode === \"multiple\" ? Array.from(next) : (next.values().next().value ?? null),\n );\n },\n [controlledSelected, disabled, nodes, onSelectedChange, selected, selectionMode],\n );\n\n const visibleNodes = nodes.filter((node) => isVisible(node.id));\n const focusNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node || node.disabled || !isVisible(id)) return;\n setActiveId(id);\n node.element?.focus();\n },\n [isVisible, nodes],\n );\n\n const handleKeyDown = useCallback(\n (id: string, event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const index = visibleNodes.findIndex((node) => node.id === id);\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = index + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleNodes.length) % visibleNodes.length;\n const nextNode = visibleNodes[nextIndex];\n if (nextIndex >= 0 && nextIndex < visibleNodes.length && nextNode) focusNode(nextNode.id);\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusNode((event.key === \"Home\" ? visibleNodes[0] : visibleNodes.at(-1))?.id ?? id);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (hasChildren(id) && !expanded.has(id)) toggleExpanded(id);\n else if (hasChildren(id))\n focusNode(nodes.find((candidate) => candidate.parentId === id)?.id ?? id);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (hasChildren(id) && expanded.has(id)) toggleExpanded(id);\n else if (node.parentId) focusNode(node.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectNode(id);\n }\n },\n [\n disabled,\n expanded,\n focusNode,\n hasChildren,\n loopFocus,\n nodes,\n selectNode,\n toggleExpanded,\n visibleNodes,\n ],\n );\n\n const context = useMemo<TreeViewContextValue>(\n () => ({\n disabled,\n loopFocus,\n selectionMode,\n expanded,\n selected,\n nodes,\n registerNode,\n setNodeElement,\n isVisible,\n hasChildren,\n getDepth,\n getSiblings,\n toggleExpanded,\n selectNode,\n focusNode,\n handleKeyDown,\n activeId,\n setActiveId,\n }),\n [\n activeId,\n disabled,\n expanded,\n focusNode,\n getDepth,\n getSiblings,\n handleKeyDown,\n hasChildren,\n isVisible,\n loopFocus,\n nodes,\n registerNode,\n selectNode,\n selected,\n selectionMode,\n setNodeElement,\n toggleExpanded,\n ],\n );\n\n return (\n <TreeViewContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n aria-multiselectable={selectionMode === \"multiple\" || undefined}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"tree-view\"\n data-slot=\"tree-view\"\n role=\"tree\"\n >\n {children}\n </div>\n </TreeViewContext.Provider>\n );\n});\n\nexport interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"id\"> {\n id: string;\n disabled?: boolean;\n hasChildren?: boolean;\n loading?: boolean;\n selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = false,\n hasChildren: hasChildrenProp = false,\n loading = false,\n onClick,\n onFocus,\n onKeyDown,\n style,\n selectable = true,\n id,\n ...props\n },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n useEffect(\n () =>\n context.registerNode({\n id,\n parentId,\n disabled,\n hasChildren: hasChildrenProp,\n loading,\n selectable,\n order: 0,\n element: null,\n }),\n [context.registerNode, disabled, hasChildrenProp, id, loading, parentId, selectable],\n );\n const siblings = context.getSiblings(id);\n const registeredNode = context.nodes.find((candidate) => candidate.id === id);\n const selected = context.selected.has(id);\n const visible = context.isVisible(id);\n const siblingIndex = siblings.findIndex((candidate) => candidate.id === id);\n const tabIndex =\n context.activeId === id || (context.activeId === null && context.nodes[0]?.id === id) ? 0 : -1;\n const childNodes = Children.toArray(children);\n const groupNodes = childNodes.filter(\n (child) => isValidElement(child) && child.type === TreeViewGroup,\n );\n const rowNodes = childNodes.filter(\n (child) => !(isValidElement(child) && child.type === TreeViewGroup),\n );\n\n return (\n <TreeParentContext.Provider value={id}>\n <TreeItemContext.Provider value={id}>\n <div\n {...props}\n ref={(element) => {\n context.setNodeElement(id, element);\n if (typeof ref === \"function\") ref(element);\n else if (ref) ref.current = element;\n }}\n aria-disabled={disabled || undefined}\n aria-expanded={context.hasChildren(id) ? context.expanded.has(id) : undefined}\n aria-busy={loading || undefined}\n aria-level={registeredNode ? context.getDepth(id) : parentId ? 2 : 1}\n aria-posinset={siblingIndex >= 0 ? siblingIndex + 1 : 1}\n aria-setsize={siblings.length || 1}\n aria-selected={context.selectionMode === \"none\" ? undefined : selected}\n className={styles.itemWrapper}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-jaci-component=\"tree-view\"\n data-selected={selected || undefined}\n data-loading={loading || undefined}\n data-slot=\"tree-view-item\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented) context.selectNode(id);\n }}\n onFocus={(event) => {\n context.setActiveId(id);\n onFocus?.(event);\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n context.handleKeyDown(id, event);\n onKeyDown?.(event);\n }}\n role=\"treeitem\"\n tabIndex={visible ? tabIndex : -1}\n >\n <div\n className={cx(styles.item, className)}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-selected={selected || undefined}\n data-slot=\"tree-view-item-row\"\n style={style}\n >\n {rowNodes}\n </div>\n {groupNodes}\n </div>\n </TreeItemContext.Provider>\n </TreeParentContext.Provider>\n );\n});\n\nexport type TreeViewGroupProps = ComponentPropsWithoutRef<\"div\">;\nexport const TreeViewGroup = forwardRef<HTMLDivElement, TreeViewGroupProps>(function TreeViewGroup(\n { children, className, style, ...props },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n const visible = parentId ? context.expanded.has(parentId) : true;\n return (\n // biome-ignore lint/a11y/useSemanticElements: WAI-ARIA tree groups require role=\"group\".\n <div\n {...props}\n ref={ref}\n aria-hidden={!visible || undefined}\n className={cx(styles.group, className)}\n data-jaci-component=\"tree-view\"\n data-expanded={visible || undefined}\n data-slot=\"tree-view-group\"\n hidden={!visible}\n role=\"group\"\n style={{ ...style, display: visible ? style?.display : \"none\" }}\n >\n {children}\n </div>\n );\n});\n\nexport type TreeViewToggleProps = ComponentPropsWithoutRef<\"button\">;\nexport const TreeViewToggle = forwardRef<HTMLButtonElement, TreeViewToggleProps>(\n function TreeViewToggle({ children, className, onClick, ...props }, ref) {\n const context = useTreeViewContext();\n const itemId = useContext(TreeItemContext);\n const id = itemId;\n const item = id ? context.nodes.find((candidate) => candidate.id === id) : undefined;\n const disabled = context.disabled || Boolean(item?.disabled);\n return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n aria-disabled={disabled || undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\n disabled={disabled || props.disabled}\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented && id) context.toggleExpanded(id);\n }}\n tabIndex={-1}\n type=\"button\"\n >\n {children ?? (id && context.expanded.has(id) ? \"▾\" : \"▸\")}\n </button>\n );\n },\n);\n\nexport type TreeViewLabelProps = ComponentPropsWithoutRef<\"span\">;\nexport const TreeViewLabel = forwardRef<HTMLSpanElement, TreeViewLabelProps>(function TreeViewLabel(\n { className, ...props },\n ref,\n) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(treeView().label, className)}\n data-slot=\"tree-view-label\"\n />\n );\n});\n\nexport interface TreeViewStateProps extends ComponentPropsWithoutRef<\"div\"> {\n children?: ReactNode;\n}\n\nexport const TreeViewLoading = forwardRef<HTMLDivElement, TreeViewStateProps>(\n function TreeViewLoading({ children = \"Loading…\", className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"polite\"\n aria-level={1}\n className={cx(treeView().loading, className)}\n data-slot=\"tree-view-loading\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n },\n);\n\nexport const TreeViewEmpty = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewEmpty(\n { children = \"No items found.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-level={1}\n className={cx(treeView().empty, className)}\n data-slot=\"tree-view-empty\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeViewError = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewError(\n { children = \"Something went wrong.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"assertive\"\n aria-level={1}\n className={cx(treeView().error, className)}\n data-slot=\"tree-view-error\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem,\n Group: TreeViewGroup,\n Toggle: TreeViewToggle,\n Label: TreeViewLabel,\n Loading: TreeViewLoading,\n Empty: TreeViewEmpty,\n Error: TreeViewError,\n};\n"],"mappings":";;;;;;AAqDA,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;AACvE,MAAM,qBAAA,GAAA,MAAA,cAAA,CAAsD,KAAA,CAAS;AACrE,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA+C,IAAI;AAEzD,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,MAAM,OAAsD,MAA6B;CAChG,IAAI,SAAS,YAAY,OAAO,IAAI,IAAI,MAAM,QAAQ,KAAK,IAAI,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC;CAC3F,OAAO,IAAI,IAAI,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI,CAAC,CAAC;AACzD;AAeA,MAAa,gBAAA,GAAA,MAAA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AAGD,kBAAAA,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,iBAAA,GAAA,MAAA,WAAA,CAA+D,SAAS,cACnF,EAAE,WAAW,yBAAyB,WAAW,GAAG,SACpD,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,iBAAc;EACd,aAAU;EACV,cAAY;EACZ,WAAWC,WAAAA,GAAGD,kBAAAA,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,SAAS;CACT,OAAO;CACP,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"tree-view.cjs","names":["createContext","useContext","forwardRef","useState","useRef","treeView","useMemo","useCallback","cx","Children","isValidElement"],"sources":["../../../src/components/tree-view/tree-view.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Children, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { treeView } from \"../../styled-system/recipes\";\n\nexport type TreeViewSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TreeViewSelection = string | readonly string[] | null;\n\ninterface TreeNodeRecord {\n id: string;\n parentId: string | undefined;\n disabled: boolean;\n hasChildren: boolean;\n loading: boolean;\n selectable: boolean;\n order: number;\n element: HTMLDivElement | null;\n}\n\ninterface TreeViewContextValue {\n disabled: boolean;\n loopFocus: boolean;\n selectionMode: TreeViewSelectionMode;\n expanded: ReadonlySet<string>;\n selected: ReadonlySet<string>;\n nodes: readonly TreeNodeRecord[];\n registerNode: (node: TreeNodeRecord) => () => void;\n setNodeElement: (id: string, element: HTMLDivElement | null) => void;\n isVisible: (id: string) => boolean;\n hasChildren: (id: string) => boolean;\n getDepth: (id: string) => number;\n getSiblings: (id: string) => readonly TreeNodeRecord[];\n toggleExpanded: (id: string) => void;\n selectNode: (id: string) => void;\n focusNode: (id: string) => void;\n handleKeyDown: (id: string, event: KeyboardEvent<HTMLDivElement>) => void;\n activeId: string | null;\n setActiveId: (id: string) => void;\n}\n\nconst TreeViewContext = createContext<TreeViewContextValue | null>(null);\nconst TreeParentContext = createContext<string | undefined>(undefined);\nconst TreeItemContext = createContext<string | null>(null);\n\nfunction useTreeViewContext() {\n const context = useContext(TreeViewContext);\n if (!context) throw new Error(\"TreeView parts must be rendered inside TreeView.Root.\");\n return context;\n}\n\nfunction asSet(value: string | readonly string[] | null | undefined, mode: TreeViewSelectionMode) {\n if (mode === \"multiple\") return new Set(Array.isArray(value) ? value : value ? [value] : []);\n return new Set(typeof value === \"string\" ? [value] : []);\n}\n\nexport interface TreeViewRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n expanded?: readonly string[];\n defaultExpanded?: readonly string[];\n onExpandedChange?: (expanded: string[]) => void;\n selected?: TreeViewSelection;\n defaultSelected?: TreeViewSelection;\n onSelectedChange?: (selected: TreeViewSelection) => void;\n selectionMode?: TreeViewSelectionMode;\n loopFocus?: boolean;\n disabled?: boolean;\n children?: ReactNode;\n}\n\nexport const TreeViewRoot = forwardRef<HTMLDivElement, TreeViewRootProps>(function TreeViewRoot(\n {\n children,\n className,\n defaultExpanded = [],\n defaultSelected = null,\n disabled = false,\n expanded: controlledExpanded,\n loopFocus = true,\n onExpandedChange,\n onSelectedChange,\n selected: controlledSelected,\n selectionMode = \"single\",\n ...props\n },\n ref,\n) {\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpanded));\n const [uncontrolledSelected, setUncontrolledSelected] = useState(() =>\n asSet(defaultSelected, selectionMode),\n );\n const [activeId, setActiveId] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const nodesRef = useRef(new Map<string, TreeNodeRecord>());\n const orderRef = useRef(0);\n const styles = treeView();\n const expanded = useMemo(\n () => new Set(controlledExpanded ?? uncontrolledExpanded),\n [controlledExpanded, uncontrolledExpanded],\n );\n const selected = useMemo(\n () =>\n controlledSelected === undefined\n ? uncontrolledSelected\n : asSet(controlledSelected, selectionMode),\n [controlledSelected, selectionMode, uncontrolledSelected],\n );\n const nodes = Array.from(nodesRef.current.values()).sort((a, b) => a.order - b.order);\n\n const registerNode = useCallback((node: TreeNodeRecord) => {\n const registeredNode = { ...node, order: orderRef.current++ };\n nodesRef.current.set(node.id, registeredNode);\n setVersion((current) => current + 1);\n return () => {\n if (nodesRef.current.get(node.id) === registeredNode) nodesRef.current.delete(node.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setNodeElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const node = nodesRef.current.get(id);\n if (node) node.element = element;\n }, []);\n\n const hasChildren = useCallback(\n (id: string) =>\n nodes.some((node) => node.parentId === id) ||\n Boolean(nodes.find((node) => node.id === id)?.hasChildren),\n [nodes],\n );\n const isVisible = useCallback(\n (id: string) => {\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n if (!expanded.has(current.parentId)) return false;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return true;\n },\n [expanded, nodes],\n );\n const getDepth = useCallback(\n (id: string) => {\n let depth = 1;\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n depth += 1;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return depth;\n },\n [nodes],\n );\n const getSiblings = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n return nodes.filter((candidate) => candidate.parentId === node?.parentId);\n },\n [nodes],\n );\n\n const toggleExpanded = useCallback(\n (id: string) => {\n if (disabled || !hasChildren(id)) return;\n const next = new Set(expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledExpanded === undefined) setUncontrolledExpanded(next);\n onExpandedChange?.(Array.from(next));\n },\n [controlledExpanded, disabled, expanded, hasChildren, onExpandedChange],\n );\n\n const selectNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (disabled || !node || node.disabled || !node.selectable || selectionMode === \"none\")\n return;\n const next = new Set(selected);\n if (selectionMode === \"single\") {\n next.clear();\n next.add(id);\n } else if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledSelected === undefined) setUncontrolledSelected(next);\n onSelectedChange?.(\n selectionMode === \"multiple\" ? Array.from(next) : (next.values().next().value ?? null),\n );\n },\n [controlledSelected, disabled, nodes, onSelectedChange, selected, selectionMode],\n );\n\n const visibleNodes = nodes.filter((node) => isVisible(node.id));\n const focusNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node || node.disabled || !isVisible(id)) return;\n setActiveId(id);\n node.element?.focus();\n },\n [isVisible, nodes],\n );\n\n const handleKeyDown = useCallback(\n (id: string, event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const index = visibleNodes.findIndex((node) => node.id === id);\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = index + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleNodes.length) % visibleNodes.length;\n const nextNode = visibleNodes[nextIndex];\n if (nextIndex >= 0 && nextIndex < visibleNodes.length && nextNode) focusNode(nextNode.id);\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusNode((event.key === \"Home\" ? visibleNodes[0] : visibleNodes.at(-1))?.id ?? id);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (hasChildren(id) && !expanded.has(id)) toggleExpanded(id);\n else if (hasChildren(id))\n focusNode(nodes.find((candidate) => candidate.parentId === id)?.id ?? id);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (hasChildren(id) && expanded.has(id)) toggleExpanded(id);\n else if (node.parentId) focusNode(node.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectNode(id);\n }\n },\n [\n disabled,\n expanded,\n focusNode,\n hasChildren,\n loopFocus,\n nodes,\n selectNode,\n toggleExpanded,\n visibleNodes,\n ],\n );\n\n const context = useMemo<TreeViewContextValue>(\n () => ({\n disabled,\n loopFocus,\n selectionMode,\n expanded,\n selected,\n nodes,\n registerNode,\n setNodeElement,\n isVisible,\n hasChildren,\n getDepth,\n getSiblings,\n toggleExpanded,\n selectNode,\n focusNode,\n handleKeyDown,\n activeId,\n setActiveId,\n }),\n [\n activeId,\n disabled,\n expanded,\n focusNode,\n getDepth,\n getSiblings,\n handleKeyDown,\n hasChildren,\n isVisible,\n loopFocus,\n nodes,\n registerNode,\n selectNode,\n selected,\n selectionMode,\n setNodeElement,\n toggleExpanded,\n ],\n );\n\n return (\n <TreeViewContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n aria-multiselectable={selectionMode === \"multiple\" || undefined}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"tree-view\"\n data-slot=\"tree-view\"\n role=\"tree\"\n >\n {children}\n </div>\n </TreeViewContext.Provider>\n );\n});\n\nexport interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"id\"> {\n id: string;\n disabled?: boolean;\n hasChildren?: boolean;\n loading?: boolean;\n selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = false,\n hasChildren: hasChildrenProp = false,\n loading = false,\n onClick,\n onFocus,\n onKeyDown,\n style,\n selectable = true,\n id,\n ...props\n },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n useEffect(\n () =>\n context.registerNode({\n id,\n parentId,\n disabled,\n hasChildren: hasChildrenProp,\n loading,\n selectable,\n order: 0,\n element: null,\n }),\n [context.registerNode, disabled, hasChildrenProp, id, loading, parentId, selectable],\n );\n const siblings = context.getSiblings(id);\n const registeredNode = context.nodes.find((candidate) => candidate.id === id);\n const selected = context.selected.has(id);\n const visible = context.isVisible(id);\n const siblingIndex = siblings.findIndex((candidate) => candidate.id === id);\n const tabIndex =\n context.activeId === id || (context.activeId === null && context.nodes[0]?.id === id) ? 0 : -1;\n const childNodes = Children.toArray(children);\n const groupNodes = childNodes.filter(\n (child) => isValidElement(child) && child.type === TreeViewGroup,\n );\n const rowNodes = childNodes.filter(\n (child) => !(isValidElement(child) && child.type === TreeViewGroup),\n );\n\n return (\n <TreeParentContext.Provider value={id}>\n <TreeItemContext.Provider value={id}>\n <div\n {...props}\n ref={(element) => {\n context.setNodeElement(id, element);\n if (typeof ref === \"function\") ref(element);\n else if (ref) ref.current = element;\n }}\n aria-disabled={disabled || undefined}\n aria-expanded={context.hasChildren(id) ? context.expanded.has(id) : undefined}\n aria-busy={loading || undefined}\n aria-level={registeredNode ? context.getDepth(id) : parentId ? 2 : 1}\n aria-posinset={siblingIndex >= 0 ? siblingIndex + 1 : 1}\n aria-setsize={siblings.length || 1}\n aria-selected={context.selectionMode === \"none\" ? undefined : selected}\n className={styles.itemWrapper}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-jaci-component=\"tree-view\"\n data-selected={selected || undefined}\n data-loading={loading || undefined}\n data-slot=\"tree-view-item\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented) context.selectNode(id);\n }}\n onFocus={(event) => {\n context.setActiveId(id);\n onFocus?.(event);\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n context.handleKeyDown(id, event);\n onKeyDown?.(event);\n }}\n role=\"treeitem\"\n tabIndex={visible ? tabIndex : -1}\n >\n <div\n className={cx(styles.item, className)}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-selected={selected || undefined}\n data-slot=\"tree-view-item-row\"\n style={style}\n >\n {rowNodes}\n </div>\n {groupNodes}\n </div>\n </TreeItemContext.Provider>\n </TreeParentContext.Provider>\n );\n});\n\nexport type TreeViewGroupProps = ComponentPropsWithoutRef<\"div\">;\nexport const TreeViewGroup = forwardRef<HTMLDivElement, TreeViewGroupProps>(function TreeViewGroup(\n { children, className, style, ...props },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n const visible = parentId ? context.expanded.has(parentId) : true;\n return (\n // biome-ignore lint/a11y/useSemanticElements: WAI-ARIA tree groups require role=\"group\".\n <div\n {...props}\n ref={ref}\n aria-hidden={!visible || undefined}\n className={cx(styles.group, className)}\n data-jaci-component=\"tree-view\"\n data-expanded={visible || undefined}\n data-slot=\"tree-view-group\"\n hidden={!visible}\n role=\"group\"\n style={{ ...style, display: visible ? style?.display : \"none\" }}\n >\n {children}\n </div>\n );\n});\n\nexport type TreeViewToggleProps = ComponentPropsWithoutRef<\"button\">;\nexport const TreeViewToggle = forwardRef<HTMLButtonElement, TreeViewToggleProps>(\n function TreeViewToggle({ children, className, onClick, ...props }, ref) {\n const context = useTreeViewContext();\n const itemId = useContext(TreeItemContext);\n const id = itemId;\n const item = id ? context.nodes.find((candidate) => candidate.id === id) : undefined;\n const disabled = context.disabled || Boolean(item?.disabled);\n return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n aria-disabled={disabled || undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\n disabled={disabled || props.disabled}\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented && id) context.toggleExpanded(id);\n }}\n tabIndex={-1}\n type=\"button\"\n >\n {children ?? (id && context.expanded.has(id) ? \"▾\" : \"▸\")}\n </button>\n );\n },\n);\n\nexport type TreeViewLabelProps = ComponentPropsWithoutRef<\"span\">;\nexport const TreeViewLabel = forwardRef<HTMLSpanElement, TreeViewLabelProps>(function TreeViewLabel(\n { className, ...props },\n ref,\n) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(treeView().label, className)}\n data-slot=\"tree-view-label\"\n />\n );\n});\n\nexport interface TreeViewStateProps extends ComponentPropsWithoutRef<\"div\"> {\n children?: ReactNode;\n}\n\nexport const TreeViewLoading = forwardRef<HTMLDivElement, TreeViewStateProps>(\n function TreeViewLoading({ children = \"Loading…\", className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"polite\"\n aria-level={1}\n className={cx(treeView().loading, className)}\n data-slot=\"tree-view-loading\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n },\n);\n\nexport const TreeViewEmpty = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewEmpty(\n { children = \"No items found.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-level={1}\n className={cx(treeView().empty, className)}\n data-slot=\"tree-view-empty\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeViewError = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewError(\n { children = \"Something went wrong.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"assertive\"\n aria-level={1}\n className={cx(treeView().error, className)}\n data-slot=\"tree-view-error\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem,\n Group: TreeViewGroup,\n Toggle: TreeViewToggle,\n Label: TreeViewLabel,\n Loading: TreeViewLoading,\n Empty: TreeViewEmpty,\n Error: TreeViewError,\n};\n"],"mappings":";;;;;;AAqDA,MAAM,mBAAA,GAAkBA,MAAAA,cAAAA,CAA2C,IAAI;AACvE,MAAM,qBAAA,G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":3,"file":"tree-view.js","names":[],"sources":["../../../src/components/tree-view/tree-view.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Children, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { treeView } from \"../../styled-system/recipes\";\n\nexport type TreeViewSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TreeViewSelection = string | readonly string[] | null;\n\ninterface TreeNodeRecord {\n id: string;\n parentId: string | undefined;\n disabled: boolean;\n hasChildren: boolean;\n loading: boolean;\n selectable: boolean;\n order: number;\n element: HTMLDivElement | null;\n}\n\ninterface TreeViewContextValue {\n disabled: boolean;\n loopFocus: boolean;\n selectionMode: TreeViewSelectionMode;\n expanded: ReadonlySet<string>;\n selected: ReadonlySet<string>;\n nodes: readonly TreeNodeRecord[];\n registerNode: (node: TreeNodeRecord) => () => void;\n setNodeElement: (id: string, element: HTMLDivElement | null) => void;\n isVisible: (id: string) => boolean;\n hasChildren: (id: string) => boolean;\n getDepth: (id: string) => number;\n getSiblings: (id: string) => readonly TreeNodeRecord[];\n toggleExpanded: (id: string) => void;\n selectNode: (id: string) => void;\n focusNode: (id: string) => void;\n handleKeyDown: (id: string, event: KeyboardEvent<HTMLDivElement>) => void;\n activeId: string | null;\n setActiveId: (id: string) => void;\n}\n\nconst TreeViewContext = createContext<TreeViewContextValue | null>(null);\nconst TreeParentContext = createContext<string | undefined>(undefined);\nconst TreeItemContext = createContext<string | null>(null);\n\nfunction useTreeViewContext() {\n const context = useContext(TreeViewContext);\n if (!context) throw new Error(\"TreeView parts must be rendered inside TreeView.Root.\");\n return context;\n}\n\nfunction asSet(value: string | readonly string[] | null | undefined, mode: TreeViewSelectionMode) {\n if (mode === \"multiple\") return new Set(Array.isArray(value) ? value : value ? [value] : []);\n return new Set(typeof value === \"string\" ? [value] : []);\n}\n\nexport interface TreeViewRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n expanded?: readonly string[];\n defaultExpanded?: readonly string[];\n onExpandedChange?: (expanded: string[]) => void;\n selected?: TreeViewSelection;\n defaultSelected?: TreeViewSelection;\n onSelectedChange?: (selected: TreeViewSelection) => void;\n selectionMode?: TreeViewSelectionMode;\n loopFocus?: boolean;\n disabled?: boolean;\n children?: ReactNode;\n}\n\nexport const TreeViewRoot = forwardRef<HTMLDivElement, TreeViewRootProps>(function TreeViewRoot(\n {\n children,\n className,\n defaultExpanded = [],\n defaultSelected = null,\n disabled = false,\n expanded: controlledExpanded,\n loopFocus = true,\n onExpandedChange,\n onSelectedChange,\n selected: controlledSelected,\n selectionMode = \"single\",\n ...props\n },\n ref,\n) {\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpanded));\n const [uncontrolledSelected, setUncontrolledSelected] = useState(() =>\n asSet(defaultSelected, selectionMode),\n );\n const [activeId, setActiveId] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const nodesRef = useRef(new Map<string, TreeNodeRecord>());\n const orderRef = useRef(0);\n const styles = treeView();\n const expanded = useMemo(\n () => new Set(controlledExpanded ?? uncontrolledExpanded),\n [controlledExpanded, uncontrolledExpanded],\n );\n const selected = useMemo(\n () =>\n controlledSelected === undefined\n ? uncontrolledSelected\n : asSet(controlledSelected, selectionMode),\n [controlledSelected, selectionMode, uncontrolledSelected],\n );\n const nodes = Array.from(nodesRef.current.values()).sort((a, b) => a.order - b.order);\n\n const registerNode = useCallback((node: TreeNodeRecord) => {\n const registeredNode = { ...node, order: orderRef.current++ };\n nodesRef.current.set(node.id, registeredNode);\n setVersion((current) => current + 1);\n return () => {\n if (nodesRef.current.get(node.id) === registeredNode) nodesRef.current.delete(node.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setNodeElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const node = nodesRef.current.get(id);\n if (node) node.element = element;\n }, []);\n\n const hasChildren = useCallback(\n (id: string) =>\n nodes.some((node) => node.parentId === id) ||\n Boolean(nodes.find((node) => node.id === id)?.hasChildren),\n [nodes],\n );\n const isVisible = useCallback(\n (id: string) => {\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n if (!expanded.has(current.parentId)) return false;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return true;\n },\n [expanded, nodes],\n );\n const getDepth = useCallback(\n (id: string) => {\n let depth = 1;\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n depth += 1;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return depth;\n },\n [nodes],\n );\n const getSiblings = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n return nodes.filter((candidate) => candidate.parentId === node?.parentId);\n },\n [nodes],\n );\n\n const toggleExpanded = useCallback(\n (id: string) => {\n if (disabled || !hasChildren(id)) return;\n const next = new Set(expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledExpanded === undefined) setUncontrolledExpanded(next);\n onExpandedChange?.(Array.from(next));\n },\n [controlledExpanded, disabled, expanded, hasChildren, onExpandedChange],\n );\n\n const selectNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (disabled || !node || node.disabled || !node.selectable || selectionMode === \"none\")\n return;\n const next = new Set(selected);\n if (selectionMode === \"single\") {\n next.clear();\n next.add(id);\n } else if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledSelected === undefined) setUncontrolledSelected(next);\n onSelectedChange?.(\n selectionMode === \"multiple\" ? Array.from(next) : (next.values().next().value ?? null),\n );\n },\n [controlledSelected, disabled, nodes, onSelectedChange, selected, selectionMode],\n );\n\n const visibleNodes = nodes.filter((node) => isVisible(node.id));\n const focusNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node || node.disabled || !isVisible(id)) return;\n setActiveId(id);\n node.element?.focus();\n },\n [isVisible, nodes],\n );\n\n const handleKeyDown = useCallback(\n (id: string, event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const index = visibleNodes.findIndex((node) => node.id === id);\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = index + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleNodes.length) % visibleNodes.length;\n const nextNode = visibleNodes[nextIndex];\n if (nextIndex >= 0 && nextIndex < visibleNodes.length && nextNode) focusNode(nextNode.id);\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusNode((event.key === \"Home\" ? visibleNodes[0] : visibleNodes.at(-1))?.id ?? id);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (hasChildren(id) && !expanded.has(id)) toggleExpanded(id);\n else if (hasChildren(id))\n focusNode(nodes.find((candidate) => candidate.parentId === id)?.id ?? id);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (hasChildren(id) && expanded.has(id)) toggleExpanded(id);\n else if (node.parentId) focusNode(node.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectNode(id);\n }\n },\n [\n disabled,\n expanded,\n focusNode,\n hasChildren,\n loopFocus,\n nodes,\n selectNode,\n toggleExpanded,\n visibleNodes,\n ],\n );\n\n const context = useMemo<TreeViewContextValue>(\n () => ({\n disabled,\n loopFocus,\n selectionMode,\n expanded,\n selected,\n nodes,\n registerNode,\n setNodeElement,\n isVisible,\n hasChildren,\n getDepth,\n getSiblings,\n toggleExpanded,\n selectNode,\n focusNode,\n handleKeyDown,\n activeId,\n setActiveId,\n }),\n [\n activeId,\n disabled,\n expanded,\n focusNode,\n getDepth,\n getSiblings,\n handleKeyDown,\n hasChildren,\n isVisible,\n loopFocus,\n nodes,\n registerNode,\n selectNode,\n selected,\n selectionMode,\n setNodeElement,\n toggleExpanded,\n ],\n );\n\n return (\n <TreeViewContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n aria-multiselectable={selectionMode === \"multiple\" || undefined}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"tree-view\"\n data-slot=\"tree-view\"\n role=\"tree\"\n >\n {children}\n </div>\n </TreeViewContext.Provider>\n );\n});\n\nexport interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"id\"> {\n id: string;\n disabled?: boolean;\n hasChildren?: boolean;\n loading?: boolean;\n selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = false,\n hasChildren: hasChildrenProp = false,\n loading = false,\n onClick,\n onFocus,\n onKeyDown,\n style,\n selectable = true,\n id,\n ...props\n },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n useEffect(\n () =>\n context.registerNode({\n id,\n parentId,\n disabled,\n hasChildren: hasChildrenProp,\n loading,\n selectable,\n order: 0,\n element: null,\n }),\n [context.registerNode, disabled, hasChildrenProp, id, loading, parentId, selectable],\n );\n const siblings = context.getSiblings(id);\n const registeredNode = context.nodes.find((candidate) => candidate.id === id);\n const selected = context.selected.has(id);\n const visible = context.isVisible(id);\n const siblingIndex = siblings.findIndex((candidate) => candidate.id === id);\n const tabIndex =\n context.activeId === id || (context.activeId === null && context.nodes[0]?.id === id) ? 0 : -1;\n const childNodes = Children.toArray(children);\n const groupNodes = childNodes.filter(\n (child) => isValidElement(child) && child.type === TreeViewGroup,\n );\n const rowNodes = childNodes.filter(\n (child) => !(isValidElement(child) && child.type === TreeViewGroup),\n );\n\n return (\n <TreeParentContext.Provider value={id}>\n <TreeItemContext.Provider value={id}>\n <div\n {...props}\n ref={(element) => {\n context.setNodeElement(id, element);\n if (typeof ref === \"function\") ref(element);\n else if (ref) ref.current = element;\n }}\n aria-disabled={disabled || undefined}\n aria-expanded={context.hasChildren(id) ? context.expanded.has(id) : undefined}\n aria-busy={loading || undefined}\n aria-level={registeredNode ? context.getDepth(id) : parentId ? 2 : 1}\n aria-posinset={siblingIndex >= 0 ? siblingIndex + 1 : 1}\n aria-setsize={siblings.length || 1}\n aria-selected={context.selectionMode === \"none\" ? undefined : selected}\n className={styles.itemWrapper}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-jaci-component=\"tree-view\"\n data-selected={selected || undefined}\n data-loading={loading || undefined}\n data-slot=\"tree-view-item\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented) context.selectNode(id);\n }}\n onFocus={(event) => {\n context.setActiveId(id);\n onFocus?.(event);\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n context.handleKeyDown(id, event);\n onKeyDown?.(event);\n }}\n role=\"treeitem\"\n tabIndex={visible ? tabIndex : -1}\n >\n <div\n className={cx(styles.item, className)}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-selected={selected || undefined}\n data-slot=\"tree-view-item-row\"\n style={style}\n >\n {rowNodes}\n </div>\n {groupNodes}\n </div>\n </TreeItemContext.Provider>\n </TreeParentContext.Provider>\n );\n});\n\nexport type TreeViewGroupProps = ComponentPropsWithoutRef<\"div\">;\nexport const TreeViewGroup = forwardRef<HTMLDivElement, TreeViewGroupProps>(function TreeViewGroup(\n { children, className, style, ...props },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n const visible = parentId ? context.expanded.has(parentId) : true;\n return (\n // biome-ignore lint/a11y/useSemanticElements: WAI-ARIA tree groups require role=\"group\".\n <div\n {...props}\n ref={ref}\n aria-hidden={!visible || undefined}\n className={cx(styles.group, className)}\n data-jaci-component=\"tree-view\"\n data-expanded={visible || undefined}\n data-slot=\"tree-view-group\"\n hidden={!visible}\n role=\"group\"\n style={{ ...style, display: visible ? style?.display : \"none\" }}\n >\n {children}\n </div>\n );\n});\n\nexport type TreeViewToggleProps = ComponentPropsWithoutRef<\"button\">;\nexport const TreeViewToggle = forwardRef<HTMLButtonElement, TreeViewToggleProps>(\n function TreeViewToggle({ children, className, onClick, ...props }, ref) {\n const context = useTreeViewContext();\n const itemId = useContext(TreeItemContext);\n const id = itemId;\n const item = id ? context.nodes.find((candidate) => candidate.id === id) : undefined;\n const disabled = context.disabled || Boolean(item?.disabled);\n return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n aria-disabled={disabled || undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\n disabled={disabled || props.disabled}\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented && id) context.toggleExpanded(id);\n }}\n tabIndex={-1}\n type=\"button\"\n >\n {children ?? (id && context.expanded.has(id) ? \"▾\" : \"▸\")}\n </button>\n );\n },\n);\n\nexport type TreeViewLabelProps = ComponentPropsWithoutRef<\"span\">;\nexport const TreeViewLabel = forwardRef<HTMLSpanElement, TreeViewLabelProps>(function TreeViewLabel(\n { className, ...props },\n ref,\n) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(treeView().label, className)}\n data-slot=\"tree-view-label\"\n />\n );\n});\n\nexport interface TreeViewStateProps extends ComponentPropsWithoutRef<\"div\"> {\n children?: ReactNode;\n}\n\nexport const TreeViewLoading = forwardRef<HTMLDivElement, TreeViewStateProps>(\n function TreeViewLoading({ children = \"Loading…\", className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"polite\"\n aria-level={1}\n className={cx(treeView().loading, className)}\n data-slot=\"tree-view-loading\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n },\n);\n\nexport const TreeViewEmpty = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewEmpty(\n { children = \"No items found.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-level={1}\n className={cx(treeView().empty, className)}\n data-slot=\"tree-view-empty\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeViewError = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewError(\n { children = \"Something went wrong.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"assertive\"\n aria-level={1}\n className={cx(treeView().error, className)}\n data-slot=\"tree-view-error\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem,\n Group: TreeViewGroup,\n Toggle: TreeViewToggle,\n Label: TreeViewLabel,\n Loading: TreeViewLoading,\n Empty: TreeViewEmpty,\n Error: TreeViewError,\n};\n"],"mappings":";;;;;;AAqDA,MAAM,kBAAkB,cAA2C,IAAI;AACvE,MAAM,oBAAoB,cAAkC,KAAA,CAAS;AACrE,MAAM,kBAAkB,cAA6B,IAAI;AAEzD,SAAS,qBAAqB;CAC5B,MAAM,UAAU,WAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,MAAM,OAAsD,MAA6B;CAChG,IAAI,SAAS,YAAY,OAAO,IAAI,IAAI,MAAM,QAAQ,KAAK,IAAI,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC;CAC3F,OAAO,IAAI,IAAI,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI,CAAC,CAAC;AACzD;AAeA,MAAa,eAAe,WAA8C,SAAS,aACjF,EACE,UACA,WACA,kBAAkB,CAAC,GACnB,kBAAkB,MAClB,WAAW,OACX,UAAU,oBACV,YAAY,MACZ,kBACA,kBACA,UAAU,oBACV,gBAAgB,UAChB,GAAG,SAEL,KACA;CACA,MAAM,CAAC,sBAAsB,2BAA2B,eAAe,IAAI,IAAI,eAAe,CAA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AAI;EACC;EACL,iBAAc;EACd,cAAY;EACZ,WAAW,GAAG,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,gBAAgB,WAA+C,SAAS,cACnF,EAAE,WAAW,yBAAyB,WAAW,GAAG,SACpD,KACA;CACA,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,iBAAc;EACd,aAAU;EACV,cAAY;EACZ,WAAW,GAAG,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,SAAS;CACT,OAAO;CACP,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"tree-view.js","names":[],"sources":["../../../src/components/tree-view/tree-view.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Children, isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { treeView } from \"../../styled-system/recipes\";\n\nexport type TreeViewSelectionMode = \"none\" | \"single\" | \"multiple\";\nexport type TreeViewSelection = string | readonly string[] | null;\n\ninterface TreeNodeRecord {\n id: string;\n parentId: string | undefined;\n disabled: boolean;\n hasChildren: boolean;\n loading: boolean;\n selectable: boolean;\n order: number;\n element: HTMLDivElement | null;\n}\n\ninterface TreeViewContextValue {\n disabled: boolean;\n loopFocus: boolean;\n selectionMode: TreeViewSelectionMode;\n expanded: ReadonlySet<string>;\n selected: ReadonlySet<string>;\n nodes: readonly TreeNodeRecord[];\n registerNode: (node: TreeNodeRecord) => () => void;\n setNodeElement: (id: string, element: HTMLDivElement | null) => void;\n isVisible: (id: string) => boolean;\n hasChildren: (id: string) => boolean;\n getDepth: (id: string) => number;\n getSiblings: (id: string) => readonly TreeNodeRecord[];\n toggleExpanded: (id: string) => void;\n selectNode: (id: string) => void;\n focusNode: (id: string) => void;\n handleKeyDown: (id: string, event: KeyboardEvent<HTMLDivElement>) => void;\n activeId: string | null;\n setActiveId: (id: string) => void;\n}\n\nconst TreeViewContext = createContext<TreeViewContextValue | null>(null);\nconst TreeParentContext = createContext<string | undefined>(undefined);\nconst TreeItemContext = createContext<string | null>(null);\n\nfunction useTreeViewContext() {\n const context = useContext(TreeViewContext);\n if (!context) throw new Error(\"TreeView parts must be rendered inside TreeView.Root.\");\n return context;\n}\n\nfunction asSet(value: string | readonly string[] | null | undefined, mode: TreeViewSelectionMode) {\n if (mode === \"multiple\") return new Set(Array.isArray(value) ? value : value ? [value] : []);\n return new Set(typeof value === \"string\" ? [value] : []);\n}\n\nexport interface TreeViewRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n expanded?: readonly string[];\n defaultExpanded?: readonly string[];\n onExpandedChange?: (expanded: string[]) => void;\n selected?: TreeViewSelection;\n defaultSelected?: TreeViewSelection;\n onSelectedChange?: (selected: TreeViewSelection) => void;\n selectionMode?: TreeViewSelectionMode;\n loopFocus?: boolean;\n disabled?: boolean;\n children?: ReactNode;\n}\n\nexport const TreeViewRoot = forwardRef<HTMLDivElement, TreeViewRootProps>(function TreeViewRoot(\n {\n children,\n className,\n defaultExpanded = [],\n defaultSelected = null,\n disabled = false,\n expanded: controlledExpanded,\n loopFocus = true,\n onExpandedChange,\n onSelectedChange,\n selected: controlledSelected,\n selectionMode = \"single\",\n ...props\n },\n ref,\n) {\n const [uncontrolledExpanded, setUncontrolledExpanded] = useState(() => new Set(defaultExpanded));\n const [uncontrolledSelected, setUncontrolledSelected] = useState(() =>\n asSet(defaultSelected, selectionMode),\n );\n const [activeId, setActiveId] = useState<string | null>(null);\n const [, setVersion] = useState(0);\n const nodesRef = useRef(new Map<string, TreeNodeRecord>());\n const orderRef = useRef(0);\n const styles = treeView();\n const expanded = useMemo(\n () => new Set(controlledExpanded ?? uncontrolledExpanded),\n [controlledExpanded, uncontrolledExpanded],\n );\n const selected = useMemo(\n () =>\n controlledSelected === undefined\n ? uncontrolledSelected\n : asSet(controlledSelected, selectionMode),\n [controlledSelected, selectionMode, uncontrolledSelected],\n );\n const nodes = Array.from(nodesRef.current.values()).sort((a, b) => a.order - b.order);\n\n const registerNode = useCallback((node: TreeNodeRecord) => {\n const registeredNode = { ...node, order: orderRef.current++ };\n nodesRef.current.set(node.id, registeredNode);\n setVersion((current) => current + 1);\n return () => {\n if (nodesRef.current.get(node.id) === registeredNode) nodesRef.current.delete(node.id);\n setVersion((current) => current + 1);\n };\n }, []);\n\n const setNodeElement = useCallback((id: string, element: HTMLDivElement | null) => {\n const node = nodesRef.current.get(id);\n if (node) node.element = element;\n }, []);\n\n const hasChildren = useCallback(\n (id: string) =>\n nodes.some((node) => node.parentId === id) ||\n Boolean(nodes.find((node) => node.id === id)?.hasChildren),\n [nodes],\n );\n const isVisible = useCallback(\n (id: string) => {\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n if (!expanded.has(current.parentId)) return false;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return true;\n },\n [expanded, nodes],\n );\n const getDepth = useCallback(\n (id: string) => {\n let depth = 1;\n let current = nodes.find((node) => node.id === id);\n while (current?.parentId) {\n depth += 1;\n current = nodes.find((node) => node.id === current?.parentId);\n }\n return depth;\n },\n [nodes],\n );\n const getSiblings = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n return nodes.filter((candidate) => candidate.parentId === node?.parentId);\n },\n [nodes],\n );\n\n const toggleExpanded = useCallback(\n (id: string) => {\n if (disabled || !hasChildren(id)) return;\n const next = new Set(expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledExpanded === undefined) setUncontrolledExpanded(next);\n onExpandedChange?.(Array.from(next));\n },\n [controlledExpanded, disabled, expanded, hasChildren, onExpandedChange],\n );\n\n const selectNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (disabled || !node || node.disabled || !node.selectable || selectionMode === \"none\")\n return;\n const next = new Set(selected);\n if (selectionMode === \"single\") {\n next.clear();\n next.add(id);\n } else if (next.has(id)) next.delete(id);\n else next.add(id);\n if (controlledSelected === undefined) setUncontrolledSelected(next);\n onSelectedChange?.(\n selectionMode === \"multiple\" ? Array.from(next) : (next.values().next().value ?? null),\n );\n },\n [controlledSelected, disabled, nodes, onSelectedChange, selected, selectionMode],\n );\n\n const visibleNodes = nodes.filter((node) => isVisible(node.id));\n const focusNode = useCallback(\n (id: string) => {\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node || node.disabled || !isVisible(id)) return;\n setActiveId(id);\n node.element?.focus();\n },\n [isVisible, nodes],\n );\n\n const handleKeyDown = useCallback(\n (id: string, event: KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const index = visibleNodes.findIndex((node) => node.id === id);\n const node = nodes.find((candidate) => candidate.id === id);\n if (!node) return;\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n const direction = event.key === \"ArrowDown\" ? 1 : -1;\n let nextIndex = index + direction;\n if (loopFocus) nextIndex = (nextIndex + visibleNodes.length) % visibleNodes.length;\n const nextNode = visibleNodes[nextIndex];\n if (nextIndex >= 0 && nextIndex < visibleNodes.length && nextNode) focusNode(nextNode.id);\n } else if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n focusNode((event.key === \"Home\" ? visibleNodes[0] : visibleNodes.at(-1))?.id ?? id);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n if (hasChildren(id) && !expanded.has(id)) toggleExpanded(id);\n else if (hasChildren(id))\n focusNode(nodes.find((candidate) => candidate.parentId === id)?.id ?? id);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n if (hasChildren(id) && expanded.has(id)) toggleExpanded(id);\n else if (node.parentId) focusNode(node.parentId);\n } else if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectNode(id);\n }\n },\n [\n disabled,\n expanded,\n focusNode,\n hasChildren,\n loopFocus,\n nodes,\n selectNode,\n toggleExpanded,\n visibleNodes,\n ],\n );\n\n const context = useMemo<TreeViewContextValue>(\n () => ({\n disabled,\n loopFocus,\n selectionMode,\n expanded,\n selected,\n nodes,\n registerNode,\n setNodeElement,\n isVisible,\n hasChildren,\n getDepth,\n getSiblings,\n toggleExpanded,\n selectNode,\n focusNode,\n handleKeyDown,\n activeId,\n setActiveId,\n }),\n [\n activeId,\n disabled,\n expanded,\n focusNode,\n getDepth,\n getSiblings,\n handleKeyDown,\n hasChildren,\n isVisible,\n loopFocus,\n nodes,\n registerNode,\n selectNode,\n selected,\n selectionMode,\n setNodeElement,\n toggleExpanded,\n ],\n );\n\n return (\n <TreeViewContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n aria-multiselectable={selectionMode === \"multiple\" || undefined}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"tree-view\"\n data-slot=\"tree-view\"\n role=\"tree\"\n >\n {children}\n </div>\n </TreeViewContext.Provider>\n );\n});\n\nexport interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"id\"> {\n id: string;\n disabled?: boolean;\n hasChildren?: boolean;\n loading?: boolean;\n selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = false,\n hasChildren: hasChildrenProp = false,\n loading = false,\n onClick,\n onFocus,\n onKeyDown,\n style,\n selectable = true,\n id,\n ...props\n },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n useEffect(\n () =>\n context.registerNode({\n id,\n parentId,\n disabled,\n hasChildren: hasChildrenProp,\n loading,\n selectable,\n order: 0,\n element: null,\n }),\n [context.registerNode, disabled, hasChildrenProp, id, loading, parentId, selectable],\n );\n const siblings = context.getSiblings(id);\n const registeredNode = context.nodes.find((candidate) => candidate.id === id);\n const selected = context.selected.has(id);\n const visible = context.isVisible(id);\n const siblingIndex = siblings.findIndex((candidate) => candidate.id === id);\n const tabIndex =\n context.activeId === id || (context.activeId === null && context.nodes[0]?.id === id) ? 0 : -1;\n const childNodes = Children.toArray(children);\n const groupNodes = childNodes.filter(\n (child) => isValidElement(child) && child.type === TreeViewGroup,\n );\n const rowNodes = childNodes.filter(\n (child) => !(isValidElement(child) && child.type === TreeViewGroup),\n );\n\n return (\n <TreeParentContext.Provider value={id}>\n <TreeItemContext.Provider value={id}>\n <div\n {...props}\n ref={(element) => {\n context.setNodeElement(id, element);\n if (typeof ref === \"function\") ref(element);\n else if (ref) ref.current = element;\n }}\n aria-disabled={disabled || undefined}\n aria-expanded={context.hasChildren(id) ? context.expanded.has(id) : undefined}\n aria-busy={loading || undefined}\n aria-level={registeredNode ? context.getDepth(id) : parentId ? 2 : 1}\n aria-posinset={siblingIndex >= 0 ? siblingIndex + 1 : 1}\n aria-setsize={siblings.length || 1}\n aria-selected={context.selectionMode === \"none\" ? undefined : selected}\n className={styles.itemWrapper}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-jaci-component=\"tree-view\"\n data-selected={selected || undefined}\n data-loading={loading || undefined}\n data-slot=\"tree-view-item\"\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented) context.selectNode(id);\n }}\n onFocus={(event) => {\n context.setActiveId(id);\n onFocus?.(event);\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n context.handleKeyDown(id, event);\n onKeyDown?.(event);\n }}\n role=\"treeitem\"\n tabIndex={visible ? tabIndex : -1}\n >\n <div\n className={cx(styles.item, className)}\n data-disabled={disabled || undefined}\n data-expanded={context.expanded.has(id) || undefined}\n data-selected={selected || undefined}\n data-slot=\"tree-view-item-row\"\n style={style}\n >\n {rowNodes}\n </div>\n {groupNodes}\n </div>\n </TreeItemContext.Provider>\n </TreeParentContext.Provider>\n );\n});\n\nexport type TreeViewGroupProps = ComponentPropsWithoutRef<\"div\">;\nexport const TreeViewGroup = forwardRef<HTMLDivElement, TreeViewGroupProps>(function TreeViewGroup(\n { children, className, style, ...props },\n ref,\n) {\n const context = useTreeViewContext();\n const parentId = useContext(TreeParentContext);\n const styles = treeView();\n const visible = parentId ? context.expanded.has(parentId) : true;\n return (\n // biome-ignore lint/a11y/useSemanticElements: WAI-ARIA tree groups require role=\"group\".\n <div\n {...props}\n ref={ref}\n aria-hidden={!visible || undefined}\n className={cx(styles.group, className)}\n data-jaci-component=\"tree-view\"\n data-expanded={visible || undefined}\n data-slot=\"tree-view-group\"\n hidden={!visible}\n role=\"group\"\n style={{ ...style, display: visible ? style?.display : \"none\" }}\n >\n {children}\n </div>\n );\n});\n\nexport type TreeViewToggleProps = ComponentPropsWithoutRef<\"button\">;\nexport const TreeViewToggle = forwardRef<HTMLButtonElement, TreeViewToggleProps>(\n function TreeViewToggle({ children, className, onClick, ...props }, ref) {\n const context = useTreeViewContext();\n const itemId = useContext(TreeItemContext);\n const id = itemId;\n const item = id ? context.nodes.find((candidate) => candidate.id === id) : undefined;\n const disabled = context.disabled || Boolean(item?.disabled);\n return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n aria-disabled={disabled || undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\n disabled={disabled || props.disabled}\n onClick={(event) => {\n event.stopPropagation();\n onClick?.(event);\n if (!event.defaultPrevented && id) context.toggleExpanded(id);\n }}\n tabIndex={-1}\n type=\"button\"\n >\n {children ?? (id && context.expanded.has(id) ? \"▾\" : \"▸\")}\n </button>\n );\n },\n);\n\nexport type TreeViewLabelProps = ComponentPropsWithoutRef<\"span\">;\nexport const TreeViewLabel = forwardRef<HTMLSpanElement, TreeViewLabelProps>(function TreeViewLabel(\n { className, ...props },\n ref,\n) {\n return (\n <span\n {...props}\n ref={ref}\n className={cx(treeView().label, className)}\n data-slot=\"tree-view-label\"\n />\n );\n});\n\nexport interface TreeViewStateProps extends ComponentPropsWithoutRef<\"div\"> {\n children?: ReactNode;\n}\n\nexport const TreeViewLoading = forwardRef<HTMLDivElement, TreeViewStateProps>(\n function TreeViewLoading({ children = \"Loading…\", className, ...props }, ref) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"polite\"\n aria-level={1}\n className={cx(treeView().loading, className)}\n data-slot=\"tree-view-loading\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n },\n);\n\nexport const TreeViewEmpty = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewEmpty(\n { children = \"No items found.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-level={1}\n className={cx(treeView().empty, className)}\n data-slot=\"tree-view-empty\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeViewError = forwardRef<HTMLDivElement, TreeViewStateProps>(function TreeViewError(\n { children = \"Something went wrong.\", className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n aria-disabled=\"true\"\n aria-live=\"assertive\"\n aria-level={1}\n className={cx(treeView().error, className)}\n data-slot=\"tree-view-error\"\n role=\"treeitem\"\n tabIndex={-1}\n >\n {children}\n </div>\n );\n});\n\nexport const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem,\n Group: TreeViewGroup,\n Toggle: TreeViewToggle,\n Label: TreeViewLabel,\n Loading: TreeViewLoading,\n Empty: TreeViewEmpty,\n Error: TreeViewError,\n};\n"],"mappings":";;;;;;AAqDA,MAAM,kBAAkB,cAA2C,IAAI;AACvE,MAAM,oBAAoB,cAAkC,KAAA,CAAS;AACrE,MAAM,kBAAkB,cAA6B,IAAI;AAEzD,SAAS,qBAAqB;CAC5B,MAAM,UAAU,WAAW,eAAe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AGA,MAAa,gBAAgB,WAAgD,SAAS,cACpF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAAC,QAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;CACX,CAAA;AAEL,CAAC;AAMD,MAAa,kBAAkB,WAC7B,SAAS,gBAAgB,EAAE,WAAW,YAAY,WAAW,GAAG,SAAS,KAAK;CAC5E,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,iBAAc;EACd,aAAU;EACV,cAAY;EACZ,WAAW,GAAG,SAAS,CAAC,CAAC,SAAS,SAAS;EAC3C,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CACF;AAEA,MAAa,gBAAgB,WAA+C,SAAS,cACnF,EAAE,WAAW,mBAAmB,WAAW,GAAG,SAC9C,KACA;CACA,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,iBAAc;EACd,cAAY;EACZ,WAAW,GAAG,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,gBAAgB,WAA+C,SAAS,cACnF,EAAE,WAAW,yBAAyB,WAAW,GAAG,SACpD,KACA;CACA,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACL,iBAAc;EACd,aAAU;EACV,cAAY;EACZ,WAAW,GAAG,SAAS,CAAC,CAAC,OAAO,SAAS;EACzC,aAAU;EACV,MAAK;EACL,UAAU;EAET;CACE,CAAA;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,SAAS;CACT,OAAO;CACP,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.cjs","names":["cx","heading"],"sources":["../../../src/components/typography/heading.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ElementType, ReactElement, Ref } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { heading } from \"../../styled-system/recipes\";\n\nexport type HeadingSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\nexport type HeadingElement = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\nexport type TypographyWeight = \"normal\" | \"medium\" | \"semibold\" | \"bold\";\nexport type TypographyWidth = \"auto\" | \"fit\" | \"full\";\nexport type TypographyLineClamp = 1 | 2 | 3 | 4;\n\nconst defaultSizeByElement: Record<HeadingElement, HeadingSize> = {\n h1: \"2xl\",\n h2: \"xl\",\n h3: \"lg\",\n h4: \"md\",\n h5: \"sm\",\n h6: \"xs\",\n};\n\nexport interface HeadingProps extends Omit<ComponentPropsWithoutRef<\"h2\">, \"color\"> {\n as?: HeadingElement;\n size?: HeadingSize;\n weight?: TypographyWeight;\n truncate?: boolean;\n lineClamp?: TypographyLineClamp;\n width?: TypographyWidth;\n}\n\nexport const Heading = forwardRef<HTMLHeadingElement, HeadingProps>(function Heading(\n { as = \"h2\", className, lineClamp, size, truncate = false, weight, width = \"auto\", ...props },\n ref,\n) {\n const Component = as as ElementType;\n const resolvedSize = size ?? defaultSizeByElement[as];\n\n return (\n <Component\n {...props}\n ref={ref as Ref<HTMLElement>}\n className={cx(\n heading({\n lineClamp: lineClamp ? (String(lineClamp) as \"1\" | \"2\" | \"3\" | \"4\") : undefined,\n size: resolvedSize,\n truncate,\n weight,\n width,\n }),\n className,\n )}\n data-jaci-component=\"heading\"\n data-slot=\"heading\"\n />\n ) as ReactElement;\n});\n"],"mappings":";;;;;AAYA,MAAM,uBAA4D;CAChE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAWA,MAAa,WAAA,
|
|
1
|
+
{"version":3,"file":"heading.cjs","names":["forwardRef","cx","heading"],"sources":["../../../src/components/typography/heading.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ElementType, ReactElement, Ref } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { heading } from \"../../styled-system/recipes\";\n\nexport type HeadingSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\nexport type HeadingElement = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\nexport type TypographyWeight = \"normal\" | \"medium\" | \"semibold\" | \"bold\";\nexport type TypographyWidth = \"auto\" | \"fit\" | \"full\";\nexport type TypographyLineClamp = 1 | 2 | 3 | 4;\n\nconst defaultSizeByElement: Record<HeadingElement, HeadingSize> = {\n h1: \"2xl\",\n h2: \"xl\",\n h3: \"lg\",\n h4: \"md\",\n h5: \"sm\",\n h6: \"xs\",\n};\n\nexport interface HeadingProps extends Omit<ComponentPropsWithoutRef<\"h2\">, \"color\"> {\n as?: HeadingElement;\n size?: HeadingSize;\n weight?: TypographyWeight;\n truncate?: boolean;\n lineClamp?: TypographyLineClamp;\n width?: TypographyWidth;\n}\n\nexport const Heading = forwardRef<HTMLHeadingElement, HeadingProps>(function Heading(\n { as = \"h2\", className, lineClamp, size, truncate = false, weight, width = \"auto\", ...props },\n ref,\n) {\n const Component = as as ElementType;\n const resolvedSize = size ?? defaultSizeByElement[as];\n\n return (\n <Component\n {...props}\n ref={ref as Ref<HTMLElement>}\n className={cx(\n heading({\n lineClamp: lineClamp ? (String(lineClamp) as \"1\" | \"2\" | \"3\" | \"4\") : undefined,\n size: resolvedSize,\n truncate,\n weight,\n width,\n }),\n className,\n )}\n data-jaci-component=\"heading\"\n data-slot=\"heading\"\n />\n ) as ReactElement;\n});\n"],"mappings":";;;;;AAYA,MAAM,uBAA4D;CAChE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAWA,MAAa,WAAA,GAAUA,MAAAA,WAAAA,CAA6C,SAAS,QAC3E,EAAE,KAAK,MAAM,WAAW,WAAW,MAAM,WAAW,OAAO,QAAQ,QAAQ,QAAQ,GAAG,SACtF,KACA;CACA,MAAM,YAAY;CAClB,MAAM,eAAe,QAAQ,qBAAqB;CAElD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GACTC,gBAAAA,QAAQ;GACN,WAAW,YAAa,OAAO,SAAS,IAA8B,KAAA;GACtE,MAAM;GACN;GACA;GACA;EACF,CAAC,GACD,SACF;EACA,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","names":["cx","link"],"sources":["../../../src/components/typography/link.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { link } from \"../../styled-system/recipes\";\n\nexport interface LinkProps extends ComponentPropsWithoutRef<\"a\"> {\n subtle?: boolean;\n}\n\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(\n { className, subtle = true, ...props },\n ref,\n) {\n return (\n <a\n {...props}\n ref={ref}\n className={cx(link({ subtle }), className)}\n data-jaci-component=\"link\"\n data-slot=\"link\"\n />\n );\n});\n"],"mappings":";;;;;AAUA,MAAa,QAAA,
|
|
1
|
+
{"version":3,"file":"link.cjs","names":["forwardRef","cx","link"],"sources":["../../../src/components/typography/link.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { link } from \"../../styled-system/recipes\";\n\nexport interface LinkProps extends ComponentPropsWithoutRef<\"a\"> {\n subtle?: boolean;\n}\n\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(\n { className, subtle = true, ...props },\n ref,\n) {\n return (\n <a\n {...props}\n ref={ref}\n className={cx(link({ subtle }), className)}\n data-jaci-component=\"link\"\n data-slot=\"link\"\n />\n );\n});\n"],"mappings":";;;;;AAUA,MAAa,QAAA,GAAOA,MAAAA,WAAAA,CAAyC,SAAS,KACpE,EAAE,WAAW,SAAS,MAAM,GAAG,SAC/B,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GAAGC,aAAAA,KAAK,EAAE,OAAO,CAAC,GAAG,SAAS;EACzC,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.cjs","names":["cx","paragraph"],"sources":["../../../src/components/typography/paragraph.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { paragraph } from \"../../styled-system/recipes\";\nimport type { TypographyLineClamp, TypographyWeight, TypographyWidth } from \"./heading\";\n\nexport interface ParagraphProps extends ComponentPropsWithoutRef<\"p\"> {\n weight?: TypographyWeight;\n truncate?: boolean;\n lineClamp?: TypographyLineClamp;\n width?: TypographyWidth;\n}\n\nexport const Paragraph = forwardRef<HTMLParagraphElement, ParagraphProps>(function Paragraph(\n { className, lineClamp, truncate = false, weight, width = \"auto\", ...props },\n ref,\n) {\n return (\n <p\n {...props}\n ref={ref}\n className={cx(\n paragraph({\n lineClamp: lineClamp ? (String(lineClamp) as \"1\" | \"2\" | \"3\" | \"4\") : undefined,\n truncate,\n weight,\n width,\n }),\n className,\n )}\n data-jaci-component=\"paragraph\"\n data-slot=\"paragraph\"\n />\n );\n});\n"],"mappings":";;;;;AAcA,MAAa,aAAA,
|
|
1
|
+
{"version":3,"file":"paragraph.cjs","names":["forwardRef","cx","paragraph"],"sources":["../../../src/components/typography/paragraph.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { paragraph } from \"../../styled-system/recipes\";\nimport type { TypographyLineClamp, TypographyWeight, TypographyWidth } from \"./heading\";\n\nexport interface ParagraphProps extends ComponentPropsWithoutRef<\"p\"> {\n weight?: TypographyWeight;\n truncate?: boolean;\n lineClamp?: TypographyLineClamp;\n width?: TypographyWidth;\n}\n\nexport const Paragraph = forwardRef<HTMLParagraphElement, ParagraphProps>(function Paragraph(\n { className, lineClamp, truncate = false, weight, width = \"auto\", ...props },\n ref,\n) {\n return (\n <p\n {...props}\n ref={ref}\n className={cx(\n paragraph({\n lineClamp: lineClamp ? (String(lineClamp) as \"1\" | \"2\" | \"3\" | \"4\") : undefined,\n truncate,\n weight,\n width,\n }),\n className,\n )}\n data-jaci-component=\"paragraph\"\n data-slot=\"paragraph\"\n />\n );\n});\n"],"mappings":";;;;;AAcA,MAAa,aAAA,GAAYA,MAAAA,WAAAA,CAAiD,SAAS,UACjF,EAAE,WAAW,WAAW,WAAW,OAAO,QAAQ,QAAQ,QAAQ,GAAG,SACrE,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GACTC,kBAAAA,UAAU;GACR,WAAW,YAAa,OAAO,SAAS,IAA8B,KAAA;GACtE;GACA;GACA;EACF,CAAC,GACD,SACF;EACA,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.cjs","names":["Component","cx","text"],"sources":["../../../src/components/typography/text.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ElementType, ReactElement, Ref } from \"react\";\nimport type { TypographyLineClamp, TypographyWeight, TypographyWidth } from \"./heading\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { text } from \"../../styled-system/recipes\";\n\nexport type TextSize = \"sm\" | \"md\" | \"lg\";\nexport type TextTone = \"default\" | \"muted\";\nexport type TextElement = \"p\" | \"span\" | \"div\";\n\nexport interface TextProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"color\"> {\n as?: TextElement;\n size?: TextSize;\n tone?: TextTone;\n weight?: TypographyWeight;\n truncate?: boolean;\n lineClamp?: TypographyLineClamp;\n width?: TypographyWidth;\n}\n\nexport const Text = forwardRef<HTMLElement, TextProps>(function Text(\n {\n as = \"p\",\n className,\n lineClamp,\n size = \"md\",\n tone = \"default\",\n truncate = false,\n weight,\n width = \"auto\",\n ...props\n },\n ref,\n) {\n const Component = as as ElementType;\n\n return (\n <Component\n {...props}\n ref={ref as Ref<HTMLElement>}\n className={cx(\n text({\n lineClamp: lineClamp ? (String(lineClamp) as \"1\" | \"2\" | \"3\" | \"4\") : undefined,\n size,\n tone,\n truncate,\n weight,\n width,\n }),\n className,\n )}\n data-jaci-component=\"text\"\n data-slot=\"text\"\n />\n ) as ReactElement;\n});\n"],"mappings":";;;;;AAqBA,MAAa,QAAA,
|
|
1
|
+
{"version":3,"file":"text.cjs","names":["forwardRef","Component","cx","text"],"sources":["../../../src/components/typography/text.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef, ElementType, ReactElement, Ref } from \"react\";\nimport type { TypographyLineClamp, TypographyWeight, TypographyWidth } from \"./heading\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { text } from \"../../styled-system/recipes\";\n\nexport type TextSize = \"sm\" | \"md\" | \"lg\";\nexport type TextTone = \"default\" | \"muted\";\nexport type TextElement = \"p\" | \"span\" | \"div\";\n\nexport interface TextProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"color\"> {\n as?: TextElement;\n size?: TextSize;\n tone?: TextTone;\n weight?: TypographyWeight;\n truncate?: boolean;\n lineClamp?: TypographyLineClamp;\n width?: TypographyWidth;\n}\n\nexport const Text = forwardRef<HTMLElement, TextProps>(function Text(\n {\n as = \"p\",\n className,\n lineClamp,\n size = \"md\",\n tone = \"default\",\n truncate = false,\n weight,\n width = \"auto\",\n ...props\n },\n ref,\n) {\n const Component = as as ElementType;\n\n return (\n <Component\n {...props}\n ref={ref as Ref<HTMLElement>}\n className={cx(\n text({\n lineClamp: lineClamp ? (String(lineClamp) as \"1\" | \"2\" | \"3\" | \"4\") : undefined,\n size,\n tone,\n truncate,\n weight,\n width,\n }),\n className,\n )}\n data-jaci-component=\"text\"\n data-slot=\"text\"\n />\n ) as ReactElement;\n});\n"],"mappings":";;;;;AAqBA,MAAa,QAAA,GAAOA,MAAAA,WAAAA,CAAmC,SAAS,KAC9D,EACE,KAAK,KACL,WACA,WACA,OAAO,MACP,OAAO,WACP,WAAW,OACX,QACA,QAAQ,QACR,GAAG,SAEL,KACA;CAGA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,IAAD;EACE,GAAI;EACC;EACL,WAAWC,WAAAA,GACTC,aAAAA,KAAK;GACH,WAAW,YAAa,OAAO,SAAS,IAA8B,KAAA;GACtE;GACA;GACA;GACA;GACA;EACF,CAAC,GACD,SACF;EACA,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC"}
|
|
@@ -15,8 +15,8 @@ function fileKey(file) {
|
|
|
15
15
|
}
|
|
16
16
|
function formatBytes(bytes) {
|
|
17
17
|
if (bytes < 1024) return `${bytes} B`;
|
|
18
|
-
if (bytes <
|
|
19
|
-
return `${(bytes /
|
|
18
|
+
if (bytes < 1048576) return `${Math.round(bytes / 1024)} KB`;
|
|
19
|
+
return `${(bytes / 1048576).toFixed(1)} MB`;
|
|
20
20
|
}
|
|
21
21
|
function acceptsFile(file, accept) {
|
|
22
22
|
if (!accept) return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.cjs","names":["upload","cx"],"sources":["../../../src/components/upload/upload.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ChangeEvent, ComponentPropsWithoutRef, ReactNode, RefObject } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { upload } from \"../../styled-system/recipes\";\n\nexport type UploadRejectionReason = \"type\" | \"size\" | \"count\" | \"duplicate\" | \"validation\";\n\nexport type UploadFileStatus = \"queued\" | \"uploading\" | \"success\" | \"error\" | \"canceled\";\n\nexport interface UploadFileState {\n status: UploadFileStatus;\n progress?: number;\n error?: ReactNode;\n}\n\nexport interface UploadRejection {\n file: File;\n message: string;\n reason: UploadRejectionReason;\n}\n\ninterface UploadContextValue {\n accept: string | undefined;\n addFiles: (files: FileList | File[]) => void;\n disabled: boolean;\n dropActive: boolean;\n files: File[];\n inputId: string;\n inputRef: RefObject<HTMLInputElement | null>;\n fileState: ((file: File) => UploadFileState | undefined) | undefined;\n maxFiles: number | undefined;\n maxSize: number | undefined;\n multiple: boolean;\n removeFile: (file: File) => void;\n cancelFile: (file: File) => void;\n rejections: UploadRejection[];\n setDropActive: (active: boolean) => void;\n styles: ReturnType<typeof upload>;\n}\n\nconst UploadContext = createContext<UploadContextValue | null>(null);\n\nfunction useUploadContext() {\n const context = useContext(UploadContext);\n if (!context) {\n throw new Error(\"Upload parts must be rendered inside Upload.Root.\");\n }\n\n return context;\n}\n\nfunction fileKey(file: File) {\n return `${file.name}-${file.size}-${file.lastModified}`;\n}\n\nfunction formatBytes(bytes: number) {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nfunction acceptsFile(file: File, accept: string | undefined) {\n if (!accept) {\n return true;\n }\n\n const fileName = file.name.toLowerCase();\n const fileType = file.type.toLowerCase();\n\n return accept.split(\",\").some((entry) => {\n const pattern = entry.trim().toLowerCase();\n if (!pattern) return true;\n if (pattern.startsWith(\".\")) return fileName.endsWith(pattern);\n if (pattern.endsWith(\"/*\")) return fileType.startsWith(pattern.slice(0, -1));\n return pattern === fileType;\n });\n}\n\nexport interface UploadRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {\n /** Accepted MIME types or file extensions, using the native input syntax. */\n accept?: string;\n /** Controlled files. Use with `onFilesChange`. */\n files?: File[];\n /** Initial files for an uncontrolled upload. */\n defaultFiles?: File[];\n /** Called whenever accepted files are added or removed. */\n onFilesChange?: (files: File[]) => void;\n /** Called with files rejected by `accept`, `maxSize`, `maxFiles` or duplicates. */\n onReject?: (rejections: UploadRejection[]) => void;\n /** Maximum number of accepted files. Defaults to one when `multiple` is false. */\n maxFiles?: number;\n /** Maximum size per file, in bytes. */\n maxSize?: number;\n /** Allows selecting more than one file. */\n multiple?: boolean;\n /** Disables file selection and drag-and-drop. */\n disabled?: boolean;\n /** Optional asynchronous validation. Return an error message to reject a file. */\n validateFile?: (file: File) => string | null | Promise<string | null>;\n /** Controlled status used by the status, progress and cancel slots. */\n fileState?: (file: File) => UploadFileState | undefined;\n /** Called when a consumer cancels an upload. */\n onCancel?: (file: File) => void;\n children?: ReactNode;\n}\n\nexport const UploadRoot = forwardRef<HTMLDivElement, UploadRootProps>(function UploadRoot(\n {\n accept,\n fileState,\n children,\n className,\n defaultFiles = [],\n disabled = false,\n files: controlledFiles,\n maxFiles,\n maxSize,\n multiple = false,\n onFilesChange,\n onCancel,\n onReject,\n validateFile,\n ...props\n },\n ref,\n) {\n const [uncontrolledFiles, setUncontrolledFiles] = useState<File[]>(defaultFiles);\n const [dropActive, setDropActive] = useState(false);\n const [rejections, setRejections] = useState<UploadRejection[]>([]);\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n const styles = upload({ disabled, dropActive });\n const currentFiles = controlledFiles ?? uncontrolledFiles;\n const fileLimit = maxFiles ?? (multiple ? undefined : 1);\n\n const updateFiles = useCallback(\n (nextFiles: File[]) => {\n if (controlledFiles === undefined) setUncontrolledFiles(nextFiles);\n onFilesChange?.(nextFiles);\n },\n [controlledFiles, onFilesChange],\n );\n\n const removeFile = useCallback(\n (file: File) => {\n updateFiles(currentFiles.filter((current) => fileKey(current) !== fileKey(file)));\n },\n [currentFiles, updateFiles],\n );\n\n const addFiles = useCallback(\n (fileList: FileList | File[]) => {\n if (disabled) return;\n\n const candidates = Array.from(fileList);\n const acceptedFiles: File[] = [];\n const nextRejections: UploadRejection[] = [];\n const pendingValidations = new Map<File, Promise<string | null>>();\n const existingKeys = new Set(currentFiles.map(fileKey));\n\n for (const file of candidates) {\n const key = fileKey(file);\n if (existingKeys.has(key) || acceptedFiles.some((accepted) => fileKey(accepted) === key)) {\n nextRejections.push({\n file,\n reason: \"duplicate\",\n message: `${file.name} was already added.`,\n });\n continue;\n }\n if (!acceptsFile(file, accept)) {\n nextRejections.push({\n file,\n reason: \"type\",\n message: `${file.name} is not an accepted file type.`,\n });\n continue;\n }\n if (maxSize !== undefined && file.size > maxSize) {\n nextRejections.push({\n file,\n reason: \"size\",\n message: `${file.name} is larger than the allowed limit.`,\n });\n continue;\n }\n if (\n fileLimit !== undefined &&\n (multiple ? currentFiles.length + acceptedFiles.length : acceptedFiles.length) >=\n fileLimit\n ) {\n nextRejections.push({\n file,\n reason: \"count\",\n message: `Only ${fileLimit} file${fileLimit === 1 ? \"\" : \"s\"} can be selected.`,\n });\n continue;\n }\n if (validateFile) {\n const validation = validateFile(file);\n if (validation && typeof validation !== \"object\") {\n nextRejections.push({ file, reason: \"validation\", message: validation });\n continue;\n }\n if (validation && typeof validation === \"object\" && \"then\" in validation) {\n pendingValidations.set(file, Promise.resolve(validation));\n }\n }\n acceptedFiles.push(file);\n }\n\n const nextFiles = multiple ? [...currentFiles, ...acceptedFiles] : acceptedFiles.slice(0, 1);\n if (acceptedFiles.length > 0) {\n updateFiles(nextFiles);\n }\n if (validateFile) {\n for (const file of acceptedFiles) {\n const validation = pendingValidations.get(file);\n if (validation) {\n void validation\n .then((message) => {\n if (!message) return;\n const rejection = { file, reason: \"validation\" as const, message };\n updateFiles(nextFiles.filter((current) => fileKey(current) !== fileKey(file)));\n setRejections((current) => [...current, rejection]);\n onReject?.([rejection]);\n })\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : \"File validation failed.\";\n const rejection = { file, reason: \"validation\" as const, message };\n updateFiles(nextFiles.filter((current) => fileKey(current) !== fileKey(file)));\n setRejections((current) => [...current, rejection]);\n onReject?.([rejection]);\n });\n }\n }\n }\n if (nextRejections.length > 0) {\n setRejections(nextRejections);\n onReject?.(nextRejections);\n } else {\n setRejections([]);\n }\n },\n [\n accept,\n currentFiles,\n disabled,\n fileLimit,\n maxSize,\n multiple,\n onReject,\n updateFiles,\n validateFile,\n ],\n );\n\n const cancelFile = useCallback((file: File) => onCancel?.(file), [onCancel]);\n\n const context = useMemo<UploadContextValue>(\n () => ({\n accept,\n addFiles,\n cancelFile,\n disabled,\n dropActive,\n files: currentFiles,\n inputId,\n inputRef,\n fileState,\n maxFiles: fileLimit,\n maxSize,\n multiple,\n removeFile,\n rejections,\n setDropActive,\n styles,\n }),\n [\n accept,\n addFiles,\n cancelFile,\n currentFiles,\n disabled,\n dropActive,\n fileLimit,\n fileState,\n inputId,\n maxSize,\n multiple,\n rejections,\n removeFile,\n styles,\n ],\n );\n\n return (\n <UploadContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"upload\"\n data-slot=\"upload\"\n >\n {children}\n </div>\n </UploadContext.Provider>\n );\n});\n\nexport interface UploadDropzoneProps extends ComponentPropsWithoutRef<\"label\"> {\n children?: ReactNode;\n}\n\nexport const UploadDropzone = forwardRef<HTMLLabelElement, UploadDropzoneProps>(\n function UploadDropzone(\n { children, className, htmlFor, onDragEnter, onDragLeave, onDragOver, onDrop, ...props },\n ref,\n ) {\n const { addFiles, disabled, dropActive, inputId, setDropActive, styles } = useUploadContext();\n\n return (\n <label\n {...props}\n ref={ref}\n aria-disabled={disabled || undefined}\n className={cx(styles.dropzone, className)}\n data-drag-active={dropActive || undefined}\n data-slot=\"upload-dropzone\"\n htmlFor={htmlFor ?? inputId}\n onDragEnter={(event) => {\n event.preventDefault();\n if (!disabled) {\n setDropActive(true);\n event.currentTarget.dataset.dragActive = \"true\";\n }\n onDragEnter?.(event);\n }}\n onDragLeave={(event) => {\n event.preventDefault();\n if (event.currentTarget === event.target) {\n setDropActive(false);\n event.currentTarget.dataset.dragActive = \"false\";\n }\n onDragLeave?.(event);\n }}\n onDragOver={(event) => {\n event.preventDefault();\n if (!disabled) setDropActive(true);\n onDragOver?.(event);\n }}\n onDrop={(event) => {\n event.preventDefault();\n setDropActive(false);\n event.currentTarget.dataset.dragActive = \"false\";\n if (!disabled) addFiles(event.dataTransfer.files);\n onDrop?.(event);\n }}\n >\n {children}\n </label>\n );\n },\n);\n\nexport type UploadInputProps = ComponentPropsWithoutRef<\"input\">;\n\nexport const UploadInput = forwardRef<HTMLInputElement, UploadInputProps>(function UploadInput(\n { accept, className, id, multiple, onChange, ...props },\n ref,\n) {\n const {\n addFiles,\n accept: rootAccept,\n disabled,\n inputId,\n inputRef,\n multiple: rootMultiple,\n styles,\n } = useUploadContext();\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n if (event.currentTarget.files) addFiles(event.currentTarget.files);\n event.currentTarget.value = \"\";\n onChange?.(event);\n };\n\n return (\n <input\n {...props}\n accept={accept ?? rootAccept}\n aria-label={props[\"aria-label\"] ?? \"Select files\"}\n className={cx(styles.input, className)}\n disabled={disabled}\n id={id ?? inputId}\n multiple={multiple ?? rootMultiple}\n onChange={handleChange}\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n tabIndex={-1}\n type=\"file\"\n />\n );\n});\n\nexport type UploadTriggerProps = ComponentPropsWithoutRef<\"button\">;\n\nexport const UploadTrigger = forwardRef<HTMLButtonElement, UploadTriggerProps>(\n function UploadTrigger(\n { children = \"Choose files\", className, disabled, onClick, ...props },\n ref,\n ) {\n const { disabled: rootDisabled, inputRef, styles } = useUploadContext();\n\n return (\n <button\n {...props}\n className={cx(styles.trigger, className)}\n data-slot=\"upload-trigger\"\n disabled={disabled ?? rootDisabled}\n onClick={(event) => {\n inputRef.current?.click();\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children}\n </button>\n );\n },\n);\n\nexport type UploadIconProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const UploadIcon = forwardRef<HTMLSpanElement, UploadIconProps>(function UploadIcon(\n { children = \"↥\", className, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n return (\n <span\n {...props}\n ref={ref}\n aria-hidden=\"true\"\n className={cx(styles.icon, className)}\n data-slot=\"upload-icon\"\n >\n {children}\n </span>\n );\n});\n\nexport type UploadTextProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const UploadText = forwardRef<HTMLSpanElement, UploadTextProps>(function UploadText(\n { className, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n return (\n <span {...props} ref={ref} className={cx(styles.text, className)} data-slot=\"upload-text\" />\n );\n});\n\nexport type UploadHintProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const UploadHint = forwardRef<HTMLSpanElement, UploadHintProps>(function UploadHint(\n { className, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n return (\n <span {...props} ref={ref} className={cx(styles.hint, className)} data-slot=\"upload-hint\" />\n );\n});\n\nexport interface UploadPreviewProps extends ComponentPropsWithoutRef<\"span\"> {\n /** File whose preview should be rendered. Image files use a temporary object URL. */\n file: File;\n /** Alternative text for image previews. Defaults to the file name. */\n alt?: string;\n /** Content rendered while the preview is unavailable or the file is not an image. */\n fallback?: ReactNode;\n}\n\nexport const UploadPreview = forwardRef<HTMLSpanElement, UploadPreviewProps>(function UploadPreview(\n { alt, className, fallback = \"Preview unavailable\", file, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n const [src, setSrc] = useState<string | null>(null);\n\n useEffect(() => {\n if (\n !file.type.startsWith(\"image/\") ||\n typeof URL === \"undefined\" ||\n typeof URL.createObjectURL !== \"function\"\n ) {\n setSrc(null);\n return;\n }\n\n const objectUrl = URL.createObjectURL(file);\n setSrc(objectUrl);\n return () => URL.revokeObjectURL(objectUrl);\n }, [file]);\n\n return (\n <span\n {...props}\n ref={ref}\n aria-hidden={props[\"aria-label\"] ? undefined : true}\n className={cx(styles.preview, className)}\n data-slot=\"upload-preview\"\n role={props[\"aria-label\"] ? \"img\" : undefined}\n >\n {src ? <img alt={alt ?? file.name} src={src} /> : fallback}\n </span>\n );\n});\n\nexport interface UploadProgressProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Progress from 0 to 100. Omit it for an indeterminate upload. */\n value?: number;\n /** Accessible label and optional visible status text. */\n label?: ReactNode;\n file?: File;\n}\n\nexport const UploadProgress = forwardRef<HTMLDivElement, UploadProgressProps>(\n function UploadProgress({ className, file, label = \"Uploading\", value, ...props }, ref) {\n const { fileState, styles } = useUploadContext();\n const state = file ? fileState?.(file) : undefined;\n const normalizedValue =\n value === undefined\n ? state?.progress === undefined\n ? undefined\n : Math.min(100, Math.max(0, state.progress))\n : Math.min(100, Math.max(0, value));\n\n return (\n <div\n {...props}\n ref={ref}\n aria-label={typeof label === \"string\" ? label : \"Upload progress\"}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={normalizedValue}\n className={cx(styles.progress, className)}\n data-indeterminate={normalizedValue === undefined || undefined}\n data-slot=\"upload-progress\"\n role=\"progressbar\"\n >\n <span className={styles.progressTrack} data-slot=\"upload-progress-track\">\n <span\n className={styles.progressIndicator}\n data-indeterminate={normalizedValue === undefined || undefined}\n data-slot=\"upload-progress-indicator\"\n style={{ width: normalizedValue === undefined ? undefined : `${normalizedValue}%` }}\n />\n </span>\n <span className={styles.progressLabel} data-slot=\"upload-progress-label\">\n {label}\n </span>\n </div>\n );\n },\n);\n\nexport type UploadListProps = ComponentPropsWithoutRef<\"ul\">;\n\nexport const UploadList = forwardRef<HTMLUListElement, UploadListProps>(function UploadList(\n { children, className, ...props },\n ref,\n) {\n const { files, styles } = useUploadContext();\n return (\n <ul {...props} ref={ref} className={cx(styles.list, className)} data-slot=\"upload-list\">\n {children ?? files.map((file) => <UploadItem file={file} key={fileKey(file)} />)}\n </ul>\n );\n});\n\nexport interface UploadItemProps extends Omit<ComponentPropsWithoutRef<\"li\">, \"children\"> {\n file: File;\n children?: ReactNode;\n}\n\nexport const UploadItem = forwardRef<HTMLLIElement, UploadItemProps>(function UploadItem(\n { children, className, file, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n return (\n <li {...props} ref={ref} className={cx(styles.item, className)} data-slot=\"upload-item\">\n {children ?? (\n <>\n <span className={styles.itemName} data-slot=\"upload-item-name\" title={file.name}>\n {file.name}\n </span>\n <span className={styles.itemMeta} data-slot=\"upload-item-meta\">\n {formatBytes(file.size)}\n </span>\n <UploadRemove file={file} />\n </>\n )}\n </li>\n );\n});\n\nexport interface UploadRemoveProps extends ComponentPropsWithoutRef<\"button\"> {\n file: File;\n}\n\nexport const UploadRemove = forwardRef<HTMLButtonElement, UploadRemoveProps>(function UploadRemove(\n { children = \"×\", className, file, onClick, ...props },\n ref,\n) {\n const { disabled, removeFile, styles } = useUploadContext();\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? `Remove ${file.name}`}\n className={cx(styles.remove, className)}\n data-slot=\"upload-remove\"\n disabled={disabled}\n onClick={(event) => {\n removeFile(file);\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children}\n </button>\n );\n});\n\nexport interface UploadStatusProps extends ComponentPropsWithoutRef<\"span\"> {\n file: File;\n}\n\nexport const UploadStatus = forwardRef<HTMLSpanElement, UploadStatusProps>(function UploadStatus(\n { children, className, file, ...props },\n ref,\n) {\n const { fileState, styles } = useUploadContext();\n const state = fileState?.(file);\n const content = children ?? state?.error ?? state?.status ?? \"queued\";\n return (\n <span\n {...props}\n aria-live=\"polite\"\n className={cx(styles.status, className)}\n data-status={state?.status}\n data-slot=\"upload-status\"\n ref={ref}\n >\n {content}\n </span>\n );\n});\n\nexport interface UploadCancelProps extends ComponentPropsWithoutRef<\"button\"> {\n file: File;\n}\n\nexport const UploadCancel = forwardRef<HTMLButtonElement, UploadCancelProps>(function UploadCancel(\n { children = \"Cancel\", className, file, onClick, ...props },\n ref,\n) {\n const { cancelFile, disabled, fileState, styles } = useUploadContext();\n const state = fileState?.(file);\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? `Cancel ${file.name}`}\n className={cx(styles.cancel, className)}\n data-slot=\"upload-cancel\"\n disabled={disabled || state?.status === \"canceled\" || state?.status === \"success\"}\n onClick={(event) => {\n cancelFile(file);\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children}\n </button>\n );\n});\n\nexport type UploadErrorProps = ComponentPropsWithoutRef<\"p\">;\n\nexport const UploadError = forwardRef<HTMLParagraphElement, UploadErrorProps>(function UploadError(\n { children, className, ...props },\n ref,\n) {\n const { rejections, styles } = useUploadContext();\n if (children === undefined && rejections.length === 0) return null;\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(styles.error, className)}\n data-slot=\"upload-error\"\n role=\"alert\"\n >\n {children ?? rejections.map((rejection) => rejection.message).join(\" \")}\n </p>\n );\n});\n\nexport const Upload = {\n Root: UploadRoot,\n Dropzone: UploadDropzone,\n Input: UploadInput,\n Trigger: UploadTrigger,\n Icon: UploadIcon,\n Text: UploadText,\n Hint: UploadHint,\n Preview: UploadPreview,\n Progress: UploadProgress,\n List: UploadList,\n Item: UploadItem,\n Remove: UploadRemove,\n Status: UploadStatus,\n Cancel: UploadCancel,\n Error: UploadError,\n};\n"],"mappings":";;;;;;AAqDA,MAAM,iBAAA,GAAA,MAAA,cAAA,CAAyD,IAAI;AAEnE,SAAS,mBAAmB;CAC1B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,aAAa;CACxC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,mDAAmD;CAGrE,OAAO;AACT;AAEA,SAAS,QAAQ,MAAY;CAC3B,OAAO,GAAG,KAAK,KAAK,GAAG,KAAK,KAAK,GAAG,KAAK;AAC3C;AAEA,SAAS,YAAY,OAAe;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AY,MAAM,iBAAiB,UAAU,KAAK;EAClD,WAAWA,WAAAA,GAAG,OAAO,QAAQ,SAAS;EACtC,aAAU;EACV,UAAU,YAAY,OAAO,WAAW,cAAc,OAAO,WAAW;EACxE,UAAU,UAAU;GAClB,WAAW,IAAI;GACf,UAAU,KAAK;EACjB;EACK;EACL,MAAK;EAEJ;CACK,CAAA;AAEZ,CAAC;AAID,MAAa,eAAA,GAAA,MAAA,WAAA,CAAiE,SAAS,YACrF,EAAE,UAAU,WAAW,GAAG,SAC1B,KACA;CACA,MAAM,EAAE,YAAY,WAAW,iBAAiB;CAChD,IAAI,aAAa,KAAA,KAAa,WAAW,WAAW,GAAG,OAAO;CAE9D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EACE,GAAI;EACC;EACL,WAAWA,WAAAA,GAAG,OAAO,OAAO,SAAS;EACrC,aAAU;EACV,MAAK;YAEJ,YAAY,WAAW,KAAK,cAAc,UAAU,OAAO,CAAC,CAAC,KAAK,GAAG;CACrE,CAAA;AAEP,CAAC;AAED,MAAa,SAAS;CACpB,MAAM;CACN,UAAU;CACV,OAAO;CACP,SAAS;CACT,MAAM;CACN,MAAM;CACN,MAAM;CACN,SAAS;CACT,UAAU;CACV,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"upload.cjs","names":["createContext","useContext","forwardRef","useState","useRef","useId","upload","useCallback","useMemo","cx"],"sources":["../../../src/components/upload/upload.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ChangeEvent, ComponentPropsWithoutRef, ReactNode, RefObject } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { upload } from \"../../styled-system/recipes\";\n\nexport type UploadRejectionReason = \"type\" | \"size\" | \"count\" | \"duplicate\" | \"validation\";\n\nexport type UploadFileStatus = \"queued\" | \"uploading\" | \"success\" | \"error\" | \"canceled\";\n\nexport interface UploadFileState {\n status: UploadFileStatus;\n progress?: number;\n error?: ReactNode;\n}\n\nexport interface UploadRejection {\n file: File;\n message: string;\n reason: UploadRejectionReason;\n}\n\ninterface UploadContextValue {\n accept: string | undefined;\n addFiles: (files: FileList | File[]) => void;\n disabled: boolean;\n dropActive: boolean;\n files: File[];\n inputId: string;\n inputRef: RefObject<HTMLInputElement | null>;\n fileState: ((file: File) => UploadFileState | undefined) | undefined;\n maxFiles: number | undefined;\n maxSize: number | undefined;\n multiple: boolean;\n removeFile: (file: File) => void;\n cancelFile: (file: File) => void;\n rejections: UploadRejection[];\n setDropActive: (active: boolean) => void;\n styles: ReturnType<typeof upload>;\n}\n\nconst UploadContext = createContext<UploadContextValue | null>(null);\n\nfunction useUploadContext() {\n const context = useContext(UploadContext);\n if (!context) {\n throw new Error(\"Upload parts must be rendered inside Upload.Root.\");\n }\n\n return context;\n}\n\nfunction fileKey(file: File) {\n return `${file.name}-${file.size}-${file.lastModified}`;\n}\n\nfunction formatBytes(bytes: number) {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nfunction acceptsFile(file: File, accept: string | undefined) {\n if (!accept) {\n return true;\n }\n\n const fileName = file.name.toLowerCase();\n const fileType = file.type.toLowerCase();\n\n return accept.split(\",\").some((entry) => {\n const pattern = entry.trim().toLowerCase();\n if (!pattern) return true;\n if (pattern.startsWith(\".\")) return fileName.endsWith(pattern);\n if (pattern.endsWith(\"/*\")) return fileType.startsWith(pattern.slice(0, -1));\n return pattern === fileType;\n });\n}\n\nexport interface UploadRootProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {\n /** Accepted MIME types or file extensions, using the native input syntax. */\n accept?: string;\n /** Controlled files. Use with `onFilesChange`. */\n files?: File[];\n /** Initial files for an uncontrolled upload. */\n defaultFiles?: File[];\n /** Called whenever accepted files are added or removed. */\n onFilesChange?: (files: File[]) => void;\n /** Called with files rejected by `accept`, `maxSize`, `maxFiles` or duplicates. */\n onReject?: (rejections: UploadRejection[]) => void;\n /** Maximum number of accepted files. Defaults to one when `multiple` is false. */\n maxFiles?: number;\n /** Maximum size per file, in bytes. */\n maxSize?: number;\n /** Allows selecting more than one file. */\n multiple?: boolean;\n /** Disables file selection and drag-and-drop. */\n disabled?: boolean;\n /** Optional asynchronous validation. Return an error message to reject a file. */\n validateFile?: (file: File) => string | null | Promise<string | null>;\n /** Controlled status used by the status, progress and cancel slots. */\n fileState?: (file: File) => UploadFileState | undefined;\n /** Called when a consumer cancels an upload. */\n onCancel?: (file: File) => void;\n children?: ReactNode;\n}\n\nexport const UploadRoot = forwardRef<HTMLDivElement, UploadRootProps>(function UploadRoot(\n {\n accept,\n fileState,\n children,\n className,\n defaultFiles = [],\n disabled = false,\n files: controlledFiles,\n maxFiles,\n maxSize,\n multiple = false,\n onFilesChange,\n onCancel,\n onReject,\n validateFile,\n ...props\n },\n ref,\n) {\n const [uncontrolledFiles, setUncontrolledFiles] = useState<File[]>(defaultFiles);\n const [dropActive, setDropActive] = useState(false);\n const [rejections, setRejections] = useState<UploadRejection[]>([]);\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n const styles = upload({ disabled, dropActive });\n const currentFiles = controlledFiles ?? uncontrolledFiles;\n const fileLimit = maxFiles ?? (multiple ? undefined : 1);\n\n const updateFiles = useCallback(\n (nextFiles: File[]) => {\n if (controlledFiles === undefined) setUncontrolledFiles(nextFiles);\n onFilesChange?.(nextFiles);\n },\n [controlledFiles, onFilesChange],\n );\n\n const removeFile = useCallback(\n (file: File) => {\n updateFiles(currentFiles.filter((current) => fileKey(current) !== fileKey(file)));\n },\n [currentFiles, updateFiles],\n );\n\n const addFiles = useCallback(\n (fileList: FileList | File[]) => {\n if (disabled) return;\n\n const candidates = Array.from(fileList);\n const acceptedFiles: File[] = [];\n const nextRejections: UploadRejection[] = [];\n const pendingValidations = new Map<File, Promise<string | null>>();\n const existingKeys = new Set(currentFiles.map(fileKey));\n\n for (const file of candidates) {\n const key = fileKey(file);\n if (existingKeys.has(key) || acceptedFiles.some((accepted) => fileKey(accepted) === key)) {\n nextRejections.push({\n file,\n reason: \"duplicate\",\n message: `${file.name} was already added.`,\n });\n continue;\n }\n if (!acceptsFile(file, accept)) {\n nextRejections.push({\n file,\n reason: \"type\",\n message: `${file.name} is not an accepted file type.`,\n });\n continue;\n }\n if (maxSize !== undefined && file.size > maxSize) {\n nextRejections.push({\n file,\n reason: \"size\",\n message: `${file.name} is larger than the allowed limit.`,\n });\n continue;\n }\n if (\n fileLimit !== undefined &&\n (multiple ? currentFiles.length + acceptedFiles.length : acceptedFiles.length) >=\n fileLimit\n ) {\n nextRejections.push({\n file,\n reason: \"count\",\n message: `Only ${fileLimit} file${fileLimit === 1 ? \"\" : \"s\"} can be selected.`,\n });\n continue;\n }\n if (validateFile) {\n const validation = validateFile(file);\n if (validation && typeof validation !== \"object\") {\n nextRejections.push({ file, reason: \"validation\", message: validation });\n continue;\n }\n if (validation && typeof validation === \"object\" && \"then\" in validation) {\n pendingValidations.set(file, Promise.resolve(validation));\n }\n }\n acceptedFiles.push(file);\n }\n\n const nextFiles = multiple ? [...currentFiles, ...acceptedFiles] : acceptedFiles.slice(0, 1);\n if (acceptedFiles.length > 0) {\n updateFiles(nextFiles);\n }\n if (validateFile) {\n for (const file of acceptedFiles) {\n const validation = pendingValidations.get(file);\n if (validation) {\n void validation\n .then((message) => {\n if (!message) return;\n const rejection = { file, reason: \"validation\" as const, message };\n updateFiles(nextFiles.filter((current) => fileKey(current) !== fileKey(file)));\n setRejections((current) => [...current, rejection]);\n onReject?.([rejection]);\n })\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : \"File validation failed.\";\n const rejection = { file, reason: \"validation\" as const, message };\n updateFiles(nextFiles.filter((current) => fileKey(current) !== fileKey(file)));\n setRejections((current) => [...current, rejection]);\n onReject?.([rejection]);\n });\n }\n }\n }\n if (nextRejections.length > 0) {\n setRejections(nextRejections);\n onReject?.(nextRejections);\n } else {\n setRejections([]);\n }\n },\n [\n accept,\n currentFiles,\n disabled,\n fileLimit,\n maxSize,\n multiple,\n onReject,\n updateFiles,\n validateFile,\n ],\n );\n\n const cancelFile = useCallback((file: File) => onCancel?.(file), [onCancel]);\n\n const context = useMemo<UploadContextValue>(\n () => ({\n accept,\n addFiles,\n cancelFile,\n disabled,\n dropActive,\n files: currentFiles,\n inputId,\n inputRef,\n fileState,\n maxFiles: fileLimit,\n maxSize,\n multiple,\n removeFile,\n rejections,\n setDropActive,\n styles,\n }),\n [\n accept,\n addFiles,\n cancelFile,\n currentFiles,\n disabled,\n dropActive,\n fileLimit,\n fileState,\n inputId,\n maxSize,\n multiple,\n rejections,\n removeFile,\n styles,\n ],\n );\n\n return (\n <UploadContext.Provider value={context}>\n <div\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"upload\"\n data-slot=\"upload\"\n >\n {children}\n </div>\n </UploadContext.Provider>\n );\n});\n\nexport interface UploadDropzoneProps extends ComponentPropsWithoutRef<\"label\"> {\n children?: ReactNode;\n}\n\nexport const UploadDropzone = forwardRef<HTMLLabelElement, UploadDropzoneProps>(\n function UploadDropzone(\n { children, className, htmlFor, onDragEnter, onDragLeave, onDragOver, onDrop, ...props },\n ref,\n ) {\n const { addFiles, disabled, dropActive, inputId, setDropActive, styles } = useUploadContext();\n\n return (\n <label\n {...props}\n ref={ref}\n aria-disabled={disabled || undefined}\n className={cx(styles.dropzone, className)}\n data-drag-active={dropActive || undefined}\n data-slot=\"upload-dropzone\"\n htmlFor={htmlFor ?? inputId}\n onDragEnter={(event) => {\n event.preventDefault();\n if (!disabled) {\n setDropActive(true);\n event.currentTarget.dataset.dragActive = \"true\";\n }\n onDragEnter?.(event);\n }}\n onDragLeave={(event) => {\n event.preventDefault();\n if (event.currentTarget === event.target) {\n setDropActive(false);\n event.currentTarget.dataset.dragActive = \"false\";\n }\n onDragLeave?.(event);\n }}\n onDragOver={(event) => {\n event.preventDefault();\n if (!disabled) setDropActive(true);\n onDragOver?.(event);\n }}\n onDrop={(event) => {\n event.preventDefault();\n setDropActive(false);\n event.currentTarget.dataset.dragActive = \"false\";\n if (!disabled) addFiles(event.dataTransfer.files);\n onDrop?.(event);\n }}\n >\n {children}\n </label>\n );\n },\n);\n\nexport type UploadInputProps = ComponentPropsWithoutRef<\"input\">;\n\nexport const UploadInput = forwardRef<HTMLInputElement, UploadInputProps>(function UploadInput(\n { accept, className, id, multiple, onChange, ...props },\n ref,\n) {\n const {\n addFiles,\n accept: rootAccept,\n disabled,\n inputId,\n inputRef,\n multiple: rootMultiple,\n styles,\n } = useUploadContext();\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n if (event.currentTarget.files) addFiles(event.currentTarget.files);\n event.currentTarget.value = \"\";\n onChange?.(event);\n };\n\n return (\n <input\n {...props}\n accept={accept ?? rootAccept}\n aria-label={props[\"aria-label\"] ?? \"Select files\"}\n className={cx(styles.input, className)}\n disabled={disabled}\n id={id ?? inputId}\n multiple={multiple ?? rootMultiple}\n onChange={handleChange}\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n tabIndex={-1}\n type=\"file\"\n />\n );\n});\n\nexport type UploadTriggerProps = ComponentPropsWithoutRef<\"button\">;\n\nexport const UploadTrigger = forwardRef<HTMLButtonElement, UploadTriggerProps>(\n function UploadTrigger(\n { children = \"Choose files\", className, disabled, onClick, ...props },\n ref,\n ) {\n const { disabled: rootDisabled, inputRef, styles } = useUploadContext();\n\n return (\n <button\n {...props}\n className={cx(styles.trigger, className)}\n data-slot=\"upload-trigger\"\n disabled={disabled ?? rootDisabled}\n onClick={(event) => {\n inputRef.current?.click();\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children}\n </button>\n );\n },\n);\n\nexport type UploadIconProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const UploadIcon = forwardRef<HTMLSpanElement, UploadIconProps>(function UploadIcon(\n { children = \"↥\", className, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n return (\n <span\n {...props}\n ref={ref}\n aria-hidden=\"true\"\n className={cx(styles.icon, className)}\n data-slot=\"upload-icon\"\n >\n {children}\n </span>\n );\n});\n\nexport type UploadTextProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const UploadText = forwardRef<HTMLSpanElement, UploadTextProps>(function UploadText(\n { className, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n return (\n <span {...props} ref={ref} className={cx(styles.text, className)} data-slot=\"upload-text\" />\n );\n});\n\nexport type UploadHintProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const UploadHint = forwardRef<HTMLSpanElement, UploadHintProps>(function UploadHint(\n { className, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n return (\n <span {...props} ref={ref} className={cx(styles.hint, className)} data-slot=\"upload-hint\" />\n );\n});\n\nexport interface UploadPreviewProps extends ComponentPropsWithoutRef<\"span\"> {\n /** File whose preview should be rendered. Image files use a temporary object URL. */\n file: File;\n /** Alternative text for image previews. Defaults to the file name. */\n alt?: string;\n /** Content rendered while the preview is unavailable or the file is not an image. */\n fallback?: ReactNode;\n}\n\nexport const UploadPreview = forwardRef<HTMLSpanElement, UploadPreviewProps>(function UploadPreview(\n { alt, className, fallback = \"Preview unavailable\", file, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n const [src, setSrc] = useState<string | null>(null);\n\n useEffect(() => {\n if (\n !file.type.startsWith(\"image/\") ||\n typeof URL === \"undefined\" ||\n typeof URL.createObjectURL !== \"function\"\n ) {\n setSrc(null);\n return;\n }\n\n const objectUrl = URL.createObjectURL(file);\n setSrc(objectUrl);\n return () => URL.revokeObjectURL(objectUrl);\n }, [file]);\n\n return (\n <span\n {...props}\n ref={ref}\n aria-hidden={props[\"aria-label\"] ? undefined : true}\n className={cx(styles.preview, className)}\n data-slot=\"upload-preview\"\n role={props[\"aria-label\"] ? \"img\" : undefined}\n >\n {src ? <img alt={alt ?? file.name} src={src} /> : fallback}\n </span>\n );\n});\n\nexport interface UploadProgressProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Progress from 0 to 100. Omit it for an indeterminate upload. */\n value?: number;\n /** Accessible label and optional visible status text. */\n label?: ReactNode;\n file?: File;\n}\n\nexport const UploadProgress = forwardRef<HTMLDivElement, UploadProgressProps>(\n function UploadProgress({ className, file, label = \"Uploading\", value, ...props }, ref) {\n const { fileState, styles } = useUploadContext();\n const state = file ? fileState?.(file) : undefined;\n const normalizedValue =\n value === undefined\n ? state?.progress === undefined\n ? undefined\n : Math.min(100, Math.max(0, state.progress))\n : Math.min(100, Math.max(0, value));\n\n return (\n <div\n {...props}\n ref={ref}\n aria-label={typeof label === \"string\" ? label : \"Upload progress\"}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={normalizedValue}\n className={cx(styles.progress, className)}\n data-indeterminate={normalizedValue === undefined || undefined}\n data-slot=\"upload-progress\"\n role=\"progressbar\"\n >\n <span className={styles.progressTrack} data-slot=\"upload-progress-track\">\n <span\n className={styles.progressIndicator}\n data-indeterminate={normalizedValue === undefined || undefined}\n data-slot=\"upload-progress-indicator\"\n style={{ width: normalizedValue === undefined ? undefined : `${normalizedValue}%` }}\n />\n </span>\n <span className={styles.progressLabel} data-slot=\"upload-progress-label\">\n {label}\n </span>\n </div>\n );\n },\n);\n\nexport type UploadListProps = ComponentPropsWithoutRef<\"ul\">;\n\nexport const UploadList = forwardRef<HTMLUListElement, UploadListProps>(function UploadList(\n { children, className, ...props },\n ref,\n) {\n const { files, styles } = useUploadContext();\n return (\n <ul {...props} ref={ref} className={cx(styles.list, className)} data-slot=\"upload-list\">\n {children ?? files.map((file) => <UploadItem file={file} key={fileKey(file)} />)}\n </ul>\n );\n});\n\nexport interface UploadItemProps extends Omit<ComponentPropsWithoutRef<\"li\">, \"children\"> {\n file: File;\n children?: ReactNode;\n}\n\nexport const UploadItem = forwardRef<HTMLLIElement, UploadItemProps>(function UploadItem(\n { children, className, file, ...props },\n ref,\n) {\n const { styles } = useUploadContext();\n return (\n <li {...props} ref={ref} className={cx(styles.item, className)} data-slot=\"upload-item\">\n {children ?? (\n <>\n <span className={styles.itemName} data-slot=\"upload-item-name\" title={file.name}>\n {file.name}\n </span>\n <span className={styles.itemMeta} data-slot=\"upload-item-meta\">\n {formatBytes(file.size)}\n </span>\n <UploadRemove file={file} />\n </>\n )}\n </li>\n );\n});\n\nexport interface UploadRemoveProps extends ComponentPropsWithoutRef<\"button\"> {\n file: File;\n}\n\nexport const UploadRemove = forwardRef<HTMLButtonElement, UploadRemoveProps>(function UploadRemove(\n { children = \"×\", className, file, onClick, ...props },\n ref,\n) {\n const { disabled, removeFile, styles } = useUploadContext();\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? `Remove ${file.name}`}\n className={cx(styles.remove, className)}\n data-slot=\"upload-remove\"\n disabled={disabled}\n onClick={(event) => {\n removeFile(file);\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children}\n </button>\n );\n});\n\nexport interface UploadStatusProps extends ComponentPropsWithoutRef<\"span\"> {\n file: File;\n}\n\nexport const UploadStatus = forwardRef<HTMLSpanElement, UploadStatusProps>(function UploadStatus(\n { children, className, file, ...props },\n ref,\n) {\n const { fileState, styles } = useUploadContext();\n const state = fileState?.(file);\n const content = children ?? state?.error ?? state?.status ?? \"queued\";\n return (\n <span\n {...props}\n aria-live=\"polite\"\n className={cx(styles.status, className)}\n data-status={state?.status}\n data-slot=\"upload-status\"\n ref={ref}\n >\n {content}\n </span>\n );\n});\n\nexport interface UploadCancelProps extends ComponentPropsWithoutRef<\"button\"> {\n file: File;\n}\n\nexport const UploadCancel = forwardRef<HTMLButtonElement, UploadCancelProps>(function UploadCancel(\n { children = \"Cancel\", className, file, onClick, ...props },\n ref,\n) {\n const { cancelFile, disabled, fileState, styles } = useUploadContext();\n const state = fileState?.(file);\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? `Cancel ${file.name}`}\n className={cx(styles.cancel, className)}\n data-slot=\"upload-cancel\"\n disabled={disabled || state?.status === \"canceled\" || state?.status === \"success\"}\n onClick={(event) => {\n cancelFile(file);\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children}\n </button>\n );\n});\n\nexport type UploadErrorProps = ComponentPropsWithoutRef<\"p\">;\n\nexport const UploadError = forwardRef<HTMLParagraphElement, UploadErrorProps>(function UploadError(\n { children, className, ...props },\n ref,\n) {\n const { rejections, styles } = useUploadContext();\n if (children === undefined && rejections.length === 0) return null;\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(styles.error, className)}\n data-slot=\"upload-error\"\n role=\"alert\"\n >\n {children ?? rejections.map((rejection) => rejection.message).join(\" \")}\n </p>\n );\n});\n\nexport const Upload = {\n Root: UploadRoot,\n Dropzone: UploadDropzone,\n Input: UploadInput,\n Trigger: UploadTrigger,\n Icon: UploadIcon,\n Text: UploadText,\n Hint: UploadHint,\n Preview: UploadPreview,\n Progress: UploadProgress,\n List: UploadList,\n Item: UploadItem,\n Remove: UploadRemove,\n Status: UploadStatus,\n Cancel: UploadCancel,\n Error: UploadError,\n};\n"],"mappings":";;;;;;AAqDA,MAAM,iBAAA,GAAgBA,MAAAA,cAAAA,CAAyC,IAAI;AAEnE,SAAS,mBAAmB;CAC1B,MAAM,WAAA,GAAUC,MAAAA,WAAAA,CAAW,aAAa;CACxC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,mDAAmD;CAGrE,OAAO;AACT;AAEA,SAAS,QAAQ,MAAY;CAC3B,OAAO,GAAG,KAAK,KAAK,GAAG,KAAK,KAAK,GAAG,KAAK;AAC3C;AAEA,SAAS,YAAY,OAAe;CAClC,IAAI,QAAQ,MAAM,OAAO,GAAG,MAAM;CAClC,IAAI,QAAQ,SAAa,OAAO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AY,IAAI;CAC9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;EACE,GAAI;EACJ,cAAY,MAAM,iBAAiB,UAAU,KAAK;EAClD,WAAWO,WAAAA,GAAG,OAAO,QAAQ,SAAS;EACtC,aAAU;EACV,UAAU,YAAY,OAAO,WAAW,cAAc,OAAO,WAAW;EACxE,UAAU,UAAU;GAClB,WAAW,IAAI;GACf,UAAU,KAAK;EACjB;EACK;EACL,MAAK;EAEJ;CACK,CAAA;AAEZ,CAAC;AAID,MAAa,eAAA,GAAcP,MAAAA,WAAAA,CAAmD,SAAS,YACrF,EAAE,UAAU,WAAW,GAAG,SAC1B,KACA;CACA,MAAM,EAAE,YAAY,WAAW,iBAAiB;CAChD,IAAI,aAAa,KAAA,KAAa,WAAW,WAAW,GAAG,OAAO;CAE9D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EACE,GAAI;EACC;EACL,WAAWO,WAAAA,GAAG,OAAO,OAAO,SAAS;EACrC,aAAU;EACV,MAAK;EAEJ,UAAA,YAAY,WAAW,KAAK,cAAc,UAAU,OAAO,CAAC,CAAC,KAAK,GAAG;CACrE,CAAA;AAEP,CAAC;AAED,MAAa,SAAS;CACpB,MAAM;CACN,UAAU;CACV,OAAO;CACP,SAAS;CACT,MAAM;CACN,MAAM;CACN,MAAM;CACN,SAAS;CACT,UAAU;CACV,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,OAAO;AACT"}
|
|
@@ -15,8 +15,8 @@ function fileKey(file) {
|
|
|
15
15
|
}
|
|
16
16
|
function formatBytes(bytes) {
|
|
17
17
|
if (bytes < 1024) return `${bytes} B`;
|
|
18
|
-
if (bytes <
|
|
19
|
-
return `${(bytes /
|
|
18
|
+
if (bytes < 1048576) return `${Math.round(bytes / 1024)} KB`;
|
|
19
|
+
return `${(bytes / 1048576).toFixed(1)} MB`;
|
|
20
20
|
}
|
|
21
21
|
function acceptsFile(file, accept) {
|
|
22
22
|
if (!accept) return true;
|