@1771technologies/lytenyte-pro 0.0.39
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/LICENSE +15 -0
- package/dist/DialogPortalContext-C2WZTqJ3.js +47 -0
- package/dist/InternalBackdrop-Dm9czgoC.js +6746 -0
- package/dist/MenuRoot-9n64jNWP.js +724 -0
- package/dist/anchor-context-B9sGQdR5.js +35 -0
- package/dist/arrow-down-icon-B-3ldODD.js +27 -0
- package/dist/arrow-svg-evmXDI_J.js +29 -0
- package/dist/column-manager.js +1241 -0
- package/dist/cross-icon-CEMLAlFX.js +20 -0
- package/dist/dialog.js +506 -0
- package/dist/filter-manager.js +1056 -0
- package/dist/getPseudoElementBounds-BSHt6WYm.js +26 -0
- package/dist/grid-container.js +18 -0
- package/dist/icons.js +512 -0
- package/dist/index.js +3730 -0
- package/dist/lytenyte-pro.css +1948 -0
- package/dist/manage-columns-icon-D4CElo5H.js +146 -0
- package/dist/menu.js +1639 -0
- package/dist/pill-C4Jhdf8E.js +985 -0
- package/dist/pill-manager.js +674 -0
- package/dist/plus-icon-ToqW5CC-.js +15 -0
- package/dist/popover.js +770 -0
- package/dist/row-group-icon-BOOju5Vu.js +205 -0
- package/dist/search-icon-CcG1lqsn.js +86 -0
- package/dist/select-C6xOZZLq.js +2231 -0
- package/dist/sort-manager.js +298 -0
- package/dist/tickmark-icon-CoogRMoO.js +51 -0
- package/dist/types/cell-selection/cell-selection-containers.d.ts +3 -0
- package/dist/types/cell-selection/cell-selection-driver.d.ts +1 -0
- package/dist/types/cell-selection/cell-style-row.d.ts +8 -0
- package/dist/types/column-manager/column-manager-drag-box-controls.d.ts +1 -0
- package/dist/types/column-manager/column-manager-drag-box-expander.d.ts +1 -0
- package/dist/types/column-manager/column-manager-drag-box-label.d.ts +5 -0
- package/dist/types/column-manager/column-manager-drag-box.d.ts +13 -0
- package/dist/types/column-manager/column-manager-drag-placeholder.d.ts +5 -0
- package/dist/types/column-manager/column-manager-drop-zone.d.ts +10 -0
- package/dist/types/column-manager/column-manager-impl.d.ts +36 -0
- package/dist/types/column-manager/column-manager-pill.d.ts +4 -0
- package/dist/types/column-manager/column-manager-pivot-mode-toggle.d.ts +1 -0
- package/dist/types/column-manager/column-manager-search.d.ts +1 -0
- package/dist/types/column-manager/column-manager-state.d.ts +8 -0
- package/dist/types/column-manager/column-manager-tree-item.d.ts +6 -0
- package/dist/types/column-manager/column-manager-tree.d.ts +11 -0
- package/dist/types/column-manager/column-manager-types.d.ts +1 -0
- package/dist/types/column-manager/column-manager.d.ts +1 -0
- package/dist/types/column-manager/column-mananger-context.d.ts +12 -0
- package/dist/types/column-manager/utils/all-leafs.d.ts +3 -0
- package/dist/types/column-manager/utils/can-hide-item.d.ts +3 -0
- package/dist/types/column-manager/utils/handle-item-hide.d.ts +3 -0
- package/dist/types/components-internal/button/button.d.ts +9 -0
- package/dist/types/components-internal/grid-frame/grid-frame.d.ts +11 -0
- package/dist/types/components-internal/radio/radio.d.ts +5 -0
- package/dist/types/components-internal/separator/separator.d.ts +8 -0
- package/dist/types/components-internal/toggle/toggle.d.ts +7 -0
- package/dist/types/dialog/dialog-driver.d.ts +1 -0
- package/dist/types/dialog/dialog-impl.d.ts +6 -0
- package/dist/types/dialog/dialog.d.ts +8 -0
- package/dist/types/dialog/use-dialog-class.d.ts +1 -0
- package/dist/types/external.d.ts +2 -0
- package/dist/types/filter-manager/combined-to-flat.d.ts +3 -0
- package/dist/types/filter-manager/components/apply-filter-button.d.ts +1 -0
- package/dist/types/filter-manager/components/clear-filter-button.d.ts +1 -0
- package/dist/types/filter-manager/components/flatten-tree-items.d.ts +4 -0
- package/dist/types/filter-manager/components/get-child-values.d.ts +2 -0
- package/dist/types/filter-manager/components/in-filter-container.d.ts +1 -0
- package/dist/types/filter-manager/components/in-filter-error.d.ts +5 -0
- package/dist/types/filter-manager/components/in-filter-loading.d.ts +1 -0
- package/dist/types/filter-manager/components/in-filter-root.d.ts +11 -0
- package/dist/types/filter-manager/components/in-filter-tree.d.ts +15 -0
- package/dist/types/filter-manager/components/simple-filter-additional-switch.d.ts +1 -0
- package/dist/types/filter-manager/components/simple-filter-operator/date-operator.d.ts +1 -0
- package/dist/types/filter-manager/components/simple-filter-operator/number-operator.d.ts +1 -0
- package/dist/types/filter-manager/components/simple-filter-operator/simple-filter-operator.d.ts +1 -0
- package/dist/types/filter-manager/components/simple-filter-operator/text-operator.d.ts +1 -0
- package/dist/types/filter-manager/components/simple-filter-root.d.ts +9 -0
- package/dist/types/filter-manager/components/simple-filter-value/date-value.d.ts +1 -0
- package/dist/types/filter-manager/components/simple-filter-value/number-value.d.ts +1 -0
- package/dist/types/filter-manager/components/simple-filter-value/simple-filter-value.d.ts +1 -0
- package/dist/types/filter-manager/components/simple-filter-value/text-value.d.ts +1 -0
- package/dist/types/filter-manager/components/use-date-filter-callbacks.d.ts +9 -0
- package/dist/types/filter-manager/components/use-in-filter-item-loader.d.ts +7 -0
- package/dist/types/filter-manager/components/use-number-filter-callbacks.d.ts +8 -0
- package/dist/types/filter-manager/components/use-text-filter-callbacks.d.ts +8 -0
- package/dist/types/filter-manager/filter-manager-impl.d.ts +27 -0
- package/dist/types/filter-manager/filter-manager.d.ts +1 -0
- package/dist/types/filter-manager/filter-state-context.d.ts +16 -0
- package/dist/types/filter-manager/flat-to-combined.d.ts +3 -0
- package/dist/types/filter-manager/flatten-combined-filter.d.ts +3 -0
- package/dist/types/filter-manager/is-filter-complete.d.ts +2 -0
- package/dist/types/filter-manager/types.d.ts +15 -0
- package/dist/types/filter-manager/use-in-filter.d.ts +5 -0
- package/dist/types/filter-manager/use-simple-filters.d.ts +8 -0
- package/dist/types/grid-container/grid-container-impl.d.ts +6 -0
- package/dist/types/grid-container/grid-container.d.ts +2 -0
- package/dist/types/icons.d.ts +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/license.d.ts +12 -0
- package/dist/types/list-view/list-view-context.d.ts +21 -0
- package/dist/types/list-view/list-view.d.ts +26 -0
- package/dist/types/lytenyte-pro.d.ts +7 -0
- package/dist/types/menu/arrow-svg.d.ts +1 -0
- package/dist/types/menu/column-menu/column-menu-driver.d.ts +4 -0
- package/dist/types/menu/context-menu/context-menu-driver.d.ts +1 -0
- package/dist/types/menu/context-menu/use-context-menu-listener.d.ts +6 -0
- package/dist/types/menu/menu-impl.d.ts +17 -0
- package/dist/types/menu/menu.d.ts +18 -0
- package/dist/types/menu/use-menu-class-name.d.ts +1 -0
- package/dist/types/overlay/load-error-overlay.d.ts +1 -0
- package/dist/types/overlay/loading-overlay.d.ts +1 -0
- package/dist/types/overlay/no-data-overlay.d.ts +1 -0
- package/dist/types/overlay/overlay-driver.d.ts +1 -0
- package/dist/types/pill/pill.d.ts +5 -0
- package/dist/types/pill-manager/pill-manager-agg-menu.d.ts +7 -0
- package/dist/types/pill-manager/pill-manager-controls.d.ts +9 -0
- package/dist/types/pill-manager/pill-manager-drag-placeholder.d.ts +5 -0
- package/dist/types/pill-manager/pill-manager-expander.d.ts +1 -0
- package/dist/types/pill-manager/pill-manager-impl.d.ts +49 -0
- package/dist/types/pill-manager/pill-manager-pill.d.ts +4 -0
- package/dist/types/pill-manager/pill-manager-pills/pill-manager-pills.d.ts +2 -0
- package/dist/types/pill-manager/pill-manager-pills/use-aggregation-source.d.ts +2 -0
- package/dist/types/pill-manager/pill-manager-pills/use-column-pivot-source.d.ts +2 -0
- package/dist/types/pill-manager/pill-manager-pills/use-column-source.d.ts +2 -0
- package/dist/types/pill-manager/pill-manager-pills/use-measures-source.d.ts +2 -0
- package/dist/types/pill-manager/pill-manager-pills/use-row-groups-source.d.ts +2 -0
- package/dist/types/pill-manager/pill-manager-pills/utils.d.ts +3 -0
- package/dist/types/pill-manager/pill-manager-row-label.d.ts +22 -0
- package/dist/types/pill-manager/pill-manager-row.d.ts +12 -0
- package/dist/types/pill-manager/pill-manager-rows.d.ts +1 -0
- package/dist/types/pill-manager/pill-manager-separator.d.ts +1 -0
- package/dist/types/pill-manager/pill-manager-types.d.ts +36 -0
- package/dist/types/pill-manager/pill-manager.d.ts +1 -0
- package/dist/types/popover/anchor-context.d.ts +6 -0
- package/dist/types/popover/popover-driver.d.ts +1 -0
- package/dist/types/popover/popover-impl.d.ts +8 -0
- package/dist/types/popover/popover.d.ts +10 -0
- package/dist/types/popover/use-popover-class.d.ts +1 -0
- package/dist/types/select/select.d.ts +17 -0
- package/dist/types/sort-manager/sort-adder.d.ts +4 -0
- package/dist/types/sort-manager/sort-apply.d.ts +1 -0
- package/dist/types/sort-manager/sort-cancel.d.ts +1 -0
- package/dist/types/sort-manager/sort-clear.d.ts +1 -0
- package/dist/types/sort-manager/sort-column-select.d.ts +5 -0
- package/dist/types/sort-manager/sort-direction-select.d.ts +5 -0
- package/dist/types/sort-manager/sort-items-to-sort-model.d.ts +3 -0
- package/dist/types/sort-manager/sort-manager-container.d.ts +53 -0
- package/dist/types/sort-manager/sort-manager-context.d.ts +4 -0
- package/dist/types/sort-manager/sort-manager-impl.d.ts +30 -0
- package/dist/types/sort-manager/sort-manager.d.ts +1 -0
- package/dist/types/sort-manager/sort-model-to-sort-items.d.ts +4 -0
- package/dist/types/sort-manager/sort-remove.d.ts +4 -0
- package/dist/types/sort-manager/sort-sort-select.d.ts +5 -0
- package/dist/types/sort-manager/use-sort-state.d.ts +8 -0
- package/dist/types/sort-manager/use-sortable-column-items.d.ts +9 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/use-client-data-source.d.ts +6 -0
- package/dist/types/use-edge-scroll.d.ts +7 -0
- package/dist/types/use-grid.d.ts +6 -0
- package/dist/types/use-lytenyte.d.ts +10 -0
- package/dist/types/use-tree-data-source.d.ts +3 -0
- package/dist/types/watermark.d.ts +3 -0
- package/dist/types.js +1 -0
- package/dist/use-grid-DKvzGZWc.js +916 -0
- package/dist/useAnchorPositioning-Cm44rb7y.js +252 -0
- package/dist/useBaseUiId-J66PFGv_.js +48 -0
- package/dist/useButton-Cy7tjZ__.js +183 -0
- package/dist/useCompositeListItem-I14CpQPi.js +51 -0
- package/dist/useScrollLock-D6h5lZYs.js +515 -0
- package/package.json +96 -0
|
@@ -0,0 +1,1241 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { IsoResizeObserver, getPreciseElementDimensions, clsx } from "@1771technologies/js-utils";
|
|
3
|
+
import { u as useGrid, a as useDragStore, b as useDrag, C as Checkbox, I as Input, G as GridProvider, D as DragProvider } from "./use-grid-DKvzGZWc.js";
|
|
4
|
+
import "@1771technologies/react-sizer";
|
|
5
|
+
import { useCombinedRefs, useEvent } from "@1771technologies/react-utils";
|
|
6
|
+
import "@1771technologies/grid-provider";
|
|
7
|
+
import { useRef, useState, useEffect, useCallback, useMemo, createContext, useContext, forwardRef, useId } from "react";
|
|
8
|
+
import "@1771technologies/react-dragon";
|
|
9
|
+
import "@1771technologies/grid-core";
|
|
10
|
+
import { g as useEdgeScroll, h as useDraggable, c as canAgg, a as canMeasure, f as useDroppable, u as useAggregationSource, b as useMeasuresSource, d as useRowGroupsSource, e as useColumnPivotSource, P as Pill, M as MenuTrigger, i as PillManagerAggMenu, j as PillManagerMeasureMenu } from "./pill-C4Jhdf8E.js";
|
|
11
|
+
import { A as ArrowRightIcon } from "./tickmark-icon-CoogRMoO.js";
|
|
12
|
+
import { A as ArrowDownIcon } from "./arrow-down-icon-B-3ldODD.js";
|
|
13
|
+
import { D as DragIcon, M as MeasuresIcon, C as ColumnPivotIcon, R as RowGroupIcon, a as MoreDotsIcon } from "./row-group-icon-BOOju5Vu.js";
|
|
14
|
+
import { createPortal } from "react-dom";
|
|
15
|
+
import { D as DragGroupIcon, S as SearchIcon } from "./search-icon-CcG1lqsn.js";
|
|
16
|
+
import { C as CrossIcon } from "./cross-icon-CEMLAlFX.js";
|
|
17
|
+
import { M as MenuRoot, a as MenuPortal, b as MenuPositioner } from "./MenuRoot-9n64jNWP.js";
|
|
18
|
+
function Sizer({
|
|
19
|
+
children,
|
|
20
|
+
onSizeChange,
|
|
21
|
+
onInit,
|
|
22
|
+
elRef,
|
|
23
|
+
...props
|
|
24
|
+
}) {
|
|
25
|
+
const ref = useRef(null);
|
|
26
|
+
const [size, setSize] = useState(null);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
return () => ref.current?.disconnect();
|
|
29
|
+
}, []);
|
|
30
|
+
const init = useCallback((el) => {
|
|
31
|
+
if (!el) return;
|
|
32
|
+
const resize = new IsoResizeObserver(() => {
|
|
33
|
+
const dims2 = getPreciseElementDimensions(el);
|
|
34
|
+
setSize(dims2);
|
|
35
|
+
});
|
|
36
|
+
const dims = getPreciseElementDimensions(el);
|
|
37
|
+
setSize(dims);
|
|
38
|
+
resize.observe(el);
|
|
39
|
+
ref.current = resize;
|
|
40
|
+
}, []);
|
|
41
|
+
const [inner, setInner] = useState(null);
|
|
42
|
+
const combined = useCombinedRefs(elRef, setInner);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!inner) return;
|
|
45
|
+
let raf = null;
|
|
46
|
+
const resizer = new IsoResizeObserver(() => {
|
|
47
|
+
if (raf) return;
|
|
48
|
+
raf = setTimeout(() => {
|
|
49
|
+
const dims2 = getPreciseElementDimensions(inner);
|
|
50
|
+
onSizeChange?.(dims2);
|
|
51
|
+
raf = null;
|
|
52
|
+
}, 20);
|
|
53
|
+
});
|
|
54
|
+
resizer.observe(inner);
|
|
55
|
+
const dims = getPreciseElementDimensions(inner);
|
|
56
|
+
onSizeChange?.(dims);
|
|
57
|
+
return () => resizer.disconnect();
|
|
58
|
+
}, [inner, onInit, onSizeChange]);
|
|
59
|
+
return /* @__PURE__ */ jsxs(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
style: {
|
|
63
|
+
minHeight: "inherit",
|
|
64
|
+
maxHeight: "inherit",
|
|
65
|
+
height: "100%",
|
|
66
|
+
width: "100%",
|
|
67
|
+
minWidth: "inherit",
|
|
68
|
+
maxWidth: "inherit",
|
|
69
|
+
position: "relative"
|
|
70
|
+
},
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
ref: init,
|
|
76
|
+
style: {
|
|
77
|
+
position: "absolute",
|
|
78
|
+
minHeight: "inherit",
|
|
79
|
+
maxHeight: "inherit",
|
|
80
|
+
height: "100%",
|
|
81
|
+
width: "100%",
|
|
82
|
+
minWidth: "inherit",
|
|
83
|
+
maxWidth: "inherit",
|
|
84
|
+
pointerEvents: "none"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
size && /* @__PURE__ */ jsx(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
...props,
|
|
92
|
+
ref: combined,
|
|
93
|
+
style: {
|
|
94
|
+
width: size.innerWidth,
|
|
95
|
+
height: size.innerHeight,
|
|
96
|
+
position: "absolute",
|
|
97
|
+
overflow: "auto",
|
|
98
|
+
scrollbarWidth: "thin",
|
|
99
|
+
...props.style
|
|
100
|
+
},
|
|
101
|
+
children
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
function Virtualized({
|
|
109
|
+
data,
|
|
110
|
+
focusedIndex,
|
|
111
|
+
itemHeight,
|
|
112
|
+
renderer: Row,
|
|
113
|
+
preventFlash,
|
|
114
|
+
elRef,
|
|
115
|
+
scrollIntoViewIndex,
|
|
116
|
+
...props
|
|
117
|
+
}) {
|
|
118
|
+
const [size, setSize] = useState(null);
|
|
119
|
+
const init = useCallback((_, size2) => {
|
|
120
|
+
setSize(size2);
|
|
121
|
+
}, []);
|
|
122
|
+
const [rowStart, setRowStart] = useState(0);
|
|
123
|
+
const [rowEnd, setRowEnd] = useState(0);
|
|
124
|
+
const [vp, setVp] = useState(null);
|
|
125
|
+
const [y, setY] = useState(0);
|
|
126
|
+
const handleScroll = useEvent(() => {
|
|
127
|
+
if (!vp || !size) return;
|
|
128
|
+
const scrollTop = vp.scrollTop;
|
|
129
|
+
const rowStart2 = Math.floor(scrollTop / itemHeight);
|
|
130
|
+
const rowEnd2 = Math.ceil(size.innerHeight / itemHeight) + rowStart2;
|
|
131
|
+
setY(scrollTop);
|
|
132
|
+
setRowStart(Math.max(0, rowStart2 - 5));
|
|
133
|
+
setRowEnd(Math.min(rowEnd2 + 5, data.length));
|
|
134
|
+
});
|
|
135
|
+
const rows = useMemo(() => {
|
|
136
|
+
const safeRowStart = Math.max(0, rowStart);
|
|
137
|
+
const safeRowEnd = Math.min(data.length, rowEnd);
|
|
138
|
+
const rows2 = [];
|
|
139
|
+
if (focusedIndex != null && focusedIndex < safeRowStart) {
|
|
140
|
+
rows2.push(
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
Row,
|
|
143
|
+
{
|
|
144
|
+
rowIndex: focusedIndex,
|
|
145
|
+
data: data[focusedIndex],
|
|
146
|
+
y: focusedIndex * itemHeight,
|
|
147
|
+
height: itemHeight
|
|
148
|
+
},
|
|
149
|
+
focusedIndex
|
|
150
|
+
)
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
for (let i = safeRowStart; i < safeRowEnd; i++) {
|
|
154
|
+
rows2.push(/* @__PURE__ */ jsx(Row, { rowIndex: i, data: data[i], y: i * itemHeight, height: itemHeight }, i));
|
|
155
|
+
}
|
|
156
|
+
if (focusedIndex != null && focusedIndex >= rowEnd)
|
|
157
|
+
rows2.push(
|
|
158
|
+
/* @__PURE__ */ jsx(
|
|
159
|
+
Row,
|
|
160
|
+
{
|
|
161
|
+
rowIndex: focusedIndex,
|
|
162
|
+
data: data[focusedIndex],
|
|
163
|
+
y: focusedIndex * itemHeight,
|
|
164
|
+
height: itemHeight
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
return rows2;
|
|
169
|
+
}, [Row, data, focusedIndex, itemHeight, rowEnd, rowStart]);
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
handleScroll();
|
|
172
|
+
}, [handleScroll, vp, size, data.length]);
|
|
173
|
+
const scrolled = useRef(false);
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (!vp || scrollIntoViewIndex == null || scrolled.current) return;
|
|
176
|
+
const t = setTimeout(() => {
|
|
177
|
+
vp.scrollBy({ top: scrollIntoViewIndex * itemHeight });
|
|
178
|
+
scrolled.current = true;
|
|
179
|
+
setTimeout(() => {
|
|
180
|
+
const child = vp.querySelector(`[data-rowindex="${scrollIntoViewIndex}"]`);
|
|
181
|
+
if (child) {
|
|
182
|
+
child.focus();
|
|
183
|
+
}
|
|
184
|
+
}, 30);
|
|
185
|
+
}, 10);
|
|
186
|
+
return () => clearTimeout(t);
|
|
187
|
+
}, [itemHeight, scrollIntoViewIndex, vp]);
|
|
188
|
+
const combinedRef = useCombinedRefs(setVp, elRef);
|
|
189
|
+
return /* @__PURE__ */ jsxs(
|
|
190
|
+
Sizer,
|
|
191
|
+
{
|
|
192
|
+
onInit: init,
|
|
193
|
+
onSizeChange: setSize,
|
|
194
|
+
...props,
|
|
195
|
+
onScroll: handleScroll,
|
|
196
|
+
elRef: combinedRef,
|
|
197
|
+
children: [
|
|
198
|
+
preventFlash && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
199
|
+
/* @__PURE__ */ jsx(
|
|
200
|
+
"div",
|
|
201
|
+
{
|
|
202
|
+
style: {
|
|
203
|
+
position: "sticky",
|
|
204
|
+
top: 0,
|
|
205
|
+
height: 0,
|
|
206
|
+
width: "100%",
|
|
207
|
+
transform: `translate3d(0px, ${-y}px, 0px)`
|
|
208
|
+
},
|
|
209
|
+
children: rows
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ jsx(
|
|
213
|
+
"div",
|
|
214
|
+
{
|
|
215
|
+
style: {
|
|
216
|
+
height: data.length * itemHeight,
|
|
217
|
+
width: "100%",
|
|
218
|
+
position: "relative",
|
|
219
|
+
pointerEvents: "none"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] }),
|
|
224
|
+
!preventFlash && /* @__PURE__ */ jsx("div", { style: { height: data.length * itemHeight, width: "100%", position: "relative" }, children: rows })
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
const context$3 = createContext(null);
|
|
230
|
+
const ColumnStateProvider = (props) => {
|
|
231
|
+
const [query, setQuery] = useState("");
|
|
232
|
+
const value = useMemo(() => {
|
|
233
|
+
return {
|
|
234
|
+
query,
|
|
235
|
+
setQuery
|
|
236
|
+
};
|
|
237
|
+
}, [query]);
|
|
238
|
+
return /* @__PURE__ */ jsx(context$3.Provider, { value, children: props.children });
|
|
239
|
+
};
|
|
240
|
+
const useColumnManagerState = () => useContext(context$3);
|
|
241
|
+
function createPathTree(items, config = {}) {
|
|
242
|
+
const roots = [];
|
|
243
|
+
const pathOccurrences = /* @__PURE__ */ new Map();
|
|
244
|
+
const pathToParentMap = /* @__PURE__ */ new Map();
|
|
245
|
+
const separator = config.pathSeparator ?? "/";
|
|
246
|
+
const considerAdjacency = config.considerAdjacency ?? false;
|
|
247
|
+
function getOccurrenceKey(path) {
|
|
248
|
+
const pathKey = path.join(separator);
|
|
249
|
+
const count = pathOccurrences.get(pathKey) ?? 0;
|
|
250
|
+
pathOccurrences.set(pathKey, count + 1);
|
|
251
|
+
return `${pathKey}#${count}`;
|
|
252
|
+
}
|
|
253
|
+
function isAdjacentPath(existingParent, pathSegment, level) {
|
|
254
|
+
const lastChild = existingParent.children[existingParent.children.length - 1];
|
|
255
|
+
if (!lastChild) return false;
|
|
256
|
+
return lastChild.path.length === level + 1 && lastChild.path[level] === pathSegment;
|
|
257
|
+
}
|
|
258
|
+
function findOrCreateParent(path, currentLevel, currentParent) {
|
|
259
|
+
if (considerAdjacency && !currentParent && path.length === 1) {
|
|
260
|
+
const lastRoot = roots[roots.length - 1];
|
|
261
|
+
if (lastRoot?.type === "parent" && lastRoot.path[0] === path[0]) {
|
|
262
|
+
return lastRoot;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (currentLevel === path.length - 1) {
|
|
266
|
+
if (!considerAdjacency) {
|
|
267
|
+
const pathKey = path.slice(0, currentLevel + 1).join(separator);
|
|
268
|
+
const existingParent = pathToParentMap.get(pathKey);
|
|
269
|
+
if (existingParent) {
|
|
270
|
+
return existingParent;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (considerAdjacency && currentParent) {
|
|
274
|
+
const lastChild = currentParent.children[currentParent.children.length - 1];
|
|
275
|
+
if (lastChild?.type === "parent" && isAdjacentPath(currentParent, path[currentLevel], currentLevel)) {
|
|
276
|
+
return lastChild;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const newParent2 = {
|
|
280
|
+
type: "parent",
|
|
281
|
+
path: path.slice(0, currentLevel + 1),
|
|
282
|
+
parent: currentParent,
|
|
283
|
+
children: [],
|
|
284
|
+
occurrence: getOccurrenceKey(path.slice(0, currentLevel + 1))
|
|
285
|
+
};
|
|
286
|
+
if (currentParent) {
|
|
287
|
+
currentParent.children.push(newParent2);
|
|
288
|
+
} else {
|
|
289
|
+
roots.push(newParent2);
|
|
290
|
+
}
|
|
291
|
+
if (!considerAdjacency) {
|
|
292
|
+
pathToParentMap.set(path.slice(0, currentLevel + 1).join(separator), newParent2);
|
|
293
|
+
}
|
|
294
|
+
return newParent2;
|
|
295
|
+
}
|
|
296
|
+
if (considerAdjacency && !currentParent) {
|
|
297
|
+
const lastRoot = roots[roots.length - 1];
|
|
298
|
+
if (lastRoot?.type === "parent" && lastRoot.path[currentLevel] === path[currentLevel]) {
|
|
299
|
+
return findOrCreateParent(path, currentLevel + 1, lastRoot);
|
|
300
|
+
}
|
|
301
|
+
} else if (considerAdjacency && currentParent) {
|
|
302
|
+
if (isAdjacentPath(currentParent, path[currentLevel], currentLevel)) {
|
|
303
|
+
const lastChild = currentParent.children[currentParent.children.length - 1];
|
|
304
|
+
return findOrCreateParent(path, currentLevel + 1, lastChild);
|
|
305
|
+
}
|
|
306
|
+
} else if (!considerAdjacency) {
|
|
307
|
+
const pathKey = path.slice(0, currentLevel + 1).join(separator);
|
|
308
|
+
const existingParent = pathToParentMap.get(pathKey);
|
|
309
|
+
if (existingParent) {
|
|
310
|
+
return findOrCreateParent(path, currentLevel + 1, existingParent);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const newParent = {
|
|
314
|
+
type: "parent",
|
|
315
|
+
path: path.slice(0, currentLevel + 1),
|
|
316
|
+
parent: currentParent,
|
|
317
|
+
children: [],
|
|
318
|
+
occurrence: getOccurrenceKey(path.slice(0, currentLevel + 1))
|
|
319
|
+
};
|
|
320
|
+
if (currentParent) {
|
|
321
|
+
currentParent.children.push(newParent);
|
|
322
|
+
} else {
|
|
323
|
+
roots.push(newParent);
|
|
324
|
+
}
|
|
325
|
+
if (!considerAdjacency) {
|
|
326
|
+
pathToParentMap.set(path.slice(0, currentLevel + 1).join(separator), newParent);
|
|
327
|
+
}
|
|
328
|
+
return findOrCreateParent(path, currentLevel + 1, newParent);
|
|
329
|
+
}
|
|
330
|
+
for (const item of items) {
|
|
331
|
+
const { path, data } = item;
|
|
332
|
+
if (path.length === 0) {
|
|
333
|
+
const leafNode2 = {
|
|
334
|
+
type: "leaf",
|
|
335
|
+
path: [],
|
|
336
|
+
parent: null,
|
|
337
|
+
data
|
|
338
|
+
};
|
|
339
|
+
roots.push(leafNode2);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
const parentNode = findOrCreateParent(path, 0, null);
|
|
343
|
+
const leafNode = {
|
|
344
|
+
type: "leaf",
|
|
345
|
+
path,
|
|
346
|
+
parent: parentNode,
|
|
347
|
+
data
|
|
348
|
+
};
|
|
349
|
+
parentNode.children.push(leafNode);
|
|
350
|
+
}
|
|
351
|
+
return roots;
|
|
352
|
+
}
|
|
353
|
+
const context$2 = createContext({
|
|
354
|
+
count: 0,
|
|
355
|
+
expansions: {},
|
|
356
|
+
renderer: () => null,
|
|
357
|
+
focused: null,
|
|
358
|
+
setFocused: () => {
|
|
359
|
+
},
|
|
360
|
+
rtl: false,
|
|
361
|
+
onExpansionChange: () => {
|
|
362
|
+
},
|
|
363
|
+
onAction: () => {
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
function ListViewProvider(props) {
|
|
367
|
+
return /* @__PURE__ */ jsx(context$2.Provider, { value: props.value, children: props.children });
|
|
368
|
+
}
|
|
369
|
+
const useListView = () => useContext(context$2);
|
|
370
|
+
function ListView({
|
|
371
|
+
paths,
|
|
372
|
+
expansions,
|
|
373
|
+
onExpansionChange,
|
|
374
|
+
onKeydown,
|
|
375
|
+
onAction,
|
|
376
|
+
renderer,
|
|
377
|
+
itemClassName,
|
|
378
|
+
itemStyle,
|
|
379
|
+
edgeScrollActive,
|
|
380
|
+
className,
|
|
381
|
+
style,
|
|
382
|
+
rtl = false,
|
|
383
|
+
itemHeight = 24,
|
|
384
|
+
scrollIntoViewIndex
|
|
385
|
+
}) {
|
|
386
|
+
const tree = useMemo(() => {
|
|
387
|
+
return createPathTree(paths, { considerAdjacency: true });
|
|
388
|
+
}, [paths]);
|
|
389
|
+
const flattenedTree = useMemo(() => {
|
|
390
|
+
const stack = [...tree];
|
|
391
|
+
const flattened = [];
|
|
392
|
+
while (stack.length) {
|
|
393
|
+
const item = stack.shift();
|
|
394
|
+
if (item.type === "leaf") {
|
|
395
|
+
flattened.push(item);
|
|
396
|
+
} else {
|
|
397
|
+
if (expansions[item.occurrence] ?? true) {
|
|
398
|
+
stack.unshift(...item.children);
|
|
399
|
+
}
|
|
400
|
+
flattened.push(item);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return flattened;
|
|
404
|
+
}, [expansions, tree]);
|
|
405
|
+
const [focused, setFocused] = useState(null);
|
|
406
|
+
const context2 = useMemo(() => {
|
|
407
|
+
return {
|
|
408
|
+
count: flattenedTree.length,
|
|
409
|
+
onExpansionChange,
|
|
410
|
+
expansions,
|
|
411
|
+
renderer,
|
|
412
|
+
setFocused,
|
|
413
|
+
onKeydown,
|
|
414
|
+
focused,
|
|
415
|
+
onAction,
|
|
416
|
+
itemClassName,
|
|
417
|
+
itemStyle,
|
|
418
|
+
rtl
|
|
419
|
+
};
|
|
420
|
+
}, [
|
|
421
|
+
expansions,
|
|
422
|
+
flattenedTree.length,
|
|
423
|
+
focused,
|
|
424
|
+
itemClassName,
|
|
425
|
+
itemStyle,
|
|
426
|
+
onAction,
|
|
427
|
+
onExpansionChange,
|
|
428
|
+
onKeydown,
|
|
429
|
+
renderer,
|
|
430
|
+
rtl
|
|
431
|
+
]);
|
|
432
|
+
const ref = useRef(null);
|
|
433
|
+
const r = useEdgeScroll({
|
|
434
|
+
isActive: !!edgeScrollActive,
|
|
435
|
+
direction: "vertical"
|
|
436
|
+
});
|
|
437
|
+
const combined = useCombinedRefs(r, ref);
|
|
438
|
+
return /* @__PURE__ */ jsx(ListViewProvider, { value: context2, children: /* @__PURE__ */ jsx(
|
|
439
|
+
Virtualized,
|
|
440
|
+
{
|
|
441
|
+
elRef: combined,
|
|
442
|
+
className,
|
|
443
|
+
style,
|
|
444
|
+
tabIndex: 0,
|
|
445
|
+
role: "tree",
|
|
446
|
+
onKeyDown: (ev) => {
|
|
447
|
+
if (document.activeElement === ref.current && ev.key === "ArrowDown") {
|
|
448
|
+
setFocused(0);
|
|
449
|
+
const firstChild = ref.current?.firstElementChild?.firstElementChild;
|
|
450
|
+
if (firstChild?.getAttribute("data-rowindex") !== "0")
|
|
451
|
+
ref.current?.scrollTo({ top: 0 });
|
|
452
|
+
setTimeout(() => {
|
|
453
|
+
const child = ref.current?.firstElementChild?.firstElementChild;
|
|
454
|
+
if (child) child.focus();
|
|
455
|
+
}, 20);
|
|
456
|
+
ev.preventDefault();
|
|
457
|
+
ev.stopPropagation();
|
|
458
|
+
}
|
|
459
|
+
if (focused == null) return;
|
|
460
|
+
if (ev.key === "ArrowDown") {
|
|
461
|
+
const next = ref.current?.querySelector(
|
|
462
|
+
`[data-rowindex="${focused + 1}"]`
|
|
463
|
+
);
|
|
464
|
+
ev.preventDefault();
|
|
465
|
+
ev.stopPropagation();
|
|
466
|
+
if (!next) {
|
|
467
|
+
document.activeElement?.scrollIntoView();
|
|
468
|
+
setTimeout(() => {
|
|
469
|
+
const next2 = ref.current?.querySelector(
|
|
470
|
+
`[data-rowindex=${focused + 1}]`
|
|
471
|
+
);
|
|
472
|
+
if (!next2) return;
|
|
473
|
+
next2.focus();
|
|
474
|
+
}, 20);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const bb = ref.current.getBoundingClientRect();
|
|
478
|
+
const n = next.getBoundingClientRect();
|
|
479
|
+
next.focus({ preventScroll: true });
|
|
480
|
+
if (bb.bottom - (n.top + n.height) < 0) {
|
|
481
|
+
next.scrollIntoView({ behavior: "instant", block: "end" });
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
if (ev.key === "ArrowUp") {
|
|
485
|
+
const next = ref.current?.querySelector(
|
|
486
|
+
`[data-rowindex="${focused - 1}"]`
|
|
487
|
+
);
|
|
488
|
+
ev.preventDefault();
|
|
489
|
+
ev.stopPropagation();
|
|
490
|
+
if (!next) {
|
|
491
|
+
document.activeElement?.scrollIntoView();
|
|
492
|
+
setTimeout(() => {
|
|
493
|
+
const next2 = ref.current?.querySelector(
|
|
494
|
+
`[data-rowindex=${focused - 1}]`
|
|
495
|
+
);
|
|
496
|
+
if (!next2) return;
|
|
497
|
+
next2.focus();
|
|
498
|
+
}, 20);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const bb = ref.current.getBoundingClientRect();
|
|
502
|
+
const n = next.getBoundingClientRect();
|
|
503
|
+
next.focus({ preventScroll: true });
|
|
504
|
+
if (bb.top - n.top > 0) {
|
|
505
|
+
next.scrollIntoView({ behavior: "instant" });
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
data: flattenedTree,
|
|
510
|
+
itemHeight,
|
|
511
|
+
renderer: ListItemRenderer,
|
|
512
|
+
focusedIndex: focused,
|
|
513
|
+
scrollIntoViewIndex,
|
|
514
|
+
preventFlash: true
|
|
515
|
+
}
|
|
516
|
+
) });
|
|
517
|
+
}
|
|
518
|
+
function ListItemRenderer(p) {
|
|
519
|
+
let depth = 1;
|
|
520
|
+
let current = p.data?.parent;
|
|
521
|
+
while (current) {
|
|
522
|
+
current = current?.parent;
|
|
523
|
+
depth++;
|
|
524
|
+
}
|
|
525
|
+
const ctx = useListView();
|
|
526
|
+
const isExpanded = p.data?.type === "parent" ? ctx.expansions[p.data.occurrence] ?? true : void 0;
|
|
527
|
+
return /* @__PURE__ */ jsx(
|
|
528
|
+
"div",
|
|
529
|
+
{
|
|
530
|
+
tabIndex: -1,
|
|
531
|
+
"data-rowindex": p.rowIndex,
|
|
532
|
+
onFocus: () => ctx.setFocused(p.rowIndex),
|
|
533
|
+
onBlur: () => ctx.setFocused(null),
|
|
534
|
+
onClick: () => ctx.onAction(p.data),
|
|
535
|
+
onKeyDown: (ev) => {
|
|
536
|
+
const open = ctx.rtl ? "ArrowLeft" : "ArrowRight";
|
|
537
|
+
const close = ctx.rtl ? "ArrowRight" : "ArrowLeft";
|
|
538
|
+
if (ev.key === " " && p.data.type === "parent") {
|
|
539
|
+
ctx.onExpansionChange(p.data.occurrence, !isExpanded);
|
|
540
|
+
ev.preventDefault();
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
if (ev.key === open && p.data.type === "parent") {
|
|
544
|
+
ctx.onExpansionChange(p.data.occurrence, true);
|
|
545
|
+
ev.preventDefault();
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (ev.key === close && p.data.type === "parent") {
|
|
549
|
+
ctx.onExpansionChange(p.data.occurrence, false);
|
|
550
|
+
ev.preventDefault();
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if (ev.key === "Enter") {
|
|
554
|
+
ctx.onAction(p.data);
|
|
555
|
+
ev.preventDefault();
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
ctx.onKeydown?.(ev.nativeEvent, p.data);
|
|
559
|
+
},
|
|
560
|
+
role: "treeitem",
|
|
561
|
+
style: {
|
|
562
|
+
...ctx.itemStyle,
|
|
563
|
+
position: "absolute",
|
|
564
|
+
top: p.y,
|
|
565
|
+
height: p.height,
|
|
566
|
+
width: "100%",
|
|
567
|
+
boxSizing: "border-box"
|
|
568
|
+
},
|
|
569
|
+
className: ctx.itemClassName,
|
|
570
|
+
"aria-posinset": p.rowIndex + 1,
|
|
571
|
+
"aria-level": depth,
|
|
572
|
+
"aria-setsize": ctx.count,
|
|
573
|
+
"aria-expanded": p.data.type === "parent" ? ctx.expansions[p.data.occurrence] : void 0,
|
|
574
|
+
children: /* @__PURE__ */ jsx(
|
|
575
|
+
ctx.renderer,
|
|
576
|
+
{
|
|
577
|
+
data: p.data,
|
|
578
|
+
depth: depth - 1,
|
|
579
|
+
expanded: !!isExpanded,
|
|
580
|
+
parent: p.data.type === "parent",
|
|
581
|
+
treeFlatIndex: p.rowIndex
|
|
582
|
+
}
|
|
583
|
+
)
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
function allLeafs(c) {
|
|
588
|
+
const leafs = [];
|
|
589
|
+
const stack = [...c.children];
|
|
590
|
+
while (stack.length) {
|
|
591
|
+
const item = stack.pop();
|
|
592
|
+
if (item.type === "leaf") {
|
|
593
|
+
leafs.push(item.data);
|
|
594
|
+
} else {
|
|
595
|
+
stack.push(...item.children);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return leafs;
|
|
599
|
+
}
|
|
600
|
+
function canHideItem(item, api) {
|
|
601
|
+
if (item.type === "parent") {
|
|
602
|
+
const leafs = allLeafs(item);
|
|
603
|
+
return leafs.every((leaf) => api.columnIsHidable(leaf));
|
|
604
|
+
} else {
|
|
605
|
+
return api.columnIsHidable(item.data);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function handleItemHide(item, api) {
|
|
609
|
+
const state = api.getState();
|
|
610
|
+
const base = state.columnBase.peek();
|
|
611
|
+
if (canHideItem(item, api)) {
|
|
612
|
+
if (item.type === "parent") {
|
|
613
|
+
const columns = allLeafs(item);
|
|
614
|
+
const allVisible = columns.every((c) => !(c.hide ?? base.hide));
|
|
615
|
+
const nextState = allVisible ? true : false;
|
|
616
|
+
const update = Object.fromEntries(columns.map((c) => [c.id, { hide: nextState }]));
|
|
617
|
+
api.columnUpdateMany(update);
|
|
618
|
+
} else {
|
|
619
|
+
const column = item.data;
|
|
620
|
+
const next = !(column.hide ?? base.hide);
|
|
621
|
+
api.columnUpdate(column, { hide: next });
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
function ColumnManagerTree({
|
|
626
|
+
className,
|
|
627
|
+
itemClassName,
|
|
628
|
+
children,
|
|
629
|
+
itemHeight = 30
|
|
630
|
+
}) {
|
|
631
|
+
const { api, state } = useGrid();
|
|
632
|
+
const columns = state.columns.use();
|
|
633
|
+
const expansions = state.internal.columnManagerTreeExpansions.use();
|
|
634
|
+
const { query } = useColumnManagerState();
|
|
635
|
+
const paths = useMemo(() => {
|
|
636
|
+
const paths2 = columns.filter((c) => {
|
|
637
|
+
if (api.columnIsGridGenerated(c) && !api.columnIsGroupAutoColumn(c)) return false;
|
|
638
|
+
if (!query) return true;
|
|
639
|
+
const searchLabel = [c.headerName ?? c.id, ...c.groupPath ?? []].join(" ");
|
|
640
|
+
return searchLabel.toLowerCase().includes(query.toLocaleLowerCase());
|
|
641
|
+
}).map((c) => ({ path: c.groupPath ?? [], data: c }));
|
|
642
|
+
return paths2;
|
|
643
|
+
}, [api, columns, query]);
|
|
644
|
+
const dragStore = useDragStore();
|
|
645
|
+
const edgeScroll = useDrag(dragStore, (d) => !!d.active);
|
|
646
|
+
return /* @__PURE__ */ jsx(
|
|
647
|
+
ListView,
|
|
648
|
+
{
|
|
649
|
+
edgeScrollActive: edgeScroll,
|
|
650
|
+
expansions,
|
|
651
|
+
className: clsx("lng1771-column-manager__tree", className),
|
|
652
|
+
itemClassName: clsx("lng1771-column-manager__tree-item-wrapper", itemClassName),
|
|
653
|
+
paths,
|
|
654
|
+
itemHeight,
|
|
655
|
+
renderer: children,
|
|
656
|
+
onAction: (item) => handleItemHide(item, api),
|
|
657
|
+
onExpansionChange: (id, s) => {
|
|
658
|
+
state.internal.columnManagerTreeExpansions.set((prev) => ({ ...prev, [id]: s }));
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
const ColumnManagerTreeItem = forwardRef(function TreeItem({ className, depthPadding = 12, style, columnItem: ci, ...props }, ref) {
|
|
664
|
+
const { api, state } = useGrid();
|
|
665
|
+
const base = state.columnBase.use();
|
|
666
|
+
const columns = state.internal.columnLookup.use();
|
|
667
|
+
const pivotMode = state.columnPivotModeIsOn.use();
|
|
668
|
+
const labelId = useId();
|
|
669
|
+
const pivotModel = state.columnPivotModel.use();
|
|
670
|
+
const aggModel = state.aggModel.use();
|
|
671
|
+
const groupModel = state.rowGroupModel.use();
|
|
672
|
+
const measureModel = state.measureModel.use();
|
|
673
|
+
const dropData = useMemo(() => {
|
|
674
|
+
const ids = ci.data.type === "leaf" ? [ci.data.data.id] : allLeafs(ci.data).map((c) => c.id);
|
|
675
|
+
return { target: "columns", ids, isGroup: ci.data.type === "parent" };
|
|
676
|
+
}, [ci.data]);
|
|
677
|
+
const { onPointerDown } = useDraggable({
|
|
678
|
+
id: ci.data.type === "leaf" ? ci.data.data.id : ci.data.occurrence,
|
|
679
|
+
getData: () => {
|
|
680
|
+
const columns2 = ci.data.type === "leaf" ? [ci.data.data] : allLeafs(ci.data);
|
|
681
|
+
return { target: "columns", columns: columns2 };
|
|
682
|
+
},
|
|
683
|
+
getTags: () => {
|
|
684
|
+
const columns2 = ci.data.type === "leaf" ? [ci.data.data] : allLeafs(ci.data);
|
|
685
|
+
const isPivotable = columns2.every((c) => api.columnIsPivotable(c)) && columns2.some((c) => !pivotModel.includes(c.id));
|
|
686
|
+
const isGroupable = columns2.every((c) => api.columnIsRowGroupable(c)) && columns2.some((c) => !groupModel.includes(c.id));
|
|
687
|
+
const isAggregable = columns2.every((c) => canAgg(c, base)) && columns2.some((c) => !aggModel[c.id]);
|
|
688
|
+
const isMeasurable = columns2.every((c) => canMeasure(c, base)) && columns2.some((c) => !measureModel[c.id]);
|
|
689
|
+
const dragTags = ["columns"];
|
|
690
|
+
if (isPivotable) dragTags.push("column-pivot");
|
|
691
|
+
if (isGroupable) dragTags.push("row-group");
|
|
692
|
+
if (isAggregable) dragTags.push("aggregations");
|
|
693
|
+
if (isMeasurable) dragTags.push("measures");
|
|
694
|
+
return dragTags;
|
|
695
|
+
},
|
|
696
|
+
onDragEnd: (p) => {
|
|
697
|
+
const data = p.data;
|
|
698
|
+
const over = p.over.at(-1);
|
|
699
|
+
if (!over) return;
|
|
700
|
+
if (over.data.target === "columns") {
|
|
701
|
+
const ids = over.data.ids;
|
|
702
|
+
const isGroup = over.data.isGroup;
|
|
703
|
+
const srcIds = data.columns.map((c) => c.id);
|
|
704
|
+
if (srcIds.some((c) => ids.includes(c))) return;
|
|
705
|
+
if (isGroup || over.yHalf === "top") api.columnMoveBefore(srcIds, ids[0]);
|
|
706
|
+
else api.columnMoveAfter(srcIds, ids[0]);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (over.id === "row-groups-pills") {
|
|
710
|
+
const columns2 = data.columns.filter((c) => !groupModel.includes(c.id));
|
|
711
|
+
state.rowGroupModel.set((prev) => [...prev, ...columns2.map((c) => c.id)]);
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
if (over.id === "column-pivots-pills") {
|
|
715
|
+
const columns2 = data.columns.filter((c) => !pivotModel.includes(c.id));
|
|
716
|
+
state.columnPivotModel.set((prev) => [...prev, ...columns2.map((c) => c.id)]);
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
if (over.id === "aggregations-pills") {
|
|
720
|
+
const columns2 = Object.fromEntries(
|
|
721
|
+
data.columns.filter((c) => !aggModel[c.id]).map((c) => {
|
|
722
|
+
const aggFn = c.aggFnDefault ?? c.aggFnsAllowed?.at(0) ?? base.aggFnsAllowed?.at(0);
|
|
723
|
+
return [c.id, { fn: aggFn }];
|
|
724
|
+
})
|
|
725
|
+
);
|
|
726
|
+
state.aggModel.set((prev) => ({ ...prev, ...columns2 }));
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
if (over.id === "measures-pills") {
|
|
730
|
+
const columns2 = Object.fromEntries(
|
|
731
|
+
data.columns.filter((c) => !measureModel[c.id]).map((c) => {
|
|
732
|
+
const measureFn = c.measureFnDefault ?? c.measureFnsAllowed?.at(0) ?? base.measureFnsAllowed?.at(0);
|
|
733
|
+
return [c.id, { fn: measureFn }];
|
|
734
|
+
})
|
|
735
|
+
);
|
|
736
|
+
state.measureModel.set((prev) => ({ ...prev, ...columns2 }));
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
const {
|
|
742
|
+
ref: dropRef,
|
|
743
|
+
canDrop,
|
|
744
|
+
yHalf
|
|
745
|
+
} = useDroppable({
|
|
746
|
+
id: ci.data.type === "leaf" ? ci.data.data.id : ci.data.occurrence,
|
|
747
|
+
accepted: ["columns"],
|
|
748
|
+
data: dropData
|
|
749
|
+
});
|
|
750
|
+
const combinedRefs = useCombinedRefs(ref, dropRef);
|
|
751
|
+
if (ci.data.type === "leaf") {
|
|
752
|
+
const data = ci.data.data;
|
|
753
|
+
const column = columns.get(data.id);
|
|
754
|
+
if (!column) return null;
|
|
755
|
+
const hidden = column.hide ?? base.hide;
|
|
756
|
+
const hidable = !pivotMode && api.columnIsHidable(column);
|
|
757
|
+
return /* @__PURE__ */ jsxs(
|
|
758
|
+
"div",
|
|
759
|
+
{
|
|
760
|
+
...props,
|
|
761
|
+
className: clsx("lng1771-column-manager__tree-item", className),
|
|
762
|
+
ref: combinedRefs,
|
|
763
|
+
"data-can-drop": canDrop,
|
|
764
|
+
style: {
|
|
765
|
+
paddingInlineStart: `calc(${depthPadding}px + ${ci.depth > 0 ? ci.depth + 1 : 0} * ${depthPadding}px + 22px)`,
|
|
766
|
+
...style
|
|
767
|
+
},
|
|
768
|
+
children: [
|
|
769
|
+
canDrop && yHalf === "top" && /* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__tree-item-drop-indicator-top" }),
|
|
770
|
+
canDrop && yHalf === "bottom" && /* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__tree-item-drop-indicator-bottom" }),
|
|
771
|
+
/* @__PURE__ */ jsx(DragIcon, { width: 16, height: 16, onPointerDown }),
|
|
772
|
+
/* @__PURE__ */ jsx(
|
|
773
|
+
Checkbox,
|
|
774
|
+
{
|
|
775
|
+
htmlFor: labelId,
|
|
776
|
+
"aria-labelledby": labelId,
|
|
777
|
+
isDisabled: !hidable,
|
|
778
|
+
tabIndex: -1,
|
|
779
|
+
isChecked: !hidden,
|
|
780
|
+
disabled: !hidable
|
|
781
|
+
}
|
|
782
|
+
),
|
|
783
|
+
/* @__PURE__ */ jsx("label", { id: labelId, children: data.headerName ?? data.id })
|
|
784
|
+
]
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
} else {
|
|
788
|
+
const id = ci.data.occurrence;
|
|
789
|
+
const path = ci.data.path.at(-1);
|
|
790
|
+
const columns2 = allLeafs(ci.data);
|
|
791
|
+
const checked = columns2.every((c) => !(c.hide ?? base.hide));
|
|
792
|
+
const isIndeterminate = columns2.some((c) => !(c.hide ?? base.hide)) && !checked;
|
|
793
|
+
const hidable = !pivotMode && columns2.every((c) => api.columnIsHidable(c));
|
|
794
|
+
return /* @__PURE__ */ jsxs(
|
|
795
|
+
"div",
|
|
796
|
+
{
|
|
797
|
+
...props,
|
|
798
|
+
style: {
|
|
799
|
+
paddingInlineStart: `calc(${depthPadding}px + ${ci.depth} * ${depthPadding}px)`,
|
|
800
|
+
...style
|
|
801
|
+
},
|
|
802
|
+
ref: combinedRefs,
|
|
803
|
+
className: clsx("lng1771-column-manager__tree-item", className),
|
|
804
|
+
children: [
|
|
805
|
+
canDrop && yHalf === "top" && /* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__tree-item-drop-indicator-top" }),
|
|
806
|
+
canDrop && yHalf === "bottom" && /* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__tree-item-drop-indicator-bottom" }),
|
|
807
|
+
/* @__PURE__ */ jsx(
|
|
808
|
+
"button",
|
|
809
|
+
{
|
|
810
|
+
className: "lng1771-column-manager__tree-item-expander",
|
|
811
|
+
onFocus: (ev) => ev.currentTarget.blur(),
|
|
812
|
+
onClick: (ev) => {
|
|
813
|
+
ev.stopPropagation();
|
|
814
|
+
state.internal.columnManagerTreeExpansions.set((prev) => ({
|
|
815
|
+
...prev,
|
|
816
|
+
[id]: !ci.expanded
|
|
817
|
+
}));
|
|
818
|
+
},
|
|
819
|
+
children: ci.expanded ? /* @__PURE__ */ jsx(ArrowDownIcon, { width: 16, height: 16, id }) : /* @__PURE__ */ jsx(ArrowRightIcon, { id, width: 16, height: 16 })
|
|
820
|
+
}
|
|
821
|
+
),
|
|
822
|
+
/* @__PURE__ */ jsx(DragIcon, { width: 16, height: 16, onPointerDown }),
|
|
823
|
+
/* @__PURE__ */ jsx(
|
|
824
|
+
Checkbox,
|
|
825
|
+
{
|
|
826
|
+
htmlFor: labelId,
|
|
827
|
+
"aria-labelledby": labelId,
|
|
828
|
+
tabIndex: -1,
|
|
829
|
+
isDisabled: !hidable,
|
|
830
|
+
isChecked: checked || isIndeterminate,
|
|
831
|
+
isDeterminate: isIndeterminate
|
|
832
|
+
}
|
|
833
|
+
),
|
|
834
|
+
/* @__PURE__ */ jsx("label", { id: labelId, children: path })
|
|
835
|
+
]
|
|
836
|
+
}
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
function ColumnManagerDragPlaceholder(props) {
|
|
841
|
+
const store = useDragStore();
|
|
842
|
+
const s = useDrag(store, (s2) => s2.active);
|
|
843
|
+
if (!s) return null;
|
|
844
|
+
const c = props.children ?? DefaultPlaceholder;
|
|
845
|
+
return createPortal(
|
|
846
|
+
/* @__PURE__ */ jsx(
|
|
847
|
+
"div",
|
|
848
|
+
{
|
|
849
|
+
className: "lng1771-column-manager__drag-placeholder",
|
|
850
|
+
style: { transform: `translate3d(${s.x}px, ${s.y}px, 0px)` },
|
|
851
|
+
children: c(s)
|
|
852
|
+
}
|
|
853
|
+
),
|
|
854
|
+
document.body
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
function DefaultPlaceholder(p) {
|
|
858
|
+
return /* @__PURE__ */ jsx(Placeholder, { ...p });
|
|
859
|
+
}
|
|
860
|
+
function Placeholder(p) {
|
|
861
|
+
const c = useMemo(() => {
|
|
862
|
+
return p.id.split("/").join(" / ").replaceAll("#0", "");
|
|
863
|
+
}, [p.id]);
|
|
864
|
+
return /* @__PURE__ */ jsxs("div", { className: "lng1771-column-manager__drag-placeholder--default", children: [
|
|
865
|
+
/* @__PURE__ */ jsx(
|
|
866
|
+
"svg",
|
|
867
|
+
{
|
|
868
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
869
|
+
width: "20px",
|
|
870
|
+
height: "20px",
|
|
871
|
+
fill: "currentcolor",
|
|
872
|
+
viewBox: "0 0 256 256",
|
|
873
|
+
children: /* @__PURE__ */ jsx("path", { d: "M90.34,61.66a8,8,0,0,1,0-11.32l32-32a8,8,0,0,1,11.32,0l32,32a8,8,0,0,1-11.32,11.32L136,43.31V96a8,8,0,0,1-16,0V43.31L101.66,61.66A8,8,0,0,1,90.34,61.66Zm64,132.68L136,212.69V160a8,8,0,0,0-16,0v52.69l-18.34-18.35a8,8,0,0,0-11.32,11.32l32,32a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0-11.32-11.32Zm83.32-72-32-32a8,8,0,0,0-11.32,11.32L212.69,120H160a8,8,0,0,0,0,16h52.69l-18.35,18.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,237.66,122.34ZM43.31,136H96a8,8,0,0,0,0-16H43.31l18.35-18.34A8,8,0,0,0,50.34,90.34l-32,32a8,8,0,0,0,0,11.32l32,32a8,8,0,0,0,11.32-11.32Z" })
|
|
874
|
+
}
|
|
875
|
+
),
|
|
876
|
+
/* @__PURE__ */ jsx("span", { children: c })
|
|
877
|
+
] });
|
|
878
|
+
}
|
|
879
|
+
const context$1 = createContext({});
|
|
880
|
+
const ColumnManagerDragBox = forwardRef(function ColumnManagerDragBox2({ source, className, children, ...props }, ref) {
|
|
881
|
+
const aggs = useAggregationSource(source);
|
|
882
|
+
const measures = useMeasuresSource(source);
|
|
883
|
+
const rowGroups = useRowGroupsSource(source, "vertical");
|
|
884
|
+
const pivots = useColumnPivotSource(source, "vertical");
|
|
885
|
+
const sourceItems = useMemo(() => {
|
|
886
|
+
if (source === "aggregations") return aggs.filter((c) => c.active);
|
|
887
|
+
if (source === "column-pivots") return pivots.filter((c) => c.active);
|
|
888
|
+
if (source === "measures") return measures.filter((c) => c.active);
|
|
889
|
+
if (source === "row-groups") return rowGroups.filter((c) => c.active);
|
|
890
|
+
return [];
|
|
891
|
+
}, [aggs, measures, pivots, rowGroups, source]);
|
|
892
|
+
const dropTags = useMemo(() => {
|
|
893
|
+
if (source === "aggregations") return ["aggregations"];
|
|
894
|
+
if (source === "column-pivots") return ["column-pivot"];
|
|
895
|
+
if (source === "measures") return ["measures"];
|
|
896
|
+
if (source === "row-groups") return ["row-group"];
|
|
897
|
+
return [];
|
|
898
|
+
}, [source]);
|
|
899
|
+
const dropData = useMemo(() => {
|
|
900
|
+
return { target: source, sourceItems };
|
|
901
|
+
}, [source, sourceItems]);
|
|
902
|
+
const value = useMemo(() => {
|
|
903
|
+
return { dropData, dropTags, pillSource: source };
|
|
904
|
+
}, [dropData, dropTags, source]);
|
|
905
|
+
return /* @__PURE__ */ jsx(context$1.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
906
|
+
"div",
|
|
907
|
+
{
|
|
908
|
+
...props,
|
|
909
|
+
tabIndex: 0,
|
|
910
|
+
className: clsx("lng1771-column-manager__drag-box", className),
|
|
911
|
+
ref,
|
|
912
|
+
children
|
|
913
|
+
}
|
|
914
|
+
) });
|
|
915
|
+
});
|
|
916
|
+
const useDragBox = () => useContext(context$1);
|
|
917
|
+
const ColumnManagerDragBoxControls = forwardRef(function ColumnManagerDragBoxControls2({ className, children, ...props }, ref) {
|
|
918
|
+
return /* @__PURE__ */ jsx(
|
|
919
|
+
"div",
|
|
920
|
+
{
|
|
921
|
+
...props,
|
|
922
|
+
className: clsx("lng1771-column-manager__drag-box-controls", className),
|
|
923
|
+
ref,
|
|
924
|
+
children
|
|
925
|
+
}
|
|
926
|
+
);
|
|
927
|
+
});
|
|
928
|
+
const ColumnManagerDragBoxLabel = forwardRef(function ColumnManagerDragBoxLabel2({ className, children, icon, ...props }, ref) {
|
|
929
|
+
const { pillSource: source } = useDragBox();
|
|
930
|
+
const I = useMemo(() => {
|
|
931
|
+
if (icon) return icon;
|
|
932
|
+
if (source === "aggregations") return /* @__PURE__ */ jsx(MeasuresIcon, {});
|
|
933
|
+
if (source === "measures") return /* @__PURE__ */ jsx(MeasuresIcon, {});
|
|
934
|
+
if (source === "column-pivots") return /* @__PURE__ */ jsx(ColumnPivotIcon, {});
|
|
935
|
+
if (source === "row-groups") return /* @__PURE__ */ jsx(RowGroupIcon, {});
|
|
936
|
+
}, [icon, source]);
|
|
937
|
+
return /* @__PURE__ */ jsxs("div", { ...props, className: clsx("lng1771-column-manager__drag-box-label", className), ref, children: [
|
|
938
|
+
I,
|
|
939
|
+
children
|
|
940
|
+
] });
|
|
941
|
+
});
|
|
942
|
+
const ColumnManagerDragBoxExpander = forwardRef(function ColumnManagerDragBoxExpander2({ className, ...props }, ref) {
|
|
943
|
+
const { pillSource } = useDragBox();
|
|
944
|
+
const { state: sx } = useGrid();
|
|
945
|
+
const key = pillSource === "row-groups" ? "rowGroups" : pillSource === "aggregations" ? "values" : pillSource === "column-pivots" ? "columnPivots" : "measures";
|
|
946
|
+
const expansions = sx.internal.columnManagerBoxExpansions.use();
|
|
947
|
+
const expanded = expansions[key];
|
|
948
|
+
return /* @__PURE__ */ jsx(
|
|
949
|
+
"button",
|
|
950
|
+
{
|
|
951
|
+
...props,
|
|
952
|
+
className: clsx("lng1771-column-manager__drag-box-expander", className),
|
|
953
|
+
onClick: () => {
|
|
954
|
+
const current = sx.internal.columnManagerBoxExpansions.peek();
|
|
955
|
+
const next = current[key] == null ? false : !current[key];
|
|
956
|
+
sx.internal.columnManagerBoxExpansions.set({
|
|
957
|
+
...current,
|
|
958
|
+
[key]: next
|
|
959
|
+
});
|
|
960
|
+
},
|
|
961
|
+
ref,
|
|
962
|
+
children: expanded ? /* @__PURE__ */ jsx(ArrowDownIcon, {}) : /* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
963
|
+
}
|
|
964
|
+
);
|
|
965
|
+
});
|
|
966
|
+
const ColumnManagerDropZoneVisibility = forwardRef(function ColumnManagerDropZoneVisibility2(props, ref) {
|
|
967
|
+
const { pillSource } = useDragBox();
|
|
968
|
+
const { state: sx } = useGrid();
|
|
969
|
+
const key = pillSource === "row-groups" ? "rowGroups" : pillSource === "aggregations" ? "values" : pillSource === "column-pivots" ? "columnPivots" : "measures";
|
|
970
|
+
const expansions = sx.internal.columnManagerBoxExpansions.use();
|
|
971
|
+
const expanded = expansions[key];
|
|
972
|
+
if (!expanded) return null;
|
|
973
|
+
return /* @__PURE__ */ jsx("div", { ...props, ref });
|
|
974
|
+
});
|
|
975
|
+
const ColumnManagerDropZone = forwardRef(function ColumnManagerDropZone2({ className, children, ...props }, ref) {
|
|
976
|
+
const { pillSource, dropTags, dropData } = useDragBox();
|
|
977
|
+
const {
|
|
978
|
+
canDrop,
|
|
979
|
+
isTarget,
|
|
980
|
+
isNearestOver,
|
|
981
|
+
ref: dropRef
|
|
982
|
+
} = useDroppable({
|
|
983
|
+
id: `${pillSource}-pills`,
|
|
984
|
+
accepted: dropTags,
|
|
985
|
+
data: dropData
|
|
986
|
+
});
|
|
987
|
+
const combined = useCombinedRefs(dropRef, ref);
|
|
988
|
+
return /* @__PURE__ */ jsxs(
|
|
989
|
+
"div",
|
|
990
|
+
{
|
|
991
|
+
...props,
|
|
992
|
+
className: clsx("lng1771-column-manager__drop-zone", className),
|
|
993
|
+
"data-is-drop-target": isTarget,
|
|
994
|
+
ref: combined,
|
|
995
|
+
"data-pill-source": pillSource,
|
|
996
|
+
"data-drop-visible": canDrop && dropData.sourceItems.filter((c) => c.active).length === 0,
|
|
997
|
+
tabIndex: -1,
|
|
998
|
+
children: [
|
|
999
|
+
children({ pills: dropData.sourceItems }),
|
|
1000
|
+
dropData.sourceItems.length === 0 && /* @__PURE__ */ jsx(EmtpyDefault, { source: pillSource }),
|
|
1001
|
+
canDrop && isNearestOver && dropData.sourceItems.filter((c) => c.active).length > 0 && /* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__drop-zone-indicator" })
|
|
1002
|
+
]
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
});
|
|
1006
|
+
function EmtpyDefault({ source }) {
|
|
1007
|
+
const label = useMemo(() => {
|
|
1008
|
+
if (source === "aggregations") return "Drag here to aggregate";
|
|
1009
|
+
if (source === "measures") return "Drag here to measure";
|
|
1010
|
+
if (source === "column-pivots") return "Drag here to pivot";
|
|
1011
|
+
if (source === "row-groups") return "Drag here to group";
|
|
1012
|
+
return "";
|
|
1013
|
+
}, [source]);
|
|
1014
|
+
return /* @__PURE__ */ jsxs("div", { className: "lng1771-column-manager__empty-default-container", children: [
|
|
1015
|
+
/* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__empty-default-icon", children: /* @__PURE__ */ jsx(DragGroupIcon, {}) }),
|
|
1016
|
+
/* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__empty-default-label", children: label })
|
|
1017
|
+
] });
|
|
1018
|
+
}
|
|
1019
|
+
function Separator(props) {
|
|
1020
|
+
return /* @__PURE__ */ jsx(
|
|
1021
|
+
"div",
|
|
1022
|
+
{
|
|
1023
|
+
role: "separator",
|
|
1024
|
+
"aria-orientation": props.dir,
|
|
1025
|
+
className: clsx(
|
|
1026
|
+
props.dir === "horizontal" && "lng1771-separator--horizontal",
|
|
1027
|
+
props.dir === "vertical" && "lng1771-separator--vertical",
|
|
1028
|
+
props.soft && "lng1771-separator--soft",
|
|
1029
|
+
props.className
|
|
1030
|
+
),
|
|
1031
|
+
style: props.style
|
|
1032
|
+
}
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
const context = createContext({});
|
|
1036
|
+
const useComponents = () => useContext(context);
|
|
1037
|
+
const ColumnMangerContextProvider = context.Provider;
|
|
1038
|
+
const ColumnManagerPill = forwardRef(function ColumnManagerPill2({ item, ...props }, ref) {
|
|
1039
|
+
const {
|
|
1040
|
+
ref: dropRef,
|
|
1041
|
+
isTarget,
|
|
1042
|
+
canDrop,
|
|
1043
|
+
yHalf
|
|
1044
|
+
} = useDroppable({
|
|
1045
|
+
id: item.dropId,
|
|
1046
|
+
accepted: item.dropTags,
|
|
1047
|
+
data: item.dropData,
|
|
1048
|
+
active: item.active
|
|
1049
|
+
});
|
|
1050
|
+
const grid = useGrid();
|
|
1051
|
+
const combinedRefs = useCombinedRefs(ref, dropRef);
|
|
1052
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
1053
|
+
const {
|
|
1054
|
+
aggMenuRenderer: AggMenu,
|
|
1055
|
+
measureMenuRenderer: MeasureMenu,
|
|
1056
|
+
menuTriggerIcon: TriggerIcon
|
|
1057
|
+
} = useComponents();
|
|
1058
|
+
return /* @__PURE__ */ jsxs(
|
|
1059
|
+
"div",
|
|
1060
|
+
{
|
|
1061
|
+
...props,
|
|
1062
|
+
role: "button",
|
|
1063
|
+
ref: combinedRefs,
|
|
1064
|
+
"data-pill-key": item.dropId,
|
|
1065
|
+
"data-pill-active": item.active,
|
|
1066
|
+
"data-is-droppable": isTarget && canDrop,
|
|
1067
|
+
className: "lng1771-column-manager__pill-outer",
|
|
1068
|
+
children: [
|
|
1069
|
+
/* @__PURE__ */ jsxs(
|
|
1070
|
+
Pill,
|
|
1071
|
+
{
|
|
1072
|
+
kind: item.kind,
|
|
1073
|
+
className: "lng1771-column-manager__pill-inner",
|
|
1074
|
+
interactive: true,
|
|
1075
|
+
"data-draggable": item.draggable,
|
|
1076
|
+
"data-drag-active": isDragging,
|
|
1077
|
+
children: [
|
|
1078
|
+
item.draggable && /* @__PURE__ */ jsx(DragHandle, { item, setIsDragging }),
|
|
1079
|
+
/* @__PURE__ */ jsxs("div", { className: "lng1771-column-manager__pill-labels", children: [
|
|
1080
|
+
/* @__PURE__ */ jsx("span", { children: item.label }),
|
|
1081
|
+
item.secondaryLabel && /* @__PURE__ */ jsx("span", { className: "lng1771-column-manager__pill-inner--secondary-label", children: item.secondaryLabel })
|
|
1082
|
+
] }),
|
|
1083
|
+
/* @__PURE__ */ jsxs("div", { className: "lng1771-column-manager__pill-buttons", children: [
|
|
1084
|
+
(item.isAggregation || item.isMeasure) && /* @__PURE__ */ jsxs(MenuRoot, { children: [
|
|
1085
|
+
/* @__PURE__ */ jsx(
|
|
1086
|
+
MenuTrigger,
|
|
1087
|
+
{
|
|
1088
|
+
className: "lng1771-column-manager__pill-button",
|
|
1089
|
+
"data-pill-menu-trigger": "true",
|
|
1090
|
+
onClick: (e) => e.stopPropagation(),
|
|
1091
|
+
children: /* @__PURE__ */ jsx(TriggerIcon, { width: 16, height: 16 })
|
|
1092
|
+
}
|
|
1093
|
+
),
|
|
1094
|
+
/* @__PURE__ */ jsx(MenuPortal, { children: /* @__PURE__ */ jsxs(MenuPositioner, { onClick: (ev) => ev.stopPropagation(), children: [
|
|
1095
|
+
item.isAggregation && /* @__PURE__ */ jsx(AggMenu, { grid, column: item.column }),
|
|
1096
|
+
item.isMeasure && /* @__PURE__ */ jsx(MeasureMenu, { grid, column: item.column })
|
|
1097
|
+
] }) })
|
|
1098
|
+
] }),
|
|
1099
|
+
(item.isRowGroup || item.isColumnPivot || item.isAggregation || item.isMeasure) && /* @__PURE__ */ jsx("button", { className: "lng1771-column-manager__pill-button", onClick: item.onClick, children: /* @__PURE__ */ jsx(CrossIcon, { width: 16, height: 16 }) })
|
|
1100
|
+
] })
|
|
1101
|
+
]
|
|
1102
|
+
}
|
|
1103
|
+
),
|
|
1104
|
+
canDrop && "bottom" === yHalf && /* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__drop-indicator-end" }),
|
|
1105
|
+
canDrop && "top" === yHalf && /* @__PURE__ */ jsx("div", { className: "lng1771-column-manager__drop-indicator-start" })
|
|
1106
|
+
]
|
|
1107
|
+
}
|
|
1108
|
+
);
|
|
1109
|
+
});
|
|
1110
|
+
function DragHandle({
|
|
1111
|
+
item,
|
|
1112
|
+
setIsDragging
|
|
1113
|
+
}) {
|
|
1114
|
+
const { onPointerDown, isActive } = useDraggable({
|
|
1115
|
+
id: item.label,
|
|
1116
|
+
getTags: () => item.dragTags,
|
|
1117
|
+
getData: () => item?.dragData,
|
|
1118
|
+
onDragStart: () => {
|
|
1119
|
+
document.body.classList.add("lng1771-drag-on");
|
|
1120
|
+
},
|
|
1121
|
+
onDragCancel: () => {
|
|
1122
|
+
document.body.classList.remove("lng1771-drag-on");
|
|
1123
|
+
},
|
|
1124
|
+
onDragEnd: (p) => {
|
|
1125
|
+
item.dragEnd?.(p);
|
|
1126
|
+
document.body.classList.remove("lng1771-drag-on");
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
useEffect(() => {
|
|
1130
|
+
setIsDragging(isActive);
|
|
1131
|
+
}, [isActive, setIsDragging]);
|
|
1132
|
+
return /* @__PURE__ */ jsx(
|
|
1133
|
+
"button",
|
|
1134
|
+
{
|
|
1135
|
+
tabIndex: -1,
|
|
1136
|
+
className: "lng1771-column-manager__pill-dragger",
|
|
1137
|
+
onPointerDown,
|
|
1138
|
+
children: /* @__PURE__ */ jsx(DragIcon, { width: 16, height: 16 })
|
|
1139
|
+
}
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
const ColumnManagerSearch = forwardRef(function ColumnManagerSearch2({ className, ...props }, ref) {
|
|
1143
|
+
const { query, setQuery } = useColumnManagerState();
|
|
1144
|
+
return /* @__PURE__ */ jsx(
|
|
1145
|
+
Input,
|
|
1146
|
+
{
|
|
1147
|
+
...props,
|
|
1148
|
+
ref,
|
|
1149
|
+
small: true,
|
|
1150
|
+
className: clsx("lng1771-column-manager__search-input", className),
|
|
1151
|
+
icon: SearchIcon,
|
|
1152
|
+
value: query,
|
|
1153
|
+
onChange: (e) => {
|
|
1154
|
+
setQuery(e.target.value);
|
|
1155
|
+
props.onChange?.(e);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
);
|
|
1159
|
+
});
|
|
1160
|
+
function Toggle({ on, onChange, disabled, id }) {
|
|
1161
|
+
const ref = useRef(null);
|
|
1162
|
+
return /* @__PURE__ */ jsxs(
|
|
1163
|
+
"div",
|
|
1164
|
+
{
|
|
1165
|
+
className: clsx(
|
|
1166
|
+
"lng1771-toggle",
|
|
1167
|
+
on && !disabled && "lng1771-toggle--on",
|
|
1168
|
+
disabled && "lng1771-toggle--disabled"
|
|
1169
|
+
),
|
|
1170
|
+
onClick: () => {
|
|
1171
|
+
if (disabled) return;
|
|
1172
|
+
onChange(!on);
|
|
1173
|
+
ref.current?.focus();
|
|
1174
|
+
},
|
|
1175
|
+
children: [
|
|
1176
|
+
/* @__PURE__ */ jsx(
|
|
1177
|
+
"div",
|
|
1178
|
+
{
|
|
1179
|
+
className: clsx(
|
|
1180
|
+
on && "lng1771-toggle__thumb--on",
|
|
1181
|
+
!on && "lng1771-toggle__thumb--off",
|
|
1182
|
+
disabled && "lng1771-toggle__thumb--disabled"
|
|
1183
|
+
)
|
|
1184
|
+
}
|
|
1185
|
+
),
|
|
1186
|
+
/* @__PURE__ */ jsx(
|
|
1187
|
+
"input",
|
|
1188
|
+
{
|
|
1189
|
+
ref,
|
|
1190
|
+
id,
|
|
1191
|
+
type: "checkbox",
|
|
1192
|
+
checked: on,
|
|
1193
|
+
onChange: (e) => onChange(e.target.checked),
|
|
1194
|
+
disabled
|
|
1195
|
+
}
|
|
1196
|
+
)
|
|
1197
|
+
]
|
|
1198
|
+
}
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
const PivotModeToggle = forwardRef(
|
|
1202
|
+
function PivotModeToggle2({ children, className, ...props }, ref) {
|
|
1203
|
+
const grid = useGrid();
|
|
1204
|
+
const state = grid.state;
|
|
1205
|
+
const id = useId();
|
|
1206
|
+
const pivotMode = state.columnPivotModeIsOn.use();
|
|
1207
|
+
return /* @__PURE__ */ jsxs("div", { ...props, className: clsx("lng1771-column-manager__pivot-toggle", className), ref, children: [
|
|
1208
|
+
/* @__PURE__ */ jsx(Toggle, { id, on: pivotMode, onChange: (b) => state.columnPivotModeIsOn.set(b) }),
|
|
1209
|
+
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "lng1771-column-manager__pivot-toggle-label", children: children ?? "Pivot Mode" })
|
|
1210
|
+
] });
|
|
1211
|
+
}
|
|
1212
|
+
);
|
|
1213
|
+
const Root = forwardRef(function Root2({ children, className, grid, aggMenuRenderer, measureMenuRenderer, menuTriggerIcon, ...props }, ref) {
|
|
1214
|
+
const components = useMemo(() => {
|
|
1215
|
+
return {
|
|
1216
|
+
aggMenuRenderer: aggMenuRenderer ?? PillManagerAggMenu,
|
|
1217
|
+
measureMenuRenderer: measureMenuRenderer ?? PillManagerMeasureMenu,
|
|
1218
|
+
menuTriggerIcon: menuTriggerIcon ?? MoreDotsIcon
|
|
1219
|
+
};
|
|
1220
|
+
}, [aggMenuRenderer, measureMenuRenderer, menuTriggerIcon]);
|
|
1221
|
+
return /* @__PURE__ */ jsx(ColumnStateProvider, { children: /* @__PURE__ */ jsx(ColumnMangerContextProvider, { value: components, children: /* @__PURE__ */ jsx(GridProvider, { value: grid, children: /* @__PURE__ */ jsx(DragProvider, { children: /* @__PURE__ */ jsx("div", { ...props, className: clsx("lng1771-column-manager", className), ref, children }) }) }) }) });
|
|
1222
|
+
});
|
|
1223
|
+
const ColumnManager = {
|
|
1224
|
+
Root,
|
|
1225
|
+
Tree: ColumnManagerTree,
|
|
1226
|
+
TreeItem: ColumnManagerTreeItem,
|
|
1227
|
+
PivotModeToggle,
|
|
1228
|
+
Separator,
|
|
1229
|
+
Search: ColumnManagerSearch,
|
|
1230
|
+
DragBox: ColumnManagerDragBox,
|
|
1231
|
+
DragBoxControls: ColumnManagerDragBoxControls,
|
|
1232
|
+
DragBoxLabel: ColumnManagerDragBoxLabel,
|
|
1233
|
+
DragBoxExpander: ColumnManagerDragBoxExpander,
|
|
1234
|
+
DropZoneVisibility: ColumnManagerDropZoneVisibility,
|
|
1235
|
+
DropZone: ColumnManagerDropZone,
|
|
1236
|
+
Pill: ColumnManagerPill,
|
|
1237
|
+
DragPlaceholder: ColumnManagerDragPlaceholder
|
|
1238
|
+
};
|
|
1239
|
+
export {
|
|
1240
|
+
ColumnManager
|
|
1241
|
+
};
|