@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.
Files changed (207) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +37 -5
  3. package/dist/{alert-dialog-DYzxchiS.js → alert-dialog-CK_47jfm.js} +1 -1
  4. package/dist/{async-slice-drJyPvuM.js → async-slice-1ZNMiwyJ.js} +1 -1
  5. package/dist/{bubble-input-CQwVSoU3.js → bubble-input-BxI1WmNs.js} +17 -5
  6. package/dist/{button-GeIsUekU.js → button-YfEMZbRO.js} +2 -2
  7. package/dist/{calculator-BS4PAm6l.js → calculator-BmYZId4c.js} +261 -460
  8. package/dist/calculator-field.js +7 -7
  9. package/dist/{calculator-segment-CEdwE24M.js → calculator-segment-DJ08DJ-n.js} +1 -1
  10. package/dist/calculator.js +1 -1
  11. package/dist/charts.js +819 -764
  12. package/dist/{chip-BdEtFQ85.js → chip-DPj6e-3v.js} +2 -2
  13. package/dist/{code-editor-BByXZOGy.js → code-editor-CZg3nLZO.js} +178 -177
  14. package/dist/code-editor.js +5 -5
  15. package/dist/{code-language-items-CSZX5zxD.js → code-language-items-Nq1iOGId.js} +14 -5
  16. package/dist/components/ui/actions/action-card/action-card-tile.css +47 -0
  17. package/dist/components/ui/display/chip/chip-soft.css +27 -2
  18. package/dist/components/ui/display/code/code-moonlight.css +10 -10
  19. package/dist/components/ui/primitives/collapsible/collapsible.css +9 -0
  20. package/dist/{components-DQ4MljCr.js → components-B2wrH_W0.js} +19302 -18583
  21. package/dist/components.js +38 -37
  22. package/dist/{conversion-variant-DTQqAyDt.js → conversion-variant-C-LPx5ek.js} +5 -5
  23. package/dist/{currency-field-Dnju7ss2.js → currency-field-DnsRIA80.js} +24 -23
  24. package/dist/{dialog-5_2__tu8.js → dialog-BKBsDGFc.js} +3 -3
  25. package/dist/dnd.js +1 -1
  26. package/dist/{dropdown-menu-FdGC5kIP.js → dropdown-menu-QMDbRidH.js} +1 -1
  27. package/dist/editor.js +9 -9
  28. package/dist/{empty-state-BoepPG5v.js → empty-state-BLIJ6znY.js} +1 -1
  29. package/dist/{field-blur-DkiZOVNV.js → field-blur-DMJwPLsg.js} +9 -9
  30. package/dist/field-blur-context-3rKussBQ.js +29 -0
  31. package/dist/{financial-variant-BhqJp5C-.js → financial-variant-Ws0Jp01H.js} +5 -5
  32. package/dist/{hooks-DjcbJZiO.js → hooks-C3vkQmzh.js} +106 -61
  33. package/dist/hooks.js +3 -3
  34. package/dist/{hover-card-CmHJeBeY.js → hover-card-Df649U6I.js} +1 -1
  35. package/dist/i18n.js +3 -3
  36. package/dist/{icon-badge-LGUPQh_c.js → icon-badge-Cma1qOOJ.js} +1 -1
  37. package/dist/{icon-button-BSVpO1jP.js → icon-button-CpKxV264.js} +1 -1
  38. package/dist/key-layout-D2goCDkD.js +31 -0
  39. package/dist/keypad.js +551 -0
  40. package/dist/label-DR-zZyGQ.js +47 -0
  41. package/dist/lib/components/ui/actions/index.d.ts +1 -0
  42. package/dist/lib/components/ui/actions/product-tile/index.d.ts +1 -0
  43. package/dist/lib/components/ui/actions/product-tile/product-tile-link.d.ts +16 -0
  44. package/dist/lib/components/ui/actions/product-tile/product-tile.d.ts +41 -0
  45. package/dist/lib/components/ui/collections/data-table/data-table-density.d.ts +1 -1
  46. package/dist/lib/components/ui/collections/data-table/partials/data-table-scroll-region.d.ts +4 -1
  47. package/dist/lib/components/ui/collections/data-table/partials/layouts/data-table-list-bar.d.ts +6 -3
  48. package/dist/lib/components/ui/collections/data-table/partials/layouts/list-bar-in-row.d.ts +2 -1
  49. package/dist/lib/components/ui/collections/data-table/types.d.ts +11 -8
  50. package/dist/lib/components/ui/collections/data-table/virtual-option.d.ts +9 -3
  51. package/dist/lib/components/ui/collections/filter/use-filter-field-config.d.ts +2 -0
  52. package/dist/lib/components/ui/collections/server-table/partials/server-table-passed-through.d.ts +1 -0
  53. package/dist/lib/components/ui/collections/server-table/types.d.ts +1 -1
  54. package/dist/lib/components/ui/display/chip/chip.variants.d.ts +5 -4
  55. package/dist/lib/components/ui/display/code/code-block-parts.d.ts +1 -1
  56. package/dist/lib/components/ui/display/code/code-block.d.ts +4 -1
  57. package/dist/lib/components/ui/display/code/languages.d.ts +2 -0
  58. package/dist/lib/components/ui/display/code/moonlight-tokens.d.ts +10 -10
  59. package/dist/lib/components/ui/feedback/confirm-dialog/confirm-dialog-props.d.ts +73 -0
  60. package/dist/lib/components/ui/feedback/confirm-dialog/confirm-dialog-rules.d.ts +12 -0
  61. package/dist/lib/components/ui/feedback/confirm-dialog/confirm-dialog.d.ts +5 -61
  62. package/dist/lib/components/ui/feedback/confirm-dialog/confirm-footer.d.ts +12 -0
  63. package/dist/lib/components/ui/feedback/confirm-dialog/confirm-phrase.d.ts +26 -0
  64. package/dist/lib/components/ui/feedback/confirm-dialog/use-confirm-action.d.ts +1 -1
  65. package/dist/lib/components/ui/fields/contacts/placeholders.d.ts +1 -1
  66. package/dist/lib/components/ui/fields/index.d.ts +1 -0
  67. package/dist/lib/components/ui/fields/quantity-field/types.d.ts +1 -1
  68. package/dist/lib/components/ui/fields/quantity-stepper/index.d.ts +2 -0
  69. package/dist/lib/components/ui/fields/quantity-stepper/quantity-stepper-model.d.ts +9 -0
  70. package/dist/lib/components/ui/fields/quantity-stepper/quantity-stepper-value.d.ts +15 -0
  71. package/dist/lib/components/ui/fields/quantity-stepper/quantity-stepper.d.ts +9 -0
  72. package/dist/lib/components/ui/fields/quantity-stepper/quantity-stepper.types.d.ts +35 -0
  73. package/dist/lib/components/ui/fields/quantity-stepper/use-quantity-stepper.d.ts +28 -0
  74. package/dist/lib/components/ui/layout/index.d.ts +1 -0
  75. package/dist/lib/components/ui/layout/pane-layout/pane-layout.d.ts +8 -3
  76. package/dist/lib/components/ui/layout/pane-layout/partials/pane-layout-classes.d.ts +2 -2
  77. package/dist/lib/components/ui/layout/pane-layout/partials/pane-layout-context.d.ts +9 -0
  78. package/dist/lib/components/ui/layout/pane-layout/partials/use-pane-layout-state.d.ts +7 -2
  79. package/dist/lib/components/ui/layout/panel-card/index.d.ts +1 -0
  80. package/dist/lib/components/ui/layout/panel-card/panel-card.d.ts +23 -0
  81. package/dist/lib/components/ui/primitives/collapsible/collapsible.d.ts +9 -1
  82. package/dist/lib/components/ui/primitives/tabs/partials/tabs-list.d.ts +6 -1
  83. package/dist/lib/components/ui/primitives/tabs/tabs-classes.d.ts +1 -0
  84. package/dist/lib/components/ui/selection/chip-group-field/chip-group-field.d.ts +8 -0
  85. package/dist/lib/components/ui/selection/chip-group-field/chip-group-field.types.d.ts +6 -0
  86. package/dist/lib/components/ui/selection/chip-group-field/partials/chip-group-reasons.d.ts +10 -0
  87. package/dist/lib/components/ui/selection/chip-group-field/partials/use-chip-rail.d.ts +12 -0
  88. package/dist/lib/components/ui/selection/choice-group/choice-group-root.d.ts +5 -2
  89. package/dist/lib/components/ui/selection/index.d.ts +1 -0
  90. package/dist/lib/components/ui/selection/status-menu/index.d.ts +3 -0
  91. package/dist/lib/components/ui/selection/status-menu/partials/status-confirm.d.ts +12 -0
  92. package/dist/lib/components/ui/selection/status-menu/partials/status-icon.d.ts +6 -0
  93. package/dist/lib/components/ui/selection/status-menu/partials/status-items.d.ts +18 -0
  94. package/dist/lib/components/ui/selection/status-menu/partials/status-menu-list.d.ts +14 -0
  95. package/dist/lib/components/ui/selection/status-menu/partials/status-sheet-row.d.ts +11 -0
  96. package/dist/lib/components/ui/selection/status-menu/partials/status-sheet.d.ts +21 -0
  97. package/dist/lib/components/ui/selection/status-menu/partials/status-trigger.d.ts +18 -0
  98. package/dist/lib/components/ui/selection/status-menu/status-menu-data.d.ts +12 -0
  99. package/dist/lib/components/ui/selection/status-menu/status-menu-form-field.d.ts +20 -0
  100. package/dist/lib/components/ui/selection/status-menu/status-menu.d.ts +13 -0
  101. package/dist/lib/components/ui/selection/status-menu/types.d.ts +76 -0
  102. package/dist/lib/components/ui/selection/status-menu/use-status-change.d.ts +18 -0
  103. package/dist/lib/components/ui/selection/status-menu/use-status-menu.d.ts +30 -0
  104. package/dist/lib/components/ui/widgets/calculator/partials/calculator-keypad.d.ts +1 -5
  105. package/dist/lib/components/ui/widgets/calculator/variants/key-layout.d.ts +3 -49
  106. package/dist/lib/components/ui/widgets/keypad/cash-model.d.ts +16 -0
  107. package/dist/lib/components/ui/widgets/keypad/index.d.ts +5 -0
  108. package/dist/lib/components/ui/widgets/keypad/key-layout.d.ts +56 -0
  109. package/dist/lib/components/ui/widgets/keypad/keypad-binding.d.ts +32 -0
  110. package/dist/lib/components/ui/widgets/keypad/keypad-cash.d.ts +28 -0
  111. package/dist/lib/components/ui/widgets/keypad/keypad-display.d.ts +11 -0
  112. package/dist/lib/components/ui/widgets/keypad/keypad-entry.d.ts +39 -0
  113. package/dist/lib/components/ui/widgets/keypad/keypad-grid.d.ts +27 -0
  114. package/dist/lib/components/ui/widgets/{calculator/partials/calculator-key.d.ts → keypad/keypad-key.d.ts} +6 -3
  115. package/dist/lib/components/ui/widgets/keypad/keypad-layout.d.ts +19 -0
  116. package/dist/lib/components/ui/widgets/{calculator/partials → keypad}/keypad-navigation.d.ts +1 -1
  117. package/dist/lib/components/ui/widgets/keypad/keypad.d.ts +9 -0
  118. package/dist/lib/components/ui/widgets/keypad/keypad.types.d.ts +91 -0
  119. package/dist/lib/components/ui/widgets/keypad/use-keypad-cash.d.ts +14 -0
  120. package/dist/lib/components/ui/widgets/keypad/use-keypad-keyboard.d.ts +7 -0
  121. package/dist/lib/components/ui/widgets/keypad/use-keypad-number.d.ts +10 -0
  122. package/dist/lib/components/ui/widgets/keypad/use-keypad-quantity.d.ts +16 -0
  123. package/dist/lib/components/ui/widgets/keypad/use-keypad-value.d.ts +17 -0
  124. package/dist/lib/components/ui/widgets/keypad/use-keypad.d.ts +23 -0
  125. package/dist/lib/components/ui/widgets/native-charts/core/label-placement.d.ts +25 -0
  126. package/dist/lib/components/ui/widgets/native-charts/core/reference-geometry.d.ts +3 -2
  127. package/dist/lib/hooks/index.d.ts +1 -0
  128. package/dist/lib/hooks/use-barcode-scanner.d.ts +39 -0
  129. package/dist/lib/i18n/resources/en/en.d.ts +28 -0
  130. package/dist/lib/i18n/resources/en/material.json.d.ts +30 -2
  131. package/dist/lib/i18n/resources/fr/fr.d.ts +28 -0
  132. package/dist/lib/i18n/resources/fr/material.json.d.ts +30 -2
  133. package/dist/lib/i18n/resources/resources.d.ts +56 -0
  134. package/dist/lib/i18n/translator.d.ts +1 -1
  135. package/dist/lib/keypad/index.d.ts +20 -0
  136. package/dist/lib/print/output/csv.d.ts +37 -0
  137. package/dist/lib/print/output/index.d.ts +1 -0
  138. package/dist/lib.js +1 -1
  139. package/dist/main.js +54 -53
  140. package/dist/map.js +9 -9
  141. package/dist/material.css +1 -1
  142. package/dist/pdf-reader.js +1 -1
  143. package/dist/{percent-field-DGlU_xii.js → percent-field-sAq7BaxN.js} +15 -14
  144. package/dist/{picker-surface-CGhqNR8a.js → picker-surface--6E-nvpU.js} +4 -4
  145. package/dist/{popover-ZxL7ktKk.js → popover-bEB8I_-w.js} +1 -1
  146. package/dist/{pos-types-BQ0QpYMp.js → pos-types-Cpdc4E33.js} +1 -1
  147. package/dist/{pos-variant-CKy8h_5i.js → pos-variant-ClMGu59I.js} +25 -25
  148. package/dist/print.js +146 -127
  149. package/dist/{programmer-variant-CbHstE28.js → programmer-variant-ChzgyA7x.js} +30 -30
  150. package/dist/{public-D-tdOz4b.js → public-BY8N5NDT.js} +9 -9
  151. package/dist/{rich-code-block-CTPj1LuD.js → rich-code-block-D2GiWuqD.js} +18 -18
  152. package/dist/{scientific-variant-B8U9h3II.js → scientific-variant-31_93gcZ.js} +8 -8
  153. package/dist/{sortable-provider-CSoWE7Ce.js → sortable-provider-DGiVn72t.js} +2 -2
  154. package/dist/{spinner-ffuwBXHl.js → spinner-CEVomQ5K.js} +1 -1
  155. package/dist/standard-layout-DTr9yy8Z.js +48 -0
  156. package/dist/{tabs-JgRq6ZJx.js → tabs-B8MXBbPW.js} +14 -14
  157. package/dist/{text-field-DURkIP-v.js → text-field-DN88qD0Q.js} +16 -15
  158. package/dist/theme-picker.js +13 -13
  159. package/dist/{theme-toggle-n_Zg7JAA.js → theme-toggle-C7pnu1Xh.js} +1 -1
  160. package/dist/{toolbar-items-IANZdcw4.js → toolbar-items-BDfoh8QB.js} +4 -4
  161. package/dist/{translate-material-CMHUH5Ha.js → translate-material-s_lxIV43.js} +1 -1
  162. package/dist/{translator-9zA-Um3W.js → translator-Cgql9srO.js} +56 -4
  163. package/dist/use-calculator-keyboard-DysnFK8m.js +222 -0
  164. package/dist/{use-chat-composer-BoIN7RCA.js → use-chat-composer-xCcp9fVc.js} +2250 -2195
  165. package/dist/{use-heading-spy-Ciw9GBHL.js → use-heading-spy-FIZlf9qj.js} +235 -154
  166. package/dist/{use-material-translation-CLNaMhUf.js → use-material-translation-xNzbSVgS.js} +1 -1
  167. package/dist/{use-return-focus-DWhbTGVe.js → use-return-focus-CW9KkDkp.js} +1 -1
  168. package/docs/README.md +2 -1
  169. package/docs/components/README.md +2 -0
  170. package/docs/components/buttons-and-actions.md +81 -2
  171. package/docs/components/data-display.md +6 -3
  172. package/docs/components/data-table-filter-and-lists.md +19 -6
  173. package/docs/components/feedback-and-status.md +20 -0
  174. package/docs/components/form-fields.md +60 -7
  175. package/docs/components/navigation-and-layout.md +48 -2
  176. package/docs/components/primitives.md +44 -2
  177. package/docs/components/rich-widgets.md +28 -0
  178. package/docs/components/selection-and-choice.md +176 -1
  179. package/docs/guides/calculator.md +1 -1
  180. package/docs/guides/cards-and-tiles.md +31 -24
  181. package/docs/guides/csp.md +4 -3
  182. package/docs/guides/data-grid.md +5 -4
  183. package/docs/guides/field-look-refined.md +2 -2
  184. package/docs/guides/forms.md +1 -0
  185. package/docs/guides/helpers.md +49 -0
  186. package/docs/guides/keypad.md +233 -0
  187. package/docs/guides/printing.md +51 -1
  188. package/docs/previews/buttons-actions-producttile.webp +0 -0
  189. package/docs/previews/data-display-codeblock.webp +0 -0
  190. package/docs/previews/data-display-codegroup.webp +0 -0
  191. package/docs/previews/data-display-jsonviewer.webp +0 -0
  192. package/docs/previews/form-fields-quantitystepper.webp +0 -0
  193. package/docs/previews/navigation-layout-panelcard.webp +0 -0
  194. package/docs/previews/rich-widgets-keypad.webp +0 -0
  195. package/docs/previews/selection-choice-statusmenu.webp +0 -0
  196. package/docs/roadmap.md +21 -0
  197. package/docs/troubleshooting.md +68 -4
  198. package/lib/components/ui/actions/action-card/action-card-tile.css +47 -0
  199. package/lib/components/ui/display/chip/chip-soft.css +27 -2
  200. package/lib/components/ui/display/code/code-moonlight.css +10 -10
  201. package/lib/components/ui/primitives/collapsible/collapsible.css +9 -0
  202. package/lib/components/ui/widgets/calculator/calculator-keys.css +3 -0
  203. package/lib/components/ui/widgets/calculator/calculator.css +118 -0
  204. package/package.json +7 -2
  205. package/dist/field-blur-context-BLGgf_3z.js +0 -73
  206. package/dist/key-layout-cR79xfGE.js +0 -38
  207. package/dist/standard-layout-BuSRr3TY.js +0 -40
