@nxgt/material 3.75.0 → 3.76.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 (239) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +37 -1
  3. package/dist/{alert-dialog-BfO_ri-N.js → alert-dialog-653apk3f.js} +8 -7
  4. package/dist/{async-slice-roMAJVzG.js → async-slice-CXLbQuOc.js} +1 -1
  5. package/dist/{bubble-input-B7BVd9fX.js → bubble-input-CQwVSoU3.js} +30 -29
  6. package/dist/{button-DgenqmpS.js → button-3op3rtZh.js} +5 -4
  7. package/dist/calculator-BaSMe0SK.js +1189 -0
  8. package/dist/calculator-announce-DRd2c6Dq.js +89 -0
  9. package/dist/calculator-context-BugcKuVG.js +10 -0
  10. package/dist/calculator-field.js +172 -0
  11. package/dist/calculator-panel-announce-AZSnZUSr.js +29 -0
  12. package/dist/calculator-segment-BlJE1LaS.js +22 -0
  13. package/dist/calculator.js +2 -0
  14. package/dist/charts.js +3 -3
  15. package/dist/{chip-CiDczNxO.js → chip-MuKDwtkG.js} +2 -2
  16. package/dist/{code-editor-CohlhFsA.js → code-editor-Bp2RrdNx.js} +13 -13
  17. package/dist/code-editor.js +37 -37
  18. package/dist/{code-language-items-Cs8GLYDp.js → code-language-items-B7WR5ua_.js} +19 -24
  19. package/dist/components/base-content.css +9 -4
  20. package/dist/components/ui/collections/server-table/server-table-phone-row.css +10 -3
  21. package/dist/{components-zJdfH4im.js → components-Ci3Zo8kC.js} +15837 -17245
  22. package/dist/components.js +37 -28
  23. package/dist/conversion-variant-BDFAxqe9.js +529 -0
  24. package/dist/copy-to-clipboard-Be5Ffvs_.js +7 -0
  25. package/dist/currency-B-r3ig11.js +16 -0
  26. package/dist/currency-field-BJ9rSrif.js +285 -0
  27. package/dist/{number.utils-BG_eEt5g.js → date.utils-DUvqcjan.js} +1 -7
  28. package/dist/dialog-Bm5LvVlB.js +166 -0
  29. package/dist/dist-BZe2evxL.js +139 -0
  30. package/dist/dist-CxhKjOYm.js +28 -0
  31. package/dist/dist-DHdUUM1w.js +241 -0
  32. package/dist/{dist-C4wtXCjf.js → dist-DOK3zo5C.js} +33 -32
  33. package/dist/dist-DWZXlCZR.js +182 -0
  34. package/dist/dist-DkQbkF9T.js +33 -0
  35. package/dist/dnd.js +1 -1
  36. package/dist/{dropdown-menu-CzR6JP31.js → dropdown-menu-xlZ6NYUA.js} +160 -159
  37. package/dist/editor.js +299 -298
  38. package/dist/{empty-state-DjHGMp5F.js → empty-state-C0kviQdW.js} +2 -2
  39. package/dist/{field-blur-CdASxjL7.js → field-blur-DkiZOVNV.js} +178 -180
  40. package/dist/{field-blur-context-kZ4SD7xu.js → field-blur-context-BLGgf_3z.js} +2 -2
  41. package/dist/financial-variant-BsZEa5sF.js +459 -0
  42. package/dist/{hooks-Dqq8O3Az.js → hooks-Dg94jPRq.js} +12 -12
  43. package/dist/hooks.js +2 -2
  44. package/dist/{hover-card-BPKqte4a.js → hover-card-B1g55Hi6.js} +44 -43
  45. package/dist/i18n.js +3 -3
  46. package/dist/icon-badge-BcW66bRk.js +17 -0
  47. package/dist/{icon-button-Cr-DyDGg.js → icon-button-Cogxy1cy.js} +5 -4
  48. package/dist/{in-dialog-Vwkyp-M5.js → in-dialog-D61Yeaol.js} +2 -1
  49. package/dist/input-CC2joTjB.js +56 -0
  50. package/dist/key-layout-cR79xfGE.js +38 -0
  51. package/dist/lib/calculator/index.d.ts +16 -0
  52. package/dist/lib/calculator-field/index.d.ts +12 -0
  53. package/dist/lib/components/ui/collections/filter/use-filter-field-config.d.ts +2 -2
  54. package/dist/lib/components/ui/feedback/moment/moment-body.d.ts +17 -2
  55. package/dist/lib/components/ui/feedback/moment/moment-passive.d.ts +13 -0
  56. package/dist/lib/components/ui/feedback/moment/moment.d.ts +16 -2
  57. package/dist/lib/components/ui/fields/calculator-field/apply-calculated.d.ts +17 -0
  58. package/dist/lib/components/ui/fields/calculator-field/calculator-field-content.d.ts +16 -0
  59. package/dist/lib/components/ui/fields/calculator-field/calculator-field-trigger.d.ts +4 -0
  60. package/dist/lib/components/ui/fields/calculator-field/calculator-field.d.ts +12 -0
  61. package/dist/lib/components/ui/fields/calculator-field/calculator-field.types.d.ts +31 -0
  62. package/dist/lib/components/ui/fields/calculator-field/calculator-form-field.d.ts +4 -0
  63. package/dist/lib/components/ui/fields/calculator-field/index.d.ts +3 -0
  64. package/dist/lib/components/ui/fields/calculator-field/use-calculator-field.d.ts +15 -0
  65. package/dist/lib/components/ui/fields/contacts/placeholders.d.ts +1 -1
  66. package/dist/lib/components/ui/fields/currency-field/currency-field.d.ts +7 -1
  67. package/dist/lib/components/ui/layout/app-shell/app-sidebar-context.d.ts +4 -0
  68. package/dist/lib/components/ui/widgets/calculator/calculator-announce.d.ts +27 -0
  69. package/dist/lib/components/ui/widgets/calculator/calculator-clipboard.d.ts +19 -0
  70. package/dist/lib/components/ui/widgets/calculator/calculator-context.d.ts +49 -0
  71. package/dist/lib/components/ui/widgets/calculator/calculator-feedback.d.ts +18 -0
  72. package/dist/lib/components/ui/widgets/calculator/calculator-keyboard.d.ts +30 -0
  73. package/dist/lib/components/ui/widgets/calculator/calculator-storage.d.ts +17 -0
  74. package/dist/lib/components/ui/widgets/calculator/calculator-variant-steps.d.ts +16 -0
  75. package/dist/lib/components/ui/widgets/calculator/calculator.d.ts +11 -0
  76. package/dist/lib/components/ui/widgets/calculator/calculator.selectors.d.ts +23 -0
  77. package/dist/lib/components/ui/widgets/calculator/calculator.slice.d.ts +1881 -0
  78. package/dist/lib/components/ui/widgets/calculator/currency.d.ts +9 -0
  79. package/dist/lib/components/ui/widgets/calculator/engine.d.ts +22 -0
  80. package/dist/lib/components/ui/widgets/calculator/index.d.ts +3 -0
  81. package/dist/lib/components/ui/widgets/calculator/partials/calculator-announcer.d.ts +2 -0
  82. package/dist/lib/components/ui/widgets/calculator/partials/calculator-display.d.ts +3 -0
  83. package/dist/lib/components/ui/widgets/calculator/partials/calculator-key.d.ts +17 -0
  84. package/dist/lib/components/ui/widgets/calculator/partials/calculator-keypad.d.ts +8 -0
  85. package/dist/lib/components/ui/widgets/calculator/partials/calculator-loading.d.ts +6 -0
  86. package/dist/lib/components/ui/widgets/calculator/partials/calculator-memory.d.ts +2 -0
  87. package/dist/lib/components/ui/widgets/calculator/partials/calculator-panel-announce.d.ts +10 -0
  88. package/dist/lib/components/ui/widgets/calculator/partials/calculator-panel-body.d.ts +9 -0
  89. package/dist/lib/components/ui/widgets/calculator/partials/calculator-screen.d.ts +4 -0
  90. package/dist/lib/components/ui/widgets/calculator/partials/calculator-segment.d.ts +21 -0
  91. package/dist/lib/components/ui/widgets/calculator/partials/calculator-shell.d.ts +9 -0
  92. package/dist/lib/components/ui/widgets/calculator/partials/calculator-switcher.d.ts +5 -0
  93. package/dist/lib/components/ui/widgets/calculator/partials/calculator-tape.d.ts +4 -0
  94. package/dist/lib/components/ui/widgets/calculator/partials/calculator-tools.d.ts +4 -0
  95. package/dist/lib/components/ui/widgets/calculator/partials/keypad-navigation.d.ts +24 -0
  96. package/dist/lib/components/ui/widgets/calculator/types.d.ts +102 -0
  97. package/dist/lib/components/ui/widgets/calculator/use-calculator-clipboard.d.ts +19 -0
  98. package/dist/lib/components/ui/widgets/calculator/use-calculator-conversion.d.ts +4 -0
  99. package/dist/lib/components/ui/widgets/calculator/use-calculator-feedback.d.ts +3 -0
  100. package/dist/lib/components/ui/widgets/calculator/use-calculator-keyboard.d.ts +22 -0
  101. package/dist/lib/components/ui/widgets/calculator/use-calculator-persistence.d.ts +14 -0
  102. package/dist/lib/components/ui/widgets/calculator/use-calculator-pos.d.ts +25 -0
  103. package/dist/lib/components/ui/widgets/calculator/use-calculator-press.d.ts +26 -0
  104. package/dist/lib/components/ui/widgets/calculator/use-calculator-tape.d.ts +29 -0
  105. package/dist/lib/components/ui/widgets/calculator/use-calculator-value.d.ts +9 -0
  106. package/dist/lib/components/ui/widgets/calculator/use-calculator-variant.d.ts +23 -0
  107. package/dist/lib/components/ui/widgets/calculator/use-calculator.d.ts +10 -0
  108. package/dist/lib/components/ui/widgets/calculator/use-engine-settings.d.ts +10 -0
  109. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-fields.d.ts +19 -0
  110. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-labels.d.ts +17 -0
  111. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-math.d.ts +31 -0
  112. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-names.d.ts +4 -0
  113. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-panel.d.ts +7 -0
  114. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-rates.d.ts +29 -0
  115. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-result.d.ts +15 -0
  116. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-state.d.ts +36 -0
  117. package/dist/lib/components/ui/widgets/calculator/variants/conversion/conversion-variant.d.ts +3 -0
  118. package/dist/lib/components/ui/widgets/calculator/variants/conversion/use-conversion.d.ts +24 -0
  119. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-change.d.ts +4 -0
  120. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-figures.d.ts +43 -0
  121. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-format.d.ts +12 -0
  122. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-loan-math.d.ts +14 -0
  123. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-loan.d.ts +4 -0
  124. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-margin.d.ts +4 -0
  125. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-math.d.ts +10 -0
  126. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-panel.d.ts +7 -0
  127. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-parts.d.ts +35 -0
  128. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-table.d.ts +7 -0
  129. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-variant.d.ts +3 -0
  130. package/dist/lib/components/ui/widgets/calculator/variants/financial/financial-vat.d.ts +4 -0
  131. package/dist/lib/components/ui/widgets/calculator/variants/key-layout.d.ts +51 -0
  132. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-announce.d.ts +16 -0
  133. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-aside.d.ts +2 -0
  134. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-display.d.ts +2 -0
  135. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-fields.d.ts +2 -0
  136. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-layout.d.ts +9 -0
  137. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-line.d.ts +6 -0
  138. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-names.d.ts +2 -0
  139. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-state.d.ts +3 -0
  140. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-tender.d.ts +2 -0
  141. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-ticket-data.d.ts +41 -0
  142. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-ticket.d.ts +5 -0
  143. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-totals.d.ts +2 -0
  144. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-types.d.ts +76 -0
  145. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-variant.d.ts +3 -0
  146. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-vat.d.ts +2 -0
  147. package/dist/lib/components/ui/widgets/calculator/variants/pos/pos-view.d.ts +28 -0
  148. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-announce.d.ts +19 -0
  149. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-base.d.ts +11 -0
  150. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-bitpad.d.ts +14 -0
  151. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-display.d.ts +9 -0
  152. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-layout.d.ts +6 -0
  153. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-names.d.ts +2 -0
  154. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-readouts.d.ts +14 -0
  155. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-reduce.d.ts +29 -0
  156. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-state.d.ts +22 -0
  157. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-toolbar.d.ts +5 -0
  158. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-variant.d.ts +3 -0
  159. package/dist/lib/components/ui/widgets/calculator/variants/programmer/programmer-word.d.ts +15 -0
  160. package/dist/lib/components/ui/widgets/calculator/variants/registry.d.ts +21 -0
  161. package/dist/lib/components/ui/widgets/calculator/variants/scientific/scientific-layout.d.ts +3 -0
  162. package/dist/lib/components/ui/widgets/calculator/variants/scientific/scientific-names.d.ts +2 -0
  163. package/dist/lib/components/ui/widgets/calculator/variants/scientific/scientific-toolbar.d.ts +2 -0
  164. package/dist/lib/components/ui/widgets/calculator/variants/scientific/scientific-variant.d.ts +3 -0
  165. package/dist/lib/components/ui/widgets/calculator/variants/standard/standard-layout.d.ts +3 -0
  166. package/dist/lib/components/ui/widgets/calculator/variants/variant-loader.d.ts +34 -0
  167. package/dist/lib/components/ui/widgets/calculator/variants/variant-logic.d.ts +40 -0
  168. package/dist/lib/components/ui/widgets/calculator/variants/variant-types.d.ts +62 -0
  169. package/dist/lib/i18n/resources/en/en.d.ts +412 -0
  170. package/dist/lib/i18n/resources/en/material.json.d.ts +412 -0
  171. package/dist/lib/i18n/resources/fr/fr.d.ts +412 -0
  172. package/dist/lib/i18n/resources/fr/material.json.d.ts +412 -0
  173. package/dist/lib/i18n/resources/resources.d.ts +824 -0
  174. package/dist/lib/i18n/translator.d.ts +1 -1
  175. package/dist/lib.js +4 -3
  176. package/dist/main.js +50 -40
  177. package/dist/map.js +66 -65
  178. package/dist/material.css +1 -1
  179. package/dist/native-select-w_FlBLHV.js +40 -0
  180. package/dist/number.utils-CSueQZcv.js +7 -0
  181. package/dist/pdf-reader.js +1 -1
  182. package/dist/percent-field-lahyDJDG.js +14 -0
  183. package/dist/picker-surface-CV09H7Nb.js +1220 -0
  184. package/dist/popover-Cd7DkND4.js +233 -0
  185. package/dist/pos-types-DKCkOTYy.js +49 -0
  186. package/dist/pos-variant-GrUfbTTP.js +603 -0
  187. package/dist/print.js +1 -1
  188. package/dist/programmer-variant-eKJNKENL.js +501 -0
  189. package/dist/programmer-word-CNCF7DJF.js +15 -0
  190. package/dist/{public-DC9VQw4Z.js → public-y6g4ddxd.js} +895 -892
  191. package/dist/{rich-code-block-DBSL9zEN.js → rich-code-block-CRQ0iyLb.js} +5 -5
  192. package/dist/scientific-variant-2y3UxAAU.js +149 -0
  193. package/dist/{sortable-provider-C4tk5esY.js → sortable-provider-DdiI3Fwk.js} +2 -2
  194. package/dist/{spinner-B2MubVWb.js → spinner-C1QIewWv.js} +133 -159
  195. package/dist/standard-layout-BuSRr3TY.js +40 -0
  196. package/dist/tabs-DzEqMb1W.js +383 -0
  197. package/dist/{icon-badge-B9uvDoyY.js → text-field-BAdY-kpO.js} +20 -34
  198. package/dist/theme-picker.js +3 -3
  199. package/dist/{theme-toggle-BInlu21G.js → theme-toggle-C_VeiiCm.js} +2 -2
  200. package/dist/toggle-FeCCJqbg.js +40 -0
  201. package/dist/{toggle-group-DXXlqid2.js → toggle-group-CVMxEpWi.js} +1 -1
  202. package/dist/{toolbar-items-CRJSx1MU.js → toolbar-items-D310xDuM.js} +333 -554
  203. package/dist/{translate-material-pVlPJ1v4.js → translate-material-BypJJ1l5.js} +1 -1
  204. package/dist/{translator-BoYCward.js → translator-DJkf4J7t.js} +824 -0
  205. package/dist/{typography-B6YMbCge.js → typography-CYEquVeb.js} +1 -1
  206. package/dist/{use-chat-composer-BvWQogJe.js → use-chat-composer-DMXu9E1O.js} +4198 -4600
  207. package/dist/{use-heading-spy-B_Z4ArDh.js → use-heading-spy-DJR8YYm6.js} +19 -19
  208. package/dist/{use-material-translation-CIS2n3RB.js → use-material-translation-CD6QoVal.js} +1 -1
  209. package/dist/{use-return-focus-DNQtADAR.js → use-return-focus-Cevw_6yq.js} +106 -105
  210. package/dist/useLatest-C2PnQEeD.js +8 -0
  211. package/docs/README.md +1 -0
  212. package/docs/components/feedback-and-status.md +10 -1
  213. package/docs/components/form-fields.md +1 -0
  214. package/docs/components/rich-widgets.md +108 -0
  215. package/docs/getting-started.md +1 -0
  216. package/docs/guides/calculator.md +468 -0
  217. package/docs/guides/forms.md +4 -2
  218. package/docs/guides/i18n.md +5 -0
  219. package/docs/previews/rich-widgets-calculator-conversion.webp +0 -0
  220. package/docs/previews/rich-widgets-calculator-point-of-sale.webp +0 -0
  221. package/docs/previews/rich-widgets-calculator.webp +0 -0
  222. package/docs/roadmap.md +9 -3
  223. package/docs/troubleshooting.md +134 -0
  224. package/lib/components/base-content.css +9 -4
  225. package/lib/components/ui/collections/server-table/server-table-phone-row.css +10 -3
  226. package/lib/components/ui/widgets/calculator/calculator-bands.css +146 -0
  227. package/lib/components/ui/widgets/calculator/calculator-display.css +83 -0
  228. package/lib/components/ui/widgets/calculator/calculator-keys.css +118 -0
  229. package/lib/components/ui/widgets/calculator/calculator-pos-ticket.css +185 -0
  230. package/lib/components/ui/widgets/calculator/calculator-pos.css +38 -0
  231. package/lib/components/ui/widgets/calculator/calculator-tape.css +71 -0
  232. package/lib/components/ui/widgets/calculator/calculator.css +97 -0
  233. package/lib/components/ui/widgets/calculator/variants/conversion/conversion.css +98 -0
  234. package/lib/components/ui/widgets/calculator/variants/financial/financial.css +162 -0
  235. package/lib/components/ui/widgets/calculator/variants/programmer/programmer.css +162 -0
  236. package/package.json +17 -3
  237. package/dist/dialog-AGsB3bv4.js +0 -219
  238. package/dist/dist-B7RjY7SL.js +0 -158
  239. package/dist/dist-lmHmz_bu.js +0 -419
