jaci-ui 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +68 -0
- package/dist/components/command/command.cjs +55 -34
- package/dist/components/command/command.cjs.map +1 -1
- package/dist/components/command/command.d.cts +1 -0
- package/dist/components/command/command.d.ts +1 -0
- package/dist/components/command/command.js +55 -34
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/data-toolbar/data-toolbar.cjs +141 -0
- package/dist/components/data-toolbar/data-toolbar.cjs.map +1 -0
- package/dist/components/data-toolbar/data-toolbar.d.cts +50 -0
- package/dist/components/data-toolbar/data-toolbar.d.ts +50 -0
- package/dist/components/data-toolbar/data-toolbar.js +132 -0
- package/dist/components/data-toolbar/data-toolbar.js.map +1 -0
- package/dist/components/data-toolbar/index.d.cts +2 -0
- package/dist/components/data-toolbar/index.d.ts +2 -0
- package/dist/components/data-view/data-view.cjs +33 -1
- package/dist/components/data-view/data-view.cjs.map +1 -1
- package/dist/components/data-view/data-view.d.cts +12 -1
- package/dist/components/data-view/data-view.d.ts +12 -1
- package/dist/components/data-view/data-view.js +31 -2
- package/dist/components/data-view/data-view.js.map +1 -1
- package/dist/components/data-view/index.d.cts +2 -2
- package/dist/components/data-view/index.d.ts +2 -2
- package/dist/components/list/list.cjs +3 -1
- package/dist/components/list/list.cjs.map +1 -1
- package/dist/components/list/list.d.cts +3 -1
- package/dist/components/list/list.d.ts +3 -1
- package/dist/components/list/list.js +3 -1
- package/dist/components/list/list.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.cjs +3 -3
- package/dist/components/navigation-menu/navigation-menu.cjs.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.js +3 -3
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/pagination/index.d.cts +2 -2
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/pagination.cjs +122 -21
- package/dist/components/pagination/pagination.cjs.map +1 -1
- package/dist/components/pagination/pagination.d.cts +25 -13
- package/dist/components/pagination/pagination.d.ts +25 -13
- package/dist/components/pagination/pagination.js +122 -23
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/sidebar/sidebar.cjs +59 -11
- package/dist/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/components/sidebar/sidebar.d.cts +13 -0
- package/dist/components/sidebar/sidebar.d.ts +13 -0
- package/dist/components/sidebar/sidebar.js +59 -13
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/stepper/index.d.cts +2 -0
- package/dist/components/stepper/index.d.ts +2 -0
- package/dist/components/stepper/stepper.cjs +341 -0
- package/dist/components/stepper/stepper.cjs.map +1 -0
- package/dist/components/stepper/stepper.d.cts +52 -0
- package/dist/components/stepper/stepper.d.ts +52 -0
- package/dist/components/stepper/stepper.js +330 -0
- package/dist/components/stepper/stepper.js.map +1 -0
- package/dist/components/table/index.d.cts +2 -2
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/table.cjs +265 -46
- package/dist/components/table/table.cjs.map +1 -1
- package/dist/components/table/table.d.cts +41 -8
- package/dist/components/table/table.d.ts +41 -8
- package/dist/components/table/table.js +264 -48
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/toast/toast.cjs +3 -1
- package/dist/components/toast/toast.cjs.map +1 -1
- package/dist/components/toast/toast.js +3 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/tree-view/index.d.cts +2 -2
- package/dist/components/tree-view/index.d.ts +2 -2
- package/dist/components/tree-view/tree-view.cjs +60 -3
- package/dist/components/tree-view/tree-view.cjs.map +1 -1
- package/dist/components/tree-view/tree-view.d.cts +12 -1
- package/dist/components/tree-view/tree-view.d.ts +12 -1
- package/dist/components/tree-view/tree-view.js +58 -4
- package/dist/components/tree-view/tree-view.js.map +1 -1
- package/dist/index.cjs +35 -0
- package/dist/index.d.cts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +7 -5
- package/dist/styled-system/recipes/data-toolbar.cjs +40 -0
- package/dist/styled-system/recipes/data-toolbar.cjs.map +1 -0
- package/dist/styled-system/recipes/data-toolbar.js +40 -0
- package/dist/styled-system/recipes/data-toolbar.js.map +1 -0
- package/dist/styled-system/recipes/data-view.cjs +3 -0
- package/dist/styled-system/recipes/data-view.cjs.map +1 -1
- package/dist/styled-system/recipes/data-view.js +3 -0
- package/dist/styled-system/recipes/data-view.js.map +1 -1
- package/dist/styled-system/recipes/list.cjs +7 -1
- package/dist/styled-system/recipes/list.cjs.map +1 -1
- package/dist/styled-system/recipes/list.js +7 -1
- package/dist/styled-system/recipes/list.js.map +1 -1
- package/dist/styled-system/recipes/pagination.cjs +9 -1
- package/dist/styled-system/recipes/pagination.cjs.map +1 -1
- package/dist/styled-system/recipes/pagination.js +9 -1
- package/dist/styled-system/recipes/pagination.js.map +1 -1
- package/dist/styled-system/recipes/sidebar.cjs +3 -0
- package/dist/styled-system/recipes/sidebar.cjs.map +1 -1
- package/dist/styled-system/recipes/sidebar.js +3 -0
- package/dist/styled-system/recipes/sidebar.js.map +1 -1
- package/dist/styled-system/recipes/stepper.cjs +53 -0
- package/dist/styled-system/recipes/stepper.cjs.map +1 -0
- package/dist/styled-system/recipes/stepper.js +53 -0
- package/dist/styled-system/recipes/stepper.js.map +1 -0
- package/dist/styled-system/recipes/table.cjs +15 -2
- package/dist/styled-system/recipes/table.cjs.map +1 -1
- package/dist/styled-system/recipes/table.js +15 -2
- package/dist/styled-system/recipes/table.js.map +1 -1
- package/dist/styled-system/recipes/tree-view.cjs +4 -1
- package/dist/styled-system/recipes/tree-view.cjs.map +1 -1
- package/dist/styled-system/recipes/tree-view.js +4 -1
- package/dist/styled-system/recipes/tree-view.js.map +1 -1
- package/dist/styles.css +602 -18
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.cjs","names":["BaseToast","withRecipeClassName","toastRecipe","cx"],"sources":["../../../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { Toast as BaseToast } from \"@base-ui/react/toast\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { toast as toastRecipe } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst toneByToastType: Record<string, ToastTone> = {\n danger: \"danger\",\n error: \"danger\",\n info: \"info\",\n success: \"success\",\n warning: \"warning\",\n};\n\nfunction resolveTone(type: string | undefined, tone: ToastTone | undefined): ToastTone {\n return tone ?? (type === undefined ? \"neutral\" : (toneByToastType[type] ?? \"neutral\"));\n}\n\nexport type ToastProviderProps = ComponentPropsWithoutRef<typeof BaseToast.Provider>;\n\n/**\n * Creates an isolated, declarative toast region. Configure `timeout` and\n * `limit` here; use `Toast.Root` to render each toast from local state or\n * `Toast.useToastManager()`.\n */\nexport function ToastProvider(props: ToastProviderProps) {\n return <BaseToast.Provider {...props} />;\n}\n\nexport type ToastViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;\n\n/**\n * A bottom-centred notification region.\n */\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(function ToastViewport(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Viewport\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().viewport, className)}\n data-jaci-component=\"toast-viewport\"\n data-slot=\"toast-viewport\"\n />\n );\n});\n\nexport interface ToastRootProps extends ComponentPropsWithoutRef<typeof BaseToast.Root> {\n /**\n * Visual status. When omitted, the value is inferred from the toast's\n * `type` (`error` maps to `danger`) and otherwise remains neutral.\n */\n tone?: ToastTone;\n}\n\n/**\n * Renders a toast object while preserving Base UI's lifecycle, focus, swipe,\n * and auto-dismiss behavior. It is intentionally composed rather than a\n * global imperative notification API.\n */\nexport const ToastRoot = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(\n { className, toast: toastObject, tone, ...props },\n ref,\n) {\n const resolvedTone = resolveTone(toastObject.type, tone);\n\n return (\n <BaseToast.Root\n {...props}\n ref={ref}\n toast={toastObject}\n className={withRecipeClassName(toastRecipe({ tone: resolvedTone }).root, className)}\n data-jaci-component=\"toast\"\n data-jaci-tone={resolvedTone}\n data-slot=\"toast\"\n />\n );\n});\n\nexport type ToastContentProps = ComponentPropsWithoutRef<typeof BaseToast.Content>;\n\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(function ToastContent(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Content\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().content, className)}\n data-slot=\"toast-content\"\n />\n );\n});\n\n/** A layout wrapper for `Toast.Title` and `Toast.Description`. */\nexport type ToastTextProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const ToastText = forwardRef<HTMLDivElement, ToastTextProps>(function ToastText(\n { className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(toastRecipe().text, className)}\n data-slot=\"toast-text\"\n />\n );\n});\n\nexport type ToastTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;\n\nexport const ToastTitle = forwardRef<HTMLHeadingElement, ToastTitleProps>(function ToastTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().title, className)}\n data-slot=\"toast-title\"\n />\n );\n});\n\nexport type ToastDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Description>;\n\nexport const ToastDescription = forwardRef<HTMLParagraphElement, ToastDescriptionProps>(\n function ToastDescription({ className, ...props }, ref) {\n return (\n <BaseToast.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().description, className)}\n data-slot=\"toast-description\"\n />\n );\n },\n);\n\nexport type ToastCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;\n\nexport const ToastClose = forwardRef<HTMLButtonElement, ToastCloseProps>(function ToastClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BaseToast.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Dismiss notification\")}\n ref={ref}\n className={withRecipeClassName(toastRecipe().close, className)}\n data-slot=\"toast-close\"\n >\n {children ?? \"×\"}\n </BaseToast.Close>\n );\n});\n\nexport type ToastActionProps = ComponentPropsWithoutRef<typeof BaseToast.Action>;\n\nexport const ToastAction = forwardRef<HTMLButtonElement, ToastActionProps>(function ToastAction(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Action\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().action, className)}\n data-slot=\"toast-action\"\n />\n );\n});\n\n/** Base UI's portal is preserved for rendering the viewport at document level. */\nexport const ToastPortal: typeof BaseToast.Portal = BaseToast.Portal;\n\nexport interface ToastComponent {\n Provider: typeof ToastProvider;\n Viewport: typeof ToastViewport;\n Root: typeof ToastRoot;\n Content: typeof ToastContent;\n Text: typeof ToastText;\n Title: typeof ToastTitle;\n Description: typeof ToastDescription;\n Close: typeof ToastClose;\n Action: typeof ToastAction;\n Portal: typeof ToastPortal;\n useToastManager: typeof BaseToast.useToastManager;\n}\n\nexport const Toast: ToastComponent = {\n Provider: ToastProvider,\n Viewport: ToastViewport,\n Root: ToastRoot,\n Content: ToastContent,\n Text: ToastText,\n Title: ToastTitle,\n Description: ToastDescription,\n Close: ToastClose,\n Action: ToastAction,\n Portal: ToastPortal,\n useToastManager: BaseToast.useToastManager,\n};\n"],"mappings":";;;;;;;;AAYA,MAAM,kBAA6C;CACjD,QAAQ;CACR,OAAO;CACP,MAAM;CACN,SAAS;CACT,SAAS;AACX;AAEA,SAAS,YAAY,MAA0B,MAAwC;CACrF,OAAO,SAAS,SAAS,KAAA,IAAY,YAAa,gBAAgB,SAAS;AAC7E;;;;;;AASA,SAAgB,cAAc,OAA2B;CACvD,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,qBAAAA,MAAU,UAAX,EAAoB,GAAI,MAAQ,CAAA;AACzC;;;;AAOA,MAAa,iBAAA,GAAA,MAAA,WAAA,CAA+D,SAAS,cACnF,EAAE,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"toast.cjs","names":["BaseToast","withRecipeClassName","toastRecipe","cx"],"sources":["../../../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { Toast as BaseToast } from \"@base-ui/react/toast\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { toast as toastRecipe } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst toneByToastType: Record<string, ToastTone> = {\n danger: \"danger\",\n error: \"danger\",\n info: \"info\",\n success: \"success\",\n warning: \"warning\",\n};\n\nfunction resolveTone(type: string | undefined, tone: ToastTone | undefined): ToastTone {\n return tone ?? (type === undefined ? \"neutral\" : (toneByToastType[type] ?? \"neutral\"));\n}\n\nexport type ToastProviderProps = ComponentPropsWithoutRef<typeof BaseToast.Provider>;\n\n/**\n * Creates an isolated, declarative toast region. Configure `timeout` and\n * `limit` here; use `Toast.Root` to render each toast from local state or\n * `Toast.useToastManager()`.\n */\nexport function ToastProvider(props: ToastProviderProps) {\n return <BaseToast.Provider {...props} />;\n}\n\nexport type ToastViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;\n\n/**\n * A bottom-centred notification region.\n */\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(function ToastViewport(\n { \"aria-label\": ariaLabel, \"aria-live\": ariaLive, className, ...props },\n ref,\n) {\n return (\n <BaseToast.Viewport\n {...props}\n aria-label={ariaLabel ?? \"Notifications\"}\n aria-live={ariaLive ?? \"polite\"}\n ref={ref}\n className={withRecipeClassName(toastRecipe().viewport, className)}\n data-jaci-component=\"toast-viewport\"\n data-slot=\"toast-viewport\"\n />\n );\n});\n\nexport interface ToastRootProps extends ComponentPropsWithoutRef<typeof BaseToast.Root> {\n /**\n * Visual status. When omitted, the value is inferred from the toast's\n * `type` (`error` maps to `danger`) and otherwise remains neutral.\n */\n tone?: ToastTone;\n}\n\n/**\n * Renders a toast object while preserving Base UI's lifecycle, focus, swipe,\n * and auto-dismiss behavior. It is intentionally composed rather than a\n * global imperative notification API.\n */\nexport const ToastRoot = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(\n { className, toast: toastObject, tone, ...props },\n ref,\n) {\n const resolvedTone = resolveTone(toastObject.type, tone);\n\n return (\n <BaseToast.Root\n {...props}\n ref={ref}\n toast={toastObject}\n className={withRecipeClassName(toastRecipe({ tone: resolvedTone }).root, className)}\n data-jaci-component=\"toast\"\n data-jaci-tone={resolvedTone}\n data-slot=\"toast\"\n />\n );\n});\n\nexport type ToastContentProps = ComponentPropsWithoutRef<typeof BaseToast.Content>;\n\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(function ToastContent(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Content\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().content, className)}\n data-slot=\"toast-content\"\n />\n );\n});\n\n/** A layout wrapper for `Toast.Title` and `Toast.Description`. */\nexport type ToastTextProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const ToastText = forwardRef<HTMLDivElement, ToastTextProps>(function ToastText(\n { className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(toastRecipe().text, className)}\n data-slot=\"toast-text\"\n />\n );\n});\n\nexport type ToastTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;\n\nexport const ToastTitle = forwardRef<HTMLHeadingElement, ToastTitleProps>(function ToastTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().title, className)}\n data-slot=\"toast-title\"\n />\n );\n});\n\nexport type ToastDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Description>;\n\nexport const ToastDescription = forwardRef<HTMLParagraphElement, ToastDescriptionProps>(\n function ToastDescription({ className, ...props }, ref) {\n return (\n <BaseToast.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().description, className)}\n data-slot=\"toast-description\"\n />\n );\n },\n);\n\nexport type ToastCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;\n\nexport const ToastClose = forwardRef<HTMLButtonElement, ToastCloseProps>(function ToastClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BaseToast.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Dismiss notification\")}\n ref={ref}\n className={withRecipeClassName(toastRecipe().close, className)}\n data-slot=\"toast-close\"\n >\n {children ?? \"×\"}\n </BaseToast.Close>\n );\n});\n\nexport type ToastActionProps = ComponentPropsWithoutRef<typeof BaseToast.Action>;\n\nexport const ToastAction = forwardRef<HTMLButtonElement, ToastActionProps>(function ToastAction(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Action\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().action, className)}\n data-slot=\"toast-action\"\n />\n );\n});\n\n/** Base UI's portal is preserved for rendering the viewport at document level. */\nexport const ToastPortal: typeof BaseToast.Portal = BaseToast.Portal;\n\nexport interface ToastComponent {\n Provider: typeof ToastProvider;\n Viewport: typeof ToastViewport;\n Root: typeof ToastRoot;\n Content: typeof ToastContent;\n Text: typeof ToastText;\n Title: typeof ToastTitle;\n Description: typeof ToastDescription;\n Close: typeof ToastClose;\n Action: typeof ToastAction;\n Portal: typeof ToastPortal;\n useToastManager: typeof BaseToast.useToastManager;\n}\n\nexport const Toast: ToastComponent = {\n Provider: ToastProvider,\n Viewport: ToastViewport,\n Root: ToastRoot,\n Content: ToastContent,\n Text: ToastText,\n Title: ToastTitle,\n Description: ToastDescription,\n Close: ToastClose,\n Action: ToastAction,\n Portal: ToastPortal,\n useToastManager: BaseToast.useToastManager,\n};\n"],"mappings":";;;;;;;;AAYA,MAAM,kBAA6C;CACjD,QAAQ;CACR,OAAO;CACP,MAAM;CACN,SAAS;CACT,SAAS;AACX;AAEA,SAAS,YAAY,MAA0B,MAAwC;CACrF,OAAO,SAAS,SAAS,KAAA,IAAY,YAAa,gBAAgB,SAAS;AAC7E;;;;;;AASA,SAAgB,cAAc,OAA2B;CACvD,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,qBAAAA,MAAU,UAAX,EAAoB,GAAI,MAAQ,CAAA;AACzC;;;;AAOA,MAAa,iBAAA,GAAA,MAAA,WAAA,CAA+D,SAAS,cACnF,EAAE,cAAc,WAAW,aAAa,UAAU,WAAW,GAAG,SAChE,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,qBAAAA,MAAU,UAAX;EACE,GAAI;EACJ,cAAY,aAAa;EACzB,aAAW,YAAY;EAClB;EACL,WAAWC,gBAAAA,oBAAoBC,cAAAA,MAAY,CAAC,CAAC,UAAU,SAAS;EAChE,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC;;;;;;AAeD,MAAa,aAAA,GAAA,MAAA,WAAA,CAAuD,SAAS,UAC3E,EAAE,WAAW,OAAO,aAAa,MAAM,GAAG,SAC1C,KACA;CACA,MAAM,eAAe,YAAY,YAAY,MAAM,IAAI;CAEvD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACF,qBAAAA,MAAU,MAAX;EACE,GAAI;EACC;EACL,OAAO;EACP,WAAWC,gBAAAA,oBAAoBC,cAAAA,MAAY,EAAE,MAAM,aAAa,CAAC,CAAC,CAAC,MAAM,SAAS;EAClF,uBAAoB;EACpB,kBAAgB;EAChB,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA6D,SAAS,aACjF,EAAE,WAAW,GAAG,SAChB,KACA;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AAoBC,cAAAA,MAAY,CAAC,CAAC,OAAO,SAAS;EAC7D,aAAU;YAET,YAAY;CACE,CAAA;AAErB,CAAC;AAID,MAAa,eAAA,GAAA,MAAA,WAAA,CAA8D,SAAS,YAClF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACF,qBAAAA,MAAU,QAAX;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,cAAAA,MAAY,CAAC,CAAC,QAAQ,SAAS;EAC9D,aAAU;CACX,CAAA;AAEL,CAAC;;AAGD,MAAa,cAAuCF,qBAAAA,MAAU;AAgB9D,MAAa,QAAwB;CACnC,UAAU;CACV,UAAU;CACV,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,aAAa;CACb,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,iBAAiBA,qBAAAA,MAAU;AAC7B"}
|
|
@@ -27,9 +27,11 @@ function ToastProvider(props) {
|
|
|
27
27
|
/**
|
|
28
28
|
* A bottom-centred notification region.
|
|
29
29
|
*/
|
|
30
|
-
const ToastViewport = forwardRef(function ToastViewport({ className, ...props }, ref) {
|
|
30
|
+
const ToastViewport = forwardRef(function ToastViewport({ "aria-label": ariaLabel, "aria-live": ariaLive, className, ...props }, ref) {
|
|
31
31
|
return /* @__PURE__ */ jsx(Toast.Viewport, {
|
|
32
32
|
...props,
|
|
33
|
+
"aria-label": ariaLabel ?? "Notifications",
|
|
34
|
+
"aria-live": ariaLive ?? "polite",
|
|
33
35
|
ref,
|
|
34
36
|
className: withRecipeClassName(toast().viewport, className),
|
|
35
37
|
"data-jaci-component": "toast-viewport",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","names":["BaseToast","toastRecipe","Toast"],"sources":["../../../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { Toast as BaseToast } from \"@base-ui/react/toast\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { toast as toastRecipe } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst toneByToastType: Record<string, ToastTone> = {\n danger: \"danger\",\n error: \"danger\",\n info: \"info\",\n success: \"success\",\n warning: \"warning\",\n};\n\nfunction resolveTone(type: string | undefined, tone: ToastTone | undefined): ToastTone {\n return tone ?? (type === undefined ? \"neutral\" : (toneByToastType[type] ?? \"neutral\"));\n}\n\nexport type ToastProviderProps = ComponentPropsWithoutRef<typeof BaseToast.Provider>;\n\n/**\n * Creates an isolated, declarative toast region. Configure `timeout` and\n * `limit` here; use `Toast.Root` to render each toast from local state or\n * `Toast.useToastManager()`.\n */\nexport function ToastProvider(props: ToastProviderProps) {\n return <BaseToast.Provider {...props} />;\n}\n\nexport type ToastViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;\n\n/**\n * A bottom-centred notification region.\n */\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(function ToastViewport(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Viewport\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().viewport, className)}\n data-jaci-component=\"toast-viewport\"\n data-slot=\"toast-viewport\"\n />\n );\n});\n\nexport interface ToastRootProps extends ComponentPropsWithoutRef<typeof BaseToast.Root> {\n /**\n * Visual status. When omitted, the value is inferred from the toast's\n * `type` (`error` maps to `danger`) and otherwise remains neutral.\n */\n tone?: ToastTone;\n}\n\n/**\n * Renders a toast object while preserving Base UI's lifecycle, focus, swipe,\n * and auto-dismiss behavior. It is intentionally composed rather than a\n * global imperative notification API.\n */\nexport const ToastRoot = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(\n { className, toast: toastObject, tone, ...props },\n ref,\n) {\n const resolvedTone = resolveTone(toastObject.type, tone);\n\n return (\n <BaseToast.Root\n {...props}\n ref={ref}\n toast={toastObject}\n className={withRecipeClassName(toastRecipe({ tone: resolvedTone }).root, className)}\n data-jaci-component=\"toast\"\n data-jaci-tone={resolvedTone}\n data-slot=\"toast\"\n />\n );\n});\n\nexport type ToastContentProps = ComponentPropsWithoutRef<typeof BaseToast.Content>;\n\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(function ToastContent(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Content\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().content, className)}\n data-slot=\"toast-content\"\n />\n );\n});\n\n/** A layout wrapper for `Toast.Title` and `Toast.Description`. */\nexport type ToastTextProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const ToastText = forwardRef<HTMLDivElement, ToastTextProps>(function ToastText(\n { className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(toastRecipe().text, className)}\n data-slot=\"toast-text\"\n />\n );\n});\n\nexport type ToastTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;\n\nexport const ToastTitle = forwardRef<HTMLHeadingElement, ToastTitleProps>(function ToastTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().title, className)}\n data-slot=\"toast-title\"\n />\n );\n});\n\nexport type ToastDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Description>;\n\nexport const ToastDescription = forwardRef<HTMLParagraphElement, ToastDescriptionProps>(\n function ToastDescription({ className, ...props }, ref) {\n return (\n <BaseToast.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().description, className)}\n data-slot=\"toast-description\"\n />\n );\n },\n);\n\nexport type ToastCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;\n\nexport const ToastClose = forwardRef<HTMLButtonElement, ToastCloseProps>(function ToastClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BaseToast.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Dismiss notification\")}\n ref={ref}\n className={withRecipeClassName(toastRecipe().close, className)}\n data-slot=\"toast-close\"\n >\n {children ?? \"×\"}\n </BaseToast.Close>\n );\n});\n\nexport type ToastActionProps = ComponentPropsWithoutRef<typeof BaseToast.Action>;\n\nexport const ToastAction = forwardRef<HTMLButtonElement, ToastActionProps>(function ToastAction(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Action\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().action, className)}\n data-slot=\"toast-action\"\n />\n );\n});\n\n/** Base UI's portal is preserved for rendering the viewport at document level. */\nexport const ToastPortal: typeof BaseToast.Portal = BaseToast.Portal;\n\nexport interface ToastComponent {\n Provider: typeof ToastProvider;\n Viewport: typeof ToastViewport;\n Root: typeof ToastRoot;\n Content: typeof ToastContent;\n Text: typeof ToastText;\n Title: typeof ToastTitle;\n Description: typeof ToastDescription;\n Close: typeof ToastClose;\n Action: typeof ToastAction;\n Portal: typeof ToastPortal;\n useToastManager: typeof BaseToast.useToastManager;\n}\n\nexport const Toast: ToastComponent = {\n Provider: ToastProvider,\n Viewport: ToastViewport,\n Root: ToastRoot,\n Content: ToastContent,\n Text: ToastText,\n Title: ToastTitle,\n Description: ToastDescription,\n Close: ToastClose,\n Action: ToastAction,\n Portal: ToastPortal,\n useToastManager: BaseToast.useToastManager,\n};\n"],"mappings":";;;;;;;;AAYA,MAAM,kBAA6C;CACjD,QAAQ;CACR,OAAO;CACP,MAAM;CACN,SAAS;CACT,SAAS;AACX;AAEA,SAAS,YAAY,MAA0B,MAAwC;CACrF,OAAO,SAAS,SAAS,KAAA,IAAY,YAAa,gBAAgB,SAAS;AAC7E;;;;;;AASA,SAAgB,cAAc,OAA2B;CACvD,OAAO,oBAACA,MAAU,UAAX,EAAoB,GAAI,MAAQ,CAAA;AACzC;;;;AAOA,MAAa,gBAAgB,WAA+C,SAAS,cACnF,EAAE,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"toast.js","names":["BaseToast","toastRecipe","Toast"],"sources":["../../../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { Toast as BaseToast } from \"@base-ui/react/toast\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { toast as toastRecipe } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst toneByToastType: Record<string, ToastTone> = {\n danger: \"danger\",\n error: \"danger\",\n info: \"info\",\n success: \"success\",\n warning: \"warning\",\n};\n\nfunction resolveTone(type: string | undefined, tone: ToastTone | undefined): ToastTone {\n return tone ?? (type === undefined ? \"neutral\" : (toneByToastType[type] ?? \"neutral\"));\n}\n\nexport type ToastProviderProps = ComponentPropsWithoutRef<typeof BaseToast.Provider>;\n\n/**\n * Creates an isolated, declarative toast region. Configure `timeout` and\n * `limit` here; use `Toast.Root` to render each toast from local state or\n * `Toast.useToastManager()`.\n */\nexport function ToastProvider(props: ToastProviderProps) {\n return <BaseToast.Provider {...props} />;\n}\n\nexport type ToastViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;\n\n/**\n * A bottom-centred notification region.\n */\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(function ToastViewport(\n { \"aria-label\": ariaLabel, \"aria-live\": ariaLive, className, ...props },\n ref,\n) {\n return (\n <BaseToast.Viewport\n {...props}\n aria-label={ariaLabel ?? \"Notifications\"}\n aria-live={ariaLive ?? \"polite\"}\n ref={ref}\n className={withRecipeClassName(toastRecipe().viewport, className)}\n data-jaci-component=\"toast-viewport\"\n data-slot=\"toast-viewport\"\n />\n );\n});\n\nexport interface ToastRootProps extends ComponentPropsWithoutRef<typeof BaseToast.Root> {\n /**\n * Visual status. When omitted, the value is inferred from the toast's\n * `type` (`error` maps to `danger`) and otherwise remains neutral.\n */\n tone?: ToastTone;\n}\n\n/**\n * Renders a toast object while preserving Base UI's lifecycle, focus, swipe,\n * and auto-dismiss behavior. It is intentionally composed rather than a\n * global imperative notification API.\n */\nexport const ToastRoot = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(\n { className, toast: toastObject, tone, ...props },\n ref,\n) {\n const resolvedTone = resolveTone(toastObject.type, tone);\n\n return (\n <BaseToast.Root\n {...props}\n ref={ref}\n toast={toastObject}\n className={withRecipeClassName(toastRecipe({ tone: resolvedTone }).root, className)}\n data-jaci-component=\"toast\"\n data-jaci-tone={resolvedTone}\n data-slot=\"toast\"\n />\n );\n});\n\nexport type ToastContentProps = ComponentPropsWithoutRef<typeof BaseToast.Content>;\n\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(function ToastContent(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Content\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().content, className)}\n data-slot=\"toast-content\"\n />\n );\n});\n\n/** A layout wrapper for `Toast.Title` and `Toast.Description`. */\nexport type ToastTextProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const ToastText = forwardRef<HTMLDivElement, ToastTextProps>(function ToastText(\n { className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(toastRecipe().text, className)}\n data-slot=\"toast-text\"\n />\n );\n});\n\nexport type ToastTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;\n\nexport const ToastTitle = forwardRef<HTMLHeadingElement, ToastTitleProps>(function ToastTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().title, className)}\n data-slot=\"toast-title\"\n />\n );\n});\n\nexport type ToastDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Description>;\n\nexport const ToastDescription = forwardRef<HTMLParagraphElement, ToastDescriptionProps>(\n function ToastDescription({ className, ...props }, ref) {\n return (\n <BaseToast.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().description, className)}\n data-slot=\"toast-description\"\n />\n );\n },\n);\n\nexport type ToastCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;\n\nexport const ToastClose = forwardRef<HTMLButtonElement, ToastCloseProps>(function ToastClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BaseToast.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Dismiss notification\")}\n ref={ref}\n className={withRecipeClassName(toastRecipe().close, className)}\n data-slot=\"toast-close\"\n >\n {children ?? \"×\"}\n </BaseToast.Close>\n );\n});\n\nexport type ToastActionProps = ComponentPropsWithoutRef<typeof BaseToast.Action>;\n\nexport const ToastAction = forwardRef<HTMLButtonElement, ToastActionProps>(function ToastAction(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Action\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().action, className)}\n data-slot=\"toast-action\"\n />\n );\n});\n\n/** Base UI's portal is preserved for rendering the viewport at document level. */\nexport const ToastPortal: typeof BaseToast.Portal = BaseToast.Portal;\n\nexport interface ToastComponent {\n Provider: typeof ToastProvider;\n Viewport: typeof ToastViewport;\n Root: typeof ToastRoot;\n Content: typeof ToastContent;\n Text: typeof ToastText;\n Title: typeof ToastTitle;\n Description: typeof ToastDescription;\n Close: typeof ToastClose;\n Action: typeof ToastAction;\n Portal: typeof ToastPortal;\n useToastManager: typeof BaseToast.useToastManager;\n}\n\nexport const Toast: ToastComponent = {\n Provider: ToastProvider,\n Viewport: ToastViewport,\n Root: ToastRoot,\n Content: ToastContent,\n Text: ToastText,\n Title: ToastTitle,\n Description: ToastDescription,\n Close: ToastClose,\n Action: ToastAction,\n Portal: ToastPortal,\n useToastManager: BaseToast.useToastManager,\n};\n"],"mappings":";;;;;;;;AAYA,MAAM,kBAA6C;CACjD,QAAQ;CACR,OAAO;CACP,MAAM;CACN,SAAS;CACT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,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAACD,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAW,oBAAoBC,MAAY,CAAC,CAAC,OAAO,SAAS;EAC7D,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,mBAAmB,WAC9B,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAS,KAAK;CACtD,OACE,oBAACD,MAAU,aAAX;EACE,GAAI;EACC;EACL,WAAW,oBAAoBC,MAAY,CAAC,CAAC,aAAa,SAAS;EACnE,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,aAAa,WAA+C,SAAS,WAChF,EAAE,cAAc,WAAW,UAAU,WAAW,GAAG,SACnD,KACA;CACA,MAAM,kBAAkB,YAAY;CAEpC,OACE,oBAACD,MAAU,OAAX;EACE,GAAI;EACJ,cAAY,cAAc,kBAAkB,KAAA,IAAY;EACnD;EACL,WAAW,oBAAoBC,MAAY,CAAC,CAAC,OAAO,SAAS;EAC7D,aAAU;YAET,YAAY;CACE,CAAA;AAErB,CAAC;AAID,MAAa,cAAc,WAAgD,SAAS,YAClF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAACD,MAAU,QAAX;EACE,GAAI;EACC;EACL,WAAW,oBAAoBC,MAAY,CAAC,CAAC,QAAQ,SAAS;EAC9D,aAAU;CACX,CAAA;AAEL,CAAC;;AAGD,MAAa,cAAuCD,MAAU;AAgB9D,MAAaE,UAAwB;CACnC,UAAU;CACV,UAAU;CACV,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,aAAa;CACb,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,iBAAiBF,MAAU;AAC7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TreeView, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewToggle, TreeViewToggleProps } from "./tree-view.cjs";
|
|
2
|
-
export { TreeView, TreeViewGroup, type TreeViewGroupProps, TreeViewItem, type TreeViewItemProps, TreeViewLabel, type TreeViewLabelProps, TreeViewRoot, type TreeViewRootProps, type TreeViewSelection, type TreeViewSelectionMode, TreeViewToggle, type TreeViewToggleProps };
|
|
1
|
+
import { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewLoading, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewStateProps, TreeViewToggle, TreeViewToggleProps } from "./tree-view.cjs";
|
|
2
|
+
export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, type TreeViewGroupProps, TreeViewItem, type TreeViewItemProps, TreeViewLabel, type TreeViewLabelProps, TreeViewLoading, TreeViewRoot, type TreeViewRootProps, type TreeViewSelection, type TreeViewSelectionMode, type TreeViewStateProps, TreeViewToggle, type TreeViewToggleProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TreeView, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewToggle, TreeViewToggleProps } from "./tree-view.js";
|
|
2
|
-
export { TreeView, TreeViewGroup, type TreeViewGroupProps, TreeViewItem, type TreeViewItemProps, TreeViewLabel, type TreeViewLabelProps, TreeViewRoot, type TreeViewRootProps, type TreeViewSelection, type TreeViewSelectionMode, TreeViewToggle, type TreeViewToggleProps };
|
|
1
|
+
import { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewLoading, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewStateProps, TreeViewToggle, TreeViewToggleProps } from "./tree-view.js";
|
|
2
|
+
export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, type TreeViewGroupProps, TreeViewItem, type TreeViewItemProps, TreeViewLabel, type TreeViewLabelProps, TreeViewLoading, TreeViewRoot, type TreeViewRootProps, type TreeViewSelection, type TreeViewSelectionMode, type TreeViewStateProps, TreeViewToggle, type TreeViewToggleProps };
|
|
@@ -47,7 +47,7 @@ const TreeViewRoot = (0, react.forwardRef)(function TreeViewRoot({ children, cla
|
|
|
47
47
|
const node = nodesRef.current.get(id);
|
|
48
48
|
if (node) node.element = element;
|
|
49
49
|
}, []);
|
|
50
|
-
const hasChildren = (0, react.useCallback)((id) => nodes.some((node) => node.parentId === id), [nodes]);
|
|
50
|
+
const hasChildren = (0, react.useCallback)((id) => nodes.some((node) => node.parentId === id) || Boolean(nodes.find((node) => node.id === id)?.hasChildren), [nodes]);
|
|
51
51
|
const isVisible = (0, react.useCallback)((id) => {
|
|
52
52
|
let current = nodes.find((node) => node.id === id);
|
|
53
53
|
while (current?.parentId) {
|
|
@@ -199,7 +199,7 @@ const TreeViewRoot = (0, react.forwardRef)(function TreeViewRoot({ children, cla
|
|
|
199
199
|
})
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
|
-
const TreeViewItem = (0, react.forwardRef)(function TreeViewItem({ children, className, disabled = false, onClick, onFocus, onKeyDown, style, selectable = true, id, ...props }, ref) {
|
|
202
|
+
const TreeViewItem = (0, react.forwardRef)(function TreeViewItem({ children, className, disabled = false, hasChildren: hasChildrenProp = false, loading = false, onClick, onFocus, onKeyDown, style, selectable = true, id, ...props }, ref) {
|
|
203
203
|
const context = useTreeViewContext();
|
|
204
204
|
const parentId = (0, react.useContext)(TreeParentContext);
|
|
205
205
|
const styles = require_tree_view.treeView();
|
|
@@ -207,13 +207,17 @@ const TreeViewItem = (0, react.forwardRef)(function TreeViewItem({ children, cla
|
|
|
207
207
|
id,
|
|
208
208
|
parentId,
|
|
209
209
|
disabled,
|
|
210
|
+
hasChildren: hasChildrenProp,
|
|
211
|
+
loading,
|
|
210
212
|
selectable,
|
|
211
213
|
order: 0,
|
|
212
214
|
element: null
|
|
213
215
|
}), [
|
|
214
216
|
context.registerNode,
|
|
215
217
|
disabled,
|
|
218
|
+
hasChildrenProp,
|
|
216
219
|
id,
|
|
220
|
+
loading,
|
|
217
221
|
parentId,
|
|
218
222
|
selectable
|
|
219
223
|
]);
|
|
@@ -239,6 +243,7 @@ const TreeViewItem = (0, react.forwardRef)(function TreeViewItem({ children, cla
|
|
|
239
243
|
},
|
|
240
244
|
"aria-disabled": disabled || void 0,
|
|
241
245
|
"aria-expanded": context.hasChildren(id) ? context.expanded.has(id) : void 0,
|
|
246
|
+
"aria-busy": loading || void 0,
|
|
242
247
|
"aria-level": registeredNode ? context.getDepth(id) : parentId ? 2 : 1,
|
|
243
248
|
"aria-posinset": siblingIndex >= 0 ? siblingIndex + 1 : 1,
|
|
244
249
|
"aria-setsize": siblings.length || 1,
|
|
@@ -248,6 +253,7 @@ const TreeViewItem = (0, react.forwardRef)(function TreeViewItem({ children, cla
|
|
|
248
253
|
"data-expanded": context.expanded.has(id) || void 0,
|
|
249
254
|
"data-jaci-component": "tree-view",
|
|
250
255
|
"data-selected": selected || void 0,
|
|
256
|
+
"data-loading": loading || void 0,
|
|
251
257
|
"data-slot": "tree-view-item",
|
|
252
258
|
onClick: (event) => {
|
|
253
259
|
event.stopPropagation();
|
|
@@ -303,12 +309,16 @@ const TreeViewGroup = (0, react.forwardRef)(function TreeViewGroup({ children, c
|
|
|
303
309
|
const TreeViewToggle = (0, react.forwardRef)(function TreeViewToggle({ children, className, onClick, ...props }, ref) {
|
|
304
310
|
const context = useTreeViewContext();
|
|
305
311
|
const id = (0, react.useContext)(TreeItemContext);
|
|
312
|
+
const item = id ? context.nodes.find((candidate) => candidate.id === id) : void 0;
|
|
313
|
+
const disabled = context.disabled || Boolean(item?.disabled);
|
|
306
314
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
307
315
|
...props,
|
|
308
316
|
ref,
|
|
309
317
|
"aria-expanded": id ? context.expanded.has(id) : void 0,
|
|
318
|
+
"aria-disabled": disabled || void 0,
|
|
310
319
|
className: require_cx.cx(require_tree_view.treeView().toggle, className),
|
|
311
320
|
"data-slot": "tree-view-toggle",
|
|
321
|
+
disabled: disabled || props.disabled,
|
|
312
322
|
onClick: (event) => {
|
|
313
323
|
event.stopPropagation();
|
|
314
324
|
onClick?.(event);
|
|
@@ -327,18 +337,65 @@ const TreeViewLabel = (0, react.forwardRef)(function TreeViewLabel({ className,
|
|
|
327
337
|
"data-slot": "tree-view-label"
|
|
328
338
|
});
|
|
329
339
|
});
|
|
340
|
+
const TreeViewLoading = (0, react.forwardRef)(function TreeViewLoading({ children = "Loading…", className, ...props }, ref) {
|
|
341
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
342
|
+
...props,
|
|
343
|
+
ref,
|
|
344
|
+
"aria-disabled": "true",
|
|
345
|
+
"aria-live": "polite",
|
|
346
|
+
"aria-level": 1,
|
|
347
|
+
className: require_cx.cx(require_tree_view.treeView().loading, className),
|
|
348
|
+
"data-slot": "tree-view-loading",
|
|
349
|
+
role: "treeitem",
|
|
350
|
+
tabIndex: -1,
|
|
351
|
+
children
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
const TreeViewEmpty = (0, react.forwardRef)(function TreeViewEmpty({ children = "No items found.", className, ...props }, ref) {
|
|
355
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
356
|
+
...props,
|
|
357
|
+
ref,
|
|
358
|
+
"aria-disabled": "true",
|
|
359
|
+
"aria-level": 1,
|
|
360
|
+
className: require_cx.cx(require_tree_view.treeView().empty, className),
|
|
361
|
+
"data-slot": "tree-view-empty",
|
|
362
|
+
role: "treeitem",
|
|
363
|
+
tabIndex: -1,
|
|
364
|
+
children
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
const TreeViewError = (0, react.forwardRef)(function TreeViewError({ children = "Something went wrong.", className, ...props }, ref) {
|
|
368
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
369
|
+
...props,
|
|
370
|
+
ref,
|
|
371
|
+
"aria-disabled": "true",
|
|
372
|
+
"aria-live": "assertive",
|
|
373
|
+
"aria-level": 1,
|
|
374
|
+
className: require_cx.cx(require_tree_view.treeView().error, className),
|
|
375
|
+
"data-slot": "tree-view-error",
|
|
376
|
+
role: "treeitem",
|
|
377
|
+
tabIndex: -1,
|
|
378
|
+
children
|
|
379
|
+
});
|
|
380
|
+
});
|
|
330
381
|
const TreeView = {
|
|
331
382
|
Root: TreeViewRoot,
|
|
332
383
|
Item: TreeViewItem,
|
|
333
384
|
Group: TreeViewGroup,
|
|
334
385
|
Toggle: TreeViewToggle,
|
|
335
|
-
Label: TreeViewLabel
|
|
386
|
+
Label: TreeViewLabel,
|
|
387
|
+
Loading: TreeViewLoading,
|
|
388
|
+
Empty: TreeViewEmpty,
|
|
389
|
+
Error: TreeViewError
|
|
336
390
|
};
|
|
337
391
|
//#endregion
|
|
338
392
|
exports.TreeView = TreeView;
|
|
393
|
+
exports.TreeViewEmpty = TreeViewEmpty;
|
|
394
|
+
exports.TreeViewError = TreeViewError;
|
|
339
395
|
exports.TreeViewGroup = TreeViewGroup;
|
|
340
396
|
exports.TreeViewItem = TreeViewItem;
|
|
341
397
|
exports.TreeViewLabel = TreeViewLabel;
|
|
398
|
+
exports.TreeViewLoading = TreeViewLoading;
|
|
342
399
|
exports.TreeViewRoot = TreeViewRoot;
|
|
343
400
|
exports.TreeViewToggle = TreeViewToggle;
|
|
344
401
|
|
|
@@ -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 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) => nodes.some((node) => node.parentId === id),\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 selectable?: boolean;\n}\n\nexport const TreeViewItem = forwardRef<HTMLDivElement, TreeViewItemProps>(function TreeViewItem(\n {\n children,\n className,\n disabled = 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 () => context.registerNode({ id, parentId, disabled, selectable, order: 0, element: null }),\n [context.registerNode, disabled, id, 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-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-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 return (\n <button\n {...props}\n ref={ref}\n aria-expanded={id ? context.expanded.has(id) : undefined}\n className={cx(treeView().toggle, className)}\n data-slot=\"tree-view-toggle\"\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 const TreeView = {\n Root: TreeViewRoot,\n Item: TreeViewItem,\n Group: TreeViewGroup,\n Toggle: TreeViewToggle,\n Label: TreeViewLabel,\n};\n"],"mappings":";;;;;;AAmDA,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,WAAA,CAA6D,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,4BAAA,GAAA,MAAA,SAAA,OAA0C,IAAI,IAAI,eAAe,CAAC;CAC/F,MAAM,CAAC,sBAAsB,4BAAA,GAAA,MAAA,SAAA,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AAO,SAAS;EACzC,aAAU;CACX,CAAA;AAEL,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;AACT"}
|
|
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,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,WAAWC,WAAAA,GAAGD,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"}
|
|
@@ -18,6 +18,8 @@ declare const TreeViewRoot: import("react").ForwardRefExoticComponent<TreeViewRo
|
|
|
18
18
|
interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<"div">, "id"> {
|
|
19
19
|
id: string;
|
|
20
20
|
disabled?: boolean;
|
|
21
|
+
hasChildren?: boolean;
|
|
22
|
+
loading?: boolean;
|
|
21
23
|
selectable?: boolean;
|
|
22
24
|
}
|
|
23
25
|
declare const TreeViewItem: import("react").ForwardRefExoticComponent<TreeViewItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -27,13 +29,22 @@ type TreeViewToggleProps = ComponentPropsWithoutRef<"button">;
|
|
|
27
29
|
declare const TreeViewToggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
28
30
|
type TreeViewLabelProps = ComponentPropsWithoutRef<"span">;
|
|
29
31
|
declare const TreeViewLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
32
|
+
interface TreeViewStateProps extends ComponentPropsWithoutRef<"div"> {
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
declare const TreeViewLoading: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
|
+
declare const TreeViewEmpty: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
37
|
+
declare const TreeViewError: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
38
|
declare const TreeView: {
|
|
31
39
|
Root: import("react").ForwardRefExoticComponent<TreeViewRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
40
|
Item: import("react").ForwardRefExoticComponent<TreeViewItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
33
41
|
Group: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
42
|
Toggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
35
43
|
Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
44
|
+
Loading: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
45
|
+
Empty: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
46
|
+
Error: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
47
|
};
|
|
37
48
|
//#endregion
|
|
38
|
-
export { TreeView, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewToggle, TreeViewToggleProps };
|
|
49
|
+
export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewLoading, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewStateProps, TreeViewToggle, TreeViewToggleProps };
|
|
39
50
|
//# sourceMappingURL=tree-view.d.cts.map
|
|
@@ -18,6 +18,8 @@ declare const TreeViewRoot: import("react").ForwardRefExoticComponent<TreeViewRo
|
|
|
18
18
|
interface TreeViewItemProps extends Omit<ComponentPropsWithoutRef<"div">, "id"> {
|
|
19
19
|
id: string;
|
|
20
20
|
disabled?: boolean;
|
|
21
|
+
hasChildren?: boolean;
|
|
22
|
+
loading?: boolean;
|
|
21
23
|
selectable?: boolean;
|
|
22
24
|
}
|
|
23
25
|
declare const TreeViewItem: import("react").ForwardRefExoticComponent<TreeViewItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -27,13 +29,22 @@ type TreeViewToggleProps = ComponentPropsWithoutRef<"button">;
|
|
|
27
29
|
declare const TreeViewToggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
28
30
|
type TreeViewLabelProps = ComponentPropsWithoutRef<"span">;
|
|
29
31
|
declare const TreeViewLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
32
|
+
interface TreeViewStateProps extends ComponentPropsWithoutRef<"div"> {
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
declare const TreeViewLoading: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
|
+
declare const TreeViewEmpty: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
37
|
+
declare const TreeViewError: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
38
|
declare const TreeView: {
|
|
31
39
|
Root: import("react").ForwardRefExoticComponent<TreeViewRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
32
40
|
Item: import("react").ForwardRefExoticComponent<TreeViewItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
33
41
|
Group: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
42
|
Toggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
35
43
|
Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
44
|
+
Loading: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
45
|
+
Empty: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
46
|
+
Error: import("react").ForwardRefExoticComponent<TreeViewStateProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
36
47
|
};
|
|
37
48
|
//#endregion
|
|
38
|
-
export { TreeView, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewToggle, TreeViewToggleProps };
|
|
49
|
+
export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewGroupProps, TreeViewItem, TreeViewItemProps, TreeViewLabel, TreeViewLabelProps, TreeViewLoading, TreeViewRoot, TreeViewRootProps, TreeViewSelection, TreeViewSelectionMode, TreeViewStateProps, TreeViewToggle, TreeViewToggleProps };
|
|
39
50
|
//# sourceMappingURL=tree-view.d.ts.map
|
|
@@ -47,7 +47,7 @@ const TreeViewRoot = forwardRef(function TreeViewRoot({ children, className, def
|
|
|
47
47
|
const node = nodesRef.current.get(id);
|
|
48
48
|
if (node) node.element = element;
|
|
49
49
|
}, []);
|
|
50
|
-
const hasChildren = useCallback((id) => nodes.some((node) => node.parentId === id), [nodes]);
|
|
50
|
+
const hasChildren = useCallback((id) => nodes.some((node) => node.parentId === id) || Boolean(nodes.find((node) => node.id === id)?.hasChildren), [nodes]);
|
|
51
51
|
const isVisible = useCallback((id) => {
|
|
52
52
|
let current = nodes.find((node) => node.id === id);
|
|
53
53
|
while (current?.parentId) {
|
|
@@ -199,7 +199,7 @@ const TreeViewRoot = forwardRef(function TreeViewRoot({ children, className, def
|
|
|
199
199
|
})
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
|
-
const TreeViewItem = forwardRef(function TreeViewItem({ children, className, disabled = false, onClick, onFocus, onKeyDown, style, selectable = true, id, ...props }, ref) {
|
|
202
|
+
const TreeViewItem = forwardRef(function TreeViewItem({ children, className, disabled = false, hasChildren: hasChildrenProp = false, loading = false, onClick, onFocus, onKeyDown, style, selectable = true, id, ...props }, ref) {
|
|
203
203
|
const context = useTreeViewContext();
|
|
204
204
|
const parentId = useContext(TreeParentContext);
|
|
205
205
|
const styles = treeView();
|
|
@@ -207,13 +207,17 @@ const TreeViewItem = forwardRef(function TreeViewItem({ children, className, dis
|
|
|
207
207
|
id,
|
|
208
208
|
parentId,
|
|
209
209
|
disabled,
|
|
210
|
+
hasChildren: hasChildrenProp,
|
|
211
|
+
loading,
|
|
210
212
|
selectable,
|
|
211
213
|
order: 0,
|
|
212
214
|
element: null
|
|
213
215
|
}), [
|
|
214
216
|
context.registerNode,
|
|
215
217
|
disabled,
|
|
218
|
+
hasChildrenProp,
|
|
216
219
|
id,
|
|
220
|
+
loading,
|
|
217
221
|
parentId,
|
|
218
222
|
selectable
|
|
219
223
|
]);
|
|
@@ -239,6 +243,7 @@ const TreeViewItem = forwardRef(function TreeViewItem({ children, className, dis
|
|
|
239
243
|
},
|
|
240
244
|
"aria-disabled": disabled || void 0,
|
|
241
245
|
"aria-expanded": context.hasChildren(id) ? context.expanded.has(id) : void 0,
|
|
246
|
+
"aria-busy": loading || void 0,
|
|
242
247
|
"aria-level": registeredNode ? context.getDepth(id) : parentId ? 2 : 1,
|
|
243
248
|
"aria-posinset": siblingIndex >= 0 ? siblingIndex + 1 : 1,
|
|
244
249
|
"aria-setsize": siblings.length || 1,
|
|
@@ -248,6 +253,7 @@ const TreeViewItem = forwardRef(function TreeViewItem({ children, className, dis
|
|
|
248
253
|
"data-expanded": context.expanded.has(id) || void 0,
|
|
249
254
|
"data-jaci-component": "tree-view",
|
|
250
255
|
"data-selected": selected || void 0,
|
|
256
|
+
"data-loading": loading || void 0,
|
|
251
257
|
"data-slot": "tree-view-item",
|
|
252
258
|
onClick: (event) => {
|
|
253
259
|
event.stopPropagation();
|
|
@@ -303,12 +309,16 @@ const TreeViewGroup = forwardRef(function TreeViewGroup({ children, className, s
|
|
|
303
309
|
const TreeViewToggle = forwardRef(function TreeViewToggle({ children, className, onClick, ...props }, ref) {
|
|
304
310
|
const context = useTreeViewContext();
|
|
305
311
|
const id = useContext(TreeItemContext);
|
|
312
|
+
const item = id ? context.nodes.find((candidate) => candidate.id === id) : void 0;
|
|
313
|
+
const disabled = context.disabled || Boolean(item?.disabled);
|
|
306
314
|
return /* @__PURE__ */ jsx("button", {
|
|
307
315
|
...props,
|
|
308
316
|
ref,
|
|
309
317
|
"aria-expanded": id ? context.expanded.has(id) : void 0,
|
|
318
|
+
"aria-disabled": disabled || void 0,
|
|
310
319
|
className: cx(treeView().toggle, className),
|
|
311
320
|
"data-slot": "tree-view-toggle",
|
|
321
|
+
disabled: disabled || props.disabled,
|
|
312
322
|
onClick: (event) => {
|
|
313
323
|
event.stopPropagation();
|
|
314
324
|
onClick?.(event);
|
|
@@ -327,14 +337,58 @@ const TreeViewLabel = forwardRef(function TreeViewLabel({ className, ...props },
|
|
|
327
337
|
"data-slot": "tree-view-label"
|
|
328
338
|
});
|
|
329
339
|
});
|
|
340
|
+
const TreeViewLoading = forwardRef(function TreeViewLoading({ children = "Loading…", className, ...props }, ref) {
|
|
341
|
+
return /* @__PURE__ */ jsx("div", {
|
|
342
|
+
...props,
|
|
343
|
+
ref,
|
|
344
|
+
"aria-disabled": "true",
|
|
345
|
+
"aria-live": "polite",
|
|
346
|
+
"aria-level": 1,
|
|
347
|
+
className: cx(treeView().loading, className),
|
|
348
|
+
"data-slot": "tree-view-loading",
|
|
349
|
+
role: "treeitem",
|
|
350
|
+
tabIndex: -1,
|
|
351
|
+
children
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
const TreeViewEmpty = forwardRef(function TreeViewEmpty({ children = "No items found.", className, ...props }, ref) {
|
|
355
|
+
return /* @__PURE__ */ jsx("div", {
|
|
356
|
+
...props,
|
|
357
|
+
ref,
|
|
358
|
+
"aria-disabled": "true",
|
|
359
|
+
"aria-level": 1,
|
|
360
|
+
className: cx(treeView().empty, className),
|
|
361
|
+
"data-slot": "tree-view-empty",
|
|
362
|
+
role: "treeitem",
|
|
363
|
+
tabIndex: -1,
|
|
364
|
+
children
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
const TreeViewError = forwardRef(function TreeViewError({ children = "Something went wrong.", className, ...props }, ref) {
|
|
368
|
+
return /* @__PURE__ */ jsx("div", {
|
|
369
|
+
...props,
|
|
370
|
+
ref,
|
|
371
|
+
"aria-disabled": "true",
|
|
372
|
+
"aria-live": "assertive",
|
|
373
|
+
"aria-level": 1,
|
|
374
|
+
className: cx(treeView().error, className),
|
|
375
|
+
"data-slot": "tree-view-error",
|
|
376
|
+
role: "treeitem",
|
|
377
|
+
tabIndex: -1,
|
|
378
|
+
children
|
|
379
|
+
});
|
|
380
|
+
});
|
|
330
381
|
const TreeView = {
|
|
331
382
|
Root: TreeViewRoot,
|
|
332
383
|
Item: TreeViewItem,
|
|
333
384
|
Group: TreeViewGroup,
|
|
334
385
|
Toggle: TreeViewToggle,
|
|
335
|
-
Label: TreeViewLabel
|
|
386
|
+
Label: TreeViewLabel,
|
|
387
|
+
Loading: TreeViewLoading,
|
|
388
|
+
Empty: TreeViewEmpty,
|
|
389
|
+
Error: TreeViewError
|
|
336
390
|
};
|
|
337
391
|
//#endregion
|
|
338
|
-
export { TreeView, TreeViewGroup, TreeViewItem, TreeViewLabel, TreeViewRoot, TreeViewToggle };
|
|
392
|
+
export { TreeView, TreeViewEmpty, TreeViewError, TreeViewGroup, TreeViewItem, TreeViewLabel, TreeViewLoading, TreeViewRoot, TreeViewToggle };
|
|
339
393
|
|
|
340
394
|
//# sourceMappingURL=tree-view.js.map
|