@@ -0,0 +1,18 @@
1
+ import { StatusChoice, StatusMenuProps } from './types.js';
2
+ export declare const isThenable: (v: unknown) => v is PromiseLike<unknown>;
3
+ /**
4
+ * Runs a pick: an `onSelect` that returns a promise is pending until it
5
+ * settles (the old status stays), a rejection is announced and sent to
6
+ * `onError`. `message` is what the live region says; `confirming` is the
7
+ * choice waiting for its confirmation.
8
+ */
9
+ export declare function useStatusChange<V extends string>(props: StatusMenuProps<V>, labelOf: (value: V) => string): {
10
+ pending: boolean;
11
+ message: string | null;
12
+ confirming: StatusChoice<V> | null;
13
+ start: (next: V) => void;
14
+ ask: (choice: StatusChoice<V>) => void;
15
+ cancelAsk: () => void;
16
+ /** What the confirm dialog runs: a throw stays in the dialog and goes to `onError`. */
17
+ confirmRun: (next: V) => Promise<void>;
18
+ };
@@ -0,0 +1,30 @@
1
+ import { StatusChoice, StatusMenuProps } from './types.js';
2
+ /** The model of a StatusMenu: its entries, names and the open state. */
3
+ export declare function useStatusMenu<V extends string>(props: StatusMenuProps<V>): {
4
+ sheet: boolean;
5
+ change: {
6
+ pending: boolean;
7
+ message: string | null;
8
+ confirming: StatusChoice<V> | null;
9
+ start: (next: V) => void;
10
+ ask: (choice: StatusChoice<V>) => void;
11
+ cancelAsk: () => void;
12
+ confirmRun: (next: V) => Promise<void>;
13
+ };
14
+ busy: boolean;
15
+ entries: {
16
+ entry: import('@nxgt/material-core/status-menu').StatusEntry<V>;
17
+ choice: StatusChoice<V>;
18
+ }[];
19
+ current: StatusChoice<V> | undefined;
20
+ reasonId: string;
21
+ open: boolean;
22
+ reasonOf: ({ entry, choice }: {
23
+ entry: import('@nxgt/material-core/status-menu').StatusEntry<V>;
24
+ choice: StatusChoice<V>;
25
+ }) => string | undefined;
26
+ lockedReason: string | undefined;
27
+ name: string;
28
+ setOpen: (next: boolean) => void;
29
+ pick: (next: string) => void;
30
+ };
@@ -1,8 +1,4 @@
1
- /**
2
- * The keys as native buttons in one `role="group"`. The group is one tab
3
- * stop (a roving tabindex); the arrow keys move over the grid in two
4
- * dimensions, Home and End along a row, with Ctrl to the first and last key.
5
- */
1
+ /** The calculator's keys: the shared keypad grid bound to the engine's press. */
6
2
  export declare function CalculatorKeypad({ helpId }: {
7
3
  helpId: string;
8
4
  }): import("react").JSX.Element;
