@pibit.ai/cure-design-system 0.3.35 → 0.3.40
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/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +90 -85
- package/dist/patterns/table/TableWrapper.d.ts +1 -1
- package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
- package/dist/patterns/table/TableWrapper.js +815 -728
- package/dist/patterns/table/index.d.ts +5 -4
- package/dist/patterns/table/index.d.ts.map +1 -1
- package/dist/patterns/table/scrollCellIntoView.d.ts +48 -0
- package/dist/patterns/table/scrollCellIntoView.d.ts.map +1 -0
- package/dist/patterns/table/scrollCellIntoView.js +122 -0
- package/dist/patterns/table/tableZoomLayout.d.ts +59 -0
- package/dist/patterns/table/tableZoomLayout.d.ts.map +1 -0
- package/dist/patterns/table/tableZoomLayout.js +37 -0
- package/dist/patterns/table/tableZoomLayout.test.d.ts +2 -0
- package/dist/patterns/table/tableZoomLayout.test.d.ts.map +1 -0
- package/dist/patterns/table/toolbar/TableToolbar.d.ts +2 -0
- package/dist/patterns/table/toolbar/TableToolbar.d.ts.map +1 -1
- package/dist/patterns/table/toolbar/TableToolbar.js +104 -102
- package/dist/patterns/table/types.d.ts +38 -1
- package/dist/patterns/table/types.d.ts.map +1 -1
- package/dist/patterns/table/useGridKeyboardNavigation.d.ts +14 -3
- package/dist/patterns/table/useGridKeyboardNavigation.d.ts.map +1 -1
- package/dist/patterns/table/useGridKeyboardNavigation.js +47 -46
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { FlipBackward as
|
|
4
|
-
import { cx as
|
|
5
|
-
import { AlignDropdown as
|
|
6
|
-
import { GroupByDropdown as
|
|
7
|
-
import { HideFieldsDropdown as
|
|
8
|
-
import { RowHeightDropdown as
|
|
9
|
-
import { ShowSummaryDropdown as
|
|
10
|
-
import { resolveColumnLabel as
|
|
11
|
-
import { useUndoRedoShortcuts as
|
|
12
|
-
import { ExpandableSearchInput as
|
|
13
|
-
import { Button as
|
|
1
|
+
import { jsx as n, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as S, isValidElement as M, cloneElement as k, useRef as I, useState as O, useEffect as W, useLayoutEffect as U } from "react";
|
|
3
|
+
import { FlipBackward as j, FlipForward as F, ChevronSelectorVertical as P, DotsHorizontal as H } from "@untitledui/icons";
|
|
4
|
+
import { cx as A } from "../../../utils/cn.js";
|
|
5
|
+
import { AlignDropdown as T } from "./AlignDropdown.js";
|
|
6
|
+
import { GroupByDropdown as G } from "./GroupByDropdown.js";
|
|
7
|
+
import { HideFieldsDropdown as _ } from "./HideFieldsDropdown.js";
|
|
8
|
+
import { RowHeightDropdown as B } from "./RowHeightDropdown.js";
|
|
9
|
+
import { ShowSummaryDropdown as V } from "./ShowSummaryDropdown.js";
|
|
10
|
+
import { resolveColumnLabel as $ } from "./tableToolbarHelpers.js";
|
|
11
|
+
import { useUndoRedoShortcuts as q } from "./useUndoRedoShortcuts.js";
|
|
12
|
+
import { ExpandableSearchInput as E } from "../../../primitives/select/ExpandableSearchInput.js";
|
|
13
|
+
import { Button as D } from "../../../primitives/button/button.js";
|
|
14
14
|
import { Dropdown as x } from "../../../primitives/dropdown/dropdown.js";
|
|
15
|
-
import { Icon as
|
|
16
|
-
function
|
|
17
|
-
return
|
|
15
|
+
import { Icon as J } from "../../../primitives/icon/icon.js";
|
|
16
|
+
function Q(e, i) {
|
|
17
|
+
return M(e) ? k(e, {
|
|
18
18
|
onApply: i.onApply,
|
|
19
19
|
onClear: i.onClear,
|
|
20
20
|
clearAllSorts: i.onClear
|
|
21
21
|
}) : e;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
23
|
+
function X(e, i) {
|
|
24
|
+
return M(e) ? k(e, {
|
|
25
25
|
onApply: i.onApply,
|
|
26
26
|
onClearAll: i.onClearAll
|
|
27
27
|
}) : e;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const Y = ({ config: e }) => (q({
|
|
30
30
|
enabled: e.shortcut ?? !0,
|
|
31
31
|
canUndo: e.canUndo,
|
|
32
32
|
canRedo: e.canRedo,
|
|
@@ -34,31 +34,31 @@ const X = ({ config: e }) => ($({
|
|
|
34
34
|
onRedo: e.onRedo,
|
|
35
35
|
isDisabled: e.isDisabled
|
|
36
36
|
}), /* @__PURE__ */ p("div", { className: "flex items-center gap-2", children: [
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
|
|
37
|
+
/* @__PURE__ */ n(
|
|
38
|
+
D,
|
|
39
39
|
{
|
|
40
40
|
size: "xs",
|
|
41
41
|
color: "secondary",
|
|
42
|
-
iconLeading: /* @__PURE__ */
|
|
42
|
+
iconLeading: /* @__PURE__ */ n(j, { size: 16 }),
|
|
43
43
|
"aria-label": "Undo",
|
|
44
44
|
title: "Undo",
|
|
45
45
|
isDisabled: e.isDisabled || !e.canUndo,
|
|
46
46
|
onClick: e.onUndo
|
|
47
47
|
}
|
|
48
48
|
),
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
|
|
49
|
+
/* @__PURE__ */ n(
|
|
50
|
+
D,
|
|
51
51
|
{
|
|
52
52
|
size: "xs",
|
|
53
53
|
color: "secondary",
|
|
54
|
-
iconLeading: /* @__PURE__ */
|
|
54
|
+
iconLeading: /* @__PURE__ */ n(F, { size: 16 }),
|
|
55
55
|
"aria-label": "Redo",
|
|
56
56
|
title: "Redo",
|
|
57
57
|
isDisabled: e.isDisabled || !e.canRedo,
|
|
58
58
|
onClick: e.onRedo
|
|
59
59
|
}
|
|
60
60
|
)
|
|
61
|
-
] })),
|
|
61
|
+
] })), Z = ({ config: e, content: i }) => {
|
|
62
62
|
const l = e.sorts.some((r) => r.field !== "" && r.direction !== "");
|
|
63
63
|
return /* @__PURE__ */ p(
|
|
64
64
|
x.Root,
|
|
@@ -69,45 +69,45 @@ const X = ({ config: e }) => ($({
|
|
|
69
69
|
},
|
|
70
70
|
children: [
|
|
71
71
|
/* @__PURE__ */ p(
|
|
72
|
-
|
|
72
|
+
D,
|
|
73
73
|
{
|
|
74
74
|
size: "xs",
|
|
75
75
|
color: "secondary",
|
|
76
|
-
iconLeading: /* @__PURE__ */
|
|
77
|
-
className:
|
|
76
|
+
iconLeading: /* @__PURE__ */ n(P, { size: 12 }),
|
|
77
|
+
className: A(
|
|
78
78
|
l && "ring-1 ring-brand-600 bg-brand-primary text-brand-600 hover:bg-brand-primary hover:text-brand-600"
|
|
79
79
|
),
|
|
80
80
|
children: [
|
|
81
81
|
"Sort",
|
|
82
|
-
l && /* @__PURE__ */
|
|
82
|
+
l && /* @__PURE__ */ n("span", { className: "ml-1 text-xs font-semibold text-brand-600", children: e.sorts.length })
|
|
83
83
|
]
|
|
84
84
|
}
|
|
85
85
|
),
|
|
86
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ n(x.Popover, { className: "w-auto min-w-[300px]", children: i })
|
|
87
87
|
]
|
|
88
88
|
}
|
|
89
89
|
);
|
|
90
|
-
},
|
|
90
|
+
}, ee = ({ config: e, content: i }) => {
|
|
91
91
|
const l = e.meaningfulConditionsCount > 0;
|
|
92
92
|
return /* @__PURE__ */ p(x.Root, { isOpen: e.isOpen, onOpenChange: e.onOpenChange, children: [
|
|
93
93
|
/* @__PURE__ */ p(
|
|
94
|
-
|
|
94
|
+
D,
|
|
95
95
|
{
|
|
96
96
|
size: "xs",
|
|
97
97
|
color: "secondary",
|
|
98
|
-
iconLeading: /* @__PURE__ */
|
|
99
|
-
className:
|
|
98
|
+
iconLeading: /* @__PURE__ */ n(J, { name: "FilterLines", size: 12 }),
|
|
99
|
+
className: A(
|
|
100
100
|
l && "ring-1 ring-brand-600 bg-brand-primary text-brand-600 hover:bg-brand-primary hover:text-brand-600"
|
|
101
101
|
),
|
|
102
102
|
children: [
|
|
103
103
|
"Filter",
|
|
104
|
-
l && /* @__PURE__ */
|
|
104
|
+
l && /* @__PURE__ */ n("span", { className: "ml-1 text-xs font-semibold text-brand-600", children: e.meaningfulConditionsCount })
|
|
105
105
|
]
|
|
106
106
|
}
|
|
107
107
|
),
|
|
108
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ n(x.Popover, { className: "w-auto min-w-[300px]", children: i })
|
|
109
109
|
] });
|
|
110
|
-
},
|
|
110
|
+
}, we = ({
|
|
111
111
|
className: e,
|
|
112
112
|
fallbackTitle: i,
|
|
113
113
|
undoRedo: l,
|
|
@@ -119,122 +119,124 @@ const X = ({ config: e }) => ($({
|
|
|
119
119
|
align: h,
|
|
120
120
|
groupBy: m,
|
|
121
121
|
summary: g,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
beforeSearch: z,
|
|
123
|
+
trailing: y,
|
|
124
|
+
searchCollapsible: o,
|
|
125
|
+
disableExtendedTools: s = !1,
|
|
126
|
+
sortContent: a,
|
|
127
|
+
filterContent: d
|
|
127
128
|
}) => {
|
|
128
|
-
const
|
|
129
|
-
() => r &&
|
|
130
|
-
[r,
|
|
131
|
-
),
|
|
132
|
-
() => t &&
|
|
133
|
-
[t,
|
|
134
|
-
),
|
|
129
|
+
const b = S(
|
|
130
|
+
() => r && a ? Q(a, r) : a,
|
|
131
|
+
[r, a]
|
|
132
|
+
), w = S(
|
|
133
|
+
() => t && d ? X(d, t) : d,
|
|
134
|
+
[t, d]
|
|
135
|
+
), N = S(() => {
|
|
135
136
|
const c = [];
|
|
136
|
-
if (l && c.push({ id: "undo-redo", node: /* @__PURE__ */
|
|
137
|
-
const
|
|
137
|
+
if (l && c.push({ id: "undo-redo", node: /* @__PURE__ */ n(Y, { config: l }) }), r && b) {
|
|
138
|
+
const f = r.sorts.some((R) => R.field !== "" && R.direction !== "");
|
|
138
139
|
c.push({
|
|
139
140
|
id: "sort",
|
|
140
|
-
widthKey:
|
|
141
|
-
node: /* @__PURE__ */
|
|
141
|
+
widthKey: f ? String(r.sorts.length) : "",
|
|
142
|
+
node: /* @__PURE__ */ n(Z, { config: r, content: b })
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
|
-
if (t &&
|
|
145
|
+
if (t && w && c.push({
|
|
145
146
|
id: "filter",
|
|
146
147
|
widthKey: t.meaningfulConditionsCount > 0 ? String(t.meaningfulConditionsCount) : "",
|
|
147
|
-
node: /* @__PURE__ */
|
|
148
|
+
node: /* @__PURE__ */ n(ee, { config: t, content: w })
|
|
148
149
|
}), C && c.push({
|
|
149
150
|
id: "row-height",
|
|
150
|
-
node: /* @__PURE__ */
|
|
151
|
+
node: /* @__PURE__ */ n(B, { ...C, isDisabled: s })
|
|
151
152
|
}), v && c.push({
|
|
152
153
|
id: "hide-fields",
|
|
153
154
|
widthKey: v.hiddenColumns.size > 0 ? String(v.hiddenColumns.size) : "",
|
|
154
|
-
node: /* @__PURE__ */
|
|
155
|
-
}), h && c.push({ id: "align", node: /* @__PURE__ */
|
|
156
|
-
const
|
|
155
|
+
node: /* @__PURE__ */ n(_, { ...v, isDisabled: s })
|
|
156
|
+
}), h && c.push({ id: "align", node: /* @__PURE__ */ n(T, { ...h, isDisabled: s }) }), m) {
|
|
157
|
+
const f = m.value ? m.schema.find((K) => K.value === m.value) : void 0, R = f ? $(f, m.labelMeta) : "";
|
|
157
158
|
c.push({
|
|
158
159
|
id: "group-by",
|
|
159
|
-
widthKey:
|
|
160
|
-
node: /* @__PURE__ */
|
|
160
|
+
widthKey: R,
|
|
161
|
+
node: /* @__PURE__ */ n(G, { ...m, isDisabled: s })
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
164
|
return g && c.push({
|
|
164
165
|
id: "summary",
|
|
165
|
-
node: /* @__PURE__ */
|
|
166
|
+
node: /* @__PURE__ */ n(V, { ...g, isDisabled: s })
|
|
166
167
|
}), c;
|
|
167
168
|
}, [
|
|
168
169
|
l,
|
|
169
170
|
r,
|
|
170
|
-
d,
|
|
171
|
-
t,
|
|
172
171
|
b,
|
|
172
|
+
t,
|
|
173
|
+
w,
|
|
173
174
|
C,
|
|
174
175
|
v,
|
|
175
176
|
h,
|
|
176
177
|
m,
|
|
177
178
|
g,
|
|
178
|
-
|
|
179
|
+
s
|
|
179
180
|
]);
|
|
180
|
-
return /* @__PURE__ */ p("div", { className:
|
|
181
|
-
|
|
181
|
+
return /* @__PURE__ */ p("div", { className: A("flex justify-between items-center gap-2", e), children: [
|
|
182
|
+
N.length > 0 ? /* @__PURE__ */ n(oe, { items: N }) : i ? /* @__PURE__ */ n("h4", { className: "text-sm font-normal text-secondary", children: i }) : /* @__PURE__ */ n("div", {}),
|
|
182
183
|
/* @__PURE__ */ p("div", { className: "flex items-center gap-2 shrink-0", children: [
|
|
183
|
-
|
|
184
|
-
|
|
184
|
+
z,
|
|
185
|
+
u && /* @__PURE__ */ n(
|
|
186
|
+
E,
|
|
185
187
|
{
|
|
186
188
|
size: "sm",
|
|
187
189
|
placeholder: "Search",
|
|
188
190
|
value: u.value,
|
|
189
191
|
onChange: u.onChange,
|
|
190
|
-
collapsible:
|
|
191
|
-
isDisabled:
|
|
192
|
+
collapsible: o,
|
|
193
|
+
isDisabled: s,
|
|
192
194
|
shortcut: u.shortcut
|
|
193
195
|
}
|
|
194
196
|
),
|
|
195
|
-
|
|
197
|
+
y
|
|
196
198
|
] })
|
|
197
199
|
] });
|
|
198
|
-
},
|
|
199
|
-
const i =
|
|
200
|
-
|
|
200
|
+
}, ne = 40, L = 8, oe = ({ items: e }) => {
|
|
201
|
+
const i = I(null), l = I(/* @__PURE__ */ new Map()), [r, t] = O(() => /* @__PURE__ */ new Map()), [u, C] = O(null), v = S(() => e.map((o) => `${o.id}:${o.widthKey ?? ""}`).join("|"), [e]);
|
|
202
|
+
W(() => {
|
|
201
203
|
t(/* @__PURE__ */ new Map());
|
|
202
|
-
}, [v]),
|
|
204
|
+
}, [v]), U(() => {
|
|
203
205
|
if (r.size === e.length) return;
|
|
204
|
-
const
|
|
206
|
+
const o = /* @__PURE__ */ new Map();
|
|
205
207
|
for (const s of e) {
|
|
206
208
|
const a = l.current.get(s.id);
|
|
207
|
-
a &&
|
|
209
|
+
a && o.set(s.id, a.getBoundingClientRect().width);
|
|
208
210
|
}
|
|
209
|
-
|
|
210
|
-
}, [e, r]),
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
211
|
+
o.size === e.length && t(o);
|
|
212
|
+
}, [e, r]), U(() => {
|
|
213
|
+
const o = i.current;
|
|
214
|
+
if (!o) return;
|
|
213
215
|
const s = () => {
|
|
214
216
|
i.current && C(i.current.clientWidth);
|
|
215
217
|
};
|
|
216
218
|
s();
|
|
217
219
|
const a = new ResizeObserver(s);
|
|
218
|
-
return a.observe(
|
|
220
|
+
return a.observe(o), () => a.disconnect();
|
|
219
221
|
}, []);
|
|
220
|
-
const h = r.size === e.length, { visibleIds: m, overflowIds: g } =
|
|
222
|
+
const h = r.size === e.length, { visibleIds: m, overflowIds: g } = S(() => {
|
|
221
223
|
if (!h || u == null)
|
|
222
224
|
return {
|
|
223
225
|
visibleIds: new Set(e.map((d) => d.id)),
|
|
224
226
|
overflowIds: /* @__PURE__ */ new Set()
|
|
225
227
|
};
|
|
226
|
-
let
|
|
228
|
+
let o = 0;
|
|
227
229
|
const s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
228
230
|
for (let d = 0; d < e.length; d++) {
|
|
229
|
-
const b = e[d].id,
|
|
230
|
-
if (
|
|
231
|
+
const b = e[d].id, w = r.get(b) ?? 0, c = e.length - d - 1 > 0 ? ne + L : 0;
|
|
232
|
+
if (o + w + c > u) {
|
|
231
233
|
for (let f = d; f < e.length; f++) a.add(e[f].id);
|
|
232
234
|
break;
|
|
233
235
|
}
|
|
234
|
-
|
|
236
|
+
o += w + L, s.add(b);
|
|
235
237
|
}
|
|
236
238
|
return { visibleIds: s, overflowIds: a };
|
|
237
|
-
}, [e, r, u, h]), z = e.filter((
|
|
239
|
+
}, [e, r, u, h]), z = e.filter((o) => m.has(o.id)), y = e.filter((o) => g.has(o.id));
|
|
238
240
|
return /* @__PURE__ */ p(
|
|
239
241
|
"div",
|
|
240
242
|
{
|
|
@@ -242,36 +244,36 @@ const X = ({ config: e }) => ($({
|
|
|
242
244
|
className: "flex items-center gap-2 min-w-0 flex-1 overflow-hidden",
|
|
243
245
|
style: h ? void 0 : { visibility: "hidden" },
|
|
244
246
|
children: [
|
|
245
|
-
(h ? z : e).map((
|
|
247
|
+
(h ? z : e).map((o) => /* @__PURE__ */ n(
|
|
246
248
|
"div",
|
|
247
249
|
{
|
|
248
250
|
ref: (s) => {
|
|
249
|
-
l.current.set(
|
|
251
|
+
l.current.set(o.id, s);
|
|
250
252
|
},
|
|
251
253
|
className: "shrink-0",
|
|
252
|
-
children:
|
|
254
|
+
children: o.node
|
|
253
255
|
},
|
|
254
|
-
|
|
256
|
+
o.id
|
|
255
257
|
)),
|
|
256
|
-
h &&
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
|
|
258
|
+
h && y.length > 0 && /* @__PURE__ */ p(x.Root, { children: [
|
|
259
|
+
/* @__PURE__ */ n(
|
|
260
|
+
D,
|
|
259
261
|
{
|
|
260
262
|
size: "xs",
|
|
261
263
|
color: "secondary",
|
|
262
|
-
iconLeading: /* @__PURE__ */
|
|
264
|
+
iconLeading: /* @__PURE__ */ n(H, { size: 16 }),
|
|
263
265
|
"aria-label": "More tools",
|
|
264
266
|
title: "More tools",
|
|
265
267
|
className: "shrink-0"
|
|
266
268
|
}
|
|
267
269
|
),
|
|
268
|
-
/* @__PURE__ */
|
|
270
|
+
/* @__PURE__ */ n(x.Popover, { className: "w-auto", children: /* @__PURE__ */ n("div", { className: "flex flex-col items-stretch gap-2 p-2 min-w-[180px]", children: y.map((o) => /* @__PURE__ */ n("div", { className: "[&>*]:w-full", children: o.node }, o.id)) }) })
|
|
269
271
|
] })
|
|
270
272
|
]
|
|
271
273
|
}
|
|
272
274
|
);
|
|
273
275
|
};
|
|
274
|
-
function
|
|
276
|
+
function xe(e) {
|
|
275
277
|
return {
|
|
276
278
|
sort: e.sort,
|
|
277
279
|
filter: e.filter,
|
|
@@ -279,6 +281,6 @@ function we(e) {
|
|
|
279
281
|
};
|
|
280
282
|
}
|
|
281
283
|
export {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
we as TableToolbar,
|
|
285
|
+
xe as pickCoreToolbarProps
|
|
284
286
|
};
|
|
@@ -4,7 +4,7 @@ import { UndoRedoToolConfig } from './toolbar/TableToolbar';
|
|
|
4
4
|
import { LegacyFilterToolConfig, LegacySortToolConfig } from './toolbar/legacyToolbarTypes';
|
|
5
5
|
import { AlignToolConfig, GroupByToolConfig, HideFieldsToolConfig, RowHeightToolConfig, SearchToolConfig, SummaryToolConfig, CellAlignment, ColumnMenuAction, ColumnMenuCapabilities, RowActionsConfig, RowGroup, SummaryFooterRowProps } from './toolbar';
|
|
6
6
|
import { TableCellRangeRect, TableCellSelection } from './cellRangeSelection';
|
|
7
|
-
export type { TableCellCoord, TableCellRangeRect, TableCellSelection } from './cellRangeSelection';
|
|
7
|
+
export type { TableCellCoord, TableCellRangeRect, TableCellSelection, } from './cellRangeSelection';
|
|
8
8
|
/** Value type used for alignment defaults and aggregation eligibility. */
|
|
9
9
|
export type TableColumnValueType = "string" | "number" | "currency" | "date" | "percentage" | "decimal_percentage" | "array" | "link";
|
|
10
10
|
/**
|
|
@@ -34,6 +34,41 @@ export interface TableColumnMenuSchema {
|
|
|
34
34
|
}
|
|
35
35
|
/** Alias for `TablePaginationConfig` — matches platform-ui `TableWrapperPaginationConfig`. */
|
|
36
36
|
export type TableWrapperPaginationConfig = TablePaginationConfig;
|
|
37
|
+
/**
|
|
38
|
+
* Opt-in Excel-style zoom for horizontally wide tables. Values are percentages, and the
|
|
39
|
+
* zoom scales the whole grid — text, padding, row heights and column widths together —
|
|
40
|
+
* so lowering it fits more columns in the available width at a smaller size.
|
|
41
|
+
*
|
|
42
|
+
* Zooming out never paints the grid narrower than its container: the columns shrink while
|
|
43
|
+
* the grid still overflows, then hold once it exactly fills, so the table is never left
|
|
44
|
+
* with dead space to its right.
|
|
45
|
+
*
|
|
46
|
+
* Requires CSS `zoom` (Chrome 128+, Safari, Firefox 126+). On an engine without it the
|
|
47
|
+
* table falls back to its unzoomed layout and the control is not rendered, so there is no
|
|
48
|
+
* dead slider — but there is also no zoom.
|
|
49
|
+
*
|
|
50
|
+
* The object may be a fresh literal on every render; `TableWrapper` keys its internal
|
|
51
|
+
* config off the four values below, not the object identity, so an inline literal will not
|
|
52
|
+
* reset a zoom level the user has set.
|
|
53
|
+
*/
|
|
54
|
+
export type TableZoomConfig = {
|
|
55
|
+
/** Initial zoom percentage. Defaults to 100. */
|
|
56
|
+
defaultZoom?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Lowest allowed zoom percentage. Defaults to 60, and is the real limit — zooming out
|
|
59
|
+
* past the point where the grid fits is allowed, so on a table that already fills its
|
|
60
|
+
* container the columns keep shrinking and the right edge pulls in from the container.
|
|
61
|
+
*/
|
|
62
|
+
minZoom?: number;
|
|
63
|
+
/** Highest allowed zoom percentage. Defaults to 120. */
|
|
64
|
+
maxZoom?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Increment the slider snaps to, in percentage points. Defaults to 10. Steps are measured
|
|
67
|
+
* from `minZoom`, so a step that divides the range keeps the readout on round numbers.
|
|
68
|
+
* Set to 1 for continuous dragging.
|
|
69
|
+
*/
|
|
70
|
+
step?: number;
|
|
71
|
+
};
|
|
37
72
|
export type TableWrapperToolbarConfig = {
|
|
38
73
|
sort?: LegacySortToolConfig;
|
|
39
74
|
filter?: LegacyFilterToolConfig;
|
|
@@ -137,6 +172,8 @@ export type TableWrapperProps = {
|
|
|
137
172
|
labelMeta?: unknown;
|
|
138
173
|
toolbarSlot?: ReactNode;
|
|
139
174
|
fillWidth?: boolean;
|
|
175
|
+
/** Enables compact column zoom controls and calculated column widths. */
|
|
176
|
+
zoom?: TableZoomConfig;
|
|
140
177
|
rowActions?: RowActionsConfig;
|
|
141
178
|
onCellActivate?: (info: {
|
|
142
179
|
rowId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,QAAQ,EACR,qBAAqB,EACtB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,MAAM,GACN,YAAY,GACZ,oBAAoB,GACpB,OAAO,GACP,MAAM,CAAC;AAEX;;;GAGG;AACH,MAAM,WAAW,iBAAiB;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AY,CAAC,EAAE,CAAC,OAAO,EAAE;QACvB,SAAS,EAAE,kBAAkB,CAAC;QAC9B,IAAI,EAAE,kBAAkB,CAAC;QACzB,KAAK,EAAE,aAAa,CAAC;KACtB,KAAK,IAAI,CAAC;CACZ,CAAC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ReactNode, RefObject } from 'react';
|
|
2
2
|
export type GridNavDirection = "up" | "down" | "left" | "right";
|
|
3
|
+
/** Options for moving grid focus; `dir` lets the scroll align the edge being travelled toward. */
|
|
4
|
+
export type FocusGridCellOptions = {
|
|
5
|
+
dir?: GridNavDirection | null;
|
|
6
|
+
};
|
|
3
7
|
export interface GridNeighbor {
|
|
4
8
|
rowId: string;
|
|
5
9
|
columnKey: string;
|
|
@@ -9,7 +13,7 @@ export interface GridNeighbor {
|
|
|
9
13
|
export interface GridNavValue {
|
|
10
14
|
getNeighbor: (rowId: string, columnKey: string, dir: GridNavDirection) => GridNeighbor | null;
|
|
11
15
|
getTabNeighbor: (rowId: string, columnKey: string, forward: boolean) => GridNeighbor | null;
|
|
12
|
-
focusCell: (rowId: string, columnKey: string) => boolean;
|
|
16
|
+
focusCell: (rowId: string, columnKey: string, options?: FocusGridCellOptions) => boolean;
|
|
13
17
|
selectCell: (rowId: string, columnKey: string, sourceIndex?: number | null) => void;
|
|
14
18
|
setEditingCell: (cell: {
|
|
15
19
|
rowId: string;
|
|
@@ -21,8 +25,15 @@ export declare const isWithinCellEditor: (target: EventTarget | null) => boolean
|
|
|
21
25
|
export declare const findGridCell: (container: HTMLElement | null, rowId: string, columnKey: string) => HTMLElement | null;
|
|
22
26
|
export declare const getGridNeighbor: (container: HTMLElement | null, rowIds: readonly string[], columnKeys: readonly string[], rowId: string, columnKey: string, dir: GridNavDirection) => GridNeighbor | null;
|
|
23
27
|
export declare const getGridTabNeighbor: (container: HTMLElement | null, rowIds: readonly string[], columnKeys: readonly string[], rowId: string, columnKey: string, forward: boolean) => GridNeighbor | null;
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Focus a cell and bring it fully into view.
|
|
30
|
+
*
|
|
31
|
+
* The implicit scroll from `focus()` is suppressed: it targets the inner focus wrapper and ignores
|
|
32
|
+
* sticky chrome, so it leaves the cell's padding and range border clipped. `scrollGridCellIntoView`
|
|
33
|
+
* scrolls the `<td>` itself, accounting for the sticky header and sticky columns.
|
|
34
|
+
*/
|
|
35
|
+
export declare const focusGridCellElement: (cell: HTMLElement | null, options?: FocusGridCellOptions) => boolean;
|
|
36
|
+
export declare const focusGridCell: (container: HTMLElement | null, rowId: string, columnKey: string, options?: FocusGridCellOptions) => boolean;
|
|
26
37
|
export declare const GridNavProvider: ({ rowIds, columnKeys, containerRef, onSelectCell, onEditingCellChange, children, }: {
|
|
27
38
|
rowIds: string[];
|
|
28
39
|
columnKeys: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGridKeyboardNavigation.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/useGridKeyboardNavigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useGridKeyboardNavigation.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/useGridKeyboardNavigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxG,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhE,kGAAkG;AAClG,MAAM,MAAM,oBAAoB,GAAG;IAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAA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,EAC7B,OAAO,MAAM,EACb,WAAW,MAAM,EACjB,SAAS,OAAO,KACf,YAAY,GAAG,IAgBjB,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,WAAW,GAAG,IAAI,EACxB,UAAS,oBAAyB,KACjC,OAMF,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,WAAW,WAAW,GAAG,IAAI,EAC7B,OAAO,MAAM,EACb,WAAW,MAAM,EACjB,UAAS,oBAAyB,KACjC,OAAmF,CAAC;AAEvF,eAAO,MAAM,eAAe,GAAI,oFAO7B;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC5C,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACtF,mBAAmB,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,KAAK,IAAI,CAAC;IACjF,QAAQ,EAAE,SAAS,CAAC;CACrB,4CA+BA,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAO,YAAY,GAAG,IAAkC,CAAC"}
|
|
@@ -1,65 +1,66 @@
|
|
|
1
1
|
import { jsx as C } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { useContext as p, useCallback as g, useMemo as h, createContext as G } from "react";
|
|
3
|
+
import { scrollGridCellIntoView as S } from "./scrollCellIntoView.js";
|
|
4
|
+
const x = G(null), v = (e, r) => `[data-grid-cell][data-grid-row-id="${CSS.escape(e)}"][data-grid-col-key="${CSS.escape(r)}"]`, M = (e) => e instanceof HTMLElement ? !!(e.closest('[contenteditable]:not([contenteditable="false"])') || e.closest("input, textarea, select") || e.closest('[role="textbox"]')) : !1, b = (e, r, t) => (e == null ? void 0 : e.querySelector(v(r, t))) ?? null, N = (e, r, t, l, c) => {
|
|
5
|
+
if (l < 0 || l >= r.length || c < 0 || c >= t.length) return null;
|
|
6
|
+
const s = r[l], u = t[c], i = b(e, s, u);
|
|
7
|
+
if (!i) return null;
|
|
8
|
+
const n = i.getAttribute("data-grid-source-index"), o = n != null && n !== "" ? Number(n) : NaN;
|
|
8
9
|
return {
|
|
9
10
|
rowId: s,
|
|
10
|
-
columnKey:
|
|
11
|
+
columnKey: u,
|
|
11
12
|
sourceIndex: Number.isNaN(o) ? null : o,
|
|
12
|
-
element:
|
|
13
|
+
element: i
|
|
13
14
|
};
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
let n =
|
|
18
|
-
return s === "up" ? n -= 1 : s === "down" ? n += 1 : s === "left" ? o -= 1 : s === "right" && (o += 1), N(e,
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
let n =
|
|
23
|
-
return o >=
|
|
24
|
-
},
|
|
25
|
-
const t =
|
|
26
|
-
return !t || typeof t.focus != "function" ? !1 : (t.focus(), !0);
|
|
27
|
-
},
|
|
15
|
+
}, m = (e, r, t, l, c, s) => {
|
|
16
|
+
const u = r.indexOf(l), i = t.indexOf(c);
|
|
17
|
+
if (u === -1 || i === -1) return null;
|
|
18
|
+
let n = u, o = i;
|
|
19
|
+
return s === "up" ? n -= 1 : s === "down" ? n += 1 : s === "left" ? o -= 1 : s === "right" && (o += 1), N(e, r, t, n, o);
|
|
20
|
+
}, I = (e, r, t, l, c, s) => {
|
|
21
|
+
const u = r.indexOf(l), i = t.indexOf(c);
|
|
22
|
+
if (u === -1 || i === -1) return null;
|
|
23
|
+
let n = u, o = i + (s ? 1 : -1);
|
|
24
|
+
return o >= t.length ? (o = 0, n += 1) : o < 0 && (o = t.length - 1, n -= 1), N(e, r, t, n, o);
|
|
25
|
+
}, O = (e) => (e == null ? void 0 : e.querySelector("[data-grid-focus]")) ?? e, T = (e, r = {}) => {
|
|
26
|
+
const t = O(e);
|
|
27
|
+
return !t || typeof t.focus != "function" ? !1 : (t.focus({ preventScroll: !0 }), S(e, { dir: r.dir ?? null }), !0);
|
|
28
|
+
}, E = (e, r, t, l = {}) => T(b(e, r, t), l), P = ({
|
|
28
29
|
rowIds: e,
|
|
29
|
-
columnKeys:
|
|
30
|
-
containerRef:
|
|
31
|
-
onSelectCell:
|
|
30
|
+
columnKeys: r,
|
|
31
|
+
containerRef: t,
|
|
32
|
+
onSelectCell: l,
|
|
32
33
|
onEditingCellChange: c,
|
|
33
34
|
children: s
|
|
34
35
|
}) => {
|
|
35
|
-
const
|
|
36
|
-
(d, f, a) =>
|
|
37
|
-
[
|
|
38
|
-
),
|
|
39
|
-
(d, f, a) =>
|
|
40
|
-
[
|
|
36
|
+
const u = g(
|
|
37
|
+
(d, f, a) => m(t.current, e, r, d, f, a),
|
|
38
|
+
[t, e, r]
|
|
39
|
+
), i = g(
|
|
40
|
+
(d, f, a) => I(t.current, e, r, d, f, a),
|
|
41
|
+
[t, e, r]
|
|
41
42
|
), n = g(
|
|
42
|
-
(d, f) =>
|
|
43
|
-
[
|
|
44
|
-
), o =
|
|
43
|
+
(d, f, a) => E(t.current, d, f, a),
|
|
44
|
+
[t]
|
|
45
|
+
), o = h(
|
|
45
46
|
() => ({
|
|
46
|
-
getNeighbor:
|
|
47
|
-
getTabNeighbor:
|
|
47
|
+
getNeighbor: u,
|
|
48
|
+
getTabNeighbor: i,
|
|
48
49
|
focusCell: n,
|
|
49
|
-
selectCell:
|
|
50
|
+
selectCell: l,
|
|
50
51
|
setEditingCell: c
|
|
51
52
|
}),
|
|
52
|
-
[
|
|
53
|
+
[u, i, n, l, c]
|
|
53
54
|
);
|
|
54
55
|
return /* @__PURE__ */ C(x.Provider, { value: o, children: s });
|
|
55
|
-
},
|
|
56
|
+
}, $ = () => p(x);
|
|
56
57
|
export {
|
|
57
|
-
|
|
58
|
+
P as GridNavProvider,
|
|
58
59
|
b as findGridCell,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
E as focusGridCell,
|
|
61
|
+
T as focusGridCellElement,
|
|
62
|
+
m as getGridNeighbor,
|
|
63
|
+
I as getGridTabNeighbor,
|
|
64
|
+
M as isWithinCellEditor,
|
|
65
|
+
$ as useGridKeyboardNavigation
|
|
65
66
|
};
|