@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,529 @@
1
+ import { i as e } from "./field-blur-context-BLGgf_3z.js";
2
+ import { t } from "./button-3op3rtZh.js";
3
+ import { t as n } from "./use-material-translation-CD6QoVal.js";
4
+ import { t as r } from "./icon-button-Cogxy1cy.js";
5
+ import { t as i } from "./text-field-BAdY-kpO.js";
6
+ import { r as a, t as o } from "./native-select-w_FlBLHV.js";
7
+ import { n as s } from "./calculator-context-BugcKuVG.js";
8
+ import { t as c } from "./calculator-announce-DRd2c6Dq.js";
9
+ import { n as l, t as u } from "./calculator-panel-announce-AZSnZUSr.js";
10
+ import { useCallback as d, useEffect as f, useId as p, useMemo as m, useReducer as h, useRef as g, useState as _ } from "react";
11
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
12
+ import { ArrowDownUp as b } from "lucide-react";
13
+ import { currencyFractionDigits as x } from "@nxgt/material-core/currency-digits";
14
+ import { CalcError as S, DEFAULT_CONTEXT as C, calcErrorMessage as w, formatDecimal as T, normaliseExpression as E, parseDecimal as D, roundTo as O, toPlain as k } from "@nxgt/material-core/calculator";
15
+ import { UNIT_CATEGORIES as A, convertCurrency as j, convertUnit as ee, parseRates as M } from "@nxgt/material-core/calculator/units";
16
+ //#region lib/components/ui/widgets/calculator/variants/conversion/conversion-fields.tsx
17
+ function N({ label: t, value: n, options: r, disabled: i, onChange: s, slot: c }) {
18
+ let l = p();
19
+ return /* @__PURE__ */ y("div", {
20
+ className: "nxgt-conv-field",
21
+ "data-slot": c,
22
+ children: [/* @__PURE__ */ v(e, {
23
+ htmlFor: l,
24
+ children: t
25
+ }), /* @__PURE__ */ v(o, {
26
+ id: l,
27
+ value: n,
28
+ disabled: i,
29
+ onChange: (e) => s(e.target.value),
30
+ children: r.map((e) => /* @__PURE__ */ v(a, {
31
+ value: e.id,
32
+ children: e.label
33
+ }, e.id))
34
+ })]
35
+ });
36
+ }
37
+ function te({ onClick: e, disabled: t }) {
38
+ let { t: i } = n();
39
+ return /* @__PURE__ */ v(r, {
40
+ variant: "tonal",
41
+ className: "nxgt-conv-swap",
42
+ disabled: t,
43
+ "aria-label": i("material.calculator.conversion.swap", "Swap the units"),
44
+ "data-pw": "calculator-conversion-swap",
45
+ onClick: e,
46
+ children: /* @__PURE__ */ v(b, {})
47
+ });
48
+ }
49
+ //#endregion
50
+ //#region lib/components/ui/widgets/calculator/variants/conversion/conversion-result.tsx
51
+ var P = "material.calculator.conversion";
52
+ function ne(e, t) {
53
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return e;
54
+ try {
55
+ return new Intl.DateTimeFormat(t, {
56
+ dateStyle: "medium",
57
+ timeZone: "UTC"
58
+ }).format(new Date(e));
59
+ } catch {
60
+ return e;
61
+ }
62
+ }
63
+ function F({ rates: e, locale: r, retry: i }) {
64
+ let { t: a } = n();
65
+ if (e.status === "loading") return /* @__PURE__ */ v("p", {
66
+ className: "nxgt-conv-note",
67
+ "aria-busy": "true",
68
+ "data-slot": "conversion-rates",
69
+ children: a(`${P}.rates.loading`, "Loading exchange rates…")
70
+ });
71
+ if (e.status === "error") {
72
+ let n = e.code;
73
+ return /* @__PURE__ */ y("div", {
74
+ className: "nxgt-conv-note nxgt-conv-error",
75
+ "data-slot": "conversion-rates",
76
+ children: [/* @__PURE__ */ v("p", { children: n ? a(c[n], w({ code: n }).fallback) : a(`${P}.rates.error`, "The exchange rates could not be loaded.") }), i ? /* @__PURE__ */ v(t, {
77
+ type: "button",
78
+ variant: "tonal",
79
+ size: "sm",
80
+ onClick: i,
81
+ children: a(`${P}.rates.retry`, "Try again")
82
+ }) : null]
83
+ });
84
+ }
85
+ let o = e.status === "ready" ? e.rates.asOf : void 0;
86
+ return o ? /* @__PURE__ */ v("p", {
87
+ className: "nxgt-conv-note",
88
+ "data-slot": "conversion-rates",
89
+ children: a(`${P}.rates.as-of`, "Rates as of {date}", { date: ne(o, r) })
90
+ }) : null;
91
+ }
92
+ function I({ outcome: e, symbol: t }) {
93
+ let { t: r } = n(), i = e?.ok ? e.text : "";
94
+ return /* @__PURE__ */ v("section", {
95
+ "aria-label": r(`${P}.result`, "Result"),
96
+ "data-slot": "conversion-result",
97
+ className: "nxgt-conv-result",
98
+ children: e === null ? /* @__PURE__ */ v("p", {
99
+ className: "nxgt-conv-note",
100
+ children: r(`${P}.empty`, "Enter a value to convert it.")
101
+ }) : e.ok ? /* @__PURE__ */ y("output", {
102
+ dir: "ltr",
103
+ "data-size": i.length > 14 ? "long" : void 0,
104
+ className: "nxgt-conv-value",
105
+ "aria-live": "off",
106
+ children: [/* @__PURE__ */ v("span", {
107
+ "data-slot": "conversion-number",
108
+ children: i
109
+ }), /* @__PURE__ */ v("span", {
110
+ className: "nxgt-conv-unit",
111
+ children: t
112
+ })]
113
+ }) : /* @__PURE__ */ v("p", {
114
+ className: "nxgt-conv-error",
115
+ role: "alert",
116
+ children: r(c[e.error], w({ code: e.error }).fallback)
117
+ })
118
+ });
119
+ }
120
+ //#endregion
121
+ //#region lib/components/ui/widgets/calculator/variants/conversion/conversion-names.ts
122
+ var L = {
123
+ nm: ["Nanometre", "nm"],
124
+ um: ["Micrometre", "µm"],
125
+ mm: ["Millimetre", "mm"],
126
+ cm: ["Centimetre", "cm"],
127
+ m: ["Metre", "m"],
128
+ km: ["Kilometre", "km"],
129
+ in: ["Inch", "in"],
130
+ ft: ["Foot", "ft"],
131
+ yd: ["Yard", "yd"],
132
+ mi: ["Mile", "mi"],
133
+ nmi: ["Nautical mile", "nmi"],
134
+ "light-second": ["Light-second", "ls"],
135
+ "light-year": ["Light-year", "ly"],
136
+ ug: ["Microgram", "µg"],
137
+ mg: ["Milligram", "mg"],
138
+ g: ["Gram", "g"],
139
+ kg: ["Kilogram", "kg"],
140
+ tonne: ["Tonne", "t"],
141
+ oz: ["Ounce", "oz"],
142
+ lb: ["Pound", "lb"],
143
+ st: ["Stone", "st"],
144
+ kelvin: ["Kelvin", "K"],
145
+ "deg-c": ["Celsius", "°C"],
146
+ "deg-f": ["Fahrenheit", "°F"],
147
+ "deg-r": ["Rankine", "°R"],
148
+ ml: ["Millilitre", "mL"],
149
+ cl: ["Centilitre", "cL"],
150
+ l: ["Litre", "L"],
151
+ cm3: ["Cubic centimetre", "cm³"],
152
+ m3: ["Cubic metre", "m³"],
153
+ tsp: ["Teaspoon (US)", "tsp"],
154
+ tbsp: ["Tablespoon (US)", "tbsp"],
155
+ floz: ["Fluid ounce (US)", "fl oz"],
156
+ cup: ["Cup (US)", "cup"],
157
+ pt: ["Pint (US)", "pt"],
158
+ qt: ["Quart (US)", "qt"],
159
+ gal: ["Gallon (US)", "gal"],
160
+ "gal-imp": ["Gallon (imperial)", "gal"],
161
+ mm2: ["Square millimetre", "mm²"],
162
+ cm2: ["Square centimetre", "cm²"],
163
+ m2: ["Square metre", "m²"],
164
+ ha: ["Hectare", "ha"],
165
+ km2: ["Square kilometre", "km²"],
166
+ in2: ["Square inch", "in²"],
167
+ ft2: ["Square foot", "ft²"],
168
+ yd2: ["Square yard", "yd²"],
169
+ acre: ["Acre", "ac"],
170
+ mi2: ["Square mile", "mi²"],
171
+ "m-s": ["Metre per second", "m/s"],
172
+ "km-h": ["Kilometre per hour", "km/h"],
173
+ "mi-h": ["Mile per hour", "mph"],
174
+ "ft-s": ["Foot per second", "ft/s"],
175
+ kn: ["Knot", "kn"],
176
+ ms: ["Millisecond", "ms"],
177
+ s: ["Second", "s"],
178
+ min: ["Minute", "min"],
179
+ h: ["Hour", "h"],
180
+ day: ["Day", "d"],
181
+ week: ["Week", "wk"],
182
+ month: ["Month", "mo"],
183
+ year: ["Year", "yr"],
184
+ bit: ["Bit", "bit"],
185
+ byte: ["Byte", "B"],
186
+ kb: ["Kilobyte", "kB"],
187
+ mb: ["Megabyte", "MB"],
188
+ gb: ["Gigabyte", "GB"],
189
+ tb: ["Terabyte", "TB"],
190
+ pb: ["Petabyte", "PB"],
191
+ kib: ["Kibibyte", "KiB"],
192
+ mib: ["Mebibyte", "MiB"],
193
+ gib: ["Gibibyte", "GiB"],
194
+ tib: ["Tebibyte", "TiB"],
195
+ pib: ["Pebibyte", "PiB"]
196
+ }, R = {
197
+ length: "Length",
198
+ mass: "Mass",
199
+ temperature: "Temperature",
200
+ volume: "Volume",
201
+ area: "Area",
202
+ speed: "Speed",
203
+ time: "Time",
204
+ data: "Data",
205
+ currency: "Currency"
206
+ }, z = "material.calculator.conversion";
207
+ function B(e, t) {
208
+ try {
209
+ return new Intl.DisplayNames(t ? [t] : void 0, { type: "currency" }).of(e) ?? e;
210
+ } catch {
211
+ return e;
212
+ }
213
+ }
214
+ function V(e) {
215
+ let { t, language: r } = n();
216
+ return {
217
+ unit: d((n) => {
218
+ let [i = n, a = n] = L[n] ?? [], o = e === "currency" ? B(n, r) : t(`${z}.unit.${n}`, i), s = e === "currency" ? n : a;
219
+ return {
220
+ name: o,
221
+ symbol: s,
222
+ option: `${o} (${s})`
223
+ };
224
+ }, [
225
+ e,
226
+ r,
227
+ t
228
+ ]),
229
+ categoryName: d((e) => t(`${z}.category.${e}`, R[e] ?? e), [t])
230
+ };
231
+ }
232
+ //#endregion
233
+ //#region lib/components/ui/widgets/calculator/variants/conversion/conversion-math.ts
234
+ var H = 16;
235
+ function U(e, t) {
236
+ let n = e.trim();
237
+ if (n !== "") return D(E(n, t));
238
+ }
239
+ function W(e) {
240
+ if (e.text.trim() === "") return null;
241
+ try {
242
+ let t = U(e.text, e.locale);
243
+ if (!t) return {
244
+ ok: !1,
245
+ error: "invalid-digit"
246
+ };
247
+ let n = {
248
+ ...C,
249
+ ...e.ctx
250
+ };
251
+ if (e.category !== "currency") {
252
+ let r = ee(t, e.from, e.to, n);
253
+ return {
254
+ ok: !0,
255
+ text: T(r, {
256
+ locale: e.locale,
257
+ maxSignificant: H
258
+ }),
259
+ value: k(r)
260
+ };
261
+ }
262
+ if (!e.rates) return {
263
+ ok: !1,
264
+ error: "invalid-rates"
265
+ };
266
+ let r = x(e.to), i = O(j(t, e.from, e.to, e.rates, n), r, "half-up");
267
+ return {
268
+ ok: !0,
269
+ text: T(i, {
270
+ locale: e.locale,
271
+ fractionDigits: r
272
+ }),
273
+ value: k(i)
274
+ };
275
+ } catch (e) {
276
+ return {
277
+ ok: !1,
278
+ error: e instanceof S ? e.code : "domain"
279
+ };
280
+ }
281
+ }
282
+ function G(e, t) {
283
+ return {
284
+ ...e ? { precision: Math.min(Math.max(Math.trunc(e), 1), 34) } : {},
285
+ ...t ? { rounding: t } : {}
286
+ };
287
+ }
288
+ //#endregion
289
+ //#region lib/components/ui/widgets/calculator/variants/conversion/conversion-rates.ts
290
+ var K = { status: "none" }, q = { status: "idle" }, J = { status: "loading" };
291
+ function Y(e) {
292
+ try {
293
+ return {
294
+ status: "ready",
295
+ rates: M(e)
296
+ };
297
+ } catch (e) {
298
+ return {
299
+ status: "error",
300
+ code: e instanceof S ? e.code : void 0
301
+ };
302
+ }
303
+ }
304
+ function X(e, t) {
305
+ let n = typeof e == "function", r = g(e);
306
+ r.current = e;
307
+ let [i, a] = _(0), [o, s] = _(q);
308
+ f(() => {
309
+ let e = r.current;
310
+ if (!t || typeof e != "function" || i < 0) return;
311
+ let n = new AbortController();
312
+ return s(J), Promise.resolve().then(() => e(n.signal)).then((e) => {
313
+ n.signal.aborted || s(Y(e));
314
+ }, () => {
315
+ n.signal.aborted || s({ status: "error" });
316
+ }), () => n.abort();
317
+ }, [t, i]);
318
+ let c = m(() => e && !n ? Y(e) : K, [e, n]), l = d(() => a((e) => e + 1), []);
319
+ return n ? {
320
+ state: o,
321
+ retry: l
322
+ } : {
323
+ state: c,
324
+ retry: void 0
325
+ };
326
+ }
327
+ //#endregion
328
+ //#region lib/components/ui/widgets/calculator/variants/conversion/conversion-state.ts
329
+ var re = {
330
+ category: "length",
331
+ from: "",
332
+ to: "",
333
+ text: ""
334
+ }, ie = {
335
+ length: ["m", "ft"],
336
+ mass: ["kg", "lb"],
337
+ temperature: ["deg-c", "deg-f"],
338
+ volume: ["l", "gal"],
339
+ area: ["m2", "ft2"],
340
+ speed: ["km-h", "mi-h"],
341
+ time: ["h", "min"],
342
+ data: ["gb", "mb"]
343
+ };
344
+ function ae(e, t) {
345
+ return e === "currency" ? t : A.find((t) => t.id === e)?.units.map((e) => e.id) ?? [];
346
+ }
347
+ function Z(e, t) {
348
+ let [n, r] = ie[e.category] ?? [t[0], t[1]], i = t.includes(e.from) ? e.from : n ?? t[0] ?? "", a = t.includes(e.to) ? e.to : void 0;
349
+ return [i, (a && a !== i ? a : [r, ...t].find((e) => e !== void 0 && e !== i) ?? i) ?? i];
350
+ }
351
+ function oe(e, t) {
352
+ switch (t.type) {
353
+ case "category": return t.id === e.category ? e : {
354
+ ...e,
355
+ category: t.id,
356
+ from: "",
357
+ to: ""
358
+ };
359
+ case "from":
360
+ case "to": {
361
+ let [n, r] = Z(e, t.units), i = t.type === "from" ? r : n;
362
+ return t.type === "from" ? {
363
+ ...e,
364
+ from: t.id,
365
+ to: t.id === i ? n : r
366
+ } : {
367
+ ...e,
368
+ to: t.id,
369
+ from: t.id === i ? r : n
370
+ };
371
+ }
372
+ case "swap": return {
373
+ ...e,
374
+ from: t.to,
375
+ to: t.from
376
+ };
377
+ case "text": return {
378
+ ...e,
379
+ text: t.text
380
+ };
381
+ }
382
+ }
383
+ //#endregion
384
+ //#region lib/components/ui/widgets/calculator/variants/conversion/use-conversion.ts
385
+ var se = "material.calculator.conversion";
386
+ function Q() {
387
+ let { t: e } = n(), { locale: t, conversion: r } = s(), [i, a] = h(oe, re), [o, c] = _(!1);
388
+ i.category === "currency" && !o && c(!0);
389
+ let { state: l, retry: u } = X(r.currencyRates, o), d = l.status !== "none", f = i.category === "currency" && !d ? "length" : i.category, p = l.status === "ready" ? l.rates : void 0, g = ae(f, m(() => p ? [...p.rates.keys()] : [], [p])), [v, y] = Z({
390
+ ...i,
391
+ category: f
392
+ }, g), { unit: b, categoryName: x } = V(f), S = m(() => G(r.precision, r.rounding), [r.precision, r.rounding]), C = m(() => v === "" ? null : W({
393
+ text: i.text,
394
+ category: f,
395
+ from: v,
396
+ to: y,
397
+ locale: t,
398
+ rates: p,
399
+ ctx: S
400
+ }), [
401
+ i.text,
402
+ f,
403
+ v,
404
+ y,
405
+ t,
406
+ p,
407
+ S
408
+ ]), w = g.map((e) => ({
409
+ id: e,
410
+ label: b(e).option
411
+ })), T = [...A.map((e) => e.id), ...d ? ["currency"] : []].map((e) => ({
412
+ id: e,
413
+ label: x(e)
414
+ })), E = b(v), D = b(y), O = C?.ok === !0 ? e(`${se}.announce`, "{value} {from} equals {result} {to}", {
415
+ value: i.text.trim(),
416
+ from: E.name,
417
+ result: C.text,
418
+ to: D.name
419
+ }) : null;
420
+ return {
421
+ state: i,
422
+ dispatch: a,
423
+ category: f,
424
+ rates: l,
425
+ retry: u,
426
+ locale: t,
427
+ units: g,
428
+ from: v,
429
+ to: y,
430
+ options: w,
431
+ categories: T,
432
+ waiting: f === "currency" && l.status !== "ready",
433
+ outcome: C,
434
+ toLabel: D,
435
+ said: O
436
+ };
437
+ }
438
+ //#endregion
439
+ //#region lib/components/ui/widgets/calculator/variants/conversion/conversion-panel.tsx
440
+ var $ = "material.calculator.conversion";
441
+ function ce({ text: e }) {
442
+ return l(e, !0), null;
443
+ }
444
+ function le() {
445
+ let { t: e } = n(), t = Q(), { state: r, dispatch: a, category: o, rates: s, retry: c, locale: l, units: d } = t, { from: f, to: p, options: m, categories: h, waiting: g, outcome: _, toLabel: b } = t;
446
+ return /* @__PURE__ */ v(u, { children: /* @__PURE__ */ y("div", {
447
+ "data-slot": "calculator-conversion",
448
+ className: "nxgt-conv",
449
+ children: [
450
+ /* @__PURE__ */ v(N, {
451
+ slot: "conversion-category",
452
+ label: e(`${$}.category.label`, "Category"),
453
+ value: o,
454
+ options: h,
455
+ onChange: (e) => a({
456
+ type: "category",
457
+ id: e
458
+ })
459
+ }),
460
+ o === "currency" ? /* @__PURE__ */ v(F, {
461
+ rates: s,
462
+ locale: l,
463
+ retry: c
464
+ }) : null,
465
+ /* @__PURE__ */ v(i, {
466
+ label: e(`${$}.value`, "Value"),
467
+ value: r.text,
468
+ inputMode: "decimal",
469
+ autoComplete: "off",
470
+ spellCheck: !1,
471
+ dir: "ltr",
472
+ disabled: g,
473
+ error: _?.ok === !1,
474
+ "data-pw": "calculator-conversion-value",
475
+ onChange: (e) => a({
476
+ type: "text",
477
+ text: e.target.value
478
+ })
479
+ }),
480
+ /* @__PURE__ */ y("div", {
481
+ className: "nxgt-conv-units",
482
+ children: [
483
+ /* @__PURE__ */ v(N, {
484
+ slot: "conversion-from",
485
+ label: e(`${$}.from`, "From"),
486
+ value: f,
487
+ options: m,
488
+ disabled: g,
489
+ onChange: (e) => a({
490
+ type: "from",
491
+ id: e,
492
+ units: d
493
+ })
494
+ }),
495
+ /* @__PURE__ */ v(te, {
496
+ disabled: g,
497
+ onClick: () => a({
498
+ type: "swap",
499
+ from: f,
500
+ to: p
501
+ })
502
+ }),
503
+ /* @__PURE__ */ v(N, {
504
+ slot: "conversion-to",
505
+ label: e(`${$}.to`, "To"),
506
+ value: p,
507
+ options: m,
508
+ disabled: g,
509
+ onChange: (e) => a({
510
+ type: "to",
511
+ id: e,
512
+ units: d
513
+ })
514
+ })
515
+ ]
516
+ }),
517
+ g ? null : /* @__PURE__ */ v(I, {
518
+ outcome: _,
519
+ symbol: b.symbol
520
+ }),
521
+ /* @__PURE__ */ v(ce, { text: t.said })
522
+ ]
523
+ }) });
524
+ }
525
+ //#endregion
526
+ //#region lib/components/ui/widgets/calculator/variants/conversion/conversion-variant.ts
527
+ var ue = { part: { panel: le } };
528
+ //#endregion
529
+ export { ue as variant };
@@ -0,0 +1,7 @@
1
+ //#region lib/components/ui/actions/copy-button/copy-to-clipboard.ts
2
+ async function e(e) {
3
+ if (!navigator.clipboard?.writeText) throw Error("Clipboard is not available");
4
+ await navigator.clipboard.writeText(e);
5
+ }
6
+ //#endregion
7
+ export { e as t };
@@ -0,0 +1,16 @@
1
+ import { formatDecimal as e } from "@nxgt/material-core/calculator";
2
+ //#region lib/components/ui/widgets/calculator/currency.ts
3
+ var t = "\xA0", n = (t, n) => e(t, {
4
+ locale: "en",
5
+ fractionDigits: n,
6
+ grouping: !1
7
+ });
8
+ function r(n, r) {
9
+ let i = e(n, {
10
+ locale: r.locale,
11
+ fractionDigits: r.digits
12
+ });
13
+ return r.currency ? `${i}${t}${r.currency}` : i;
14
+ }
15
+ //#endregion
16
+ export { n, r as t };