@@ -1,51 +1,5 @@
1
- import { CalcKey } from '@nxgt/material-core/calculator';
2
- import { CalculatorMessage } from '../types.js';
3
- import { POS_NAMES } from './pos/pos-names.js';
4
- import { PROGRAMMER_NAMES } from './programmer/programmer-names.js';
5
- import { SCIENTIFIC_NAMES } from './scientific/scientific-names.js';
6
- /** What a key looks like: its shape and colour follow the role. */
7
- export type KeyRole = 'digit' | 'operator' | 'equals' | 'utility' | 'function' | 'memory'
8
- /** ( and ): small keys like the memory ones. */
9
- | 'bracket';
10
- export type KeyDef = {
11
- readonly id: string;
12
- /** The engine key it presses. */
13
- readonly key: CalcKey;
14
- /** What is drawn; `aria-hidden`, the spoken name is `name`. */
15
- readonly glyph: string;
16
- readonly role: KeyRole;
17
- /** The spoken name, the button's `aria-label`. */
18
- readonly name: CalculatorMessage;
19
- /** Grid units spanned, 1 by default. */
20
- readonly span?: number;
21
- /** What the key is on the second page (2nd): same place, another key. */
22
- readonly alt?: KeyAlt;
23
- /** Keys pressed one after the other, instead of `key` (`EE` is `* 10 ^`). */
24
- readonly sequence?: readonly CalcKey[];
25
- };
26
- /** A key's second-page face: it keeps the button, so focus stays put. */
27
- export type KeyAlt = Pick<KeyDef, 'key' | 'glyph' | 'name'>;
28
- /** Keys by rows on a grid of `columns`. */
29
- export type KeyLayout = {
30
- readonly columns: number;
31
- readonly rows: readonly (readonly KeyDef[])[];
32
- /**
33
- * The first `split` rows are a pane of their own (the scientific
34
- * functions): above the rest on a phone, beside it from 600px.
35
- */
36
- readonly split?: number;
37
- };
38
- /** The spoken names, as the `material.calculator.keys.*` leaves. */
39
- export type KeyName = (typeof DIGIT_NAMES)[number] | 'decimal' | 'add' | 'subtract' | 'multiply' | 'divide' | 'equals' | 'clear' | 'backspace' | 'sign' | 'percent' | 'open-paren' | 'close-paren' | 'memory-clear' | 'memory-recall' | 'memory-add' | 'memory-subtract' | (typeof SCIENTIFIC_NAMES)[number] | (typeof POS_NAMES)[number] | (typeof PROGRAMMER_NAMES)[number];
40
- export declare const msg: (name: KeyName, fallback: string) => CalculatorMessage;
41
- export declare const key: (id: string, k: CalcKey, glyph: string, role: KeyRole, name: KeyName, fallback: string, span?: number) => KeyDef;
42
- export declare const DIGIT_NAMES: readonly ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
43
- export declare const digit: (n: number, span?: number) => KeyDef;
1
+ import { KeyDef } from '../../keypad/key-layout.js';
44
2
  /** `( ) MC MR M+ M-`: six small keys, two grid units each (twelve units a row). */