@@ -0,0 +1,9 @@
1
+ import { Decimal } from '@nxgt/material-core/calculator';
2
+ /** An amount as plain text with `digits` decimals and no grouping (`'12.50'`). */
3
+ export declare const formatPlain: (d: Decimal, digits: number) => string;
4
+ /** An amount in `locale` with `digits` decimals, then the currency code after a no-break space. */
5
+ export declare function formatMoney(d: Decimal, o: {
6
+ locale?: string;
7
+ currency?: string;
8
+ digits: number;
9
+ }): string;
@@ -0,0 +1,22 @@
1
+ import { AngleMode, CalcOptions, Notation, PercentMode, RoundingMode } from '@nxgt/material-core/calculator';
2
+ import { ProgrammerState } from './variants/programmer/programmer-word.js';
3
+ /** How a result is written: `auto` switches to powers of ten when it must. */
4
+ export type ResultNotation = 'auto' | 'sci' | 'eng';
5
+ /** The props that decide how the engine calculates and how it is shown. */
6
+ export type EngineSettings = {
7
+ readonly locale?: string;
8
+ readonly percent: PercentMode;
9
+ readonly precision?: number;
10
+ readonly rounding?: RoundingMode;
11
+ /** The scientific functions and constants (the Scientific variant). */
12
+ readonly scientific?: boolean;
13
+ /** The unit of `sin`, `cos`, `tan` and their inverses; degrees by default. */
14
+ readonly angle?: AngleMode;
15
+ readonly notation?: ResultNotation;
16
+ /** The word and the base of the Programmer variant. */
17
+ readonly programmer?: ProgrammerState;
18
+ };
19
+ /** The engine options for `settings`; unset fields keep the engine's defaults. */
20
+ export declare function engineOptions(settings: EngineSettings): CalcOptions;
21
+ /** The core formatter's notation for a result notation. */
22
+ export declare const formatNotation: (n: ResultNotation | undefined) => Notation;
@@ -0,0 +1,3 @@
1
+ export { Calculator } from './calculator.js';
2
+ export { CALCULATOR_VARIANTS, type CalculatorConversionProps, type CalculatorCurrencyRates, type CalculatorFeedback, type CalculatorPosProps, type CalculatorProps, type CalculatorRatesSource, type CalculatorVariant, } from './types.js';
3
+ export type { PosTicket, PosTicketDiscount, } from './variants/pos/pos-ticket-data.js';
@@ -0,0 +1,2 @@
1
+ /** The polite live region: results, errors, memory, copy and paste; not every key. */
2
+ export declare function CalculatorAnnouncer(): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function CalculatorDisplay({ tapeId }: {
2
+ tapeId: string;
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { Ref } from 'react';
2
+ import { KeyDef } from '../variants/key-layout.js';
3
+ export type CalculatorKeyProps = {
4
+ def: KeyDef;
5
+ row: number;
6
+ index: number;
7
+ tabIndex: 0 | -1;
8
+ /** What the decimal key draws: the locale's separator. */
9
+ decimal: string;
10
+ /** A digit the base does not have: it stays focusable, says so, and presses nothing. */
11
+ unavailable?: boolean;
12
+ onPress: (def: KeyDef) => void;
13
+ onFocus: (row: number, index: number) => void;
14
+ buttonRef: Ref<HTMLButtonElement>;
15
+ };
16
+ /** 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;
@@ -0,0 +1,8 @@
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
+ */
6
+ export declare function CalculatorKeypad({ helpId }: {
7
+ helpId: string;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The body of a variant whose code is loading: a display and a keypad of
3
+ * skeleton blocks sized like Standard's, so the frame keeps its size when the
4
+ * variant arrives. A polite status says so; a failed load offers a retry.
5
+ */
6
+ export declare function CalculatorLoading(): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ /** The "M" chip: shown while the memory holds a value, and spoken with it. */
2
+ export declare function CalculatorMemory(): import("react").JSX.Element | null;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * The panel's one polite live region: a result is read once the fields stop
4
+ * changing, not at every digit typed.
5
+ */
6
+ export declare function AnnounceProvider({ children }: {
7
+ children: ReactNode;
8
+ }): import("react").JSX.Element;
9
+ /** Says `text` after the quiet delay; nothing while `text` is empty or the tab is hidden. */
10
+ export declare function useAnnounce(text: string | null, active: boolean): void;
@@ -0,0 +1,9 @@
1
+ import { ComponentType } from 'react';
2
+ /**
3
+ * The body of a variant that has a panel instead of the display and the
4
+ * keypad: typing and pasting in its fields must not reach the calculator's
5
+ * own keys, so both events stop here.
6
+ */
7
+ export declare function CalculatorPanelBody({ panel: Panel, }: {
8
+ panel: ComponentType;
9
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ /** How long the big line is, so CSS can shrink it instead of clipping it. */
2
+ export declare const sizeOf: (text: string) => "long" | "short" | "xlong";
3
+ /** The expression and the result: named, not a tab stop (keys are typed from the keypad). */
4
+ export declare function CalculatorScreen(): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { useMaterialTranslation } from '../../../../../i18n/use-material-translation.js';
2
+ export type Choice<T extends string> = {
3
+ readonly id: T;
4
+ readonly glyph: string;
5
+ readonly name: string;
6
+ /** The spoken name when the application already translated it. */
7
+ readonly spoken?: string;
8
+ };
9
+ type SegmentProps<T extends string> = {
10
+ label: string;
11
+ choices: readonly Choice<T>[];
12
+ value: T;
13
+ nameKey?: (id: T) => Parameters<ReturnType<typeof useMaterialTranslation>['t']>[0];
14
+ onChange: (id: T) => void;
15
+ };
16
+ /**
17
+ * One choice among a few: native buttons with `aria-pressed` in a named group
18
+ * (no inline style, unlike a roving-focus group), each its own tab stop.
19
+ */
20
+ export declare function Segment<T extends string>({ label, choices, value, nameKey, onChange, }: SegmentProps<T>): import("react").JSX.Element;
21
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ClipboardEventHandler, KeyboardEventHandler } from 'react';
2
+ export type CalculatorShellProps = {
3
+ className?: string;
4
+ 'aria-label'?: string;
5
+ onKeyDown: KeyboardEventHandler<HTMLDivElement>;
6
+ onPaste: ClipboardEventHandler<HTMLDivElement>;
7
+ };
8
+ /** The frame: switcher, display, keypad, tape and the live region. */
9
+ export declare function CalculatorShell({ className, 'aria-label': ariaLabel, onKeyDown, onPaste, }: CalculatorShellProps): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ /** The variant tabs; the variant's body is the open panel. */
3
+ export declare function CalculatorSwitcher({ children }: {
4
+ children: ReactNode;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ /** The tape: every `=`, newest first, each replayable and its result reusable. */
2
+ export declare function CalculatorTape({ id }: {
3
+ id: string;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ /** Above the screen: the memory chip, copy, paste and the history toggle. */
2
+ export declare function CalculatorTools({ tapeId }: {
3
+ tapeId: string;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { KeyLayout } from '../variants/key-layout.js';
2
+ export type Cell = {
3
+ readonly row: number;
4
+ readonly index: number;
5
+ };
6
+ type Placed = {
7
+ start: number;
8
+ end: number;
9
+ };
10
+ /** Each key's first and last column, for moving up and down a grid with wide keys. */
11
+ export declare function placeKeys(layout: KeyLayout): Placed[][];
12
+ /**
13
+ * Where an arrow key, Home or End leads from `cell`; `undefined` when it goes
14
+ * nowhere (the edge). Up and down keep the column the key starts in.
15
+ */
16
+ export declare function moveCell(placed: readonly (readonly Placed[])[], cell: Cell, key: string, ctrl?: boolean,
17
+ /** With the function pane beside the keys: how many rows it has. */
18
+ split?: number): Cell | undefined;
19
+ /**
20
+ * True when the two panes sit side by side. Stacked, a pane is
21
+ * `display: contents` (it has no box of its own), so its first key stands in.
22
+ */
23
+ export declare function panesBeside(keypad: Pick<HTMLElement, 'querySelectorAll'>): boolean;
24
+ export {};
@@ -0,0 +1,102 @@
1
+ import { PercentMode, RoundingMode } from '@nxgt/material-core/calculator';
2
+ import { WordSize } from '@nxgt/material-core/calculator/programmer';
3
+ import { CurrencyRates } from '@nxgt/material-core/calculator/units';
4
+ import { MaterialLocaleKey } from '../../../../i18n/types.js';
5
+ import { PosTicket } from './variants/pos/pos-ticket-data.js';
6
+ export declare const CALCULATOR_VARIANTS: readonly ["standard", "scientific", "pos", "financial", "conversion", "programmer"];
7
+ export type CalculatorVariant = (typeof CALCULATOR_VARIANTS)[number];
8
+ /** A UI string: the `material.*` key and the English text used without a provider. */
9
+ export type CalculatorMessage = {
10
+ readonly key: MaterialLocaleKey;
11
+ readonly fallback: string;
12
+ };
13
+ /** Haptics and sound on a key press. Both are off unless asked for. */
14
+ export type CalculatorFeedback = {
15
+ /** `navigator.vibrate(8)` on a key press, never under reduced motion. */
16
+ haptics?: boolean;
17
+ /** A short tick from the Web Audio API, created on the first press. */
18
+ sound?: boolean;
19
+ };
20
+ /** What the point-of-sale variant is told by the application; no other variant reads it. */
21
+ export type CalculatorPosProps = {
22
+ /** The VAT rates, in percent (`20`, `'5.5'`); the first is the default. None: no VAT. */
23
+ vatRates?: readonly (number | string)[];
24
+ /** The bills and coins, for the round amounts offered as tendered (`[5, 10, 20, 50]`). */
25
+ denominations?: readonly (number | string)[];
26
+ /** Whether the prices typed include the VAT (default) or the VAT is added to them. */
27
+ pricesIncludeVat?: boolean;
28
+ /** The Charge button: the exact total (`'12.50'`) and the ticket as plain data. */
29
+ onCharge?: (total: string, ticket: PosTicket) => void;
30
+ };
31
+ /** What the Programmer variant is told by the application; no other variant reads it. */
32
+ export type CalculatorProgrammerProps = {
33
+ /** The word the Programmer variant starts with: 8, 16, 32 or 64 bits (default 64). */
34
+ defaultWordSize?: WordSize;
35
+ /** Whether that word is signed (two's complement, default) or unsigned. */
36
+ defaultSigned?: boolean;
37
+ };
38
+ /** Exchange rates as the application quotes them: `{ base, rates, asOf? }`. */
39
+ export type CalculatorCurrencyRates = CurrencyRates;
40
+ /** What the conversion variant is told by the application; no other variant reads it. */
41
+ export type CalculatorConversionProps = {
42
+ /**
43
+ * Exchange rates for the Currency category: an object
44
+ * `{ base, rates, asOf? }` (`rates[code]` is how much of `code` one `base`
45
+ * buys), or a function that fetches them and must stop when `signal`
46
+ * aborts. None: the Currency category is not offered.
47
+ */
48
+ currencyRates?: CalculatorRatesSource;
49
+ };
50
+ export type CalculatorRatesSource = CalculatorCurrencyRates | ((signal: AbortSignal) => Promise<CalculatorCurrencyRates>);
51
+ export type CalculatorProps = CalculatorPosProps & CalculatorConversionProps & CalculatorProgrammerProps & {
52
+ /**
53
+ * ISO 4217 code of the amounts (the point of sale's and the Financial
54
+ * variant's): sets the decimals (JPY 0, EUR 2, KWD 3) and is written beside
55
+ * them. None: two decimals and no code.
56
+ */
57
+ currency?: string;
58
+ /** The variant shown (controlled). Pair it with `onVariantChange`. */
59
+ variant?: CalculatorVariant;
60
+ /** The variant shown first (uncontrolled). Defaults to `standard`. */
61
+ defaultVariant?: CalculatorVariant;
62
+ onVariantChange?: (variant: CalculatorVariant) => void;
63
+ /**
64
+ * The variants the switcher offers; one or none hides the switcher. Every
65
+ * registered variant by default, a list that grows with each variant the
66
+ * library adds: pass `variants` for a fixed set.
67
+ */
68
+ variants?: readonly CalculatorVariant[];
69
+ /** Number format and separators (BCP 47). Defaults to the page's language. */
70
+ locale?: string;
71
+ /** Significant digits kept by the engine, 34 by default. */
72
+ precision?: number;
73
+ rounding?: RoundingMode;
74
+ /** `contextual` (`100 + 10%` is 110) or `literal` (`/100`); contextual by default. */
75
+ percent?: PercentMode;
76
+ /**
77
+ * Keep the tape and the memory in `localStorage` (after mount; versioned).
78
+ * `true` by default; `{ key }` names the slot when several calculators
79
+ * live on one origin; `false` keeps nothing.
80
+ */
81
+ persist?: boolean | {
82
+ key: string;
83
+ };
84
+ feedback?: CalculatorFeedback;
85
+ /** Also take the keys typed anywhere on the page (never in a field). */
86
+ globalKeyboard?: boolean;
87
+ /**
88
+ * A number the calculator opens with (`'12.5'`), as a finished result: a
89
+ * digit starts a new number, an operator carries on from it.
90
+ */
91
+ defaultValue?: string;
92
+ /**
93
+ * Called with the exact value of the display (the result, or the live
94
+ * preview of the expression) each time it changes; `''` when there is
95
+ * none (empty, error, unfinished).
96
+ */
97
+ onValueChange?: (value: string) => void;
98
+ /** Called with the exact result and its canonical expression after each `=`. */
99
+ onResult?: (value: string, expression: string) => void;
100
+ className?: string;
101
+ 'aria-label'?: string;
102
+ };
@@ -0,0 +1,19 @@
1
+ import { Announcement } from './calculator-announce.js';
2
+ import { ProgrammerState } from './variants/programmer/programmer-word.js';
3
+ type ClipboardActions = {
4
+ announce: (m: Announcement | null) => void;
5
+ paste: (p: {
6
+ text: string;
7
+ locale?: string;
8
+ }) => void;
9
+ };
10
+ /**
11
+ * The copy and paste buttons and the copy key. A keyboard paste is the
12
+ * root's `onPaste` (it reads the event's data, no permission needed).
13
+ */
14
+ export declare function useCalculatorClipboard(value: string, locale: string | undefined, actions: ClipboardActions, programmer?: ProgrammerState): {
15
+ copy: () => Promise<boolean>;
16
+ paste: () => Promise<void>;
17
+ pasteEvent: (text: string) => void;
18
+ };
19
+ export {};
@@ -0,0 +1,4 @@
1
+ import { CalculatorContextValue } from './calculator-context.js';
2
+ import { CalculatorProps } from './types.js';
3
+ /** What the conversion variant reads from the props, stable between renders. */
4
+ export declare function useConversionProps(props: Pick<CalculatorProps, 'currencyRates' | 'precision' | 'rounding'>): CalculatorContextValue['conversion'];
@@ -0,0 +1,3 @@
1
+ import { CalculatorFeedback } from './types.js';
2
+ /** `feel()` for each key press: a short vibration and/or tick when asked for. */
3
+ export declare function useCalculatorFeedback(feedback: CalculatorFeedback | undefined): () => void;
@@ -0,0 +1,22 @@
1
+ import { CalcKey } from '@nxgt/material-core/calculator';
2
+ import { KeyboardEvent } from 'react';
3
+ import { CalculatorKeyEvent } from './calculator-keyboard.js';
4
+ type Handlers = {
5
+ locale?: string;
6
+ accepts: (key: CalcKey) => boolean;
7
+ global?: boolean;
8
+ programmer?: boolean;
9
+ onKey: (key: CalcKey) => void;
10
+ onCopy: () => void;
11
+ /** First look at an event; `true` means it was used (Escape closing the tape). */
12
+ beforeKey?: (ev: CalculatorKeyEvent) => boolean;
13
+ };
14
+ /**
15
+ * The keyboard: `onKeyDown` for the calculator's root, and, with `global`, a
16
+ * window listener that also takes the keys typed elsewhere on the page (never
17
+ * in a field). A key the calculator uses has its default prevented, which is
18
+ * how the two listeners avoid taking one event twice. A paste is not a key
19
+ * here: the browser's paste event reaches the root's `onPaste`.
20
+ */
21
+ export declare function useCalculatorKeyboard(h: Handlers): (ev: KeyboardEvent<HTMLElement>) => void;
22
+ export {};
@@ -0,0 +1,14 @@
1
+ import { CalculatorState } from './calculator.slice.js';
2
+ import { CalculatorProps } from './types.js';
3
+ /**
4
+ * Reads the tape and the memory after mount (never during render, so the
5
+ * server and the first client frame agree), then writes them back, debounced,
6
+ * whenever they change. `persist={false}` reads and writes nothing.
7
+ */
8
+ export declare function useCalculatorPersistence(persist: CalculatorProps['persist'], state: CalculatorState, actions: {
9
+ restore: (p: {
10
+ history: CalculatorState['history'];
11
+ memory: string;
12
+ }) => void;
13
+ markRestored: () => void;
14
+ }): void;
@@ -0,0 +1,25 @@
1
+ import { CalculatorPosProps } from './types.js';
2
+ import { PosFormat } from './variants/pos/pos-announce.js';
3
+ import { PosAction, PosEnv, PosState } from './variants/pos/pos-types.js';
4
+ import { PosView } from './variants/pos/pos-view.js';
5
+ /** The props the point of sale reads: its own and the shared `currency`. */
6
+ export type PosProps = CalculatorPosProps & {
7
+ currency?: string;
8
+ };
9
+ /** What the point-of-sale panel is given: options, the ticket's view, actions. */
10
+ export type PosModel = {
11
+ props: PosProps;
12
+ env: PosEnv;
13
+ format: PosFormat;
14
+ /** `null` while another variant is shown or this one loads: nothing is computed then. */
15
+ view: PosView | null;
16
+ dispatch: (action: PosAction) => void;
17
+ };
18
+ type Send = (payload: {
19
+ action: PosAction;
20
+ env: PosEnv;
21
+ format: PosFormat;
22
+ }) => void;
23
+ /** The options, the engine's view of the ticket and the dispatcher of the POS actions. */
24
+ export declare function useCalculatorPos(props: PosProps, locale: string | undefined, state: PosState, active: boolean, send: Send): PosModel;
25
+ export {};
@@ -0,0 +1,26 @@
1
+ import { CalcKey } from '@nxgt/material-core/calculator';
2
+ import { EngineSettings } from './engine.js';
3
+ import { PosAction } from './variants/pos/pos-types.js';
4
+ import { unavailableDigit } from './variants/programmer/programmer-announce.js';
5
+ type Deps = {
6
+ actions: {
7
+ press: (p: {
8
+ key: CalcKey;
9
+ settings: EngineSettings;
10
+ id: string;
11
+ }) => void;
12
+ announce: (m: ReturnType<typeof unavailableDigit>) => void;
13
+ };
14
+ feel: () => void;
15
+ settings: EngineSettings;
16
+ isPos: boolean;
17
+ dispatchPos: (action: PosAction) => void;
18
+ t: Parameters<typeof unavailableDigit>[1];
19
+ };
20
+ /**
21
+ * The key press of the keypad and the keyboard: a digit the Programmer base
22
+ * does not have presses nothing and says so; the point of sale takes its keys
23
+ * itself; every other key moves the session.
24
+ */
25
+ export declare function useCalculatorPress(d: Deps): (key: CalcKey) => void;
26
+ export {};
@@ -0,0 +1,29 @@
1
+ import { CalcSession } from '@nxgt/material-core/calculator';
2
+ /** The part of the history toggle `closeOverlay` uses; a button fits. */
3
+ export type ToggleLike = {
4
+ getClientRects: () => {
5
+ length: number;
6
+ };
7
+ focus: () => void;
8
+ };
9
+ /**
10
+ * Closes the tape and hands focus to the toggle, when the tape is open and the
11
+ * toggle is on screen (it only is while the tape lies over the keypad).
12
+ * Returns whether it did.
13
+ */
14
+ export declare function closeOverlay(open: boolean, toggle: ToggleLike | null | undefined, close: () => void): boolean;
15
+ /** Tells `onResult` about a finished calculation; nothing otherwise. */
16
+ export declare function reportResult(onResult: ((value: string, expression: string) => void) | undefined, justEvaluated: boolean, result: string, expression: string): void;
17
+ /**
18
+ * The tape's focus: it moves into the tape when it opens, and Escape closes
19
+ * it back to the history toggle while it lies over the keypad (the toggle is
20
+ * only on screen then, under 720px); on a wide calculator the tape is always
21
+ * there and Escape means `C`.
22
+ */
23
+ export declare function useCalculatorTape(open: boolean, close: () => void): {
24
+ toggleRef: import('react').RefObject<HTMLButtonElement | null>;
25
+ tapeRef: import('react').RefObject<HTMLDivElement | null>;
26
+ closeTapeOverlay: () => boolean;
27
+ };
28
+ /** Calls `onResult` with the exact result and its expression after each `=`. */
29
+ export declare function useResultCallback(onResult: ((value: string, expression: string) => void) | undefined, { justEvaluated, result, expression }: CalcSession): void;
@@ -0,0 +1,9 @@
1
+ import { CalcSession } from '@nxgt/material-core/calculator';
2
+ /**
3
+ * The session a calculator opens with: `value` (a plain decimal, `'12.5'`) as
4
+ * a finished result, so a digit starts a new number and an operator carries on
5
+ * from it. Anything that is not a number opens an empty calculator.
6
+ */
7
+ export declare function seedSession(value: string | undefined): CalcSession;
8
+ /** Tells `onValueChange` the display's exact value each time it changes. */
9
+ export declare function useValueCallback(onValueChange: ((value: string) => void) | undefined, value: string): void;
@@ -0,0 +1,23 @@
1
+ import { CalcKey } from '@nxgt/material-core/calculator';
2
+ import { CalculatorProps, CalculatorVariant } from './types.js';
3
+ import { VariantDefinition } from './variants/registry.js';
4
+ export type ResolvedVariant = {
5
+ variant: CalculatorVariant;
6
+ variants: readonly CalculatorVariant[];
7
+ definition: VariantDefinition;
8
+ accepts: (key: CalcKey) => boolean;
9
+ };
10
+ /**
11
+ * The variant shown: `variant` when controlled, else the chrome's, held to the
12
+ * ones that are registered and listed in `variants`; Standard otherwise. A
13
+ * variant other than Standard loads on demand: its `definition` is a pending
14
+ * one until its chunk arrives.
15
+ */
16
+ export declare function useCalculatorVariant(props: Pick<CalculatorProps, 'variant' | 'variants'>, chrome: CalculatorVariant): ResolvedVariant;
17
+ /**
18
+ * Switches to `next` and tells `onChange`, once: choosing the variant already
19
+ * shown does nothing.
20
+ */
21
+ export declare function changeVariant(next: CalculatorVariant, current: CalculatorVariant, set: (variant: CalculatorVariant) => void, onChange?: (variant: CalculatorVariant) => void): void;
22
+ /** `changeVariant` as a stable callback for the switcher. */
23
+ export declare function useVariantChange(current: CalculatorVariant, set: (variant: CalculatorVariant) => void, onChange?: (variant: CalculatorVariant) => void): (variant: CalculatorVariant) => void;
@@ -0,0 +1,10 @@
1
+ import { CalcKey } from '@nxgt/material-core/calculator';
2
+ import { CalculatorContextValue } from './calculator-context.js';
3
+ import { CalculatorProps } from './types.js';
4
+ export type CalculatorModel = CalculatorContextValue & {
5
+ accepts: (key: CalcKey) => boolean;
6
+ /** Closes the tape when it lays over the keypad (Escape); `false` when not. */
7
+ closeTapeOverlay: () => boolean;
8
+ };
9
+ /** The calculator's state, wired to its props: thin over the slice and the engine. */
10
+ export declare function useCalculator(props: CalculatorProps): CalculatorModel;
@@ -0,0 +1,10 @@
1
+ import { CalculatorState } from './calculator.slice.js';
2
+ import { EngineSettings } from './engine.js';
3
+ import { CalculatorProps } from './types.js';
4
+ import { VariantDefinition } from './variants/registry.js';
5
+ /**
6
+ * What the engine and the display are told: the props, and for the Scientific
7
+ * variant its angle unit and notation. Scientific is `literal` for percent
8
+ * (`100 + 10%` is `100.1`) unless the `percent` prop says otherwise.
9
+ */
10
+ export declare function useEngineSettings(props: Pick<CalculatorProps, 'percent' | 'precision' | 'rounding'>, locale: string | undefined, state: Pick<CalculatorState, 'angle' | 'notation' | 'programmer'>, definition: Pick<VariantDefinition, 'scientific' | 'programmer'>): EngineSettings;
@@ -0,0 +1,19 @@
1
+ type Option = {
2
+ readonly id: string;
3
+ readonly label: string;
4
+ };
5
+ /** A labelled native `<select>`, the library's field box. */
6
+ export declare function ChoiceSelect({ label, value, options, disabled, onChange, slot, }: {
7
+ label: string;
8
+ value: string;
9
+ options: readonly Option[];
10
+ disabled?: boolean;
11
+ onChange: (id: string) => void;
12
+ slot: string;
13
+ }): import("react").JSX.Element;
14
+ /** Swaps the two units; its glyph turns a half turn each time. */
15
+ export declare function SwapButton({ onClick, disabled, }: {
16
+ onClick: () => void;
17
+ disabled?: boolean;
18
+ }): import("react").JSX.Element;
19
+ export {};
@@ -0,0 +1,17 @@
1
+ export type UnitLabel = {
2
+ /** `Kilometre`, `Euro`. */
3
+ readonly name: string;
4
+ /** `km`, `EUR`. */
5
+ readonly symbol: string;
6
+ /** `Kilometre (km)`: the option's text. */
7
+ readonly option: string;
8
+ };
9
+ /**
10
+ * The names of the categories and units, in the application's i18n language
11
+ * (the one the unit names are translated in; `locale` only formats numbers
12
+ * and dates).
13
+ */
14
+ export declare function useConversionLabels(category: string): {
15
+ unit: (id: string) => UnitLabel;
16
+ categoryName: (id: string) => string;
17
+ };
@@ -0,0 +1,31 @@
1
+ import { CalcErrorCode, Decimal, DecimalContext, RoundingMode } from '@nxgt/material-core/calculator';
2
+ import { ParsedRates } from '@nxgt/material-core/calculator/units';
3
+ export type ConversionOutcome = null | {
4
+ readonly ok: true;
5
+ readonly text: string;
6
+ readonly value: string;
7
+ } | {
8
+ readonly ok: false;
9
+ readonly error: CalcErrorCode;
10
+ };
11
+ export type ConversionInput = {
12
+ /** The value as typed, in the locale's own separators. */
13
+ readonly text: string;
14
+ readonly category: string;
15
+ readonly from: string;
16
+ readonly to: string;
17
+ readonly locale?: string;
18
+ readonly rates?: ParsedRates;
19
+ readonly ctx?: Partial<DecimalContext>;
20
+ };
21
+ /** The text as an exact decimal, or `undefined` when it is not a number. */
22
+ export declare function readValue(text: string, locale?: string): Decimal | undefined;
23
+ /**
24
+ * `text` converted from `from` to `to`: `null` while there is nothing to
25
+ * convert, else the result as shown (`text`, in the locale, up to 16
26
+ * significant digits) and its exact digits (`value`), or the engine's error
27
+ * code. A currency is rounded to the minor unit of `to`. Never throws.
28
+ */
29
+ export declare function convertText(i: ConversionInput): ConversionOutcome;
30
+ /** The engine's context for the `precision` and `rounding` props (34 digits at most). */
31
+ export declare function engineContext(precision?: number, rounding?: RoundingMode): Partial<DecimalContext>;
@@ -0,0 +1,4 @@
1
+ /** The English name and the symbol of each unit; the name is the `material.calculator.conversion.unit.*` fallback. */
2
+ export declare const UNIT_NAMES: Readonly<Record<string, readonly [name: string, symbol: string]>>;
3
+ /** The English name of each category; the `material.calculator.conversion.category.*` fallback. */
4
+ export declare const CATEGORY_NAMES: Readonly<Record<string, string>>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The Conversion variant's body, in place of the display and the keypad: a
3
+ * category, a value, the unit it is in and the unit wanted, and the exact
4
+ * result. The tables and the maths are `@nxgt/material-core/calculator/units`;
5
+ * the Currency category exists only with `currencyRates`.
6
+ */
7
+ export declare function ConversionPanel(): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { CalcErrorCode } from '@nxgt/material-core/calculator';
2
+ import { ParsedRates } from '@nxgt/material-core/calculator/units';
3
+ import { CalculatorRatesSource } from '../../types.js';
4
+ export type RatesState = {
5
+ readonly status: 'none';
6
+ } | {
7
+ readonly status: 'idle';
8
+ } | {
9
+ readonly status: 'loading';
10
+ } | {
11
+ readonly status: 'error';
12
+ readonly code?: CalcErrorCode;
13
+ } | {
14
+ readonly status: 'ready';
15
+ readonly rates: ParsedRates;
16
+ };
17
+ /** The rates checked, or the engine's reason for refusing them. */
18
+ export declare function readRates(source: unknown): RatesState;
19
+ /**
20
+ * The exchange rates of the `currencyRates` prop. An object is checked at
21
+ * once. A function is called the first time the Currency category is chosen, with an `AbortSignal` that
22
+ * aborts when it closes or the call is repeated: `loading`, then `ready` or
23
+ * `error`; `retry` calls it again. The function's identity does not matter
24
+ * (an inline arrow is fine): only a retry calls it again.
25
+ */
26
+ export declare function useCurrencyRates(source: CalculatorRatesSource | undefined, wanted: boolean): {
27
+ state: RatesState;
28
+ retry: (() => void) | undefined;
29
+ };