@nxgt/material 3.105.0 → 3.107.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/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/dist/components/ui/collections/data-table/data-table-items-tiles.css +14 -0
- package/dist/components/ui/collections/data-table/data-table-items.css +22 -0
- package/dist/{components-Cn14BksP.js → components-xpdWhhI5.js} +51 -45
- package/dist/components.js +1 -1
- package/dist/keypad.js +224 -207
- package/dist/lib/components/ui/actions/product-tile/product-tile-parts.d.ts +12 -0
- package/dist/lib/components/ui/actions/product-tile/product-tile.d.ts +7 -1
- package/dist/lib/components/ui/collections/data-table/layout-types.d.ts +14 -0
- package/dist/lib/components/ui/collections/data-table/types.d.ts +2 -3
- package/dist/lib/components/ui/widgets/keypad/keypad-above.d.ts +14 -0
- package/dist/lib/components/ui/widgets/keypad/keypad-display.d.ts +3 -1
- package/dist/lib/components/ui/widgets/keypad/keypad.types.d.ts +9 -2
- package/dist/main.js +1 -1
- package/dist/material.css +1 -1
- package/docs/components/buttons-and-actions.md +8 -1
- package/docs/components/data-table-filter-and-lists.md +1 -0
- package/docs/guides/cards-and-tiles.md +20 -0
- package/docs/guides/keypad.md +20 -6
- package/lib/components/ui/collections/data-table/data-table-items-tiles.css +14 -0
- package/lib/components/ui/collections/data-table/data-table-items.css +22 -0
- package/lib/components/ui/widgets/calculator/calculator.css +71 -6
- package/package.json +1 -1
package/dist/keypad.js
CHANGED
|
@@ -6,157 +6,26 @@ import { i as a, o, r as s, t as c } from "./key-layout-D2goCDkD.js";
|
|
|
6
6
|
import { useCallback as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
7
7
|
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
8
8
|
import { currencyFractionDigits as g } from "@nxgt/material-core/currency-digits";
|
|
9
|
-
import { EMPTY_SESSION as _, ZERO as v, announcement as
|
|
10
|
-
import { billShortcuts as
|
|
11
|
-
//#region lib/components/ui/widgets/keypad/keypad-entry.ts
|
|
12
|
-
var j = {
|
|
13
|
-
add: "+",
|
|
14
|
-
subtract: "-",
|
|
15
|
-
multiply: "*",
|
|
16
|
-
divide: "/"
|
|
17
|
-
}, M = [
|
|
18
|
-
"add",
|
|
19
|
-
"subtract",
|
|
20
|
-
"multiply",
|
|
21
|
-
"divide"
|
|
22
|
-
];
|
|
23
|
-
function N(e) {
|
|
24
|
-
return e === !0 ? M : e ? M.filter((t) => e.includes(t)) : [];
|
|
25
|
-
}
|
|
26
|
-
function P(e) {
|
|
27
|
-
return e.entry === "minor" || e.variant === "cash" ? [] : N(e.operations);
|
|
28
|
-
}
|
|
29
|
-
var F = (e) => j[e];
|
|
30
|
-
function I(e) {
|
|
31
|
-
let t = C(e);
|
|
32
|
-
return t ? {
|
|
33
|
-
..._,
|
|
34
|
-
expression: E(t)
|
|
35
|
-
} : _;
|
|
36
|
-
}
|
|
37
|
-
function L(e) {
|
|
38
|
-
let t = C(e.justEvaluated && e.result ? e.result : e.expression);
|
|
39
|
-
return t ? E(t) : "";
|
|
40
|
-
}
|
|
41
|
-
var R = (e) => !e.justEvaluated && e.expression !== "" && C(e.expression) == null, ne = (e) => /\.(\d*)$/.exec(e)?.[1]?.length ?? 0;
|
|
42
|
-
function z(e, t) {
|
|
43
|
-
if (t === void 0 || e.justEvaluated) return !1;
|
|
44
|
-
let n = C(e.expression);
|
|
45
|
-
return n != null && b(n, C(String(t)) ?? v) > 0;
|
|
46
|
-
}
|
|
47
|
-
var re = (e, t) => O(C(L(e)) ?? v, t);
|
|
48
|
-
function ie(e, t, n, r) {
|
|
49
|
-
if (!/^(?:\d|00|backspace|C|CE)$/.test(t)) return e;
|
|
50
|
-
let i = t === "C" || t === "CE" ? "clear" : t, a = k(re(e, r), i), o = {
|
|
51
|
-
..._,
|
|
52
|
-
expression: a === 0n ? "" : E(A(a, r))
|
|
53
|
-
};
|
|
54
|
-
return z(o, n.max) ? e : o;
|
|
55
|
-
}
|
|
56
|
-
function ae(e, t, n) {
|
|
57
|
-
if (n.entry === "minor") return ie(e, t, n, n.digits ?? 2);
|
|
58
|
-
if (t === "." && n.digits === 0) return e;
|
|
59
|
-
let r = Object.keys(j).find((e) => j[e] === t);
|
|
60
|
-
if (r && !n.operations.includes(r) || !r && !/^(?:\d|00|\.|=|backspace|C|CE)$/.test(t)) return e;
|
|
61
|
-
let i = r && e.justEvaluated && e.result ? {
|
|
62
|
-
...I(e.result),
|
|
63
|
-
ans: e.ans,
|
|
64
|
-
memory: e.memory
|
|
65
|
-
} : e, a = w(i, t);
|
|
66
|
-
if (a === i || n.digits !== void 0 && ne(a.expression) > n.digits || z(a, n.max)) return e;
|
|
67
|
-
let o = a.justEvaluated ? C(a.result) : void 0;
|
|
68
|
-
if (o && n.digits !== void 0) {
|
|
69
|
-
let e = E(T(o, n.digits, "half-up"));
|
|
70
|
-
return {
|
|
71
|
-
...a,
|
|
72
|
-
result: e,
|
|
73
|
-
ans: e
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
return a;
|
|
77
|
-
}
|
|
78
|
-
function B(e, t, n) {
|
|
79
|
-
let r = C(e);
|
|
80
|
-
if (!r) return "";
|
|
81
|
-
let i = t === void 0 ? void 0 : C(String(t)), a = n === void 0 ? void 0 : C(String(n));
|
|
82
|
-
return i && b(r, i) < 0 && (r = i), a && b(r, a) > 0 && (r = a), E(r);
|
|
83
|
-
}
|
|
84
|
-
function V(e, t) {
|
|
85
|
-
if (R(e)) return;
|
|
86
|
-
let n = L(e);
|
|
87
|
-
return n === t ? void 0 : n;
|
|
88
|
-
}
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region lib/components/ui/widgets/keypad/keypad-binding.ts
|
|
91
|
-
var H = 2;
|
|
92
|
-
function U(e) {
|
|
93
|
-
return e.currency ? g(e.currency, e.fractionDigits) : e.fractionDigits ?? (e.minorUnits ? H : void 0);
|
|
94
|
-
}
|
|
95
|
-
function W(e, t) {
|
|
96
|
-
if (e == null || !Number.isFinite(e)) return "";
|
|
97
|
-
if (t.minorUnits) return E(A(BigInt(Math.trunc(e)), t.digits ?? H));
|
|
98
|
-
let n = C(String(e));
|
|
99
|
-
return n ? E(n) : "";
|
|
100
|
-
}
|
|
101
|
-
function G(e, t) {
|
|
102
|
-
let n = C(e);
|
|
103
|
-
return n ? t.minorUnits ? Number(O(n, t.digits ?? H)) : Number(E(t.digits === void 0 ? n : T(n, t.digits, "half-up"))) : null;
|
|
104
|
-
}
|
|
105
|
-
var K = (e, t, n) => e === void 0 || !t.minorUnits ? e : Number(W(e, {
|
|
106
|
-
minorUnits: !0,
|
|
107
|
-
digits: n
|
|
108
|
-
}));
|
|
109
|
-
function q(e) {
|
|
110
|
-
let t = U(e);
|
|
111
|
-
return {
|
|
112
|
-
value: W(e.value, {
|
|
113
|
-
minorUnits: e.minorUnits,
|
|
114
|
-
digits: t
|
|
115
|
-
}),
|
|
116
|
-
onValueChange: (n) => e.onChange?.(G(n, {
|
|
117
|
-
minorUnits: e.minorUnits,
|
|
118
|
-
digits: t
|
|
119
|
-
})),
|
|
120
|
-
fractionDigits: t,
|
|
121
|
-
min: K(e.min, e, t),
|
|
122
|
-
max: K(e.max, e, t)
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function oe(e) {
|
|
126
|
-
let t = e.binding;
|
|
127
|
-
if (!t) return e;
|
|
128
|
-
let { onValueChange: n } = e;
|
|
129
|
-
return {
|
|
130
|
-
...e,
|
|
131
|
-
value: e.value ?? t.value,
|
|
132
|
-
fractionDigits: e.fractionDigits ?? t.fractionDigits,
|
|
133
|
-
min: e.min ?? t.min,
|
|
134
|
-
max: e.max ?? t.max,
|
|
135
|
-
display: e.display ?? P(e).length > 0,
|
|
136
|
-
onValueChange: (e) => {
|
|
137
|
-
t.onValueChange(e), n?.(e);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
9
|
+
import { EMPTY_SESSION as _, ZERO as v, announcement as ee, compare as y, formatDecimal as b, formatExpression as x, localeSeparators as te, parseDecimal as S, press as C, roundTo as w, toCanonical as T } from "@nxgt/material-core/calculator";
|
|
10
|
+
import { billShortcuts as E, decimalToMinor as D, enterMinor as O, minorToDecimal as k, settle as A } from "@nxgt/material-core/calculator/pos";
|
|
142
11
|
//#region lib/components/ui/widgets/keypad/keypad-display.tsx
|
|
143
|
-
function
|
|
144
|
-
let r =
|
|
145
|
-
return r ?
|
|
12
|
+
function j(e, t, n) {
|
|
13
|
+
let r = S(e);
|
|
14
|
+
return r ? b(r, {
|
|
146
15
|
locale: n,
|
|
147
16
|
fractionDigits: t ?? 2
|
|
148
17
|
}) : e;
|
|
149
18
|
}
|
|
150
|
-
function
|
|
151
|
-
if (t === "minor") return
|
|
152
|
-
let a =
|
|
153
|
-
return i ?
|
|
19
|
+
function ne(e, t, n, r, i) {
|
|
20
|
+
if (t === "minor") return S(e || "0") ? j(e || "0", n, r) : "";
|
|
21
|
+
let a = x(e, { locale: r });
|
|
22
|
+
return i ? N(a || "0", i, r) : a;
|
|
154
23
|
}
|
|
155
|
-
function
|
|
156
|
-
let i =
|
|
157
|
-
return r ?
|
|
24
|
+
function M(e, t, n, r) {
|
|
25
|
+
let i = j(e, t, n);
|
|
26
|
+
return r ? N(i, r, n) : i;
|
|
158
27
|
}
|
|
159
|
-
function
|
|
28
|
+
function N(e, t, n) {
|
|
160
29
|
let r = [];
|
|
161
30
|
try {
|
|
162
31
|
r = new Intl.NumberFormat(n, {
|
|
@@ -167,21 +36,25 @@ function X(e, t, n) {
|
|
|
167
36
|
let i = r.findIndex((e) => e.type === "currency"), a = i >= 0 && i < r.findIndex((e) => e.type === "integer"), o = r[i]?.value ?? t, s = r[a ? i + 1 : i - 1], c = i < 0 ? "\xA0" : s?.type === "literal" ? s.value : "", l = r.findIndex((e) => e.type === "minusSign");
|
|
168
37
|
return a && /^[-\u2212]/u.test(e) && (l < 0 || l < i) ? `${e[0]}${o}${c}${e.slice(1)}` : a ? `${o}${c}${e}` : `${e}${c}${o}`;
|
|
169
38
|
}
|
|
170
|
-
function
|
|
171
|
-
let
|
|
39
|
+
function P({ keypad: e, locale: t, currency: n, placeholder: r }) {
|
|
40
|
+
let i = e.session.justEvaluated && e.value ? e.value : e.session.expression, a = !i && !e.session.error ? r : void 0, o = a ? "" : ne(i, e.entry, e.digits, t, n);
|
|
172
41
|
return /* @__PURE__ */ m("output", {
|
|
173
42
|
"data-slot": "keypad-display",
|
|
174
43
|
"data-kind": e.session.error ? "error" : void 0,
|
|
175
44
|
"aria-live": "off",
|
|
176
45
|
dir: "ltr",
|
|
177
46
|
className: "nxgt-keypad-display bg-muted",
|
|
178
|
-
children:
|
|
47
|
+
children: o || (a ? /* @__PURE__ */ m("span", {
|
|
48
|
+
"data-placeholder": "",
|
|
49
|
+
"aria-hidden": "true",
|
|
50
|
+
children: a
|
|
51
|
+
}) : "\xA0")
|
|
179
52
|
});
|
|
180
53
|
}
|
|
181
54
|
//#endregion
|
|
182
55
|
//#region lib/components/ui/widgets/keypad/keypad-cash.tsx
|
|
183
|
-
function
|
|
184
|
-
let { t: o } = t(), s = (e) =>
|
|
56
|
+
function F({ total: e, settlement: n, digits: r, locale: i, currency: a }) {
|
|
57
|
+
let { t: o } = t(), s = (e) => M(e, r, i, a);
|
|
185
58
|
return /* @__PURE__ */ h("dl", {
|
|
186
59
|
"data-slot": "keypad-cash-summary",
|
|
187
60
|
className: "nxgt-keypad-cash",
|
|
@@ -197,7 +70,7 @@ function le({ total: e, settlement: n, digits: r, locale: i, currency: a }) {
|
|
|
197
70
|
}) : null]
|
|
198
71
|
});
|
|
199
72
|
}
|
|
200
|
-
function
|
|
73
|
+
function re({ amounts: e, onPick: n, disabled: r, digits: i, locale: a, currency: o }) {
|
|
201
74
|
let { t: s } = t();
|
|
202
75
|
return e.length === 0 ? null : /* @__PURE__ */ m("div", {
|
|
203
76
|
role: "group",
|
|
@@ -205,7 +78,7 @@ function ue({ amounts: e, onPick: n, disabled: r, digits: i, locale: a, currency
|
|
|
205
78
|
"data-slot": "keypad-shortcuts",
|
|
206
79
|
className: "nxgt-keypad-shortcuts",
|
|
207
80
|
children: e.map((e) => {
|
|
208
|
-
let t =
|
|
81
|
+
let t = M(e, i, a, o);
|
|
209
82
|
return /* @__PURE__ */ m("button", {
|
|
210
83
|
type: "button",
|
|
211
84
|
"aria-disabled": r ? !0 : void 0,
|
|
@@ -219,17 +92,17 @@ function ue({ amounts: e, onPick: n, disabled: r, digits: i, locale: a, currency
|
|
|
219
92
|
})
|
|
220
93
|
});
|
|
221
94
|
}
|
|
222
|
-
function
|
|
95
|
+
function ie({ cash: e, total: t, onPick: n, disabled: r, digits: i, locale: a, currency: o }) {
|
|
223
96
|
let s = {
|
|
224
97
|
digits: i,
|
|
225
98
|
locale: a,
|
|
226
99
|
currency: o
|
|
227
100
|
};
|
|
228
|
-
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(
|
|
101
|
+
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(F, {
|
|
229
102
|
...s,
|
|
230
103
|
total: t,
|
|
231
104
|
settlement: e.settlement
|
|
232
|
-
}), /* @__PURE__ */ m(
|
|
105
|
+
}), /* @__PURE__ */ m(re, {
|
|
233
106
|
...s,
|
|
234
107
|
amounts: e.shortcuts,
|
|
235
108
|
onPick: n,
|
|
@@ -237,6 +110,155 @@ function de({ cash: e, total: t, onPick: n, disabled: r, digits: i, locale: a, c
|
|
|
237
110
|
})] });
|
|
238
111
|
}
|
|
239
112
|
//#endregion
|
|
113
|
+
//#region lib/components/ui/widgets/keypad/keypad-above.tsx
|
|
114
|
+
function ae({ keypad: e, cash: t, display: n, disabled: r, locale: i, currency: a, placeholder: o }) {
|
|
115
|
+
return /* @__PURE__ */ h(p, { children: [n ? /* @__PURE__ */ m(P, {
|
|
116
|
+
keypad: e,
|
|
117
|
+
locale: i,
|
|
118
|
+
currency: a,
|
|
119
|
+
placeholder: o
|
|
120
|
+
}) : null, t.cash ? /* @__PURE__ */ m(ie, {
|
|
121
|
+
cash: t,
|
|
122
|
+
total: t.total ?? "0",
|
|
123
|
+
onPick: e.set,
|
|
124
|
+
disabled: r,
|
|
125
|
+
digits: e.digits,
|
|
126
|
+
locale: i,
|
|
127
|
+
currency: a
|
|
128
|
+
}) : null] });
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region lib/components/ui/widgets/keypad/keypad-entry.ts
|
|
132
|
+
var I = {
|
|
133
|
+
add: "+",
|
|
134
|
+
subtract: "-",
|
|
135
|
+
multiply: "*",
|
|
136
|
+
divide: "/"
|
|
137
|
+
}, L = [
|
|
138
|
+
"add",
|
|
139
|
+
"subtract",
|
|
140
|
+
"multiply",
|
|
141
|
+
"divide"
|
|
142
|
+
];
|
|
143
|
+
function oe(e) {
|
|
144
|
+
return e === !0 ? L : e ? L.filter((t) => e.includes(t)) : [];
|
|
145
|
+
}
|
|
146
|
+
function R(e) {
|
|
147
|
+
return e.entry === "minor" || e.variant === "cash" ? [] : oe(e.operations);
|
|
148
|
+
}
|
|
149
|
+
var z = (e) => I[e];
|
|
150
|
+
function B(e) {
|
|
151
|
+
let t = S(e);
|
|
152
|
+
return t ? {
|
|
153
|
+
..._,
|
|
154
|
+
expression: T(t)
|
|
155
|
+
} : _;
|
|
156
|
+
}
|
|
157
|
+
function V(e) {
|
|
158
|
+
let t = S(e.justEvaluated && e.result ? e.result : e.expression);
|
|
159
|
+
return t ? T(t) : "";
|
|
160
|
+
}
|
|
161
|
+
var H = (e) => !e.justEvaluated && e.expression !== "" && S(e.expression) == null, U = (e) => /\.(\d*)$/.exec(e)?.[1]?.length ?? 0;
|
|
162
|
+
function W(e, t) {
|
|
163
|
+
if (t === void 0 || e.justEvaluated) return !1;
|
|
164
|
+
let n = S(e.expression);
|
|
165
|
+
return n != null && y(n, S(String(t)) ?? v) > 0;
|
|
166
|
+
}
|
|
167
|
+
var G = (e, t) => D(S(V(e)) ?? v, t);
|
|
168
|
+
function K(e, t, n, r) {
|
|
169
|
+
if (!/^(?:\d|00|backspace|C|CE)$/.test(t)) return e;
|
|
170
|
+
let i = t === "C" || t === "CE" ? "clear" : t, a = O(G(e, r), i), o = {
|
|
171
|
+
..._,
|
|
172
|
+
expression: a === 0n ? "" : T(k(a, r))
|
|
173
|
+
};
|
|
174
|
+
return W(o, n.max) ? e : o;
|
|
175
|
+
}
|
|
176
|
+
function se(e, t, n) {
|
|
177
|
+
if (n.entry === "minor") return K(e, t, n, n.digits ?? 2);
|
|
178
|
+
if (t === "." && n.digits === 0) return e;
|
|
179
|
+
let r = Object.keys(I).find((e) => I[e] === t);
|
|
180
|
+
if (r && !n.operations.includes(r) || !r && !/^(?:\d|00|\.|=|backspace|C|CE)$/.test(t)) return e;
|
|
181
|
+
let i = r && e.justEvaluated && e.result ? {
|
|
182
|
+
...B(e.result),
|
|
183
|
+
ans: e.ans,
|
|
184
|
+
memory: e.memory
|
|
185
|
+
} : e, a = C(i, t);
|
|
186
|
+
if (a === i || n.digits !== void 0 && U(a.expression) > n.digits || W(a, n.max)) return e;
|
|
187
|
+
let o = a.justEvaluated ? S(a.result) : void 0;
|
|
188
|
+
if (o && n.digits !== void 0) {
|
|
189
|
+
let e = T(w(o, n.digits, "half-up"));
|
|
190
|
+
return {
|
|
191
|
+
...a,
|
|
192
|
+
result: e,
|
|
193
|
+
ans: e
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return a;
|
|
197
|
+
}
|
|
198
|
+
function q(e, t, n) {
|
|
199
|
+
let r = S(e);
|
|
200
|
+
if (!r) return "";
|
|
201
|
+
let i = t === void 0 ? void 0 : S(String(t)), a = n === void 0 ? void 0 : S(String(n));
|
|
202
|
+
return i && y(r, i) < 0 && (r = i), a && y(r, a) > 0 && (r = a), T(r);
|
|
203
|
+
}
|
|
204
|
+
function ce(e, t) {
|
|
205
|
+
if (H(e)) return;
|
|
206
|
+
let n = V(e);
|
|
207
|
+
return n === t ? void 0 : n;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region lib/components/ui/widgets/keypad/keypad-binding.ts
|
|
211
|
+
var J = 2;
|
|
212
|
+
function le(e) {
|
|
213
|
+
return e.currency ? g(e.currency, e.fractionDigits) : e.fractionDigits ?? (e.minorUnits ? J : void 0);
|
|
214
|
+
}
|
|
215
|
+
function Y(e, t) {
|
|
216
|
+
if (e == null || !Number.isFinite(e)) return "";
|
|
217
|
+
if (t.minorUnits) return T(k(BigInt(Math.trunc(e)), t.digits ?? J));
|
|
218
|
+
let n = S(String(e));
|
|
219
|
+
return n ? T(n) : "";
|
|
220
|
+
}
|
|
221
|
+
function ue(e, t) {
|
|
222
|
+
let n = S(e);
|
|
223
|
+
return n ? t.minorUnits ? Number(D(n, t.digits ?? J)) : Number(T(t.digits === void 0 ? n : w(n, t.digits, "half-up"))) : null;
|
|
224
|
+
}
|
|
225
|
+
var X = (e, t, n) => e === void 0 || !t.minorUnits ? e : Number(Y(e, {
|
|
226
|
+
minorUnits: !0,
|
|
227
|
+
digits: n
|
|
228
|
+
}));
|
|
229
|
+
function Z(e) {
|
|
230
|
+
let t = le(e);
|
|
231
|
+
return {
|
|
232
|
+
value: Y(e.value, {
|
|
233
|
+
minorUnits: e.minorUnits,
|
|
234
|
+
digits: t
|
|
235
|
+
}),
|
|
236
|
+
onValueChange: (n) => e.onChange?.(ue(n, {
|
|
237
|
+
minorUnits: e.minorUnits,
|
|
238
|
+
digits: t
|
|
239
|
+
})),
|
|
240
|
+
fractionDigits: t,
|
|
241
|
+
min: X(e.min, e, t),
|
|
242
|
+
max: X(e.max, e, t)
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function de(e) {
|
|
246
|
+
let t = e.binding;
|
|
247
|
+
if (!t) return e;
|
|
248
|
+
let { onValueChange: n } = e;
|
|
249
|
+
return {
|
|
250
|
+
...e,
|
|
251
|
+
value: e.value ?? t.value,
|
|
252
|
+
fractionDigits: e.fractionDigits ?? t.fractionDigits,
|
|
253
|
+
min: e.min ?? t.min,
|
|
254
|
+
max: e.max ?? t.max,
|
|
255
|
+
display: e.display ?? R(e).length > 0,
|
|
256
|
+
onValueChange: (e) => {
|
|
257
|
+
t.onValueChange(e), n?.(e);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
240
262
|
//#region lib/components/ui/widgets/keypad/keypad-layout.ts
|
|
241
263
|
var fe = {
|
|
242
264
|
add: [
|
|
@@ -326,29 +348,29 @@ function pe(e) {
|
|
|
326
348
|
}
|
|
327
349
|
//#endregion
|
|
328
350
|
//#region lib/components/ui/widgets/keypad/cash-model.ts
|
|
329
|
-
function
|
|
351
|
+
function Q(e, t) {
|
|
330
352
|
if (e === void 0) return;
|
|
331
|
-
let n =
|
|
332
|
-
if (n) return
|
|
353
|
+
let n = S(String(e));
|
|
354
|
+
if (n) return T(t === void 0 ? n : w(n, t, "half-up"));
|
|
333
355
|
}
|
|
334
|
-
function
|
|
356
|
+
function $(e, t) {
|
|
335
357
|
if (!(e === void 0 || t === "")) try {
|
|
336
|
-
let n =
|
|
358
|
+
let n = A(e, t);
|
|
337
359
|
return n.status === "paid" ? {
|
|
338
360
|
status: "paid",
|
|
339
|
-
change:
|
|
361
|
+
change: T(n.change)
|
|
340
362
|
} : {
|
|
341
363
|
status: "short",
|
|
342
|
-
due:
|
|
364
|
+
due: T(n.due)
|
|
343
365
|
};
|
|
344
366
|
} catch {
|
|
345
367
|
return;
|
|
346
368
|
}
|
|
347
369
|
}
|
|
348
|
-
function
|
|
349
|
-
if (e === void 0 ||
|
|
370
|
+
function me(e, t, n, r, i = 4) {
|
|
371
|
+
if (e === void 0 || S(String(e)) == null) return [];
|
|
350
372
|
try {
|
|
351
|
-
let a = n === void 0 ? void 0 :
|
|
373
|
+
let a = n === void 0 ? void 0 : S(String(n)), o = E(e, t ?? [], { limit: i - 1 }).map((e) => r === void 0 ? e : w(e, r, "half-up")).filter((e) => !a || y(e, a) <= 0).map(T);
|
|
352
374
|
return [...new Set(o)];
|
|
353
375
|
} catch {
|
|
354
376
|
return [];
|
|
@@ -356,27 +378,27 @@ function $(e, t, n, r, i = 4) {
|
|
|
356
378
|
}
|
|
357
379
|
//#endregion
|
|
358
380
|
//#region lib/components/ui/widgets/keypad/use-keypad-value.ts
|
|
359
|
-
function
|
|
360
|
-
let [n, r] = f(() =>
|
|
361
|
-
if (
|
|
362
|
-
let t =
|
|
363
|
-
t !== i.current && (i.current = t, r(
|
|
381
|
+
function he(e, t) {
|
|
382
|
+
let [n, r] = f(() => B(e.value ?? e.defaultValue ?? "")), i = d("");
|
|
383
|
+
if (H(n) || (i.current = V(n)), e.value !== void 0) {
|
|
384
|
+
let t = V(B(e.value));
|
|
385
|
+
t !== i.current && (i.current = t, r(B(e.value)));
|
|
364
386
|
}
|
|
365
387
|
return {
|
|
366
388
|
session: n,
|
|
367
389
|
setInner: r,
|
|
368
390
|
report: l((e) => {
|
|
369
|
-
let n =
|
|
391
|
+
let n = ce(e, i.current);
|
|
370
392
|
n !== void 0 && (i.current = n, t.current?.(n));
|
|
371
393
|
}, [t])
|
|
372
394
|
};
|
|
373
395
|
}
|
|
374
396
|
//#endregion
|
|
375
397
|
//#region lib/components/ui/widgets/keypad/use-keypad.ts
|
|
376
|
-
function
|
|
377
|
-
let t = e.entry ?? "decimal", n = e.currency ? g(e.currency, e.fractionDigits) : e.fractionDigits, r =
|
|
398
|
+
function ge(e) {
|
|
399
|
+
let t = e.entry ?? "decimal", n = e.currency ? g(e.currency, e.fractionDigits) : e.fractionDigits, r = R(e), i = d(e.onValueChange);
|
|
378
400
|
i.current = e.onValueChange;
|
|
379
|
-
let { session: a, setInner: o, report: s } =
|
|
401
|
+
let { session: a, setInner: o, report: s } = he(e, i), c = {
|
|
380
402
|
entry: t,
|
|
381
403
|
digits: n,
|
|
382
404
|
operations: r,
|
|
@@ -394,21 +416,21 @@ function he(e) {
|
|
|
394
416
|
let f = l((e) => {
|
|
395
417
|
let { session: t, o: n, config: r } = u.current;
|
|
396
418
|
if (n.disabled) return;
|
|
397
|
-
let i =
|
|
419
|
+
let i = se(t, e, r);
|
|
398
420
|
i !== t && (o(i), s(i));
|
|
399
421
|
}, [s, o]), p = l(() => {
|
|
400
422
|
let { session: e, o: t, config: n } = u.current;
|
|
401
423
|
if (t.disabled) return;
|
|
402
|
-
if (
|
|
403
|
-
let r =
|
|
424
|
+
if (H(e)) return f("=");
|
|
425
|
+
let r = V(e);
|
|
404
426
|
if (r === "") return;
|
|
405
|
-
let i =
|
|
427
|
+
let i = q(r, t.min, t.max);
|
|
406
428
|
if (i !== r) {
|
|
407
|
-
let e =
|
|
429
|
+
let e = B(i);
|
|
408
430
|
o(e), s(e);
|
|
409
431
|
}
|
|
410
432
|
if (t.variant === "cash") {
|
|
411
|
-
let e = Q(
|
|
433
|
+
let e = $(Q(t.total, n.digits), i);
|
|
412
434
|
e && t.onTender?.(i, e);
|
|
413
435
|
return;
|
|
414
436
|
}
|
|
@@ -420,13 +442,13 @@ function he(e) {
|
|
|
420
442
|
]), m = l((e) => {
|
|
421
443
|
let { o: t } = u.current;
|
|
422
444
|
if (t.disabled) return;
|
|
423
|
-
let n =
|
|
445
|
+
let n = B(q(e, void 0, t.max));
|
|
424
446
|
o(n), s(n);
|
|
425
447
|
}, [s, o]);
|
|
426
448
|
return {
|
|
427
449
|
session: a,
|
|
428
|
-
value:
|
|
429
|
-
pending:
|
|
450
|
+
value: V(a),
|
|
451
|
+
pending: H(a),
|
|
430
452
|
digits: n,
|
|
431
453
|
entry: t,
|
|
432
454
|
operations: r,
|
|
@@ -437,8 +459,8 @@ function he(e) {
|
|
|
437
459
|
}
|
|
438
460
|
//#endregion
|
|
439
461
|
//#region lib/components/ui/widgets/keypad/use-keypad-cash.ts
|
|
440
|
-
function
|
|
441
|
-
let { t: r } = t(), i = e.variant === "cash", a = i ?
|
|
462
|
+
function _e(e, n) {
|
|
463
|
+
let { t: r } = t(), i = e.variant === "cash", a = i ? Q(e.total, n.digits) : void 0, o = i ? $(a, n.value) : void 0, s = u(() => i ? me(a, e.denominations, e.max, n.digits) : [], [
|
|
442
464
|
i,
|
|
443
465
|
a,
|
|
444
466
|
e.denominations,
|
|
@@ -446,7 +468,7 @@ function ge(e, n) {
|
|
|
446
468
|
n.digits
|
|
447
469
|
]), c;
|
|
448
470
|
if (o) {
|
|
449
|
-
let t = (t) =>
|
|
471
|
+
let t = (t) => M(t, n.digits, e.locale, e.currency);
|
|
450
472
|
c = o.status === "paid" ? r("material.keypad.change", "Change {amount}", { amount: t(o.change) }) : r("material.keypad.due", "Still due {amount}", { amount: t(o.due) });
|
|
451
473
|
}
|
|
452
474
|
return {
|
|
@@ -459,19 +481,19 @@ function ge(e, n) {
|
|
|
459
481
|
}
|
|
460
482
|
//#endregion
|
|
461
483
|
//#region lib/components/ui/widgets/keypad/use-keypad-keyboard.ts
|
|
462
|
-
function
|
|
484
|
+
function ve(e, t, n) {
|
|
463
485
|
return i({
|
|
464
486
|
locale: t,
|
|
465
487
|
global: n,
|
|
466
|
-
accepts: (t) => /^(?:\d|00|\.|=|backspace|C|CE)$/.test(t) || e.operations.some((e) =>
|
|
488
|
+
accepts: (t) => /^(?:\d|00|\.|=|backspace|C|CE)$/.test(t) || e.operations.some((e) => z(e) === t),
|
|
467
489
|
onKey: (t) => t === "=" ? e.commit() : e.press(t),
|
|
468
490
|
onCopy: () => {}
|
|
469
491
|
});
|
|
470
492
|
}
|
|
471
493
|
//#endregion
|
|
472
494
|
//#region lib/components/ui/widgets/keypad/keypad.tsx
|
|
473
|
-
function
|
|
474
|
-
let o =
|
|
495
|
+
function ye(i) {
|
|
496
|
+
let o = de(i), { locale: s, currency: c, commitLabel: l, disabled: d, keyboard: f = "focus", size: p = "comfortable", display: g = !0, label: _, placeholder: v, className: y } = o, { t: b } = t(), x = ge(o), S = _e(o, x), C = u(() => pe({
|
|
475
497
|
operations: x.operations,
|
|
476
498
|
decimal: x.entry === "decimal" && x.digits !== 0,
|
|
477
499
|
commitLabel: l,
|
|
@@ -484,34 +506,29 @@ function ve(i) {
|
|
|
484
506
|
l,
|
|
485
507
|
x.pending,
|
|
486
508
|
S.cash
|
|
487
|
-
]), w =
|
|
509
|
+
]), w = ve(x, s, f === "global"), T = ee(x.session, s);
|
|
488
510
|
return /* @__PURE__ */ m("div", {
|
|
489
511
|
"data-slot": "keypad",
|
|
490
512
|
"data-size": p,
|
|
491
513
|
"data-disabled": d ? "" : void 0,
|
|
492
|
-
className: e("nxgt-calc nxgt-keypad",
|
|
514
|
+
className: e("nxgt-calc nxgt-keypad", y),
|
|
493
515
|
onKeyDown: f === "focus" ? w : void 0,
|
|
494
516
|
children: /* @__PURE__ */ h("div", {
|
|
495
517
|
className: "nxgt-calc-body nxgt-keypad-body",
|
|
496
518
|
children: [
|
|
497
|
-
|
|
519
|
+
/* @__PURE__ */ m(ae, {
|
|
498
520
|
keypad: x,
|
|
499
|
-
locale: s,
|
|
500
|
-
currency: c
|
|
501
|
-
}) : null,
|
|
502
|
-
S.cash ? /* @__PURE__ */ m(de, {
|
|
503
521
|
cash: S,
|
|
504
|
-
|
|
505
|
-
onPick: x.set,
|
|
522
|
+
display: g,
|
|
506
523
|
disabled: d,
|
|
507
|
-
digits: x.digits,
|
|
508
524
|
locale: s,
|
|
509
|
-
currency: c
|
|
510
|
-
|
|
525
|
+
currency: c,
|
|
526
|
+
placeholder: v
|
|
527
|
+
}),
|
|
511
528
|
/* @__PURE__ */ m(r, {
|
|
512
529
|
layout: C,
|
|
513
530
|
label: _ ?? b("material.calculator.keypad", "Keypad"),
|
|
514
|
-
decimal:
|
|
531
|
+
decimal: te(s).decimal,
|
|
515
532
|
unavailable: () => d === !0,
|
|
516
533
|
onPress: (e) => {
|
|
517
534
|
if (e.id === "commit") x.commit();
|
|
@@ -531,14 +548,14 @@ function ve(i) {
|
|
|
531
548
|
}
|
|
532
549
|
//#endregion
|
|
533
550
|
//#region lib/components/ui/widgets/keypad/use-keypad-number.ts
|
|
534
|
-
function
|
|
535
|
-
return
|
|
551
|
+
function be(e) {
|
|
552
|
+
return Z(e);
|
|
536
553
|
}
|
|
537
554
|
//#endregion
|
|
538
555
|
//#region lib/components/ui/widgets/keypad/use-keypad-quantity.ts
|
|
539
|
-
function
|
|
556
|
+
function xe(e) {
|
|
540
557
|
let { value: t, onChange: n } = e;
|
|
541
|
-
return
|
|
558
|
+
return Z({
|
|
542
559
|
...e,
|
|
543
560
|
value: t?.value,
|
|
544
561
|
onChange: (e) => n?.({
|
|
@@ -548,4 +565,4 @@ function be(e) {
|
|
|
548
565
|
});
|
|
549
566
|
}
|
|
550
567
|
//#endregion
|
|
551
|
-
export {
|
|
568
|
+
export { ye as Keypad, be as useKeypadNumber, xe as useKeypadQuantity };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ProductTileProps } from './product-tile.js';
|
|
3
|
+
export declare function ProductTileBody({ picture, title, price, status, size, }: {
|
|
4
|
+
size: 'sm' | 'md';
|
|
5
|
+
picture: ReactNode;
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
price?: ReactNode;
|
|
8
|
+
status?: ReactNode;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
export declare function ProductTileMedia({ image, imageFit, icon, tone, shape, size, }: Pick<ProductTileProps, 'image' | 'icon'> & Required<Pick<ProductTileProps, 'tone' | 'shape' | 'size'>> & {
|
|
11
|
+
imageFit: 'contain' | 'cover';
|
|
12
|
+
}): import("react").JSX.Element | null;
|
|
@@ -28,6 +28,12 @@ export type ProductTileProps = Omit<ComponentProps<'button'>, 'title'> & {
|
|
|
28
28
|
shape?: ShapeName;
|
|
29
29
|
/** The item is in the basket or chosen: `aria-pressed`, a tint and a bar at the start. */
|
|
30
30
|
selected?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* `md` (default) is the roomy tile for 2 to 4 columns. `sm` is the compact tile for a dense grid
|
|
33
|
+
* (`minItem` near 9rem, 6 to 7 columns on a desktop): a 3:2 media box, tighter padding and smaller
|
|
34
|
+
* type. Both keep the 44 px target and the accessible name.
|
|
35
|
+
*/
|
|
36
|
+
size?: 'sm' | 'md';
|
|
31
37
|
/** Render the tile inside the one child element (a router `Link`, an `<a>`) instead of a `button`: pass it as `children`, empty. */
|
|
32
38
|
asChild?: boolean;
|
|
33
39
|
};
|
|
@@ -38,4 +44,4 @@ export type ProductTileProps = Omit<ComponentProps<'button'>, 'title'> & {
|
|
|
38
44
|
* price, status); at least 44 px high, and as tall as
|
|
39
45
|
* its row in a `ResponsiveGrid`. `disabled` dims it and stops taps (with `asChild`, the child gets `aria-disabled`, `tabIndex={-1}` and a click handler that cancels navigation, and no pointer events).
|
|
40
46
|
*/
|
|
41
|
-
export declare function ProductTile({ title, price, status, image, imageFit, icon, media, tone, shape, selected, asChild, disabled, className, children, onClick, ...props }: ProductTileProps): import("react").JSX.Element;
|
|
47
|
+
export declare function ProductTile({ title, price, status, image, imageFit, icon, media, tone, shape, selected, size, asChild, disabled, className, children, onClick, ...props }: ProductTileProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { DataTableEmptyProps } from './empty-types.js';
|
|
2
3
|
/** How a `DataTable` lays its rows out: a `table` (default), a list of
|
|
3
4
|
* `cards` (`renderCard`), or `tiles` (`renderTile`): one column of rows in a
|
|
4
5
|
* single surface, split by hairlines. */
|
|
@@ -84,3 +85,16 @@ export type DataTableVirtual = boolean | {
|
|
|
84
85
|
};
|
|
85
86
|
/** How tight a `DataTable`'s rows are. */
|
|
86
87
|
export type DataTableDensity = 'comfortable' | 'compact';
|
|
88
|
+
/** What `DataTableProps` takes beside the empty states: the list surface of the `cards` and `tiles` layouts. */
|
|
89
|
+
export interface DataTableListProps extends DataTableEmptyProps {
|
|
90
|
+
/** The surface of the `cards` and `tiles` layouts: `'card'` (default) draws
|
|
91
|
+
* it as before; `'none'` draws none, for a list inside a card (a page card, a
|
|
92
|
+
* `PanelCard`) that would otherwise be a card in a card. The table's own fill
|
|
93
|
+
* and padding go, tiles lose the list's border, fill and rounded corners
|
|
94
|
+
* (rows stay split by hairlines), and each card loses its border and fill
|
|
95
|
+
* (cards of a single column stay split by hairlines). Hover and selection
|
|
96
|
+
* tints, the padding and the focus ring are unchanged. It is the list's
|
|
97
|
+
* `data-surface="none"`; the `table` layout ignores it. (`ServerTable` has
|
|
98
|
+
* its own `surface`, for its root, and does not pass this one on.) */
|
|
99
|
+
surface?: 'card' | 'none';
|
|
100
|
+
}
|