45
3
  export declare const MEMORY_ROW: readonly KeyDef[];
46
- /** A row of four keys, three grid units each, on the twelve-unit grid. */
47
- export declare const wide: (keys: readonly KeyDef[]) => readonly KeyDef[];
48
- /** The key a pressed `def` stands for on page one or, with 2nd, page two. */
49
- export declare const faceOf: (def: KeyDef, second: boolean) => KeyDef;
50
- /** The keys a press of `def` sends to the engine, in order. */
51
- export declare const keysOf: (def: KeyDef) => readonly CalcKey[];
4
+ export type { KeyAlt, KeyDef, KeyLayout, KeyName, KeyRole, } from '../../keypad/key-layout.js';
5
+ export { DIGIT_NAMES, digit, faceOf, key, keysOf, msg, wide, } from '../../keypad/key-layout.js';
@@ -0,0 +1,16 @@
1
+ import { KeypadSettlement } from './keypad.types.js';
2
+ /**
3
+ * The total as the till charges it: rounded half-up, once, to the decimals
4
+ * kept (a float sum such as `0.1 + 0.2` is `0.3`, `19.999` is `20`), as
5
+ * canonical text. `undefined` when it is missing or not a number. Settlement,
6
+ * shortcuts and the summary all start from this one amount.
7
+ */
8
+ export declare function cashTotal(total: number | string | undefined, digits?: number): string | undefined;
9
+ /** The settlement of `tendered` against `total`; `undefined` while nothing is tendered or an amount is invalid. */
10
+ export declare function cashSettlement(total: number | string | undefined, tendered: string): KeypadSettlement | undefined;
11
+ /**
12
+ * The amounts to offer as one-tap tenders: the exact total, then the round
13
+ * amounts above it, at most four, rounded to `digits` and none above `max`
14
+ * (the keypad would hold less than the button says).
15
+ */
16
+ export declare function cashShortcuts(total: number | string | undefined, denominations: readonly number[] | undefined, max?: number, digits?: number, limit?: number): string[];
@@ -0,0 +1,5 @@
1
+ export { Keypad } from './keypad.js';
2
+ export type { KeypadBinding, KeypadEntry, KeypadOperation, KeypadProps, KeypadSettlement, KeypadVariant, } from './keypad.types.js';
3
+ export type { UseKeypadNumberOptions } from './keypad-binding.js';
4
+ export { useKeypadNumber } from './use-keypad-number.js';
5
+ export { type UseKeypadQuantityOptions, useKeypadQuantity, } from './use-keypad-quantity.js';
@@ -0,0 +1,56 @@
1
+ import { CalcKey } from '@nxgt/material-core/calculator';
2
+ import { MaterialLocaleKey } from '../../../../i18n/types.js';
3
+ import { POS_NAMES } from '../calculator/variants/pos/pos-names.js';
4
+ import { PROGRAMMER_NAMES } from '../calculator/variants/programmer/programmer-names.js';
5
+ import { SCIENTIFIC_NAMES } from '../calculator/variants/scientific/scientific-names.js';
6
+ /** What a key looks like: its shape and colour follow the role. */
7
+ export type KeyRole = 'digit' | 'operator' | 'equals' | 'utility' | 'function' | 'memory'
8
+ /** ( and ): small keys like the memory ones. */
9
+ | 'bracket';
10
+ /** A UI string: the `material.*` key and the English text used without a provider. */
11
+ export type KeyMessage = {
12
+ readonly key: MaterialLocaleKey;
13
+ readonly fallback: string;
14
+ };
15
+ export type KeyDef = {
16
+ readonly id: string;
17
+ /** The engine key it presses. */
18
+ readonly key: CalcKey;
19
+ /** What is drawn; `aria-hidden`, the spoken name is `name`. */
20
+ readonly glyph: string;
21
+ readonly role: KeyRole;
22
+ /** The spoken name, the button's `aria-label`. */
23
+ readonly name: KeyMessage;
24
+ /** An app's own spoken name, which replaces the translated `name`. */
25
+ readonly label?: string;
26
+ /** Grid units spanned, 1 by default. */
27
+ readonly span?: number;
28
+ /** What the key is on the second page (2nd): same place, another key. */
29
+ readonly alt?: KeyAlt;
30
+ /** Keys pressed one after the other, instead of `key` (`EE` is `* 10 ^`). */
31
+ readonly sequence?: readonly CalcKey[];
32
+ };
33
+ /** A key's second-page face: it keeps the button, so focus stays put. */
34
+ export type KeyAlt = Pick<KeyDef, 'key' | 'glyph' | 'name'>;
35
+ /** Keys by rows on a grid of `columns`. */
36
+ export type KeyLayout = {
37
+ readonly columns: number;
38
+ readonly rows: readonly (readonly KeyDef[])[];
39
+ /**
40
+ * The first `split` rows are a pane of their own (the scientific
41
+ * functions): above the rest on a phone, beside it from 600px.
42
+ */
43
+ readonly split?: number;
44
+ };
45
+ /** A row of four keys, three grid units each, on the twelve-unit grid. */
46
+ export declare const wide: (keys: readonly KeyDef[]) => readonly KeyDef[];
47
+ /** The key a pressed `def` stands for on page one or, with 2nd, page two. */
48
+ export declare const faceOf: (def: KeyDef, second: boolean) => KeyDef;
49
+ /** The keys a press of `def` sends to the engine, in order. */
50
+ export declare const keysOf: (def: KeyDef) => readonly CalcKey[];
51
+ /** The spoken names, as the `material.calculator.keys.*` leaves. */
52
+ export type KeyName = (typeof DIGIT_NAMES)[number] | 'decimal' | 'add' | 'subtract' | 'multiply' | 'divide' | 'equals' | 'clear' | 'backspace' | 'sign' | 'percent' | 'open-paren' | 'close-paren' | 'memory-clear' | 'memory-recall' | 'memory-add' | 'memory-subtract' | (typeof SCIENTIFIC_NAMES)[number] | (typeof POS_NAMES)[number] | (typeof PROGRAMMER_NAMES)[number];
53
+ export declare const msg: (name: KeyName, fallback: string) => KeyMessage;
54
+ export declare const key: (id: string, k: CalcKey, glyph: string, role: KeyRole, name: KeyName, fallback: string, span?: number) => KeyDef;
55
+ export declare const DIGIT_NAMES: readonly ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
56
+ export declare const digit: (n: number, span?: number) => KeyDef;
@@ -0,0 +1,32 @@
1
+ import { KeypadBinding, KeypadProps } from './keypad.types.js';
2
+ export type UseKeypadNumberOptions = {
3
+ /** The field's number (`null` or `undefined` while empty). */
4
+ value: number | null | undefined;
5
+ onChange?: (value: number | null) => void;
6
+ min?: number;
7
+ max?: number;
8
+ /** Decimals kept; a `currency`'s own by default. */
9
+ fractionDigits?: number;
10
+ currency?: string;
11
+ /** The field holds whole minor units (CurrencyField's `minorUnits`): 1250 is 12.50. */
12
+ minorUnits?: boolean;
13
+ };
14
+ /** The decimals a binding keeps; `undefined` for any number of them. */
15
+ export declare function bindingDigits(o: UseKeypadNumberOptions): number | undefined;
16
+ /** A field number as the keypad's value text; `''` when empty or not a finite number. */
17
+ export declare function numberToText(value: number | null | undefined, o: Pick<UseKeypadNumberOptions, 'minorUnits'> & {
18
+ digits?: number;
19
+ }): string;
20
+ /** The keypad's value text as the field's number: `null` when empty. */
21
+ export declare function textToNumber(text: string, o: Pick<UseKeypadNumberOptions, 'minorUnits'> & {
22
+ digits?: number;
23
+ }): number | null;
24
+ /** The keypad binding of a number held by a field. */
25
+ export declare function numberBinding(o: UseKeypadNumberOptions): KeypadBinding;
26
+ /**
27
+ * The props a keypad runs with: an explicit prop wins over the binding's, both
28
+ * `onValueChange` handlers are called, and the display is off for a bound
29
+ * keypad unless asked for or `operations` are offered (the field shows the
30
+ * number, but not the calculation in progress).
31
+ */
32
+ export declare function resolveBinding(props: KeypadProps): KeypadProps;
@@ -0,0 +1,28 @@
1
+ import { KeypadSettlement } from './keypad.types.js';
2
+ type Format = {
3
+ digits: number | undefined;
4
+ locale?: string;
5
+ currency?: string;
6
+ };
7
+ /** The total, and under it the change or what is still due once something is tendered. */
8
+ export declare function KeypadCashSummary({ total, settlement, digits, locale, currency, }: Format & {
9
+ total: string;
10
+ settlement: KeypadSettlement | undefined;
11
+ }): import("react").JSX.Element;
12
+ /** One-tap tendered amounts: the exact total, then the round amounts above it. */
13
+ export declare function KeypadShortcuts({ amounts, onPick, disabled, digits, locale, currency, }: Format & {
14
+ amounts: readonly string[];
15
+ onPick: (amount: string) => void;
16
+ disabled?: boolean;
17
+ }): import("react").JSX.Element | null;
18
+ /** The cash variant's parts above the keys: the total with its settlement, then the shortcuts. */
19
+ export declare function KeypadCash({ cash, total, onPick, disabled, digits, locale, currency, }: Format & {
20
+ cash: {
21
+ settlement: KeypadSettlement | undefined;
22
+ shortcuts: readonly string[];
23
+ };
24
+ total: string;
25
+ onPick: (amount: string) => void;
26
+ disabled?: boolean;
27
+ }): import("react").JSX.Element;
28
+ export {};
@@ -0,0 +1,11 @@
1
+ import { useKeypad } from './use-keypad.js';
2
+ /** A canonical amount for a locale at fixed decimals, with the currency's symbol when given. */
3
+ export declare function formatAmount(text: string, digits: number | undefined, locale: string | undefined, currency: string | undefined): string;
4
+ type Props = {
5
+ keypad: ReturnType<typeof useKeypad>;
6
+ locale?: string;
7
+ currency?: string;
8
+ };
9
+ /** The amount above the keys; after `=` it is the result, not the expression. */
10
+ export declare function KeypadDisplay({ keypad: k, locale, currency }: Props): import("react").JSX.Element;
11
+ export {};
@@ -0,0 +1,39 @@
1
+ import { CalcKey, CalcSession } from '@nxgt/material-core/calculator';
2
+ import { KeypadOperation } from './keypad.types.js';
3
+ export declare const ALL_OPERATIONS: readonly KeypadOperation[];
4
+ /** The operations a keypad offers for its `operations` prop. */
5
+ export declare function operationsOf(operations: boolean | readonly KeypadOperation[] | undefined): readonly KeypadOperation[];
6
+ /** The operations a keypad runs with: none in minor entry nor in the cash variant. */
7
+ export declare function keypadOperations(o: {
8
+ entry?: 'decimal' | 'minor';
9
+ variant?: 'standard' | 'cash';
10
+ operations?: boolean | readonly KeypadOperation[];
11
+ }): readonly KeypadOperation[];
12
+ export declare const operationKey: (o: KeypadOperation) => CalcKey;
13
+ export type EntryConfig = {
14
+ entry: 'decimal' | 'minor';
15
+ /** Decimals kept; `undefined` for any number of them. */
16
+ digits: number | undefined;
17
+ operations: readonly KeypadOperation[];
18
+ max?: number;
19
+ };
20
+ /** A session that holds `value` as typed. */
21
+ export declare function seedSession(value: string): CalcSession;
22
+ /** The value text of a session: the result after `=`, the number typed, `''` mid-calculation. */
23
+ export declare function sessionValue(s: CalcSession): string;
24
+ /** True while the expression is more than one number (a calculation to evaluate). */
25
+ export declare const isPending: (s: CalcSession) => boolean;
26
+ /**
27
+ * One key of a keypad. Pure: the next session comes back, or the same one
28
+ * when the key does nothing here (an operation not offered, a decimal key at
29
+ * no decimals, a digit past `max` or past the decimals kept).
30
+ */
31
+ export declare function pressEntry(s: CalcSession, key: CalcKey, cfg: EntryConfig): CalcSession;
32
+ /** `value` held between `min` and `max` (either may be absent); `''` stays `''`. */
33
+ export declare function clampValue(value: string, min?: number, max?: number): string;
34
+ /**
35
+ * The value to tell the app after a key, or `undefined` when there is nothing
36
+ * to tell: while a calculation waits the field keeps the number it had, and a
37
+ * key that leaves the value as reported says nothing.
38
+ */
39
+ export declare function valueToReport(next: CalcSession, reported: string): string | undefined;
@@ -0,0 +1,27 @@
1
+ import { KeyDef, KeyLayout } from './key-layout.js';
2
+ export type KeypadGridProps = {
3
+ layout: KeyLayout;
4
+ /** The group's accessible name. */
5
+ label: string;
6
+ /** The id of the element that describes the group. */
7
+ describedBy?: string;
8
+ /** What the decimal key draws: the locale's separator. */
9
+ decimal: string;
10
+ /** The face a key shows (the calculator's 2nd page); the key itself by default. */
11
+ faceOf?: (def: KeyDef) => KeyDef;
12
+ /** A key that stays focusable, says so, and presses nothing. */
13
+ unavailable?: (def: KeyDef) => boolean;
14
+ onPress: (def: KeyDef) => void;
15
+ /** The group's `data-slot` and class, then its keys' and panes' (the calculator's by default). */
16
+ slot?: string;
17
+ className?: string;
18
+ keySlot?: string;
19
+ keyClassName?: string;
20
+ paneClassName?: string;
21
+ };
22
+ /**
23
+ * The keys as native buttons in one `role="group"`. The group is one tab
24
+ * stop (a roving tabindex); the arrow keys move over the grid in two
25
+ * dimensions, Home and End along a row, with Ctrl to the first and last key.
26
+ */
27
+ export declare function KeypadGrid({ layout, label, describedBy, decimal, faceOf, unavailable, onPress, slot, className, keySlot, keyClassName, paneClassName, }: KeypadGridProps): import("react").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { Ref } from 'react';
2
- import { KeyDef } from '../variants/key-layout.js';
3
- export type CalculatorKeyProps = {
2
+ import { KeyDef } from './key-layout.js';
3
+ export type KeypadKeyProps = {
4
4
  def: KeyDef;
5
5
  row: number;
6
6
  index: number;
@@ -12,6 +12,9 @@ export type CalculatorKeyProps = {
12
12
  onPress: (def: KeyDef) => void;
13
13
  onFocus: (row: number, index: number) => void;
14
14
  buttonRef: Ref<HTMLButtonElement>;
15
+ /** The button's `data-slot` and class (the calculator's by default). */
16
+ slot?: string;
17
+ className?: string;
15
18
  };
16
19
  /** One native button. Its glyph is decoration; the spoken name is the label. */
17
- export declare function CalculatorKey({ def, row, index, tabIndex, decimal, unavailable, onPress, onFocus, buttonRef, }: CalculatorKeyProps): import("react").JSX.Element;
20
+ export declare function KeypadKey({ def, row, index, tabIndex, decimal, unavailable, onPress, onFocus, buttonRef, slot, className, }: KeypadKeyProps): import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { KeyLayout } from './key-layout.js';
2
+ import { KeypadOperation } from './keypad.types.js';
3
+ export type KeypadLayoutOptions = {
4
+ operations: readonly KeypadOperation[];
5
+ /** The decimal key; off at no decimals, and when digits go in as minor units. */
6
+ decimal: boolean;
7
+ /** The commit key's text and name, when the app names it. */
8
+ commitLabel?: string;
9
+ /** True while a calculation waits: the commit key then reads "=". */
10
+ pending: boolean;
11
+ /** The cash variant: the commit key tenders. */
12
+ cash?: boolean;
13
+ };
14
+ /**
15
+ * Twelve grid units: 7 8 9 C / 4 5 6 ⌫ / 1 2 3 00 / 0 . and the commit key,
16
+ * with a row of the offered operations above. `wide` makes four keys of three
17
+ * units; the last row's `0` takes six.
18
+ */
19
+ export declare function keypadLayout(o: KeypadLayoutOptions): KeyLayout;
@@ -1,4 +1,4 @@
1
- import { KeyLayout } from '../variants/key-layout.js';
1
+ import { KeyLayout } from './key-layout.js';
2
2
  export type Cell = {
3
3
  readonly row: number;
4
4
  readonly index: number;
@@ -0,0 +1,9 @@
1
+ import { KeypadProps } from './keypad.types.js';
2
+ /**
3
+ * `Keypad`: touch and keyboard numeric entry outside the Calculator widget,
4
+ * for a quantity, a price, a percentage. The digits go in as typed
5
+ * (`entry="decimal"`) or like a till (`entry="minor"`); `operations` adds
6
+ * calculation keys. The value is a canonical decimal string. Styled by
7
+ * `calculator.css`.
8
+ */
9
+ export declare function Keypad(raw: KeypadProps): import("react").JSX.Element;
@@ -0,0 +1,91 @@
1
+ /** A calculation key the keypad can offer next to the digits. */
2
+ export type KeypadOperation = 'add' | 'subtract' | 'multiply' | 'divide';
3
+ /** What the keypad is for: plain `standard` entry, or a `cash` tender against a `total`. */
4
+ export type KeypadVariant = 'standard' | 'cash';
5
+ /**
6
+ * The outcome of a cash tender, amounts as canonical decimal text: the
7
+ * customer gave enough (`change` may be `'0'`), or still owes `due`.
8
+ */
9
+ export type KeypadSettlement = {
10
+ readonly status: 'paid';
11
+ readonly change: string;
12
+ } | {
13
+ readonly status: 'short';
14
+ readonly due: string;
15
+ };
16
+ /** How the digits go in: `decimal` as typed (`1`, `2`, `.`, `5` is 12.5), or `minor` like a till (`1`, `2`, `5` is 1.25). */
17
+ export type KeypadEntry = 'decimal' | 'minor';
18
+ /**
19
+ * A field's number as the keypad reads and writes it (from `useKeypadNumber`
20
+ * or `useKeypadQuantity`). Pass it whole as the `binding` prop. The field keeps its number while a calculation is typed; `onValueChange` is called with the result at `=`.
21
+ */
22
+ export type KeypadBinding = {
23
+ /** The field's number as canonical decimal text (`''` when empty). */
24
+ value: string;
25
+ onValueChange: (value: string) => void;
26
+ /** The decimals the field keeps. */
27
+ fractionDigits?: number;
28
+ min?: number;
29
+ max?: number;
30
+ };
31
+ export type KeypadProps = {
32
+ /** The value as canonical decimal text (`'12.5'`, `''` when empty). Controlled with `onValueChange`. */
33
+ value?: string;
34
+ /** The value of an uncontrolled keypad. */
35
+ defaultValue?: string;
36
+ /** Called with the new value text whenever it changes (`''` when emptied); not while a calculation waits for `=`. */
37
+ onValueChange?: (value: string) => void;
38
+ /**
39
+ * The commit key (or Enter): the value, within `min` and `max`, and the
40
+ * expression that gave it (`'2+3'`; the value itself without operations).
41
+ * With operations, the key first evaluates a pending calculation.
42
+ */
43
+ onCommit?: (value: string, expression: string) => void;
44
+ /** Calculation keys: `true` offers all four, a list picks some. Off by default; `minor` entry and the `cash` variant take none. */
45
+ operations?: boolean | readonly KeypadOperation[];
46
+ /** The locale of the decimal separator, grouping and spoken results; the page's by default. */
47
+ locale?: string;
48
+ /** Decimals kept: further digits are refused, a calculation is rounded half-up to them. The currency's by default. */
49
+ fractionDigits?: number;
50
+ /** An ISO 4217 code: the amount shows its symbol and takes the currency's decimals. */
51
+ currency?: string;
52
+ /** The commit key clamps the value to this floor and ceiling; typing past `max` is refused. */
53
+ min?: number;
54
+ max?: number;
55
+ /**
56
+ * Where the physical keyboard works: `'focus'` (default) when focus is in
57
+ * the keypad, `'global'` anywhere on the page outside fields, `false` never.
58
+ */
59
+ keyboard?: 'focus' | 'global' | false;
60
+ /** Key height: `comfortable` (default) or `large` for a till. */
61
+ size?: 'comfortable' | 'large';
62
+ /** The commit key's name and text; the translated "Enter" by default. */
63
+ commitLabel?: string;
64
+ /** Keys do nothing and say so. */
65
+ disabled?: boolean;
66
+ /** `'standard'` (default) or `'cash'`: tender against `total`, with change, bill shortcuts and `onTender`. */
67
+ variant?: KeypadVariant;
68
+ /** `cash`: the amount due, as a number or exact decimal text. */
69
+ total?: number | string;
70
+ /** `cash`: the bills and coins (`[5, 10, 20, 50]`) whose next round amount at or above `total` is offered as an amount button after the exact total (four buttons at most, none above `max`). A button fills the amount; the commit key tenders. */
71
+ denominations?: readonly number[];
72
+ /**
73
+ * `cash`: the commit key (or Enter) with the amount tendered and the
74
+ * settlement, once a valid `total` is set and an amount is entered (a missing
75
+ * or negative `total` does nothing). `onCommit` is not called in this variant. The app owns the charge; the keypad only reports it. A
76
+ * short payment is a settlement too, not an error.
77
+ */
78
+ onTender?: (tendered: string, settlement: KeypadSettlement) => void;
79
+ /** `'decimal'` (default) or `'minor'`. */
80
+ entry?: KeypadEntry;
81
+ /**
82
+ * A field the keypad types into (`useKeypadNumber`, `useKeypadQuantity`).
83
+ * Its value, decimals, `min` and `max` apply unless the same prop is given.
84
+ */
85
+ binding?: KeypadBinding;
86
+ /** Shows the amount above the keys: by default when no `binding` is given or `operations` are offered (the field shows the number, not the calculation). */
87
+ display?: boolean;
88
+ /** The keypad's accessible name; "Keypad" by default. */
89
+ label?: string;
90
+ className?: string;
91
+ };
@@ -0,0 +1,14 @@
1
+ import { KeypadProps } from './keypad.types.js';
2
+ import { useKeypad } from './use-keypad.js';
3
+ /**
4
+ * What the cash variant adds to the keypad: the settlement of what is
5
+ * tendered so far, the bill shortcuts, and the sentence the live region says
6
+ * ("Change 2.65", "Still due 1.00"). Nothing for the standard variant.
7
+ */
8
+ export declare function useKeypadCash(p: Pick<KeypadProps, 'variant' | 'total' | 'denominations' | 'locale' | 'currency' | 'max'>, k: ReturnType<typeof useKeypad>): {
9
+ cash: boolean;
10
+ total: string | undefined;
11
+ settlement: import('./keypad.types.js').KeypadSettlement | undefined;
12
+ shortcuts: string[];
13
+ said: string | undefined;
14
+ };
@@ -0,0 +1,7 @@
1
+ import { useKeypad } from './use-keypad.js';
2
+ /**
3
+ * The physical keyboard: `onKeyDown` for the keypad's root (the `'focus'`
4
+ * mode), and with `global` a window listener too. Enter commits, the other
5
+ * keys press; a key the keypad does not offer is left to the page.
6
+ */
7
+ export declare function useKeypadKeyboard(k: ReturnType<typeof useKeypad>, locale: string | undefined, global: boolean): (ev: import('react').KeyboardEvent<HTMLElement>) => void;
@@ -0,0 +1,10 @@
1
+ import { KeypadBinding } from './keypad.types.js';
2
+ import { UseKeypadNumberOptions } from './keypad-binding.js';
3
+ /**
4
+ * Binds a Keypad to a number field's value (`NumberField`, `PercentField`,
5
+ * `CurrencyField`, including its `minorUnits`): pass the result as the
6
+ * keypad's `binding`. The keypad reads the field's number, writes each change
7
+ * back, holds `min` / `max` and the decimals, and hides its own display unless
8
+ * `operations` are offered.
9
+ */
10
+ export declare function useKeypadNumber(options: UseKeypadNumberOptions): KeypadBinding;
@@ -0,0 +1,16 @@
1
+ import { QuantityValue } from '../../fields/quantity-field/types.js';
2
+ import { KeypadBinding } from './keypad.types.js';
3
+ export type UseKeypadQuantityOptions = {
4
+ /** The QuantityField's value: the amount and its unit. */
5
+ value: QuantityValue | undefined;
6
+ /** Called on each change; `value` is `null` when the keypad is emptied. */
7
+ onChange?: (value: QuantityValue) => void;
8
+ min?: number;
9
+ max?: number;
10
+ fractionDigits?: number;
11
+ };
12
+ /**
13
+ * Binds a Keypad to a `QuantityField`'s amount: the keypad types the number,
14
+ * the unit stays as the field holds it.
15
+ */
16
+ export declare function useKeypadQuantity(options: UseKeypadQuantityOptions): KeypadBinding;
@@ -0,0 +1,17 @@
1
+ import { CalcSession } from '@nxgt/material-core/calculator';
2
+ import { RefObject } from 'react';
3
+ import { KeypadProps } from './keypad.types.js';
4
+ type ValueOptions = Pick<KeypadProps, 'value' | 'defaultValue' | 'onValueChange'>;
5
+ /**
6
+ * The keypad's session and its link to the app's value. A controlled `value`
7
+ * is the truth on every render: when it differs from the value the keypad
8
+ * last held or reported, the session is replaced by it (the app cleared, set
9
+ * or refused a change), even while a calculation waits. `report` tells the
10
+ * app the value, except while a calculation waits for `=`.
11
+ */
12
+ export declare function useKeypadValue(o: ValueOptions, onValueChange: RefObject<ValueOptions['onValueChange']>): {
13
+ session: CalcSession;
14
+ setInner: import('react').Dispatch<import('react').SetStateAction<CalcSession>>;
15
+ report: (next: CalcSession) => void;
16
+ };
17
+ export {};
@@ -0,0 +1,23 @@
1
+ import { CalcKey } from '@nxgt/material-core/calculator';
2
+ import { KeypadProps } from './keypad.types.js';
3
+ type Options = Pick<KeypadProps, 'value' | 'defaultValue' | 'onValueChange' | 'onCommit' | 'variant' | 'total' | 'onTender' | 'operations' | 'fractionDigits' | 'currency' | 'min' | 'max' | 'entry' | 'disabled'>;
4
+ /**
5
+ * The keypad's state: a calculator session, held as typed. A controlled
6
+ * `value` is the truth on every render: when it differs from the value the
7
+ * keypad last held or reported, it replaces the session (the app cleared, set
8
+ * or refused a change), even while a calculation waits; `onValueChange` fires when a key changes the
9
+ * value text, not on every key (a `.` or an operator does not) and never
10
+ * while a calculation waits for `=`.
11
+ */
12
+ export declare function useKeypad(o: Options): {
13
+ session: import('@nxgt/material-core/calculator').CalcSession;
14
+ value: string;
15
+ pending: boolean;
16
+ digits: number | undefined;
17
+ entry: import('./keypad.types.js').KeypadEntry;
18
+ operations: readonly import('./keypad.types.js').KeypadOperation[];
19
+ press: (key: CalcKey) => void;
20
+ commit: () => void;
21
+ set: (value: string) => void;
22
+ };
23
+ export {};
@@ -0,0 +1,25 @@
1
+ /** A point of a series on the plot, in pixels. */
2
+ export type PlotPoint = {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ /**
7
+ * Where a threshold's label goes: the first of end-above, end-below, start-above
8
+ * and start-below whose text box stays inside the plot and meets no series
9
+ * segment nor marker within its x-range. When none is free, the label stays at
10
+ * the end, clamped inside the plot (`thresholdLabelBaseline`). `edge` is the x
11
+ * of the label's end side (its right edge), `startEdge` of its start side (its
12
+ * left edge); `width` is the text's width. The label box spans `edge - width`
13
+ * to `edge` at the end side, `startEdge` to `startEdge + width` at the start.
14
+ */
15
+ export declare function placeThresholdLabel(input: {
16
+ lineY: number;
17
+ floor: number;
18
+ edge: number;
19
+ startEdge: number;
20
+ width: number;
21
+ series: readonly (readonly (PlotPoint | null)[])[];
22
+ }): {
23
+ side: 'end' | 'start';
24
+ baseline: number;
25
+ };
@@ -57,9 +57,10 @@ export declare function markersBetween(ys: readonly (number | null)[], x: (index
57
57
  * of the plot. `pointYs` are the y of the series' points under the label's
58
58
  * width: when one would sit on the label above the line and none would
59
59
  * under it, the label goes to the other side, so it never covers a point or
60
- * its marker.
60
+ * its marker. `floor` is the plot's height: the label stays inside the plot,
61
+ * so a side with no room is left for the other, or the baseline is clamped.
61
62
  */
62
- export declare function thresholdLabelBaseline(lineY: number, pointYs?: readonly number[]): number;
63
+ export declare function thresholdLabelBaseline(lineY: number, pointYs?: readonly number[], floor?: number): number;
63
64
  /** How many of `values` lie outside `band` (a missing value is not counted, nor one in a row where a stepped band has no range), and how many there are. */
64
65
  export declare function outsideBand(values: readonly (number | null | undefined)[], band: Pick<RefBand, 'from' | 'to' | 'ranges'>): {
65
66
  outside: number;