@nxgt/material 3.101.0 → 3.104.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 +82 -0
- package/README.md +37 -5
- package/dist/{alert-dialog-DYzxchiS.js → alert-dialog-CK_47jfm.js} +1 -1
- package/dist/{async-slice-drJyPvuM.js → async-slice-1ZNMiwyJ.js} +1 -1
- package/dist/{bubble-input-CQwVSoU3.js → bubble-input-BxI1WmNs.js} +17 -5
- package/dist/{button-GeIsUekU.js → button-YfEMZbRO.js} +2 -2
- package/dist/{calculator-BS4PAm6l.js → calculator-BmYZId4c.js} +261 -460
- package/dist/calculator-field.js +7 -7
- package/dist/{calculator-segment-CEdwE24M.js → calculator-segment-DJ08DJ-n.js} +1 -1
- package/dist/calculator.js +1 -1
- package/dist/charts.js +819 -764
- package/dist/{chip-BdEtFQ85.js → chip-DPj6e-3v.js} +2 -2
- package/dist/{code-editor-BByXZOGy.js → code-editor-CZg3nLZO.js} +178 -177
- package/dist/code-editor.js +5 -5
- package/dist/{code-language-items-CSZX5zxD.js → code-language-items-Nq1iOGId.js} +14 -5
- package/dist/components/ui/actions/action-card/action-card-tile.css +47 -0
- package/dist/components/ui/display/chip/chip-soft.css +27 -2
- package/dist/components/ui/display/code/code-moonlight.css +10 -10
- package/dist/components/ui/primitives/collapsible/collapsible.css +9 -0
- package/dist/{components-DQ4MljCr.js → components-B2wrH_W0.js} +19302 -18583
- package/dist/components.js +38 -37
- package/dist/{conversion-variant-DTQqAyDt.js → conversion-variant-C-LPx5ek.js} +5 -5
- package/dist/{currency-field-Dnju7ss2.js → currency-field-DnsRIA80.js} +24 -23
- package/dist/{dialog-5_2__tu8.js → dialog-BKBsDGFc.js} +3 -3
- package/dist/dnd.js +1 -1
- package/dist/{dropdown-menu-FdGC5kIP.js → dropdown-menu-QMDbRidH.js} +1 -1
- package/dist/editor.js +9 -9
- package/dist/{empty-state-BoepPG5v.js → empty-state-BLIJ6znY.js} +1 -1
- package/dist/{field-blur-DkiZOVNV.js → field-blur-DMJwPLsg.js} +9 -9
- package/dist/field-blur-context-3rKussBQ.js +29 -0
- package/dist/{financial-variant-BhqJp5C-.js → financial-variant-Ws0Jp01H.js} +5 -5
- package/dist/{hooks-DjcbJZiO.js → hooks-C3vkQmzh.js} +106 -61
- package/dist/hooks.js +3 -3
- package/dist/{hover-card-CmHJeBeY.js → hover-card-Df649U6I.js} +1 -1
- package/dist/i18n.js +3 -3
- package/dist/{icon-badge-LGUPQh_c.js → icon-badge-Cma1qOOJ.js} +1 -1
- package/dist/{icon-button-BSVpO1jP.js → icon-button-CpKxV264.js} +1 -1
- package/dist/key-layout-D2goCDkD.js +31 -0
- package/dist/keypad.js +551 -0
- package/dist/label-DR-zZyGQ.js +47 -0
- package/dist/lib/components/ui/actions/index.d.ts +1 -0
- package/dist/lib/components/ui/actions/product-tile/index.d.ts +1 -0
- package/dist/lib/components/ui/actions/product-tile/product-tile-link.d.ts +16 -0
- package/dist/lib/components/ui/actions/product-tile/product-tile.d.ts +41 -0
- package/dist/lib/components/ui/collections/data-table/data-table-density.d.ts +1 -1
- package/dist/lib/components/ui/collections/data-table/partials/data-table-scroll-region.d.ts +4 -1
- package/dist/lib/components/ui/collections/data-table/partials/layouts/data-table-list-bar.d.ts +6 -3
- package/dist/lib/components/ui/collections/data-table/partials/layouts/list-bar-in-row.d.ts +2 -1
- package/dist/lib/components/ui/collections/data-table/types.d.ts +11 -8
- package/dist/lib/components/ui/collections/data-table/virtual-option.d.ts +9 -3
- package/dist/lib/components/ui/collections/filter/use-filter-field-config.d.ts +2 -0
- package/dist/lib/components/ui/collections/server-table/partials/server-table-passed-through.d.ts +1 -0
- package/dist/lib/components/ui/collections/server-table/types.d.ts +1 -1
- package/dist/lib/components/ui/display/chip/chip.variants.d.ts +5 -4
- package/dist/lib/components/ui/display/code/code-block-parts.d.ts +1 -1
- package/dist/lib/components/ui/display/code/code-block.d.ts +4 -1
- package/dist/lib/components/ui/display/code/languages.d.ts +2 -0
- package/dist/lib/components/ui/display/code/moonlight-tokens.d.ts +10 -10
- package/dist/lib/components/ui/feedback/confirm-dialog/confirm-dialog-props.d.ts +73 -0
- package/dist/lib/components/ui/feedback/confirm-dialog/confirm-dialog-rules.d.ts +12 -0
- package/dist/lib/components/ui/feedback/confirm-dialog/confirm-dialog.d.ts +5 -61
- package/dist/lib/components/ui/feedback/confirm-dialog/confirm-footer.d.ts +12 -0
- package/dist/lib/components/ui/feedback/confirm-dialog/confirm-phrase.d.ts +26 -0
- package/dist/lib/components/ui/feedback/confirm-dialog/use-confirm-action.d.ts +1 -1
- package/dist/lib/components/ui/fields/contacts/placeholders.d.ts +1 -1
- package/dist/lib/components/ui/fields/index.d.ts +1 -0
- package/dist/lib/components/ui/fields/quantity-field/types.d.ts +1 -1
- package/dist/lib/components/ui/fields/quantity-stepper/index.d.ts +2 -0
- package/dist/lib/components/ui/fields/quantity-stepper/quantity-stepper-model.d.ts +9 -0
- package/dist/lib/components/ui/fields/quantity-stepper/quantity-stepper-value.d.ts +15 -0
- package/dist/lib/components/ui/fields/quantity-stepper/quantity-stepper.d.ts +9 -0
- package/dist/lib/components/ui/fields/quantity-stepper/quantity-stepper.types.d.ts +35 -0
- package/dist/lib/components/ui/fields/quantity-stepper/use-quantity-stepper.d.ts +28 -0
- package/dist/lib/components/ui/layout/index.d.ts +1 -0
- package/dist/lib/components/ui/layout/pane-layout/pane-layout.d.ts +8 -3
- package/dist/lib/components/ui/layout/pane-layout/partials/pane-layout-classes.d.ts +2 -2
- package/dist/lib/components/ui/layout/pane-layout/partials/pane-layout-context.d.ts +9 -0
- package/dist/lib/components/ui/layout/pane-layout/partials/use-pane-layout-state.d.ts +7 -2
- package/dist/lib/components/ui/layout/panel-card/index.d.ts +1 -0
- package/dist/lib/components/ui/layout/panel-card/panel-card.d.ts +23 -0
- package/dist/lib/components/ui/primitives/collapsible/collapsible.d.ts +9 -1
- package/dist/lib/components/ui/primitives/tabs/partials/tabs-list.d.ts +6 -1
- package/dist/lib/components/ui/primitives/tabs/tabs-classes.d.ts +1 -0
- package/dist/lib/components/ui/selection/chip-group-field/chip-group-field.d.ts +8 -0
- package/dist/lib/components/ui/selection/chip-group-field/chip-group-field.types.d.ts +6 -0
- package/dist/lib/components/ui/selection/chip-group-field/partials/chip-group-reasons.d.ts +10 -0
- package/dist/lib/components/ui/selection/chip-group-field/partials/use-chip-rail.d.ts +12 -0
- package/dist/lib/components/ui/selection/choice-group/choice-group-root.d.ts +5 -2
- package/dist/lib/components/ui/selection/index.d.ts +1 -0
- package/dist/lib/components/ui/selection/status-menu/index.d.ts +3 -0
- package/dist/lib/components/ui/selection/status-menu/partials/status-confirm.d.ts +12 -0
- package/dist/lib/components/ui/selection/status-menu/partials/status-icon.d.ts +6 -0
- package/dist/lib/components/ui/selection/status-menu/partials/status-items.d.ts +18 -0
- package/dist/lib/components/ui/selection/status-menu/partials/status-menu-list.d.ts +14 -0
- package/dist/lib/components/ui/selection/status-menu/partials/status-sheet-row.d.ts +11 -0
- package/dist/lib/components/ui/selection/status-menu/partials/status-sheet.d.ts +21 -0
- package/dist/lib/components/ui/selection/status-menu/partials/status-trigger.d.ts +18 -0
- package/dist/lib/components/ui/selection/status-menu/status-menu-data.d.ts +12 -0
- package/dist/lib/components/ui/selection/status-menu/status-menu-form-field.d.ts +20 -0
- package/dist/lib/components/ui/selection/status-menu/status-menu.d.ts +13 -0
- package/dist/lib/components/ui/selection/status-menu/types.d.ts +76 -0
- package/dist/lib/components/ui/selection/status-menu/use-status-change.d.ts +18 -0
- package/dist/lib/components/ui/selection/status-menu/use-status-menu.d.ts +30 -0
- package/dist/lib/components/ui/widgets/calculator/partials/calculator-keypad.d.ts +1 -5
- package/dist/lib/components/ui/widgets/calculator/variants/key-layout.d.ts +3 -49
- package/dist/lib/components/ui/widgets/keypad/cash-model.d.ts +16 -0
- package/dist/lib/components/ui/widgets/keypad/index.d.ts +5 -0
- package/dist/lib/components/ui/widgets/keypad/key-layout.d.ts +56 -0
- package/dist/lib/components/ui/widgets/keypad/keypad-binding.d.ts +32 -0
- package/dist/lib/components/ui/widgets/keypad/keypad-cash.d.ts +28 -0
- package/dist/lib/components/ui/widgets/keypad/keypad-display.d.ts +11 -0
- package/dist/lib/components/ui/widgets/keypad/keypad-entry.d.ts +39 -0
- package/dist/lib/components/ui/widgets/keypad/keypad-grid.d.ts +27 -0
- package/dist/lib/components/ui/widgets/{calculator/partials/calculator-key.d.ts → keypad/keypad-key.d.ts} +6 -3
- package/dist/lib/components/ui/widgets/keypad/keypad-layout.d.ts +19 -0
- package/dist/lib/components/ui/widgets/{calculator/partials → keypad}/keypad-navigation.d.ts +1 -1
- package/dist/lib/components/ui/widgets/keypad/keypad.d.ts +9 -0
- package/dist/lib/components/ui/widgets/keypad/keypad.types.d.ts +91 -0
- package/dist/lib/components/ui/widgets/keypad/use-keypad-cash.d.ts +14 -0
- package/dist/lib/components/ui/widgets/keypad/use-keypad-keyboard.d.ts +7 -0
- package/dist/lib/components/ui/widgets/keypad/use-keypad-number.d.ts +10 -0
- package/dist/lib/components/ui/widgets/keypad/use-keypad-quantity.d.ts +16 -0
- package/dist/lib/components/ui/widgets/keypad/use-keypad-value.d.ts +17 -0
- package/dist/lib/components/ui/widgets/keypad/use-keypad.d.ts +23 -0
- package/dist/lib/components/ui/widgets/native-charts/core/label-placement.d.ts +25 -0
- package/dist/lib/components/ui/widgets/native-charts/core/reference-geometry.d.ts +3 -2
- package/dist/lib/hooks/index.d.ts +1 -0
- package/dist/lib/hooks/use-barcode-scanner.d.ts +39 -0
- package/dist/lib/i18n/resources/en/en.d.ts +28 -0
- package/dist/lib/i18n/resources/en/material.json.d.ts +30 -2
- package/dist/lib/i18n/resources/fr/fr.d.ts +28 -0
- package/dist/lib/i18n/resources/fr/material.json.d.ts +30 -2
- package/dist/lib/i18n/resources/resources.d.ts +56 -0
- package/dist/lib/i18n/translator.d.ts +1 -1
- package/dist/lib/keypad/index.d.ts +20 -0
- package/dist/lib/print/output/csv.d.ts +37 -0
- package/dist/lib/print/output/index.d.ts +1 -0
- package/dist/lib.js +1 -1
- package/dist/main.js +54 -53
- package/dist/map.js +9 -9
- package/dist/material.css +1 -1
- package/dist/pdf-reader.js +1 -1
- package/dist/{percent-field-DGlU_xii.js → percent-field-sAq7BaxN.js} +15 -14
- package/dist/{picker-surface-CGhqNR8a.js → picker-surface--6E-nvpU.js} +4 -4
- package/dist/{popover-ZxL7ktKk.js → popover-bEB8I_-w.js} +1 -1
- package/dist/{pos-types-BQ0QpYMp.js → pos-types-Cpdc4E33.js} +1 -1
- package/dist/{pos-variant-CKy8h_5i.js → pos-variant-ClMGu59I.js} +25 -25
- package/dist/print.js +146 -127
- package/dist/{programmer-variant-CbHstE28.js → programmer-variant-ChzgyA7x.js} +30 -30
- package/dist/{public-D-tdOz4b.js → public-BY8N5NDT.js} +9 -9
- package/dist/{rich-code-block-CTPj1LuD.js → rich-code-block-D2GiWuqD.js} +18 -18
- package/dist/{scientific-variant-B8U9h3II.js → scientific-variant-31_93gcZ.js} +8 -8
- package/dist/{sortable-provider-CSoWE7Ce.js → sortable-provider-DGiVn72t.js} +2 -2
- package/dist/{spinner-ffuwBXHl.js → spinner-CEVomQ5K.js} +1 -1
- package/dist/standard-layout-DTr9yy8Z.js +48 -0
- package/dist/{tabs-JgRq6ZJx.js → tabs-B8MXBbPW.js} +14 -14
- package/dist/{text-field-DURkIP-v.js → text-field-DN88qD0Q.js} +16 -15
- package/dist/theme-picker.js +13 -13
- package/dist/{theme-toggle-n_Zg7JAA.js → theme-toggle-C7pnu1Xh.js} +1 -1
- package/dist/{toolbar-items-IANZdcw4.js → toolbar-items-BDfoh8QB.js} +4 -4
- package/dist/{translate-material-CMHUH5Ha.js → translate-material-s_lxIV43.js} +1 -1
- package/dist/{translator-9zA-Um3W.js → translator-Cgql9srO.js} +56 -4
- package/dist/use-calculator-keyboard-DysnFK8m.js +222 -0
- package/dist/{use-chat-composer-BoIN7RCA.js → use-chat-composer-xCcp9fVc.js} +2250 -2195
- package/dist/{use-heading-spy-Ciw9GBHL.js → use-heading-spy-FIZlf9qj.js} +235 -154
- package/dist/{use-material-translation-CLNaMhUf.js → use-material-translation-xNzbSVgS.js} +1 -1
- package/dist/{use-return-focus-DWhbTGVe.js → use-return-focus-CW9KkDkp.js} +1 -1
- package/docs/README.md +2 -1
- package/docs/components/README.md +2 -0
- package/docs/components/buttons-and-actions.md +81 -2
- package/docs/components/data-display.md +6 -3
- package/docs/components/data-table-filter-and-lists.md +19 -6
- package/docs/components/feedback-and-status.md +20 -0
- package/docs/components/form-fields.md +60 -7
- package/docs/components/navigation-and-layout.md +48 -2
- package/docs/components/primitives.md +44 -2
- package/docs/components/rich-widgets.md +28 -0
- package/docs/components/selection-and-choice.md +176 -1
- package/docs/guides/calculator.md +1 -1
- package/docs/guides/cards-and-tiles.md +31 -24
- package/docs/guides/csp.md +4 -3
- package/docs/guides/data-grid.md +5 -4
- package/docs/guides/field-look-refined.md +2 -2
- package/docs/guides/forms.md +1 -0
- package/docs/guides/helpers.md +49 -0
- package/docs/guides/keypad.md +233 -0
- package/docs/guides/printing.md +51 -1
- package/docs/previews/buttons-actions-producttile.webp +0 -0
- package/docs/previews/data-display-codeblock.webp +0 -0
- package/docs/previews/data-display-codegroup.webp +0 -0
- package/docs/previews/data-display-jsonviewer.webp +0 -0
- package/docs/previews/form-fields-quantitystepper.webp +0 -0
- package/docs/previews/navigation-layout-panelcard.webp +0 -0
- package/docs/previews/rich-widgets-keypad.webp +0 -0
- package/docs/previews/selection-choice-statusmenu.webp +0 -0
- package/docs/roadmap.md +21 -0
- package/docs/troubleshooting.md +68 -4
- package/lib/components/ui/actions/action-card/action-card-tile.css +47 -0
- package/lib/components/ui/display/chip/chip-soft.css +27 -2
- package/lib/components/ui/display/code/code-moonlight.css +10 -10
- package/lib/components/ui/primitives/collapsible/collapsible.css +9 -0
- package/lib/components/ui/widgets/calculator/calculator-keys.css +3 -0
- package/lib/components/ui/widgets/calculator/calculator.css +118 -0
- package/package.json +7 -2
- package/dist/field-blur-context-BLGgf_3z.js +0 -73
- package/dist/key-layout-cR79xfGE.js +0 -38
- package/dist/standard-layout-BuSRr3TY.js +0 -40
package/dist/keypad.js
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { t as e } from "./utils-BLfntITJ.js";
|
|
2
|
+
import { t } from "./use-material-translation-xNzbSVgS.js";
|
|
3
|
+
import { t as n } from "./live-status-BGPaN8r8.js";
|
|
4
|
+
import { n as r, t as i } from "./use-calculator-keyboard-DysnFK8m.js";
|
|
5
|
+
import { i as a, o, r as s, t as c } from "./key-layout-D2goCDkD.js";
|
|
6
|
+
import { useCallback as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
7
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
8
|
+
import { currencyFractionDigits as g } from "@nxgt/material-core/currency-digits";
|
|
9
|
+
import { EMPTY_SESSION as _, ZERO as v, announcement as y, compare as b, formatDecimal as x, formatExpression as S, localeSeparators as ee, parseDecimal as C, press as w, roundTo as T, toCanonical as E } from "@nxgt/material-core/calculator";
|
|
10
|
+
import { billShortcuts as D, decimalToMinor as O, enterMinor as k, minorToDecimal as A, settle as te } from "@nxgt/material-core/calculator/pos";
|
|
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
|
|
142
|
+
//#region lib/components/ui/widgets/keypad/keypad-display.tsx
|
|
143
|
+
function J(e, t, n) {
|
|
144
|
+
let r = C(e);
|
|
145
|
+
return r ? x(r, {
|
|
146
|
+
locale: n,
|
|
147
|
+
fractionDigits: t ?? 2
|
|
148
|
+
}) : e;
|
|
149
|
+
}
|
|
150
|
+
function se(e, t, n, r, i) {
|
|
151
|
+
if (t === "minor") return C(e || "0") ? J(e || "0", n, r) : "";
|
|
152
|
+
let a = S(e, { locale: r });
|
|
153
|
+
return i ? X(a || "0", i, r) : a;
|
|
154
|
+
}
|
|
155
|
+
function Y(e, t, n, r) {
|
|
156
|
+
let i = J(e, t, n);
|
|
157
|
+
return r ? X(i, r, n) : i;
|
|
158
|
+
}
|
|
159
|
+
function X(e, t, n) {
|
|
160
|
+
let r = [];
|
|
161
|
+
try {
|
|
162
|
+
r = new Intl.NumberFormat(n, {
|
|
163
|
+
style: "currency",
|
|
164
|
+
currency: t
|
|
165
|
+
}).formatToParts(-1234.5);
|
|
166
|
+
} catch {}
|
|
167
|
+
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
|
+
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
|
+
}
|
|
170
|
+
function ce({ keypad: e, locale: t, currency: n }) {
|
|
171
|
+
let r = se(e.session.justEvaluated && e.value ? e.value : e.session.expression, e.entry, e.digits, t, n);
|
|
172
|
+
return /* @__PURE__ */ m("output", {
|
|
173
|
+
"data-slot": "keypad-display",
|
|
174
|
+
"data-kind": e.session.error ? "error" : void 0,
|
|
175
|
+
"aria-live": "off",
|
|
176
|
+
dir: "ltr",
|
|
177
|
+
className: "nxgt-keypad-display bg-muted",
|
|
178
|
+
children: r || "\xA0"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region lib/components/ui/widgets/keypad/keypad-cash.tsx
|
|
183
|
+
function le({ total: e, settlement: n, digits: r, locale: i, currency: a }) {
|
|
184
|
+
let { t: o } = t(), s = (e) => Y(e, r, i, a);
|
|
185
|
+
return /* @__PURE__ */ h("dl", {
|
|
186
|
+
"data-slot": "keypad-cash-summary",
|
|
187
|
+
className: "nxgt-keypad-cash",
|
|
188
|
+
children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: o("material.keypad.total", "Total") }), /* @__PURE__ */ m("dd", {
|
|
189
|
+
"data-slot": "keypad-total",
|
|
190
|
+
children: s(e)
|
|
191
|
+
})] }), n ? /* @__PURE__ */ h("div", {
|
|
192
|
+
"data-status": n.status,
|
|
193
|
+
children: [/* @__PURE__ */ m("dt", { children: n.status === "paid" ? o("material.keypad.change-label", "Change") : o("material.keypad.due-label", "Still due") }), /* @__PURE__ */ m("dd", {
|
|
194
|
+
"data-slot": "keypad-settlement",
|
|
195
|
+
children: s(n.status === "paid" ? n.change : n.due)
|
|
196
|
+
})]
|
|
197
|
+
}) : null]
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function ue({ amounts: e, onPick: n, disabled: r, digits: i, locale: a, currency: o }) {
|
|
201
|
+
let { t: s } = t();
|
|
202
|
+
return e.length === 0 ? null : /* @__PURE__ */ m("div", {
|
|
203
|
+
role: "group",
|
|
204
|
+
"aria-label": s("material.keypad.shortcuts", "Quick amounts"),
|
|
205
|
+
"data-slot": "keypad-shortcuts",
|
|
206
|
+
className: "nxgt-keypad-shortcuts",
|
|
207
|
+
children: e.map((e) => {
|
|
208
|
+
let t = Y(e, i, a, o);
|
|
209
|
+
return /* @__PURE__ */ m("button", {
|
|
210
|
+
type: "button",
|
|
211
|
+
"aria-disabled": r ? !0 : void 0,
|
|
212
|
+
"aria-label": s("material.keypad.amount", "Amount {amount}", { amount: t }),
|
|
213
|
+
onClick: () => !r && n(e),
|
|
214
|
+
children: /* @__PURE__ */ m("span", {
|
|
215
|
+
"aria-hidden": "true",
|
|
216
|
+
children: t
|
|
217
|
+
})
|
|
218
|
+
}, e);
|
|
219
|
+
})
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function de({ cash: e, total: t, onPick: n, disabled: r, digits: i, locale: a, currency: o }) {
|
|
223
|
+
let s = {
|
|
224
|
+
digits: i,
|
|
225
|
+
locale: a,
|
|
226
|
+
currency: o
|
|
227
|
+
};
|
|
228
|
+
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(le, {
|
|
229
|
+
...s,
|
|
230
|
+
total: t,
|
|
231
|
+
settlement: e.settlement
|
|
232
|
+
}), /* @__PURE__ */ m(ue, {
|
|
233
|
+
...s,
|
|
234
|
+
amounts: e.shortcuts,
|
|
235
|
+
onPick: n,
|
|
236
|
+
disabled: r
|
|
237
|
+
})] });
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region lib/components/ui/widgets/keypad/keypad-layout.ts
|
|
241
|
+
var fe = {
|
|
242
|
+
add: [
|
|
243
|
+
"+",
|
|
244
|
+
"+",
|
|
245
|
+
"Plus"
|
|
246
|
+
],
|
|
247
|
+
subtract: [
|
|
248
|
+
"-",
|
|
249
|
+
"−",
|
|
250
|
+
"Minus"
|
|
251
|
+
],
|
|
252
|
+
multiply: [
|
|
253
|
+
"*",
|
|
254
|
+
"×",
|
|
255
|
+
"Times"
|
|
256
|
+
],
|
|
257
|
+
divide: [
|
|
258
|
+
"/",
|
|
259
|
+
"÷",
|
|
260
|
+
"Divided by"
|
|
261
|
+
]
|
|
262
|
+
};
|
|
263
|
+
function pe(e) {
|
|
264
|
+
let t = e.pending ? s("commit", "=", "=", "equals", "equals", "Equals") : {
|
|
265
|
+
id: "commit",
|
|
266
|
+
key: "=",
|
|
267
|
+
glyph: e.commitLabel ?? "✓",
|
|
268
|
+
role: "equals",
|
|
269
|
+
name: e.cash ? {
|
|
270
|
+
key: "material.keypad.tender",
|
|
271
|
+
fallback: "Tender"
|
|
272
|
+
} : {
|
|
273
|
+
key: "material.keypad.commit",
|
|
274
|
+
fallback: "Enter"
|
|
275
|
+
},
|
|
276
|
+
label: e.commitLabel
|
|
277
|
+
}, n = e.operations.map((e) => {
|
|
278
|
+
let [t, n, r] = fe[e];
|
|
279
|
+
return s(e, t, n, "operator", e, r);
|
|
280
|
+
}), r = [];
|
|
281
|
+
if (n.length > 0) {
|
|
282
|
+
let e = 12 / n.length;
|
|
283
|
+
r.push(n.map((t) => ({
|
|
284
|
+
...t,
|
|
285
|
+
span: e
|
|
286
|
+
})));
|
|
287
|
+
}
|
|
288
|
+
return r.push(o([
|
|
289
|
+
c(7),
|
|
290
|
+
c(8),
|
|
291
|
+
c(9),
|
|
292
|
+
s("clear", "C", "C", "utility", "clear", "Clear all")
|
|
293
|
+
]), o([
|
|
294
|
+
c(4),
|
|
295
|
+
c(5),
|
|
296
|
+
c(6),
|
|
297
|
+
s("backspace", "backspace", "⌫", "utility", "backspace", "Delete last character")
|
|
298
|
+
]), o([
|
|
299
|
+
c(1),
|
|
300
|
+
c(2),
|
|
301
|
+
c(3),
|
|
302
|
+
s("double-zero", "00", "00", "digit", "double-zero", "00, double zero")
|
|
303
|
+
]), e.decimal ? [
|
|
304
|
+
{
|
|
305
|
+
...c(0),
|
|
306
|
+
span: 6
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
...s("decimal", ".", ".", "digit", "decimal", "Decimal separator"),
|
|
310
|
+
span: 3
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
...t,
|
|
314
|
+
span: 3
|
|
315
|
+
}
|
|
316
|
+
] : [{
|
|
317
|
+
...c(0),
|
|
318
|
+
span: 9
|
|
319
|
+
}, {
|
|
320
|
+
...t,
|
|
321
|
+
span: 3
|
|
322
|
+
}]), {
|
|
323
|
+
columns: 12,
|
|
324
|
+
rows: r
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region lib/components/ui/widgets/keypad/cash-model.ts
|
|
329
|
+
function Z(e, t) {
|
|
330
|
+
if (e === void 0) return;
|
|
331
|
+
let n = C(String(e));
|
|
332
|
+
if (n) return E(t === void 0 ? n : T(n, t, "half-up"));
|
|
333
|
+
}
|
|
334
|
+
function Q(e, t) {
|
|
335
|
+
if (!(e === void 0 || t === "")) try {
|
|
336
|
+
let n = te(e, t);
|
|
337
|
+
return n.status === "paid" ? {
|
|
338
|
+
status: "paid",
|
|
339
|
+
change: E(n.change)
|
|
340
|
+
} : {
|
|
341
|
+
status: "short",
|
|
342
|
+
due: E(n.due)
|
|
343
|
+
};
|
|
344
|
+
} catch {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function $(e, t, n, r, i = 4) {
|
|
349
|
+
if (e === void 0 || C(String(e)) == null) return [];
|
|
350
|
+
try {
|
|
351
|
+
let a = n === void 0 ? void 0 : C(String(n)), o = D(e, t ?? [], { limit: i - 1 }).map((e) => r === void 0 ? e : T(e, r, "half-up")).filter((e) => !a || b(e, a) <= 0).map(E);
|
|
352
|
+
return [...new Set(o)];
|
|
353
|
+
} catch {
|
|
354
|
+
return [];
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region lib/components/ui/widgets/keypad/use-keypad-value.ts
|
|
359
|
+
function me(e, t) {
|
|
360
|
+
let [n, r] = f(() => I(e.value ?? e.defaultValue ?? "")), i = d("");
|
|
361
|
+
if (R(n) || (i.current = L(n)), e.value !== void 0) {
|
|
362
|
+
let t = L(I(e.value));
|
|
363
|
+
t !== i.current && (i.current = t, r(I(e.value)));
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
session: n,
|
|
367
|
+
setInner: r,
|
|
368
|
+
report: l((e) => {
|
|
369
|
+
let n = V(e, i.current);
|
|
370
|
+
n !== void 0 && (i.current = n, t.current?.(n));
|
|
371
|
+
}, [t])
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region lib/components/ui/widgets/keypad/use-keypad.ts
|
|
376
|
+
function he(e) {
|
|
377
|
+
let t = e.entry ?? "decimal", n = e.currency ? g(e.currency, e.fractionDigits) : e.fractionDigits, r = P(e), i = d(e.onValueChange);
|
|
378
|
+
i.current = e.onValueChange;
|
|
379
|
+
let { session: a, setInner: o, report: s } = me(e, i), c = {
|
|
380
|
+
entry: t,
|
|
381
|
+
digits: n,
|
|
382
|
+
operations: r,
|
|
383
|
+
max: e.max
|
|
384
|
+
}, u = d({
|
|
385
|
+
session: a,
|
|
386
|
+
o: e,
|
|
387
|
+
config: c
|
|
388
|
+
});
|
|
389
|
+
u.current = {
|
|
390
|
+
session: a,
|
|
391
|
+
o: e,
|
|
392
|
+
config: c
|
|
393
|
+
};
|
|
394
|
+
let f = l((e) => {
|
|
395
|
+
let { session: t, o: n, config: r } = u.current;
|
|
396
|
+
if (n.disabled) return;
|
|
397
|
+
let i = ae(t, e, r);
|
|
398
|
+
i !== t && (o(i), s(i));
|
|
399
|
+
}, [s, o]), p = l(() => {
|
|
400
|
+
let { session: e, o: t, config: n } = u.current;
|
|
401
|
+
if (t.disabled) return;
|
|
402
|
+
if (R(e)) return f("=");
|
|
403
|
+
let r = L(e);
|
|
404
|
+
if (r === "") return;
|
|
405
|
+
let i = B(r, t.min, t.max);
|
|
406
|
+
if (i !== r) {
|
|
407
|
+
let e = I(i);
|
|
408
|
+
o(e), s(e);
|
|
409
|
+
}
|
|
410
|
+
if (t.variant === "cash") {
|
|
411
|
+
let e = Q(Z(t.total, n.digits), i);
|
|
412
|
+
e && t.onTender?.(i, e);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
t.onCommit?.(i, e.expression);
|
|
416
|
+
}, [
|
|
417
|
+
f,
|
|
418
|
+
s,
|
|
419
|
+
o
|
|
420
|
+
]), m = l((e) => {
|
|
421
|
+
let { o: t } = u.current;
|
|
422
|
+
if (t.disabled) return;
|
|
423
|
+
let n = I(B(e, void 0, t.max));
|
|
424
|
+
o(n), s(n);
|
|
425
|
+
}, [s, o]);
|
|
426
|
+
return {
|
|
427
|
+
session: a,
|
|
428
|
+
value: L(a),
|
|
429
|
+
pending: R(a),
|
|
430
|
+
digits: n,
|
|
431
|
+
entry: t,
|
|
432
|
+
operations: r,
|
|
433
|
+
press: f,
|
|
434
|
+
commit: p,
|
|
435
|
+
set: m
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region lib/components/ui/widgets/keypad/use-keypad-cash.ts
|
|
440
|
+
function ge(e, n) {
|
|
441
|
+
let { t: r } = t(), i = e.variant === "cash", a = i ? Z(e.total, n.digits) : void 0, o = i ? Q(a, n.value) : void 0, s = u(() => i ? $(a, e.denominations, e.max, n.digits) : [], [
|
|
442
|
+
i,
|
|
443
|
+
a,
|
|
444
|
+
e.denominations,
|
|
445
|
+
e.max,
|
|
446
|
+
n.digits
|
|
447
|
+
]), c;
|
|
448
|
+
if (o) {
|
|
449
|
+
let t = (t) => Y(t, n.digits, e.locale, e.currency);
|
|
450
|
+
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
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
cash: i,
|
|
454
|
+
total: a,
|
|
455
|
+
settlement: o,
|
|
456
|
+
shortcuts: s,
|
|
457
|
+
said: c
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region lib/components/ui/widgets/keypad/use-keypad-keyboard.ts
|
|
462
|
+
function _e(e, t, n) {
|
|
463
|
+
return i({
|
|
464
|
+
locale: t,
|
|
465
|
+
global: n,
|
|
466
|
+
accepts: (t) => /^(?:\d|00|\.|=|backspace|C|CE)$/.test(t) || e.operations.some((e) => F(e) === t),
|
|
467
|
+
onKey: (t) => t === "=" ? e.commit() : e.press(t),
|
|
468
|
+
onCopy: () => {}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region lib/components/ui/widgets/keypad/keypad.tsx
|
|
473
|
+
function ve(i) {
|
|
474
|
+
let o = oe(i), { locale: s, currency: c, commitLabel: l, disabled: d, keyboard: f = "focus", size: p = "comfortable", display: g = !0, label: _, className: v } = o, { t: b } = t(), x = he(o), S = ge(o, x), C = u(() => pe({
|
|
475
|
+
operations: x.operations,
|
|
476
|
+
decimal: x.entry === "decimal" && x.digits !== 0,
|
|
477
|
+
commitLabel: l,
|
|
478
|
+
pending: x.pending,
|
|
479
|
+
cash: S.cash
|
|
480
|
+
}), [
|
|
481
|
+
x.operations,
|
|
482
|
+
x.entry,
|
|
483
|
+
x.digits,
|
|
484
|
+
l,
|
|
485
|
+
x.pending,
|
|
486
|
+
S.cash
|
|
487
|
+
]), w = _e(x, s, f === "global"), T = y(x.session, s);
|
|
488
|
+
return /* @__PURE__ */ m("div", {
|
|
489
|
+
"data-slot": "keypad",
|
|
490
|
+
"data-size": p,
|
|
491
|
+
"data-disabled": d ? "" : void 0,
|
|
492
|
+
className: e("nxgt-calc nxgt-keypad", v),
|
|
493
|
+
onKeyDown: f === "focus" ? w : void 0,
|
|
494
|
+
children: /* @__PURE__ */ h("div", {
|
|
495
|
+
className: "nxgt-calc-body nxgt-keypad-body",
|
|
496
|
+
children: [
|
|
497
|
+
g ? /* @__PURE__ */ m(ce, {
|
|
498
|
+
keypad: x,
|
|
499
|
+
locale: s,
|
|
500
|
+
currency: c
|
|
501
|
+
}) : null,
|
|
502
|
+
S.cash ? /* @__PURE__ */ m(de, {
|
|
503
|
+
cash: S,
|
|
504
|
+
total: S.total ?? "0",
|
|
505
|
+
onPick: x.set,
|
|
506
|
+
disabled: d,
|
|
507
|
+
digits: x.digits,
|
|
508
|
+
locale: s,
|
|
509
|
+
currency: c
|
|
510
|
+
}) : null,
|
|
511
|
+
/* @__PURE__ */ m(r, {
|
|
512
|
+
layout: C,
|
|
513
|
+
label: _ ?? b("material.calculator.keypad", "Keypad"),
|
|
514
|
+
decimal: ee(s).decimal,
|
|
515
|
+
unavailable: () => d === !0,
|
|
516
|
+
onPress: (e) => {
|
|
517
|
+
if (e.id === "commit") x.commit();
|
|
518
|
+
else for (let t of a(e)) x.press(t);
|
|
519
|
+
},
|
|
520
|
+
slot: "keypad-keys",
|
|
521
|
+
keySlot: "keypad-key",
|
|
522
|
+
className: "nxgt-calc-keys nxgt-keypad-keys"
|
|
523
|
+
}),
|
|
524
|
+
/* @__PURE__ */ m(n, {
|
|
525
|
+
slot: "keypad-status",
|
|
526
|
+
children: S.said ?? (T ? b(T.key, T.fallback, T.values) : null)
|
|
527
|
+
})
|
|
528
|
+
]
|
|
529
|
+
})
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region lib/components/ui/widgets/keypad/use-keypad-number.ts
|
|
534
|
+
function ye(e) {
|
|
535
|
+
return q(e);
|
|
536
|
+
}
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region lib/components/ui/widgets/keypad/use-keypad-quantity.ts
|
|
539
|
+
function be(e) {
|
|
540
|
+
let { value: t, onChange: n } = e;
|
|
541
|
+
return q({
|
|
542
|
+
...e,
|
|
543
|
+
value: t?.value,
|
|
544
|
+
onChange: (e) => n?.({
|
|
545
|
+
value: e,
|
|
546
|
+
unit: t?.unit ?? ""
|
|
547
|
+
})
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
//#endregion
|
|
551
|
+
export { ve as Keypad, ye as useKeypadNumber, be as useKeypadQuantity };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { t as e } from "./utils-BLfntITJ.js";
|
|
2
|
+
import { i as t } from "./dist-DWZXlCZR.js";
|
|
3
|
+
import * as n from "react";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
//#region ../../node_modules/@radix-ui/react-label/dist/index.mjs
|
|
6
|
+
var a = Object.defineProperty, o = /* @__PURE__ */ n.forwardRef(/* @__PURE__ */ ((e, t) => a(e, "name", {
|
|
7
|
+
value: t,
|
|
8
|
+
configurable: !0
|
|
9
|
+
}))(function(e, n) {
|
|
10
|
+
return /* @__PURE__ */ r(t.label, {
|
|
11
|
+
...e,
|
|
12
|
+
ref: n,
|
|
13
|
+
onMouseDown: (t) => {
|
|
14
|
+
t.target.closest("button, input, select, textarea") || (e.onMouseDown?.(t), !t.defaultPrevented && t.detail > 1 && t.preventDefault());
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}, "Label"));
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region lib/components/ui/primitives/label/label.tsx
|
|
20
|
+
function s() {
|
|
21
|
+
return /* @__PURE__ */ r("svg", {
|
|
22
|
+
"data-slot": "label-required-mark",
|
|
23
|
+
"aria-hidden": "true",
|
|
24
|
+
focusable: "false",
|
|
25
|
+
viewBox: "0 0 10 10",
|
|
26
|
+
fill: "none",
|
|
27
|
+
stroke: "currentColor",
|
|
28
|
+
strokeWidth: "1.75",
|
|
29
|
+
strokeLinecap: "round",
|
|
30
|
+
children: /* @__PURE__ */ r("path", { d: "M5 1v8M1.5 3l7 4M8.5 3l-7 4" })
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function c({ className: t, withAsterisk: n, ...a }) {
|
|
34
|
+
return /* @__PURE__ */ r(o, {
|
|
35
|
+
"data-slot": "label",
|
|
36
|
+
className: e("flex items-center ps-0.5 gap-2 text-sm leading-5 -my-[3px] empty:my-0 font-semibold select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", t),
|
|
37
|
+
...a,
|
|
38
|
+
children: n ? /* @__PURE__ */ i("span", {
|
|
39
|
+
"data-slot": "label-text",
|
|
40
|
+
"data-required": "",
|
|
41
|
+
className: "inline-flex",
|
|
42
|
+
children: [a.children, /* @__PURE__ */ r(s, {})]
|
|
43
|
+
}) : a.children
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { c as t };
|
|
@@ -10,6 +10,7 @@ export * from './language-switcher/index.js';
|
|
|
10
10
|
export * from './link/index.js';
|
|
11
11
|
export * from './load-more-button/index.js';
|
|
12
12
|
export * from './load-more-footer/index.js';
|
|
13
|
+
export * from './product-tile/index.js';
|
|
13
14
|
export * from './responsive-button/index.js';
|
|
14
15
|
export * from './scroll-to-latest-button/index.js';
|
|
15
16
|
export * from './scroll-to-top/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './product-tile.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The props `ProductTile` puts on its child with `asChild`. A disabled tile
|
|
4
|
+
* leaves the Tab order and cancels the click (so Enter on a link does not
|
|
5
|
+
* follow it) and never calls the caller's `onClick`, as a disabled button.
|
|
6
|
+
*/
|
|
7
|
+
export declare function productTileLinkProps(disabled: boolean | undefined, selected: boolean, onClick: ((e: MouseEvent<HTMLButtonElement>) => void) | undefined): {
|
|
8
|
+
tabIndex: number;
|
|
9
|
+
onClick: (e: MouseEvent<HTMLElement>) => void;
|
|
10
|
+
'aria-disabled': true | undefined;
|
|
11
|
+
'aria-current': "true" | undefined;
|
|
12
|
+
} | {
|
|
13
|
+
onClick: ((e: MouseEvent<HTMLButtonElement>) => void) | undefined;
|
|
14
|
+
'aria-disabled': true | undefined;
|
|
15
|
+
'aria-current': "true" | undefined;
|
|
16
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ShapeName } from '@nxgt/material-core/shapes';
|
|
2
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
import { IconName } from '../../primitives/icon/icon.js';
|
|
4
|
+
import { Tone } from '../../tones.js';
|
|
5
|
+
export type ProductTileProps = Omit<ComponentProps<'button'>, 'title'> & {
|
|
6
|
+
/** The item's name: the first line, up to two lines long. */
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
/** The price, large and tabular. A `ReactNode`: format it with the app's locale. */
|
|
9
|
+
price?: ReactNode;
|
|
10
|
+
/** The stock state on its own line under the price (a `Badge`, a text). */
|
|
11
|
+
status?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* The item's photo (a URL, a square one fits best): shown in a square box
|
|
14
|
+
* on a soft surface, lazy loaded, with an empty `alt` since the title
|
|
15
|
+
* names the tile. If it fails to load, the toned `icon` shape takes its
|
|
16
|
+
* place.
|
|
17
|
+
*/
|
|
18
|
+
image?: string;
|
|
19
|
+
/** How the photo fills its box: `contain` (default, a transparent PNG or a white-background packshot) or `cover` (a full-bleed photo). */
|
|
20
|
+
imageFit?: 'contain' | 'cover';
|
|
21
|
+
/** Without an `image` (or when it fails), a toned shape with this icon. */
|
|
22
|
+
icon?: IconName;
|
|
23
|
+
/** Any other media in place of the box (a `Shape` of your own); replaces `image` and `icon`. */
|
|
24
|
+
media?: ReactNode;
|
|
25
|
+
/** The tone of the shape behind `icon`, `primary` by default. */
|
|
26
|
+
tone?: Tone;
|
|
27
|
+
/** The expressive shape behind the icon, `squircle` by default. */
|
|
28
|
+
shape?: ShapeName;
|
|
29
|
+
/** The item is in the basket or chosen: `aria-pressed`, a tint and a bar at the start. */
|
|
30
|
+
selected?: boolean;
|
|
31
|
+
/** Render the tile inside the one child element (a router `Link`, an `<a>`) instead of a `button`: pass it as `children`, empty. */
|
|
32
|
+
asChild?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A large, even tap tile for a point-of-sale or kiosk catalogue: a picture or
|
|
36
|
+
* a toned shape with an icon, the item's name, a prominent price and a stock
|
|
37
|
+
* state on its own line. The tile is one button whose name is its text (title,
|
|
38
|
+
* price, status); at least 44 px high, and as tall as
|
|
39
|
+
* 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
|
+
*/
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The `<table>`'s classes: the gap between rows (4px, 8px from `md`) that
|
|
2
2
|
* `compact` shrinks to 2px. */
|
|
3
|
-
export declare const TABLE_DENSITY_CLASS = "border-separate border-spacing-y-1 md:
|
|
3
|
+
export declare const TABLE_DENSITY_CLASS = "border-separate border-spacing-y-(--row-gap) [--row-gap:calc(var(--spacing)*1)] md:[--row-gap:calc(var(--spacing)*2)] data-[density=compact]:[--row-gap:calc(var(--spacing)*0.5)] md:data-[density=compact]:[--row-gap:calc(var(--spacing)*0.5)]";
|
|
4
4
|
/** A body cell: 8px of padding, 4px above and below when compact (the sides
|
|
5
5
|
* stay 8px, aligned with the header, and a checkbox cell keeps its `pr-0`). */
|
|
6
6
|
export declare const CELL_DENSITY_CLASS = "[table[data-density=compact]>tbody>tr>&]:py-1";
|
package/dist/lib/components/ui/collections/data-table/partials/data-table-scroll-region.d.ts
CHANGED
|
@@ -9,9 +9,12 @@ import { ReactNode } from 'react';
|
|
|
9
9
|
* not a size container, which would collapse it inside a content-sized parent
|
|
10
10
|
* (`w-fit`, `inline-flex`, an `auto` grid track, a popover).
|
|
11
11
|
*/
|
|
12
|
-
export declare function DataTableScrollRegion({ label, maxHeight, virtual, children, }: {
|
|
12
|
+
export declare function DataTableScrollRegion({ label, maxHeight, maxHeightClassName, virtual, children, }: {
|
|
13
13
|
label: string;
|
|
14
14
|
maxHeight?: number | string;
|
|
15
|
+
/** A class that caps the height; no inline style, and `maxHeight` is
|
|
16
|
+
* ignored. */
|
|
17
|
+
maxHeightClassName?: string;
|
|
15
18
|
/** Virtual rows: no scroll anchoring, which would move the scroll when
|
|
16
19
|
* the spacers above the rows change height. */
|
|
17
20
|
virtual?: boolean;
|