@kumix/ui 0.3.7 → 0.3.9
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 +26 -25
- package/dist/cascader-types-BnH6wYD-.d.ts +183 -0
- package/dist/cascader-types-BnH6wYD-.d.ts.map +1 -0
- package/dist/components/agents/ai-sidebar.js +3 -5
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
- package/dist/components/motion/animated-sidebar.js +12 -3
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/attachment-upload.d.ts.map +1 -1
- package/dist/components/motion/attachment-upload.js +9 -5
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
- package/dist/components/motion/bottom-sheet.js +77 -74
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/center-morph-modal.d.ts.map +1 -1
- package/dist/components/motion/center-morph-modal.js +82 -88
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/combobox/content.js +1 -1
- package/dist/components/motion/combobox/context.d.ts +6 -0
- package/dist/components/motion/combobox/context.d.ts.map +1 -1
- package/dist/components/motion/combobox/context.js +1 -233
- package/dist/components/motion/combobox/list.js +1 -1
- package/dist/components/motion/combobox/trigger.js +7 -8
- package/dist/components/motion/combobox/trigger.js.map +1 -1
- package/dist/components/motion/combobox.js +1 -1
- package/dist/components/motion/command-palette.d.ts.map +1 -1
- package/dist/components/motion/command-palette.js +62 -45
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/drawer.d.ts.map +1 -1
- package/dist/components/motion/drawer.js +30 -30
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/loader.js +20 -22
- package/dist/components/motion/loader.js.map +1 -1
- package/dist/components/motion/morphing-modal.d.ts.map +1 -1
- package/dist/components/motion/morphing-modal.js +83 -83
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.d.ts +28 -0
- package/dist/components/motion/morphing-search.d.ts.map +1 -0
- package/dist/components/motion/morphing-search.js +422 -0
- package/dist/components/motion/morphing-search.js.map +1 -0
- package/dist/components/motion/project-folder.js +20 -20
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-async.d.ts +90 -0
- package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-async.js +549 -0
- package/dist/components/reui/cascader/cascader-async.js.map +1 -0
- package/dist/components/reui/cascader/cascader-columns.d.ts +29 -0
- package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-columns.js +135 -0
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -0
- package/dist/components/reui/cascader/cascader-context.d.ts +193 -0
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-context.js +59 -0
- package/dist/components/reui/cascader/cascader-context.js.map +1 -0
- package/dist/components/reui/cascader/cascader-footer.d.ts +85 -0
- package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-footer.js +456 -0
- package/dist/components/reui/cascader/cascader-footer.js.map +1 -0
- package/dist/components/reui/cascader/cascader-i18n.d.ts +17 -0
- package/dist/components/reui/cascader/cascader-i18n.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-i18n.js +68 -0
- package/dist/components/reui/cascader/cascader-i18n.js.map +1 -0
- package/dist/components/reui/cascader/cascader-item.d.ts +115 -0
- package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-item.js +530 -0
- package/dist/components/reui/cascader/cascader-item.js.map +1 -0
- package/dist/components/reui/cascader/cascader-lib.d.ts +141 -0
- package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-lib.js +576 -0
- package/dist/components/reui/cascader/cascader-lib.js.map +1 -0
- package/dist/components/reui/cascader/cascader-nav.d.ts +59 -0
- package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-nav.js +312 -0
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -0
- package/dist/components/reui/cascader/cascader-types.d.ts +2 -0
- package/dist/components/reui/cascader/cascader-types.js +2 -0
- package/dist/components/reui/cascader/cascader-virtual.d.ts +65 -0
- package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-virtual.js +240 -0
- package/dist/components/reui/cascader/cascader-virtual.js.map +1 -0
- package/dist/components/reui/cascader/cascader.d.ts +322 -0
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader.js +1459 -0
- package/dist/components/reui/cascader/cascader.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts +28 -47
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +26 -44
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts +19 -57
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-advanced.d.ts +52 -0
- package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-advanced.js +1191 -0
- package/dist/components/reui/filters/filters-advanced.js.map +1 -0
- package/dist/components/reui/filters/filters-builder.d.ts +43 -0
- package/dist/components/reui/filters/filters-builder.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-builder.js +152 -0
- package/dist/components/reui/filters/filters-builder.js.map +1 -0
- package/dist/components/reui/filters/filters-chip.d.ts +79 -0
- package/dist/components/reui/filters/filters-chip.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-chip.js +553 -0
- package/dist/components/reui/filters/filters-chip.js.map +1 -0
- package/dist/components/reui/filters/filters-context.d.ts +290 -0
- package/dist/components/reui/filters/filters-context.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-context.js +277 -0
- package/dist/components/reui/filters/filters-context.js.map +1 -0
- package/dist/components/reui/filters/filters-date.d.ts +43 -0
- package/dist/components/reui/filters/filters-date.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-date.js +143 -0
- package/dist/components/reui/filters/filters-date.js.map +1 -0
- package/dist/components/reui/filters/filters-dnd.d.ts +101 -0
- package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-dnd.js +454 -0
- package/dist/components/reui/filters/filters-dnd.js.map +1 -0
- package/dist/components/reui/filters/filters-draft.d.ts +2 -0
- package/dist/components/reui/filters/filters-draft.js +128 -0
- package/dist/components/reui/filters/filters-draft.js.map +1 -0
- package/dist/components/reui/filters/filters-editors.d.ts +91 -0
- package/dist/components/reui/filters/filters-editors.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-editors.js +773 -0
- package/dist/components/reui/filters/filters-editors.js.map +1 -0
- package/dist/components/reui/filters/filters-i18n.d.ts +24 -0
- package/dist/components/reui/filters/filters-i18n.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-i18n.js +127 -0
- package/dist/components/reui/filters/filters-i18n.js.map +1 -0
- package/dist/components/reui/filters/filters-lib.d.ts +171 -0
- package/dist/components/reui/filters/filters-lib.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-lib.js +336 -0
- package/dist/components/reui/filters/filters-lib.js.map +1 -0
- package/dist/components/reui/filters/filters-operators.d.ts +49 -0
- package/dist/components/reui/filters/filters-operators.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-operators.js +300 -0
- package/dist/components/reui/filters/filters-operators.js.map +1 -0
- package/dist/components/reui/filters/filters-query.d.ts +132 -0
- package/dist/components/reui/filters/filters-query.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-query.js +476 -0
- package/dist/components/reui/filters/filters-query.js.map +1 -0
- package/dist/components/reui/filters/filters-types.d.ts +452 -0
- package/dist/components/reui/filters/filters-types.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-types.js +2 -0
- package/dist/components/reui/filters/filters.d.ts +114 -0
- package/dist/components/reui/filters/filters.d.ts.map +1 -0
- package/dist/components/reui/filters/filters.js +638 -0
- package/dist/components/reui/filters/filters.js.map +1 -0
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-types.d.ts +25 -71
- package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/field.js +2 -2
- package/dist/components/ui/field.js.map +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/context-BizvUNZv.js +298 -0
- package/dist/context-BizvUNZv.js.map +1 -0
- package/dist/filters-draft-DEAl3TO-.d.ts +70 -0
- package/dist/filters-draft-DEAl3TO-.d.ts.map +1 -0
- package/dist/hooks/use-on-open.d.ts +18 -0
- package/dist/hooks/use-on-open.d.ts.map +1 -0
- package/dist/hooks/use-on-open.js +27 -0
- package/dist/hooks/use-on-open.js.map +1 -0
- package/dist/hooks/use-row-cursor.d.ts +39 -0
- package/dist/hooks/use-row-cursor.d.ts.map +1 -0
- package/dist/hooks/use-row-cursor.js +77 -0
- package/dist/hooks/use-row-cursor.js.map +1 -0
- package/dist/lib/text-shimmer.d.ts +2 -2
- package/dist/lib/text-shimmer.d.ts.map +1 -1
- package/dist/lib/text-shimmer.js +2 -2
- package/dist/lib/text-shimmer.js.map +1 -1
- package/dist/presence-gate-BekdC4Bo.js +24 -0
- package/dist/presence-gate-BekdC4Bo.js.map +1 -0
- package/package.json +11 -11
- package/dist/components/motion/combobox/context.js.map +0 -1
- package/dist/components/reui/filters.d.ts +0 -176
- package/dist/components/reui/filters.d.ts.map +0 -1
- package/dist/components/reui/filters.js +0 -1223
- package/dist/components/reui/filters.js.map +0 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCascaderActions, useCascaderHighlight, useCascaderState } from "./cascader-context.js";
|
|
3
|
+
import { CascaderItem, CascaderItems, getCascaderMoreProps } from "./cascader-item.js";
|
|
4
|
+
import { CascaderColumnPanel } from "./cascader-columns.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
|
|
8
|
+
//#region src/components/reui/cascader/cascader-virtual.tsx
|
|
9
|
+
/**
|
|
10
|
+
* The cascader's virtualizer: TanStack plus the highlight pinning and
|
|
11
|
+
* scroll-into-view a combobox list needs. `activeIndex` is clamped here, not by
|
|
12
|
+
* the caller: emitted from a layout effect, it can be one commit ahead of a
|
|
13
|
+
* level that just shrank and would otherwise scroll to a row that is gone.
|
|
14
|
+
*/
|
|
15
|
+
function useCascaderVirtualizer({ count, getScrollElement, estimateSize = 32, overscan = 8, getItemKey, activeIndex = -1 }) {
|
|
16
|
+
const active = activeIndex >= 0 && activeIndex < count ? activeIndex : -1;
|
|
17
|
+
const rangeExtractor = React$1.useCallback((range) => {
|
|
18
|
+
const indices = new Set(defaultRangeExtractor(range));
|
|
19
|
+
if (active !== -1) indices.add(active);
|
|
20
|
+
return Array.from(indices).sort((a, b) => a - b);
|
|
21
|
+
}, [active]);
|
|
22
|
+
const measureEstimate = React$1.useCallback(() => estimateSize, [estimateSize]);
|
|
23
|
+
const virtualizer = useVirtualizer({
|
|
24
|
+
count,
|
|
25
|
+
getScrollElement,
|
|
26
|
+
estimateSize: measureEstimate,
|
|
27
|
+
overscan,
|
|
28
|
+
getItemKey,
|
|
29
|
+
rangeExtractor
|
|
30
|
+
});
|
|
31
|
+
React$1.useEffect(() => {
|
|
32
|
+
if (active === -1) return;
|
|
33
|
+
virtualizer.scrollToIndex(active, { align: "auto" });
|
|
34
|
+
}, [active, virtualizer]);
|
|
35
|
+
return virtualizer;
|
|
36
|
+
}
|
|
37
|
+
const NO_GUTTER = {
|
|
38
|
+
block: 0,
|
|
39
|
+
inline: 0
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The ROWS' BOX's own padding, never the scrollport's (separate element, reads
|
|
43
|
+
* a flat zero). Measured because every style sets its own: a windowed row is
|
|
44
|
+
* positioned against this box's PADDING box while the scroll-height spacer is
|
|
45
|
+
* an in-flow child of its CONTENT box, so without it rows sit flush.
|
|
46
|
+
*/
|
|
47
|
+
function useCascaderVirtualGutter(contentElement) {
|
|
48
|
+
const [gutter, setGutter] = React$1.useState(NO_GUTTER);
|
|
49
|
+
React$1.useLayoutEffect(() => {
|
|
50
|
+
if (!contentElement) return;
|
|
51
|
+
const styles = getComputedStyle(contentElement);
|
|
52
|
+
const block = Number.parseFloat(styles.paddingTop) || 0;
|
|
53
|
+
const inline = Number.parseFloat(styles.paddingInlineStart || styles.paddingLeft) || 0;
|
|
54
|
+
setGutter((previous) => previous.block === block && previous.inline === inline ? previous : {
|
|
55
|
+
block,
|
|
56
|
+
inline
|
|
57
|
+
});
|
|
58
|
+
}, [contentElement]);
|
|
59
|
+
return gutter;
|
|
60
|
+
}
|
|
61
|
+
/** Logical insets, not `left` / `width`, so RTL needs no second code path. */
|
|
62
|
+
function cascaderVirtualRowStyle(start, gutter) {
|
|
63
|
+
return {
|
|
64
|
+
position: "absolute",
|
|
65
|
+
top: 0,
|
|
66
|
+
insetInlineStart: gutter.inline,
|
|
67
|
+
insetInlineEnd: gutter.inline,
|
|
68
|
+
transform: `translateY(${start + gutter.block}px)`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The element that actually SCROLLS: the `ScrollArea` viewport above the rows'
|
|
73
|
+
* box, not the rows' box itself, which never overflows, so a virtualizer aimed
|
|
74
|
+
* at it would read a full `clientHeight` and render every row. `closest` rather
|
|
75
|
+
* than `parentElement`, plus a fallback to the content element, keeps a
|
|
76
|
+
* hand-written `overflow-y-auto` container working.
|
|
77
|
+
*/
|
|
78
|
+
function cascaderScrollElement(content) {
|
|
79
|
+
if (!content) return null;
|
|
80
|
+
return content.closest("[data-slot=\"scroll-area-viewport\"]") ?? content;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* `role="presentation"` keeps the listbox owning nothing but options, and this
|
|
84
|
+
* node's parent IS the rows' box, saving a ref threaded through `CascaderList`.
|
|
85
|
+
*/
|
|
86
|
+
function CascaderVirtualSpacer({ height, onContentElement }) {
|
|
87
|
+
return /* @__PURE__ */ jsx("div", {
|
|
88
|
+
ref: (node) => onContentElement(node?.parentElement ?? null),
|
|
89
|
+
role: "presentation",
|
|
90
|
+
"data-slot": "cascader-virtual-spacer",
|
|
91
|
+
style: { height }
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Windowed replacement for `CascaderItems`, dropped inside `CascaderList`. The
|
|
96
|
+
* registration is a LAYOUT effect because the root derives `virtualized` from
|
|
97
|
+
* it and the flip has to land before the browser paints. Until the root has
|
|
98
|
+
* seen it, this renders exactly what `CascaderItems` does, so no frame carries
|
|
99
|
+
* indexed rows while Base UI still owns the composite list.
|
|
100
|
+
*/
|
|
101
|
+
function CascaderVirtualItems(props) {
|
|
102
|
+
const { virtualized, registerVirtualRenderer } = useCascaderActions();
|
|
103
|
+
React$1.useLayoutEffect(() => registerVirtualRenderer(), [registerVirtualRenderer]);
|
|
104
|
+
if (!virtualized) return /* @__PURE__ */ jsx(CascaderItems, {});
|
|
105
|
+
return /* @__PURE__ */ jsx(CascaderVirtualRows, { ...props });
|
|
106
|
+
}
|
|
107
|
+
function CascaderVirtualRows({ estimateSize, overscan }) {
|
|
108
|
+
const { estimateRowSize, overscan: rootOverscan, mode, isBranch, isSelectable, isSelected, isIndeterminate } = useCascaderActions();
|
|
109
|
+
const { renderedItems, treeRows, deepResults, loadStates } = useCascaderState();
|
|
110
|
+
const highlight = useCascaderHighlight();
|
|
111
|
+
const [contentElement, setContentElement] = React$1.useState(null);
|
|
112
|
+
const gutter = useCascaderVirtualGutter(contentElement);
|
|
113
|
+
const tree = mode === "tree";
|
|
114
|
+
const count = tree ? treeRows.length : renderedItems.length;
|
|
115
|
+
const showPath = !tree && deepResults !== null;
|
|
116
|
+
const getItemKey = React$1.useCallback((index) => (tree ? treeRows[index]?.node.value : renderedItems[index]?.value) ?? index, [
|
|
117
|
+
tree,
|
|
118
|
+
treeRows,
|
|
119
|
+
renderedItems
|
|
120
|
+
]);
|
|
121
|
+
const virtualizer = useCascaderVirtualizer({
|
|
122
|
+
count,
|
|
123
|
+
getScrollElement: () => cascaderScrollElement(contentElement),
|
|
124
|
+
estimateSize: estimateSize ?? estimateRowSize,
|
|
125
|
+
overscan: overscan ?? rootOverscan,
|
|
126
|
+
getItemKey,
|
|
127
|
+
activeIndex: highlight.index
|
|
128
|
+
});
|
|
129
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CascaderVirtualSpacer, {
|
|
130
|
+
height: virtualizer.getTotalSize(),
|
|
131
|
+
onContentElement: setContentElement
|
|
132
|
+
}), virtualizer.getVirtualItems().map((row) => {
|
|
133
|
+
const flat = tree ? treeRows[row.index] : void 0;
|
|
134
|
+
const node = tree ? flat?.node : renderedItems[row.index];
|
|
135
|
+
if (!node) return null;
|
|
136
|
+
return /* @__PURE__ */ jsx(CascaderItem, {
|
|
137
|
+
ref: virtualizer.measureElement,
|
|
138
|
+
"data-index": row.index,
|
|
139
|
+
style: cascaderVirtualRowStyle(row.start, gutter),
|
|
140
|
+
node,
|
|
141
|
+
index: row.index,
|
|
142
|
+
depth: flat?.depth,
|
|
143
|
+
expanded: flat?.expanded,
|
|
144
|
+
branch: flat ? flat.branch : isBranch(node),
|
|
145
|
+
selectable: isSelectable(node),
|
|
146
|
+
selected: isSelected(node),
|
|
147
|
+
indeterminate: isIndeterminate(node),
|
|
148
|
+
...getCascaderMoreProps(node, loadStates),
|
|
149
|
+
showPath,
|
|
150
|
+
"aria-setsize": flat ? flat.setSize : count,
|
|
151
|
+
"aria-posinset": flat ? flat.posInSet : row.index + 1
|
|
152
|
+
}, row.key);
|
|
153
|
+
})] });
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Windowed replacement for one Miller column, passed through the
|
|
157
|
+
* `CascaderColumns` render slot. One virtualizer PER COLUMN, since columns
|
|
158
|
+
* scroll independently, and only the deepest is Base UI's listbox: the trail
|
|
159
|
+
* behind is `as="button"` rows outside Base UI, so it windows on its own row
|
|
160
|
+
* count rather than waiting for the root to flip.
|
|
161
|
+
*/
|
|
162
|
+
function CascaderVirtualColumn({ column, estimateSize, overscan }) {
|
|
163
|
+
const { virtualized, registerVirtualRenderer, virtualize, virtualizeThreshold } = useCascaderActions();
|
|
164
|
+
React$1.useLayoutEffect(() => registerVirtualRenderer(), [registerVirtualRenderer]);
|
|
165
|
+
if (!(column.active ? virtualized : virtualize ?? column.items.length >= virtualizeThreshold)) return /* @__PURE__ */ jsx(CascaderColumnPanel, { column });
|
|
166
|
+
return /* @__PURE__ */ jsx(CascaderColumnPanel, {
|
|
167
|
+
column,
|
|
168
|
+
virtualized: true,
|
|
169
|
+
children: column.active ? /* @__PURE__ */ jsx(CascaderVirtualActiveColumnRows, {
|
|
170
|
+
column,
|
|
171
|
+
estimateSize,
|
|
172
|
+
overscan
|
|
173
|
+
}) : /* @__PURE__ */ jsx(CascaderVirtualColumnRows, {
|
|
174
|
+
column,
|
|
175
|
+
estimateSize,
|
|
176
|
+
overscan,
|
|
177
|
+
activeIndex: -1
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/** Only the active column subscribes to the highlight; a trail column must not. */
|
|
182
|
+
function CascaderVirtualActiveColumnRows(props) {
|
|
183
|
+
const highlight = useCascaderHighlight();
|
|
184
|
+
return /* @__PURE__ */ jsx(CascaderVirtualColumnRows, {
|
|
185
|
+
...props,
|
|
186
|
+
activeIndex: highlight.index
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function CascaderVirtualColumnRows({ column, estimateSize, overscan, activeIndex }) {
|
|
190
|
+
const { estimateRowSize, overscan: rootOverscan, baseId, isBranch, isSelectable, isSelected, isIndeterminate } = useCascaderActions();
|
|
191
|
+
const { loadStates } = useCascaderState();
|
|
192
|
+
const [contentElement, setContentElement] = React$1.useState(null);
|
|
193
|
+
const gutter = useCascaderVirtualGutter(contentElement);
|
|
194
|
+
const items = column.items;
|
|
195
|
+
const getItemKey = React$1.useCallback((index) => items[index]?.value ?? index, [items]);
|
|
196
|
+
const virtualizer = useCascaderVirtualizer({
|
|
197
|
+
count: items.length,
|
|
198
|
+
getScrollElement: () => cascaderScrollElement(contentElement),
|
|
199
|
+
estimateSize: estimateSize ?? estimateRowSize,
|
|
200
|
+
overscan: overscan ?? rootOverscan,
|
|
201
|
+
getItemKey,
|
|
202
|
+
activeIndex
|
|
203
|
+
});
|
|
204
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CascaderVirtualSpacer, {
|
|
205
|
+
height: virtualizer.getTotalSize(),
|
|
206
|
+
onContentElement: setContentElement
|
|
207
|
+
}), virtualizer.getVirtualItems().map((row) => {
|
|
208
|
+
const node = items[row.index];
|
|
209
|
+
if (!node) return null;
|
|
210
|
+
const open = node.value === column.activeValue;
|
|
211
|
+
return /* @__PURE__ */ jsx(CascaderItem, {
|
|
212
|
+
ref: virtualizer.measureElement,
|
|
213
|
+
"data-index": row.index,
|
|
214
|
+
style: cascaderVirtualRowStyle(row.start, gutter),
|
|
215
|
+
node,
|
|
216
|
+
as: column.active ? "option" : "button",
|
|
217
|
+
depth: column.depth,
|
|
218
|
+
branch: isBranch(node),
|
|
219
|
+
selectable: isSelectable(node),
|
|
220
|
+
selected: isSelected(node),
|
|
221
|
+
indeterminate: isIndeterminate(node),
|
|
222
|
+
...getCascaderMoreProps(node, loadStates),
|
|
223
|
+
"data-open": open || void 0,
|
|
224
|
+
className: open ? "bg-accent/60 text-accent-foreground" : void 0,
|
|
225
|
+
...column.active ? {
|
|
226
|
+
index: row.index,
|
|
227
|
+
"aria-setsize": items.length,
|
|
228
|
+
"aria-posinset": row.index + 1
|
|
229
|
+
} : null,
|
|
230
|
+
...!column.active && open ? {
|
|
231
|
+
"aria-expanded": true,
|
|
232
|
+
"aria-controls": `${baseId}-column-${column.depth + 1}`
|
|
233
|
+
} : null
|
|
234
|
+
}, row.key);
|
|
235
|
+
})] });
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
export { CascaderVirtualColumn, CascaderVirtualItems, useCascaderVirtualizer };
|
|
239
|
+
|
|
240
|
+
//# sourceMappingURL=cascader-virtual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cascader-virtual.js","names":["React"],"sources":["../../../../src/components/reui/cascader/cascader-virtual.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n defaultRangeExtractor,\n type Range,\n useVirtualizer,\n type Virtualizer,\n} from \"@tanstack/react-virtual\";\n\nimport { CascaderColumnPanel } from \"./cascader-columns\";\nimport type { CascaderColumn } from \"./cascader-context\";\nimport { useCascaderActions, useCascaderHighlight, useCascaderState } from \"./cascader-context\";\nimport { CascaderItem, CascaderItems, getCascaderMoreProps } from \"./cascader-item\";\n\n/**\n * Windowing for the cascader, in its own file so the primitive's own install\n * never pulls `@tanstack/react-virtual` in. Base UI forces three rules:\n *\n * 1. A windowed row MUST carry an explicit `index`; the fallback\n * `findItemIndex` is O(n) per row and returns `-1` on the frame a level swap\n * renders empty, dangling `aria-activedescendant`.\n * 2. That index is DESTRUCTIVE while unvirtualized (`useCompositeListItem`\n * skips registration, `CompositeList` truncates `elementsRef` to zero and\n * the first arrow key highlights nothing), so rows stay plain until the root\n * flips `virtualized`, gated inside `CascaderItem`.\n * 3. No `Combobox.Collection` and no FUNCTION CHILD on `Combobox.List`, which\n * implicitly wraps one in a Collection: a Collection renders every filtered\n * item.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Virtualizer */\n/* -------------------------------------------------------------------------- */\n\nexport interface UseCascaderVirtualizerOptions {\n count: number;\n getScrollElement: () => HTMLElement | null;\n estimateSize?: number;\n overscan?: number;\n /** Key rows by node value, never by index: a tree expand shifts every index. */\n getItemKey: (index: number) => string | number;\n /** Render index of the highlighted row, or `-1`. Pinned into the window. */\n activeIndex?: number;\n}\n\nexport type CascaderVirtualizer = Virtualizer<HTMLElement, HTMLElement>;\n\n/**\n * The cascader's virtualizer: TanStack plus the highlight pinning and\n * scroll-into-view a combobox list needs. `activeIndex` is clamped here, not by\n * the caller: emitted from a layout effect, it can be one commit ahead of a\n * level that just shrank and would otherwise scroll to a row that is gone.\n */\nexport function useCascaderVirtualizer({\n count,\n getScrollElement,\n estimateSize = 32,\n overscan = 8,\n getItemKey,\n activeIndex = -1,\n}: UseCascaderVirtualizerOptions): CascaderVirtualizer {\n const active = activeIndex >= 0 && activeIndex < count ? activeIndex : -1;\n\n // Keeps the highlighted row mounted so `aria-activedescendant` never dangles.\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const indices = new Set(defaultRangeExtractor(range));\n if (active !== -1) indices.add(active);\n return Array.from(indices).sort((a, b) => a - b);\n },\n [active],\n );\n\n const measureEstimate = React.useCallback(() => estimateSize, [estimateSize]);\n\n // React Compiler bails on `useVirtualizer`; harmless, rows memoise one by one.\n // eslint-disable-next-line react-hooks/incompatible-library\n const virtualizer = useVirtualizer<HTMLElement, HTMLElement>({\n count,\n getScrollElement,\n estimateSize: measureEstimate,\n overscan,\n getItemKey,\n rangeExtractor,\n });\n\n // Base UI's scroll-into-view no-ops on a windowed-out row (empty `listRef`).\n React.useEffect(() => {\n if (active === -1) return;\n virtualizer.scrollToIndex(active, { align: \"auto\" });\n }, [active, virtualizer]);\n\n return virtualizer;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Geometry */\n/* -------------------------------------------------------------------------- */\n\ninterface CascaderVirtualGutter {\n block: number;\n inline: number;\n}\n\nconst NO_GUTTER: CascaderVirtualGutter = { block: 0, inline: 0 };\n\n/**\n * The ROWS' BOX's own padding, never the scrollport's (separate element, reads\n * a flat zero). Measured because every style sets its own: a windowed row is\n * positioned against this box's PADDING box while the scroll-height spacer is\n * an in-flow child of its CONTENT box, so without it rows sit flush.\n */\nfunction useCascaderVirtualGutter(contentElement: HTMLElement | null): CascaderVirtualGutter {\n const [gutter, setGutter] = React.useState<CascaderVirtualGutter>(NO_GUTTER);\n\n React.useLayoutEffect(() => {\n if (!contentElement) return;\n const styles = getComputedStyle(contentElement);\n const block = Number.parseFloat(styles.paddingTop) || 0;\n const inline = Number.parseFloat(styles.paddingInlineStart || styles.paddingLeft) || 0;\n setGutter((previous) =>\n previous.block === block && previous.inline === inline ? previous : { block, inline },\n );\n }, [contentElement]);\n\n return gutter;\n}\n\n/** Logical insets, not `left` / `width`, so RTL needs no second code path. */\nfunction cascaderVirtualRowStyle(\n start: number,\n gutter: CascaderVirtualGutter,\n): React.CSSProperties {\n return {\n position: \"absolute\",\n top: 0,\n insetInlineStart: gutter.inline,\n insetInlineEnd: gutter.inline,\n transform: `translateY(${start + gutter.block}px)`,\n };\n}\n\n/**\n * The element that actually SCROLLS: the `ScrollArea` viewport above the rows'\n * box, not the rows' box itself, which never overflows, so a virtualizer aimed\n * at it would read a full `clientHeight` and render every row. `closest` rather\n * than `parentElement`, plus a fallback to the content element, keeps a\n * hand-written `overflow-y-auto` container working.\n */\nfunction cascaderScrollElement(content: HTMLElement | null): HTMLElement | null {\n if (!content) return null;\n return content.closest<HTMLElement>('[data-slot=\"scroll-area-viewport\"]') ?? content;\n}\n\n/**\n * `role=\"presentation\"` keeps the listbox owning nothing but options, and this\n * node's parent IS the rows' box, saving a ref threaded through `CascaderList`.\n */\nfunction CascaderVirtualSpacer({\n height,\n onContentElement,\n}: {\n height: number;\n onContentElement: (element: HTMLElement | null) => void;\n}) {\n return (\n <div\n ref={(node) => onContentElement(node?.parentElement ?? null)}\n role=\"presentation\"\n data-slot=\"cascader-virtual-spacer\"\n style={{ height }}\n />\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Rows */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderVirtualItemsProps {\n /** Row height before measurement. Defaults to the root `estimateRowSize`. */\n estimateSize?: number;\n /** Rows rendered beyond each edge. Defaults to the root `overscan`. */\n overscan?: number;\n}\n\n/**\n * Windowed replacement for `CascaderItems`, dropped inside `CascaderList`. The\n * registration is a LAYOUT effect because the root derives `virtualized` from\n * it and the flip has to land before the browser paints. Until the root has\n * seen it, this renders exactly what `CascaderItems` does, so no frame carries\n * indexed rows while Base UI still owns the composite list.\n */\nfunction CascaderVirtualItems(props: CascaderVirtualItemsProps) {\n const { virtualized, registerVirtualRenderer } = useCascaderActions();\n\n React.useLayoutEffect(() => registerVirtualRenderer(), [registerVirtualRenderer]);\n\n if (!virtualized) return <CascaderItems />;\n\n return <CascaderVirtualRows {...props} />;\n}\n\nfunction CascaderVirtualRows({ estimateSize, overscan }: CascaderVirtualItemsProps) {\n const {\n estimateRowSize,\n overscan: rootOverscan,\n mode,\n isBranch,\n isSelectable,\n isSelected,\n isIndeterminate,\n } = useCascaderActions();\n const { renderedItems, treeRows, deepResults, loadStates } = useCascaderState();\n // Re-renders on every highlight change, and has to: the pinned row and the\n // scroll target are both derived from it.\n const highlight = useCascaderHighlight();\n\n const [contentElement, setContentElement] = React.useState<HTMLElement | null>(null);\n const gutter = useCascaderVirtualGutter(contentElement);\n\n const tree = mode === \"tree\";\n const count = tree ? treeRows.length : renderedItems.length;\n const showPath = !tree && deepResults !== null;\n\n const getItemKey = React.useCallback(\n (index: number) => (tree ? treeRows[index]?.node.value : renderedItems[index]?.value) ?? index,\n [tree, treeRows, renderedItems],\n );\n\n const virtualizer = useCascaderVirtualizer({\n count,\n getScrollElement: () => cascaderScrollElement(contentElement),\n estimateSize: estimateSize ?? estimateRowSize,\n overscan: overscan ?? rootOverscan,\n getItemKey,\n activeIndex: highlight.index,\n });\n\n return (\n <>\n <CascaderVirtualSpacer\n height={virtualizer.getTotalSize()}\n onContentElement={setContentElement}\n />\n {virtualizer.getVirtualItems().map((row) => {\n const flat = tree ? treeRows[row.index] : undefined;\n const node = tree ? flat?.node : renderedItems[row.index];\n // For one commit after a query narrows the level, the window can name\n // a row it no longer has; the count recomputes on the same tick.\n if (!node) return null;\n\n return (\n <CascaderItem\n key={row.key}\n /* Measured, not estimated: rows are two lines with a `description`\n and three in deep search, and row height is per style. An\n estimate alone would make `scrollToIndex` land on the wrong row. */\n ref={virtualizer.measureElement}\n data-index={row.index}\n style={cascaderVirtualRowStyle(row.start, gutter)}\n node={node}\n index={row.index}\n depth={flat?.depth}\n expanded={flat?.expanded}\n branch={flat ? flat.branch : isBranch(node)}\n selectable={isSelectable(node)}\n selected={isSelected(node)}\n indeterminate={isIndeterminate(node)}\n {...getCascaderMoreProps(node, loadStates)}\n showPath={showPath}\n aria-setsize={flat ? flat.setSize : count}\n aria-posinset={flat ? flat.posInSet : row.index + 1}\n />\n );\n })}\n </>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Column */\n/* -------------------------------------------------------------------------- */\n\nexport interface CascaderVirtualColumnProps extends CascaderVirtualItemsProps {\n column: CascaderColumn;\n}\n\n/**\n * Windowed replacement for one Miller column, passed through the\n * `CascaderColumns` render slot. One virtualizer PER COLUMN, since columns\n * scroll independently, and only the deepest is Base UI's listbox: the trail\n * behind is `as=\"button\"` rows outside Base UI, so it windows on its own row\n * count rather than waiting for the root to flip.\n */\nfunction CascaderVirtualColumn({ column, estimateSize, overscan }: CascaderVirtualColumnProps) {\n const { virtualized, registerVirtualRenderer, virtualize, virtualizeThreshold } =\n useCascaderActions();\n\n React.useLayoutEffect(() => registerVirtualRenderer(), [registerVirtualRenderer]);\n\n const windowed = column.active\n ? virtualized\n : (virtualize ?? column.items.length >= virtualizeThreshold);\n\n if (!windowed) return <CascaderColumnPanel column={column} />;\n\n return (\n <CascaderColumnPanel column={column} virtualized>\n {column.active ? (\n <CascaderVirtualActiveColumnRows\n column={column}\n estimateSize={estimateSize}\n overscan={overscan}\n />\n ) : (\n <CascaderVirtualColumnRows\n column={column}\n estimateSize={estimateSize}\n overscan={overscan}\n activeIndex={-1}\n />\n )}\n </CascaderColumnPanel>\n );\n}\n\n/** Only the active column subscribes to the highlight; a trail column must not. */\nfunction CascaderVirtualActiveColumnRows(props: CascaderVirtualColumnProps) {\n const highlight = useCascaderHighlight();\n return <CascaderVirtualColumnRows {...props} activeIndex={highlight.index} />;\n}\n\nfunction CascaderVirtualColumnRows({\n column,\n estimateSize,\n overscan,\n activeIndex,\n}: CascaderVirtualColumnProps & { activeIndex: number }) {\n const {\n estimateRowSize,\n overscan: rootOverscan,\n baseId,\n isBranch,\n isSelectable,\n isSelected,\n isIndeterminate,\n } = useCascaderActions();\n const { loadStates } = useCascaderState();\n\n const [contentElement, setContentElement] = React.useState<HTMLElement | null>(null);\n const gutter = useCascaderVirtualGutter(contentElement);\n\n const items = column.items;\n const getItemKey = React.useCallback((index: number) => items[index]?.value ?? index, [items]);\n\n const virtualizer = useCascaderVirtualizer({\n count: items.length,\n getScrollElement: () => cascaderScrollElement(contentElement),\n estimateSize: estimateSize ?? estimateRowSize,\n overscan: overscan ?? rootOverscan,\n getItemKey,\n activeIndex,\n });\n\n return (\n <>\n <CascaderVirtualSpacer\n height={virtualizer.getTotalSize()}\n onContentElement={setContentElement}\n />\n {virtualizer.getVirtualItems().map((row) => {\n const node = items[row.index];\n if (!node) return null;\n const open = node.value === column.activeValue;\n\n return (\n <CascaderItem\n key={row.key}\n ref={virtualizer.measureElement}\n data-index={row.index}\n style={cascaderVirtualRowStyle(row.start, gutter)}\n node={node}\n as={column.active ? \"option\" : \"button\"}\n depth={column.depth}\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 /* Only the listbox column may carry an index or listbox metadata.\n A trail row is a `role=\"button\"`, which allows neither. */\n {...(column.active\n ? {\n index: row.index,\n \"aria-setsize\": items.length,\n \"aria-posinset\": row.index + 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}\n\nexport { CascaderVirtualColumn, CascaderVirtualItems };\n"],"mappings":";;;;;;;;;;;;;;AAsDA,SAAgB,uBAAuB,EACrC,OACA,kBACA,eAAe,IACf,WAAW,GACX,YACA,cAAc,MACuC;CACrD,MAAM,SAAS,eAAe,KAAK,cAAc,QAAQ,cAAc;CAGvE,MAAM,iBAAiBA,QAAM,aAC1B,UAAiB;EAChB,MAAM,UAAU,IAAI,IAAI,sBAAsB,KAAK,CAAC;EACpD,IAAI,WAAW,IAAI,QAAQ,IAAI,MAAM;EACrC,OAAO,MAAM,KAAK,OAAO,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC;CACjD,GACA,CAAC,MAAM,CACT;CAEA,MAAM,kBAAkBA,QAAM,kBAAkB,cAAc,CAAC,YAAY,CAAC;CAI5E,MAAM,cAAc,eAAyC;EAC3D;EACA;EACA,cAAc;EACd;EACA;EACA;CACF,CAAC;CAGD,QAAM,gBAAgB;EACpB,IAAI,WAAW,IAAI;EACnB,YAAY,cAAc,QAAQ,EAAE,OAAO,OAAO,CAAC;CACrD,GA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AA,YAAA,EAAA,UAAA,CACE,oBAAC,uBAAD;EACE,QAAQ,YAAY,aAAa;EACjC,kBAAkB;CACnB,CAAA,GACA,YAAY,gBAAgB,CAAC,CAAC,KAAK,QAAQ;EAC1C,MAAM,OAAO,MAAM,IAAI;EACvB,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,OAAO,KAAK,UAAU,OAAO;EAEnC,OACE,oBAAC,cAAD;GAEE,KAAK,YAAY;GACjB,cAAY,IAAI;GAChB,OAAO,wBAAwB,IAAI,OAAO,MAAM;GAC1C;GACN,IAAI,OAAO,SAAS,WAAW;GAC/B,OAAO,OAAO;GACd,QAAQ,SAAS,IAAI;GACrB,YAAY,aAAa,IAAI;GAC7B,UAAU,WAAW,IAAI;GACzB,eAAe,gBAAgB,IAAI;GACnC,GAAI,qBAAqB,MAAM,UAAU;GACzC,aAAW,QAAQ,KAAA;GACnB,WAAW,OAAO,wCAAwC,KAAA;GAG1D,GAAK,OAAO,SACR;IACE,OAAO,IAAI;IACX,gBAAgB,MAAM;IACtB,iBAAiB,IAAI,QAAQ;GAC/B,IACA;GACJ,GAAK,CAAC,OAAO,UAAU,OACnB;IACE,iBAAiB;IACjB,iBAAiB,GAAG,OAAO,UAAU,OAAO,QAAQ;GACtD,IACA;EACL,GA7BM,IAAI,GA6BV;CAEL,CAAC,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { _ as CascaderSelectable, f as CascaderMode, g as CascaderSearchScope, n as CascaderChangeDetails, p as CascaderNode, s as CascaderLabels, t as CascaderActionItem } from "../../../cascader-types-BnH6wYD-.js";
|
|
2
|
+
import { CascaderGetChildren, CascaderOnSearch, CascaderResolveValue } from "./cascader-async.js";
|
|
3
|
+
import { CascaderActionsContextValue, CascaderColumn, CascaderHighlight, CascaderHighlightStore, CascaderItemState, CascaderRenderContextValue, CascaderStateContextValue, createCascaderHighlightStore, useCascaderActions, useCascaderHighlight, useCascaderRender, useCascaderState } from "./cascader-context.js";
|
|
4
|
+
import { CascaderCheckedStrategy } from "./cascader-lib.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
+
import { Combobox } from "@base-ui/react";
|
|
8
|
+
//#region src/components/reui/cascader/cascader.d.ts
|
|
9
|
+
/** The pre-split shape, merged, so `useCascader()` returns what it always did. */
|
|
10
|
+
interface CascaderContextValue<T = unknown> extends CascaderActionsContextValue<T>, CascaderStateContextValue<T> {}
|
|
11
|
+
/**
|
|
12
|
+
* The cascader's internals, typed for the caller's own item payload.
|
|
13
|
+
* @deprecated Reads BOTH halves, so a caller re-renders on every keystroke.
|
|
14
|
+
* Prefer `useCascaderActions()` or `useCascaderState()`. Kept for compat.
|
|
15
|
+
*/
|
|
16
|
+
declare function useCascader<T = unknown>(): CascaderContextValue<T>;
|
|
17
|
+
interface CascaderSelection<T = unknown> {
|
|
18
|
+
/** The selected nodes, resolved. Empty when nothing is selected. */
|
|
19
|
+
selected: CascaderNode<T>[];
|
|
20
|
+
/** Ancestor chain per selected node, root first, node last. */
|
|
21
|
+
paths: CascaderNode<T>[][];
|
|
22
|
+
/** The single selection, or the first one in `multiple` mode. */
|
|
23
|
+
first: CascaderNode<T> | null;
|
|
24
|
+
/** Ancestor chain of `first`. */
|
|
25
|
+
firstPath: CascaderNode<T>[];
|
|
26
|
+
count: number;
|
|
27
|
+
isEmpty: boolean;
|
|
28
|
+
multiple: boolean;
|
|
29
|
+
remove: (value: string) => void;
|
|
30
|
+
clear: () => void;
|
|
31
|
+
}
|
|
32
|
+
/** Headless access to the selection, for a trigger that is not
|
|
33
|
+
* `CascaderValue`. Pass the payload explicitly to get `node.data` typed. */
|
|
34
|
+
declare function useCascaderSelection<T = unknown>(): CascaderSelection<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Why the navigation path changed.
|
|
37
|
+
* - `"drill"`: a branch was entered (row press, level arrow, deep-search hit).
|
|
38
|
+
* - `"back"`: one level up (back control, Backspace on an empty query).
|
|
39
|
+
* - `"breadcrumb"`: a jump to an exact depth in the trail.
|
|
40
|
+
* - `"reveal"`: the reopen navigated to the level holding the selection.
|
|
41
|
+
* - `"external"`: `setPath` called from outside the primitive's own flows.
|
|
42
|
+
*/
|
|
43
|
+
type CascaderPathChangeReason = "drill" | "back" | "breadcrumb" | "reveal" | "external";
|
|
44
|
+
/** Everything independent of the selection mode; the rest is on the two arms. */
|
|
45
|
+
interface CascaderBaseProps<T = unknown> {
|
|
46
|
+
/** Nested tree, or a flat list when `getParent` is supplied. */
|
|
47
|
+
items: CascaderNode<T>[];
|
|
48
|
+
/** Opt in to flat adjacency input by returning each node's parent value. */
|
|
49
|
+
getParent?: (node: CascaderNode<T>) => string | null | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Fetches one level on demand; `node` is `null` for the root. Return an
|
|
52
|
+
* array, or a `CascaderLoadResult` when the level pages. Pages cache apart
|
|
53
|
+
* from `items`; mark unfetched branches `hasChildren` or they read as leaves.
|
|
54
|
+
*/
|
|
55
|
+
getChildren?: CascaderGetChildren<T>;
|
|
56
|
+
/**
|
|
57
|
+
* Server-side search, debounced by `searchDebounce`; replaces the local scan
|
|
58
|
+
* while the query is set. Results are detached: resolvable by value, in no
|
|
59
|
+
* level. Ignored in `mode="tree"`, where a hit belongs to no visible branch.
|
|
60
|
+
*/
|
|
61
|
+
onSearch?: CascaderOnSearch<T>;
|
|
62
|
+
/** Milliseconds of quiet before `onSearch` fires. */
|
|
63
|
+
searchDebounce?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Resolves a value the loader has never seen into its ancestor chain, root
|
|
66
|
+
* first, so the trigger can path a server-supplied selection. Does NOT mark
|
|
67
|
+
* those levels loaded: opening one still fetches.
|
|
68
|
+
*/
|
|
69
|
+
resolveValue?: CascaderResolveValue<T>;
|
|
70
|
+
/** Cache key. Changing it drops every page and aborts anything in flight. */
|
|
71
|
+
loadKey?: unknown;
|
|
72
|
+
/** Prefetch a highlighted branch's children after a pause. Off by default. */
|
|
73
|
+
prefetch?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Called when a load fails. `context.parent` is the level (`null` for root);
|
|
76
|
+
* `context.reason` is `"level"`, `"more"`, `"retry"`, `"prefetch"`,
|
|
77
|
+
* `"search"` or `"resolve"`. Never for an aborted or superseded request.
|
|
78
|
+
*/
|
|
79
|
+
onLoadError?: (error: unknown, context: {
|
|
80
|
+
parent: string | null;
|
|
81
|
+
reason: string;
|
|
82
|
+
}) => void;
|
|
83
|
+
/** Which nodes may be committed. Defaults to leaves only. */
|
|
84
|
+
selectable?: CascaderSelectable<T>;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the built-in SINGLE-SELECT check is drawn. Defaults to true.
|
|
87
|
+
* `false` also gives back the inline-end gutter every style reserves for it;
|
|
88
|
+
* `data-selected` and `aria-selected` stay. A no-op under `multiple`, where
|
|
89
|
+
* the checkbox is the selection CONTROL rather than a decoration.
|
|
90
|
+
*/
|
|
91
|
+
indicator?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Footer ACTIONS: commands pinned below the list, never rows in it, and never
|
|
94
|
+
* touching the data tree. A childless `<CascaderFooter />` draws these; an
|
|
95
|
+
* action with `items` opens a side-anchored flyout rather than firing.
|
|
96
|
+
*/
|
|
97
|
+
actions?: CascaderActionItem[];
|
|
98
|
+
/**
|
|
99
|
+
* Parent/child cascading. Multi-select only, off by default, and it needs
|
|
100
|
+
* committable branches (`selectable="any"` or a predicate). A commit selects
|
|
101
|
+
* or deselects every SELECTABLE node in the LOADED subtree and reconciles
|
|
102
|
+
* ancestors. LOADED is the semantic, not a hedge: a commit must not fan out
|
|
103
|
+
* into a request per level, so children arriving later arrive unchecked.
|
|
104
|
+
*/
|
|
105
|
+
cascade?: boolean;
|
|
106
|
+
mode?: CascaderMode;
|
|
107
|
+
/** How a branch opens from the pointer in columns mode's ACTIVE column.
|
|
108
|
+
* `"click"` is the default, and neither value ever commits a selection. */
|
|
109
|
+
expandTrigger?: "click" | "hover";
|
|
110
|
+
path?: string[];
|
|
111
|
+
defaultPath?: string[];
|
|
112
|
+
/** The second argument says WHY. An existing `(path) => void` still works. */
|
|
113
|
+
onPathChange?: (path: string[], details: {
|
|
114
|
+
reason: CascaderPathChangeReason;
|
|
115
|
+
}) => void;
|
|
116
|
+
expanded?: string[];
|
|
117
|
+
defaultExpanded?: string[];
|
|
118
|
+
onExpandedChange?: (expanded: string[]) => void;
|
|
119
|
+
open?: boolean;
|
|
120
|
+
defaultOpen?: boolean;
|
|
121
|
+
/** Forwards Base UI's reason; a leaf commit's close says `"item-press"`. */
|
|
122
|
+
onOpenChange?: (open: boolean, details: {
|
|
123
|
+
reason: string;
|
|
124
|
+
}) => void;
|
|
125
|
+
/**
|
|
126
|
+
* Whether a SINGLE-SELECT leaf commit closes the popup. Defaults to true.
|
|
127
|
+
* `false` is for a compare-and-repick flow; Escape, outside press and the
|
|
128
|
+
* trigger still close. Ignored under `multiple`, which never closes.
|
|
129
|
+
*/
|
|
130
|
+
closeOnSelect?: boolean;
|
|
131
|
+
inputValue?: string;
|
|
132
|
+
defaultInputValue?: string;
|
|
133
|
+
onInputValueChange?: (value: string) => void;
|
|
134
|
+
searchScope?: CascaderSearchScope;
|
|
135
|
+
/** Custom matcher, replacing label + keywords substring matching. */
|
|
136
|
+
filter?: (node: CascaderNode<T>, normalizedQuery: string) => boolean;
|
|
137
|
+
/** On open, navigate to the level holding the selection. Default true. */
|
|
138
|
+
revealSelected?: boolean;
|
|
139
|
+
maxHeight?: number | string;
|
|
140
|
+
/**
|
|
141
|
+
* Window the rendered rows. `undefined` decides per level from
|
|
142
|
+
* `virtualizeThreshold`; `true`/`false` force it. Also opt-in at the markup
|
|
143
|
+
* level, so the base install pulls in no virtualization library.
|
|
144
|
+
*/
|
|
145
|
+
virtualize?: boolean;
|
|
146
|
+
/** Row count at which windowing turns itself on. */
|
|
147
|
+
virtualizeThreshold?: number;
|
|
148
|
+
/** Row height handed to the virtualizer before a row has been measured. */
|
|
149
|
+
estimateRowSize?: number;
|
|
150
|
+
/** Rows rendered beyond each edge of the viewport. */
|
|
151
|
+
overscan?: number;
|
|
152
|
+
labels?: Partial<CascaderLabels>;
|
|
153
|
+
/** Replaces the entire row, affordances included. */
|
|
154
|
+
renderItem?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React$1.ReactNode;
|
|
155
|
+
/** Replaces only the label block; icon, count, chevron and check stay. */
|
|
156
|
+
renderLabel?: (node: CascaderNode<T>, state: CascaderItemState<T>) => React$1.ReactNode;
|
|
157
|
+
disabled?: boolean;
|
|
158
|
+
/** Native form field name. Submits the selected value(s). */
|
|
159
|
+
name?: string;
|
|
160
|
+
/** Id of the owning form, for a cascader rendered outside it. */
|
|
161
|
+
form?: string;
|
|
162
|
+
/** Id of the control. Pairs the field with a `<label htmlFor>`. */
|
|
163
|
+
id?: string;
|
|
164
|
+
/** Marks the field required for native form validation. */
|
|
165
|
+
required?: boolean;
|
|
166
|
+
/** The value can be read and submitted, but not changed. */
|
|
167
|
+
readOnly?: boolean;
|
|
168
|
+
/** Marks the field invalid: `aria-invalid` and `data-invalid` on the trigger,
|
|
169
|
+
* the chips and the input, which every style's error treatment reads. */
|
|
170
|
+
invalid?: boolean;
|
|
171
|
+
/** Ref to the hidden input Base UI submits with, for form-library focus. */
|
|
172
|
+
inputRef?: React$1.Ref<HTMLInputElement>;
|
|
173
|
+
/** Renders without a floating popup, for an embedded `CascaderPanel`. */
|
|
174
|
+
inline?: boolean;
|
|
175
|
+
children?: React$1.ReactNode;
|
|
176
|
+
}
|
|
177
|
+
interface CascaderSingleProps<T = unknown> extends CascaderBaseProps<T> {
|
|
178
|
+
multiple?: false;
|
|
179
|
+
value?: string;
|
|
180
|
+
defaultValue?: string;
|
|
181
|
+
onValueChange?: (value: string, details: CascaderChangeDetails<T>) => void;
|
|
182
|
+
/** `never` so passing it is a compile error, not a silent no-op. */
|
|
183
|
+
max?: never;
|
|
184
|
+
}
|
|
185
|
+
/** Multi-select props. Enables checkbox rows and chip display. */
|
|
186
|
+
interface CascaderMultipleProps<T = unknown> extends CascaderBaseProps<T> {
|
|
187
|
+
multiple: true;
|
|
188
|
+
value?: string[];
|
|
189
|
+
defaultValue?: string[];
|
|
190
|
+
onValueChange?: (value: string[], details: CascaderChangeDetails<T>) => void;
|
|
191
|
+
/** Cap on selections. Further picks are refused, the existing ones survive. */
|
|
192
|
+
max?: number;
|
|
193
|
+
}
|
|
194
|
+
/** `multiple` discriminates: `value`, `onValueChange` and `max` narrow with it. */
|
|
195
|
+
type CascaderProps<T = unknown> = CascaderSingleProps<T> | CascaderMultipleProps<T>;
|
|
196
|
+
/** No default on `T`: inferred from `items`, so `node.data` arrives typed. */
|
|
197
|
+
declare function Cascader<T>({ items, getParent, getChildren, onSearch, searchDebounce, resolveValue, loadKey, prefetch, onLoadError, value: valueProp, defaultValue, onValueChange: onValueChangeProp, multiple, selectable, indicator, actions, cascade, max, mode, expandTrigger, path: pathProp, defaultPath, onPathChange, expanded: expandedProp, defaultExpanded, onExpandedChange, open: openProp, defaultOpen, onOpenChange, closeOnSelect, inputValue: inputValueProp, defaultInputValue, onInputValueChange, searchScope, filter, revealSelected, maxHeight, virtualize, virtualizeThreshold, estimateRowSize, overscan, labels: labelsProp, renderItem, renderLabel, disabled, name, form, id, required, readOnly, invalid, inputRef, inline, children }: CascaderProps<T>): React$1.JSX.Element;
|
|
198
|
+
/** `Trigger.Props` stops short of `ref`, so it is intersected in, as the
|
|
199
|
+
* shadcn combobox wrapper also does: a form library needs a ref here, and
|
|
200
|
+
* `onBlur`, the "touched" signal, lands here too. */
|
|
201
|
+
interface CascaderTriggerProps extends Combobox.Trigger.Props, Pick<React$1.ComponentPropsWithRef<"button">, "ref"> {
|
|
202
|
+
/** Hides the trailing chevron, for a trigger that supplies its own. */
|
|
203
|
+
showIcon?: boolean;
|
|
204
|
+
}
|
|
205
|
+
declare function CascaderTrigger({ className, children, showIcon, ref, ...props }: CascaderTriggerProps): React$1.JSX.Element;
|
|
206
|
+
/** Ref for the chips container: they replace the trigger, so the popup has to
|
|
207
|
+
* be anchored to them. Hand it to `CascaderContent`'s `anchor`. */
|
|
208
|
+
declare function useCascaderAnchor(): React$1.RefObject<HTMLDivElement | null>;
|
|
209
|
+
interface CascaderChipsProps extends Omit<Combobox.Chips.Props, "children">, Pick<React$1.ComponentPropsWithRef<"div">, "ref"> {
|
|
210
|
+
/** Shown in place of the chips when nothing is selected. */
|
|
211
|
+
placeholder?: React$1.ReactNode;
|
|
212
|
+
/**
|
|
213
|
+
* How a `cascade` selection is condensed into chips. DISPLAY ONLY: the
|
|
214
|
+
* stored value stays the full closure, which keeps a row's checked state an
|
|
215
|
+
* O(1) lookup. `"all"` (default) is one chip per value, `"parent"` collapses
|
|
216
|
+
* a fully selected branch, `"child"` chips only the deepest frontier.
|
|
217
|
+
* Removing a condensed chip removes its whole closure and reconciles.
|
|
218
|
+
*/
|
|
219
|
+
strategy?: CascaderCheckedStrategy;
|
|
220
|
+
/** Replaces the chip list, receiving the resolved selection IN SELECTION
|
|
221
|
+
* ORDER. Keep that order: Base UI removes a chip by sibling position. */
|
|
222
|
+
children?: React$1.ReactNode | ((nodes: CascaderNode[]) => React$1.ReactNode);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* The multi-select trigger surface: one removable chip per selection, where
|
|
226
|
+
* `CascaderValue` would collapse to "3 selected". A component rather than a
|
|
227
|
+
* recipe because of three easy misses: the popup anchored to the chips, an
|
|
228
|
+
* accessible name on every remove button, and labels that disambiguate when
|
|
229
|
+
* two branches use the same one.
|
|
230
|
+
*
|
|
231
|
+
* ```tsx
|
|
232
|
+
* const anchor = useCascaderAnchor()
|
|
233
|
+
* <Cascader multiple items={items}>
|
|
234
|
+
* <CascaderChips ref={anchor} placeholder="Select attributes" />
|
|
235
|
+
* <CascaderContent anchor={anchor}>...</CascaderContent>
|
|
236
|
+
* </Cascader>
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
declare function CascaderChips({ className, children, placeholder, strategy, ...props }: CascaderChipsProps): React$1.JSX.Element;
|
|
240
|
+
interface CascaderChipProps extends Omit<Combobox.Chip.Props, "children"> {
|
|
241
|
+
node: CascaderNode;
|
|
242
|
+
/** Prefix the label with its ancestor trail. */
|
|
243
|
+
showPath?: boolean;
|
|
244
|
+
/** Trail segments to show, the node itself included. */
|
|
245
|
+
maxSegments?: number;
|
|
246
|
+
/** Hides the remove button, for a read-only chip. */
|
|
247
|
+
showRemove?: boolean;
|
|
248
|
+
/** Replaces Base UI's positional removal for this chip (remove button and
|
|
249
|
+
* Backspace/Delete). Supplied for a `strategy`-condensed chip, whose
|
|
250
|
+
* position no longer maps onto the stored array. */
|
|
251
|
+
onRemove?: () => void;
|
|
252
|
+
/** Replaces the chip's label. The remove button is still rendered. */
|
|
253
|
+
children?: React$1.ReactNode;
|
|
254
|
+
}
|
|
255
|
+
/** One chip. Removal goes through Base UI's `ChipRemove`, which reports the
|
|
256
|
+
* shortened selection to the root, so it lands in the same `setSelection` as
|
|
257
|
+
* every other deselection and `cascade` applies to it. */
|
|
258
|
+
declare function CascaderChip({ className, node, showPath, maxSegments, showRemove, onRemove, children, ...props }: CascaderChipProps): React$1.JSX.Element;
|
|
259
|
+
interface CascaderContentProps extends Combobox.Popup.Props,
|
|
260
|
+
/** Positioner surface forwarded as-is, so an unusual anchor does not force
|
|
261
|
+
* a rebuild of the content stack. No `trackAnchor`: Base UI 1.5.0 has
|
|
262
|
+
* none. */
|
|
263
|
+
Pick<Combobox.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset" | "anchor" | "collisionBoundary" | "collisionPadding" | "sticky" | "positionMethod">,
|
|
264
|
+
/** Where the portal mounts, for a shadow root or a scoped stacking context. */
|
|
265
|
+
Pick<Combobox.Portal.Props, "container"> {}
|
|
266
|
+
/** Portal + Positioner + floating panel. Unlike shadcn's `ComboboxContent` it
|
|
267
|
+
* does NOT clamp the popup to the anchor width (a cascader panel is routinely
|
|
268
|
+
* wider), but it keeps `group/combobox-content`, which `CascaderEmpty` needs. */
|
|
269
|
+
declare function CascaderContent({ className, side, sideOffset, align, alignOffset, anchor, collisionBoundary, collisionPadding, sticky, positionMethod, container, ref, ...props }: CascaderContentProps): React$1.JSX.Element;
|
|
270
|
+
type CascaderPanelProps = useRender.ComponentProps<"div">;
|
|
271
|
+
/**
|
|
272
|
+
* The nav + list(s) + footer container, with no positioning of its own: inside
|
|
273
|
+
* `CascaderContent` for the popup case, alone for the embedded one.
|
|
274
|
+
*
|
|
275
|
+
* `min-h-0` and `max-h-full` are load-bearing. A flex child without `min-h-0`
|
|
276
|
+
* refuses to shrink below its content, which is the usual reason a scroll area
|
|
277
|
+
* never scrolls - worst embedded, where no positioner publishes
|
|
278
|
+
* `--available-height`. It also owns the panel's TAB ORDER: the scroll area
|
|
279
|
+
* makes itself a tab stop whenever the level overflows, stranding the footer,
|
|
280
|
+
* and the panel is the only ancestor of both ends of that move in BOTH shapes.
|
|
281
|
+
*/
|
|
282
|
+
declare function CascaderPanel({ className, ...props }: CascaderPanelProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
|
|
283
|
+
interface CascaderListProps extends Omit<Combobox.List.Props, "style"> {
|
|
284
|
+
/** Applied to the OUTER shell, which owns the height, so an inline
|
|
285
|
+
* `--cascader-max-height` lands where the bound can read it. Narrowed from
|
|
286
|
+
* Base UI's `style`: the shell is a plain `<div>` with no list state. */
|
|
287
|
+
style?: React$1.CSSProperties;
|
|
288
|
+
/** Caps this level's height; the panel still shrinks to fit. Default 24rem. */
|
|
289
|
+
maxHeight?: number | string;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Scroll container for one level: pattern 3 of the house scroll reference,
|
|
293
|
+
* viewport-bounded popup scroll. The height is `min()` of `--available-height`
|
|
294
|
+
* (the positioner's space between anchor and viewport edge) and `maxHeight`,
|
|
295
|
+
* so neither can be ignored; a fixed pixel cap alone still reserved 288px for
|
|
296
|
+
* a panel opened 200px above the fold and spilled off screen, and wasted room
|
|
297
|
+
* in a tall window. The four classes are shared with `CascaderColumns` and
|
|
298
|
+
* live in `cascader-lib.tsx`.
|
|
299
|
+
*/
|
|
300
|
+
declare function CascaderList({ className, style, maxHeight: maxHeightProp, ...props }: CascaderListProps): React$1.JSX.Element;
|
|
301
|
+
interface CascaderEmptyProps extends Combobox.Empty.Props {
|
|
302
|
+
/** @deprecated Ignored: the loading surface no longer draws skeletons. They
|
|
303
|
+
* promised a shape the level might not have and cost a second layout; the
|
|
304
|
+
* progress lives on the branch row instead. Kept so call sites compile. */
|
|
305
|
+
skeletonRows?: number;
|
|
306
|
+
}
|
|
307
|
+
/** The empty, loading and error surface, in ONE element that never unmounts.
|
|
308
|
+
* `Combobox.Empty` renders whenever `filteredItems.length === 0`, as true of a
|
|
309
|
+
* fetching level as of an empty one, so swapping siblings would announce "No
|
|
310
|
+
* results found." over every async level. Swap the CHILDREN. */
|
|
311
|
+
declare function CascaderEmpty({ className, children, skeletonRows, ...props }: CascaderEmptyProps): React$1.JSX.Element;
|
|
312
|
+
type CascaderStatusProps = Combobox.Status.Props;
|
|
313
|
+
/**
|
|
314
|
+
* Polite live region for the current level and result count, which drill-down
|
|
315
|
+
* otherwise hides in a visual breadcrumb. Built on `Combobox.Status` for its
|
|
316
|
+
* initial-mutation marker: Safari and VoiceOver need a text change ~200ms
|
|
317
|
+
* after mount before reading a polite region at all.
|
|
318
|
+
*/
|
|
319
|
+
declare function CascaderStatus({ className, children, ...props }: CascaderStatusProps): React$1.JSX.Element;
|
|
320
|
+
//#endregion
|
|
321
|
+
export { Cascader, type CascaderActionsContextValue, CascaderBaseProps, CascaderChip, CascaderChipProps, CascaderChips, CascaderChipsProps, type CascaderColumn, CascaderContent, CascaderContentProps, CascaderContextValue, CascaderEmpty, CascaderEmptyProps, type CascaderHighlight, type CascaderHighlightStore, type CascaderItemState, CascaderList, CascaderListProps, CascaderMultipleProps, CascaderPanel, CascaderPanelProps, CascaderPathChangeReason, CascaderProps, type CascaderRenderContextValue, CascaderSelection, CascaderSingleProps, type CascaderStateContextValue, CascaderStatus, CascaderStatusProps, CascaderTrigger, CascaderTriggerProps, createCascaderHighlightStore, useCascader, useCascaderActions, useCascaderAnchor, useCascaderHighlight, useCascaderRender, useCascaderSelection, useCascaderState };
|
|
322
|
+
//# sourceMappingURL=cascader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cascader.d.ts","names":[],"sources":["../../../../src/components/reui/cascader/cascader.tsx"],"mappings":";;;;;;;;;UA2MiB,qBAAqB,qBAC5B,4BAA4B,IAClC,0BAA0B;;;;;;iBAOd,YAAY,gBAAgB,qBAAqB;UAWhD,kBAAkB;;EAEjC,UAAU,aAAa;;EAEvB,OAAO,aAAa;;EAEpB,OAAO,aAAa;;EAEpB,WAAW,aAAa;EACxB;EACA;EACA;EACA,SAAS;EACT;;;;iBAKc,qBAAqB,gBAAgB,kBAAkB;;;;;;;;;KAqC3D;;UAGK,kBAAkB;;EAEjC,OAAO,aAAa;;EAEpB,aAAa,MAAM,aAAa;;;;;;EAOhC,cAAc,oBAAoB;;;;;;EAMlC,WAAW,iBAAiB;;EAE5B;;;;;;EAMA,eAAe,qBAAqB;;EAEpC;;EAEA;;;;;;EAMA,eAAe,gBAAgB;IAAW;IAAuB;;;EAGjE,aAAa,mBAAmB;;;;;;;EAQhC;;;;;;EAOA,UAAU;;;;;;;;EASV;EAEA,OAAO;;;EAIP;EAEA;EACA;;EAEA,gBAAgB,gBAAgB;IAAW,QAAQ;;EAEnD;EACA;EACA,oBAAoB;EAEpB;EACA;;EAEA,gBAAgB,eAAe;IAAW;;;;;;;EAO1C;EAEA;EACA;EACA,sBAAsB;EAEtB,cAAc;;EAEd,UAAU,MAAM,aAAa,IAAI;;EAGjC;EAEA;;;;;;EAOA;;EAEA;;EAEA;;EAEA;EAEA,SAAS,QAAQ;;EAEjB,cAAc,MAAM,aAAa,IAAI,OAAO,kBAAkB,OAAO,QAAM;;EAE3E,eAAe,MAAM,a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