@kumix/ui 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -30
- package/dist/{cascader-types-DVT-znZ-.d.ts → cascader-types-zhnUQ4sP.d.ts} +11 -3
- package/dist/cascader-types-zhnUQ4sP.d.ts.map +1 -0
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/charts/candlestick-chart/context.d.ts.map +1 -1
- package/dist/components/charts/donut-chart/context.d.ts.map +1 -1
- package/dist/components/charts/liquidity-heatmap.d.ts.map +1 -1
- package/dist/components/charts/order-book.d.ts.map +1 -1
- package/dist/components/charts/treemap.d.ts.map +1 -1
- package/dist/components/charts/volume-profile.d.ts.map +1 -1
- package/dist/components/motion/action-swap.d.ts +1 -1
- package/dist/components/motion/action-swap.d.ts.map +1 -1
- package/dist/components/motion/action-swap.js +43 -20
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/animated-badge.d.ts +1 -1
- package/dist/components/motion/animated-badge.d.ts.map +1 -1
- package/dist/components/motion/animated-badge.js +60 -101
- package/dist/components/motion/animated-badge.js.map +1 -1
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-toast-stack.js +1 -1
- package/dist/components/motion/attachment-upload.js +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +1 -1
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.d.ts.map +1 -1
- package/dist/components/motion/bloom-menu.js +73 -8
- package/dist/components/motion/bloom-menu.js.map +1 -1
- package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
- package/dist/components/motion/bottom-sheet.js +6 -10
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +35 -22
- package/dist/components/motion/bouncy-accordion.js.map +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/color-picker.d.ts.map +1 -1
- package/dist/components/motion/command-palette.js +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/date-range-picker.d.ts.map +1 -1
- package/dist/components/motion/drawer.d.ts +1 -1
- package/dist/components/motion/drawer.d.ts.map +1 -1
- package/dist/components/motion/drawer.js +10 -10
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
- package/dist/components/motion/feedback-widget.js +4 -1
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/morphing-lightbox.d.ts.map +1 -1
- package/dist/components/motion/morphing-lightbox.js +1 -1
- package/dist/components/motion/morphing-modal.d.ts +6 -1
- package/dist/components/motion/morphing-modal.d.ts.map +1 -1
- package/dist/components/motion/morphing-modal.js +37 -5
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/otp-input.js +19 -11
- package/dist/components/motion/otp-input.js.map +1 -1
- package/dist/components/motion/popover-morph.d.ts +4 -3
- package/dist/components/motion/popover-morph.d.ts.map +1 -1
- package/dist/components/motion/popover-morph.js +47 -55
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.js +7 -1
- package/dist/components/motion/popover.js.map +1 -1
- package/dist/components/motion/prediction-market-card.js +1 -1
- package/dist/components/motion/prediction-market.js +1 -1
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/radio.d.ts +5 -1
- package/dist/components/motion/radio.d.ts.map +1 -1
- package/dist/components/motion/radio.js +53 -5
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/select-morph.d.ts +1 -1
- package/dist/components/motion/select-morph.d.ts.map +1 -1
- package/dist/components/motion/select-morph.js +89 -21
- package/dist/components/motion/select-morph.js.map +1 -1
- package/dist/components/motion/select.d.ts.map +1 -1
- package/dist/components/motion/select.js +153 -135
- package/dist/components/motion/select.js.map +1 -1
- package/dist/components/motion/shader-background.d.ts +3 -2
- package/dist/components/motion/shader-background.d.ts.map +1 -1
- package/dist/components/motion/shader-background.js +9 -3
- package/dist/components/motion/shader-background.js.map +1 -1
- package/dist/components/motion/shared-layout-bg.d.ts.map +1 -1
- package/dist/components/motion/shared-layout-bg.js +17 -3
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/swipeable-list.d.ts.map +1 -1
- package/dist/components/motion/swipeable-list.js +61 -4
- package/dist/components/motion/swipeable-list.js.map +1 -1
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/tabs.d.ts +12 -3
- package/dist/components/motion/tabs.d.ts.map +1 -1
- package/dist/components/motion/tabs.js +248 -26
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts.map +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/autocomplete.js.map +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/cascader/cascader-async.d.ts +21 -5
- package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-async.js +61 -34
- package/dist/components/reui/cascader/cascader-async.js.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +5 -2
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-context.d.ts +3 -1
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-context.js.map +1 -1
- package/dist/components/reui/cascader/cascader-i18n.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-item.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-lib.d.ts +34 -8
- package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-lib.js +145 -29
- package/dist/components/reui/cascader/cascader-lib.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-types.d.ts +1 -1
- package/dist/components/reui/cascader/cascader.d.ts +13 -8
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader.js +31 -16
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
- package/dist/components/reui/color-picker.js +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-cell-selection.js +1 -0
- package/dist/components/reui/data-grid/data-grid-cell-selection.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +1 -0
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts +6 -8
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +7 -8
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +1 -0
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +1 -0
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +1 -0
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +3 -2
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +2 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +2 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +6 -11
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +22 -22
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +16 -1
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +80 -22
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.d.ts.map +1 -1
- package/dist/components/reui/date-selector.js +21 -15
- package/dist/components/reui/date-selector.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +3 -5
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
- package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar.js +34 -31
- package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
- package/dist/components/reui/file-type.d.ts +302 -6
- package/dist/components/reui/file-type.d.ts.map +1 -1
- package/dist/components/reui/file-type.js +416 -13
- package/dist/components/reui/file-type.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.d.ts +1 -1
- package/dist/components/reui/filters/filters-lib.d.ts +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +2 -2
- package/dist/components/reui/gantt/gantt-nav.js.map +1 -1
- package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt.js +5 -2
- package/dist/components/reui/gantt/gantt.js.map +1 -1
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/phone-input.js +30 -27
- package/dist/components/reui/phone-input.js.map +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/time-picker.js +1 -1
- package/dist/components/ui/attachment.d.ts +2 -2
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/code-block.d.ts +29 -0
- package/dist/components/ui/code-block.d.ts.map +1 -0
- package/dist/components/ui/code-block.js +124 -0
- package/dist/components/ui/code-block.js.map +1 -0
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/trace.d.ts +21 -0
- package/dist/components/ui/trace.d.ts.map +1 -0
- package/dist/components/ui/trace.js +77 -0
- package/dist/components/ui/trace.js.map +1 -0
- package/dist/context-BYXeJQnz.d.ts.map +1 -1
- package/dist/{copy-menu-BXUh52bu.js → copy-menu-DOg9Jh-U.js} +2 -2
- package/dist/{copy-menu-BXUh52bu.js.map → copy-menu-DOg9Jh-U.js.map} +1 -1
- package/dist/hooks/use-focus-trap.d.ts +22 -0
- package/dist/hooks/use-focus-trap.d.ts.map +1 -0
- package/dist/hooks/use-focus-trap.js +80 -0
- package/dist/hooks/use-focus-trap.js.map +1 -0
- package/dist/hooks/use-highlighted-code.d.ts +5 -0
- package/dist/hooks/use-highlighted-code.d.ts.map +1 -0
- package/dist/hooks/use-highlighted-code.js +128 -0
- package/dist/hooks/use-highlighted-code.js.map +1 -0
- package/dist/hooks/use-listbox.d.ts +29 -0
- package/dist/hooks/use-listbox.d.ts.map +1 -0
- package/dist/hooks/use-listbox.js +75 -0
- package/dist/hooks/use-listbox.js.map +1 -0
- package/dist/tooltip-C01qUgsW.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/cascader-types-DVT-znZ-.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ScrollArea } from "../../ui/scroll-area.js";
|
|
3
3
|
import { useCascaderActions, useCascaderState } from "./cascader-context.js";
|
|
4
|
-
import { CASCADER_LIST_HEIGHT_CLASS, CASCADER_LIST_PAD_CLASS, CASCADER_ROWS_CLASS, CASCADER_SCROLL_CLASS, warnCascaderOnce } from "./cascader-lib.js";
|
|
4
|
+
import { CASCADER_LIST_HEIGHT_CLASS, CASCADER_LIST_PAD_CLASS, CASCADER_ROWS_CLASS, CASCADER_SCROLL_CLASS, focusCascaderHome, warnCascaderOnce } from "./cascader-lib.js";
|
|
5
5
|
import { CascaderItem, getCascaderMoreProps } from "./cascader-item.js";
|
|
6
6
|
import * as React$1 from "react";
|
|
7
7
|
import { cn } from "@kumix/utils";
|
|
@@ -59,7 +59,10 @@ function CascaderColumnPanel({ column, children, virtualized }) {
|
|
|
59
59
|
/* @__PURE__ */ jsx("button", {
|
|
60
60
|
type: "button",
|
|
61
61
|
"data-slot": "cascader-retry",
|
|
62
|
-
onClick: () =>
|
|
62
|
+
onClick: (event) => {
|
|
63
|
+
focusCascaderHome(event.currentTarget);
|
|
64
|
+
retryLevel(columnKey);
|
|
65
|
+
},
|
|
63
66
|
className: "rounded-md px-1 font-medium text-foreground outline-hidden transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50",
|
|
64
67
|
children: labels.retry
|
|
65
68
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascader-columns.js","names":["React","ComboboxPrimitive"],"sources":["../../../../src/components/reui/cascader/cascader-columns.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react\";\nimport { LoaderCircleIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { ScrollArea } from \"../../ui/scroll-area\";\nimport type { CascaderColumn } from \"./cascader-context\";\nimport { useCascaderActions, useCascaderState } from \"./cascader-context\";\nimport { CascaderItem, getCascaderMoreProps } from \"./cascader-item\";\nimport {\n CASCADER_LIST_HEIGHT_CLASS,\n CASCADER_LIST_PAD_CLASS,\n CASCADER_ROOT_KEY,\n CASCADER_ROWS_CLASS,\n CASCADER_SCROLL_CLASS,\n warnCascaderOnce,\n} from \"./cascader-lib\";\n\nexport interface CascaderColumnsProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n /** Width of each column. */\n columnWidth?: number | string;\n /** Height CAP per column. Falls back to the root `maxHeight`, then 24rem. */\n maxHeight?: number | string;\n /** Replaces the default panel; the seam a windowed column plugs into. */\n children?: (column: CascaderColumn) => React.ReactNode;\n}\n\n/**\n * Miller columns: the open trail side by side, one panel per level. Only the\n * DEEPEST column is a real listbox (Base UI owns exactly one list); the trail\n * behind is plain buttons, which keeps one state machine instead of a second,\n * 2D one. `CascaderInput` moves between columns with ArrowLeft/ArrowRight.\n */\nfunction CascaderColumns({\n className,\n columnWidth = 220,\n maxHeight: maxHeightProp,\n children,\n ...props\n}: CascaderColumnsProps) {\n const { maxHeight, mode, labels } = useCascaderActions();\n const { columns } = useCascaderState();\n\n // Before the early return, so the hook count is the same in both modes.\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n if (mode === \"columns\") return;\n warnCascaderOnce(\n `columns-outside-columns-mode:${mode}`,\n `\\`CascaderColumns\\` renders nothing in \\`mode=\"${mode}\"\\`, so \\`columnWidth\\` and everything else on it does nothing. Set \\`mode=\"columns\"\\` on the root, or render \\`CascaderList\\` instead.`,\n );\n }, [mode]);\n\n if (mode !== \"columns\") return null;\n\n const height = maxHeightProp ?? maxHeight;\n const toCss = (value: number | string) => (typeof value === \"number\" ? `${value}px` : value);\n\n return (\n <div\n data-slot=\"cascader-columns\"\n role=\"group\"\n aria-label={labels.columnsLabel}\n style={\n {\n \"--cascader-column-width\": toCss(columnWidth),\n /* Set only from an EXPLICIT cap: unset means \"24rem or what the\n viewport leaves\", via the `min()` fallback on the panel. A `?? 280`\n default here ignored short viewports and wasted tall ones. */\n ...(height != null ? { \"--cascader-max-height\": toCss(height) } : null),\n } as React.CSSProperties\n }\n className={cn(\n /* `max-h-full` with `min-h-0`: the trail is the panel's shrinking\n child, and the columns inside it size against this box. */\n \"flex max-h-full min-h-0 items-stretch overflow-x-auto overscroll-x-contain\",\n CASCADER_LIST_PAD_CLASS,\n className,\n )}\n {...props}\n >\n {columns.map((column) =>\n children ? (\n <React.Fragment key={column.depth}>{children(column)}</React.Fragment>\n ) : (\n <CascaderColumnPanel key={column.depth} column={column} />\n ),\n )}\n </div>\n );\n}\n\n/**\n * One column's box. `columnWidth` is the width of the LIST, not the box: under\n * `border-box` the 1px inline-start divider on every column but the first would\n * come out of the rows, so bordered columns are widened by that pixel. The box\n * is also the BOUND, the same `min(--available-height, cap)` the single list\n * uses, and the `ScrollArea` inside scrolls, so every column shows a thumb.\n */\nconst PANEL_CLASS = `flex w-(--cascader-column-width) shrink-0 flex-col overscroll-contain not-first:w-[calc(var(--cascader-column-width)_+_1px)] not-first:border-border/60 not-first:border-s ${CASCADER_LIST_HEIGHT_CLASS}`;\n\nexport interface CascaderColumnPanelProps {\n column: CascaderColumn;\n /** Replaces the panel's rows; the empty state still wins on an empty column. */\n children?: React.ReactNode;\n /** Containing block for the windowed column's absolutely positioned rows. */\n virtualized?: boolean;\n}\n\nfunction CascaderColumnPanel({ column, children, virtualized }: CascaderColumnPanelProps) {\n const {\n labels,\n baseId,\n isBranch,\n isSelectable,\n isSelected,\n isIndeterminate,\n retryLevel,\n searchScope,\n } = useCascaderActions();\n const { loadStates, deepResults } = useCascaderState();\n\n // Keyed per level, not one global flag: columns load and land independently.\n const columnKey = column.parent?.value ?? CASCADER_ROOT_KEY;\n const loadState = loadStates.get(columnKey);\n\n let emptyBody: React.ReactNode = labels.empty;\n if (loadState?.error) {\n emptyBody = (\n <>\n {labels.error}{\" \"}\n <button\n type=\"button\"\n data-slot=\"cascader-retry\"\n onClick={() => retryLevel(columnKey)}\n className=\"rounded-md px-1 font-medium text-foreground outline-hidden transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50\"\n >\n {labels.retry}\n </button>\n </>\n );\n } else if (loadState?.loading) {\n emptyBody = (\n <span className=\"flex items-center gap-1.5\">\n <LoaderCircleIcon className=\"size-3.5 animate-spin\" aria-hidden />\n {labels.loading}\n </span>\n );\n }\n\n const rows =\n column.items.length === 0 ? (\n <p\n data-slot=\"cascader-column-empty\"\n data-state={loadState?.error ? \"error\" : loadState?.loading ? \"loading\" : \"empty\"}\n className=\"px-2 py-1.5 text-muted-foreground text-sm\"\n >\n {emptyBody}\n </p>\n ) : (\n (children ??\n column.items.map((node, i) => {\n const open = node.value === column.activeValue;\n return (\n <CascaderItem\n key={node.value}\n node={node}\n /* A trail row must not compete for `aria-activedescendant`. */\n as={column.active ? \"option\" : \"button\"}\n depth={column.depth}\n /* Answered here, not in the row: the trail rows are memoised too. */\n branch={isBranch(node)}\n selectable={isSelectable(node)}\n selected={isSelected(node)}\n indeterminate={isIndeterminate(node)}\n {...getCascaderMoreProps(node, loadStates)}\n data-open={open || undefined}\n className={open ? \"bg-accent/60 text-accent-foreground\" : undefined}\n /* Set metadata is option-only; a trail row is a `role=\"button\"`. */\n {...(column.active\n ? {\n \"aria-setsize\": column.items.length,\n \"aria-posinset\": i + 1,\n }\n : null)}\n {...(!column.active && open\n ? {\n \"aria-expanded\": true,\n \"aria-controls\": `${baseId}-column-${column.depth + 1}`,\n }\n : null)}\n />\n );\n }))\n );\n\n const shared = {\n \"data-slot\": \"cascader-column\",\n \"data-active\": column.active || undefined,\n \"data-depth\": column.depth,\n // Addressable so the opening trail row can point `aria-controls` here, and\n // named even at the root, which has no parent label to borrow.\n id: `${baseId}-column-${column.depth}`,\n // Global hits come from the whole tree, so the parent would understate them.\n \"aria-label\":\n column.active && searchScope === \"global\" && deepResults\n ? labels.rootLevel\n : (column.parent?.label ?? labels.rootLevel),\n // Conditional spread, never an explicit `undefined`: the active column is a\n // Base UI element, and its `mergeProps` iterates own keys.\n ...(virtualized ? { \"data-virtualized\": true } : null),\n };\n\n // A windowed row is absolutely positioned, so the ROWS' box is the containing\n // block, not the scrollport: it carries the padding the geometry is measured\n // against.\n const rowsClass = cn(CASCADER_ROWS_CLASS, virtualized && \"relative\");\n\n // The active column IS the Combobox list: only rows inside `Combobox.List`\n // reach the CompositeList, arrow-key navigation and `aria-activedescendant`.\n const body = column.active ? (\n <ComboboxPrimitive.List {...shared} className={rowsClass}>\n {rows}\n </ComboboxPrimitive.List>\n ) : (\n // A named `group`, not a second listbox competing with the active column.\n <div {...shared} role=\"group\" className={rowsClass}>\n {rows}\n </div>\n );\n\n return (\n <div\n data-slot=\"cascader-column-bounds\"\n /* Repeated from `shared`: this box, not the semantic element, owns the\n width, the divider and the height, so style hooks must reach it, and\n `:first-child` on the semantic element no longer means \"first column\"\n (it is its own scrollport's only child). */\n data-active={column.active || undefined}\n data-depth={column.depth}\n className={PANEL_CLASS}\n >\n <ScrollArea className={CASCADER_SCROLL_CLASS}>{body}</ScrollArea>\n </div>\n );\n}\n\nexport { CascaderColumnPanel, CascaderColumns };\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,SAAS,gBAAgB,EACvB,WACA,cAAc,KACd,WAAW,eACX,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EAAwB,GAAI;EAAQ,WAAW;EAC5C,UAAA;CACqB,CAAA,IAGxB,oBAAC,OAAD;EAAK,GAAI;EAAQ,MAAK;EAAQ,WAAW;EACtC,UAAA;CACE,CAAA;CAGP,OACE,oBAAC,OAAD;EACE,aAAU;EAKV,eAAa,OAAO,UAAU,KAAA;EAC9B,cAAY,OAAO;EACnB,WAAW;EAEX,UAAA,oBAAC,YAAD;GAAY,WAAW;GAAwB,UAAA;EAAiB,CAAA;CAC7D,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"cascader-columns.js","names":["React","ComboboxPrimitive"],"sources":["../../../../src/components/reui/cascader/cascader-columns.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react\";\nimport { LoaderCircleIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { ScrollArea } from \"../../ui/scroll-area\";\nimport type { CascaderColumn } from \"./cascader-context\";\nimport { useCascaderActions, useCascaderState } from \"./cascader-context\";\nimport { CascaderItem, getCascaderMoreProps } from \"./cascader-item\";\nimport {\n CASCADER_LIST_HEIGHT_CLASS,\n CASCADER_LIST_PAD_CLASS,\n CASCADER_ROOT_KEY,\n CASCADER_ROWS_CLASS,\n CASCADER_SCROLL_CLASS,\n focusCascaderHome,\n warnCascaderOnce,\n} from \"./cascader-lib\";\n\nexport interface CascaderColumnsProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n /** Width of each column. */\n columnWidth?: number | string;\n /** Height CAP per column. Falls back to the root `maxHeight`, then 24rem. */\n maxHeight?: number | string;\n /** Replaces the default panel; the seam a windowed column plugs into. */\n children?: (column: CascaderColumn) => React.ReactNode;\n}\n\n/**\n * Miller columns: the open trail side by side, one panel per level. Only the\n * DEEPEST column is a real listbox (Base UI owns exactly one list); the trail\n * behind is plain buttons, which keeps one state machine instead of a second,\n * 2D one. `CascaderInput` moves between columns with ArrowLeft/ArrowRight.\n */\nfunction CascaderColumns({\n className,\n columnWidth = 220,\n maxHeight: maxHeightProp,\n children,\n ...props\n}: CascaderColumnsProps) {\n const { maxHeight, mode, labels } = useCascaderActions();\n const { columns } = useCascaderState();\n\n // Before the early return, so the hook count is the same in both modes.\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n if (mode === \"columns\") return;\n warnCascaderOnce(\n `columns-outside-columns-mode:${mode}`,\n `\\`CascaderColumns\\` renders nothing in \\`mode=\"${mode}\"\\`, so \\`columnWidth\\` and everything else on it does nothing. Set \\`mode=\"columns\"\\` on the root, or render \\`CascaderList\\` instead.`,\n );\n }, [mode]);\n\n if (mode !== \"columns\") return null;\n\n const height = maxHeightProp ?? maxHeight;\n const toCss = (value: number | string) => (typeof value === \"number\" ? `${value}px` : value);\n\n return (\n <div\n data-slot=\"cascader-columns\"\n role=\"group\"\n aria-label={labels.columnsLabel}\n style={\n {\n \"--cascader-column-width\": toCss(columnWidth),\n /* Set only from an EXPLICIT cap: unset means \"24rem or what the\n viewport leaves\", via the `min()` fallback on the panel. A `?? 280`\n default here ignored short viewports and wasted tall ones. */\n ...(height != null ? { \"--cascader-max-height\": toCss(height) } : null),\n } as React.CSSProperties\n }\n className={cn(\n /* `max-h-full` with `min-h-0`: the trail is the panel's shrinking\n child, and the columns inside it size against this box. */\n \"flex max-h-full min-h-0 items-stretch overflow-x-auto overscroll-x-contain\",\n CASCADER_LIST_PAD_CLASS,\n className,\n )}\n {...props}\n >\n {columns.map((column) =>\n children ? (\n <React.Fragment key={column.depth}>{children(column)}</React.Fragment>\n ) : (\n <CascaderColumnPanel key={column.depth} column={column} />\n ),\n )}\n </div>\n );\n}\n\n/**\n * One column's box. `columnWidth` is the width of the LIST, not the box: under\n * `border-box` the 1px inline-start divider on every column but the first would\n * come out of the rows, so bordered columns are widened by that pixel. The box\n * is also the BOUND, the same `min(--available-height, cap)` the single list\n * uses, and the `ScrollArea` inside scrolls, so every column shows a thumb.\n */\nconst PANEL_CLASS = `flex w-(--cascader-column-width) shrink-0 flex-col overscroll-contain not-first:w-[calc(var(--cascader-column-width)_+_1px)] not-first:border-border/60 not-first:border-s ${CASCADER_LIST_HEIGHT_CLASS}`;\n\nexport interface CascaderColumnPanelProps {\n column: CascaderColumn;\n /** Replaces the panel's rows; the empty state still wins on an empty column. */\n children?: React.ReactNode;\n /** Containing block for the windowed column's absolutely positioned rows. */\n virtualized?: boolean;\n}\n\nfunction CascaderColumnPanel({ column, children, virtualized }: CascaderColumnPanelProps) {\n const {\n labels,\n baseId,\n isBranch,\n isSelectable,\n isSelected,\n isIndeterminate,\n retryLevel,\n searchScope,\n } = useCascaderActions();\n const { loadStates, deepResults } = useCascaderState();\n\n // Keyed per level, not one global flag: columns load and land independently.\n const columnKey = column.parent?.value ?? CASCADER_ROOT_KEY;\n const loadState = loadStates.get(columnKey);\n\n let emptyBody: React.ReactNode = labels.empty;\n if (loadState?.error) {\n emptyBody = (\n <>\n {labels.error}{\" \"}\n <button\n type=\"button\"\n data-slot=\"cascader-retry\"\n onClick={(event) => {\n // Same hand-off as the panel's Retry: a trail column, or an\n // inline one, can hold focus, and the loading state unmounts this.\n focusCascaderHome(event.currentTarget);\n retryLevel(columnKey);\n }}\n className=\"rounded-md px-1 font-medium text-foreground outline-hidden transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50\"\n >\n {labels.retry}\n </button>\n </>\n );\n } else if (loadState?.loading) {\n emptyBody = (\n <span className=\"flex items-center gap-1.5\">\n <LoaderCircleIcon className=\"size-3.5 animate-spin\" aria-hidden />\n {labels.loading}\n </span>\n );\n }\n\n const rows =\n column.items.length === 0 ? (\n <p\n data-slot=\"cascader-column-empty\"\n data-state={loadState?.error ? \"error\" : loadState?.loading ? \"loading\" : \"empty\"}\n className=\"px-2 py-1.5 text-muted-foreground text-sm\"\n >\n {emptyBody}\n </p>\n ) : (\n (children ??\n column.items.map((node, i) => {\n const open = node.value === column.activeValue;\n return (\n <CascaderItem\n key={node.value}\n node={node}\n /* A trail row must not compete for `aria-activedescendant`. */\n as={column.active ? \"option\" : \"button\"}\n depth={column.depth}\n /* Answered here, not in the row: the trail rows are memoised too. */\n branch={isBranch(node)}\n selectable={isSelectable(node)}\n selected={isSelected(node)}\n indeterminate={isIndeterminate(node)}\n {...getCascaderMoreProps(node, loadStates)}\n data-open={open || undefined}\n className={open ? \"bg-accent/60 text-accent-foreground\" : undefined}\n /* Set metadata is option-only; a trail row is a `role=\"button\"`. */\n {...(column.active\n ? {\n \"aria-setsize\": column.items.length,\n \"aria-posinset\": i + 1,\n }\n : null)}\n {...(!column.active && open\n ? {\n \"aria-expanded\": true,\n \"aria-controls\": `${baseId}-column-${column.depth + 1}`,\n }\n : null)}\n />\n );\n }))\n );\n\n const shared = {\n \"data-slot\": \"cascader-column\",\n \"data-active\": column.active || undefined,\n \"data-depth\": column.depth,\n // Addressable so the opening trail row can point `aria-controls` here, and\n // named even at the root, which has no parent label to borrow.\n id: `${baseId}-column-${column.depth}`,\n // Global hits come from the whole tree, so the parent would understate them.\n \"aria-label\":\n column.active && searchScope === \"global\" && deepResults\n ? labels.rootLevel\n : (column.parent?.label ?? labels.rootLevel),\n // Conditional spread, never an explicit `undefined`: the active column is a\n // Base UI element, and its `mergeProps` iterates own keys.\n ...(virtualized ? { \"data-virtualized\": true } : null),\n };\n\n // A windowed row is absolutely positioned, so the ROWS' box is the containing\n // block, not the scrollport: it carries the padding the geometry is measured\n // against.\n const rowsClass = cn(CASCADER_ROWS_CLASS, virtualized && \"relative\");\n\n // The active column IS the Combobox list: only rows inside `Combobox.List`\n // reach the CompositeList, arrow-key navigation and `aria-activedescendant`.\n const body = column.active ? (\n <ComboboxPrimitive.List {...shared} className={rowsClass}>\n {rows}\n </ComboboxPrimitive.List>\n ) : (\n // A named `group`, not a second listbox competing with the active column.\n <div {...shared} role=\"group\" className={rowsClass}>\n {rows}\n </div>\n );\n\n return (\n <div\n data-slot=\"cascader-column-bounds\"\n /* Repeated from `shared`: this box, not the semantic element, owns the\n width, the divider and the height, so style hooks must reach it, and\n `:first-child` on the semantic element no longer means \"first column\"\n (it is its own scrollport's only child). */\n data-active={column.active || undefined}\n data-depth={column.depth}\n className={PANEL_CLASS}\n >\n <ScrollArea className={CASCADER_SCROLL_CLASS}>{body}</ScrollArea>\n </div>\n );\n}\n\nexport { CascaderColumnPanel, CascaderColumns };\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,SAAS,gBAAgB,EACvB,WACA,cAAc,KACd,WAAW,eACX,UACA,GAAG,SACoB;CACvB,MAAM,EAAE,WAAW,MAAM,WAAW,mBAAmB;CACvD,MAAM,EAAE,YAAY,iBAAiB;CAGrC,QAAM,gBAAgB;EACpB,IAAI,QAAQ,IAAI,aAAa,cAAc;EAC3C,IAAI,SAAS,WAAW;EACxB,iBACE,gCAAgC,QAChC,kDAAkD,KAAK,wIACzD;CACF,GAAG,CAAC,IAAI,CAAC;CAET,IAAI,SAAS,WAAW,OAAO;CAE/B,MAAM,SAAS,iBAAiB;CAChC,MAAM,SAAS,UAA4B,OAAO,UAAU,WAAW,GAAG,MAAM,MAAM;CAEtF,OACE,oBAAC,OAAD;EACE,aAAU;EACV,MAAK;EACL,cAAY,OAAO;EACnB,OACE;GACE,2BAA2B,MAAM,WAAW;GAI5C,GAAI,UAAU,OAAO,EAAE,yBAAyB,MAAM,MAAM,EAAE,IAAI;EACpE;EAEF,WAAW,GAGT,8EACA,yBACA,SACF;EACA,GAAI;EAEH,UAAA,QAAQ,KAAK,WACZ,WACE,oBAACA,QAAM,UAAP,EAAA,UAAoC,SAAS,MAAM,EAAkB,GAAhD,OAAO,KAAyC,IAErE,oBAAC,qBAAD,EAAgD,OAAS,GAA/B,OAAO,KAAwB,CAE7D;CACG,CAAA;AAET;;;;;;;;AASA,MAAM,cAAc,8KAA8K;AAUlM,SAAS,oBAAoB,EAAE,QAAQ,UAAU,eAAyC;CACxF,MAAM,EACJ,QACA,QACA,UACA,cACA,YACA,iBACA,YACA,gBACE,mBAAmB;CACvB,MAAM,EAAE,Y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AAM,SAAS;EACb,aAAa;EACb,eAAe,OAAO,UAAU,KAAA;EAChC,cAAc,OAAO;EAGrB,IAAI,GAAG,OAAO,UAAU,OAAO;EAE/B,cACE,OAAO,UAAU,gBAAgB,YAAY,cACzC,OAAO,YACN,OAAO,QAAQ,SAAS,OAAO;EAGtC,GAAI,cAAc,EAAE,oBAAoB,KAAK,IAAI;CACnD;CAKA,MAAM,YAAY,GAAG,qBAAqB,eAAe,UAAU;CAInE,MAAM,OAAO,OAAO,SAClB,oBAACC,SAAkB,MAAnB;EAAwB,GAAI;EAAQ,WAAW;EAC5C,UAAA;CACqB,CAAA,IAGxB,oBAAC,OAAD;EAAK,GAAI;EAAQ,MAAK;EAAQ,WAAW;EACtC,UAAA;CACE,CAAA;CAGP,OACE,oBAAC,OAAD;EACE,aAAU;EAKV,eAAa,OAAO,UAAU,KAAA;EAC9B,cAAY,OAAO;EACnB,WAAW;EAEX,UAAA,oBAAC,YAAD;GAAY,WAAW;GAAwB,UAAA;EAAiB,CAAA;CAC7D,CAAA;AAET"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as CascaderFlatNode, d as CascaderLoadState, f as CascaderMode, g as CascaderSearchScope, o as CascaderIndex, p as CascaderNode, r as CascaderChangeReason, s as CascaderLabels, t as CascaderActionItem } from "../../../cascader-types-
|
|
1
|
+
import { a as CascaderFlatNode, d as CascaderLoadState, f as CascaderMode, g as CascaderSearchScope, o as CascaderIndex, p as CascaderNode, r as CascaderChangeReason, s as CascaderLabels, t as CascaderActionItem } from "../../../cascader-types-zhnUQ4sP.js";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
//#region src/components/reui/cascader/cascader-context.d.ts
|
|
4
4
|
/**
|
|
@@ -110,6 +110,8 @@ export interface CascaderActionsContextValue<T = unknown> {
|
|
|
110
110
|
/** Next page of a level. Latched: a page with nothing new is not re-asked. */
|
|
111
111
|
loadMore: (parentKey: string) => void;
|
|
112
112
|
retryLevel: (parentKey: string) => void;
|
|
113
|
+
/** Re-runs a failed server search (`onSearch`) for the current query. */
|
|
114
|
+
retrySearch: () => void;
|
|
113
115
|
/**
|
|
114
116
|
* Evicts one level's async cache, `null` for the root, so membership reads
|
|
115
117
|
* never-loaded. A level that is on screen when evicted refetches at once.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascader-context.d.ts","names":["React"],"sources":["../../../../src/components/reui/cascader/cascader-context.tsx"],"mappings":";;;;;;;;;iBA2BiB,eAAe;EAC9B,QAAQ,aAAa;EACrB,OAAO,aAAa;EACpB;;EAEA;;EAEA;;iBAGe,kBAAkB;EACjC;EACA;;EAEA;EACA;EACA;;EAEA,MAAM,aAAa;;;;;;iBAWJ,0BAA0B;;EAEzC,OAAO,cAAc;EACrB;EACA,UAAU;EACV;EACA,eAAe,aAAa;;EAE5B,YAAY,aAAa;EACzB,aAAa,aAAa;;EAE1B,eAAe,aAAa;EAC5B,SAAS,eAAe;EACxB,UAAU,iBAAiB;EAC3B;;EAEA,qBAAqB;;;;;;EAMrB,YAAY,oBAAoB;;EAEhC,aAAa;EACb;;cAGI,sBAAoBA,QAAA,QAAA;;;;;wBAMV,iBAAiB,gBAAgB,0BAA0B;;;;;;;iBAkB1D,4BAA4B;EAC3C,OAAO,cAAc;EACrB,MAAM;EACN;;EAEA;;EAEA;;EAEA;EACA;EACA,SAAS;EACT,aAAa;EACb;EACA;EACA;;;;;;EAMA;EACA,QAAQ;;;;;;EAOR;;EAEA;;EAEA;EACA;EACA;EACA;;EAGA;;EAEA,WAAW;EACX,aAAa;;;;;
|
|
1
|
+
{"version":3,"file":"cascader-context.d.ts","names":["React"],"sources":["../../../../src/components/reui/cascader/cascader-context.tsx"],"mappings":";;;;;;;;;iBA2BiB,eAAe;EAC9B,QAAQ,aAAa;EACrB,OAAO,aAAa;EACpB;;EAEA;;EAEA;;iBAGe,kBAAkB;EACjC;EACA;;EAEA;EACA;EACA;;EAEA,MAAM,aAAa;;;;;;iBAWJ,0BAA0B;;EA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QAAM;;cAGxE,uBAAqBA,QAAA,QAAA;wBAEX,kBAAkB,gBAAgB,2BAA2B;iBAQ5D;EACf;EACA;;;;;;;;iBASe;EACf,YAAY;EACZ,mBAAmB;EACnB,MAAM,MAAM;;wBAKE,gCAAgC;cA0B1C,0BAAwBA,QAAA,QAAA;;wBAId,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascader-context.js","names":["React"],"sources":["../../../../src/components/reui/cascader/cascader-context.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport type {\n CascaderActionItem,\n CascaderChangeReason,\n CascaderFlatNode,\n CascaderIndex,\n CascaderLabels,\n CascaderLoadState,\n CascaderMode,\n CascaderNode,\n CascaderSearchScope,\n} from \"./cascader-types\";\n\n/**\n * Four contexts, not one: actions (config and callbacks, near-stable), state\n * (every keystroke), render (`renderItem` identity) and highlight (every arrow\n * key and pointer move). One combined context re-rendered every row on every\n * keystroke, which is what made `React.memo` on the row worth nothing.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Shared types */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderColumn<T = unknown> {\n parent: CascaderNode<T> | null;\n items: CascaderNode<T>[];\n depth: number;\n /** The node in this column that is drilled into, if any. */\n activeValue: string | null;\n /** Whether this is the deepest column, the one Base UI owns. */\n active: boolean;\n}\n\nexport interface CascaderItemState<T = unknown> {\n branch: boolean;\n selected: boolean;\n /** The node's own flag or a disabled ancestor's, as `isCascaderDisabled`. */\n disabled: boolean;\n depth: number;\n count: number;\n /** Ancestor chain, root first. Populated for deep and global search rows. */\n path: CascaderNode<T>[];\n}\n\n/* -------------------------------------------------------------------------- */\n/* State */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Everything derived from the query, the path and the selection. One keystroke\n * rebuilds most of it, so never subscribe to it from a row.\n */\nexport interface CascaderStateContextValue<T = unknown> {\n /** Same `useMemo` identity as the actions context's `index`. */\n index: CascaderIndex<T>;\n path: string[];\n expanded: ReadonlySet<string>;\n query: string;\n currentParent: CascaderNode<T> | null;\n /** Rows for the current level, already filtered. */\n levelItems: CascaderNode<T>[];\n deepResults: CascaderNode<T>[] | null;\n /** What `Combobox.Root` is currently rendering, in render order. */\n renderedItems: CascaderNode<T>[];\n columns: CascaderColumn<T>[];\n treeRows: CascaderFlatNode<T>[];\n selectedValues: string[];\n /** Selected nodes below each value, at any depth. Absent means zero. */\n selectedDescendants: ReadonlyMap<string, number>;\n /**\n * Per level, keyed by parent value or `CASCADER_ROOT_KEY`. MEMBERSHIP is the\n * discriminator: no entry means never fetched, an entry with no `loading`, no\n * `error` and no children means fetched and genuinely empty.\n */\n loadStates: ReadonlyMap<string, CascaderLoadState>;\n /** Async search, `null` when idle. Separate: a search belongs to no level. */\n searchState: CascaderLoadState | null;\n announcement: string;\n}\n\nconst CascaderStateContext = React.createContext<CascaderStateContextValue | undefined>(undefined);\n\n/**\n * One provider serves every `T`, so the context holds an erased `unknown` value\n * and this cast restores it. The primitive never inspects the payload.\n */\nexport function useCascaderState<T = unknown>(): CascaderStateContextValue<T> {\n const context = React.useContext(CascaderStateContext);\n if (!context) {\n throw new Error(\"useCascaderState must be used within a Cascader\");\n }\n return context as unknown as CascaderStateContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Actions */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Config and callbacks, slow enough that a memoised row can subscribe: the\n * mutators are `[]`-dep callbacks over a latest-props ref. The predicates are\n * the exception, read DURING RENDER where a ref written in an effect would\n * return the previous commit's answer, so each is memoised on its own input.\n */\nexport interface CascaderActionsContextValue<T = unknown> {\n index: CascaderIndex<T>;\n mode: CascaderMode;\n multiple: boolean;\n /** Multi-select only: a commit propagates over the LOADED subtree. */\n cascade: boolean;\n /** Whether a BRANCH is committable. Per-LIST: the check gutter is a COLUMN. */\n branchesSelectable: boolean;\n /** Draws the SINGLE-SELECT check and its gutter. Ignored in multi-select. */\n indicator: boolean;\n expandTrigger?: \"click\" | \"hover\";\n actions: CascaderActionItem[];\n searchScope: CascaderSearchScope;\n maxHeight?: number | string;\n inline: boolean;\n invalid: boolean;\n /**\n * Id prefix; columns are `${baseId}-column-${depth}`. The SCHEME is contract:\n * the filters primitive's `FilterMenuPinKeeper` restores its highlight across\n * a live re-pin through `${baseId}-column-0` and the `cascader-item` slot.\n */\n baseId: string;\n labels: CascaderLabels;\n\n /**\n * Whether rows are WINDOWED. Also handed to `Combobox.Root`, which is what\n * makes an explicit row `index` legal: forwarding one while this is false\n * makes `aria-activedescendant` resolve to nothing. Latched per level.\n */\n virtualized: boolean;\n /** Mounts a windowing renderer, returns its unregister. LAYOUT effect only. */\n registerVirtualRenderer: () => () => void;\n /** The root's `virtualize` prop. `undefined` means \"decide by count\". */\n virtualize?: boolean;\n virtualizeThreshold: number;\n estimateRowSize: number;\n overscan: number;\n\n /** Tells \"this level is empty\" from \"not fetched yet\" before a load state. */\n hasLoader: boolean;\n /** Next page of a level. Latched: a page with nothing new is not re-asked. */\n loadMore: (parentKey: string) => void;\n retryLevel: (parentKey: string) => void;\n /**\n * Evicts one level's async cache, `null` for the root, so membership reads\n * never-loaded. A level that is on screen when evicted refetches at once.\n */\n invalidateLevel: (value: string | null) => void;\n\n /** Index as of the last commit. Use in the stable callbacks, not `index`. */\n getIndex: () => CascaderIndex<T>;\n getState: () => CascaderStateContextValue<T>;\n /** Highlighted row or null. A getter: the highlight moves per arrow key. */\n getHighlighted: () => CascaderNode<T> | null;\n\n setPath: (next: string[] | ((prev: string[]) => string[])) => void;\n pushLevel: (value: string) => void;\n popLevel: () => void;\n goToDepth: (depth: number) => void;\n toggleExpanded: (value: string) => void;\n /**\n * Registers a footer submenu as open or closed. `Combobox` has no\n * `FloatingTree`, so one Escape would dismiss the flyout AND the cascader;\n * the root's `onOpenChange` guard cancels the close while any is open, from a\n * ref so it reads as of that event without re-rendering the root.\n */\n setFlyoutOpen: (key: string, open: boolean) => void;\n hasOpenFlyout: () => boolean;\n setQuery: (next: string) => void;\n /**\n * Replaces the selection. `onValueChange` diffs it against the current one\n * for its node and reason; pass `reason` only when the caller knows better.\n */\n setSelection: (values: string[], reason?: CascaderChangeReason) => void;\n /** Commits a node, for rows outside the listbox such as ancestor columns. */\n commit: (node: CascaderNode<T>) => void;\n navigate: (node: CascaderNode<T>) => void;\n /** Into `node` as a child of `depth`, replacing anything deeper. */\n navigateAt: (node: CascaderNode<T>, depth: number) => void;\n /** Never undefined: falls back to a remembered label, then a synthetic node. */\n resolveNode: (value: string) => CascaderNode<T>;\n isBranch: (node: CascaderNode<T>) => boolean;\n isSelectable: (node: CascaderNode<T>) => boolean;\n /**\n * The node or an ancestor is `disabled`. Rows render it disabled; row\n * presses, keys, `commit`, `navigate`, `navigateAt` and a held navigation\n * refuse it. `pushLevel`, `setPath`, `toggleExpanded` and `setSelection` are\n * raw setters and do not ask.\n */\n isDisabled: (node: CascaderNode<T>) => boolean;\n isSelected: (node: CascaderNode<T>) => boolean;\n /** Always `false` without `cascade`: partial selection needs propagation. */\n isIndeterminate: (node: CascaderNode<T>) => boolean;\n /**\n * O(1) read of `selectedDescendants`; a memoised row may not subscribe.\n * Unlike `isIndeterminate` this answers in every mode.\n */\n selectedDescendantCount: (node: CascaderNode<T>) => number;\n}\n\nconst CascaderActionsContext = React.createContext<CascaderActionsContextValue | undefined>(\n undefined,\n);\n\nexport function useCascaderActions<T = unknown>(): CascaderActionsContextValue<T> {\n const context = React.useContext(CascaderActionsContext);\n if (!context) {\n throw new Error(\"useCascaderActions must be used within a Cascader\");\n }\n return context as unknown as CascaderActionsContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Render props */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Their own context, republished every render. They cannot ride on the actions\n * context: an inline closure read off a memoised object is whichever closure\n * that object captured, so the row would call a stale prop over stale state.\n */\nexport interface CascaderRenderContextValue<T = unknown> {\n renderItem?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n renderLabel?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n}\n\nconst CascaderRenderContext = React.createContext<CascaderRenderContextValue>({});\n\nexport function useCascaderRender<T = unknown>(): CascaderRenderContextValue<T> {\n return React.useContext(CascaderRenderContext) as CascaderRenderContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Highlight store */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderHighlight {\n index: number;\n value: string | null;\n}\n\n/**\n * An external store, deliberately NOT React state: `onItemHighlighted` fires on\n * every arrow key AND every pointer move over the list, so `setState` would\n * re-render the whole root at mousemove rate. A store re-renders subscribers\n * only, which inside the primitive is the virtualizer.\n */\nexport interface CascaderHighlightStore {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => CascaderHighlight;\n set: (next: CascaderHighlight) => void;\n}\n\nconst NO_HIGHLIGHT: CascaderHighlight = { index: -1, value: null };\n\nexport function createCascaderHighlightStore(): CascaderHighlightStore {\n let snapshot: CascaderHighlight = NO_HIGHLIGHT;\n const listeners = new Set<() => void>();\n\n return {\n subscribe(onStoreChange) {\n listeners.add(onStoreChange);\n return () => {\n listeners.delete(onStoreChange);\n };\n },\n // The SAME object until something changes; `useSyncExternalStore` needs it.\n getSnapshot() {\n return snapshot;\n },\n set(next) {\n if (next.index === snapshot.index && next.value === snapshot.value) return;\n snapshot = next;\n for (const listener of listeners) listener();\n },\n };\n}\n\n/** Shared and permanently empty, so the hook degrades outside a `Cascader`. */\nconst FALLBACK_HIGHLIGHT_STORE = createCascaderHighlightStore();\n\nconst CascaderHighlightContext =\n React.createContext<CascaderHighlightStore>(FALLBACK_HIGHLIGHT_STORE);\n\n/** Subscribes to the highlight. Re-renders ONLY the calling component. */\nexport function useCascaderHighlight(): CascaderHighlight {\n const store = React.useContext(CascaderHighlightContext);\n return React.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n}\n\nexport {\n CascaderActionsContext,\n CascaderHighlightContext,\n CascaderRenderContext,\n CascaderStateContext,\n};\n"],"mappings":";;;AAoFA,MAAM,uBAAuBA,QAAM,cAAqD,KAAA,CAAS;;;;;AAMjG,SAAgB,mBAA8D;CAC5E,MAAM,UAAUA,QAAM,WAAW,oBAAoB;CACrD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,iDAAiD;CAEnE,OAAO;AACT;AAgHA,MAAM,yBAAyBA,QAAM,cACnC,KAAA,CACF;AAEA,SAAgB,qBAAkE;CAChF,MAAM,UAAUA,QAAM,WAAW,sBAAsB;CACvD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,mDAAmD;CAErE,OAAO;AACT;AAgBA,MAAM,wBAAwBA,QAAM,cAA0C,CAAC,CAAC;AAEhF,SAAgB,oBAAgE;CAC9E,OAAOA,QAAM,WAAW,qBAAqB;AAC/C;AAuBA,MAAM,eAAkC;CAAE,OAAO;CAAI,OAAO;AAAK;AAEjE,SAAgB,+BAAuD;CACrE,IAAI,WAA8B;CAClC,MAAM,4BAAY,IAAI,IAAgB;CAEtC,OAAO;EACL,UAAU,eAAe;GACvB,UAAU,IAAI,aAAa;GAC3B,aAAa;IACX,UAAU,OAAO,aAAa;GAChC;EACF;EAEA,cAAc;GACZ,OAAO;EACT;EACA,IAAI,MAAM;GACR,IAAI,KAAK,UAAU,SAAS,SAAS,KAAK,UAAU,SAAS,OAAO;GACpE,WAAW;GACX,KAAK,MAAM,YAAY,WAAW,SAAS;EAC7C;CACF;AACF;;AAGA,MAAM,2BAA2B,6BAA6B;AAE9D,MAAM,2BACJA,QAAM,cAAsC,wBAAwB;;AAGtE,SAAgB,uBAA0C;CACxD,MAAM,QAAQA,QAAM,WAAW,wBAAwB;CACvD,OAAOA,QAAM,qBAAqB,MAAM,WAAW,MAAM,aAAa,MAAM,WAAW;AACzF"}
|
|
1
|
+
{"version":3,"file":"cascader-context.js","names":["React"],"sources":["../../../../src/components/reui/cascader/cascader-context.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport type {\n CascaderActionItem,\n CascaderChangeReason,\n CascaderFlatNode,\n CascaderIndex,\n CascaderLabels,\n CascaderLoadState,\n CascaderMode,\n CascaderNode,\n CascaderSearchScope,\n} from \"./cascader-types\";\n\n/**\n * Four contexts, not one: actions (config and callbacks, near-stable), state\n * (every keystroke), render (`renderItem` identity) and highlight (every arrow\n * key and pointer move). One combined context re-rendered every row on every\n * keystroke, which is what made `React.memo` on the row worth nothing.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Shared types */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderColumn<T = unknown> {\n parent: CascaderNode<T> | null;\n items: CascaderNode<T>[];\n depth: number;\n /** The node in this column that is drilled into, if any. */\n activeValue: string | null;\n /** Whether this is the deepest column, the one Base UI owns. */\n active: boolean;\n}\n\nexport interface CascaderItemState<T = unknown> {\n branch: boolean;\n selected: boolean;\n /** The node's own flag or a disabled ancestor's, as `isCascaderDisabled`. */\n disabled: boolean;\n depth: number;\n count: number;\n /** Ancestor chain, root first. Populated for deep and global search rows. */\n path: CascaderNode<T>[];\n}\n\n/* -------------------------------------------------------------------------- */\n/* State */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Everything derived from the query, the path and the selection. One keystroke\n * rebuilds most of it, so never subscribe to it from a row.\n */\nexport interface CascaderStateContextValue<T = unknown> {\n /** Same `useMemo` identity as the actions context's `index`. */\n index: CascaderIndex<T>;\n path: string[];\n expanded: ReadonlySet<string>;\n query: string;\n currentParent: CascaderNode<T> | null;\n /** Rows for the current level, already filtered. */\n levelItems: CascaderNode<T>[];\n deepResults: CascaderNode<T>[] | null;\n /** What `Combobox.Root` is currently rendering, in render order. */\n renderedItems: CascaderNode<T>[];\n columns: CascaderColumn<T>[];\n treeRows: CascaderFlatNode<T>[];\n selectedValues: string[];\n /** Selected nodes below each value, at any depth. Absent means zero. */\n selectedDescendants: ReadonlyMap<string, number>;\n /**\n * Per level, keyed by parent value or `CASCADER_ROOT_KEY`. MEMBERSHIP is the\n * discriminator: no entry means never fetched, an entry with no `loading`, no\n * `error` and no children means fetched and genuinely empty.\n */\n loadStates: ReadonlyMap<string, CascaderLoadState>;\n /** Async search, `null` when idle. Separate: a search belongs to no level. */\n searchState: CascaderLoadState | null;\n announcement: string;\n}\n\nconst CascaderStateContext = React.createContext<CascaderStateContextValue | undefined>(undefined);\n\n/**\n * One provider serves every `T`, so the context holds an erased `unknown` value\n * and this cast restores it. The primitive never inspects the payload.\n */\nexport function useCascaderState<T = unknown>(): CascaderStateContextValue<T> {\n const context = React.useContext(CascaderStateContext);\n if (!context) {\n throw new Error(\"useCascaderState must be used within a Cascader\");\n }\n return context as unknown as CascaderStateContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Actions */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Config and callbacks, slow enough that a memoised row can subscribe: the\n * mutators are `[]`-dep callbacks over a latest-props ref. The predicates are\n * the exception, read DURING RENDER where a ref written in an effect would\n * return the previous commit's answer, so each is memoised on its own input.\n */\nexport interface CascaderActionsContextValue<T = unknown> {\n index: CascaderIndex<T>;\n mode: CascaderMode;\n multiple: boolean;\n /** Multi-select only: a commit propagates over the LOADED subtree. */\n cascade: boolean;\n /** Whether a BRANCH is committable. Per-LIST: the check gutter is a COLUMN. */\n branchesSelectable: boolean;\n /** Draws the SINGLE-SELECT check and its gutter. Ignored in multi-select. */\n indicator: boolean;\n expandTrigger?: \"click\" | \"hover\";\n actions: CascaderActionItem[];\n searchScope: CascaderSearchScope;\n maxHeight?: number | string;\n inline: boolean;\n invalid: boolean;\n /**\n * Id prefix; columns are `${baseId}-column-${depth}`. The SCHEME is contract:\n * the filters primitive's `FilterMenuPinKeeper` restores its highlight across\n * a live re-pin through `${baseId}-column-0` and the `cascader-item` slot.\n */\n baseId: string;\n labels: CascaderLabels;\n\n /**\n * Whether rows are WINDOWED. Also handed to `Combobox.Root`, which is what\n * makes an explicit row `index` legal: forwarding one while this is false\n * makes `aria-activedescendant` resolve to nothing. Latched per level.\n */\n virtualized: boolean;\n /** Mounts a windowing renderer, returns its unregister. LAYOUT effect only. */\n registerVirtualRenderer: () => () => void;\n /** The root's `virtualize` prop. `undefined` means \"decide by count\". */\n virtualize?: boolean;\n virtualizeThreshold: number;\n estimateRowSize: number;\n overscan: number;\n\n /** Tells \"this level is empty\" from \"not fetched yet\" before a load state. */\n hasLoader: boolean;\n /** Next page of a level. Latched: a page with nothing new is not re-asked. */\n loadMore: (parentKey: string) => void;\n retryLevel: (parentKey: string) => void;\n /** Re-runs a failed server search (`onSearch`) for the current query. */\n retrySearch: () => void;\n /**\n * Evicts one level's async cache, `null` for the root, so membership reads\n * never-loaded. A level that is on screen when evicted refetches at once.\n */\n invalidateLevel: (value: string | null) => void;\n\n /** Index as of the last commit. Use in the stable callbacks, not `index`. */\n getIndex: () => CascaderIndex<T>;\n getState: () => CascaderStateContextValue<T>;\n /** Highlighted row or null. A getter: the highlight moves per arrow key. */\n getHighlighted: () => CascaderNode<T> | null;\n\n setPath: (next: string[] | ((prev: string[]) => string[])) => void;\n pushLevel: (value: string) => void;\n popLevel: () => void;\n goToDepth: (depth: number) => void;\n toggleExpanded: (value: string) => void;\n /**\n * Registers a footer submenu as open or closed. `Combobox` has no\n * `FloatingTree`, so one Escape would dismiss the flyout AND the cascader;\n * the root's `onOpenChange` guard cancels the close while any is open, from a\n * ref so it reads as of that event without re-rendering the root.\n */\n setFlyoutOpen: (key: string, open: boolean) => void;\n hasOpenFlyout: () => boolean;\n setQuery: (next: string) => void;\n /**\n * Replaces the selection. `onValueChange` diffs it against the current one\n * for its node and reason; pass `reason` only when the caller knows better.\n */\n setSelection: (values: string[], reason?: CascaderChangeReason) => void;\n /** Commits a node, for rows outside the listbox such as ancestor columns. */\n commit: (node: CascaderNode<T>) => void;\n navigate: (node: CascaderNode<T>) => void;\n /** Into `node` as a child of `depth`, replacing anything deeper. */\n navigateAt: (node: CascaderNode<T>, depth: number) => void;\n /** Never undefined: falls back to a remembered label, then a synthetic node. */\n resolveNode: (value: string) => CascaderNode<T>;\n isBranch: (node: CascaderNode<T>) => boolean;\n isSelectable: (node: CascaderNode<T>) => boolean;\n /**\n * The node or an ancestor is `disabled`. Rows render it disabled; row\n * presses, keys, `commit`, `navigate`, `navigateAt` and a held navigation\n * refuse it. `pushLevel`, `setPath`, `toggleExpanded` and `setSelection` are\n * raw setters and do not ask.\n */\n isDisabled: (node: CascaderNode<T>) => boolean;\n isSelected: (node: CascaderNode<T>) => boolean;\n /** Always `false` without `cascade`: partial selection needs propagation. */\n isIndeterminate: (node: CascaderNode<T>) => boolean;\n /**\n * O(1) read of `selectedDescendants`; a memoised row may not subscribe.\n * Unlike `isIndeterminate` this answers in every mode.\n */\n selectedDescendantCount: (node: CascaderNode<T>) => number;\n}\n\nconst CascaderActionsContext = React.createContext<CascaderActionsContextValue | undefined>(\n undefined,\n);\n\nexport function useCascaderActions<T = unknown>(): CascaderActionsContextValue<T> {\n const context = React.useContext(CascaderActionsContext);\n if (!context) {\n throw new Error(\"useCascaderActions must be used within a Cascader\");\n }\n return context as unknown as CascaderActionsContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Render props */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Their own context, republished every render. They cannot ride on the actions\n * context: an inline closure read off a memoised object is whichever closure\n * that object captured, so the row would call a stale prop over stale state.\n */\nexport interface CascaderRenderContextValue<T = unknown> {\n renderItem?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n renderLabel?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React.ReactNode;\n}\n\nconst CascaderRenderContext = React.createContext<CascaderRenderContextValue>({});\n\nexport function useCascaderRender<T = unknown>(): CascaderRenderContextValue<T> {\n return React.useContext(CascaderRenderContext) as CascaderRenderContextValue<T>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Highlight store */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderHighlight {\n index: number;\n value: string | null;\n}\n\n/**\n * An external store, deliberately NOT React state: `onItemHighlighted` fires on\n * every arrow key AND every pointer move over the list, so `setState` would\n * re-render the whole root at mousemove rate. A store re-renders subscribers\n * only, which inside the primitive is the virtualizer.\n */\nexport interface CascaderHighlightStore {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => CascaderHighlight;\n set: (next: CascaderHighlight) => void;\n}\n\nconst NO_HIGHLIGHT: CascaderHighlight = { index: -1, value: null };\n\nexport function createCascaderHighlightStore(): CascaderHighlightStore {\n let snapshot: CascaderHighlight = NO_HIGHLIGHT;\n const listeners = new Set<() => void>();\n\n return {\n subscribe(onStoreChange) {\n listeners.add(onStoreChange);\n return () => {\n listeners.delete(onStoreChange);\n };\n },\n // The SAME object until something changes; `useSyncExternalStore` needs it.\n getSnapshot() {\n return snapshot;\n },\n set(next) {\n if (next.index === snapshot.index && next.value === snapshot.value) return;\n snapshot = next;\n for (const listener of listeners) listener();\n },\n };\n}\n\n/** Shared and permanently empty, so the hook degrades outside a `Cascader`. */\nconst FALLBACK_HIGHLIGHT_STORE = createCascaderHighlightStore();\n\nconst CascaderHighlightContext =\n React.createContext<CascaderHighlightStore>(FALLBACK_HIGHLIGHT_STORE);\n\n/** Subscribes to the highlight. Re-renders ONLY the calling component. */\nexport function useCascaderHighlight(): CascaderHighlight {\n const store = React.useContext(CascaderHighlightContext);\n return React.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n}\n\nexport {\n CascaderActionsContext,\n CascaderHighlightContext,\n CascaderRenderContext,\n CascaderStateContext,\n};\n"],"mappings":";;;AAoFA,MAAM,uBAAuBA,QAAM,cAAqD,KAAA,CAAS;;;;;AAMjG,SAAgB,mBAA8D;CAC5E,MAAM,UAAUA,QAAM,WAAW,oBAAoB;CACrD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,iDAAiD;CAEnE,OAAO;AACT;AAkHA,MAAM,yBAAyBA,QAAM,cACnC,KAAA,CACF;AAEA,SAAgB,qBAAkE;CAChF,MAAM,UAAUA,QAAM,WAAW,sBAAsB;CACvD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,mDAAmD;CAErE,OAAO;AACT;AAgBA,MAAM,wBAAwBA,QAAM,cAA0C,CAAC,CAAC;AAEhF,SAAgB,oBAAgE;CAC9E,OAAOA,QAAM,WAAW,qBAAqB;AAC/C;AAuBA,MAAM,eAAkC;CAAE,OAAO;CAAI,OAAO;AAAK;AAEjE,SAAgB,+BAAuD;CACrE,IAAI,WAA8B;CAClC,MAAM,4BAAY,IAAI,IAAgB;CAEtC,OAAO;EACL,UAAU,eAAe;GACvB,UAAU,IAAI,aAAa;GAC3B,aAAa;IACX,UAAU,OAAO,aAAa;GAChC;EACF;EAEA,cAAc;GACZ,OAAO;EACT;EACA,IAAI,MAAM;GACR,IAAI,KAAK,UAAU,SAAS,SAAS,KAAK,UAAU,SAAS,OAAO;GACpE,WAAW;GACX,KAAK,MAAM,YAAY,WAAW,SAAS;EAC7C;CACF;AACF;;AAGA,MAAM,2BAA2B,6BAA6B;AAE9D,MAAM,2BACJA,QAAM,cAAsC,wBAAwB;;AAGtE,SAAgB,uBAA0C;CACxD,MAAM,QAAQA,QAAM,WAAW,wBAAwB;CACvD,OAAOA,QAAM,qBAAqB,MAAM,WAAW,MAAM,aAAa,MAAM,WAAW;AACzF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as CascaderLabels } from "../../../cascader-types-
|
|
1
|
+
import { s as CascaderLabels } from "../../../cascader-types-zhnUQ4sP.js";
|
|
2
2
|
//#region src/components/reui/cascader/cascader-i18n.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* English defaults. Every string the primitive can render lives here, so a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as CascaderLoadState, p as CascaderNode } from "../../../cascader-types-
|
|
1
|
+
import { d as CascaderLoadState, p as CascaderNode } from "../../../cascader-types-zhnUQ4sP.js";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
import { Combobox } from "@base-ui/react";
|
|
4
4
|
//#region src/components/reui/cascader/cascader-item.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as CascaderSelectable, a as CascaderFlatNode, i as CascaderCollapse, m as CascaderPathSegment, o as CascaderIndex, p as CascaderNode } from "../../../cascader-types-
|
|
1
|
+
import { _ as CascaderSelectable, a as CascaderFlatNode, i as CascaderCollapse, m as CascaderPathSegment, o as CascaderIndex, p as CascaderNode } from "../../../cascader-types-zhnUQ4sP.js";
|
|
2
2
|
//#region src/components/reui/cascader/cascader-lib.d.ts
|
|
3
3
|
/** Root level key in `childrenOf`. NUL-prefixed so no real value collides. */
|
|
4
4
|
export declare const CASCADER_ROOT_KEY = "\0root";
|
|
@@ -30,6 +30,12 @@ export declare const CASCADER_SCROLL_CLASS = "size-full min-h-0 **:data-[slot=sc
|
|
|
30
30
|
export declare const CASCADER_ROWS_CLASS = "p-(--cascader-list-pad,4px) data-empty:p-0";
|
|
31
31
|
/** The footer's own stops; an `aria-disabled` command still counts as one. */
|
|
32
32
|
export declare function getCascaderFooterStops(scope: HTMLElement): HTMLElement[];
|
|
33
|
+
/**
|
|
34
|
+
* Hands focus to the panel's search field, or the popup without one. A Retry
|
|
35
|
+
* button is replaced by the loading state as the retry starts, and a focused
|
|
36
|
+
* node that unmounts drops focus to the body.
|
|
37
|
+
*/
|
|
38
|
+
export declare function focusCascaderHome(from: HTMLElement): void;
|
|
33
39
|
/** Where Tab lands, or `null` to let the browser out: focus is never trapped. */
|
|
34
40
|
export declare function getCascaderTabTarget(panel: HTMLElement, from: Element | null, backwards: boolean): HTMLElement | null;
|
|
35
41
|
/**
|
|
@@ -51,8 +57,27 @@ export declare function buildCascaderIndex<T = unknown>(items: readonly Cascader
|
|
|
51
57
|
* Folds loaded pages into an index built from `items`, so a re-render with a
|
|
52
58
|
* new `items` array keeps what the user drilled into. Static `items` wins;
|
|
53
59
|
* `detached` is `byValue` ONLY, or deep search doubles it and `childrenOf` lies.
|
|
60
|
+
*
|
|
61
|
+
* A resolved chain node in `links` that no page placed still gets its parent,
|
|
62
|
+
* so the trigger keeps its path. While its parent's level is unloaded it is
|
|
63
|
+
* searchable but no row; while that level has pages left (`paging`) it is
|
|
64
|
+
* LISTED, last, and in `pinned`; once the level loaded completely without it
|
|
65
|
+
* (moved, deleted) it is `hidden`: no row, hit or cascade child. A node some
|
|
66
|
+
* link names as a parent reads as a branch, whatever chain wrote it last.
|
|
67
|
+
*/
|
|
68
|
+
export declare function mergeCascaderIndex<T = unknown>(base: CascaderIndex<T>, pages: ReadonlyMap<string, readonly CascaderNode<T>[]>, detached?: ReadonlyMap<string, CascaderNode<T>>, links?: ReadonlyMap<string, string>, paging?: ReadonlySet<string>): CascaderIndex<T>;
|
|
69
|
+
/**
|
|
70
|
+
* Values reachable from the roots through `childrenOf`: the nodes a level can
|
|
71
|
+
* show. A tree query keeps only these, or a resolved node no level lists left
|
|
72
|
+
* its ancestors expanded over nothing.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getCascaderListedValues<T>(index: CascaderIndex<T>): ReadonlySet<string>;
|
|
75
|
+
/**
|
|
76
|
+
* A level's rows plus its paging row, placed BEFORE the `pinned` rows, which
|
|
77
|
+
* sit last: the first row a page appends then takes the paging row's index,
|
|
78
|
+
* so the highlight Base UI keeps by index lands on it.
|
|
54
79
|
*/
|
|
55
|
-
export declare function
|
|
80
|
+
export declare function withCascaderMoreRow<T>(rows: readonly CascaderNode<T>[], more: CascaderNode<T>, pinned?: ReadonlySet<string>): CascaderNode<T>[];
|
|
56
81
|
/** Children of `parent`, or the root level when `parent` is nullish. */
|
|
57
82
|
export declare function getCascaderChildren<T>(index: CascaderIndex<T>, parent?: string | null): CascaderNode<T>[];
|
|
58
83
|
/** A branch has known children, or `hasChildren` for an unfetched level. */
|
|
@@ -98,15 +123,16 @@ export declare function collapseCascaderPath<T>(path: readonly CascaderNode<T>[]
|
|
|
98
123
|
collapse?: CascaderCollapse;
|
|
99
124
|
}): CascaderPathSegment<T>[];
|
|
100
125
|
/**
|
|
101
|
-
* Every
|
|
102
|
-
* would mean a network request per level of
|
|
126
|
+
* Every KNOWN node under `value`, root first: loaded, or on a resolved chain.
|
|
127
|
+
* Reaching an unfetched descendant would mean a network request per level of
|
|
128
|
+
* the subtree on every selection.
|
|
103
129
|
*/
|
|
104
130
|
export declare function collectCascaderSubtree<T>(index: CascaderIndex<T>, value: string): CascaderNode<T>[];
|
|
105
131
|
/**
|
|
106
|
-
* Toggles `value` with its
|
|
107
|
-
* array, no hidden "checked" state: a branch is
|
|
108
|
-
* every selectable
|
|
109
|
-
* O(1) lookup. Nodes `isSelectable` rejects are skipped down AND ignored up,
|
|
132
|
+
* Toggles `value` with its known subtree (loaded, or on a resolved chain), then
|
|
133
|
+
* reconciles ancestors. One flat array, no hidden "checked" state: a branch is
|
|
134
|
+
* in the selection exactly when every selectable known child of it is, which
|
|
135
|
+
* keeps a row's checked state an O(1) lookup. Nodes `isSelectable` rejects are skipped down AND ignored up,
|
|
110
136
|
* the pressed node excepted.
|
|
111
137
|
*/
|
|
112
138
|
export declare function applyCascadeSelection<T>(index: CascaderIndex<T>, selected: readonly string[], value: string, select: boolean, isSelectable?: (node: CascaderNode<T>) => boolean): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascader-lib.d.ts","names":[],"sources":["../../../../src/components/reui/cascader/cascader-lib.tsx"],"mappings":";;;qBAYa;;;;;qBAMA;;;;;;;;;;;qBAiBA;;;;;;qBAQA;;qBAGA;;qBAIA;;wBAiCG,uBAAuB,OAAO,cAAc;;
|
|
1
|
+
{"version":3,"file":"cascader-lib.d.ts","names":[],"sources":["../../../../src/components/reui/cascader/cascader-lib.tsx"],"mappings":";;;qBAYa;;;;;qBAMA;;;;;;;;;;;qBAiBA;;;;;;qBAQA;;qBAGA;;qBAIA;;wBAiCG,uBAAuB,OAAO,cAAc;;;;;;wBAa5C,kBAAkB,MAAM;;wBAexB,qBACd,OAAO,aACP,MAAM,gBACN,qBACC;;;;;wBA0Ba,cAAc,SAAS,SAAS;;;;;wBAYhC,uBA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wBA+DP,uBAAuB,GACrC,OAAO,cAAc,IACrB,gBACC,aAAa;;;;;;;;wBAyBA,sBAAsB,GACpC,OAAO,cAAc,IACrB,6BACA,eACA,iBACA,gBAAe,MAAM,aAAa;;;;;wBA6CpB,+BAA+B,GAC7C,OAAO,cAAc,IACrB,8BACC;;wBAiBa,6BACd,QAAQ,6BACR,8BACC;;wBAYa,yBAAyB,GACvC,OAAO,cAAc,IACrB,8BACC;;YAKS;;;;;;;wBAQI,yBAAyB,GACvC,OAAO,cAAc,IACrB,6BACA,UAAU;;wBAwBI,4BAA4B,GAAG,gBAAgB,aAAa,OAAO;;wBAyBnE,iBAAiB,aAAa;;wBAQ9B;;iBAKC;;EAEf;;EAEA;;;wBAIc,uBAAuB,GACrC,gBAAgB,aAAa,kBAC7B,aAAa,MAAM,aAAa,mCAC/B"}
|
|
@@ -48,6 +48,17 @@ function getCascaderFooterStops(scope) {
|
|
|
48
48
|
if (!footer) return [];
|
|
49
49
|
return getCascaderTabStops(footer);
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Hands focus to the panel's search field, or the popup without one. A Retry
|
|
53
|
+
* button is replaced by the loading state as the retry starts, and a focused
|
|
54
|
+
* node that unmounts drops focus to the body.
|
|
55
|
+
*/
|
|
56
|
+
function focusCascaderHome(from) {
|
|
57
|
+
const panel = from.closest("[data-slot=\"cascader-panel\"]");
|
|
58
|
+
const home = panel?.querySelector("[data-slot=\"cascader-input\"]") ?? from.closest("[data-slot=\"cascader-content\"]") ?? panel;
|
|
59
|
+
if (home && home === panel && !home.hasAttribute("tabindex")) home.setAttribute("tabindex", "-1");
|
|
60
|
+
home?.focus();
|
|
61
|
+
}
|
|
51
62
|
/** Where Tab lands, or `null` to let the browser out: focus is never trapped. */
|
|
52
63
|
function getCascaderTabTarget(panel, from, backwards) {
|
|
53
64
|
const stops = getCascaderTabStops(panel);
|
|
@@ -157,12 +168,33 @@ function buildCascaderIndex(items, getParent) {
|
|
|
157
168
|
all
|
|
158
169
|
};
|
|
159
170
|
}
|
|
171
|
+
/** One branch-flagged copy per node, so a re-merge keeps row identity. */
|
|
172
|
+
const BRANCH_COPIES = /* @__PURE__ */ new WeakMap();
|
|
173
|
+
function asCascaderBranch(node) {
|
|
174
|
+
if (node.hasChildren) return node;
|
|
175
|
+
let copy = BRANCH_COPIES.get(node);
|
|
176
|
+
if (!copy) {
|
|
177
|
+
copy = {
|
|
178
|
+
...node,
|
|
179
|
+
hasChildren: true
|
|
180
|
+
};
|
|
181
|
+
BRANCH_COPIES.set(node, copy);
|
|
182
|
+
}
|
|
183
|
+
return copy;
|
|
184
|
+
}
|
|
160
185
|
/**
|
|
161
186
|
* Folds loaded pages into an index built from `items`, so a re-render with a
|
|
162
187
|
* new `items` array keeps what the user drilled into. Static `items` wins;
|
|
163
188
|
* `detached` is `byValue` ONLY, or deep search doubles it and `childrenOf` lies.
|
|
189
|
+
*
|
|
190
|
+
* A resolved chain node in `links` that no page placed still gets its parent,
|
|
191
|
+
* so the trigger keeps its path. While its parent's level is unloaded it is
|
|
192
|
+
* searchable but no row; while that level has pages left (`paging`) it is
|
|
193
|
+
* LISTED, last, and in `pinned`; once the level loaded completely without it
|
|
194
|
+
* (moved, deleted) it is `hidden`: no row, hit or cascade child. A node some
|
|
195
|
+
* link names as a parent reads as a branch, whatever chain wrote it last.
|
|
164
196
|
*/
|
|
165
|
-
function mergeCascaderIndex(base, pages, detached) {
|
|
197
|
+
function mergeCascaderIndex(base, pages, detached, links, paging) {
|
|
166
198
|
if (pages.size === 0 && !detached?.size) return base;
|
|
167
199
|
const byValue = new Map(base.byValue);
|
|
168
200
|
const childrenOf = new Map(base.childrenOf);
|
|
@@ -188,6 +220,20 @@ function mergeCascaderIndex(base, pages, detached) {
|
|
|
188
220
|
}
|
|
189
221
|
};
|
|
190
222
|
for (const [parentKey, nodes] of pages) insert(parentKey, nodes);
|
|
223
|
+
const pinned = /* @__PURE__ */ new Set();
|
|
224
|
+
const hidden = /* @__PURE__ */ new Set();
|
|
225
|
+
const linkParents = new Set(links?.values());
|
|
226
|
+
for (const [value, parentKey] of links ?? []) {
|
|
227
|
+
const linked = detached?.get(value);
|
|
228
|
+
if (!linked || byValue.has(value)) continue;
|
|
229
|
+
const node = linkParents.has(value) ? asCascaderBranch(linked) : linked;
|
|
230
|
+
byValue.set(value, node);
|
|
231
|
+
parentOf.set(value, parentKey === "\0root" ? null : parentKey);
|
|
232
|
+
if (paging?.has(parentKey)) {
|
|
233
|
+
append(parentKey, node);
|
|
234
|
+
pinned.add(value);
|
|
235
|
+
} else if (pages.has(parentKey) || base.childrenOf.has(parentKey)) hidden.add(value);
|
|
236
|
+
}
|
|
191
237
|
for (const value of byValue.keys()) {
|
|
192
238
|
if (depthOf.has(value)) continue;
|
|
193
239
|
let depth = 0;
|
|
@@ -214,7 +260,7 @@ function mergeCascaderIndex(base, pages, detached) {
|
|
|
214
260
|
};
|
|
215
261
|
walk(roots);
|
|
216
262
|
for (const [value, node] of byValue) {
|
|
217
|
-
if (visited.has(value)) continue;
|
|
263
|
+
if (visited.has(value) || hidden.has(value)) continue;
|
|
218
264
|
visited.add(value);
|
|
219
265
|
all.push(node);
|
|
220
266
|
}
|
|
@@ -228,9 +274,49 @@ function mergeCascaderIndex(base, pages, detached) {
|
|
|
228
274
|
parentOf,
|
|
229
275
|
depthOf,
|
|
230
276
|
roots,
|
|
231
|
-
all
|
|
277
|
+
all,
|
|
278
|
+
pinned,
|
|
279
|
+
hidden
|
|
232
280
|
};
|
|
233
281
|
}
|
|
282
|
+
/** Per index, so a query does not rebuild it. */
|
|
283
|
+
const LISTED_VALUES = /* @__PURE__ */ new WeakMap();
|
|
284
|
+
/**
|
|
285
|
+
* Values reachable from the roots through `childrenOf`: the nodes a level can
|
|
286
|
+
* show. A tree query keeps only these, or a resolved node no level lists left
|
|
287
|
+
* its ancestors expanded over nothing.
|
|
288
|
+
*/
|
|
289
|
+
function getCascaderListedValues(index) {
|
|
290
|
+
let listed = LISTED_VALUES.get(index);
|
|
291
|
+
if (listed) return listed;
|
|
292
|
+
const seen = /* @__PURE__ */ new Set();
|
|
293
|
+
const walk = (nodes) => {
|
|
294
|
+
for (const node of nodes) {
|
|
295
|
+
if (seen.has(node.value)) continue;
|
|
296
|
+
seen.add(node.value);
|
|
297
|
+
const children = index.childrenOf.get(node.value);
|
|
298
|
+
if (children?.length) walk(children);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
walk(index.roots);
|
|
302
|
+
listed = seen;
|
|
303
|
+
LISTED_VALUES.set(index, listed);
|
|
304
|
+
return listed;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* A level's rows plus its paging row, placed BEFORE the `pinned` rows, which
|
|
308
|
+
* sit last: the first row a page appends then takes the paging row's index,
|
|
309
|
+
* so the highlight Base UI keeps by index lands on it.
|
|
310
|
+
*/
|
|
311
|
+
function withCascaderMoreRow(rows, more, pinned) {
|
|
312
|
+
const at = pinned?.size ? rows.findIndex((row) => pinned.has(row.value)) : -1;
|
|
313
|
+
if (at === -1) return [...rows, more];
|
|
314
|
+
return [
|
|
315
|
+
...rows.slice(0, at),
|
|
316
|
+
more,
|
|
317
|
+
...rows.slice(at)
|
|
318
|
+
];
|
|
319
|
+
}
|
|
234
320
|
/** Children of `parent`, or the root level when `parent` is nullish. */
|
|
235
321
|
function getCascaderChildren(index, parent) {
|
|
236
322
|
return index.childrenOf.get(parent ?? "\0root") ?? [];
|
|
@@ -355,10 +441,21 @@ function searchCascaderDeep(index, query, options = {}) {
|
|
|
355
441
|
function flattenCascaderTree(index, expanded, sentinels) {
|
|
356
442
|
const rows = [];
|
|
357
443
|
const walk = (nodes, parentKey, depth) => {
|
|
358
|
-
const
|
|
359
|
-
const setSize =
|
|
360
|
-
for (let i = 0; i <
|
|
361
|
-
const node =
|
|
444
|
+
const items = sentinels?.has(parentKey) ? withCascaderMoreRow(nodes, createCascaderMoreNode(parentKey, nodes.length), index.pinned) : nodes;
|
|
445
|
+
const setSize = items.length;
|
|
446
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
447
|
+
const node = items[i];
|
|
448
|
+
if (isCascaderMoreNode(node)) {
|
|
449
|
+
rows.push({
|
|
450
|
+
node,
|
|
451
|
+
depth,
|
|
452
|
+
branch: false,
|
|
453
|
+
expanded: false,
|
|
454
|
+
setSize,
|
|
455
|
+
posInSet: i + 1
|
|
456
|
+
});
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
362
459
|
const branch = isCascaderBranch(index, node);
|
|
363
460
|
const isExpanded = branch && expanded.has(node.value);
|
|
364
461
|
rows.push({
|
|
@@ -371,14 +468,6 @@ function flattenCascaderTree(index, expanded, sentinels) {
|
|
|
371
468
|
});
|
|
372
469
|
if (isExpanded) walk(index.childrenOf.get(node.value) ?? [], node.value, depth + 1);
|
|
373
470
|
}
|
|
374
|
-
if (sentinel) rows.push({
|
|
375
|
-
node: createCascaderMoreNode(parentKey, nodes.length),
|
|
376
|
-
depth,
|
|
377
|
-
branch: false,
|
|
378
|
-
expanded: false,
|
|
379
|
-
setSize,
|
|
380
|
-
posInSet: setSize
|
|
381
|
-
});
|
|
382
471
|
};
|
|
383
472
|
walk(index.roots, CASCADER_ROOT_KEY, 0);
|
|
384
473
|
return rows;
|
|
@@ -412,30 +501,55 @@ function collapseCascaderPath(path, options = {}) {
|
|
|
412
501
|
...asNodes(tail)
|
|
413
502
|
];
|
|
414
503
|
}
|
|
504
|
+
/** Per index, so a press does not rebuild it. */
|
|
505
|
+
const SELECTION_CHILDREN = /* @__PURE__ */ new WeakMap();
|
|
415
506
|
/**
|
|
416
|
-
*
|
|
417
|
-
*
|
|
507
|
+
* Children by parent, built from `parentOf`. Unlike `childrenOf` it also holds
|
|
508
|
+
* a resolved chain node whose level has not loaded, which the selection walks
|
|
509
|
+
* must see: unchecking an ancestor has to take it along. A `hidden` one is left
|
|
510
|
+
* out, since its level loaded without it.
|
|
511
|
+
*/
|
|
512
|
+
function getSelectionChildren(index) {
|
|
513
|
+
let map = SELECTION_CHILDREN.get(index);
|
|
514
|
+
if (map) return map;
|
|
515
|
+
map = /* @__PURE__ */ new Map();
|
|
516
|
+
for (const [value, parent] of index.parentOf) {
|
|
517
|
+
const node = index.byValue.get(value);
|
|
518
|
+
if (!node || index.hidden?.has(value)) continue;
|
|
519
|
+
const key = parent ?? "\0root";
|
|
520
|
+
const bucket = map.get(key);
|
|
521
|
+
if (bucket) bucket.push(node);
|
|
522
|
+
else map.set(key, [node]);
|
|
523
|
+
}
|
|
524
|
+
SELECTION_CHILDREN.set(index, map);
|
|
525
|
+
return map;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Every KNOWN node under `value`, root first: loaded, or on a resolved chain.
|
|
529
|
+
* Reaching an unfetched descendant would mean a network request per level of
|
|
530
|
+
* the subtree on every selection.
|
|
418
531
|
*/
|
|
419
532
|
function collectCascaderSubtree(index, value) {
|
|
420
533
|
const root = index.byValue.get(value);
|
|
421
534
|
if (!root) return [];
|
|
535
|
+
const childrenOf = getSelectionChildren(index);
|
|
422
536
|
const out = [];
|
|
423
537
|
const seen = /* @__PURE__ */ new Set();
|
|
424
538
|
const walk = (node) => {
|
|
425
539
|
if (seen.has(node.value)) return;
|
|
426
540
|
seen.add(node.value);
|
|
427
541
|
out.push(node);
|
|
428
|
-
const children =
|
|
542
|
+
const children = childrenOf.get(node.value);
|
|
429
543
|
if (children) for (const child of children) walk(child);
|
|
430
544
|
};
|
|
431
545
|
walk(root);
|
|
432
546
|
return out;
|
|
433
547
|
}
|
|
434
548
|
/**
|
|
435
|
-
* Toggles `value` with its
|
|
436
|
-
* array, no hidden "checked" state: a branch is
|
|
437
|
-
* every selectable
|
|
438
|
-
* O(1) lookup. Nodes `isSelectable` rejects are skipped down AND ignored up,
|
|
549
|
+
* Toggles `value` with its known subtree (loaded, or on a resolved chain), then
|
|
550
|
+
* reconciles ancestors. One flat array, no hidden "checked" state: a branch is
|
|
551
|
+
* in the selection exactly when every selectable known child of it is, which
|
|
552
|
+
* keeps a row's checked state an O(1) lookup. Nodes `isSelectable` rejects are skipped down AND ignored up,
|
|
439
553
|
* the pressed node excepted.
|
|
440
554
|
*/
|
|
441
555
|
function applyCascadeSelection(index, selected, value, select, isSelectable = () => true) {
|
|
@@ -455,7 +569,7 @@ function applyCascadeSelection(index, selected, value, select, isSelectable = ()
|
|
|
455
569
|
while (cursor != null && !seen.has(cursor)) {
|
|
456
570
|
seen.add(cursor);
|
|
457
571
|
const parent = index.byValue.get(cursor);
|
|
458
|
-
const selectable = (index.
|
|
572
|
+
const selectable = (getSelectionChildren(index).get(cursor) ?? []).filter((child) => isSelectable(child));
|
|
459
573
|
if (selectable.length > 0 && selectable.every((child) => next.has(child.value)) && !!parent && isSelectable(parent)) next.add(cursor);
|
|
460
574
|
else next.delete(cursor);
|
|
461
575
|
cursor = index.parentOf.get(cursor) ?? null;
|
|
@@ -503,11 +617,13 @@ function getCascaderCheckedValues(index, selected, strategy) {
|
|
|
503
617
|
const parent = index.parentOf.get(value);
|
|
504
618
|
return parent == null || !set.has(parent);
|
|
505
619
|
});
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (
|
|
509
|
-
|
|
510
|
-
|
|
620
|
+
const withSelectedChild = /* @__PURE__ */ new Set();
|
|
621
|
+
for (const value of selected) {
|
|
622
|
+
if (index.hidden?.has(value)) continue;
|
|
623
|
+
const parent = index.parentOf.get(value);
|
|
624
|
+
if (parent != null) withSelectedChild.add(parent);
|
|
625
|
+
}
|
|
626
|
+
return selected.filter((value) => !withSelectedChild.has(value));
|
|
511
627
|
}
|
|
512
628
|
/** Values in `nodes` whose label collides, so the chip must show its path. */
|
|
513
629
|
function findAmbiguousCascaderLabels(nodes) {
|
|
@@ -579,6 +695,6 @@ function findCascaderDataIssues(items, getParent) {
|
|
|
579
695
|
};
|
|
580
696
|
}
|
|
581
697
|
//#endregion
|
|
582
|
-
export { CASCADER_LIST_HEIGHT_CLASS, CASCADER_LIST_PAD_CLASS, CASCADER_MORE_PREFIX, CASCADER_ROOT_KEY, CASCADER_ROWS_CLASS, CASCADER_SCROLL_CLASS, applyCascadeSelection, buildCascaderIndex, collapseCascaderPath, collectCascaderSubtree, createCascaderMoreNode, filterCascaderLevel, findAmbiguousCascaderLabels, findCascaderDataIssues, flattenCascaderTree, foldCascaderText, getCascaderCheckedValues, getCascaderChildren, getCascaderCount, getCascaderFooterStops, getCascaderIndeterminate, getCascaderIndeterminateFrom, getCascaderMoreParent, getCascaderPath, getCascaderSelectedDescendants, getCascaderTabTarget, isCascaderBranch, isCascaderDisabled, isCascaderMoreNode, isCascaderRtl, isCascaderSelectable, matchesCascaderQuery, mergeCascaderIndex, normalizeCascaderQuery, resetCascaderWarnings, searchCascaderDeep, warnCascaderOnce };
|
|
698
|
+
export { CASCADER_LIST_HEIGHT_CLASS, CASCADER_LIST_PAD_CLASS, CASCADER_MORE_PREFIX, CASCADER_ROOT_KEY, CASCADER_ROWS_CLASS, CASCADER_SCROLL_CLASS, applyCascadeSelection, buildCascaderIndex, collapseCascaderPath, collectCascaderSubtree, createCascaderMoreNode, filterCascaderLevel, findAmbiguousCascaderLabels, findCascaderDataIssues, flattenCascaderTree, focusCascaderHome, foldCascaderText, getCascaderCheckedValues, getCascaderChildren, getCascaderCount, getCascaderFooterStops, getCascaderIndeterminate, getCascaderIndeterminateFrom, getCascaderListedValues, getCascaderMoreParent, getCascaderPath, getCascaderSelectedDescendants, getCascaderTabTarget, isCascaderBranch, isCascaderDisabled, isCascaderMoreNode, isCascaderRtl, isCascaderSelectable, matchesCascaderQuery, mergeCascaderIndex, normalizeCascaderQuery, resetCascaderWarnings, searchCascaderDeep, warnCascaderOnce, withCascaderMoreRow };
|
|
583
699
|
|
|
584
700
|
//# sourceMappingURL=cascader-lib.js.map
|