@nice2dev/ui-erp 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1650 -335
- package/dist/index.mjs +1595 -280
- 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",
|
|
@@ -216,77 +360,1215 @@ const tr = {
|
|
|
216
360
|
"zoom-out": "M11 4a7 7 0 100 14 7 7 0 000-14z M21 21l-4.35-4.35 M8 11h6",
|
|
217
361
|
navigation: "M12 2l7 19-7-4-7 4z",
|
|
218
362
|
"refresh-ccw": "M1 4v6h6 M23 20v-6h-6 M20.49 9A9 9 0 005.64 5.64L1 10 M3.51 15a9 9 0 0014.85 3.36L23 14",
|
|
219
|
-
minimize: "M4 14h6v6 M20 10h-6V4 M14 10l7-7 M3 21l7-7"
|
|
220
|
-
|
|
363
|
+
minimize: "M4 14h6v6 M20 10h-6V4 M14 10l7-7 M3 21l7-7",
|
|
364
|
+
// 1.2.2: geometry tools and object grouping, drawn as glyphs before (Ntd* of the same names in icons)
|
|
365
|
+
point: "M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z M12 12h.01",
|
|
366
|
+
segment: "M6.5 17.5L17.5 6.5 M3 19a2 2 0 1 0 4 0a2 2 0 1 0-4 0 M17 5a2 2 0 1 0 4 0a2 2 0 1 0-4 0",
|
|
367
|
+
perpendicular: "M3 20h18 M12 20V4 M12 15h5v5",
|
|
368
|
+
parallel: "M4 16L14 6 M10 20L20 10",
|
|
369
|
+
midpoint: "M3 12h6 M15 12h6 M3 9v6 M21 9v6 M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z",
|
|
370
|
+
"angle-bisector": "M4 20h17 M4 20L16 5 M4 20l14.4-6.9 M10 20a6 6 0 0 0-2.25-4.68",
|
|
371
|
+
group: "M3 7V3h4 M17 3h4v4 M21 17v4h-4 M7 21H3v-4 M7 7h5v5H7z M12 12h5v5h-5z",
|
|
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 = {
|
|
221
421
|
xs: 12,
|
|
222
422
|
sm: 16,
|
|
223
423
|
md: 20,
|
|
224
424
|
lg: 24,
|
|
225
425
|
xl: 32
|
|
226
|
-
},
|
|
227
|
-
function
|
|
228
|
-
path:
|
|
229
|
-
size:
|
|
230
|
-
className:
|
|
426
|
+
}, Oe = /* @__PURE__ */ $e$1.createContext({});
|
|
427
|
+
function Zt({
|
|
428
|
+
path: n,
|
|
429
|
+
size: e,
|
|
430
|
+
className: t,
|
|
231
431
|
style: a2,
|
|
232
|
-
color:
|
|
233
|
-
title:
|
|
234
|
-
onClick:
|
|
432
|
+
color: r,
|
|
433
|
+
title: s,
|
|
434
|
+
onClick: o
|
|
235
435
|
}) {
|
|
236
436
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
237
437
|
"svg",
|
|
238
438
|
{
|
|
239
439
|
xmlns: "http://www.w3.org/2000/svg",
|
|
240
|
-
width:
|
|
241
|
-
height:
|
|
440
|
+
width: e,
|
|
441
|
+
height: e,
|
|
242
442
|
viewBox: "0 0 24 24",
|
|
243
443
|
fill: "none",
|
|
244
|
-
stroke:
|
|
444
|
+
stroke: r || "currentColor",
|
|
245
445
|
strokeWidth: 2,
|
|
246
446
|
strokeLinecap: "round",
|
|
247
447
|
strokeLinejoin: "round",
|
|
248
|
-
className: `nice-icon ${
|
|
448
|
+
className: `nice-icon ${t || ""}`,
|
|
249
449
|
style: a2,
|
|
250
|
-
role: o ? "img" : "presentation",
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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,
|
|
254
456
|
children: [
|
|
255
|
-
|
|
256
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d:
|
|
457
|
+
s && /* @__PURE__ */ jsxRuntime.jsx("title", { children: s }),
|
|
458
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: n })
|
|
257
459
|
]
|
|
258
460
|
}
|
|
259
461
|
);
|
|
260
462
|
}
|
|
261
|
-
const
|
|
262
|
-
name:
|
|
263
|
-
size:
|
|
264
|
-
className:
|
|
463
|
+
const te = ({
|
|
464
|
+
name: n,
|
|
465
|
+
size: e = "md",
|
|
466
|
+
className: t,
|
|
265
467
|
style: a2,
|
|
266
|
-
color:
|
|
267
|
-
title:
|
|
268
|
-
onClick:
|
|
468
|
+
color: r,
|
|
469
|
+
title: s,
|
|
470
|
+
onClick: o
|
|
269
471
|
}) => {
|
|
270
|
-
const { resolver: i2 } =
|
|
472
|
+
const { resolver: i2 } = $e$1.useContext(Oe), c2 = typeof e == "number" ? e : Jt[e];
|
|
271
473
|
if (i2) {
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
274
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
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
|
+
);
|
|
275
488
|
}
|
|
276
|
-
const
|
|
277
|
-
return
|
|
278
|
-
|
|
489
|
+
const d = xt[n];
|
|
490
|
+
return d ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
491
|
+
Zt,
|
|
279
492
|
{
|
|
280
|
-
path:
|
|
493
|
+
path: d,
|
|
281
494
|
size: c2,
|
|
282
|
-
className:
|
|
495
|
+
className: t,
|
|
283
496
|
style: a2,
|
|
284
|
-
color:
|
|
285
|
-
title:
|
|
286
|
-
onClick:
|
|
497
|
+
color: r,
|
|
498
|
+
title: s,
|
|
499
|
+
onClick: o
|
|
287
500
|
}
|
|
288
501
|
) : null;
|
|
289
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
|
+
}
|
|
290
1572
|
process.env.NODE_ENV !== "production" && "NiceRTLProvider";
|
|
291
1573
|
process.env.NODE_ENV !== "production" && "NiceAccessControl";
|
|
292
1574
|
process.env.NODE_ENV !== "production" && "NiceA11yProvider";
|
|
@@ -333,15 +1615,15 @@ const NiceCapacityPlanner = ({
|
|
|
333
1615
|
var _a, _b;
|
|
334
1616
|
const { t } = v();
|
|
335
1617
|
const config = { ...DEFAULT_VIEW_CONFIG$1, ...externalConfig };
|
|
336
|
-
const [selectedAllocation, setSelectedAllocation] =
|
|
337
|
-
const [hoveredCell, setHoveredCell] =
|
|
338
|
-
const [timeUnit, setTimeUnit] =
|
|
339
|
-
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(
|
|
340
1622
|
new Set(resources.map((r) => r.id))
|
|
341
1623
|
);
|
|
342
|
-
const [showAllocationModal, setShowAllocationModal] =
|
|
343
|
-
const [newAllocation, setNewAllocation] =
|
|
344
|
-
const timePeriods =
|
|
1624
|
+
const [showAllocationModal, setShowAllocationModal] = $e$1.useState(false);
|
|
1625
|
+
const [newAllocation, setNewAllocation] = $e$1.useState({});
|
|
1626
|
+
const timePeriods = $e$1.useMemo(() => {
|
|
345
1627
|
const periods = [];
|
|
346
1628
|
const increment = TIME_INCREMENTS[timeUnit];
|
|
347
1629
|
let current = new Date(dateRange.start);
|
|
@@ -351,7 +1633,7 @@ const NiceCapacityPlanner = ({
|
|
|
351
1633
|
}
|
|
352
1634
|
return periods;
|
|
353
1635
|
}, [dateRange.start, dateRange.end, timeUnit]);
|
|
354
|
-
const utilizationMap =
|
|
1636
|
+
const utilizationMap = $e$1.useMemo(() => {
|
|
355
1637
|
const map = /* @__PURE__ */ new Map();
|
|
356
1638
|
resources.forEach((resource) => {
|
|
357
1639
|
const resourceMap = /* @__PURE__ */ new Map();
|
|
@@ -382,7 +1664,7 @@ const NiceCapacityPlanner = ({
|
|
|
382
1664
|
});
|
|
383
1665
|
return map;
|
|
384
1666
|
}, [resources, allocations, timePeriods, timeUnit]);
|
|
385
|
-
const conflicts =
|
|
1667
|
+
const conflicts = $e$1.useMemo(() => {
|
|
386
1668
|
const conflictList = [];
|
|
387
1669
|
utilizationMap.forEach((resourceMap, resourceId) => {
|
|
388
1670
|
const resource = resources.find((r) => r.id === resourceId);
|
|
@@ -410,7 +1692,7 @@ const NiceCapacityPlanner = ({
|
|
|
410
1692
|
});
|
|
411
1693
|
return conflictList;
|
|
412
1694
|
}, [utilizationMap, allocations, resources, timeUnit]);
|
|
413
|
-
const getCellAllocations =
|
|
1695
|
+
const getCellAllocations = $e$1.useCallback(
|
|
414
1696
|
(resourceId, date) => {
|
|
415
1697
|
const periodStart = date.getTime();
|
|
416
1698
|
const periodEnd = periodStart + TIME_INCREMENTS[timeUnit];
|
|
@@ -531,7 +1813,7 @@ const NiceCapacityPlanner = ({
|
|
|
531
1813
|
unit
|
|
532
1814
|
)) }) }),
|
|
533
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: [
|
|
534
|
-
/* @__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 }) }),
|
|
535
1817
|
(conflicts.length === 1 ? t("capacityPlanner.oneConflict", "1 Conflict") : t("capacityPlanner.conflicts", "{count} Conflicts")).replace("{count}", String(conflicts.length))
|
|
536
1818
|
] }) })
|
|
537
1819
|
] }),
|
|
@@ -554,13 +1836,10 @@ const NiceCapacityPlanner = ({
|
|
|
554
1836
|
style: { backgroundColor: "var(--nice-warning-tint-30, rgba(245, 158, 11, 0.3))" }
|
|
555
1837
|
}
|
|
556
1838
|
),
|
|
557
|
-
/* @__PURE__ */ jsxRuntime.
|
|
558
|
-
"
|
|
559
|
-
"
|
|
560
|
-
|
|
561
|
-
config.utilizationThreshold,
|
|
562
|
-
"%)"
|
|
563
|
-
] })
|
|
1839
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: t(
|
|
1840
|
+
"capacityPlanner.highUtilization",
|
|
1841
|
+
"High Utilization (>={utilizationThreshold}%)"
|
|
1842
|
+
).replace("{utilizationThreshold}", String(config.utilizationThreshold)) })
|
|
564
1843
|
] }),
|
|
565
1844
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-resource-allocation__legend-item", children: [
|
|
566
1845
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -582,6 +1861,9 @@ const NiceCapacityPlanner = ({
|
|
|
582
1861
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
583
1862
|
"div",
|
|
584
1863
|
{
|
|
1864
|
+
role: onResourceClick ? "button" : void 0,
|
|
1865
|
+
tabIndex: onResourceClick ? 0 : void 0,
|
|
1866
|
+
onKeyDown: onResourceClick ? Et : void 0,
|
|
585
1867
|
className: "nice-resource-allocation__resource-cell",
|
|
586
1868
|
onClick: () => onResourceClick == null ? void 0 : onResourceClick(resource),
|
|
587
1869
|
children: [
|
|
@@ -594,7 +1876,7 @@ const NiceCapacityPlanner = ({
|
|
|
594
1876
|
toggleResource(resource.id);
|
|
595
1877
|
},
|
|
596
1878
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
597
|
-
|
|
1879
|
+
te,
|
|
598
1880
|
{
|
|
599
1881
|
name: expandedResources.has(resource.id) ? "chevron-down" : "chevron-right",
|
|
600
1882
|
size: 14
|
|
@@ -602,15 +1884,15 @@ const NiceCapacityPlanner = ({
|
|
|
602
1884
|
)
|
|
603
1885
|
}
|
|
604
1886
|
),
|
|
605
|
-
/* @__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 }) }),
|
|
606
1888
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-resource-allocation__resource-info", children: [
|
|
607
1889
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__resource-name", children: resource.name }),
|
|
608
1890
|
resource.department && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__resource-dept", children: resource.department })
|
|
609
1891
|
] }),
|
|
610
|
-
/* @__PURE__ */ jsxRuntime.
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
1892
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__resource-capacity", children: t("capacityPlanner.hDay", "{maxCapacity}h/day").replace(
|
|
1893
|
+
"{maxCapacity}",
|
|
1894
|
+
String(resource.maxCapacity)
|
|
1895
|
+
) })
|
|
614
1896
|
]
|
|
615
1897
|
}
|
|
616
1898
|
),
|
|
@@ -622,6 +1904,10 @@ const NiceCapacityPlanner = ({
|
|
|
622
1904
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
623
1905
|
"div",
|
|
624
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,
|
|
625
1911
|
className: `nice-resource-allocation__time-cell ${isHovered ? "nice-resource-allocation__time-cell--hovered" : ""}`,
|
|
626
1912
|
style: { backgroundColor: getCellColor(resource.id, period) },
|
|
627
1913
|
onClick: () => handleCellClick(resource.id, period),
|
|
@@ -632,6 +1918,7 @@ const NiceCapacityPlanner = ({
|
|
|
632
1918
|
cellAllocations.slice(0, 2).map((alloc) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
633
1919
|
"div",
|
|
634
1920
|
{
|
|
1921
|
+
role: "presentation",
|
|
635
1922
|
className: `nice-resource-allocation__allocation-dot nice-resource-allocation__allocation-dot--${alloc.status}`,
|
|
636
1923
|
onClick: (e) => {
|
|
637
1924
|
e.stopPropagation();
|
|
@@ -670,6 +1957,9 @@ const NiceCapacityPlanner = ({
|
|
|
670
1957
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
671
1958
|
"div",
|
|
672
1959
|
{
|
|
1960
|
+
role: "button",
|
|
1961
|
+
tabIndex: 0,
|
|
1962
|
+
onKeyDown: Et,
|
|
673
1963
|
className: `nice-resource-allocation__allocation-bar nice-resource-allocation__allocation-bar--${allocation.status} ${selectedAllocation === allocation.id ? "nice-resource-allocation__allocation-bar--selected" : ""}`,
|
|
674
1964
|
style: {
|
|
675
1965
|
left: `${leftPercent}%`,
|
|
@@ -677,10 +1967,10 @@ const NiceCapacityPlanner = ({
|
|
|
677
1967
|
},
|
|
678
1968
|
onClick: () => setSelectedAllocation(allocation.id),
|
|
679
1969
|
children: [
|
|
680
|
-
/* @__PURE__ */ jsxRuntime.
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
1970
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-resource-allocation__allocation-label", children: t("capacityPlanner.hDay2", "{hoursPerDay}h/day").replace(
|
|
1971
|
+
"{hoursPerDay}",
|
|
1972
|
+
String(allocation.hoursPerDay)
|
|
1973
|
+
) }),
|
|
684
1974
|
!readOnly && /* @__PURE__ */ jsxRuntime.jsx(
|
|
685
1975
|
"button",
|
|
686
1976
|
{
|
|
@@ -690,7 +1980,7 @@ const NiceCapacityPlanner = ({
|
|
|
690
1980
|
e.stopPropagation();
|
|
691
1981
|
onAllocationDelete == null ? void 0 : onAllocationDelete(allocation.id);
|
|
692
1982
|
},
|
|
693
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1983
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "close", size: 14 })
|
|
694
1984
|
}
|
|
695
1985
|
)
|
|
696
1986
|
]
|
|
@@ -703,11 +1993,13 @@ const NiceCapacityPlanner = ({
|
|
|
703
1993
|
showAllocationModal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
704
1994
|
"div",
|
|
705
1995
|
{
|
|
1996
|
+
role: "presentation",
|
|
706
1997
|
className: "nice-resource-allocation__modal-overlay",
|
|
707
1998
|
onClick: () => setShowAllocationModal(false),
|
|
708
1999
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
709
2000
|
"div",
|
|
710
2001
|
{
|
|
2002
|
+
role: "presentation",
|
|
711
2003
|
className: "nice-resource-allocation__allocation-modal",
|
|
712
2004
|
onClick: (e) => e.stopPropagation(),
|
|
713
2005
|
children: [
|
|
@@ -845,21 +2137,21 @@ const NiceInventoryManager = ({
|
|
|
845
2137
|
var _a, _b;
|
|
846
2138
|
const { t } = v();
|
|
847
2139
|
const config = { ...DEFAULT_VIEW_CONFIG, ...externalConfig };
|
|
848
|
-
const [filters, setFilters] =
|
|
849
|
-
const [view, setView] =
|
|
850
|
-
const [sortBy, setSortBy] =
|
|
851
|
-
const [sortOrder, setSortOrder] =
|
|
852
|
-
const [page, setPage] =
|
|
853
|
-
const [selectedItems, setSelectedItems] =
|
|
854
|
-
const [showItemModal, setShowItemModal] =
|
|
855
|
-
const [showTransactionModal, setShowTransactionModal] =
|
|
856
|
-
const [editingItem, setEditingItem] =
|
|
857
|
-
const [newTransaction, setNewTransaction] =
|
|
858
|
-
const [activeTab, setActiveTab] =
|
|
859
|
-
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(() => {
|
|
860
2152
|
return Array.from(new Set(items.map((item) => item.category))).sort();
|
|
861
2153
|
}, [items]);
|
|
862
|
-
const filteredItems =
|
|
2154
|
+
const filteredItems = $e$1.useMemo(() => {
|
|
863
2155
|
var _a2, _b2;
|
|
864
2156
|
let result = [...items];
|
|
865
2157
|
if (filters.searchQuery) {
|
|
@@ -904,18 +2196,18 @@ const NiceInventoryManager = ({
|
|
|
904
2196
|
});
|
|
905
2197
|
return result;
|
|
906
2198
|
}, [items, filters, sortBy, sortOrder]);
|
|
907
|
-
const paginatedItems =
|
|
2199
|
+
const paginatedItems = $e$1.useMemo(() => {
|
|
908
2200
|
const start = (page - 1) * config.pageSize;
|
|
909
2201
|
return filteredItems.slice(start, start + config.pageSize);
|
|
910
2202
|
}, [filteredItems, page, config.pageSize]);
|
|
911
2203
|
const totalPages = Math.ceil(filteredItems.length / config.pageSize);
|
|
912
|
-
const reorderItems =
|
|
2204
|
+
const reorderItems = $e$1.useMemo(() => {
|
|
913
2205
|
return items.filter((item) => item.quantity <= item.reorderLevel);
|
|
914
2206
|
}, [items]);
|
|
915
|
-
const recentTransactions =
|
|
2207
|
+
const recentTransactions = $e$1.useMemo(() => {
|
|
916
2208
|
return [...transactions].sort((a2, b) => b.date.getTime() - a2.date.getTime()).slice(0, 50);
|
|
917
2209
|
}, [transactions]);
|
|
918
|
-
const kanbanGroups =
|
|
2210
|
+
const kanbanGroups = $e$1.useMemo(() => {
|
|
919
2211
|
if (view !== "kanban") {
|
|
920
2212
|
return null;
|
|
921
2213
|
}
|
|
@@ -1023,7 +2315,7 @@ const NiceInventoryManager = ({
|
|
|
1023
2315
|
onChange: (e) => setFilters((prev) => ({ ...prev, searchQuery: e.target.value }))
|
|
1024
2316
|
}
|
|
1025
2317
|
),
|
|
1026
|
-
/* @__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 }) })
|
|
1027
2319
|
] }),
|
|
1028
2320
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1029
2321
|
"select",
|
|
@@ -1058,7 +2350,7 @@ const NiceInventoryManager = ({
|
|
|
1058
2350
|
className: `nice-inventory-manager__view-button ${view === v2 ? "nice-inventory-manager__view-button--active" : ""}`,
|
|
1059
2351
|
onClick: () => setView(v2),
|
|
1060
2352
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1061
|
-
|
|
2353
|
+
te,
|
|
1062
2354
|
{
|
|
1063
2355
|
name: v2 === "grid" ? "grid" : v2 === "list" ? "list" : "table",
|
|
1064
2356
|
size: 14
|
|
@@ -1083,34 +2375,32 @@ const NiceInventoryManager = ({
|
|
|
1083
2375
|
});
|
|
1084
2376
|
setShowItemModal(true);
|
|
1085
2377
|
},
|
|
1086
|
-
children: "+ Add Item"
|
|
2378
|
+
children: t("inventoryManager.addItem", "+ Add Item")
|
|
1087
2379
|
}
|
|
1088
2380
|
)
|
|
1089
2381
|
] })
|
|
1090
2382
|
] }),
|
|
1091
2383
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__tabs", children: [
|
|
1092
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2384
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1093
2385
|
"button",
|
|
1094
2386
|
{
|
|
1095
2387
|
className: `nice-inventory-manager__tab ${activeTab === "inventory" ? "nice-inventory-manager__tab--active" : ""}`,
|
|
1096
2388
|
onClick: () => setActiveTab("inventory"),
|
|
1097
|
-
children:
|
|
1098
|
-
"
|
|
1099
|
-
items.length
|
|
1100
|
-
|
|
1101
|
-
]
|
|
2389
|
+
children: t("inventoryManager.inventory", "Inventory ({items})").replace(
|
|
2390
|
+
"{items}",
|
|
2391
|
+
String(items.length)
|
|
2392
|
+
)
|
|
1102
2393
|
}
|
|
1103
2394
|
),
|
|
1104
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2395
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1105
2396
|
"button",
|
|
1106
2397
|
{
|
|
1107
2398
|
className: `nice-inventory-manager__tab ${activeTab === "transactions" ? "nice-inventory-manager__tab--active" : ""}`,
|
|
1108
2399
|
onClick: () => setActiveTab("transactions"),
|
|
1109
|
-
children:
|
|
1110
|
-
"
|
|
1111
|
-
transactions.length
|
|
1112
|
-
|
|
1113
|
-
]
|
|
2400
|
+
children: t("inventoryManager.transactions", "Transactions ({transactions})").replace(
|
|
2401
|
+
"{transactions}",
|
|
2402
|
+
String(transactions.length)
|
|
2403
|
+
)
|
|
1114
2404
|
}
|
|
1115
2405
|
),
|
|
1116
2406
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1132,6 +2422,9 @@ const NiceInventoryManager = ({
|
|
|
1132
2422
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1133
2423
|
"div",
|
|
1134
2424
|
{
|
|
2425
|
+
role: onItemClick ? "button" : void 0,
|
|
2426
|
+
tabIndex: onItemClick ? 0 : void 0,
|
|
2427
|
+
onKeyDown: onItemClick ? Et : void 0,
|
|
1135
2428
|
className: `nice-inventory-manager__item-card ${selectedItems.has(item.id) ? "nice-inventory-manager__item-card--selected" : ""}`,
|
|
1136
2429
|
onClick: () => onItemClick == null ? void 0 : onItemClick(item),
|
|
1137
2430
|
children: [
|
|
@@ -1145,7 +2438,7 @@ const NiceInventoryManager = ({
|
|
|
1145
2438
|
onClick: (e) => e.stopPropagation()
|
|
1146
2439
|
}
|
|
1147
2440
|
),
|
|
1148
|
-
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 }) }) }),
|
|
1149
2442
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__item-info", children: [
|
|
1150
2443
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__item-sku", children: item.sku }),
|
|
1151
2444
|
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "nice-inventory-manager__item-name", children: item.name }),
|
|
@@ -1166,7 +2459,7 @@ const NiceInventoryManager = ({
|
|
|
1166
2459
|
item.unit
|
|
1167
2460
|
] }),
|
|
1168
2461
|
item.quantity <= item.reorderLevel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "nice-inventory-manager__reorder-alert", children: [
|
|
1169
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2462
|
+
/* @__PURE__ */ jsxRuntime.jsx(te, { name: "warning", size: 12 }),
|
|
1170
2463
|
" ",
|
|
1171
2464
|
t("inventoryManager.lowStock", "Low Stock")
|
|
1172
2465
|
] })
|
|
@@ -1191,7 +2484,7 @@ const NiceInventoryManager = ({
|
|
|
1191
2484
|
t("inventoryManager.sku", "SKU"),
|
|
1192
2485
|
" ",
|
|
1193
2486
|
sortBy === "sku" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1194
|
-
|
|
2487
|
+
te,
|
|
1195
2488
|
{
|
|
1196
2489
|
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
1197
2490
|
size: 12
|
|
@@ -1211,7 +2504,7 @@ const NiceInventoryManager = ({
|
|
|
1211
2504
|
t("inventoryManager.name", "Name"),
|
|
1212
2505
|
" ",
|
|
1213
2506
|
sortBy === "name" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1214
|
-
|
|
2507
|
+
te,
|
|
1215
2508
|
{
|
|
1216
2509
|
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
1217
2510
|
size: 12
|
|
@@ -1232,7 +2525,7 @@ const NiceInventoryManager = ({
|
|
|
1232
2525
|
t("inventoryManager.qty", "Qty"),
|
|
1233
2526
|
" ",
|
|
1234
2527
|
sortBy === "quantity" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1235
|
-
|
|
2528
|
+
te,
|
|
1236
2529
|
{
|
|
1237
2530
|
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
1238
2531
|
size: 12
|
|
@@ -1254,7 +2547,7 @@ const NiceInventoryManager = ({
|
|
|
1254
2547
|
t("inventoryManager.value", "Value"),
|
|
1255
2548
|
" ",
|
|
1256
2549
|
sortBy === "value" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1257
|
-
|
|
2550
|
+
te,
|
|
1258
2551
|
{
|
|
1259
2552
|
name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
|
|
1260
2553
|
size: 12
|
|
@@ -1317,7 +2610,7 @@ const NiceInventoryManager = ({
|
|
|
1317
2610
|
setEditingItem(item);
|
|
1318
2611
|
setShowItemModal(true);
|
|
1319
2612
|
},
|
|
1320
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2613
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "edit", size: 14 })
|
|
1321
2614
|
}
|
|
1322
2615
|
),
|
|
1323
2616
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1329,7 +2622,7 @@ const NiceInventoryManager = ({
|
|
|
1329
2622
|
setNewTransaction({ itemId: item.id });
|
|
1330
2623
|
setShowTransactionModal(true);
|
|
1331
2624
|
},
|
|
1332
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2625
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "clipboard", size: 14 })
|
|
1333
2626
|
}
|
|
1334
2627
|
),
|
|
1335
2628
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1340,7 +2633,7 @@ const NiceInventoryManager = ({
|
|
|
1340
2633
|
e.stopPropagation();
|
|
1341
2634
|
onItemDelete == null ? void 0 : onItemDelete(item.id);
|
|
1342
2635
|
},
|
|
1343
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2636
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "trash", size: 14 })
|
|
1344
2637
|
}
|
|
1345
2638
|
)
|
|
1346
2639
|
] })
|
|
@@ -1371,6 +2664,9 @@ const NiceInventoryManager = ({
|
|
|
1371
2664
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-inventory-manager__column-items", children: statusItems.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1372
2665
|
"div",
|
|
1373
2666
|
{
|
|
2667
|
+
role: onItemClick ? "button" : void 0,
|
|
2668
|
+
tabIndex: onItemClick ? 0 : void 0,
|
|
2669
|
+
onKeyDown: onItemClick ? Et : void 0,
|
|
1374
2670
|
className: "nice-inventory-manager__kanban-card",
|
|
1375
2671
|
onClick: () => onItemClick == null ? void 0 : onItemClick(item),
|
|
1376
2672
|
children: [
|
|
@@ -1398,13 +2694,13 @@ const NiceInventoryManager = ({
|
|
|
1398
2694
|
{
|
|
1399
2695
|
className: "nice-inventory-manager__add-transaction-button",
|
|
1400
2696
|
onClick: () => setShowTransactionModal(true),
|
|
1401
|
-
children: "+ New Transaction"
|
|
2697
|
+
children: t("inventoryManager.newTransaction", "+ New Transaction")
|
|
1402
2698
|
}
|
|
1403
2699
|
),
|
|
1404
2700
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-inventory-manager__transactions-list", children: recentTransactions.map((tx) => {
|
|
1405
2701
|
const item = items.find((i2) => i2.id === tx.itemId);
|
|
1406
2702
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__transaction-item", children: [
|
|
1407
|
-
/* @__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 }) }),
|
|
1408
2704
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__tx-info", children: [
|
|
1409
2705
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__tx-type", children: tx.type }),
|
|
1410
2706
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__tx-item", children: (item == null ? void 0 : item.name) || tx.itemId })
|
|
@@ -1420,15 +2716,15 @@ const NiceInventoryManager = ({
|
|
|
1420
2716
|
}
|
|
1421
2717
|
),
|
|
1422
2718
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__tx-date", children: tx.date.toLocaleString() }),
|
|
1423
|
-
tx.reference && /* @__PURE__ */ jsxRuntime.
|
|
1424
|
-
"
|
|
1425
|
-
tx.reference
|
|
1426
|
-
|
|
2719
|
+
tx.reference && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__tx-ref", children: t("inventoryManager.ref", "Ref: {reference}").replace(
|
|
2720
|
+
"{reference}",
|
|
2721
|
+
String(tx.reference)
|
|
2722
|
+
) })
|
|
1427
2723
|
] }, tx.id);
|
|
1428
2724
|
}) })
|
|
1429
2725
|
] }),
|
|
1430
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: [
|
|
1431
|
-
/* @__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 }) }),
|
|
1432
2728
|
/* @__PURE__ */ jsxRuntime.jsx("p", { children: t(
|
|
1433
2729
|
"inventoryManager.allItemsAreSufficientlyStocked",
|
|
1434
2730
|
"All items are sufficiently stocked"
|
|
@@ -1439,20 +2735,15 @@ const NiceInventoryManager = ({
|
|
|
1439
2735
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__reorder-name", children: item.name })
|
|
1440
2736
|
] }),
|
|
1441
2737
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__reorder-stock", children: [
|
|
1442
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
] }),
|
|
1452
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "nice-inventory-manager__reorder-qty", children: [
|
|
1453
|
-
"Order qty: ",
|
|
1454
|
-
item.reorderQuantity
|
|
1455
|
-
] })
|
|
2738
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__current-qty", children: t("inventoryManager.current", "Current: {quantity} {unit}").replace("{quantity}", String(item.quantity)).replace("{unit}", String(item.unit)) }),
|
|
2739
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__reorder-level", children: t("inventoryManager.reorderAt", "Reorder at: {reorderLevel}").replace(
|
|
2740
|
+
"{reorderLevel}",
|
|
2741
|
+
String(item.reorderLevel)
|
|
2742
|
+
) }),
|
|
2743
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__reorder-qty", children: t("inventoryManager.orderQty", "Order qty: {reorderQuantity}").replace(
|
|
2744
|
+
"{reorderQuantity}",
|
|
2745
|
+
String(item.reorderQuantity)
|
|
2746
|
+
) })
|
|
1456
2747
|
] }),
|
|
1457
2748
|
item.supplier && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-inventory-manager__supplier-name", children: item.supplier.name }),
|
|
1458
2749
|
!readOnly && onCreatePurchaseOrder && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1469,153 +2760,164 @@ const NiceInventoryManager = ({
|
|
|
1469
2760
|
showItemModal && editingItem && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1470
2761
|
"div",
|
|
1471
2762
|
{
|
|
2763
|
+
role: "presentation",
|
|
1472
2764
|
className: "nice-inventory-manager__modal-overlay",
|
|
1473
2765
|
onClick: () => setShowItemModal(false),
|
|
1474
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
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
|
+
] })
|
|
1488
2894
|
] }),
|
|
1489
|
-
/* @__PURE__ */ jsxRuntime.jsxs("
|
|
1490
|
-
t("inventoryManager.name", "Name"),
|
|
1491
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1492
|
-
"input",
|
|
1493
|
-
{
|
|
1494
|
-
type: "text",
|
|
1495
|
-
value: editingItem.name || "",
|
|
1496
|
-
onChange: (e) => setEditingItem((prev) => ({ ...prev, name: e.target.value }))
|
|
1497
|
-
}
|
|
1498
|
-
)
|
|
1499
|
-
] })
|
|
1500
|
-
] }),
|
|
1501
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1502
|
-
t("inventoryManager.description", "Description"),
|
|
1503
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1504
|
-
"textarea",
|
|
1505
|
-
{
|
|
1506
|
-
value: editingItem.description || "",
|
|
1507
|
-
onChange: (e) => setEditingItem((prev) => ({ ...prev, description: e.target.value }))
|
|
1508
|
-
}
|
|
1509
|
-
)
|
|
1510
|
-
] }),
|
|
1511
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__form-row", children: [
|
|
1512
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1513
|
-
t("inventoryManager.category", "Category"),
|
|
2895
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__modal-actions", children: [
|
|
1514
2896
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1515
|
-
"
|
|
2897
|
+
"button",
|
|
1516
2898
|
{
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
list: "categories"
|
|
2899
|
+
className: "nice-inventory-manager__cancel-button",
|
|
2900
|
+
onClick: () => setShowItemModal(false),
|
|
2901
|
+
children: t("inventoryManager.cancel", "Cancel")
|
|
1521
2902
|
}
|
|
1522
2903
|
),
|
|
1523
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
1524
|
-
] }),
|
|
1525
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1526
|
-
t("inventoryManager.unit", "Unit"),
|
|
1527
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1528
|
-
"input",
|
|
1529
|
-
{
|
|
1530
|
-
type: "text",
|
|
1531
|
-
value: editingItem.unit || "",
|
|
1532
|
-
onChange: (e) => setEditingItem((prev) => ({ ...prev, unit: e.target.value }))
|
|
1533
|
-
}
|
|
1534
|
-
)
|
|
1535
|
-
] })
|
|
1536
|
-
] }),
|
|
1537
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__form-row", children: [
|
|
1538
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1539
|
-
t("inventoryManager.quantity", "Quantity"),
|
|
1540
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1541
|
-
"input",
|
|
1542
|
-
{
|
|
1543
|
-
type: "number",
|
|
1544
|
-
value: editingItem.quantity || 0,
|
|
1545
|
-
onChange: (e) => setEditingItem((prev) => ({ ...prev, quantity: parseInt(e.target.value) }))
|
|
1546
|
-
}
|
|
1547
|
-
)
|
|
1548
|
-
] }),
|
|
1549
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1550
|
-
t("inventoryManager.reorderLevel", "Reorder Level"),
|
|
1551
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1552
|
-
"input",
|
|
1553
|
-
{
|
|
1554
|
-
type: "number",
|
|
1555
|
-
value: editingItem.reorderLevel || 0,
|
|
1556
|
-
onChange: (e) => setEditingItem((prev) => ({
|
|
1557
|
-
...prev,
|
|
1558
|
-
reorderLevel: parseInt(e.target.value)
|
|
1559
|
-
}))
|
|
1560
|
-
}
|
|
1561
|
-
)
|
|
1562
|
-
] }),
|
|
1563
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
1564
|
-
t("inventoryManager.reorderQty", "Reorder Qty"),
|
|
1565
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1566
|
-
"input",
|
|
1567
|
-
{
|
|
1568
|
-
type: "number",
|
|
1569
|
-
value: editingItem.reorderQuantity || 0,
|
|
1570
|
-
onChange: (e) => setEditingItem((prev) => ({
|
|
1571
|
-
...prev,
|
|
1572
|
-
reorderQuantity: parseInt(e.target.value)
|
|
1573
|
-
}))
|
|
1574
|
-
}
|
|
1575
|
-
)
|
|
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") })
|
|
1576
2905
|
] })
|
|
1577
|
-
]
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1581
|
-
"input",
|
|
1582
|
-
{
|
|
1583
|
-
type: "number",
|
|
1584
|
-
step: "0.01",
|
|
1585
|
-
value: ((_b = editingItem.cost) == null ? void 0 : _b.amount) || 0,
|
|
1586
|
-
onChange: (e) => setEditingItem((prev) => ({
|
|
1587
|
-
...prev,
|
|
1588
|
-
cost: {
|
|
1589
|
-
...prev.cost,
|
|
1590
|
-
amount: parseFloat(e.target.value)
|
|
1591
|
-
}
|
|
1592
|
-
}))
|
|
1593
|
-
}
|
|
1594
|
-
)
|
|
1595
|
-
] })
|
|
1596
|
-
] }),
|
|
1597
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-inventory-manager__modal-actions", children: [
|
|
1598
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1599
|
-
"button",
|
|
1600
|
-
{
|
|
1601
|
-
className: "nice-inventory-manager__cancel-button",
|
|
1602
|
-
onClick: () => setShowItemModal(false),
|
|
1603
|
-
children: t("inventoryManager.cancel", "Cancel")
|
|
1604
|
-
}
|
|
1605
|
-
),
|
|
1606
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "nice-inventory-manager__save-button", onClick: handleItemSubmit, children: editingItem.id ? "Save Changes" : "Create Item" })
|
|
1607
|
-
] })
|
|
1608
|
-
] })
|
|
2906
|
+
]
|
|
2907
|
+
}
|
|
2908
|
+
)
|
|
1609
2909
|
}
|
|
1610
2910
|
),
|
|
1611
2911
|
showTransactionModal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1612
2912
|
"div",
|
|
1613
2913
|
{
|
|
2914
|
+
role: "presentation",
|
|
1614
2915
|
className: "nice-inventory-manager__modal-overlay",
|
|
1615
2916
|
onClick: () => setShowTransactionModal(false),
|
|
1616
2917
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1617
2918
|
"div",
|
|
1618
2919
|
{
|
|
2920
|
+
role: "presentation",
|
|
1619
2921
|
className: "nice-inventory-manager__transaction-modal",
|
|
1620
2922
|
onClick: (e) => e.stopPropagation(),
|
|
1621
2923
|
children: [
|
|
@@ -1749,7 +3051,7 @@ function fmtDate$1(d, locale) {
|
|
|
1749
3051
|
const dt = d instanceof Date ? d : new Date(d);
|
|
1750
3052
|
return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(dt);
|
|
1751
3053
|
}
|
|
1752
|
-
const NiceInvoiceView = /* @__PURE__ */
|
|
3054
|
+
const NiceInvoiceView = /* @__PURE__ */ $e$1.forwardRef(
|
|
1753
3055
|
function NiceInvoiceView2({
|
|
1754
3056
|
invoice,
|
|
1755
3057
|
locale,
|
|
@@ -1772,7 +3074,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1772
3074
|
dueDate: "Due date",
|
|
1773
3075
|
seller: "Seller",
|
|
1774
3076
|
buyer: "Buyer",
|
|
1775
|
-
description: "Description",
|
|
3077
|
+
description: t("invoiceView.description", "Description"),
|
|
1776
3078
|
qty: "Qty",
|
|
1777
3079
|
unitPrice: "Unit price",
|
|
1778
3080
|
vat: "VAT",
|
|
@@ -1787,7 +3089,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1787
3089
|
vatId: "VAT ID",
|
|
1788
3090
|
...labels
|
|
1789
3091
|
};
|
|
1790
|
-
const totals =
|
|
3092
|
+
const totals = $e$1.useMemo(() => {
|
|
1791
3093
|
let net = 0;
|
|
1792
3094
|
let vat = 0;
|
|
1793
3095
|
const byRate = /* @__PURE__ */ new Map();
|
|
@@ -1852,7 +3154,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1852
3154
|
onClick: () => onAction == null ? void 0 : onAction("download"),
|
|
1853
3155
|
"aria-label": t("invoiceView.download", "Download"),
|
|
1854
3156
|
title: t("invoiceView.download", "Download"),
|
|
1855
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3157
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "arrow-down", size: 12 })
|
|
1856
3158
|
}
|
|
1857
3159
|
),
|
|
1858
3160
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1862,7 +3164,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1862
3164
|
onClick: () => onAction == null ? void 0 : onAction("print"),
|
|
1863
3165
|
"aria-label": t("invoiceView.print", "Print"),
|
|
1864
3166
|
title: t("invoiceView.print", "Print"),
|
|
1865
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3167
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "printer", size: 14 })
|
|
1866
3168
|
}
|
|
1867
3169
|
),
|
|
1868
3170
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1872,7 +3174,7 @@ const NiceInvoiceView = /* @__PURE__ */ ve.forwardRef(
|
|
|
1872
3174
|
onClick: () => onAction == null ? void 0 : onAction("send"),
|
|
1873
3175
|
"aria-label": t("invoiceView.send", "Send"),
|
|
1874
3176
|
title: t("invoiceView.send", "Send"),
|
|
1875
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3177
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(te, { name: "mail", size: 14 })
|
|
1876
3178
|
}
|
|
1877
3179
|
)
|
|
1878
3180
|
] })
|
|
@@ -1999,7 +3301,7 @@ function colorFor(occ, colors) {
|
|
|
1999
3301
|
}
|
|
2000
3302
|
return colors.high;
|
|
2001
3303
|
}
|
|
2002
|
-
const NiceWarehouseView = /* @__PURE__ */
|
|
3304
|
+
const NiceWarehouseView = /* @__PURE__ */ $e$1.forwardRef(
|
|
2003
3305
|
function NiceWarehouseView2({
|
|
2004
3306
|
warehouseName,
|
|
2005
3307
|
cells = EMPTY_CELLS,
|
|
@@ -2017,8 +3319,8 @@ const NiceWarehouseView = /* @__PURE__ */ ve.forwardRef(
|
|
|
2017
3319
|
id
|
|
2018
3320
|
}, ref) {
|
|
2019
3321
|
const { t } = v();
|
|
2020
|
-
const [hovered, setHovered] =
|
|
2021
|
-
const grid =
|
|
3322
|
+
const [hovered, setHovered] = $e$1.useState(null);
|
|
3323
|
+
const grid = $e$1.useMemo(() => {
|
|
2022
3324
|
const rows = /* @__PURE__ */ new Map();
|
|
2023
3325
|
for (const c2 of cells) {
|
|
2024
3326
|
const rowKey = c2.row !== void 0 ? `r${c2.row}` : c2.location.rack ?? c2.location.aisle ?? "0";
|
|
@@ -2031,6 +3333,8 @@ const NiceWarehouseView = /* @__PURE__ */ ve.forwardRef(
|
|
|
2031
3333
|
}
|
|
2032
3334
|
return [...rows.entries()].map(([rowKey, arr]) => ({ rowKey, cells: arr }));
|
|
2033
3335
|
}, [cells]);
|
|
3336
|
+
const gridRef = $e$1.useRef(null);
|
|
3337
|
+
Xa(gridRef);
|
|
2034
3338
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, id, className: `nice-warehouse-view ${className ?? ""}`, style, children: [
|
|
2035
3339
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { className: "nice-warehouse-view__header", children: [
|
|
2036
3340
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { children: warehouseName }),
|
|
@@ -2041,40 +3345,54 @@ const NiceWarehouseView = /* @__PURE__ */ ve.forwardRef(
|
|
|
2041
3345
|
"aria-label": t("warehouseView.occupancyLegend", "Occupancy legend"),
|
|
2042
3346
|
children: [
|
|
2043
3347
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { background: colors.low } }),
|
|
2044
|
-
"
|
|
3348
|
+
" ",
|
|
3349
|
+
t("warehouseView.low", "low"),
|
|
2045
3350
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { background: colors.mid } }),
|
|
2046
|
-
"
|
|
3351
|
+
" ",
|
|
3352
|
+
t("warehouseView.mid", "mid"),
|
|
2047
3353
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { background: colors.high } }),
|
|
2048
|
-
"
|
|
3354
|
+
" ",
|
|
3355
|
+
t("warehouseView.high", "high")
|
|
2049
3356
|
]
|
|
2050
3357
|
}
|
|
2051
3358
|
)
|
|
2052
3359
|
] }),
|
|
2053
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
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
|
+
),
|
|
2078
3396
|
hovered && /* @__PURE__ */ jsxRuntime.jsxs("aside", { className: "nice-warehouse-view__details", "aria-live": "polite", children: [
|
|
2079
3397
|
/* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
|
|
2080
3398
|
hovered.location.rack,
|
|
@@ -2083,12 +3401,7 @@ const NiceWarehouseView = /* @__PURE__ */ ve.forwardRef(
|
|
|
2083
3401
|
"/",
|
|
2084
3402
|
hovered.location.bin
|
|
2085
3403
|
] }),
|
|
2086
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2087
|
-
hovered.items.length,
|
|
2088
|
-
" items · ",
|
|
2089
|
-
(hovered.occupancy * 100).toFixed(0),
|
|
2090
|
-
"% full"
|
|
2091
|
-
] }),
|
|
3404
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: t("warehouseView.itemsFull", "{items} items · {occupancy}% full").replace("{items}", String(hovered.items.length)).replace("{occupancy}", String((hovered.occupancy * 100).toFixed(0))) }),
|
|
2092
3405
|
/* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
|
|
2093
3406
|
hovered.items.slice(0, 5).map((it) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
2094
3407
|
it.sku,
|
|
@@ -2128,7 +3441,7 @@ function fmtDate(d, locale) {
|
|
|
2128
3441
|
const dt = d instanceof Date ? d : new Date(d);
|
|
2129
3442
|
return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(dt);
|
|
2130
3443
|
}
|
|
2131
|
-
const NicePurchaseOrder = /* @__PURE__ */
|
|
3444
|
+
const NicePurchaseOrder = /* @__PURE__ */ $e$1.forwardRef(function NicePurchaseOrder2({
|
|
2132
3445
|
orders = EMPTY_ORDERS,
|
|
2133
3446
|
selectable = true,
|
|
2134
3447
|
initialSelectedId,
|
|
@@ -2144,7 +3457,7 @@ const NicePurchaseOrder = /* @__PURE__ */ ve.forwardRef(function NicePurchaseOrd
|
|
|
2144
3457
|
}, ref) {
|
|
2145
3458
|
var _a;
|
|
2146
3459
|
const { t } = v();
|
|
2147
|
-
const [selectedId, setSelectedId] =
|
|
3460
|
+
const [selectedId, setSelectedId] = $e$1.useState(
|
|
2148
3461
|
initialSelectedId ?? ((_a = orders[0]) == null ? void 0 : _a.id)
|
|
2149
3462
|
);
|
|
2150
3463
|
const L = {
|
|
@@ -2165,7 +3478,7 @@ const NicePurchaseOrder = /* @__PURE__ */ ve.forwardRef(function NicePurchaseOrd
|
|
|
2165
3478
|
receive: "Receive all",
|
|
2166
3479
|
...labels
|
|
2167
3480
|
};
|
|
2168
|
-
const selected =
|
|
3481
|
+
const selected = $e$1.useMemo(
|
|
2169
3482
|
() => orders.find((o) => o.id === selectedId),
|
|
2170
3483
|
[orders, selectedId]
|
|
2171
3484
|
);
|
|
@@ -2275,7 +3588,7 @@ const NicePurchaseOrder = /* @__PURE__ */ ve.forwardRef(function NicePurchaseOrd
|
|
|
2275
3588
|
] });
|
|
2276
3589
|
});
|
|
2277
3590
|
const EMPTY_EMPLOYEES = [];
|
|
2278
|
-
const NiceHRDashboard = /* @__PURE__ */
|
|
3591
|
+
const NiceHRDashboard = /* @__PURE__ */ $e$1.forwardRef(
|
|
2279
3592
|
function NiceHRDashboard2({
|
|
2280
3593
|
employees = EMPTY_EMPLOYEES,
|
|
2281
3594
|
labels,
|
|
@@ -2297,7 +3610,7 @@ const NiceHRDashboard = /* @__PURE__ */ ve.forwardRef(
|
|
|
2297
3610
|
activeEmployees: "Active",
|
|
2298
3611
|
...labels
|
|
2299
3612
|
};
|
|
2300
|
-
const stats =
|
|
3613
|
+
const stats = $e$1.useMemo(() => {
|
|
2301
3614
|
const active = employees.filter((e) => e.active !== false);
|
|
2302
3615
|
const fte = active.reduce((s, e) => s + (e.fte ?? 1), 0);
|
|
2303
3616
|
const vacationAvg = active.length === 0 ? 0 : active.reduce((s, e) => s + (e.vacationBalanceDays ?? 0), 0) / active.length;
|
|
@@ -2410,11 +3723,11 @@ const DEFAULT_SEED = {
|
|
|
2410
3723
|
};
|
|
2411
3724
|
function useMockErpApi(options = {}) {
|
|
2412
3725
|
const { latencyMs = 300, errorRate = 0, seed } = options;
|
|
2413
|
-
const [loading, setLoading] =
|
|
2414
|
-
const [error, setError] =
|
|
2415
|
-
const [data, setData] =
|
|
2416
|
-
const settledRef =
|
|
2417
|
-
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 () => {
|
|
2418
3731
|
setLoading(true);
|
|
2419
3732
|
setError(null);
|
|
2420
3733
|
await wait(latencyMs);
|
|
@@ -2425,14 +3738,14 @@ function useMockErpApi(options = {}) {
|
|
|
2425
3738
|
}
|
|
2426
3739
|
setLoading(false);
|
|
2427
3740
|
}, [latencyMs, errorRate]);
|
|
2428
|
-
|
|
3741
|
+
$e$1.useEffect(() => {
|
|
2429
3742
|
if (settledRef.current) {
|
|
2430
3743
|
return;
|
|
2431
3744
|
}
|
|
2432
3745
|
settledRef.current = true;
|
|
2433
3746
|
void refresh();
|
|
2434
3747
|
}, [refresh]);
|
|
2435
|
-
const writeWith =
|
|
3748
|
+
const writeWith = $e$1.useCallback(
|
|
2436
3749
|
async (key, item) => {
|
|
2437
3750
|
await wait(latencyMs);
|
|
2438
3751
|
if (Math.random() < errorRate) {
|
|
@@ -2451,7 +3764,7 @@ function useMockErpApi(options = {}) {
|
|
|
2451
3764
|
},
|
|
2452
3765
|
[latencyMs, errorRate]
|
|
2453
3766
|
);
|
|
2454
|
-
return
|
|
3767
|
+
return $e$1.useMemo(
|
|
2455
3768
|
() => ({
|
|
2456
3769
|
loading,
|
|
2457
3770
|
error,
|
|
@@ -2470,7 +3783,7 @@ function useMockErpApi(options = {}) {
|
|
|
2470
3783
|
[loading, error, data, refresh, writeWith]
|
|
2471
3784
|
);
|
|
2472
3785
|
}
|
|
2473
|
-
const NiceVatTable = /* @__PURE__ */
|
|
3786
|
+
const NiceVatTable = /* @__PURE__ */ $e$1.forwardRef(
|
|
2474
3787
|
function NiceVatTable2({
|
|
2475
3788
|
country = "PL",
|
|
2476
3789
|
rates,
|
|
@@ -2484,17 +3797,18 @@ const NiceVatTable = /* @__PURE__ */ ve.forwardRef(
|
|
|
2484
3797
|
style,
|
|
2485
3798
|
id
|
|
2486
3799
|
}, ref) {
|
|
2487
|
-
const
|
|
3800
|
+
const { t } = v();
|
|
3801
|
+
const [internal, setInternal] = $e$1.useState(rates ?? NICE_VAT_PRESETS[country]);
|
|
2488
3802
|
const L = {
|
|
2489
3803
|
code: "Code",
|
|
2490
3804
|
rate: "Rate",
|
|
2491
|
-
label: "Label",
|
|
2492
|
-
description: "Description",
|
|
3805
|
+
label: t("vatTable.label", "Label"),
|
|
3806
|
+
description: t("vatTable.description", "Description"),
|
|
2493
3807
|
add: "+ Add",
|
|
2494
3808
|
remove: "Remove",
|
|
2495
3809
|
...labels
|
|
2496
3810
|
};
|
|
2497
|
-
const update =
|
|
3811
|
+
const update = $e$1.useCallback(
|
|
2498
3812
|
(next) => {
|
|
2499
3813
|
setInternal(next);
|
|
2500
3814
|
onChange == null ? void 0 : onChange(next);
|
|
@@ -2521,7 +3835,7 @@ const NiceVatTable = /* @__PURE__ */ ve.forwardRef(
|
|
|
2521
3835
|
};
|
|
2522
3836
|
const removeRow = (idx) => {
|
|
2523
3837
|
const code = internal[idx].code;
|
|
2524
|
-
const next = internal.filter((
|
|
3838
|
+
const next = internal.filter((_2, i2) => i2 !== idx);
|
|
2525
3839
|
update(next);
|
|
2526
3840
|
onRemove == null ? void 0 : onRemove(code);
|
|
2527
3841
|
};
|
|
@@ -2574,7 +3888,7 @@ const NiceVatTable = /* @__PURE__ */ ve.forwardRef(
|
|
|
2574
3888
|
onChange: (e) => onCellEdit(idx, "description", e.target.value)
|
|
2575
3889
|
}
|
|
2576
3890
|
) : r.description ?? "" }),
|
|
2577
|
-
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 }) }) })
|
|
2578
3892
|
] }, r.code)) })
|
|
2579
3893
|
] }),
|
|
2580
3894
|
editable && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "nice-vat-table__add", onClick: addRow, children: L.add })
|
|
@@ -2636,7 +3950,7 @@ function defaultBuildXml(opts) {
|
|
|
2636
3950
|
lines.push("</JPK>");
|
|
2637
3951
|
return lines.join("\n");
|
|
2638
3952
|
}
|
|
2639
|
-
const NiceJpkExporter = /* @__PURE__ */
|
|
3953
|
+
const NiceJpkExporter = /* @__PURE__ */ $e$1.forwardRef(
|
|
2640
3954
|
function NiceJpkExporter2({
|
|
2641
3955
|
invoices = EMPTY_INVOICES,
|
|
2642
3956
|
taxpayer,
|
|
@@ -2650,12 +3964,13 @@ const NiceJpkExporter = /* @__PURE__ */ ve.forwardRef(
|
|
|
2650
3964
|
style,
|
|
2651
3965
|
id
|
|
2652
3966
|
}, ref) {
|
|
3967
|
+
const { t } = v();
|
|
2653
3968
|
const today = /* @__PURE__ */ new Date();
|
|
2654
|
-
const [format, setFormat] =
|
|
2655
|
-
const [from, setFrom] =
|
|
3969
|
+
const [format, setFormat] = $e$1.useState(defaultFormat);
|
|
3970
|
+
const [from, setFrom] = $e$1.useState(
|
|
2656
3971
|
isoDate((defaultPeriod == null ? void 0 : defaultPeriod.from) ?? new Date(today.getFullYear(), today.getMonth(), 1))
|
|
2657
3972
|
);
|
|
2658
|
-
const [to, setTo] =
|
|
3973
|
+
const [to, setTo] = $e$1.useState(
|
|
2659
3974
|
isoDate((defaultPeriod == null ? void 0 : defaultPeriod.to) ?? new Date(today.getFullYear(), today.getMonth() + 1, 0))
|
|
2660
3975
|
);
|
|
2661
3976
|
const L = {
|
|
@@ -2665,7 +3980,7 @@ const NiceJpkExporter = /* @__PURE__ */ ve.forwardRef(
|
|
|
2665
3980
|
export: "Export",
|
|
2666
3981
|
...labels
|
|
2667
3982
|
};
|
|
2668
|
-
const exportNow =
|
|
3983
|
+
const exportNow = $e$1.useCallback(() => {
|
|
2669
3984
|
const opts = {
|
|
2670
3985
|
format,
|
|
2671
3986
|
period: { from: new Date(from), to: new Date(to) },
|
|
@@ -2712,10 +4027,10 @@ const NiceJpkExporter = /* @__PURE__ */ ve.forwardRef(
|
|
|
2712
4027
|
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "date", value: to, onChange: (e) => setTo(e.target.value) })
|
|
2713
4028
|
] }),
|
|
2714
4029
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: exportNow, children: L.export }),
|
|
2715
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2716
|
-
invoices
|
|
2717
|
-
|
|
2718
|
-
|
|
4030
|
+
/* @__PURE__ */ jsxRuntime.jsx("small", { children: t("jpkExporter.invoicesReady", "{invoices} invoices ready").replace(
|
|
4031
|
+
"{invoices}",
|
|
4032
|
+
String(invoices.length)
|
|
4033
|
+
) })
|
|
2719
4034
|
] });
|
|
2720
4035
|
}
|
|
2721
4036
|
);
|