@rozie-ui/data-table-solid 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs +68 -287
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +43 -285
- package/package.json +5 -7
- package/src/Column.tsx +1 -1
- package/src/DataTable.tsx +68 -15
- package/src/EditorSelect.tsx +1 -1
- package/src/EditorText.tsx +21 -4
- package/src/FilterSelect.tsx +1 -1
- package/src/GroupBar.tsx +1 -1
- package/src/Popover.tsx +0 -416
- package/src/internal/middleware.ts +0 -54
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Idiomatic **solid** `DataTable` — a headless, fully-accessible (WAI-ARIA) data
|
|
|
8
8
|
npm i @rozie-ui/data-table-solid
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Peer dependencies: `solid-js + @tanstack/table-core + @tanstack/virtual-core + @
|
|
11
|
+
Peer dependencies: `solid-js + @tanstack/table-core + @tanstack/virtual-core + @rozie-ui/popover-solid`. Install them alongside this package.
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
@@ -529,5 +529,5 @@ The `detail` (expandable rows), `groupBar` (grouping) and `filter` (faceted filt
|
|
|
529
529
|
| filter | columnId, value, uniqueValues, minMax, setFilter |
|
|
530
530
|
| selectCell | row, checked, toggle |
|
|
531
531
|
| cell | columnId, column, row, value |
|
|
532
|
-
| editor | columnId, column, row, value, commit, cancel |
|
|
532
|
+
| editor | columnId, column, row, value, commit, cancel, autofocus |
|
|
533
533
|
| detail | row |
|
package/dist/index.cjs
CHANGED
|
@@ -2,286 +2,35 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
var __create = Object.create;
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
//#endregion
|
|
5
27
|
let Solid_js = require("solid-js");
|
|
6
28
|
let _solid_primitives_keyed = require("@solid-primitives/keyed");
|
|
7
29
|
let _rozie_runtime_solid = require("@rozie/runtime-solid");
|
|
8
|
-
let
|
|
30
|
+
let _rozie_ui_popover_solid = require("@rozie-ui/popover-solid");
|
|
31
|
+
_rozie_ui_popover_solid = __toESM(_rozie_ui_popover_solid);
|
|
9
32
|
let _tanstack_table_core = require("@tanstack/table-core");
|
|
10
33
|
let _tanstack_virtual_core = require("@tanstack/virtual-core");
|
|
11
|
-
//#region src/internal/middleware.ts
|
|
12
|
-
/**
|
|
13
|
-
* Build the ordered middleware array for `computePosition`. Pure — no engine
|
|
14
|
-
* import, no DOM read beyond the passed-in arrow element.
|
|
15
|
-
*/
|
|
16
|
-
function buildMiddleware(factories, config) {
|
|
17
|
-
const mw = [factories.offset(config.offset)];
|
|
18
|
-
if (!config.disableFlip) mw.push(factories.flip());
|
|
19
|
-
if (!config.disableShift) mw.push(factories.shift());
|
|
20
|
-
if (config.arrow && config.arrowEl) mw.push(factories.arrow({ element: config.arrowEl }));
|
|
21
|
-
return mw;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/Popover.tsx
|
|
25
|
-
(0, _rozie_runtime_solid.__rozieInjectStyle)("Popover-c6cf02ea", `.rozie-popover[data-rozie-s-c6cf02ea] {
|
|
26
|
-
display: contents;
|
|
27
|
-
}
|
|
28
|
-
.rozie-popover-anchor[data-rozie-s-c6cf02ea] {
|
|
29
|
-
display: inline-block;
|
|
30
|
-
}
|
|
31
|
-
.rozie-popover-floating[data-rozie-s-c6cf02ea] {
|
|
32
|
-
position: absolute;
|
|
33
|
-
left: 0;
|
|
34
|
-
top: 0;
|
|
35
|
-
z-index: var(--rozie-popover-z, 1000);
|
|
36
|
-
width: max-content;
|
|
37
|
-
max-width: var(--rozie-popover-max-width, calc(100vw - 16px));
|
|
38
|
-
background: var(--rozie-popover-bg, #fff);
|
|
39
|
-
color: var(--rozie-popover-color, inherit);
|
|
40
|
-
border: var(--rozie-popover-border, 1px solid rgba(0, 0, 0, 0.12));
|
|
41
|
-
border-radius: var(--rozie-popover-radius, 8px);
|
|
42
|
-
box-shadow: var(--rozie-popover-shadow, 0 8px 24px rgba(0, 0, 0, 0.12));
|
|
43
|
-
padding: var(--rozie-popover-padding, 8px 12px);
|
|
44
|
-
}
|
|
45
|
-
.rozie-popover-arrow[data-rozie-s-c6cf02ea] {
|
|
46
|
-
position: absolute;
|
|
47
|
-
width: var(--rozie-popover-arrow-size, 8px);
|
|
48
|
-
height: var(--rozie-popover-arrow-size, 8px);
|
|
49
|
-
background: var(--rozie-popover-bg, #fff);
|
|
50
|
-
border: var(--rozie-popover-border, 1px solid rgba(0, 0, 0, 0.12));
|
|
51
|
-
transform: rotate(45deg);
|
|
52
|
-
}`);
|
|
53
|
-
function Popover(_props) {
|
|
54
|
-
const [local, attrs] = (0, Solid_js.splitProps)((0, Solid_js.mergeProps)({
|
|
55
|
-
placement: "bottom",
|
|
56
|
-
trigger: "click",
|
|
57
|
-
offset: 8,
|
|
58
|
-
disableFlip: false,
|
|
59
|
-
disableShift: false,
|
|
60
|
-
arrow: false,
|
|
61
|
-
disabled: false,
|
|
62
|
-
modal: false,
|
|
63
|
-
strategy: "absolute"
|
|
64
|
-
}, _props), [
|
|
65
|
-
"open",
|
|
66
|
-
"placement",
|
|
67
|
-
"trigger",
|
|
68
|
-
"offset",
|
|
69
|
-
"disableFlip",
|
|
70
|
-
"disableShift",
|
|
71
|
-
"arrow",
|
|
72
|
-
"disabled",
|
|
73
|
-
"modal",
|
|
74
|
-
"strategy",
|
|
75
|
-
"children",
|
|
76
|
-
"ref"
|
|
77
|
-
]);
|
|
78
|
-
const resolved = (0, Solid_js.children)(() => local.children);
|
|
79
|
-
(0, Solid_js.onMount)(() => {
|
|
80
|
-
local.ref?.({
|
|
81
|
-
show,
|
|
82
|
-
hide,
|
|
83
|
-
toggle,
|
|
84
|
-
reposition
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
const [open, setOpen] = (0, _rozie_runtime_solid.createControllableSignal)(_props, "open", false);
|
|
88
|
-
(0, Solid_js.onMount)(() => {
|
|
89
|
-
const _cleanup = (() => {
|
|
90
|
-
anchorNode = anchorElRef;
|
|
91
|
-
if (open() && !local.disabled) {
|
|
92
|
-
floatingNode = floatingElRef;
|
|
93
|
-
arrowNode = arrowElRef;
|
|
94
|
-
startTracking();
|
|
95
|
-
}
|
|
96
|
-
})();
|
|
97
|
-
if (_cleanup) (0, Solid_js.onCleanup)(_cleanup);
|
|
98
|
-
(0, Solid_js.onCleanup)(() => {
|
|
99
|
-
stopTracking();
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
(0, Solid_js.createEffect)((0, Solid_js.on)(() => open(), (v) => (0, Solid_js.untrack)(() => ((isOpen) => {
|
|
103
|
-
if (isOpen && !local.disabled) queueMicrotask(() => {
|
|
104
|
-
if (!open() || local.disabled) return;
|
|
105
|
-
floatingNode = floatingElRef;
|
|
106
|
-
arrowNode = arrowElRef;
|
|
107
|
-
startTracking();
|
|
108
|
-
});
|
|
109
|
-
else stopTracking();
|
|
110
|
-
})(v)), { defer: true }));
|
|
111
|
-
(0, Solid_js.createEffect)((0, Solid_js.on)(() => local.placement, (v) => (0, Solid_js.untrack)(() => (() => {
|
|
112
|
-
if (open()) position();
|
|
113
|
-
})()), { defer: true }));
|
|
114
|
-
(0, Solid_js.createEffect)((0, Solid_js.on)(() => local.offset, (v) => (0, Solid_js.untrack)(() => (() => {
|
|
115
|
-
if (open()) position();
|
|
116
|
-
})()), { defer: true }));
|
|
117
|
-
(0, Solid_js.createEffect)((0, Solid_js.on)(() => local.disableFlip, (v) => (0, Solid_js.untrack)(() => (() => {
|
|
118
|
-
if (open()) position();
|
|
119
|
-
})()), { defer: true }));
|
|
120
|
-
(0, Solid_js.createEffect)((0, Solid_js.on)(() => local.disableShift, (v) => (0, Solid_js.untrack)(() => (() => {
|
|
121
|
-
if (open()) position();
|
|
122
|
-
})()), { defer: true }));
|
|
123
|
-
(0, Solid_js.createEffect)((0, Solid_js.on)(() => local.strategy, (v) => (0, Solid_js.untrack)(() => (() => {
|
|
124
|
-
if (open()) position();
|
|
125
|
-
})()), { defer: true }));
|
|
126
|
-
let anchorElRef = null;
|
|
127
|
-
let floatingElRef = null;
|
|
128
|
-
let arrowElRef = null;
|
|
129
|
-
let anchorNode = null;
|
|
130
|
-
let floatingNode = null;
|
|
131
|
-
let arrowNode = null;
|
|
132
|
-
let stopAutoUpdate = null;
|
|
133
|
-
let lastFocusedEl = null;
|
|
134
|
-
function deepActiveElement() {
|
|
135
|
-
let el = document.activeElement;
|
|
136
|
-
while (el && el.shadowRoot && el.shadowRoot.activeElement) el = el.shadowRoot.activeElement;
|
|
137
|
-
return el;
|
|
138
|
-
}
|
|
139
|
-
function requestOpen(next) {
|
|
140
|
-
if (open() === next) return;
|
|
141
|
-
if (next && local.trigger === "click") lastFocusedEl = deepActiveElement();
|
|
142
|
-
setOpen(next);
|
|
143
|
-
_props.onChange?.(next);
|
|
144
|
-
if (!next && local.trigger === "click" && lastFocusedEl && lastFocusedEl.isConnected && typeof lastFocusedEl.focus === "function") lastFocusedEl.focus();
|
|
145
|
-
if (!next) lastFocusedEl = null;
|
|
146
|
-
}
|
|
147
|
-
function applyPosition(x, y, middlewareData) {
|
|
148
|
-
if (!floatingNode) return;
|
|
149
|
-
floatingNode.style.left = x + "px";
|
|
150
|
-
floatingNode.style.top = y + "px";
|
|
151
|
-
if (arrowNode && middlewareData && middlewareData.arrow) {
|
|
152
|
-
const ax = middlewareData.arrow.x;
|
|
153
|
-
const ay = middlewareData.arrow.y;
|
|
154
|
-
arrowNode.style.left = ax == null ? "" : ax + "px";
|
|
155
|
-
arrowNode.style.top = ay == null ? "" : ay + "px";
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function position() {
|
|
159
|
-
if (!anchorNode || !floatingNode) return;
|
|
160
|
-
const middleware = buildMiddleware({
|
|
161
|
-
offset: _floating_ui_dom.offset,
|
|
162
|
-
flip: _floating_ui_dom.flip,
|
|
163
|
-
shift: _floating_ui_dom.shift,
|
|
164
|
-
arrow: _floating_ui_dom.arrow
|
|
165
|
-
}, {
|
|
166
|
-
offset: local.offset,
|
|
167
|
-
disableFlip: local.disableFlip,
|
|
168
|
-
disableShift: local.disableShift,
|
|
169
|
-
arrow: local.arrow,
|
|
170
|
-
arrowEl: arrowNode
|
|
171
|
-
});
|
|
172
|
-
if (local.strategy === "fixed") floatingNode.style.position = "fixed";
|
|
173
|
-
else floatingNode.style.position = "";
|
|
174
|
-
let opts = null;
|
|
175
|
-
opts = {
|
|
176
|
-
placement: local.placement,
|
|
177
|
-
strategy: local.strategy,
|
|
178
|
-
middleware
|
|
179
|
-
};
|
|
180
|
-
(0, _floating_ui_dom.computePosition)(anchorNode, floatingNode, opts).then((result) => {
|
|
181
|
-
applyPosition(result.x, result.y, result.middlewareData);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
function startTracking() {
|
|
185
|
-
if (!anchorNode || !floatingNode) return;
|
|
186
|
-
if (stopAutoUpdate) {
|
|
187
|
-
stopAutoUpdate();
|
|
188
|
-
stopAutoUpdate = null;
|
|
189
|
-
}
|
|
190
|
-
stopAutoUpdate = (0, _floating_ui_dom.autoUpdate)(anchorNode, floatingNode, position);
|
|
191
|
-
}
|
|
192
|
-
function stopTracking() {
|
|
193
|
-
if (stopAutoUpdate) {
|
|
194
|
-
stopAutoUpdate();
|
|
195
|
-
stopAutoUpdate = null;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
function onAnchorClick() {
|
|
199
|
-
if (local.disabled) return;
|
|
200
|
-
requestOpen(!open());
|
|
201
|
-
}
|
|
202
|
-
function onAnchorPointerEnter() {
|
|
203
|
-
if (local.disabled) return;
|
|
204
|
-
requestOpen(true);
|
|
205
|
-
}
|
|
206
|
-
function onAnchorPointerLeave() {
|
|
207
|
-
if (local.disabled) return;
|
|
208
|
-
requestOpen(false);
|
|
209
|
-
}
|
|
210
|
-
function onAnchorFocus() {
|
|
211
|
-
if (local.disabled) return;
|
|
212
|
-
requestOpen(true);
|
|
213
|
-
}
|
|
214
|
-
function onAnchorBlur() {
|
|
215
|
-
if (local.disabled) return;
|
|
216
|
-
requestOpen(false);
|
|
217
|
-
}
|
|
218
|
-
function dismiss() {
|
|
219
|
-
requestOpen(false);
|
|
220
|
-
}
|
|
221
|
-
function isTooltip() {
|
|
222
|
-
return local.trigger === "hover" || local.trigger === "focus";
|
|
223
|
-
}
|
|
224
|
-
function floatingRole() {
|
|
225
|
-
return isTooltip() ? "tooltip" : local.modal ? "dialog" : void 0;
|
|
226
|
-
}
|
|
227
|
-
function show() {
|
|
228
|
-
if (!local.disabled) requestOpen(true);
|
|
229
|
-
}
|
|
230
|
-
function hide() {
|
|
231
|
-
requestOpen(false);
|
|
232
|
-
}
|
|
233
|
-
function toggle() {
|
|
234
|
-
if (!local.disabled) requestOpen(!open());
|
|
235
|
-
}
|
|
236
|
-
function reposition() {
|
|
237
|
-
position();
|
|
238
|
-
}
|
|
239
|
-
(0, Solid_js.createEffect)(() => {
|
|
240
|
-
if (!open()) return;
|
|
241
|
-
const _rozieHandler = ($event) => {
|
|
242
|
-
if ($event.key !== "Escape") return;
|
|
243
|
-
dismiss();
|
|
244
|
-
};
|
|
245
|
-
document.addEventListener("keydown", _rozieHandler);
|
|
246
|
-
(0, Solid_js.onCleanup)(() => document.removeEventListener("keydown", _rozieHandler));
|
|
247
|
-
});
|
|
248
|
-
(0, _rozie_runtime_solid.createOutsideClick)([() => anchorElRef, () => floatingElRef], dismiss, () => open());
|
|
249
|
-
return <>
|
|
250
|
-
<div {...attrs} class={"rozie-popover" + (attrs.class ? " " + attrs.class : "")} data-rozie-s-c6cf02ea="">
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
<div aria-haspopup="dialog" aria-expanded={!!open()} aria-describedby={(0, _rozie_runtime_solid.rozieAttr)(isTooltip() && open() ? "rozie-popover-floating" : null)} class={"rozie-popover-anchor"} ref={(el) => {
|
|
254
|
-
anchorElRef = el;
|
|
255
|
-
}} onClick={($event) => {
|
|
256
|
-
local.trigger === "click" && onAnchorClick();
|
|
257
|
-
}} onPointerEnter={($event) => {
|
|
258
|
-
local.trigger === "hover" && onAnchorPointerEnter();
|
|
259
|
-
}} onPointerLeave={($event) => {
|
|
260
|
-
local.trigger === "hover" && onAnchorPointerLeave();
|
|
261
|
-
}} onFocusIn={($event) => {
|
|
262
|
-
local.trigger === "focus" && onAnchorFocus();
|
|
263
|
-
}} onFocusOut={($event) => {
|
|
264
|
-
local.trigger === "focus" && onAnchorBlur();
|
|
265
|
-
}} data-rozie-s-c6cf02ea="">
|
|
266
|
-
{(_props.anchorSlot ?? _props.slots?.["anchor"])?.({
|
|
267
|
-
open: open(),
|
|
268
|
-
toggle,
|
|
269
|
-
show,
|
|
270
|
-
hide
|
|
271
|
-
})}
|
|
272
|
-
</div>
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
{<Solid_js.Show when={open() && !local.disabled}><div class={"rozie-popover-floating"} ref={(el) => {
|
|
276
|
-
floatingElRef = el;
|
|
277
|
-
}} id="rozie-popover-floating" role={(0, _rozie_runtime_solid.rozieAttr)(floatingRole())} aria-modal={!!(floatingRole() === "dialog")} data-rozie-s-c6cf02ea="">
|
|
278
|
-
{<Solid_js.Show when={local.arrow}><div class={"rozie-popover-arrow"} ref={(el) => {
|
|
279
|
-
arrowElRef = el;
|
|
280
|
-
}} data-rozie-s-c6cf02ea="" /></Solid_js.Show>}{resolved()}
|
|
281
|
-
</div></Solid_js.Show>}</div>
|
|
282
|
-
</>;
|
|
283
|
-
}
|
|
284
|
-
//#endregion
|
|
285
34
|
//#region src/DataTable.tsx
|
|
286
35
|
(0, _rozie_runtime_solid.__rozieInjectStyle)("DataTable-d5dcab4c", `.rozie-data-table[data-rozie-s-d5dcab4c] {
|
|
287
36
|
border-collapse: collapse;
|
|
@@ -738,6 +487,7 @@ function DataTable(_props) {
|
|
|
738
487
|
const [draftValue, setDraftValue] = (0, Solid_js.createSignal)(null);
|
|
739
488
|
const [invalidMsg, setInvalidMsg] = (0, Solid_js.createSignal)("");
|
|
740
489
|
const [editVer, setEditVer] = (0, Solid_js.createSignal)(0);
|
|
490
|
+
const [editFocusColId, setEditFocusColId] = (0, Solid_js.createSignal)(null);
|
|
741
491
|
const [editingRowIndex, setEditingRowIndex] = (0, Solid_js.createSignal)(null);
|
|
742
492
|
const [rowDraft, setRowDraft] = (0, Solid_js.createSignal)({});
|
|
743
493
|
const [rangeAnchor, setRangeAnchor] = (0, Solid_js.createSignal)(null);
|
|
@@ -1722,8 +1472,7 @@ function DataTable(_props) {
|
|
|
1722
1472
|
const base = pinStyle(colId);
|
|
1723
1473
|
if (isExpanderColumn(colId) && row && row.depth) {
|
|
1724
1474
|
const pad = "padding-left:" + (.5 + row.depth * 1.25) + "rem";
|
|
1725
|
-
|
|
1726
|
-
return base ? base + sep + pad : pad;
|
|
1475
|
+
return base ? base + pad : pad;
|
|
1727
1476
|
}
|
|
1728
1477
|
return base;
|
|
1729
1478
|
}
|
|
@@ -3180,6 +2929,7 @@ function DataTable(_props) {
|
|
|
3180
2929
|
}
|
|
3181
2930
|
function focusEditorWhenReady(selectAll = true) {
|
|
3182
2931
|
if (!gridRoot) return;
|
|
2932
|
+
if (editFocusColId() != null && hasEditorSlot(editFocusColId())) return;
|
|
3183
2933
|
let attempts = 0;
|
|
3184
2934
|
const tryFocus = () => {
|
|
3185
2935
|
const el = gridRoot ? gridRoot.querySelector("[data-editing-cell]") : null;
|
|
@@ -3230,6 +2980,7 @@ function DataTable(_props) {
|
|
|
3230
2980
|
setDraftValue(seed != null ? seed : cellValueAt(rowIndex, colIndex));
|
|
3231
2981
|
setActiveInControl(true);
|
|
3232
2982
|
setEditVer(editVer() + 1);
|
|
2983
|
+
setEditFocusColId(colId);
|
|
3233
2984
|
focusEditorWhenReady(seed == null);
|
|
3234
2985
|
}
|
|
3235
2986
|
function focusCellWhenReady(row, col) {
|
|
@@ -3266,6 +3017,7 @@ function DataTable(_props) {
|
|
|
3266
3017
|
setInvalidMsg("");
|
|
3267
3018
|
setActiveInControl(false);
|
|
3268
3019
|
setEditVer(editVer() + 1);
|
|
3020
|
+
setEditFocusColId(null);
|
|
3269
3021
|
}
|
|
3270
3022
|
function endRowEdit() {
|
|
3271
3023
|
setEditingRowIndex(null);
|
|
@@ -3273,6 +3025,14 @@ function DataTable(_props) {
|
|
|
3273
3025
|
setInvalidMsg("");
|
|
3274
3026
|
setActiveInControl(false);
|
|
3275
3027
|
setEditVer(editVer() + 1);
|
|
3028
|
+
setEditFocusColId(null);
|
|
3029
|
+
}
|
|
3030
|
+
function editorAutofocusFor(colId, rowIndex) {
|
|
3031
|
+
if (editVer() < 0) return false;
|
|
3032
|
+
if (editingRowIndex() != null) {
|
|
3033
|
+
if (editingRowIndex() !== rowIndex) return false;
|
|
3034
|
+
} else if (editingRow() !== rowIndex) return false;
|
|
3035
|
+
return editFocusColId() != null && editFocusColId() === colId;
|
|
3276
3036
|
}
|
|
3277
3037
|
function coerceCellValue(colId, raw) {
|
|
3278
3038
|
if (editorTypeOf(colId) !== "number") return raw;
|
|
@@ -3391,6 +3151,8 @@ function DataTable(_props) {
|
|
|
3391
3151
|
}
|
|
3392
3152
|
function focusRowEditorAt(rowIndex, colIndex) {
|
|
3393
3153
|
if (!gridRoot) return;
|
|
3154
|
+
const colId = columnIdAt(rowIndex, colIndex);
|
|
3155
|
+
if (colId != null && hasEditorSlot(colId)) return;
|
|
3394
3156
|
let attempts = 0;
|
|
3395
3157
|
const tryFocus = () => {
|
|
3396
3158
|
const cellEl = resolveCellEl(String(rowIndex), colIndex);
|
|
@@ -3431,6 +3193,7 @@ function DataTable(_props) {
|
|
|
3431
3193
|
setEditingRowIndex(rowIndex);
|
|
3432
3194
|
setActiveInControl(true);
|
|
3433
3195
|
setEditVer(editVer() + 1);
|
|
3196
|
+
setEditFocusColId(editable[0].colId);
|
|
3434
3197
|
focusEditorWhenReady();
|
|
3435
3198
|
}
|
|
3436
3199
|
function commitRow() {
|
|
@@ -3450,6 +3213,8 @@ function DataTable(_props) {
|
|
|
3450
3213
|
const err = runValidator(ec.colId, coerceCellValue(ec.colId, draft[ec.colId]), rowOriginal);
|
|
3451
3214
|
if (err !== true) {
|
|
3452
3215
|
setInvalid(err);
|
|
3216
|
+
setEditFocusColId(ec.colId);
|
|
3217
|
+
setEditVer(editVer() + 1);
|
|
3453
3218
|
focusRowEditorAt(rowIndex, ec.colIndex);
|
|
3454
3219
|
return false;
|
|
3455
3220
|
}
|
|
@@ -3623,7 +3388,10 @@ function DataTable(_props) {
|
|
|
3623
3388
|
let pos = cols.indexOf(cur);
|
|
3624
3389
|
if (pos < 0) pos = 0;
|
|
3625
3390
|
const len = cols.length;
|
|
3626
|
-
|
|
3391
|
+
const nextPos = backward ? (pos - 1 + len) % len : (pos + 1) % len;
|
|
3392
|
+
setEditFocusColId(editable[nextPos].colId);
|
|
3393
|
+
setEditVer(editVer() + 1);
|
|
3394
|
+
focusRowEditorAt(rowIndex, cols[nextPos]);
|
|
3627
3395
|
}
|
|
3628
3396
|
function onEditorKeyDown(e) {
|
|
3629
3397
|
if (!e) return;
|
|
@@ -3938,7 +3706,7 @@ function DataTable(_props) {
|
|
|
3938
3706
|
}) ?? (0, _rozie_runtime_solid.rozieDisplay)(headerLabel(header().column.id))}
|
|
3939
3707
|
</span>
|
|
3940
3708
|
<span class={"rdt-sort-ind"} aria-hidden="true" data-rozie-s-d5dcab4c="">{(0, _rozie_runtime_solid.rozieDisplay)(sortIndicator(header().column.id))}</span>
|
|
3941
|
-
</button></Solid_js.Show>}<
|
|
3709
|
+
</button></Solid_js.Show>}<_rozie_ui_popover_solid.default trigger="click" placement="bottom-end" strategy="fixed" offset={4} data-rozie-s-d5dcab4c="" anchorSlot={() => <>
|
|
3942
3710
|
<button type="button" class={"rdt-col-menu-trigger"} aria-label={(0, _rozie_runtime_solid.rozieAttr)("Column options for " + headerLabel(header().column.id))} data-rozie-s-d5dcab4c="">⋯</button>
|
|
3943
3711
|
</>}><div class={"rdt-col-menu"} role="menu" data-rozie-s-d5dcab4c="">
|
|
3944
3712
|
<button type="button" role="menuitem" aria-pressed={columnPinSide(header().column.id) === "left"} class={"rdt-col-menu-item"} onClick={($event) => {
|
|
@@ -3954,7 +3722,7 @@ function DataTable(_props) {
|
|
|
3954
3722
|
<button type="button" role="menuitem" class={"rdt-col-menu-item"} onClick={($event) => {
|
|
3955
3723
|
onHideColumn(header().column.id, $event);
|
|
3956
3724
|
}} data-rozie-s-d5dcab4c="">Hide column</button>
|
|
3957
|
-
</div></
|
|
3725
|
+
</div></_rozie_ui_popover_solid.default>
|
|
3958
3726
|
|
|
3959
3727
|
<button type="button" aria-label={(0, _rozie_runtime_solid.rozieAttr)("Resize " + headerLabel(header().column.id))} class={"rdt-resize-handle"} onPointerDown={($event) => {
|
|
3960
3728
|
onResizeStart(header().column.id, $event);
|
|
@@ -4042,7 +3810,8 @@ function DataTable(_props) {
|
|
|
4042
3810
|
row: row().original,
|
|
4043
3811
|
value: editorValueFor(cell().column.id),
|
|
4044
3812
|
commit: editorCommitFor(cell().column.id),
|
|
4045
|
-
cancel: editorCancelFor()
|
|
3813
|
+
cancel: editorCancelFor(),
|
|
3814
|
+
autofocus: editorAutofocusFor(cell().column.id, rowIndexOf(row()))
|
|
4046
3815
|
})}
|
|
4047
3816
|
</span></Solid_js.Show>}</span></Solid_js.Show>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
|
|
4048
3817
|
<button type="button" data-expander="" aria-expanded={!!rowIsExpanded(row())} aria-label={(0, _rozie_runtime_solid.rozieAttr)(rowIsExpanded(row()) ? "Collapse group" : "Expand group")} class={"rdt-expander rdt-group-toggle"} onClick={($event) => {
|
|
@@ -4121,7 +3890,7 @@ function DataTable(_props) {
|
|
|
4121
3890
|
}) ?? (0, _rozie_runtime_solid.rozieDisplay)(headerLabel(header().column.id))}
|
|
4122
3891
|
</span>
|
|
4123
3892
|
<span class={"rdt-sort-ind"} aria-hidden="true" data-rozie-s-d5dcab4c="">{(0, _rozie_runtime_solid.rozieDisplay)(sortIndicator(header().column.id))}</span>
|
|
4124
|
-
</button></Solid_js.Show>}<
|
|
3893
|
+
</button></Solid_js.Show>}<_rozie_ui_popover_solid.default trigger="click" placement="bottom-end" strategy="fixed" offset={4} data-rozie-s-d5dcab4c="" anchorSlot={() => <>
|
|
4125
3894
|
<button type="button" class={"rdt-col-menu-trigger"} aria-label={(0, _rozie_runtime_solid.rozieAttr)("Column options for " + headerLabel(header().column.id))} data-rozie-s-d5dcab4c="">⋯</button>
|
|
4126
3895
|
</>}><div class={"rdt-col-menu"} role="menu" data-rozie-s-d5dcab4c="">
|
|
4127
3896
|
<button type="button" role="menuitem" aria-pressed={columnPinSide(header().column.id) === "left"} class={"rdt-col-menu-item"} onClick={($event) => {
|
|
@@ -4137,7 +3906,7 @@ function DataTable(_props) {
|
|
|
4137
3906
|
<button type="button" role="menuitem" class={"rdt-col-menu-item"} onClick={($event) => {
|
|
4138
3907
|
onHideColumn(header().column.id, $event);
|
|
4139
3908
|
}} data-rozie-s-d5dcab4c="">Hide column</button>
|
|
4140
|
-
</div></
|
|
3909
|
+
</div></_rozie_ui_popover_solid.default>
|
|
4141
3910
|
<button type="button" aria-label={(0, _rozie_runtime_solid.rozieAttr)("Resize " + headerLabel(header().column.id))} class={"rdt-resize-handle"} onPointerDown={($event) => {
|
|
4142
3911
|
onResizeStart(header().column.id, $event);
|
|
4143
3912
|
}} onTouchStart={($event) => {
|
|
@@ -4231,7 +4000,8 @@ function DataTable(_props) {
|
|
|
4231
4000
|
row: wr().row.original,
|
|
4232
4001
|
value: editorValueFor(cell().column.id),
|
|
4233
4002
|
commit: editorCommitFor(cell().column.id),
|
|
4234
|
-
cancel: editorCancelFor()
|
|
4003
|
+
cancel: editorCancelFor(),
|
|
4004
|
+
autofocus: editorAutofocusFor(cell().column.id, wr().vi.index)
|
|
4235
4005
|
})}
|
|
4236
4006
|
</span></Solid_js.Show>}</span></Solid_js.Show>}><span style={{ display: "contents" }} data-rozie-s-d5dcab4c="">
|
|
4237
4007
|
<button type="button" data-expander="" aria-expanded={!!rowIsExpanded(wr().row)} aria-label={(0, _rozie_runtime_solid.rozieAttr)(rowIsExpanded(wr().row) ? "Collapse group" : "Expand group")} class={"rdt-expander rdt-group-toggle"} onClick={($event) => {
|
|
@@ -4406,16 +4176,25 @@ function EditorText(_props) {
|
|
|
4406
4176
|
row: null,
|
|
4407
4177
|
value: null,
|
|
4408
4178
|
commit: null,
|
|
4409
|
-
cancel: null
|
|
4179
|
+
cancel: null,
|
|
4180
|
+
autofocus: false
|
|
4410
4181
|
}, _props), [
|
|
4411
4182
|
"columnId",
|
|
4412
4183
|
"column",
|
|
4413
4184
|
"row",
|
|
4414
4185
|
"value",
|
|
4415
4186
|
"commit",
|
|
4416
|
-
"cancel"
|
|
4187
|
+
"cancel",
|
|
4188
|
+
"autofocus"
|
|
4417
4189
|
]);
|
|
4418
4190
|
const [draft, setDraft] = (0, Solid_js.createSignal)("");
|
|
4191
|
+
(0, Solid_js.onMount)(() => {
|
|
4192
|
+
if (local.autofocus) inputElRef?.focus();
|
|
4193
|
+
});
|
|
4194
|
+
(0, Solid_js.createEffect)((0, Solid_js.on)(() => local.autofocus, (v) => (0, Solid_js.untrack)(() => ((v) => {
|
|
4195
|
+
if (v) inputElRef?.focus();
|
|
4196
|
+
})(v)), { defer: true }));
|
|
4197
|
+
let inputElRef = null;
|
|
4419
4198
|
setDraft(local.value != null ? String(local.value) : "");
|
|
4420
4199
|
function onInput(e) {
|
|
4421
4200
|
setDraft(e && e.target ? e.target.value : "");
|
|
@@ -4439,7 +4218,9 @@ function EditorText(_props) {
|
|
|
4439
4218
|
doCommit();
|
|
4440
4219
|
}
|
|
4441
4220
|
return <>
|
|
4442
|
-
<input type="text" data-editing-cell="" aria-label={local.columnId}
|
|
4221
|
+
<input type="text" data-editing-cell="" aria-label={local.columnId} ref={(el) => {
|
|
4222
|
+
inputElRef = el;
|
|
4223
|
+
}} class={"rdt-cell-editor"} value={draft()} onInput={($event) => {
|
|
4443
4224
|
onInput($event);
|
|
4444
4225
|
}} onKeyDown={($event) => {
|
|
4445
4226
|
onKeydown($event);
|
package/dist/index.d.cts
CHANGED
|
@@ -42,6 +42,7 @@ interface EditorSlotCtx {
|
|
|
42
42
|
value: any;
|
|
43
43
|
commit: any;
|
|
44
44
|
cancel: any;
|
|
45
|
+
autofocus: any;
|
|
45
46
|
}
|
|
46
47
|
interface DetailSlotCtx {
|
|
47
48
|
row: any;
|
|
@@ -339,6 +340,10 @@ interface EditorTextProps {
|
|
|
339
340
|
* `() => void` — revert the edit and close the editor (from the `#editor` slot scope). Null-guarded at call sites.
|
|
340
341
|
*/
|
|
341
342
|
cancel?: ((...args: unknown[]) => unknown) | null;
|
|
343
|
+
/**
|
|
344
|
+
* Focus this editor's primary input when true — the host sets it for the one editor that should hold focus; reactive.
|
|
345
|
+
*/
|
|
346
|
+
autofocus?: boolean;
|
|
342
347
|
}
|
|
343
348
|
declare function EditorText(_props: EditorTextProps): JSX.Element;
|
|
344
349
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -42,6 +42,7 @@ interface EditorSlotCtx {
|
|
|
42
42
|
value: any;
|
|
43
43
|
commit: any;
|
|
44
44
|
cancel: any;
|
|
45
|
+
autofocus: any;
|
|
45
46
|
}
|
|
46
47
|
interface DetailSlotCtx {
|
|
47
48
|
row: any;
|
|
@@ -339,6 +340,10 @@ interface EditorTextProps {
|
|
|
339
340
|
* `() => void` — revert the edit and close the editor (from the `#editor` slot scope). Null-guarded at call sites.
|
|
340
341
|
*/
|
|
341
342
|
cancel?: ((...args: unknown[]) => unknown) | null;
|
|
343
|
+
/**
|
|
344
|
+
* Focus this editor's primary input when true — the host sets it for the one editor that should hold focus; reactive.
|
|
345
|
+
*/
|
|
346
|
+
autofocus?: boolean;
|
|
342
347
|
}
|
|
343
348
|
declare function EditorText(_props: EditorTextProps): JSX.Element;
|
|
344
349
|
//#endregion
|