@nice2dev/ui-erp 1.2.2 → 1.3.1
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.cjs +1590 -274
- package/dist/index.mjs +1535 -219
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,157 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
5
|
-
const a = (e, t) => t, c = /* @__PURE__ */
|
|
4
|
+
const $e$1 = require("react");
|
|
5
|
+
const a = (e, t) => t, c = /* @__PURE__ */ $e$1.createContext(a), i = /* @__PURE__ */ $e$1.createContext("en");
|
|
6
6
|
function v() {
|
|
7
|
-
const e =
|
|
7
|
+
const e = $e$1.useContext(c), t = $e$1.useContext(i);
|
|
8
8
|
return { t: e, lang: t };
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const gt = /* @__PURE__ */ new Set([
|
|
11
|
+
"",
|
|
12
|
+
"text",
|
|
13
|
+
"search",
|
|
14
|
+
"email",
|
|
15
|
+
"url",
|
|
16
|
+
"tel",
|
|
17
|
+
"password"
|
|
18
|
+
]), Pe = /* @__PURE__ */ new Set([
|
|
19
|
+
"number",
|
|
20
|
+
"range",
|
|
21
|
+
"date",
|
|
22
|
+
"time",
|
|
23
|
+
"datetime-local",
|
|
24
|
+
"month",
|
|
25
|
+
"week"
|
|
26
|
+
]), Ut = /* @__PURE__ */ new Set([
|
|
27
|
+
"checkbox",
|
|
28
|
+
"radio",
|
|
29
|
+
"button",
|
|
30
|
+
"submit",
|
|
31
|
+
"reset",
|
|
32
|
+
"file",
|
|
33
|
+
"image",
|
|
34
|
+
"color"
|
|
35
|
+
]), Gt = /* @__PURE__ */ new Set([
|
|
36
|
+
"button",
|
|
37
|
+
"link",
|
|
38
|
+
"checkbox",
|
|
39
|
+
"radio",
|
|
40
|
+
"switch",
|
|
41
|
+
"tab",
|
|
42
|
+
"menuitem",
|
|
43
|
+
"menuitemcheckbox",
|
|
44
|
+
"menuitemradio",
|
|
45
|
+
"option",
|
|
46
|
+
"treeitem"
|
|
47
|
+
]), bt = (n) => n instanceof HTMLInputElement && gt.has(n.type), De = (n) => n instanceof HTMLTextAreaElement, yt = (n) => n instanceof HTMLElement && n.isContentEditable;
|
|
48
|
+
function qt(n, e) {
|
|
49
|
+
const { intent: t, direction: a2 } = e;
|
|
50
|
+
return bt(n) ? t === "navigate" ? a2 === "left" || a2 === "right" : t === "first" || t === "last" || t === "activate" || t === "toggleHints" : De(n) || yt(n) ? t !== "back" && t !== "view" && t !== "menu" && t !== "secondary" : n instanceof HTMLSelectElement ? t !== "back" && t !== "view" && t !== "menu" : n instanceof HTMLInputElement ? Pe.has(n.type) ? t === "navigate" || t === "first" || t === "last" || t === "pagePrev" || t === "pageNext" : n.type === "radio" && t === "navigate" : false;
|
|
51
|
+
}
|
|
52
|
+
function wt(n) {
|
|
53
|
+
if (n instanceof HTMLButtonElement || n.tagName === "SUMMARY")
|
|
54
|
+
return true;
|
|
55
|
+
if (n instanceof HTMLAnchorElement)
|
|
56
|
+
return n.hasAttribute("href");
|
|
57
|
+
if (n instanceof HTMLInputElement)
|
|
58
|
+
return Ut.has(n.type);
|
|
59
|
+
const e = n.getAttribute("role");
|
|
60
|
+
return e !== null && Gt.has(e);
|
|
61
|
+
}
|
|
62
|
+
function $t(n) {
|
|
63
|
+
if (typeof n.click == "function") {
|
|
64
|
+
n.click();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const e = n.ownerDocument.defaultView;
|
|
68
|
+
n.dispatchEvent(
|
|
69
|
+
new ((e == null ? void 0 : e.MouseEvent) ?? MouseEvent)("click", {
|
|
70
|
+
bubbles: true,
|
|
71
|
+
cancelable: true,
|
|
72
|
+
composed: true
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
function Et(n) {
|
|
77
|
+
if (n.defaultPrevented || n.repeat || n.target !== n.currentTarget || n.key !== "Enter" && n.key !== " " && n.key !== "Spacebar")
|
|
78
|
+
return;
|
|
79
|
+
const e = n.currentTarget;
|
|
80
|
+
if (!e || typeof e.dispatchEvent != "function")
|
|
81
|
+
return;
|
|
82
|
+
n.preventDefault();
|
|
83
|
+
const t = e.ownerDocument.defaultView;
|
|
84
|
+
e.dispatchEvent(
|
|
85
|
+
new ((t == null ? void 0 : t.MouseEvent) ?? MouseEvent)("click", {
|
|
86
|
+
bubbles: true,
|
|
87
|
+
cancelable: true,
|
|
88
|
+
composed: true,
|
|
89
|
+
ctrlKey: !!n.ctrlKey,
|
|
90
|
+
shiftKey: !!n.shiftKey,
|
|
91
|
+
altKey: !!n.altKey,
|
|
92
|
+
metaKey: !!n.metaKey
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function me(n) {
|
|
97
|
+
const e = n.getAttribute("data-nice-engage");
|
|
98
|
+
if (e === "value" || e === "text" || e === "popup" || e === "canvas")
|
|
99
|
+
return e;
|
|
100
|
+
if (e === "none")
|
|
101
|
+
return null;
|
|
102
|
+
const t = n.getAttribute("role");
|
|
103
|
+
return t === "combobox" ? "popup" : t === "slider" || t === "spinbutton" || n instanceof HTMLSelectElement ? "value" : n instanceof HTMLInputElement ? gt.has(n.type) ? n.readOnly ? null : "text" : Pe.has(n.type) && !n.readOnly ? "value" : null : De(n) ? n.readOnly ? null : "text" : yt(n) ? "text" : null;
|
|
104
|
+
}
|
|
105
|
+
function kt(n, e) {
|
|
106
|
+
return e === "popup" ? n.getAttribute("aria-expanded") === "true" : n.hasAttribute("data-nice-engaged");
|
|
107
|
+
}
|
|
108
|
+
function ce(n) {
|
|
109
|
+
return n instanceof HTMLSelectElement || n instanceof HTMLInputElement && Pe.has(n.type);
|
|
110
|
+
}
|
|
111
|
+
function Me(n) {
|
|
112
|
+
n.dispatchEvent(new Event("input", { bubbles: true })), n.dispatchEvent(new Event("change", { bubbles: true }));
|
|
113
|
+
}
|
|
114
|
+
function Ie(n, e) {
|
|
115
|
+
var r;
|
|
116
|
+
const t = Object.getPrototypeOf(n), a2 = (r = Object.getOwnPropertyDescriptor(t, "value")) == null ? void 0 : r.set;
|
|
117
|
+
a2 ? a2.call(n, e) : n.value = e;
|
|
118
|
+
}
|
|
119
|
+
const be = (n) => n instanceof HTMLInputElement && n.type === "number";
|
|
120
|
+
function Wt(n, e) {
|
|
121
|
+
n.value !== e && (Ie(n, e), Me(n));
|
|
122
|
+
}
|
|
123
|
+
function le(n, e, t = "step") {
|
|
124
|
+
const a2 = e === "up" || e === "right";
|
|
125
|
+
if (n instanceof HTMLSelectElement) {
|
|
126
|
+
const s = n.selectedIndex, o = n.options.length - 1;
|
|
127
|
+
if (t === "edge")
|
|
128
|
+
n.selectedIndex = a2 ? o : 0;
|
|
129
|
+
else {
|
|
130
|
+
const i2 = t === "big" ? 10 : 1;
|
|
131
|
+
n.selectedIndex = Math.max(0, Math.min(o, s + (a2 ? i2 : -i2)));
|
|
132
|
+
}
|
|
133
|
+
return n.selectedIndex !== s ? (Me(n), true) : false;
|
|
134
|
+
}
|
|
135
|
+
const r = n.value;
|
|
136
|
+
try {
|
|
137
|
+
if (t === "edge" && (n.min !== "" || n.max !== ""))
|
|
138
|
+
Ie(n, a2 ? n.max || n.value : n.min || n.value);
|
|
139
|
+
else {
|
|
140
|
+
const s = t === "big" ? 10 : 1;
|
|
141
|
+
a2 ? n.stepUp(s) : n.stepDown(s);
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return n.value !== r ? (Me(n), true) : false;
|
|
147
|
+
}
|
|
148
|
+
function Xt(n, e) {
|
|
149
|
+
if (!(bt(n) || De(n)) || n.selectionStart === null || e !== "left" && e !== "right")
|
|
150
|
+
return false;
|
|
151
|
+
const t = n.selectionStart + (e === "right" ? 1 : -1), a2 = Math.max(0, Math.min(n.value.length, t));
|
|
152
|
+
return n.setSelectionRange(a2, a2), true;
|
|
153
|
+
}
|
|
154
|
+
const xt = {
|
|
11
155
|
// Navigation
|
|
12
156
|
"chevron-down": "M6 9l6 6 6-6",
|
|
13
157
|
"chevron-up": "M18 15l-6-6-6 6",
|
|
@@ -225,77 +369,1206 @@ const tr = {
|
|
|
225
369
|
midpoint: "M3 12h6 M15 12h6 M3 9v6 M21 9v6 M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z",
|
|
226
370
|
"angle-bisector": "M4 20h17 M4 20L16 5 M4 20l14.4-6.9 M10 20a6 6 0 0 0-2.25-4.68",
|
|
227
371
|
group: "M3 7V3h4 M17 3h4v4 M21 17v4h-4 M7 21H3v-4 M7 7h5v5H7z M12 12h5v5h-5z",
|
|
228
|
-
ungroup: "M3 3h8v8H3z M13 13h8v8h-8z"
|
|
229
|
-
|
|
372
|
+
ungroup: "M3 3h8v8H3z M13 13h8v8h-8z",
|
|
373
|
+
// 1.3.0: button and key glyphs of the input prompts (ADR-005 § 8, decision 0.8). Outline here;
|
|
374
|
+
// the filled, coloured Ntd* of @nice2dev/icons carry the same names in its resolver.
|
|
375
|
+
"pad-xbox-a": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.25 16l2.75-8 2.75 8 M10.2 13.25h3.6",
|
|
376
|
+
"pad-xbox-b": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.75 8v8 M9.75 8h2.5a2 2 0 0 1 0 4h-2.5 M9.75 12h3a2 2 0 0 1 0 4h-3",
|
|
377
|
+
"pad-xbox-x": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l5 8 M14.5 8l-5 8",
|
|
378
|
+
"pad-xbox-y": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l2.5 4 2.5-4 M12 12v4",
|
|
379
|
+
"pad-nintendo-a": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.25 16l2.75-8 2.75 8 M10.2 13.25h3.6",
|
|
380
|
+
"pad-nintendo-b": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.75 8v8 M9.75 8h2.5a2 2 0 0 1 0 4h-2.5 M9.75 12h3a2 2 0 0 1 0 4h-3",
|
|
381
|
+
"pad-nintendo-x": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l5 8 M14.5 8l-5 8",
|
|
382
|
+
"pad-nintendo-y": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l2.5 4 2.5-4 M12 12v4",
|
|
383
|
+
"pad-playstation-cross": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9 9l6 6 M15 9l-6 6",
|
|
384
|
+
"pad-playstation-circle": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8.25a3.75 3.75 0 1 0 0 7.5a3.75 3.75 0 1 0 0 -7.5z",
|
|
385
|
+
"pad-playstation-square": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M8.5 8.5h7v7h-7z",
|
|
386
|
+
"pad-playstation-triangle": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8l4.5 7.5h-9z",
|
|
387
|
+
"pad-generic-north": "M12 3a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M12 6h.01 M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
|
|
388
|
+
"pad-generic-east": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 9a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M18 12h.01 M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
|
|
389
|
+
"pad-generic-west": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 9a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M6 12h.01 M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
|
|
390
|
+
"pad-generic-south": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 15a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M12 18h.01",
|
|
391
|
+
"pad-lb": "M6 9h12a3 3 0 0 1 0 6H6a3 3 0 0 1 0-6z M7.5 12h.01",
|
|
392
|
+
"pad-rb": "M6 9h12a3 3 0 0 1 0 6H6a3 3 0 0 1 0-6z M16.5 12h.01",
|
|
393
|
+
"pad-lt": "M9 3h6a3 3 0 0 1 3 3v7a6 6 0 0 1-12 0V6a3 3 0 0 1 3-3z M9.5 7h.01",
|
|
394
|
+
"pad-rt": "M9 3h6a3 3 0 0 1 3 3v7a6 6 0 0 1-12 0V6a3 3 0 0 1 3-3z M14.5 7h.01",
|
|
395
|
+
"pad-start": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M8.5 8.75h7 M8.5 12h7 M8.5 15.25h7",
|
|
396
|
+
"pad-select": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M7.75 7.75h5.5v5.5h-5.5z M10.75 16.25h5.5v-5.5",
|
|
397
|
+
"pad-home": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M7.95 12L12 8.6l4.05 3.4v4H7.95z",
|
|
398
|
+
"pad-dpad": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z",
|
|
399
|
+
"pad-dpad-up": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M12 5.6l1.15 1.5h-2.3z",
|
|
400
|
+
"pad-dpad-down": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M12 18.4l1.15-1.5h-2.3z",
|
|
401
|
+
"pad-dpad-left": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M5.6 12l1.5-1.15v2.3z",
|
|
402
|
+
"pad-dpad-right": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M18.4 12l-1.5-1.15v2.3z",
|
|
403
|
+
"pad-stick-left": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M4.5 12h1",
|
|
404
|
+
"pad-stick-right": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M18.5 12h1",
|
|
405
|
+
"pad-stick-left-press": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M12 12h.01 M4.5 12h1",
|
|
406
|
+
"pad-stick-right-press": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M12 12h.01 M18.5 12h1",
|
|
407
|
+
"remote-ok": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8.5a3.5 3.5 0 1 0 0 7a3.5 3.5 0 1 0 0 -7z",
|
|
408
|
+
"remote-back": "M9 14l-4-4 4-4 M5 10h9a5 5 0 0 1 0 10h-2",
|
|
409
|
+
"remote-menu": "M4 6h16v12H4z M8 10h8 M8 14h8",
|
|
410
|
+
"key-command": "M9 9V6.5A2.5 2.5 0 1 0 6.5 9H9z M9 9h6 M9 9v6 M15 9V6.5A2.5 2.5 0 1 1 17.5 9H15z M15 9v6 M15 15H9 M15 15v2.5a2.5 2.5 0 1 0 2.5-2.5H15z M9 15H6.5A2.5 2.5 0 1 0 9 17.5V15z",
|
|
411
|
+
"key-option": "M4 6h5l6 12h5 M14 6h6",
|
|
412
|
+
"key-shift": "M12 4l-8 8h4v8h8v-8h4z",
|
|
413
|
+
"key-control": "M7 14l5-5 5 5",
|
|
414
|
+
"key-enter": "M20 5v7a3 3 0 0 1-3 3H5 M9 11l-4 4 4 4",
|
|
415
|
+
"key-tab": "M4 12h14 M14 8l4 4-4 4 M20 6v12",
|
|
416
|
+
// on-screen keyboard (1.3.0 H1)
|
|
417
|
+
"key-backspace": "M21 5H9l-6 7 6 7h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1z M17 9l-6 6 M11 9l6 6",
|
|
418
|
+
"key-space": "M4 10v4h16v-4",
|
|
419
|
+
"key-caps": "M12 4l-7 7h4v5h6v-5h4z M8 20h8"
|
|
420
|
+
}, Jt = {
|
|
230
421
|
xs: 12,
|
|
231
422
|
sm: 16,
|
|
232
423
|
md: 20,
|
|
233
424
|
lg: 24,
|
|
234
425
|
xl: 32
|
|
235
|
-
},
|
|
236
|
-
function
|
|
237
|
-
path:
|
|
238
|
-
size:
|
|
239
|
-
className:
|
|
426
|
+
}, Oe = /* @__PURE__ */ $e$1.createContext({});
|
|
427
|
+
function Zt({
|
|
428
|
+
path: n,
|
|
429
|
+
size: e,
|
|
430
|
+
className: t,
|
|
240
431
|
style: a2,
|
|
241
|
-
color:
|
|
242
|
-
title:
|
|
243
|
-
onClick:
|
|
432
|
+
color: r,
|
|
433
|
+
title: s,
|
|
434
|
+
onClick: o
|
|
244
435
|
}) {
|
|
245
436
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
246
437
|
"svg",
|
|
247
438
|
{
|
|
248
439
|
xmlns: "http://www.w3.org/2000/svg",
|
|
249
|
-
width:
|
|
250
|
-
height:
|
|
440
|
+
width: e,
|
|
441
|
+
height: e,
|
|
251
442
|
viewBox: "0 0 24 24",
|
|
252
443
|
fill: "none",
|
|
253
|
-
stroke:
|
|
444
|
+
stroke: r || "currentColor",
|
|
254
445
|
strokeWidth: 2,
|
|
255
446
|
strokeLinecap: "round",
|
|
256
447
|
strokeLinejoin: "round",
|
|
257
|
-
className: `nice-icon ${
|
|
448
|
+
className: `nice-icon ${t || ""}`,
|
|
258
449
|
style: a2,
|
|
259
|
-
role: o ? "img" : "presentation",
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
450
|
+
role: o ? "button" : s ? "img" : "presentation",
|
|
451
|
+
tabIndex: o ? 0 : void 0,
|
|
452
|
+
onKeyDown: o ? Et : void 0,
|
|
453
|
+
"aria-label": s,
|
|
454
|
+
"aria-hidden": o ? void 0 : !s,
|
|
455
|
+
onClick: o,
|
|
263
456
|
children: [
|
|
264
|
-
|
|
265
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d:
|
|
457
|
+
s && /* @__PURE__ */ jsxRuntime.jsx("title", { children: s }),
|
|
458
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: n })
|
|
266
459
|
]
|
|
267
460
|
}
|
|
268
461
|
);
|
|
269
462
|
}
|
|
270
|
-
const
|
|
271
|
-
name:
|
|
272
|
-
size:
|
|
273
|
-
className:
|
|
463
|
+
const te = ({
|
|
464
|
+
name: n,
|
|
465
|
+
size: e = "md",
|
|
466
|
+
className: t,
|
|
274
467
|
style: a2,
|
|
275
|
-
color:
|
|
276
|
-
title:
|
|
277
|
-
onClick:
|
|
468
|
+
color: r,
|
|
469
|
+
title: s,
|
|
470
|
+
onClick: o
|
|
278
471
|
}) => {
|
|
279
|
-
const { resolver:
|
|
280
|
-
if (
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
472
|
+
const { resolver: i2 } = $e$1.useContext(Oe), c2 = typeof e == "number" ? e : Jt[e];
|
|
473
|
+
if (i2) {
|
|
474
|
+
const u = i2(n, c2);
|
|
475
|
+
if (u)
|
|
476
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
477
|
+
"span",
|
|
478
|
+
{
|
|
479
|
+
role: o ? "button" : void 0,
|
|
480
|
+
tabIndex: o ? 0 : void 0,
|
|
481
|
+
onKeyDown: o ? Et : void 0,
|
|
482
|
+
className: `nice-icon-wrap ${t || ""}`,
|
|
483
|
+
style: a2,
|
|
484
|
+
onClick: o,
|
|
485
|
+
children: u
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
const d = xt[n];
|
|
490
|
+
return d ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
491
|
+
Zt,
|
|
288
492
|
{
|
|
289
|
-
path:
|
|
493
|
+
path: d,
|
|
290
494
|
size: c2,
|
|
291
|
-
className:
|
|
495
|
+
className: t,
|
|
292
496
|
style: a2,
|
|
293
|
-
color:
|
|
294
|
-
title:
|
|
295
|
-
onClick:
|
|
497
|
+
color: r,
|
|
498
|
+
title: s,
|
|
499
|
+
onClick: o
|
|
296
500
|
}
|
|
297
501
|
) : null;
|
|
298
502
|
};
|
|
503
|
+
const zt = [
|
|
504
|
+
"a[href]",
|
|
505
|
+
"area[href]",
|
|
506
|
+
"button",
|
|
507
|
+
'input:not([type="hidden"])',
|
|
508
|
+
"select",
|
|
509
|
+
"textarea",
|
|
510
|
+
"summary",
|
|
511
|
+
"iframe",
|
|
512
|
+
"audio[controls]",
|
|
513
|
+
"video[controls]",
|
|
514
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
515
|
+
"[tabindex]",
|
|
516
|
+
"[data-nice-focusable]"
|
|
517
|
+
].join(",");
|
|
518
|
+
function J(n) {
|
|
519
|
+
const e = n.getBoundingClientRect();
|
|
520
|
+
return {
|
|
521
|
+
left: e.left,
|
|
522
|
+
top: e.top,
|
|
523
|
+
right: e.right,
|
|
524
|
+
bottom: e.bottom,
|
|
525
|
+
width: e.width,
|
|
526
|
+
height: e.height
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
const _e = (n) => n instanceof HTMLButtonElement || n instanceof HTMLInputElement || n instanceof HTMLSelectElement || n instanceof HTMLTextAreaElement;
|
|
530
|
+
function Qt(n) {
|
|
531
|
+
if (_e(n) && n.disabled || n.getAttribute("aria-disabled") === "true" && !n.hasAttribute("data-nice-focusable"))
|
|
532
|
+
return true;
|
|
533
|
+
const e = n.closest("fieldset[disabled]");
|
|
534
|
+
if (e && _e(n)) {
|
|
535
|
+
const t = e.querySelector(":scope > legend");
|
|
536
|
+
return !(t && t.contains(n));
|
|
537
|
+
}
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
function en(n) {
|
|
541
|
+
var a2;
|
|
542
|
+
if (n.closest("[hidden]"))
|
|
543
|
+
return false;
|
|
544
|
+
const e = n.getBoundingClientRect();
|
|
545
|
+
if (e.width === 0 && e.height === 0) {
|
|
546
|
+
const r = n.ownerDocument.documentElement.getBoundingClientRect();
|
|
547
|
+
if (r.width !== 0 || r.height !== 0)
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
const t = (a2 = n.ownerDocument.defaultView) == null ? void 0 : a2.getComputedStyle(n);
|
|
551
|
+
return !t || t.display !== "none" && t.visibility !== "hidden" && t.visibility !== "collapse";
|
|
552
|
+
}
|
|
553
|
+
function tn(n) {
|
|
554
|
+
if (!(n instanceof HTMLInputElement) || n.type !== "radio" || !n.name || n.checked)
|
|
555
|
+
return true;
|
|
556
|
+
const t = [...(n.form ?? n.ownerDocument).querySelectorAll('input[type="radio"]')].filter(
|
|
557
|
+
(a2) => a2.name === n.name
|
|
558
|
+
);
|
|
559
|
+
return !t.some((a2) => a2.checked) && t[0] === n;
|
|
560
|
+
}
|
|
561
|
+
function ne(n) {
|
|
562
|
+
if (!(n instanceof HTMLElement) || !n.matches(zt))
|
|
563
|
+
return false;
|
|
564
|
+
if (!n.hasAttribute("data-nice-focusable")) {
|
|
565
|
+
const e = n.getAttribute("tabindex");
|
|
566
|
+
if (e !== null && Number(e) < 0 || n instanceof HTMLAnchorElement && !n.hasAttribute("href") && e === null)
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
return n.closest('[inert],[aria-hidden="true"]') || Qt(n) ? false : en(n) && tn(n);
|
|
570
|
+
}
|
|
571
|
+
function U(n, e = []) {
|
|
572
|
+
const t = [];
|
|
573
|
+
for (const a2 of n.querySelectorAll(zt))
|
|
574
|
+
e.some((r) => r && r.contains(a2)) || ne(a2) && t.push(a2);
|
|
575
|
+
return t;
|
|
576
|
+
}
|
|
577
|
+
const Be = typeof window > "u" ? $e$1.useEffect : $e$1.useLayoutEffect;
|
|
578
|
+
function _(n, e, t) {
|
|
579
|
+
const a2 = $e$1.useRef({ el: null, deps: [] }), r = $e$1.useRef(e);
|
|
580
|
+
r.current = e, Be(() => {
|
|
581
|
+
const s = (n == null ? void 0 : n.current) ?? null, o = a2.current;
|
|
582
|
+
s === o.el && t.length === o.deps.length && t.every((c2, d) => Object.is(c2, o.deps[d])) || (typeof o.cleanup == "function" && o.cleanup(), o.el = s, o.deps = [...t], o.cleanup = s ? r.current(s) : void 0);
|
|
583
|
+
}), Be(
|
|
584
|
+
() => () => {
|
|
585
|
+
const s = a2.current;
|
|
586
|
+
typeof s.cleanup == "function" && s.cleanup(), a2.current = { el: null, deps: [] };
|
|
587
|
+
},
|
|
588
|
+
[]
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
const Ue = {
|
|
592
|
+
"045e": "xbox",
|
|
593
|
+
"054c": "playstation",
|
|
594
|
+
"057e": "nintendo",
|
|
595
|
+
"28de": "steam"
|
|
596
|
+
};
|
|
597
|
+
function on(n) {
|
|
598
|
+
var a2, r, s;
|
|
599
|
+
const e = n.toLowerCase(), t = ((a2 = /vendor:\s*([0-9a-f]{4})/.exec(e)) == null ? void 0 : a2[1]) ?? ((s = (r = /^([0-9a-f]{1,4})-[0-9a-f]{1,4}-/.exec(e)) == null ? void 0 : r[1]) == null ? void 0 : s.padStart(4, "0"));
|
|
600
|
+
return t && Ue[t] ? Ue[t] : /xbox|xinput|x-box/.test(e) ? "xbox" : /dualsense|dualshock|playstation/.test(e) ? "playstation" : /nintendo|pro controller|joy-con|switch/.test(e) ? "nintendo" : /steam|valve/.test(e) ? "steam" : "generic";
|
|
601
|
+
}
|
|
602
|
+
function cn(n, e) {
|
|
603
|
+
return e !== "auto" ? e : n === "nintendo" ? "east" : "south";
|
|
604
|
+
}
|
|
605
|
+
const Ht = ["up", "down", "left", "right"], Ee = {
|
|
606
|
+
navigate: ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"],
|
|
607
|
+
activate: ["Enter", "Space"],
|
|
608
|
+
back: ["Escape"],
|
|
609
|
+
secondary: ["ContextMenu", "Shift+F10"],
|
|
610
|
+
tertiary: [],
|
|
611
|
+
menu: ["Ctrl+K"],
|
|
612
|
+
view: ["F6", "Shift+F6"],
|
|
613
|
+
sectionPrev: ["Ctrl+PageUp"],
|
|
614
|
+
sectionNext: ["Ctrl+PageDown"],
|
|
615
|
+
pagePrev: ["PageUp"],
|
|
616
|
+
pageNext: ["PageDown"],
|
|
617
|
+
first: ["Home"],
|
|
618
|
+
last: ["End"],
|
|
619
|
+
scroll: [],
|
|
620
|
+
toggleHints: ["Shift+?"]
|
|
621
|
+
}, $e = {
|
|
622
|
+
navigate: ["dpadUp", "dpadDown", "dpadLeft", "dpadRight"],
|
|
623
|
+
activate: ["south"],
|
|
624
|
+
back: ["east"],
|
|
625
|
+
secondary: ["west"],
|
|
626
|
+
tertiary: ["north"],
|
|
627
|
+
menu: ["start"],
|
|
628
|
+
view: ["select"],
|
|
629
|
+
sectionPrev: ["leftBumper"],
|
|
630
|
+
sectionNext: ["rightBumper"],
|
|
631
|
+
pagePrev: ["leftTrigger"],
|
|
632
|
+
pageNext: ["rightTrigger"],
|
|
633
|
+
first: [],
|
|
634
|
+
last: [],
|
|
635
|
+
scroll: [],
|
|
636
|
+
toggleHints: ["leftStick"]
|
|
637
|
+
}, Mn = {
|
|
638
|
+
" ": "Space",
|
|
639
|
+
Spacebar: "Space",
|
|
640
|
+
Esc: "Escape",
|
|
641
|
+
Apps: "ContextMenu",
|
|
642
|
+
Up: "ArrowUp",
|
|
643
|
+
Down: "ArrowDown",
|
|
644
|
+
Left: "ArrowLeft",
|
|
645
|
+
Right: "ArrowRight"
|
|
646
|
+
};
|
|
647
|
+
function Ve(n) {
|
|
648
|
+
return Mn[n] ?? n;
|
|
649
|
+
}
|
|
650
|
+
function Nt(n) {
|
|
651
|
+
const e = n.endsWith("++") ? [...n.slice(0, -2).split("+"), "+"] : n.split("+"), t = e.pop() ?? "", a2 = new Set(e.map((r) => r.toLowerCase()));
|
|
652
|
+
return {
|
|
653
|
+
key: Ve(t),
|
|
654
|
+
primary: a2.has("ctrl") || a2.has("cmd") || a2.has("meta") || a2.has("mod"),
|
|
655
|
+
alt: a2.has("alt") || a2.has("option"),
|
|
656
|
+
shift: a2.has("shift")
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
const gn = (n) => n.length === 1 && n.toLowerCase() === n.toUpperCase();
|
|
660
|
+
function Tt(n, e) {
|
|
661
|
+
const t = Ve(e.key);
|
|
662
|
+
return !(t.length === 1 ? t.toLowerCase() === n.key.toLowerCase() : t === n.key) || n.primary !== (e.ctrlKey || e.metaKey) || n.alt !== e.altKey ? false : gn(n.key) || n.shift === e.shiftKey;
|
|
663
|
+
}
|
|
664
|
+
function Ye(n) {
|
|
665
|
+
const e = {};
|
|
666
|
+
for (const t of Object.keys(Ee)) {
|
|
667
|
+
const a2 = n.keyboardBindings[t] ?? Ee[t];
|
|
668
|
+
e[t] = a2.map(Nt);
|
|
669
|
+
}
|
|
670
|
+
return e;
|
|
671
|
+
}
|
|
672
|
+
function bn(n, e) {
|
|
673
|
+
for (const t of Object.keys(e)) {
|
|
674
|
+
const a2 = e[t];
|
|
675
|
+
for (let r = 0; r < a2.length; r++)
|
|
676
|
+
if (Tt(a2[r], n))
|
|
677
|
+
return t === "navigate" ? { intent: t, direction: Ht[r] } : t === "view" ? { intent: t, direction: a2[r].shift ? "up" : "down" } : { intent: t };
|
|
678
|
+
}
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
const yn = /* @__PURE__ */ new Set(["GoBack", "BrowserBack", "XF86Back"]), wn = /* @__PURE__ */ new Set([461, 10009]);
|
|
682
|
+
function En(n) {
|
|
683
|
+
return yn.has(n.key) || wn.has(n.keyCode) ? { intent: "back" } : n.key === "ChannelUp" ? { intent: "sectionNext" } : n.key === "ChannelDown" ? { intent: "sectionPrev" } : null;
|
|
684
|
+
}
|
|
685
|
+
function ke(n, e) {
|
|
686
|
+
const t = cn(e, n.confirmButton), a2 = t === "south" ? "east" : "south", r = {};
|
|
687
|
+
for (const s of Object.keys($e)) {
|
|
688
|
+
const o = n.gamepadBindings[s];
|
|
689
|
+
o ? r[s] = [...o] : s === "activate" ? r[s] = [t] : s === "back" ? r[s] = [a2] : r[s] = [...$e[s]];
|
|
690
|
+
}
|
|
691
|
+
return r;
|
|
692
|
+
}
|
|
693
|
+
function kn(n) {
|
|
694
|
+
const e = /* @__PURE__ */ new Map();
|
|
695
|
+
for (const t of Object.keys(n))
|
|
696
|
+
n[t].forEach((a2, r) => {
|
|
697
|
+
e.has(a2) || e.set(a2, t === "navigate" ? { intent: t, direction: Ht[r] } : { intent: t });
|
|
698
|
+
});
|
|
699
|
+
return e;
|
|
700
|
+
}
|
|
701
|
+
const se = "data-nice-focus-scope", xe = `[${se}]`;
|
|
702
|
+
function Pt(n) {
|
|
703
|
+
const e = n.getAttribute(se), t = n.getAttribute("data-nice-scope-enter");
|
|
704
|
+
return {
|
|
705
|
+
nav: e === "vertical" || e === "horizontal" || e === "grid" || e === "none" ? e : "spatial",
|
|
706
|
+
wrap: n.hasAttribute("data-nice-scope-wrap"),
|
|
707
|
+
trap: n.hasAttribute("data-nice-scope-trap"),
|
|
708
|
+
enter: t === "selected" || t === "first" ? t : "last"
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function We(n, e) {
|
|
712
|
+
var a2;
|
|
713
|
+
const t = (a2 = n.parentElement) == null ? void 0 : a2.closest(xe);
|
|
714
|
+
return t && e.contains(t) && t !== e ? t : e;
|
|
715
|
+
}
|
|
716
|
+
function zn(n) {
|
|
717
|
+
var t, a2;
|
|
718
|
+
const e = [];
|
|
719
|
+
for (let r = (t = n.parentElement) == null ? void 0 : t.closest(xe); r; r = (a2 = r.parentElement) == null ? void 0 : a2.closest(xe))
|
|
720
|
+
e.push(r);
|
|
721
|
+
return e;
|
|
722
|
+
}
|
|
723
|
+
function An(n) {
|
|
724
|
+
var t;
|
|
725
|
+
const e = (t = n.closest("[data-nice-arrows]")) == null ? void 0 : t.getAttribute("data-nice-arrows");
|
|
726
|
+
return e === "spatial" || e === "native" ? e : null;
|
|
727
|
+
}
|
|
728
|
+
const Xe = { horizontal: 30, vertical: 2 }, G = 1, Je = (n) => n === "left" || n === "right", Ze = (n, e, t, a2) => Math.max(0, Math.max(n, t) - Math.min(e, a2));
|
|
729
|
+
function Sn(n, e, t) {
|
|
730
|
+
switch (t) {
|
|
731
|
+
case "right":
|
|
732
|
+
return e.left >= n.right - G;
|
|
733
|
+
case "left":
|
|
734
|
+
return e.right <= n.left + G;
|
|
735
|
+
case "down":
|
|
736
|
+
return e.top >= n.bottom - G;
|
|
737
|
+
default:
|
|
738
|
+
return e.bottom <= n.top + G;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
function Ln(n, e, t) {
|
|
742
|
+
const a2 = n.left + n.width / 2, r = n.top + n.height / 2, s = e.left + e.width / 2, o = e.top + e.height / 2;
|
|
743
|
+
switch (t) {
|
|
744
|
+
case "right":
|
|
745
|
+
return s > a2 + G;
|
|
746
|
+
case "left":
|
|
747
|
+
return s < a2 - G;
|
|
748
|
+
case "down":
|
|
749
|
+
return o > r + G;
|
|
750
|
+
default:
|
|
751
|
+
return o < r - G;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
function Cn(n, e, t) {
|
|
755
|
+
let a2, r, s;
|
|
756
|
+
Je(t) ? (a2 = t === "right" ? e.left - n.right : n.left - e.right, r = Ze(n.top, n.bottom, e.top, e.bottom), s = Math.abs(e.top + e.height / 2 - (n.top + n.height / 2))) : (a2 = t === "down" ? e.top - n.bottom : n.top - e.bottom, r = Ze(n.left, n.right, e.left, e.right), s = Math.abs(e.left + e.width / 2 - (n.left + n.width / 2)));
|
|
757
|
+
const o = Je(t) ? Xe.horizontal : Xe.vertical;
|
|
758
|
+
return Math.max(0, a2) + r * o + s * 0.01;
|
|
759
|
+
}
|
|
760
|
+
function Dt(n, e, t, a2) {
|
|
761
|
+
const r = e.map(t);
|
|
762
|
+
for (const s of [Sn, Ln]) {
|
|
763
|
+
let o = -1, i2 = 1 / 0;
|
|
764
|
+
for (let c2 = 0; c2 < r.length; c2++) {
|
|
765
|
+
if (!s(n, r[c2], a2))
|
|
766
|
+
continue;
|
|
767
|
+
const d = Cn(n, r[c2], a2);
|
|
768
|
+
d < i2 && (i2 = d, o = c2);
|
|
769
|
+
}
|
|
770
|
+
if (o >= 0)
|
|
771
|
+
return e[o];
|
|
772
|
+
}
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
const de = (n) => n === "left" || n === "right", Hn = (n) => {
|
|
776
|
+
var e;
|
|
777
|
+
return ((e = n.ownerDocument.defaultView) == null ? void 0 : e.getComputedStyle(n).direction) === "rtl";
|
|
778
|
+
};
|
|
779
|
+
function Nn(n, e, t, a2) {
|
|
780
|
+
if (n.length === 0)
|
|
781
|
+
return null;
|
|
782
|
+
const r = (s) => !!(e.compareDocumentPosition(s) & Node.DOCUMENT_POSITION_FOLLOWING);
|
|
783
|
+
if (t)
|
|
784
|
+
return n.find(r) ?? (a2 ? n[0] : null);
|
|
785
|
+
for (let s = n.length - 1; s >= 0; s--)
|
|
786
|
+
if (!r(n[s]))
|
|
787
|
+
return n[s];
|
|
788
|
+
return a2 ? n[n.length - 1] : null;
|
|
789
|
+
}
|
|
790
|
+
const Tn = '[aria-selected="true"],[aria-checked="true"],[aria-current]:not([aria-current="false"]),:checked';
|
|
791
|
+
function Pn(n, e, t) {
|
|
792
|
+
let a2 = null;
|
|
793
|
+
for (let s = n.parentElement; s && !s.contains(e); s = s.parentElement)
|
|
794
|
+
s.hasAttribute(se) && (a2 = s);
|
|
795
|
+
if (!a2)
|
|
796
|
+
return n;
|
|
797
|
+
const r = Pt(a2).enter;
|
|
798
|
+
if (r === "last") {
|
|
799
|
+
const s = t.get(a2);
|
|
800
|
+
return s && s.isConnected && a2.contains(s) && ne(s) ? s : n;
|
|
801
|
+
}
|
|
802
|
+
return r === "selected" ? [...a2.querySelectorAll(Tn)].find(ne) ?? n : U(a2)[0] ?? n;
|
|
803
|
+
}
|
|
804
|
+
function Dn(n, e, t) {
|
|
805
|
+
const a2 = J(n);
|
|
806
|
+
let r = We(n, t.root), s = null;
|
|
807
|
+
for (; ; ) {
|
|
808
|
+
const o = Pt(r);
|
|
809
|
+
if (o.nav === "spatial" || o.nav === "grid" || o.nav === "vertical" && !de(e) || o.nav === "horizontal" && de(e)) {
|
|
810
|
+
const c2 = U(r, [n, s]);
|
|
811
|
+
let d;
|
|
812
|
+
if (o.nav === "vertical" || o.nav === "horizontal") {
|
|
813
|
+
let u = e === "down" || e === "right";
|
|
814
|
+
de(e) && Hn(r) && (u = !u), d = Nn(c2, n, u, o.wrap);
|
|
815
|
+
} else
|
|
816
|
+
d = Dt(a2, c2, J, e);
|
|
817
|
+
if (d)
|
|
818
|
+
return Pn(d, n, t.memory);
|
|
819
|
+
}
|
|
820
|
+
if (r === t.root || o.trap)
|
|
821
|
+
return null;
|
|
822
|
+
s = r, r = We(r, t.root);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
function Qe(n, e) {
|
|
826
|
+
const t = e.left + e.width / 2, a2 = e.top + e.height / 2;
|
|
827
|
+
let r = null, s = 1 / 0;
|
|
828
|
+
for (const o of U(n)) {
|
|
829
|
+
const i2 = J(o), c2 = Math.hypot(i2.left + i2.width / 2 - t, i2.top + i2.height / 2 - a2);
|
|
830
|
+
c2 < s && (s = c2, r = o);
|
|
831
|
+
}
|
|
832
|
+
return r;
|
|
833
|
+
}
|
|
834
|
+
const It = [
|
|
835
|
+
"[data-nice-region]",
|
|
836
|
+
"header",
|
|
837
|
+
"nav",
|
|
838
|
+
"main",
|
|
839
|
+
"aside",
|
|
840
|
+
"footer",
|
|
841
|
+
'[role="banner"]',
|
|
842
|
+
'[role="navigation"]',
|
|
843
|
+
'[role="main"]',
|
|
844
|
+
'[role="complementary"]',
|
|
845
|
+
'[role="contentinfo"]',
|
|
846
|
+
'[role="search"]',
|
|
847
|
+
'[role="region"][aria-label]',
|
|
848
|
+
'[role="region"][aria-labelledby]'
|
|
849
|
+
].join(",");
|
|
850
|
+
function In(n, e, t) {
|
|
851
|
+
const a2 = [...t.root.querySelectorAll(It)], r = a2.filter(
|
|
852
|
+
(u) => !a2.some((p) => p !== u && p.contains(u)) && U(u).length > 0
|
|
853
|
+
);
|
|
854
|
+
if (r.length === 0)
|
|
855
|
+
return null;
|
|
856
|
+
const s = r.findIndex((u) => u.contains(n)), o = e === "up" || e === "left" ? -1 : 1, i2 = s < 0 ? o > 0 ? -1 : 0 : s, c2 = r[(i2 + o + r.length) % r.length];
|
|
857
|
+
if (c2 === r[s])
|
|
858
|
+
return null;
|
|
859
|
+
const d = t.memory.get(c2);
|
|
860
|
+
return d && d.isConnected && c2.contains(d) && ne(d) ? d : U(c2)[0];
|
|
861
|
+
}
|
|
862
|
+
const he = [
|
|
863
|
+
"south",
|
|
864
|
+
"east",
|
|
865
|
+
"west",
|
|
866
|
+
"north",
|
|
867
|
+
"leftBumper",
|
|
868
|
+
"rightBumper",
|
|
869
|
+
"leftTrigger",
|
|
870
|
+
"rightTrigger",
|
|
871
|
+
"select",
|
|
872
|
+
"start",
|
|
873
|
+
"leftStick",
|
|
874
|
+
"rightStick",
|
|
875
|
+
"dpadUp",
|
|
876
|
+
"dpadDown",
|
|
877
|
+
"dpadLeft",
|
|
878
|
+
"dpadRight",
|
|
879
|
+
"home"
|
|
880
|
+
], ze = "nice-intent", ae = "nice-engagechange", W = {
|
|
881
|
+
confirmButton: "auto",
|
|
882
|
+
gamepadBindings: {},
|
|
883
|
+
keyboardBindings: {},
|
|
884
|
+
stickThreshold: 0.5,
|
|
885
|
+
stickDeadzone: 0.2,
|
|
886
|
+
invertScroll: false,
|
|
887
|
+
repeatDelay: 400,
|
|
888
|
+
repeatInterval: 110,
|
|
889
|
+
repeatIntervalMin: 50,
|
|
890
|
+
hints: "auto",
|
|
891
|
+
hintDensity: "bar",
|
|
892
|
+
glyphFamily: "auto",
|
|
893
|
+
vibration: false,
|
|
894
|
+
arrowNavigation: "auto",
|
|
895
|
+
onScreenKeyboard: "auto"
|
|
896
|
+
}, On = /* @__PURE__ */ new Set([4, 5, 6, 7, 12, 13, 14, 15]), Rn = 0.85;
|
|
897
|
+
function Vn(n, e) {
|
|
898
|
+
return Math.abs(n) > Math.abs(e) ? n > 0 ? "right" : "left" : e > 0 ? "down" : "up";
|
|
899
|
+
}
|
|
900
|
+
class Fn {
|
|
901
|
+
constructor(e, t) {
|
|
902
|
+
this.states = /* @__PURE__ */ new Map(), this.connected = /* @__PURE__ */ new Set(), this.warned = /* @__PURE__ */ new Set(), this.started = false, this.frameId = 0, this.onConnected = (a2) => {
|
|
903
|
+
const r = a2.gamepad;
|
|
904
|
+
r && this.connected.add(r.index), this.schedule();
|
|
905
|
+
}, this.onDisconnected = (a2) => {
|
|
906
|
+
var s, o;
|
|
907
|
+
const r = a2.gamepad;
|
|
908
|
+
r && (this.connected.delete(r.index), this.states.delete(r.index) && ((o = (s = this.opts).onPadsChange) == null || o.call(s, this.pads))), this.connected.size === 0 && this.cancel();
|
|
909
|
+
}, this.onVisibility = () => {
|
|
910
|
+
this.win.document.hidden ? this.cancel() : this.schedule();
|
|
911
|
+
}, this.frame = (a2) => {
|
|
912
|
+
this.frameId = 0, this.poll(a2), this.schedule();
|
|
913
|
+
}, this.win = e, this.opts = t;
|
|
914
|
+
}
|
|
915
|
+
/** Whether an animation frame is scheduled (false without a pad or on a hidden page). */
|
|
916
|
+
get running() {
|
|
917
|
+
return this.frameId !== 0;
|
|
918
|
+
}
|
|
919
|
+
get pads() {
|
|
920
|
+
return [...this.states.values()].map((e) => e.info);
|
|
921
|
+
}
|
|
922
|
+
start() {
|
|
923
|
+
if (!this.started) {
|
|
924
|
+
this.started = true, this.win.addEventListener("gamepadconnected", this.onConnected), this.win.addEventListener("gamepaddisconnected", this.onDisconnected), this.win.document.addEventListener("visibilitychange", this.onVisibility);
|
|
925
|
+
for (const e of this.read())
|
|
926
|
+
this.connected.add(e.index);
|
|
927
|
+
this.schedule();
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
stop() {
|
|
931
|
+
this.started && (this.started = false, this.win.removeEventListener("gamepadconnected", this.onConnected), this.win.removeEventListener("gamepaddisconnected", this.onDisconnected), this.win.document.removeEventListener("visibilitychange", this.onVisibility), this.cancel(), this.connected.clear(), this.states.clear());
|
|
932
|
+
}
|
|
933
|
+
/** Read every pad once; public so tests can drive a frame. */
|
|
934
|
+
poll(e) {
|
|
935
|
+
var o, i2, c2, d, u, p;
|
|
936
|
+
const t = this.opts.timing(), a2 = /* @__PURE__ */ new Set(), r = this.read();
|
|
937
|
+
for (const l of r) {
|
|
938
|
+
a2.add(l.index);
|
|
939
|
+
let v2 = this.states.get(l.index);
|
|
940
|
+
(!v2 || v2.info.id !== l.id) && (v2 = {
|
|
941
|
+
info: {
|
|
942
|
+
index: l.index,
|
|
943
|
+
id: l.id,
|
|
944
|
+
family: on(l.id),
|
|
945
|
+
mapping: l.mapping
|
|
946
|
+
},
|
|
947
|
+
pressed: [],
|
|
948
|
+
stick: null,
|
|
949
|
+
holds: /* @__PURE__ */ new Map()
|
|
950
|
+
}, this.states.set(l.index, v2), this.warnMapping(l), (i2 = (o = this.opts).onPadsChange) == null || i2.call(o, this.pads)), this.readButtons(v2, l, e, t), this.readSticks(v2, l, e, t);
|
|
951
|
+
}
|
|
952
|
+
let s = false;
|
|
953
|
+
for (const l of [...this.states.keys()])
|
|
954
|
+
a2.has(l) || (this.states.delete(l), s = true);
|
|
955
|
+
s && ((d = (c2 = this.opts).onPadsChange) == null || d.call(c2, this.pads)), (p = (u = this.opts).onFrame) == null || p.call(u, r, e);
|
|
956
|
+
}
|
|
957
|
+
readButtons(e, t, a2, r) {
|
|
958
|
+
for (let s = 0; s < he.length; s++) {
|
|
959
|
+
const o = t.buttons[s], i2 = !!(o && (o.pressed || o.value > 0.5)), c2 = `b${s}`;
|
|
960
|
+
i2 !== !!e.pressed[s] ? (e.pressed[s] = i2, i2 && On.has(s) ? e.holds.set(c2, { since: a2, last: a2, count: 0 }) : e.holds.delete(c2), this.opts.onButton({
|
|
961
|
+
pad: e.info,
|
|
962
|
+
button: he[s],
|
|
963
|
+
pressed: i2,
|
|
964
|
+
repeat: false
|
|
965
|
+
})) : i2 && this.repeats(e, c2, a2, r) && this.opts.onButton({
|
|
966
|
+
pad: e.info,
|
|
967
|
+
button: he[s],
|
|
968
|
+
pressed: i2,
|
|
969
|
+
repeat: true
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
readSticks(e, t, a2, r) {
|
|
974
|
+
const s = t.axes[0] ?? 0, o = t.axes[1] ?? 0, i2 = Math.hypot(s, o);
|
|
975
|
+
if (i2 >= r.stickThreshold) {
|
|
976
|
+
const p = Vn(s, o);
|
|
977
|
+
p !== e.stick ? (e.stick = p, e.holds.set("stick", { since: a2, last: a2, count: 0 }), this.opts.onStick({ pad: e.info, direction: p, repeat: false })) : this.repeats(e, "stick", a2, r) && this.opts.onStick({ pad: e.info, direction: p, repeat: true });
|
|
978
|
+
} else e.stick && i2 < r.stickThreshold * 0.7 && (e.stick = null, e.holds.delete("stick"));
|
|
979
|
+
const c2 = t.axes[2] ?? 0, d = t.axes[3] ?? 0, u = Math.hypot(c2, d);
|
|
980
|
+
if (u > r.stickDeadzone) {
|
|
981
|
+
const p = (u - r.stickDeadzone) / (1 - r.stickDeadzone) / u;
|
|
982
|
+
this.opts.onScroll({ pad: e.info, x: c2 * p, y: d * p });
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
repeats(e, t, a2, r) {
|
|
986
|
+
const s = e.holds.get(t);
|
|
987
|
+
if (!s || a2 - s.since < r.repeatDelay)
|
|
988
|
+
return false;
|
|
989
|
+
const o = Math.max(
|
|
990
|
+
r.repeatIntervalMin,
|
|
991
|
+
r.repeatInterval * Rn ** s.count
|
|
992
|
+
);
|
|
993
|
+
return a2 - s.last < o ? false : (s.last = a2, s.count++, true);
|
|
994
|
+
}
|
|
995
|
+
read() {
|
|
996
|
+
var a2, r;
|
|
997
|
+
const e = ((r = (a2 = this.win.navigator).getGamepads) == null ? void 0 : r.call(a2)) ?? [], t = [];
|
|
998
|
+
for (const s of e)
|
|
999
|
+
s && s.connected !== false && t.push(s);
|
|
1000
|
+
return t;
|
|
1001
|
+
}
|
|
1002
|
+
warnMapping(e) {
|
|
1003
|
+
e.mapping === "standard" || this.warned.has(e.id) || (this.warned.add(e.id), process.env.NODE_ENV !== "production" && console.warn(
|
|
1004
|
+
`[nice2dev/input] "${e.id}" has no standard mapping; its buttons are read by standard positions and may be off.`
|
|
1005
|
+
));
|
|
1006
|
+
}
|
|
1007
|
+
schedule() {
|
|
1008
|
+
this.frameId === 0 && this.started && this.connected.size > 0 && !this.win.document.hidden && typeof this.win.requestAnimationFrame == "function" && (this.frameId = this.win.requestAnimationFrame(this.frame));
|
|
1009
|
+
}
|
|
1010
|
+
cancel() {
|
|
1011
|
+
this.frameId !== 0 && (this.win.cancelAnimationFrame(this.frameId), this.frameId = 0);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
const _n = {
|
|
1015
|
+
up: "ArrowUp",
|
|
1016
|
+
down: "ArrowDown",
|
|
1017
|
+
left: "ArrowLeft",
|
|
1018
|
+
right: "ArrowRight"
|
|
1019
|
+
}, et = {
|
|
1020
|
+
ArrowUp: 38,
|
|
1021
|
+
ArrowDown: 40,
|
|
1022
|
+
ArrowLeft: 37,
|
|
1023
|
+
ArrowRight: 39,
|
|
1024
|
+
Enter: 13,
|
|
1025
|
+
Escape: 27,
|
|
1026
|
+
Home: 36,
|
|
1027
|
+
End: 35,
|
|
1028
|
+
PageUp: 33,
|
|
1029
|
+
PageDown: 34
|
|
1030
|
+
}, tt = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta", "AltGraph", "OS"]), Bn = /Web0S|webOS|Tizen|SMART-TV|SmartTV|HbbTV|NetCast|Android TV|AFT|BRAVIA|CrKey/i, nt = 18, at = (n) => n === "keyboard" || n === "gamepad" || n === "remote";
|
|
1031
|
+
class Kn {
|
|
1032
|
+
constructor(e) {
|
|
1033
|
+
this.started = false, this.listeners = /* @__PURE__ */ new Set(), this.frameListeners = /* @__PURE__ */ new Set(), this.padMaps = /* @__PURE__ */ new Map(), this.memory = /* @__PURE__ */ new WeakMap(), this.engagedValues = /* @__PURE__ */ new WeakMap(), this.overlays = [], this.hintsToggled = false, this.activePad = null, this.lastFocus = null, this.observer = null, this.live = null, this.snapshot = [], this.capture = null, this.translate = (t, a2) => a2, this.onKeyDown = (t) => {
|
|
1034
|
+
if (t.niceSource)
|
|
1035
|
+
return;
|
|
1036
|
+
const a2 = En(t), r = this.tv || a2 ? "remote" : "keyboard";
|
|
1037
|
+
if (tt.has(t.key) || this.setMethod(r), this.capture && !tt.has(t.key)) {
|
|
1038
|
+
t.preventDefault();
|
|
1039
|
+
const c2 = [
|
|
1040
|
+
t.ctrlKey || t.metaKey ? "Ctrl" : "",
|
|
1041
|
+
t.altKey ? "Alt" : "",
|
|
1042
|
+
t.shiftKey ? "Shift" : ""
|
|
1043
|
+
], d = Ve(t.key);
|
|
1044
|
+
this.capture({
|
|
1045
|
+
keys: [...c2, d.length === 1 ? d.toUpperCase() : d].filter(Boolean).join("+")
|
|
1046
|
+
});
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
if (t.defaultPrevented || t.isComposing)
|
|
1050
|
+
return;
|
|
1051
|
+
const s = a2 ?? bn(t, this.keyTable);
|
|
1052
|
+
if (!s)
|
|
1053
|
+
return;
|
|
1054
|
+
const o = this.targetOf(t);
|
|
1055
|
+
if (qt(o, s))
|
|
1056
|
+
return;
|
|
1057
|
+
const i2 = {
|
|
1058
|
+
intent: s.intent,
|
|
1059
|
+
direction: s.direction,
|
|
1060
|
+
source: r,
|
|
1061
|
+
repeat: t.repeat,
|
|
1062
|
+
keyEvent: t
|
|
1063
|
+
};
|
|
1064
|
+
(this.dispatchIntent(i2, o) || this.keyDefault(i2, o)) && t.preventDefault();
|
|
1065
|
+
}, this.onPadButton = (t) => {
|
|
1066
|
+
if (this.activePad = t.pad, this.setMethod("gamepad", t.pad.family), !t.pressed)
|
|
1067
|
+
return;
|
|
1068
|
+
if (this.capture) {
|
|
1069
|
+
t.repeat || this.capture({ button: t.button });
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
const a2 = this.padMap(t.pad.family).get(t.button);
|
|
1073
|
+
a2 && this.deviceIntent({ ...a2, source: "gamepad", repeat: t.repeat, gamepad: t.pad });
|
|
1074
|
+
}, this.onPadStick = (t) => {
|
|
1075
|
+
this.activePad = t.pad, this.setMethod("gamepad", t.pad.family), !this.capture && this.deviceIntent({
|
|
1076
|
+
intent: "navigate",
|
|
1077
|
+
direction: t.direction,
|
|
1078
|
+
source: "gamepad",
|
|
1079
|
+
repeat: t.repeat,
|
|
1080
|
+
gamepad: t.pad
|
|
1081
|
+
});
|
|
1082
|
+
}, this.onPadScroll = (t) => {
|
|
1083
|
+
this.activePad = t.pad, this.setMethod("gamepad", t.pad.family);
|
|
1084
|
+
const a2 = this.state.preferences.invertScroll ? -1 : 1, r = t.x * a2, s = t.y * a2, o = this.focused(), i2 = {
|
|
1085
|
+
intent: "scroll",
|
|
1086
|
+
direction: Math.abs(r) > Math.abs(s) ? r > 0 ? "right" : "left" : s > 0 ? "down" : "up",
|
|
1087
|
+
amount: Math.min(1, Math.hypot(r, s)),
|
|
1088
|
+
source: "gamepad",
|
|
1089
|
+
repeat: true,
|
|
1090
|
+
gamepad: t.pad
|
|
1091
|
+
};
|
|
1092
|
+
this.dispatchIntent(i2, o) || rt(st(o, r, s), r * nt, s * nt);
|
|
1093
|
+
}, this.onPointerDown = (t) => {
|
|
1094
|
+
this.setMethod(t.pointerType === "touch" ? "touch" : "pointer");
|
|
1095
|
+
}, this.onFocusIn = (t) => {
|
|
1096
|
+
const a2 = t.target;
|
|
1097
|
+
if (a2 instanceof HTMLElement) {
|
|
1098
|
+
for (let r = a2.parentElement; r; r = r.parentElement)
|
|
1099
|
+
(r.hasAttribute(se) || r.matches(It) || r === this.doc.body) && this.memory.set(r, a2);
|
|
1100
|
+
this.lastFocus = { el: a2, rect: J(a2), scope: zn(a2)[0] ?? null };
|
|
1101
|
+
}
|
|
1102
|
+
}, this.onFocusOut = (t) => {
|
|
1103
|
+
const a2 = t.target;
|
|
1104
|
+
a2 instanceof HTMLElement && a2.hasAttribute("data-nice-engaged") && this.release(a2, this.state.method === "gamepad" ? "gamepad" : "keyboard", false);
|
|
1105
|
+
}, this.recover = () => {
|
|
1106
|
+
const t = this.lastFocus;
|
|
1107
|
+
if (!t || t.el.isConnected)
|
|
1108
|
+
return;
|
|
1109
|
+
this.lastFocus = null;
|
|
1110
|
+
const a2 = this.doc.activeElement;
|
|
1111
|
+
if (a2 && a2 !== this.doc.body)
|
|
1112
|
+
return;
|
|
1113
|
+
const r = this.navigationRoot(), s = t.scope && t.scope.isConnected && r.contains(t.scope) ? t.scope : r, o = Qe(s, t.rect) ?? (s !== r ? Qe(r, t.rect) : null);
|
|
1114
|
+
o && this.focusElement(o);
|
|
1115
|
+
}, this.win = e, this.doc = e.document, this.tv = Bn.test(e.navigator.userAgent), this.keyTable = Ye(W), this.state = {
|
|
1116
|
+
method: "pointer",
|
|
1117
|
+
family: null,
|
|
1118
|
+
pads: [],
|
|
1119
|
+
preferences: W,
|
|
1120
|
+
hintsVisible: W.hints === "always"
|
|
1121
|
+
}, this.poller = new Fn(e, {
|
|
1122
|
+
timing: () => this.state.preferences,
|
|
1123
|
+
onButton: this.onPadButton,
|
|
1124
|
+
onStick: this.onPadStick,
|
|
1125
|
+
onScroll: this.onPadScroll,
|
|
1126
|
+
onPadsChange: (t) => {
|
|
1127
|
+
t.length === 0 && (this.snapshot = []), this.update({ pads: t });
|
|
1128
|
+
},
|
|
1129
|
+
onFrame: (t, a2) => {
|
|
1130
|
+
this.snapshot = t, this.frameListeners.forEach((r) => r(t, a2));
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
/* ── Lifecycle ───────────────────────────────────────────────── */
|
|
1135
|
+
get isStarted() {
|
|
1136
|
+
return this.started;
|
|
1137
|
+
}
|
|
1138
|
+
/** Whether the page runs in a TV browser (webOS, Tizen, Android TV, …): remote and 10-foot. */
|
|
1139
|
+
get isTv() {
|
|
1140
|
+
return this.tv;
|
|
1141
|
+
}
|
|
1142
|
+
start() {
|
|
1143
|
+
this.started || (this.started = true, this.tv && !this.doc.documentElement.hasAttribute("data-nice-tv") && this.doc.documentElement.setAttribute("data-nice-tv", "auto"), this.win.addEventListener("keydown", this.onKeyDown), this.win.addEventListener("pointerdown", this.onPointerDown, { capture: true, passive: true }), this.doc.addEventListener("focusin", this.onFocusIn), this.doc.addEventListener("focusout", this.onFocusOut), this.poller.start());
|
|
1144
|
+
}
|
|
1145
|
+
stop() {
|
|
1146
|
+
this.started && (this.started = false, this.win.removeEventListener("keydown", this.onKeyDown), this.win.removeEventListener("pointerdown", this.onPointerDown, { capture: true }), this.doc.removeEventListener("focusin", this.onFocusIn), this.doc.removeEventListener("focusout", this.onFocusOut), this.poller.stop(), this.watchRecovery(false));
|
|
1147
|
+
}
|
|
1148
|
+
/** Whether the gamepad loop is scheduled (false without a pad). */
|
|
1149
|
+
get polling() {
|
|
1150
|
+
return this.poller.running;
|
|
1151
|
+
}
|
|
1152
|
+
/* ── State ───────────────────────────────────────────────────── */
|
|
1153
|
+
/** Same object until something changes (fit for `useSyncExternalStore`). */
|
|
1154
|
+
getState() {
|
|
1155
|
+
return this.state;
|
|
1156
|
+
}
|
|
1157
|
+
subscribe(e) {
|
|
1158
|
+
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
1159
|
+
}
|
|
1160
|
+
setPreferences(e) {
|
|
1161
|
+
const t = { ...this.state.preferences, ...e };
|
|
1162
|
+
this.keyTable = Ye(t), this.padMaps.clear(), this.update({ preferences: t });
|
|
1163
|
+
}
|
|
1164
|
+
/** Words of announcements and labels; the React provider passes the app's translator. */
|
|
1165
|
+
setTranslator(e) {
|
|
1166
|
+
this.translate = e;
|
|
1167
|
+
}
|
|
1168
|
+
/** Pad family of the prompts: the preference, else the pad used last. */
|
|
1169
|
+
get glyphFamily() {
|
|
1170
|
+
const e = this.state.preferences.glyphFamily;
|
|
1171
|
+
return e !== "auto" ? e : this.state.family ?? "xbox";
|
|
1172
|
+
}
|
|
1173
|
+
/** The buttons bound to an intent on a pad of the family (for prompts). */
|
|
1174
|
+
gamepadBinding(e, t = this.glyphFamily) {
|
|
1175
|
+
return ke(this.state.preferences, t)[e];
|
|
1176
|
+
}
|
|
1177
|
+
/** The keys bound to an intent (for prompts), as written in the preferences. */
|
|
1178
|
+
keyboardBinding(e) {
|
|
1179
|
+
return this.keyTable[e];
|
|
1180
|
+
}
|
|
1181
|
+
toggleHints() {
|
|
1182
|
+
this.hintsToggled = !this.hintsToggled, this.update({});
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Hands the next pad button or key press to `onInput` instead of acting on it (a bindings
|
|
1186
|
+
* screen); returns what cancels the capture.
|
|
1187
|
+
*/
|
|
1188
|
+
captureNextInput(e) {
|
|
1189
|
+
const t = (a2) => {
|
|
1190
|
+
this.capture = null, e(a2);
|
|
1191
|
+
};
|
|
1192
|
+
return this.capture = t, () => {
|
|
1193
|
+
this.capture === t && (this.capture = null);
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
update(e) {
|
|
1197
|
+
const t = { ...this.state, ...e }, { hints: a2 } = t.preferences;
|
|
1198
|
+
let r = a2 === "always" ? true : a2 === "never" ? false : at(t.method);
|
|
1199
|
+
this.hintsToggled && (r = !r), t.hintsVisible = r, this.state = t, this.listeners.forEach((s) => s());
|
|
1200
|
+
}
|
|
1201
|
+
setMethod(e, t) {
|
|
1202
|
+
const a2 = this.doc.documentElement;
|
|
1203
|
+
t && a2.getAttribute("data-nice-gamepad") !== t && a2.setAttribute("data-nice-gamepad", t), !(e === this.state.method && (t === void 0 || t === this.state.family)) && (a2.setAttribute("data-nice-input", e), this.watchRecovery(at(e)), this.update(t ? { method: e, family: t } : { method: e }));
|
|
1204
|
+
}
|
|
1205
|
+
/* ── Gamepad frames (games, device testers) ──────────────────── */
|
|
1206
|
+
/** Raw pads every polled frame while a pad is connected. */
|
|
1207
|
+
subscribeGamepadFrames(e) {
|
|
1208
|
+
return this.frameListeners.add(e), () => this.frameListeners.delete(e);
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* The pads as read in the last polled frame — empty without a pad. For code that runs its own
|
|
1212
|
+
* animation loop (games, particle effects) instead of a second `getGamepads()` reader.
|
|
1213
|
+
*/
|
|
1214
|
+
get gamepadSnapshot() {
|
|
1215
|
+
return this.snapshot;
|
|
1216
|
+
}
|
|
1217
|
+
/** Feedback rumble on the pad used last, when the user allows vibration. */
|
|
1218
|
+
vibrate(e, t = 0.5) {
|
|
1219
|
+
this.state.preferences.vibration && this.activePad && this.rumble(this.activePad.index, e, t, t);
|
|
1220
|
+
}
|
|
1221
|
+
/** Rumble a given pad regardless of the preference (a game's own effect). */
|
|
1222
|
+
rumble(e, t, a2 = 0.5, r = 0.5) {
|
|
1223
|
+
var i2, c2, d;
|
|
1224
|
+
const s = (c2 = (i2 = this.win.navigator).getGamepads) == null ? void 0 : c2.call(i2)[e], o = s == null ? void 0 : s.vibrationActuator;
|
|
1225
|
+
(d = o == null ? void 0 : o.playEffect) == null || d.call(o, "dual-rumble", {
|
|
1226
|
+
startDelay: 0,
|
|
1227
|
+
duration: t,
|
|
1228
|
+
weakMagnitude: a2,
|
|
1229
|
+
strongMagnitude: r
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
/* ── Overlays ────────────────────────────────────────────────── */
|
|
1233
|
+
/** Puts an overlay on the stack; returns what takes it off. */
|
|
1234
|
+
pushOverlay(e) {
|
|
1235
|
+
return this.overlays.push(e), () => {
|
|
1236
|
+
const t = this.overlays.lastIndexOf(e);
|
|
1237
|
+
t >= 0 && this.overlays.splice(t, 1);
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
topOverlay() {
|
|
1241
|
+
return this.overlays[this.overlays.length - 1];
|
|
1242
|
+
}
|
|
1243
|
+
/** Closes the top overlay that can be closed; returns whether one was. */
|
|
1244
|
+
closeTopOverlay(e) {
|
|
1245
|
+
for (let t = this.overlays.length - 1; t >= 0; t--) {
|
|
1246
|
+
const a2 = this.overlays[t];
|
|
1247
|
+
if (a2.onClose)
|
|
1248
|
+
return a2.onClose(e), true;
|
|
1249
|
+
if (a2.modal)
|
|
1250
|
+
return false;
|
|
1251
|
+
}
|
|
1252
|
+
return false;
|
|
1253
|
+
}
|
|
1254
|
+
/* ── Intents ─────────────────────────────────────────────────── */
|
|
1255
|
+
/** Dispatches `nice-intent` on the target; returns whether a handler consumed it. */
|
|
1256
|
+
dispatchIntent(e, t = this.focused()) {
|
|
1257
|
+
const a2 = new CustomEvent(ze, {
|
|
1258
|
+
detail: e,
|
|
1259
|
+
bubbles: true,
|
|
1260
|
+
cancelable: true,
|
|
1261
|
+
composed: true
|
|
1262
|
+
});
|
|
1263
|
+
return t.dispatchEvent(a2), a2.defaultPrevented;
|
|
1264
|
+
}
|
|
1265
|
+
/** Moves focus in a direction through the scope tree; returns whether it moved. */
|
|
1266
|
+
moveFocus(e, t = this.focused()) {
|
|
1267
|
+
const a2 = this.navigationRoot();
|
|
1268
|
+
if (t === this.doc.body || !a2.contains(t))
|
|
1269
|
+
return this.focusInitial(a2);
|
|
1270
|
+
const r = Dn(t, e, { root: a2, memory: this.memory });
|
|
1271
|
+
return r ? (this.focusElement(r), true) : false;
|
|
1272
|
+
}
|
|
1273
|
+
/** The `view` intent: next (`down`) or previous (`up`) region. */
|
|
1274
|
+
focusRegion(e, t = this.focused()) {
|
|
1275
|
+
const a2 = In(t, e, {
|
|
1276
|
+
root: this.navigationRoot(),
|
|
1277
|
+
memory: this.memory
|
|
1278
|
+
});
|
|
1279
|
+
return a2 ? (this.focusElement(a2), true) : false;
|
|
1280
|
+
}
|
|
1281
|
+
/** Focuses the element and brings it into view (scroll-padding respected). */
|
|
1282
|
+
focusElement(e) {
|
|
1283
|
+
var t;
|
|
1284
|
+
e.focus({ preventScroll: true, focusVisible: true }), (t = e.scrollIntoView) == null || t.call(e, { block: "nearest", inline: "nearest" });
|
|
1285
|
+
}
|
|
1286
|
+
/** Engages a control (ADR-005 § 6); popup controls open instead. */
|
|
1287
|
+
engage(e, t, a2 = me(e)) {
|
|
1288
|
+
if (a2) {
|
|
1289
|
+
if (a2 === "popup") {
|
|
1290
|
+
this.emulateKey(e, "ArrowDown", t);
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
e.setAttribute("data-nice-engaged", ""), be(e) && this.engagedValues.set(e, e.value), this.fireEngage(e, { engaged: true, cancelled: false, source: t }), this.announce(this.translate("input.engaged", "Editing"));
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Releases an engaged control; `cancelled` when left with `back`. A native number field gets
|
|
1298
|
+
* its value from before back; custom controls do that in `useEngage`'s `onRelease`.
|
|
1299
|
+
*/
|
|
1300
|
+
release(e, t, a2) {
|
|
1301
|
+
if (!e.hasAttribute("data-nice-engaged"))
|
|
1302
|
+
return;
|
|
1303
|
+
e.removeAttribute("data-nice-engaged");
|
|
1304
|
+
const r = this.engagedValues.get(e);
|
|
1305
|
+
this.engagedValues.delete(e), a2 && r !== void 0 && be(e) && Wt(e, r), this.fireEngage(e, { engaged: false, cancelled: a2, source: t }), this.announce(this.translate("input.released", "Done editing"));
|
|
1306
|
+
}
|
|
1307
|
+
/** Defaults of trusted keys: the browser already clicks, types and scrolls. */
|
|
1308
|
+
keyDefault(e, t) {
|
|
1309
|
+
switch (e.intent) {
|
|
1310
|
+
case "navigate":
|
|
1311
|
+
return this.arrowPolicy(t, e.source) === "spatial" ? this.moveFocus(e.direction ?? "down", t) : false;
|
|
1312
|
+
case "view":
|
|
1313
|
+
return this.focusRegion(e.direction ?? "down", t);
|
|
1314
|
+
case "back":
|
|
1315
|
+
return this.closeTopOverlay(e.source);
|
|
1316
|
+
case "toggleHints":
|
|
1317
|
+
return this.toggleHints(), true;
|
|
1318
|
+
default:
|
|
1319
|
+
return false;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
arrowPolicy(e, t) {
|
|
1323
|
+
if (t !== "keyboard")
|
|
1324
|
+
return "spatial";
|
|
1325
|
+
const a2 = this.state.preferences.arrowNavigation;
|
|
1326
|
+
return a2 !== "auto" ? a2 : An(e) ?? "native";
|
|
1327
|
+
}
|
|
1328
|
+
/* ── Gamepad ─────────────────────────────────────────────────── */
|
|
1329
|
+
padMap(e) {
|
|
1330
|
+
let t = this.padMaps.get(e);
|
|
1331
|
+
return t || (t = kn(ke(this.state.preferences, e)), this.padMaps.set(e, t)), t;
|
|
1332
|
+
}
|
|
1333
|
+
/** A pad intent: the intent event, then engage rules, key emulation and the default action. */
|
|
1334
|
+
deviceIntent(e) {
|
|
1335
|
+
const t = this.focused();
|
|
1336
|
+
if (this.dispatchIntent(e, t))
|
|
1337
|
+
return;
|
|
1338
|
+
const a2 = t === this.doc.body ? null : me(t), r = a2 !== null && kt(t, a2), s = t, o = e.source;
|
|
1339
|
+
switch (e.intent) {
|
|
1340
|
+
case "navigate": {
|
|
1341
|
+
const i2 = e.direction ?? "down";
|
|
1342
|
+
a2 && !r ? this.moveFocus(i2, t) : r && ce(t) ? le(t, i2) : r && a2 === "text" ? Xt(t, i2) : this.emulateKey(t, _n[i2], o) || this.moveFocus(i2, t);
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
case "activate":
|
|
1346
|
+
a2 && !r ? this.engage(s, o, a2) : r && a2 === "popup" ? this.emulateKey(t, "Enter", o) : r && (a2 === "value" || a2 === "canvas") ? this.release(s, o, false) : r || (wt(t) ? $t(t) : this.emulateKey(t, "Enter", o));
|
|
1347
|
+
return;
|
|
1348
|
+
case "back":
|
|
1349
|
+
r && a2 === "popup" ? this.emulateKey(t, "Escape", o) : r ? this.release(s, o, true) : this.emulateKey(t, "Escape", o) || this.closeTopOverlay(o);
|
|
1350
|
+
return;
|
|
1351
|
+
case "sectionPrev":
|
|
1352
|
+
case "sectionNext":
|
|
1353
|
+
if (r && a2 === "value") {
|
|
1354
|
+
const i2 = e.intent === "sectionNext";
|
|
1355
|
+
ce(t) ? le(t, i2 ? "up" : "down", "big") : this.emulateKey(t, i2 ? "PageUp" : "PageDown", o);
|
|
1356
|
+
}
|
|
1357
|
+
return;
|
|
1358
|
+
case "pagePrev":
|
|
1359
|
+
case "pageNext": {
|
|
1360
|
+
const i2 = e.intent === "pageNext";
|
|
1361
|
+
if (r && a2 === "value")
|
|
1362
|
+
ce(t) ? le(t, i2 ? "up" : "down", "edge") : this.emulateKey(t, i2 ? "End" : "Home", o);
|
|
1363
|
+
else if (!this.emulateKey(t, i2 ? "PageDown" : "PageUp", o)) {
|
|
1364
|
+
const c2 = st(t, 0, i2 ? 1 : -1);
|
|
1365
|
+
rt(c2, 0, (i2 ? 1 : -1) * ((c2 == null ? void 0 : c2.clientHeight) ?? 0) * 0.9);
|
|
1366
|
+
}
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
case "first":
|
|
1370
|
+
case "last":
|
|
1371
|
+
this.emulateKey(t, e.intent === "first" ? "Home" : "End", o);
|
|
1372
|
+
return;
|
|
1373
|
+
case "secondary":
|
|
1374
|
+
this.contextMenu(t);
|
|
1375
|
+
return;
|
|
1376
|
+
case "menu":
|
|
1377
|
+
r && a2 === "text" && (this.release(s, o, false), this.emulateKey(t, "Enter", o));
|
|
1378
|
+
return;
|
|
1379
|
+
case "view":
|
|
1380
|
+
this.focusRegion(e.direction ?? "down", t);
|
|
1381
|
+
return;
|
|
1382
|
+
case "toggleHints":
|
|
1383
|
+
this.toggleHints();
|
|
1384
|
+
return;
|
|
1385
|
+
default:
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
/** A synthetic key on the element; returns whether a handler consumed it. */
|
|
1390
|
+
emulateKey(e, t, a2) {
|
|
1391
|
+
const r = (o) => {
|
|
1392
|
+
const i2 = new KeyboardEvent(o, {
|
|
1393
|
+
key: t,
|
|
1394
|
+
code: t,
|
|
1395
|
+
bubbles: true,
|
|
1396
|
+
cancelable: true,
|
|
1397
|
+
composed: true
|
|
1398
|
+
});
|
|
1399
|
+
return Object.defineProperty(i2, "niceSource", { value: a2 }), Object.defineProperty(i2, "keyCode", { value: et[t] ?? 0 }), Object.defineProperty(i2, "which", { value: et[t] ?? 0 }), i2;
|
|
1400
|
+
}, s = r("keydown");
|
|
1401
|
+
return e.dispatchEvent(s), e.dispatchEvent(r("keyup")), s.defaultPrevented;
|
|
1402
|
+
}
|
|
1403
|
+
/** `secondary` on a pad: the context menu of the element, as a right click would open it. */
|
|
1404
|
+
contextMenu(e) {
|
|
1405
|
+
const t = e.getBoundingClientRect();
|
|
1406
|
+
e.dispatchEvent(
|
|
1407
|
+
new MouseEvent("contextmenu", {
|
|
1408
|
+
bubbles: true,
|
|
1409
|
+
cancelable: true,
|
|
1410
|
+
button: 2,
|
|
1411
|
+
clientX: t.left + t.width / 2,
|
|
1412
|
+
clientY: t.top + t.height / 2
|
|
1413
|
+
})
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
watchRecovery(e) {
|
|
1417
|
+
e && !this.observer && typeof MutationObserver < "u" && this.doc.body ? (this.observer = new MutationObserver(this.recover), this.observer.observe(this.doc.body, { childList: true, subtree: true })) : !e && this.observer && (this.observer.disconnect(), this.observer = null);
|
|
1418
|
+
}
|
|
1419
|
+
/* ── Helpers ─────────────────────────────────────────────────── */
|
|
1420
|
+
focused() {
|
|
1421
|
+
const e = this.doc.activeElement;
|
|
1422
|
+
return e && e !== this.doc.documentElement ? e : this.doc.body;
|
|
1423
|
+
}
|
|
1424
|
+
targetOf(e) {
|
|
1425
|
+
var a2;
|
|
1426
|
+
const t = (a2 = e.composedPath) == null ? void 0 : a2.call(e)[0];
|
|
1427
|
+
return t instanceof Element ? t : e.target instanceof Element ? e.target : this.focused();
|
|
1428
|
+
}
|
|
1429
|
+
/** Moves stay inside the top modal overlay. */
|
|
1430
|
+
navigationRoot() {
|
|
1431
|
+
for (let e = this.overlays.length - 1; e >= 0; e--)
|
|
1432
|
+
if (this.overlays[e].modal && this.overlays[e].element.isConnected)
|
|
1433
|
+
return this.overlays[e].element;
|
|
1434
|
+
return this.doc.body;
|
|
1435
|
+
}
|
|
1436
|
+
/** Nothing focused yet: the remembered element, else the first one of the main region. */
|
|
1437
|
+
focusInitial(e) {
|
|
1438
|
+
const t = this.memory.get(e), a2 = e.querySelector('main,[role="main"]'), r = (t && t.isConnected && e.contains(t) && ne(t) ? t : null) ?? (a2 ? U(a2)[0] : void 0) ?? U(e)[0];
|
|
1439
|
+
return r ? (this.focusElement(r), true) : false;
|
|
1440
|
+
}
|
|
1441
|
+
fireEngage(e, t) {
|
|
1442
|
+
e.dispatchEvent(new CustomEvent(ae, { detail: t, bubbles: true }));
|
|
1443
|
+
}
|
|
1444
|
+
/** Polite announcement through the engine's own live region. */
|
|
1445
|
+
announce(e) {
|
|
1446
|
+
if (!this.live || !this.live.isConnected) {
|
|
1447
|
+
const t = this.doc.createElement("div");
|
|
1448
|
+
t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("data-nice-input-live", ""), t.style.cssText = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", this.doc.body.appendChild(t), this.live = t;
|
|
1449
|
+
}
|
|
1450
|
+
this.live.textContent = e;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
function rt(n, e, t) {
|
|
1454
|
+
n && (typeof n.scrollBy == "function" ? n.scrollBy({ left: e, top: t }) : (n.scrollLeft += e, n.scrollTop += t));
|
|
1455
|
+
}
|
|
1456
|
+
function st(n, e, t) {
|
|
1457
|
+
const a2 = n.ownerDocument, r = a2.defaultView;
|
|
1458
|
+
for (let s = n; s && s !== a2.body; s = s.parentElement) {
|
|
1459
|
+
if (!(s instanceof HTMLElement) || !r)
|
|
1460
|
+
continue;
|
|
1461
|
+
const o = r.getComputedStyle(s), i2 = /(auto|scroll)/.test(o.overflowY) && s.scrollHeight > s.clientHeight, c2 = /(auto|scroll)/.test(o.overflowX) && s.scrollWidth > s.clientWidth;
|
|
1462
|
+
if (t !== 0 && i2 || e !== 0 && c2)
|
|
1463
|
+
return s;
|
|
1464
|
+
}
|
|
1465
|
+
return a2.scrollingElement ?? a2.documentElement;
|
|
1466
|
+
}
|
|
1467
|
+
const ot = /* @__PURE__ */ new WeakMap();
|
|
1468
|
+
function jn(n = window, e = true) {
|
|
1469
|
+
let t = ot.get(n);
|
|
1470
|
+
return t || (t = new Kn(n), ot.set(n, t)), e && t.start(), t;
|
|
1471
|
+
}
|
|
1472
|
+
function B() {
|
|
1473
|
+
const [n] = $e$1.useState(
|
|
1474
|
+
() => typeof window > "u" ? null : jn(window, false)
|
|
1475
|
+
);
|
|
1476
|
+
return $e$1.useEffect(() => {
|
|
1477
|
+
n == null || n.start();
|
|
1478
|
+
}, [n]), n;
|
|
1479
|
+
}
|
|
1480
|
+
const da = '[role="row"],tr', ha = '[role="gridcell"],[role="columnheader"],[role="rowheader"],td,th', fa = 'button:not([disabled]),a[href],input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled])', pa = 'textarea,select,input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"])';
|
|
1481
|
+
function Xa(n, e = {}) {
|
|
1482
|
+
const { rowSelector: t = da, cellSelector: a2 = ha, pageSize: r = 10, enabled: s = true } = e, o = $e$1.useRef(e);
|
|
1483
|
+
o.current = e;
|
|
1484
|
+
const i2 = B();
|
|
1485
|
+
_(
|
|
1486
|
+
n,
|
|
1487
|
+
(c2) => {
|
|
1488
|
+
if (!s)
|
|
1489
|
+
return;
|
|
1490
|
+
const d = c2.ownerDocument, u = (g) => {
|
|
1491
|
+
var S;
|
|
1492
|
+
return !!g && g.matches(t) && ((S = g.parentElement) == null ? void 0 : S.closest('[role="grid"],[role="treegrid"]')) === c2;
|
|
1493
|
+
}, p = () => [...c2.querySelectorAll(t)].filter(u), l = (g) => [...g.children].filter((S) => S.matches(a2)), v2 = (g) => {
|
|
1494
|
+
const S = g.querySelectorAll(fa);
|
|
1495
|
+
return S.length === 1 ? S[0] : g;
|
|
1496
|
+
}, y = () => p().flatMap((g) => l(g).map(v2)), k = (g) => {
|
|
1497
|
+
const S = (g == null ? void 0 : g.closest(a2)) ?? null;
|
|
1498
|
+
return S && u(S.parentElement) ? S : null;
|
|
1499
|
+
}, E = () => {
|
|
1500
|
+
const g = y();
|
|
1501
|
+
if (g.length === 0)
|
|
1502
|
+
return;
|
|
1503
|
+
const S = d.activeElement, N = g.find((w) => w === S || w.contains(S)) ?? g.find((w) => w.getAttribute("tabindex") === "0") ?? g[0];
|
|
1504
|
+
for (const w of g) {
|
|
1505
|
+
const b = w === N ? "0" : "-1";
|
|
1506
|
+
w.getAttribute("tabindex") !== b && w.setAttribute("tabindex", b);
|
|
1507
|
+
}
|
|
1508
|
+
}, H = (g, S, N) => {
|
|
1509
|
+
var b, T;
|
|
1510
|
+
const w = v2(g);
|
|
1511
|
+
for (const f of y())
|
|
1512
|
+
f.setAttribute("tabindex", f === w ? "0" : "-1");
|
|
1513
|
+
i2 ? i2.focusElement(w) : w.focus(), (T = (b = o.current).onMove) == null || T.call(b, g, S, N);
|
|
1514
|
+
}, x = (g) => {
|
|
1515
|
+
var D;
|
|
1516
|
+
if (g.defaultPrevented || g.altKey || g.metaKey)
|
|
1517
|
+
return;
|
|
1518
|
+
const S = g.target, N = k(S);
|
|
1519
|
+
if (!N || v2(N) !== S || S !== N && S.matches(pa))
|
|
1520
|
+
return;
|
|
1521
|
+
const w = p(), b = w.indexOf(N.parentElement), T = l(w[b]).indexOf(N), f = (L, P) => {
|
|
1522
|
+
const I = w[L] ? l(w[L]) : [];
|
|
1523
|
+
if (I.length === 0)
|
|
1524
|
+
return null;
|
|
1525
|
+
const $ = Math.min(P, I.length - 1);
|
|
1526
|
+
return [I[$], L, $];
|
|
1527
|
+
};
|
|
1528
|
+
let h = null;
|
|
1529
|
+
const A = ((D = d.defaultView) == null ? void 0 : D.getComputedStyle(c2).direction) === "rtl", m = A && g.key === "ArrowLeft" ? "ArrowRight" : A && g.key === "ArrowRight" ? "ArrowLeft" : g.key;
|
|
1530
|
+
if (g.ctrlKey && (m === "Home" || m === "End"))
|
|
1531
|
+
h = m === "Home" ? f(0, 0) : f(w.length - 1, Number.MAX_SAFE_INTEGER);
|
|
1532
|
+
else {
|
|
1533
|
+
if (g.ctrlKey)
|
|
1534
|
+
return;
|
|
1535
|
+
if (m === "ArrowRight")
|
|
1536
|
+
h = T + 1 < l(w[b]).length ? f(b, T + 1) : null;
|
|
1537
|
+
else if (m === "ArrowLeft")
|
|
1538
|
+
h = T > 0 ? f(b, T - 1) : null;
|
|
1539
|
+
else if (m === "ArrowDown")
|
|
1540
|
+
h = b + 1 < w.length ? f(b + 1, T) : null;
|
|
1541
|
+
else if (m === "ArrowUp")
|
|
1542
|
+
h = b > 0 ? f(b - 1, T) : null;
|
|
1543
|
+
else if (m === "Home")
|
|
1544
|
+
h = f(b, 0);
|
|
1545
|
+
else if (m === "End")
|
|
1546
|
+
h = f(b, Number.MAX_SAFE_INTEGER);
|
|
1547
|
+
else if (m === "PageDown" || m === "PageUp") {
|
|
1548
|
+
const L = m === "PageDown" ? Math.min(w.length - 1, b + r) : Math.max(0, b - r);
|
|
1549
|
+
h = L !== b ? f(L, T) : null;
|
|
1550
|
+
} else if ((m === "Enter" || m === " ") && S === N && !N.matches("button,a[href]")) {
|
|
1551
|
+
g.preventDefault(), N.click();
|
|
1552
|
+
return;
|
|
1553
|
+
} else
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1556
|
+
h && h[0] !== N && (g.preventDefault(), H(...h));
|
|
1557
|
+
}, M = () => E();
|
|
1558
|
+
E(), c2.addEventListener("keydown", x), c2.addEventListener("focusin", M);
|
|
1559
|
+
const z = typeof MutationObserver > "u" ? null : new MutationObserver(() => E());
|
|
1560
|
+
return z == null || z.observe(c2, {
|
|
1561
|
+
childList: true,
|
|
1562
|
+
subtree: true,
|
|
1563
|
+
attributes: true,
|
|
1564
|
+
attributeFilter: ["disabled"]
|
|
1565
|
+
}), () => {
|
|
1566
|
+
c2.removeEventListener("keydown", x), c2.removeEventListener("focusin", M), z == null || z.disconnect();
|
|
1567
|
+
};
|
|
1568
|
+
},
|
|
1569
|
+
[s, t, a2, r, i2]
|
|
1570
|
+
);
|
|
1571
|
+
}
|
|
299
1572
|
process.env.NODE_ENV !== "production" && "NiceRTLProvider";
|
|
300
1573
|
process.env.NODE_ENV !== "production" && "NiceAccessControl";
|
|
301
1574
|
process.env.NODE_ENV !== "production" && "NiceA11yProvider";
|
|
@@ -342,15 +1615,15 @@ const NiceCapacityPlanner = ({
|
|
|
342
1615
|
var _a, _b;
|
|
343
1616
|
const { t } = v();
|
|
344
1617
|
const config = { ...DEFAULT_VIEW_CONFIG$1, ...externalConfig };
|
|
345
|
-
const [selectedAllocation, setSelectedAllocation] =
|
|
346
|
-
const [hoveredCell, setHoveredCell] =
|
|
347
|
-
const [timeUnit, setTimeUnit] =
|
|
348
|
-
const [expandedResources, setExpandedResources] =
|
|
1618
|
+
const [selectedAllocation, setSelectedAllocation] = $e$1.useState(null);
|
|
1619
|
+
const [hoveredCell, setHoveredCell] = $e$1.useState(null);
|
|
1620
|
+
const [timeUnit, setTimeUnit] = $e$1.useState(config.timeUnit);
|
|
1621
|
+
const [expandedResources, setExpandedResources] = $e$1.useState(
|
|
349
1622
|
new Set(resources.map((r) => r.id))
|
|
350
1623
|
);
|
|
351
|
-
const [showAllocationModal, setShowAllocationModal] =
|
|
352
|
-
const [newAllocation, setNewAllocation] =
|
|
353
|
-
const timePeriods =
|
|
1624
|
+
const [showAllocationModal, setShowAllocationModal] = $e$1.useState(false);
|
|
1625
|
+
const [newAllocation, setNewAllocation] = $e$1.useState({});
|
|
1626
|
+
const timePeriods = $e$1.useMemo(() => {
|
|
354
1627
|
const periods = [];
|
|
355
1628
|
const increment = TIME_INCREMENTS[timeUnit];
|
|
356
1629
|
let current = new Date(dateRange.start);
|
|
@@ -360,7 +1633,7 @@ const NiceCapacityPlanner = ({
|
|
|
360
1633
|
}
|
|
361
1634
|
return periods;
|
|
362
1635
|
}, [dateRange.start, dateRange.end, timeUnit]);
|
|
363
|
-
const utilizationMap =
|
|
1636
|
+
const utilizationMap = $e$1.useMemo(() => {
|
|
364
1637
|
const map = /* @__PURE__ */ new Map();
|
|
365
1638
|
resources.forEach((resource) => {
|
|
366
1639
|
const resourceMap = /* @__PURE__ */ new Map();
|
|
@@ -391,7 +1664,7 @@ const NiceCapacityPlanner = ({
|
|
|
391
1664
|
});
|
|
392
1665
|
return map;
|
|
393
1666
|
}, [resources, allocations, timePeriods, timeUnit]);
|
|
394
|
-
const conflicts =
|
|
1667
|
+
const conflicts = $e$1.useMemo(() => {
|
|
395
1668
|
const conflictList = [];
|
|
396
1669
|
utilizationMap.forEach((resourceMap, resourceId) => {
|
|
397
1670
|
const resource = resources.find((r) => r.id === resourceId);
|
|
@@ -419,7 +1692,7 @@ const NiceCapacityPlanner = ({
|
|
|
419
1692
|
});
|
|
420
1693
|
return conflictList;
|
|
421
1694
|
}, [utilizationMap, allocations, resources, timeUnit]);
|
|
422
|
-
const getCellAllocations =
|
|
1695
|
+
const getCellAllocations = $e$1.useCallback(
|
|
423
1696
|
(resourceId, date) => {
|
|
424
1697
|
const periodStart = date.getTime();
|
|
425
1698
|
const periodEnd = periodStart + TIME_INCREMENTS[timeUnit];
|
|
@@ -540,7 +1813,7 @@ const NiceCapacityPlanner = ({
|
|
|
540
1813
|
unit
|
|
541
1814
|
)) }) }),
|
|
542
1815
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-resource-allocation__toolbar-right", children: config.showConflicts && conflicts.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-resource-allocation__conflicts-badge", children: [
|
|
543
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__badge-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1816
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__badge-icon", children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "warning", size: 14 }) }),
|
|
544
1817
|
(conflicts.length === 1 ? t("capacityPlanner.oneConflict", "1 Conflict") : t("capacityPlanner.conflicts", "{count} Conflicts")).replace("{count}", String(conflicts.length))
|
|
545
1818
|
] }) })
|
|
546
1819
|
] }),
|
|
@@ -588,6 +1861,9 @@ const NiceCapacityPlanner = ({
|
|
|
588
1861
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
589
1862
|
"div",
|
|
590
1863
|
{
|
|
1864
|
+
role: onResourceClick ? "button" : void 0,
|
|
1865
|
+
tabIndex: onResourceClick ? 0 : void 0,
|
|
1866
|
+
onKeyDown: onResourceClick ? Et : void 0,
|
|
591
1867
|
className: "nice-resource-allocation__resource-cell",
|
|
592
1868
|
onClick: () => onResourceClick == null ? void 0 : onResourceClick(resource),
|
|
593
1869
|
children: [
|
|
@@ -600,7 +1876,7 @@ const NiceCapacityPlanner = ({
|
|
|
600
1876
|
toggleResource(resource.id);
|
|
601
1877
|
},
|
|
602
1878
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
603
|
-
|
|
1879
|
+
te,
|
|
604
1880
|
{
|
|
605
1881
|
name: expandedResources.has(resource.id) ? "chevron-down" : "chevron-right",
|
|
606
1882
|
size: 14
|
|
@@ -608,7 +1884,7 @@ const NiceCapacityPlanner = ({
|
|
|
608
1884
|
)
|
|
609
1885
|
}
|
|
610
1886
|
),
|
|
611
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__resource-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1887
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__resource-icon", children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: getResourceTypeIcon(resource.type), size: 16 }) }),
|
|
612
1888
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-resource-allocation__resource-info", children: [
|
|
613
1889
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__resource-name", children: resource.name }),
|
|
614
1890
|
resource.department && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__resource-dept", children: resource.department })
|
|
@@ -628,6 +1904,10 @@ const NiceCapacityPlanner = ({
|
|
|
628
1904
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
629
1905
|
"div",
|
|
630
1906
|
{
|
|
1907
|
+
role: readOnly ? void 0 : "button",
|
|
1908
|
+
tabIndex: readOnly ? void 0 : 0,
|
|
1909
|
+
"aria-label": readOnly ? void 0 : `${resource.name} ${formatDate(period)}`,
|
|
1910
|
+
onKeyDown: readOnly ? void 0 : Et,
|
|
631
1911
|
className: `nice-resource-allocation__time-cell ${isHovered ? "nice-resource-allocation__time-cell--hovered" : ""}`,
|
|
632
1912
|
style: { backgroundColor: getCellColor(resource.id, period) },
|
|
633
1913
|
onClick: () => handleCellClick(resource.id, period),
|
|
@@ -638,6 +1918,7 @@ const NiceCapacityPlanner = ({
|
|
|
638
1918
|
cellAllocations.slice(0, 2).map((alloc) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
639
1919
|
"div",
|
|
640
1920
|
{
|
|
1921
|
+
role: "presentation",
|
|
641
1922
|
className: `nice-resource-allocation__allocation-dot nice-resource-allocation__allocation-dot--${alloc.status}`,
|
|
642
1923
|
onClick: (e) => {
|
|
643
1924
|
e.stopPropagation();
|
|
@@ -676,6 +1957,9 @@ const NiceCapacityPlanner = ({
|
|
|
676
1957
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
677
1958
|
"div",
|
|
678
1959
|
{
|
|
1960
|
+
role: "button",
|
|
1961
|
+
tabIndex: 0,
|
|
1962
|
+
onKeyDown: Et,
|
|
679
1963
|
className: `nice-resource-allocation__allocation-bar nice-resource-allocation__allocation-bar--${allocation.status} ${selectedAllocation === allocation.id ? "nice-resource-allocation__allocation-bar--selected" : ""}`,
|
|
680
1964
|
style: {
|
|
681
1965
|
left: `${leftPercent}%`,
|
|
@@ -696,7 +1980,7 @@ const NiceCapacityPlanner = ({
|
|
|
696
1980
|
e.stopPropagation();
|
|
697
1981
|
onAllocationDelete == null ? void 0 : onAllocationDelete(allocation.id);
|
|
698
1982
|
},
|
|
699
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1983
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "close", size: 14 })
|
|
700
1984
|
}
|
|
701
1985
|
)
|
|
702
1986
|
]
|
|
@@ -709,11 +1993,13 @@ const NiceCapacityPlanner = ({
|
|
|
709
1993
|
showAllocationModal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
710
1994
|
"div",
|
|
711
1995
|
{
|
|
1996
|
+
role: "presentation",
|
|
712
1997
|
className: "nice-resource-allocation__modal-overlay",
|
|
713
1998
|
onClick: () => setShowAllocationModal(false),
|
|
714
1999
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
715
2000
|
"div",
|
|
716
2001
|
{
|
|
2002
|
+
role: "presentation",
|
|
717
2003
|
className: "nice-resource-allocation__allocation-modal",
|
|
718
2004
|
onClick: (e) => e.stopPropagation(),
|
|
719
2005
|
children: [
|
|
@@ -851,21 +2137,21 @@ const NiceInventoryManager = ({
|
|
|
851
2137
|
var _a, _b;
|
|
852
2138
|
const { t } = v();
|
|
853
2139
|
const config = { ...DEFAULT_VIEW_CONFIG, ...externalConfig };
|
|
854
|
-
const [filters, setFilters] =
|
|
855
|
-
const [view, setView] =
|
|
856
|
-
const [sortBy, setSortBy] =
|
|
857
|
-
const [sortOrder, setSortOrder] =
|
|
858
|
-
const [page, setPage] =
|
|
859
|
-
const [selectedItems, setSelectedItems] =
|
|
860
|
-
const [showItemModal, setShowItemModal] =
|
|
861
|
-
const [showTransactionModal, setShowTransactionModal] =
|
|
862
|
-
const [editingItem, setEditingItem] =
|
|
863
|
-
const [newTransaction, setNewTransaction] =
|
|
864
|
-
const [activeTab, setActiveTab] =
|
|
865
|
-
const categories =
|
|
2140
|
+
const [filters, setFilters] = $e$1.useState({});
|
|
2141
|
+
const [view, setView] = $e$1.useState(config.view);
|
|
2142
|
+
const [sortBy, setSortBy] = $e$1.useState(config.sortBy);
|
|
2143
|
+
const [sortOrder, setSortOrder] = $e$1.useState(config.sortOrder);
|
|
2144
|
+
const [page, setPage] = $e$1.useState(1);
|
|
2145
|
+
const [selectedItems, setSelectedItems] = $e$1.useState(/* @__PURE__ */ new Set());
|
|
2146
|
+
const [showItemModal, setShowItemModal] = $e$1.useState(false);
|
|
2147
|
+
const [showTransactionModal, setShowTransactionModal] = $e$1.useState(false);
|
|
2148
|
+
const [editingItem, setEditingItem] = $e$1.useState(null);
|
|
2149
|
+
const [newTransaction, setNewTransaction] = $e$1.useState({});
|
|
2150
|
+
const [activeTab, setActiveTab] = $e$1.useState("inventory");
|
|
2151
|
+
const categories = $e$1.useMemo(() => {
|
|
866
2152
|
return Array.from(new Set(items.map((item) => item.category))).sort();
|
|
867
2153
|
}, [items]);
|
|
868
|
-
const filteredItems =
|
|
2154
|
+
const filteredItems = $e$1.useMemo(() => {
|
|
869
2155
|
var _a2, _b2;
|
|
870
2156
|
let result = [...items];
|
|
871
2157
|
if (filters.searchQuery) {
|
|
@@ -910,18 +2196,18 @@ const NiceInventoryManager = ({
|
|
|
910
2196
|
});
|
|
911
2197
|
return result;
|
|
912
2198
|
}, [items, filters, sortBy, sortOrder]);
|
|
913
|
-
const paginatedItems =
|
|
2199
|
+
const paginatedItems = $e$1.useMemo(() => {
|
|
914
2200
|
const start = (page - 1) * config.pageSize;
|
|
915
2201
|
return filteredItems.slice(start, start + config.pageSize);
|
|
916
2202
|
}, [filteredItems, page, config.pageSize]);
|
|
917
2203
|
const totalPages = Math.ceil(filteredItems.length / config.pageSize);
|
|
918
|
-
const reorderItems =
|
|
2204
|
+
const reorderItems = $e$1.useMemo(() => {
|
|
919
2205
|
return items.filter((item) => item.quantity <= item.reorderLevel);
|
|
920
2206
|
}, [items]);
|
|
921
|
-
const recentTransactions =
|
|
2207
|
+
const recentTransactions = $e$1.useMemo(() => {
|
|
922
2208
|
return [...transactions].sort((a2, b) => b.date.getTime() - a2.date.getTime()).slice(0, 50);
|
|
923
2209
|
}, [transactions]);
|
|
924
|
-
const kanbanGroups =
|
|
2210
|
+
const kanbanGroups = $e$1.useMemo(() => {
|
|
925
2211
|
if (view !== "kanban") {
|
|
926
2212
|
return null;
|
|
927
2213
|
}
|
|
@@ -1029,7 +2315,7 @@ const NiceInventoryManager = ({
|
|
|
1029
2315
|
onChange: (e) => setFilters((prev) => ({ ...prev, searchQuery: e.target.value }))
|
|
1030
2316
|
}
|
|
1031
2317
|
),
|
|
1032
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__search-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2318
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__search-icon", children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "search", size: 14 }) })
|
|
1033
2319
|
] }),
|
|
1034
2320
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1035
2321
|
"select",
|
|
@@ -1064,7 +2350,7 @@ const NiceInventoryManager = ({
|
|
|
1064
2350
|
className: `nice-inventory-manager__view-button ${view === v2 ? "nice-inventory-manager__view-button--active" : ""}`,
|
|
1065
2351
|
onClick: () => setView(v2),
|
|
1066
2352
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1067
|
-
|
|
2353
|
+
te,
|
|
1068
2354
|
{
|
|
1069
2355
|
name: v2 === "grid" ? "grid" : v2 === "list" ? "list" : "table",
|
|
1070
2356
|
size: 14
|
|
@@ -1136,6 +2422,9 @@ const NiceInventoryManager = ({
|
|
|
1136
2422
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1137
2423
|
"div",
|
|
1138
2424
|
{
|
|
2425
|
+
role: onItemClick ? "button" : void 0,
|
|
2426
|
+
tabIndex: onItemClick ? 0 : void 0,
|
|
2427
|
+
onKeyDown: onItemClick ? Et : void 0,
|
|
1139
2428
|
className: `nice-inventory-manager__item-card ${selectedItems.has(item.id) ? "nice-inventory-manager__item-card--selected" : ""}`,
|
|
1140
2429
|
onClick: () => onItemClick == null ? void 0 : onItemClick(item),
|
|
1141
2430
|
children: [
|
|
@@ -1149,7 +2438,7 @@ const NiceInventoryManager = ({
|
|
|
1149
2438
|
onClick: (e) => e.stopPropagation()
|
|
1150
2439
|
}
|
|
1151
2440
|
),
|
|
1152
|
-
config.showImages && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-inventory-manager__item-image", children: ((_a2 = item.images) == null ? void 0 : _a2[0]) ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: item.images[0], alt: item.name }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__placeholder-image", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2441
|
+
config.showImages && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-inventory-manager__item-image", children: ((_a2 = item.images) == null ? void 0 : _a2[0]) ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: item.images[0], alt: item.name }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__placeholder-image", children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "box", size: 32 }) }) }),
|
|
1153
2442
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__item-info", children: [
|
|
1154
2443
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__item-sku", children: item.sku }),
|
|
1155
2444
|
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "nice-inventory-manager__item-name", children: item.name }),
|
|
@@ -1170,7 +2459,7 @@ const NiceInventoryManager = ({
|
|
|
1170
2459
|
item.unit
|
|
1171
2460
|
] }),
|
|
1172
2461
|
item.quantity <= item.reorderLevel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "nice-inventory-manager__reorder-alert", children: [
|
|
1173
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2462
|
+
/* @__PURE__ */ jsxRuntime.jsx(te, { name: "warning", size: 12 }),
|
|
1174
2463
|
" ",
|
|
1175
2464
|
t("inventoryManager.lowStock", "Low Stock")
|
|
1176
2465
|
] })
|
|
@@ -1195,7 +2484,7 @@ const NiceInventoryManager = ({
|
|
|
1195
2484
|
t("inventoryManager.sku", "SKU"),
|
|
1196
2485
|
" ",
|
|
1197
2486
|
sortBy === "sku" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1198
|
-
|
|
2487
|
+
te,
|
|
1199
2488
|
{
|
|
1200
2489
|
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
1201
2490
|
size: 12
|
|
@@ -1215,7 +2504,7 @@ const NiceInventoryManager = ({
|
|
|
1215
2504
|
t("inventoryManager.name", "Name"),
|
|
1216
2505
|
" ",
|
|
1217
2506
|
sortBy === "name" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1218
|
-
|
|
2507
|
+
te,
|
|
1219
2508
|
{
|
|
1220
2509
|
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
1221
2510
|
size: 12
|
|
@@ -1236,7 +2525,7 @@ const NiceInventoryManager = ({
|
|
|
1236
2525
|
t("inventoryManager.qty", "Qty"),
|
|
1237
2526
|
" ",
|
|
1238
2527
|
sortBy === "quantity" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1239
|
-
|
|
2528
|
+
te,
|
|
1240
2529
|
{
|
|
1241
2530
|
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
1242
2531
|
size: 12
|
|
@@ -1258,7 +2547,7 @@ const NiceInventoryManager = ({
|
|
|
1258
2547
|
t("inventoryManager.value", "Value"),
|
|
1259
2548
|
" ",
|
|
1260
2549
|
sortBy === "value" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1261
|
-
|
|
2550
|
+
te,
|
|
1262
2551
|
{
|
|
1263
2552
|
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
1264
2553
|
size: 12
|
|
@@ -1321,7 +2610,7 @@ const NiceInventoryManager = ({
|
|
|
1321
2610
|
setEditingItem(item);
|
|
1322
2611
|
setShowItemModal(true);
|
|
1323
2612
|
},
|
|
1324
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2613
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "edit", size: 14 })
|
|
1325
2614
|
}
|
|
1326
2615
|
),
|
|
1327
2616
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1333,7 +2622,7 @@ const NiceInventoryManager = ({
|
|
|
1333
2622
|
setNewTransaction({ itemId: item.id });
|
|
1334
2623
|
setShowTransactionModal(true);
|
|
1335
2624
|
},
|
|
1336
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2625
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "clipboard", size: 14 })
|
|
1337
2626
|
}
|
|
1338
2627
|
),
|
|
1339
2628
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1344,7 +2633,7 @@ const NiceInventoryManager = ({
|
|
|
1344
2633
|
e.stopPropagation();
|
|
1345
2634
|
onItemDelete == null ? void 0 : onItemDelete(item.id);
|
|
1346
2635
|
},
|
|
1347
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2636
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "trash", size: 14 })
|
|
1348
2637
|
}
|
|
1349
2638
|
)
|
|
1350
2639
|
] })
|
|
@@ -1375,6 +2664,9 @@ const NiceInventoryManager = ({
|
|
|
1375
2664
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-inventory-manager__column-items", children: statusItems.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1376
2665
|
"div",
|
|
1377
2666
|
{
|
|
2667
|
+
role: onItemClick ? "button" : void 0,
|
|
2668
|
+
tabIndex: onItemClick ? 0 : void 0,
|
|
2669
|
+
onKeyDown: onItemClick ? Et : void 0,
|
|
1378
2670
|
className: "nice-inventory-manager__kanban-card",
|
|
1379
2671
|
onClick: () => onItemClick == null ? void 0 : onItemClick(item),
|
|
1380
2672
|
children: [
|
|
@@ -1408,7 +2700,7 @@ const NiceInventoryManager = ({
|
|
|
1408
2700
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-inventory-manager__transactions-list", children: recentTransactions.map((tx) => {
|
|
1409
2701
|
const item = items.find((i2) => i2.id === tx.itemId);
|
|
1410
2702
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__transaction-item", children: [
|
|
1411
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__tx-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2703
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__tx-icon", children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: getTransactionIcon(tx.type), size: 16 }) }),
|
|
1412
2704
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__tx-info", children: [
|
|
1413
2705
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__tx-type", children: tx.type }),
|
|
1414
2706
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__tx-item", children: (item == null ? void 0 : item.name) || tx.itemId })
|
|
@@ -1432,7 +2724,7 @@ const NiceInventoryManager = ({
|
|
|
1432
2724
|
}) })
|
|
1433
2725
|
] }),
|
|
1434
2726
|
activeTab === "reorder" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-inventory-manager__reorder-tab", children: reorderItems.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__empty-state", children: [
|
|
1435
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__empty-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2727
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__empty-icon", children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "success", size: 32 }) }),
|
|
1436
2728
|
/* @__PURE__ */ jsxRuntime.jsx("p", { children: t(
|
|
1437
2729
|
"inventoryManager.allItemsAreSufficientlyStocked",
|
|
1438
2730
|
"All items are sufficiently stocked"
|
|
@@ -1468,153 +2760,164 @@ const NiceInventoryManager = ({
|
|
|
1468
2760
|
showItemModal && editingItem && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1469
2761
|
"div",
|
|
1470
2762
|
{
|
|
2763
|
+
role: "presentation",
|
|
1471
2764
|
className: "nice-inventory-manager__modal-overlay",
|
|
1472
2765
|
onClick: () => setShowItemModal(false),
|
|
1473
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
2766
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2767
|
+
"div",
|
|
2768
|
+
{
|
|
2769
|
+
role: "presentation",
|
|
2770
|
+
className: "nice-inventory-manager__item-modal",
|
|
2771
|
+
onClick: (e) => e.stopPropagation(),
|
|
2772
|
+
children: [
|
|
2773
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { children: editingItem.id ? t("inventoryManager.editItem", "Edit Item") : t("inventoryManager.addNewItem", "Add New Item") }),
|
|
2774
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__modal-form", children: [
|
|
2775
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__form-row", children: [
|
|
2776
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2777
|
+
"SKU",
|
|
2778
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2779
|
+
"input",
|
|
2780
|
+
{
|
|
2781
|
+
type: "text",
|
|
2782
|
+
value: editingItem.sku || "",
|
|
2783
|
+
onChange: (e) => setEditingItem((prev) => ({ ...prev, sku: e.target.value }))
|
|
2784
|
+
}
|
|
2785
|
+
)
|
|
2786
|
+
] }),
|
|
2787
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2788
|
+
t("inventoryManager.name", "Name"),
|
|
2789
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2790
|
+
"input",
|
|
2791
|
+
{
|
|
2792
|
+
type: "text",
|
|
2793
|
+
value: editingItem.name || "",
|
|
2794
|
+
onChange: (e) => setEditingItem((prev) => ({ ...prev, name: e.target.value }))
|
|
2795
|
+
}
|
|
2796
|
+
)
|
|
2797
|
+
] })
|
|
2798
|
+
] }),
|
|
2799
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2800
|
+
t("inventoryManager.description", "Description"),
|
|
2801
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2802
|
+
"textarea",
|
|
2803
|
+
{
|
|
2804
|
+
value: editingItem.description || "",
|
|
2805
|
+
onChange: (e) => setEditingItem((prev) => ({ ...prev, description: e.target.value }))
|
|
2806
|
+
}
|
|
2807
|
+
)
|
|
2808
|
+
] }),
|
|
2809
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__form-row", children: [
|
|
2810
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2811
|
+
t("inventoryManager.category", "Category"),
|
|
2812
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2813
|
+
"input",
|
|
2814
|
+
{
|
|
2815
|
+
type: "text",
|
|
2816
|
+
value: editingItem.category || "",
|
|
2817
|
+
onChange: (e) => setEditingItem((prev) => ({ ...prev, category: e.target.value })),
|
|
2818
|
+
list: "categories"
|
|
2819
|
+
}
|
|
2820
|
+
),
|
|
2821
|
+
/* @__PURE__ */ jsxRuntime.jsx("datalist", { id: "categories", children: categories.map((c2) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: c2 }, c2)) })
|
|
2822
|
+
] }),
|
|
2823
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2824
|
+
t("inventoryManager.unit", "Unit"),
|
|
2825
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2826
|
+
"input",
|
|
2827
|
+
{
|
|
2828
|
+
type: "text",
|
|
2829
|
+
value: editingItem.unit || "",
|
|
2830
|
+
onChange: (e) => setEditingItem((prev) => ({ ...prev, unit: e.target.value }))
|
|
2831
|
+
}
|
|
2832
|
+
)
|
|
2833
|
+
] })
|
|
2834
|
+
] }),
|
|
2835
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__form-row", children: [
|
|
2836
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2837
|
+
t("inventoryManager.quantity", "Quantity"),
|
|
2838
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2839
|
+
"input",
|
|
2840
|
+
{
|
|
2841
|
+
type: "number",
|
|
2842
|
+
value: editingItem.quantity || 0,
|
|
2843
|
+
onChange: (e) => setEditingItem((prev) => ({ ...prev, quantity: parseInt(e.target.value) }))
|
|
2844
|
+
}
|
|
2845
|
+
)
|
|
2846
|
+
] }),
|
|
2847
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2848
|
+
t("inventoryManager.reorderLevel", "Reorder Level"),
|
|
2849
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2850
|
+
"input",
|
|
2851
|
+
{
|
|
2852
|
+
type: "number",
|
|
2853
|
+
value: editingItem.reorderLevel || 0,
|
|
2854
|
+
onChange: (e) => setEditingItem((prev) => ({
|
|
2855
|
+
...prev,
|
|
2856
|
+
reorderLevel: parseInt(e.target.value)
|
|
2857
|
+
}))
|
|
2858
|
+
}
|
|
2859
|
+
)
|
|
2860
|
+
] }),
|
|
2861
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2862
|
+
t("inventoryManager.reorderQty", "Reorder Qty"),
|
|
2863
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2864
|
+
"input",
|
|
2865
|
+
{
|
|
2866
|
+
type: "number",
|
|
2867
|
+
value: editingItem.reorderQuantity || 0,
|
|
2868
|
+
onChange: (e) => setEditingItem((prev) => ({
|
|
2869
|
+
...prev,
|
|
2870
|
+
reorderQuantity: parseInt(e.target.value)
|
|
2871
|
+
}))
|
|
2872
|
+
}
|
|
2873
|
+
)
|
|
2874
|
+
] })
|
|
2875
|
+
] }),
|
|
2876
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
2877
|
+
t("inventoryManager.unitCost", "Unit Cost"),
|
|
2878
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2879
|
+
"input",
|
|
2880
|
+
{
|
|
2881
|
+
type: "number",
|
|
2882
|
+
step: "0.01",
|
|
2883
|
+
value: ((_b = editingItem.cost) == null ? void 0 : _b.amount) || 0,
|
|
2884
|
+
onChange: (e) => setEditingItem((prev) => ({
|
|
2885
|
+
...prev,
|
|
2886
|
+
cost: {
|
|
2887
|
+
...prev.cost,
|
|
2888
|
+
amount: parseFloat(e.target.value)
|
|
2889
|
+
}
|
|
2890
|
+
}))
|
|
2891
|
+
}
|
|
2892
|
+
)
|
|
2893
|
+
] })
|
|
1487
2894
|
] }),
|
|
1488
|
-
/* @__PURE__ */ jsxRuntime.jsxs("
|
|
1489
|
-
t("inventoryManager.name", "Name"),
|
|
1490
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1491
|
-
"input",
|
|
1492
|
-
{
|
|
1493
|
-
type: "text",
|
|
1494
|
-
value: editingItem.name || "",
|
|
1495
|
-
onChange: (e) => setEditingItem((prev) => ({ ...prev, name: e.target.value }))
|
|
1496
|
-
}
|
|
1497
|
-
)
|
|
1498
|
-
] })
|
|
1499
|
-
] }),
|
|
1500
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1501
|
-
t("inventoryManager.description", "Description"),
|
|
1502
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1503
|
-
"textarea",
|
|
1504
|
-
{
|
|
1505
|
-
value: editingItem.description || "",
|
|
1506
|
-
onChange: (e) => setEditingItem((prev) => ({ ...prev, description: e.target.value }))
|
|
1507
|
-
}
|
|
1508
|
-
)
|
|
1509
|
-
] }),
|
|
1510
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__form-row", children: [
|
|
1511
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1512
|
-
t("inventoryManager.category", "Category"),
|
|
2895
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__modal-actions", children: [
|
|
1513
2896
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1514
|
-
"
|
|
2897
|
+
"button",
|
|
1515
2898
|
{
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
list: "categories"
|
|
2899
|
+
className: "nice-inventory-manager__cancel-button",
|
|
2900
|
+
onClick: () => setShowItemModal(false),
|
|
2901
|
+
children: t("inventoryManager.cancel", "Cancel")
|
|
1520
2902
|
}
|
|
1521
2903
|
),
|
|
1522
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
1523
|
-
] }),
|
|
1524
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1525
|
-
t("inventoryManager.unit", "Unit"),
|
|
1526
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1527
|
-
"input",
|
|
1528
|
-
{
|
|
1529
|
-
type: "text",
|
|
1530
|
-
value: editingItem.unit || "",
|
|
1531
|
-
onChange: (e) => setEditingItem((prev) => ({ ...prev, unit: e.target.value }))
|
|
1532
|
-
}
|
|
1533
|
-
)
|
|
2904
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "nice-inventory-manager__save-button", onClick: handleItemSubmit, children: editingItem.id ? t("inventoryManager.saveChanges", "Save Changes") : t("inventoryManager.createItem", "Create Item") })
|
|
1534
2905
|
] })
|
|
1535
|
-
]
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
t("inventoryManager.quantity", "Quantity"),
|
|
1539
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1540
|
-
"input",
|
|
1541
|
-
{
|
|
1542
|
-
type: "number",
|
|
1543
|
-
value: editingItem.quantity || 0,
|
|
1544
|
-
onChange: (e) => setEditingItem((prev) => ({ ...prev, quantity: parseInt(e.target.value) }))
|
|
1545
|
-
}
|
|
1546
|
-
)
|
|
1547
|
-
] }),
|
|
1548
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1549
|
-
t("inventoryManager.reorderLevel", "Reorder Level"),
|
|
1550
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1551
|
-
"input",
|
|
1552
|
-
{
|
|
1553
|
-
type: "number",
|
|
1554
|
-
value: editingItem.reorderLevel || 0,
|
|
1555
|
-
onChange: (e) => setEditingItem((prev) => ({
|
|
1556
|
-
...prev,
|
|
1557
|
-
reorderLevel: parseInt(e.target.value)
|
|
1558
|
-
}))
|
|
1559
|
-
}
|
|
1560
|
-
)
|
|
1561
|
-
] }),
|
|
1562
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1563
|
-
t("inventoryManager.reorderQty", "Reorder Qty"),
|
|
1564
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1565
|
-
"input",
|
|
1566
|
-
{
|
|
1567
|
-
type: "number",
|
|
1568
|
-
value: editingItem.reorderQuantity || 0,
|
|
1569
|
-
onChange: (e) => setEditingItem((prev) => ({
|
|
1570
|
-
...prev,
|
|
1571
|
-
reorderQuantity: parseInt(e.target.value)
|
|
1572
|
-
}))
|
|
1573
|
-
}
|
|
1574
|
-
)
|
|
1575
|
-
] })
|
|
1576
|
-
] }),
|
|
1577
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1578
|
-
t("inventoryManager.unitCost", "Unit Cost"),
|
|
1579
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1580
|
-
"input",
|
|
1581
|
-
{
|
|
1582
|
-
type: "number",
|
|
1583
|
-
step: "0.01",
|
|
1584
|
-
value: ((_b = editingItem.cost) == null ? void 0 : _b.amount) || 0,
|
|
1585
|
-
onChange: (e) => setEditingItem((prev) => ({
|
|
1586
|
-
...prev,
|
|
1587
|
-
cost: {
|
|
1588
|
-
...prev.cost,
|
|
1589
|
-
amount: parseFloat(e.target.value)
|
|
1590
|
-
}
|
|
1591
|
-
}))
|
|
1592
|
-
}
|
|
1593
|
-
)
|
|
1594
|
-
] })
|
|
1595
|
-
] }),
|
|
1596
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__modal-actions", children: [
|
|
1597
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1598
|
-
"button",
|
|
1599
|
-
{
|
|
1600
|
-
className: "nice-inventory-manager__cancel-button",
|
|
1601
|
-
onClick: () => setShowItemModal(false),
|
|
1602
|
-
children: t("inventoryManager.cancel", "Cancel")
|
|
1603
|
-
}
|
|
1604
|
-
),
|
|
1605
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "nice-inventory-manager__save-button", onClick: handleItemSubmit, children: editingItem.id ? t("inventoryManager.saveChanges", "Save Changes") : t("inventoryManager.createItem", "Create Item") })
|
|
1606
|
-
] })
|
|
1607
|
-
] })
|
|
2906
|
+
]
|
|
2907
|
+
}
|
|
2908
|
+
)
|
|
1608
2909
|
}
|
|
1609
2910
|
),
|
|
1610
2911
|
showTransactionModal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1611
2912
|
"div",
|
|
1612
2913
|
{
|
|
2914
|
+
role: "presentation",
|
|
1613
2915
|
className: "nice-inventory-manager__modal-overlay",
|
|
1614
2916
|
onClick: () => setShowTransactionModal(false),
|
|
1615
2917
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1616
2918
|
"div",
|
|
1617
2919
|
{
|
|
2920
|
+
role: "presentation",
|
|
1618
2921
|
className: "nice-inventory-manager__transaction-modal",
|
|
1619
2922
|
onClick: (e) => e.stopPropagation(),
|
|
1620
2923
|
children: [
|
|
@@ -1748,7 +3051,7 @@ function fmtDate$1(d, locale) {
|
|
|
1748
3051
|
const dt = d instanceof Date ? d : new Date(d);
|
|
1749
3052
|
return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(dt);
|
|
1750
3053
|
}
|
|
1751
|
-
const NiceInvoiceView = /* @__PURE__ */
|
|
3054
|
+
const NiceInvoiceView = /* @__PURE__ */ $e$1.forwardRef(
|
|
1752
3055
|
function NiceInvoiceView2({
|
|
1753
3056
|
invoice,
|
|
1754
3057
|
locale,
|
|
@@ -1786,7 +3089,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1786
3089
|
vatId: "VAT ID",
|
|
1787
3090
|
...labels
|
|
1788
3091
|
};
|
|
1789
|
-
const totals =
|
|
3092
|
+
const totals = $e$1.useMemo(() => {
|
|
1790
3093
|
let net = 0;
|
|
1791
3094
|
let vat = 0;
|
|
1792
3095
|
const byRate = /* @__PURE__ */ new Map();
|
|
@@ -1851,7 +3154,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1851
3154
|
onClick: () => onAction == null ? void 0 : onAction("download"),
|
|
1852
3155
|
"aria-label": t("invoiceView.download", "Download"),
|
|
1853
3156
|
title: t("invoiceView.download", "Download"),
|
|
1854
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3157
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "arrow-down", size: 12 })
|
|
1855
3158
|
}
|
|
1856
3159
|
),
|
|
1857
3160
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1861,7 +3164,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1861
3164
|
onClick: () => onAction == null ? void 0 : onAction("print"),
|
|
1862
3165
|
"aria-label": t("invoiceView.print", "Print"),
|
|
1863
3166
|
title: t("invoiceView.print", "Print"),
|
|
1864
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3167
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "printer", size: 14 })
|
|
1865
3168
|
}
|
|
1866
3169
|
),
|
|
1867
3170
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1871,7 +3174,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1871
3174
|
onClick: () => onAction == null ? void 0 : onAction("send"),
|
|
1872
3175
|
"aria-label": t("invoiceView.send", "Send"),
|
|
1873
3176
|
title: t("invoiceView.send", "Send"),
|
|
1874
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3177
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "mail", size: 14 })
|
|
1875
3178
|
}
|
|
1876
3179
|
)
|
|
1877
3180
|
] })
|
|
@@ -1998,7 +3301,7 @@ function colorFor(occ, colors) {
|
|
|
1998
3301
|
}
|
|
1999
3302
|
return colors.high;
|
|
2000
3303
|
}
|
|
2001
|
-
const NiceWarehouseView = /* @__PURE__ */
|
|
3304
|
+
const NiceWarehouseView = /* @__PURE__ */ $e$1.forwardRef(
|
|
2002
3305
|
function NiceWarehouseView2({
|
|
2003
3306
|
warehouseName,
|
|
2004
3307
|
cells = EMPTY_CELLS,
|
|
@@ -2016,8 +3319,8 @@ const NiceWarehouseView = /* @__PURE__ */ ve.forwardRef(
|
|
|
2016
3319
|
id
|
|
2017
3320
|
}, ref) {
|
|
2018
3321
|
const { t } = v();
|
|
2019
|
-
const [hovered, setHovered] =
|
|
2020
|
-
const grid =
|
|
3322
|
+
const [hovered, setHovered] = $e$1.useState(null);
|
|
3323
|
+
const grid = $e$1.useMemo(() => {
|
|
2021
3324
|
const rows = /* @__PURE__ */ new Map();
|
|
2022
3325
|
for (const c2 of cells) {
|
|
2023
3326
|
const rowKey = c2.row !== void 0 ? `r${c2.row}` : c2.location.rack ?? c2.location.aisle ?? "0";
|
|
@@ -2030,6 +3333,8 @@ const NiceWarehouseView = /* @__PURE__ */ ve.forwardRef(
|
|
|
2030
3333
|
}
|
|
2031
3334
|
return [...rows.entries()].map(([rowKey, arr]) => ({ rowKey, cells: arr }));
|
|
2032
3335
|
}, [cells]);
|
|
3336
|
+
const gridRef = $e$1.useRef(null);
|
|
3337
|
+
Xa(gridRef);
|
|
2033
3338
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, id, className: `nice-warehouse-view ${className ?? ""}`, style, children: [
|
|
2034
3339
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "nice-warehouse-view__header", children: [
|
|
2035
3340
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { children: warehouseName }),
|
|
@@ -2052,31 +3357,42 @@ const NiceWarehouseView = /* @__PURE__ */ ve.forwardRef(
|
|
|
2052
3357
|
}
|
|
2053
3358
|
)
|
|
2054
3359
|
] }),
|
|
2055
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
3360
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3361
|
+
"div",
|
|
3362
|
+
{
|
|
3363
|
+
ref: gridRef,
|
|
3364
|
+
className: "nice-warehouse-view__grid",
|
|
3365
|
+
role: "grid",
|
|
3366
|
+
"aria-label": warehouseName,
|
|
3367
|
+
children: grid.map(({ rowKey, cells: row }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-warehouse-view__row", role: "row", children: row.map((c2, idx) => {
|
|
3368
|
+
const key = [c2.location.rack, c2.location.aisle, c2.location.shelf, c2.location.bin].filter(Boolean).join("-") || String(idx);
|
|
3369
|
+
const aisleBreak = aisleEvery > 0 && idx > 0 && idx % aisleEvery === 0;
|
|
3370
|
+
return /* @__PURE__ */ jsxRuntime.jsxs($e$1.Fragment, { children: [
|
|
3371
|
+
aisleBreak && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-warehouse-view__aisle", "aria-hidden": true }),
|
|
3372
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3373
|
+
"button",
|
|
3374
|
+
{
|
|
3375
|
+
type: "button",
|
|
3376
|
+
role: "gridcell",
|
|
3377
|
+
className: "nice-warehouse-view__cell",
|
|
3378
|
+
style: {
|
|
3379
|
+
width: cellSize,
|
|
3380
|
+
height: cellSize,
|
|
3381
|
+
background: colorFor(c2.occupancy, colors)
|
|
3382
|
+
},
|
|
3383
|
+
title: t("warehouseView.items", "{key} — {occupancy}% ({items} items)").replace("{key}", String(key)).replace("{occupancy}", String((c2.occupancy * 100).toFixed(0))).replace("{items}", String(c2.items.length)),
|
|
3384
|
+
onClick: () => onCellClick == null ? void 0 : onCellClick(c2),
|
|
3385
|
+
onMouseEnter: () => setHovered(c2),
|
|
3386
|
+
onMouseLeave: () => setHovered(null),
|
|
3387
|
+
onFocus: () => setHovered(c2),
|
|
3388
|
+
onBlur: () => setHovered(null),
|
|
3389
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-warehouse-view__bin", children: c2.location.bin ?? c2.location.shelf ?? "" })
|
|
3390
|
+
}
|
|
3391
|
+
)
|
|
3392
|
+
] }, key);
|
|
3393
|
+
}) }, rowKey))
|
|
3394
|
+
}
|
|
3395
|
+
),
|
|
2080
3396
|
hovered && /* @__PURE__ */ jsxRuntime.jsxs("aside", { className: "nice-warehouse-view__details", "aria-live": "polite", children: [
|
|
2081
3397
|
/* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
|
|
2082
3398
|
hovered.location.rack,
|
|
@@ -2125,7 +3441,7 @@ function fmtDate(d, locale) {
|
|
|
2125
3441
|
const dt = d instanceof Date ? d : new Date(d);
|
|
2126
3442
|
return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(dt);
|
|
2127
3443
|
}
|
|
2128
|
-
const NicePurchaseOrder = /* @__PURE__ */
|
|
3444
|
+
const NicePurchaseOrder = /* @__PURE__ */ $e$1.forwardRef(function NicePurchaseOrder2({
|
|
2129
3445
|
orders = EMPTY_ORDERS,
|
|
2130
3446
|
selectable = true,
|
|
2131
3447
|
initialSelectedId,
|
|
@@ -2141,7 +3457,7 @@ const NicePurchaseOrder = /* @__PURE__ */ ve.forwardRef(function NicePurchaseOrd
|
|
|
2141
3457
|
}, ref) {
|
|
2142
3458
|
var _a;
|
|
2143
3459
|
const { t } = v();
|
|
2144
|
-
const [selectedId, setSelectedId] =
|
|
3460
|
+
const [selectedId, setSelectedId] = $e$1.useState(
|
|
2145
3461
|
initialSelectedId ?? ((_a = orders[0]) == null ? void 0 : _a.id)
|
|
2146
3462
|
);
|
|
2147
3463
|
const L = {
|
|
@@ -2162,7 +3478,7 @@ const NicePurchaseOrder = /* @__PURE__ */ ve.forwardRef(function NicePurchaseOrd
|
|
|
2162
3478
|
receive: "Receive all",
|
|
2163
3479
|
...labels
|
|
2164
3480
|
};
|
|
2165
|
-
const selected =
|
|
3481
|
+
const selected = $e$1.useMemo(
|
|
2166
3482
|
() => orders.find((o) => o.id === selectedId),
|
|
2167
3483
|
[orders, selectedId]
|
|
2168
3484
|
);
|
|
@@ -2272,7 +3588,7 @@ const NicePurchaseOrder = /* @__PURE__ */ ve.forwardRef(function NicePurchaseOrd
|
|
|
2272
3588
|
] });
|
|
2273
3589
|
});
|
|
2274
3590
|
const EMPTY_EMPLOYEES = [];
|
|
2275
|
-
const NiceHRDashboard = /* @__PURE__ */
|
|
3591
|
+
const NiceHRDashboard = /* @__PURE__ */ $e$1.forwardRef(
|
|
2276
3592
|
function NiceHRDashboard2({
|
|
2277
3593
|
employees = EMPTY_EMPLOYEES,
|
|
2278
3594
|
labels,
|
|
@@ -2294,7 +3610,7 @@ const NiceHRDashboard = /* @__PURE__ */ ve.forwardRef(
|
|
|
2294
3610
|
activeEmployees: "Active",
|
|
2295
3611
|
...labels
|
|
2296
3612
|
};
|
|
2297
|
-
const stats =
|
|
3613
|
+
const stats = $e$1.useMemo(() => {
|
|
2298
3614
|
const active = employees.filter((e) => e.active !== false);
|
|
2299
3615
|
const fte = active.reduce((s, e) => s + (e.fte ?? 1), 0);
|
|
2300
3616
|
const vacationAvg = active.length === 0 ? 0 : active.reduce((s, e) => s + (e.vacationBalanceDays ?? 0), 0) / active.length;
|
|
@@ -2407,11 +3723,11 @@ const DEFAULT_SEED = {
|
|
|
2407
3723
|
};
|
|
2408
3724
|
function useMockErpApi(options = {}) {
|
|
2409
3725
|
const { latencyMs = 300, errorRate = 0, seed } = options;
|
|
2410
|
-
const [loading, setLoading] =
|
|
2411
|
-
const [error, setError] =
|
|
2412
|
-
const [data, setData] =
|
|
2413
|
-
const settledRef =
|
|
2414
|
-
const refresh =
|
|
3726
|
+
const [loading, setLoading] = $e$1.useState(true);
|
|
3727
|
+
const [error, setError] = $e$1.useState(null);
|
|
3728
|
+
const [data, setData] = $e$1.useState(() => ({ ...DEFAULT_SEED, ...seed }));
|
|
3729
|
+
const settledRef = $e$1.useRef(false);
|
|
3730
|
+
const refresh = $e$1.useCallback(async () => {
|
|
2415
3731
|
setLoading(true);
|
|
2416
3732
|
setError(null);
|
|
2417
3733
|
await wait(latencyMs);
|
|
@@ -2422,14 +3738,14 @@ function useMockErpApi(options = {}) {
|
|
|
2422
3738
|
}
|
|
2423
3739
|
setLoading(false);
|
|
2424
3740
|
}, [latencyMs, errorRate]);
|
|
2425
|
-
|
|
3741
|
+
$e$1.useEffect(() => {
|
|
2426
3742
|
if (settledRef.current) {
|
|
2427
3743
|
return;
|
|
2428
3744
|
}
|
|
2429
3745
|
settledRef.current = true;
|
|
2430
3746
|
void refresh();
|
|
2431
3747
|
}, [refresh]);
|
|
2432
|
-
const writeWith =
|
|
3748
|
+
const writeWith = $e$1.useCallback(
|
|
2433
3749
|
async (key, item) => {
|
|
2434
3750
|
await wait(latencyMs);
|
|
2435
3751
|
if (Math.random() < errorRate) {
|
|
@@ -2448,7 +3764,7 @@ function useMockErpApi(options = {}) {
|
|
|
2448
3764
|
},
|
|
2449
3765
|
[latencyMs, errorRate]
|
|
2450
3766
|
);
|
|
2451
|
-
return
|
|
3767
|
+
return $e$1.useMemo(
|
|
2452
3768
|
() => ({
|
|
2453
3769
|
loading,
|
|
2454
3770
|
error,
|
|
@@ -2467,7 +3783,7 @@ function useMockErpApi(options = {}) {
|
|
|
2467
3783
|
[loading, error, data, refresh, writeWith]
|
|
2468
3784
|
);
|
|
2469
3785
|
}
|
|
2470
|
-
const NiceVatTable = /* @__PURE__ */
|
|
3786
|
+
const NiceVatTable = /* @__PURE__ */ $e$1.forwardRef(
|
|
2471
3787
|
function NiceVatTable2({
|
|
2472
3788
|
country = "PL",
|
|
2473
3789
|
rates,
|
|
@@ -2482,7 +3798,7 @@ const NiceVatTable = /* @__PURE__ */ ve.forwardRef(
|
|
|
2482
3798
|
id
|
|
2483
3799
|
}, ref) {
|
|
2484
3800
|
const { t } = v();
|
|
2485
|
-
const [internal, setInternal] =
|
|
3801
|
+
const [internal, setInternal] = $e$1.useState(rates ?? NICE_VAT_PRESETS[country]);
|
|
2486
3802
|
const L = {
|
|
2487
3803
|
code: "Code",
|
|
2488
3804
|
rate: "Rate",
|
|
@@ -2492,7 +3808,7 @@ const NiceVatTable = /* @__PURE__ */ ve.forwardRef(
|
|
|
2492
3808
|
remove: "Remove",
|
|
2493
3809
|
...labels
|
|
2494
3810
|
};
|
|
2495
|
-
const update =
|
|
3811
|
+
const update = $e$1.useCallback(
|
|
2496
3812
|
(next) => {
|
|
2497
3813
|
setInternal(next);
|
|
2498
3814
|
onChange == null ? void 0 : onChange(next);
|
|
@@ -2519,7 +3835,7 @@ const NiceVatTable = /* @__PURE__ */ ve.forwardRef(
|
|
|
2519
3835
|
};
|
|
2520
3836
|
const removeRow = (idx) => {
|
|
2521
3837
|
const code = internal[idx].code;
|
|
2522
|
-
const next = internal.filter((
|
|
3838
|
+
const next = internal.filter((_2, i2) => i2 !== idx);
|
|
2523
3839
|
update(next);
|
|
2524
3840
|
onRemove == null ? void 0 : onRemove(code);
|
|
2525
3841
|
};
|
|
@@ -2572,7 +3888,7 @@ const NiceVatTable = /* @__PURE__ */ ve.forwardRef(
|
|
|
2572
3888
|
onChange: (e) => onCellEdit(idx, "description", e.target.value)
|
|
2573
3889
|
}
|
|
2574
3890
|
) : r.description ?? "" }),
|
|
2575
|
-
editable && /* @__PURE__ */ jsxRuntime.jsx("td", { children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => removeRow(idx), "aria-label": L.remove, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3891
|
+
editable && /* @__PURE__ */ jsxRuntime.jsx("td", { children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => removeRow(idx), "aria-label": L.remove, children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "close", size: 14 }) }) })
|
|
2576
3892
|
] }, r.code)) })
|
|
2577
3893
|
] }),
|
|
2578
3894
|
editable && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "nice-vat-table__add", onClick: addRow, children: L.add })
|
|
@@ -2634,7 +3950,7 @@ function defaultBuildXml(opts) {
|
|
|
2634
3950
|
lines.push("</JPK>");
|
|
2635
3951
|
return lines.join("\n");
|
|
2636
3952
|
}
|
|
2637
|
-
const NiceJpkExporter = /* @__PURE__ */
|
|
3953
|
+
const NiceJpkExporter = /* @__PURE__ */ $e$1.forwardRef(
|
|
2638
3954
|
function NiceJpkExporter2({
|
|
2639
3955
|
invoices = EMPTY_INVOICES,
|
|
2640
3956
|
taxpayer,
|
|
@@ -2650,11 +3966,11 @@ const NiceJpkExporter = /* @__PURE__ */ ve.forwardRef(
|
|
|
2650
3966
|
}, ref) {
|
|
2651
3967
|
const { t } = v();
|
|
2652
3968
|
const today = /* @__PURE__ */ new Date();
|
|
2653
|
-
const [format, setFormat] =
|
|
2654
|
-
const [from, setFrom] =
|
|
3969
|
+
const [format, setFormat] = $e$1.useState(defaultFormat);
|
|
3970
|
+
const [from, setFrom] = $e$1.useState(
|
|
2655
3971
|
isoDate((defaultPeriod == null ? void 0 : defaultPeriod.from) ?? new Date(today.getFullYear(), today.getMonth(), 1))
|
|
2656
3972
|
);
|
|
2657
|
-
const [to, setTo] =
|
|
3973
|
+
const [to, setTo] = $e$1.useState(
|
|
2658
3974
|
isoDate((defaultPeriod == null ? void 0 : defaultPeriod.to) ?? new Date(today.getFullYear(), today.getMonth() + 1, 0))
|
|
2659
3975
|
);
|
|
2660
3976
|
const L = {
|
|
@@ -2664,7 +3980,7 @@ const NiceJpkExporter = /* @__PURE__ */ ve.forwardRef(
|
|
|
2664
3980
|
export: "Export",
|
|
2665
3981
|
...labels
|
|
2666
3982
|
};
|
|
2667
|
-
const exportNow =
|
|
3983
|
+
const exportNow = $e$1.useCallback(() => {
|
|
2668
3984
|
const opts = {
|
|
2669
3985
|
format,
|
|
2670
3986
|
period: { from: new Date(from), to: new Date(to) },
|