@entifix/react-controls 0.23.7 → 0.23.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,7 +50,7 @@ get quantity(): number { … }
50
50
 
51
51
  `scaled: { scale: 3 }` fixes the scale instead. A computed column takes the same value through `<EntityColumn scaled>`. Outside entity metadata, `ScaledValue`, `ScaledInput` and `QuantityInput`'s `scale` prop do the same; a server reading the posted text uses `parseScaled` from `@entifix/core` with the same scale and locale.
52
52
 
53
- None of them, nor `MoneyInput`, rounds or guesses. More decimals than the scale holds is invalid. `1,000` is a thousand wherever three decimals do not fit; where they do (`1.500` at scale 3) it is a fraction only in the locale's own decimal separator, and refused otherwise. `QuantityInput` with a `scale` also never clamps what was typed.
53
+ None of them, nor `MoneyInput`, rounds or guesses. More decimals than the scale holds is invalid. One separator and three digits is a fraction in the decimal separator of the locale's formatting locale, at every scale: where that is `.`, `64.999` is invalid money and never 64,999. In the other separator it is a thousand where three decimals do not fit (`1,000`) and invalid where they do. A host whose language is formatted as a region's declares it: `defineLocales({ …, formattingLocales: { es: 'es-GT' } })`. `QuantityInput` with a `scale` also never clamps what was typed.
54
54
 
55
55
  ---
56
56
 
@@ -1 +1 @@
1
- {"version":3,"file":"i18n-context.d.ts","sourceRoot":"","sources":["../../src/i18n/i18n-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,iBAAiB,EAGvB,MAAM,OAAO,CAAC;AAIf;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,MAAM,CAAC;AAEZ,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,U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E,MAAM,GAAG,SAAS,EACtB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC;CACX;AAkGD,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,UAAU,EACV,QAAQ,GACT,EAAE,uBAAuB,+BAGzB;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAM3C;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;AAErC;;;;;;;;;GASG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAE9C"}
@@ -51,10 +51,13 @@ const interpolate = (text, params)=>params === undefined ? text : text.replace(/
51
51
  // Read on every call rather than once at load: a host declares its locales
52
52
  // from its own entry module, which may well evaluate after this one (#35).
53
53
  const locale = defaultLocale();
54
- if ((fallback == null ? void 0 : fallback.locale) === locale) return fallback;
54
+ const formatters = makeFormatters(locale);
55
+ if ((fallback == null ? void 0 : fallback.locale) === locale && fallback.formatters === formatters) {
56
+ return fallback;
57
+ }
55
58
  fallback = {
56
59
  locale,
57
- formatters: makeFormatters(locale),
60
+ formatters,
58
61
  t: (ns, key, params)=>{
59
62
  var _fallbackCatalogFor;
60
63
  // `useTranslateKey` hands over a fully qualified `entity:gadget.label`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/i18n/i18n-context.tsx"],"sourcesContent":["'use client';\n\nimport {\n defaultLocale,\n type Formatters,\n type Locale,\n makeFormatters,\n} from '@entifix/core';\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useMemo,\n} from 'react';\n\nimport { fallbackCatalogFor } from './fallback-catalogs.js';\n\n/**\n * Resolving a key to a sentence. The whole of what a control needs from an i18n\n * library, and deliberately not i18next's `TFunction`.\n *\n * ⚠️ **This port is what makes the controls adoptable on their own.** They used\n * to import `createI18n` directly, so taking a table meant taking i18next,\n * react-i18next and a Spanish catalog — the first of the three composition\n * defects the tier register was written to catch. The i18next binding now lives\n * behind `@entifix/react-controls/i18next`, and the peers it needs are optional.\n */\nexport type Translate = (\n key: string,\n params?: Record<string, unknown>,\n) => string;\n\nexport interface Translator {\n readonly locale: Locale;\n readonly formatters: Formatters;\n /** `ns` is the namespace a caller asked for, or the default when omitted. */\n t(\n ns: string | undefined,\n key: string,\n params?: Record<string, unknown>,\n ): string;\n}\n\nconst I18nContext = createContext<Translator | null>(null);\n\nlet fallback: Translator | undefined;\n\n/** `'table.filters'` → the string at that path, or `undefined`. */\nconst at = (catalog: object, key: string): string | undefined => {\n let node: unknown = catalog;\n for (const segment of key.split('.')) {\n if (typeof node !== 'object' || node === null) return undefined;\n node = (node as Record<string, unknown>)[segment];\n }\n return typeof node === 'string' ? node : undefined;\n};\n\n/**\n * Resolves a key, honouring i18next's `_one`/`_other` plural suffixes when the\n * caller passed a `count`.\n *\n * ⚠️ **Two plural forms, not a CLDR rule set.** i18next asks `Intl.PluralRules`\n * and handles languages with six categories; this covers the two that Spanish\n * and English have, which is what this package's own catalog is written in. An\n * adopter whose locale needs more than that wants the real thing — which is\n * what `@entifix/react-controls/i18next` is, and why it exists.\n */\nconst lookup = (\n catalog: object,\n key: string,\n params?: Record<string, unknown>,\n): string | undefined => {\n const count = params?.['count'];\n if (typeof count === 'number') {\n const plural = at(catalog, `${key}_${count === 1 ? 'one' : 'other'}`);\n if (plural !== undefined) return plural;\n }\n return at(catalog, key);\n};\n\nconst interpolate = (text: string, params?: Record<string, unknown>): string =>\n params === undefined\n ? text\n : text.replace(/\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g, (whole, name: string) =>\n name in params ? String(params[name]) : whole,\n );\n\n/**\n * What a control renders when nobody mounted a provider — Storybook, a unit\n * spec, a page that forgot.\n *\n * Deliberately a working translator rather than a thrown error, unlike\n * `useTheme`. These controls render inside server components, and a control\n * that explodes on a missing ancestor is worse than one that renders the host's\n * default locale: the failure mode becomes \"this screen is in the default\n * language for a visitor who chose another\",\n * which the locale-switch e2e catches, not a blank page.\n *\n * It resolves against **this package's own catalog**, which is the point of the\n * catalog living here: the controls arrive already able to speak, so an adopter\n * who wants no i18n library at all still gets a working table rather than one\n * captioned `table.filters`. A key outside `controls` — a host's namespace, an\n * entity label — has nothing here to resolve against and comes back as itself.\n */\nfunction fallbackTranslator(): Translator {\n // Read on every call rather than once at load: a host declares its locales\n // from its own entry module, which may well evaluate after this one (#35).\n const locale = defaultLocale();\n if (fallback?.locale === locale) return fallback;\n fallback = {\n locale,\n formatters: makeFormatters(locale),\n t: (ns, key, params) => {\n // `useTranslateKey` hands over a fully qualified `entity:gadget.label`,\n // because a runtime key carries its own namespace. i18next strips the\n // prefix and answers with the bare key when it cannot resolve one, and\n // this matches that so swapping the binding in or out changes nothing a\n // caller can see.\n const [prefix, ...rest] = key.split(':');\n const qualified = rest.length > 0;\n const namespace = qualified ? prefix : ns;\n const bare = qualified ? rest.join(':') : key;\n\n // A host may default to a locale this package ships no copy for; its own\n // English then beats a raw key.\n const catalog =\n fallbackCatalogFor(namespace ?? 'controls', locale) ??\n fallbackCatalogFor(namespace ?? 'controls', 'en');\n if (catalog === undefined) return bare;\n const text = lookup(catalog, bare, params);\n return text === undefined ? bare : interpolate(text, params);\n },\n };\n return fallback;\n}\n\nexport interface TranslatorProviderProps extends PropsWithChildren {\n readonly translator: Translator;\n}\n\n/**\n * Binds one translator to the subtree.\n *\n * A host with no i18n library builds one of these by hand; a host using\n * i18next mounts `I18nProvider` from `@entifix/react-controls/i18next`, which\n * builds it from a per-locale instance.\n */\nexport function TranslatorProvider({\n translator,\n children,\n}: TranslatorProviderProps) {\n const value = useMemo(() => translator, [translator]);\n return <I18nContext.Provider value={value}>{children}</I18nContext.Provider>;\n}\n\n/** The translator in scope, or the key-returning fallback. */\nexport function useTranslator(): Translator {\n return useContext(I18nContext) ?? fallbackTranslator();\n}\n\nexport function useLocale(): Locale {\n return useTranslator().locale;\n}\n\n/**\n * Locale-aware `Intl` wrappers. Every date and number a control renders goes\n * through these so the server and the browser agree on the output.\n */\nexport function useFormatters(): Formatters {\n return useTranslator().formatters;\n}\n\n/**\n * The translate function for one namespace.\n *\n * ⚠️ **Typed by the host, not by this package.** TypeScript permits exactly one\n * `declare module 'i18next' { interface CustomTypeOptions }` per compilation, so\n * the catalogs can be owned per package but the type gate cannot — a second\n * declaration is `TS2717`. entifix therefore ships each namespace's `Resources`\n * type and the host composes the single augmentation, which is what keeps every\n * `useT('shell')` and `useT('app')` call site compiling exactly as before.\n */\nexport function useT(ns?: string): Translate {\n const translator = useTranslator();\n return useMemo(\n () => (key, params) => translator.t(ns, key, params),\n [translator, ns],\n );\n}\n\nexport type TranslateKey = Translate;\n\n/**\n * Resolves a key that is only known at runtime — an entity's `labelKey`, one\n * value out of an enum vocabulary.\n *\n * Deliberately separate from {@link useT}, which stays strict. This is the one\n * place the typed-key guarantee is given up, and it is given up for keys that\n * `@entifix/core` cannot type: core carries `labelKey` as an opaque string\n * because it has no catalogs to check it against. Authored copy must go through\n * `useT` so a typo stays a compile error.\n */\nexport function useTranslateKey(): TranslateKey {\n return useT();\n}\n"],"names":["defaultLocale","makeFormatters","createContext","useContext","useMemo","fallbackCatalogFor","I18nContext","fallback","at","catalog","key","node","segment","split","undefined","lookup","params","count","plural","interpolate","text","replace","whole","name","String","fallbackTranslator","locale","formatters","t","ns","prefix","rest","qualified","length","namespace","bare","join","TranslatorProvider","translator","children","value","Provider","useTranslator","useLocale","useFormatters","useT","useTranslateKey"],"mappings":"AAAA;;AAEA,SACEA,aAAa,EAGbC,cAAc,QACT,gBAAgB;AACvB,SACEC,aAAa,EAEbC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YAAYD,KAAKE,MAAM,GAAG;YAChC,MAAMC,YAAYF,YAAYF,SAASD;YACvC,MAAMM,OAAOH,YAAYD,KAAKK,IAAI,CAAC,OAAO1B;YAE1C,yEAAyE;YACzE,gCAAgC;YAChC,MAAMD,WACJJ,sBAAAA,mBAAmB6B,oBAAAA,YAAa,YAAYR,mBAA5CrB,sBACAA,mBAAmB6B,oBAAAA,YAAa,YAAY;YAC9C,IAAIzB,YAAYK,WAAW,OAAOqB;YAClC,MAAMf,OAAOL,OAAON,SAAS0B,MAAMnB;YACnC,OAAOI,SAASN,YAAYqB,OAAOhB,YAAYC,MAAMJ;QACvD;IACF;IACA,OAAOT;AACT;AAMA;;;;;;CAMC,GACD,OAAO,SAAS8B,mBAAmB,EACjCC,UAAU,EACVC,QAAQ,EACgB;IACxB,MAAMC,QAAQpC,QAAQ,IAAMkC,YAAY;QAACA;KAAW;IACpD,qBAAO,KAAChC,YAAYmC,QAAQ;QAACD,OAAOA;kBAAQD;;AAC9C;AAEA,4DAA4D,GAC5D,OAAO,SAASG;QACPvC;IAAP,QAAOA,cAAAA,WAAWG,wBAAXH,cAA2BsB;AACpC;AAEA,OAAO,SAASkB;IACd,OAAOD,gBAAgBhB,MAAM;AAC/B;AAEA;;;CAGC,GACD,OAAO,SAASkB;IACd,OAAOF,gBAAgBf,UAAU;AACnC;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASkB,KAAKhB,EAAW;IAC9B,MAAMS,aAAaI;IACnB,OAAOtC,QACL,IAAM,CAACM,KAAKM,SAAWsB,WAAWV,CAAC,CAACC,IAAInB,KAAKM,SAC7C;QAACsB;QAAYT;KAAG;AAEpB;AAIA;;;;;;;;;CASC,GACD,OAAO,SAASiB;IACd,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../src/i18n/i18n-context.tsx"],"sourcesContent":["'use client';\n\nimport {\n defaultLocale,\n type Formatters,\n type Locale,\n makeFormatters,\n} from '@entifix/core';\nimport {\n createContext,\n type PropsWithChildren,\n useContext,\n useMemo,\n} from 'react';\n\nimport { fallbackCatalogFor } from './fallback-catalogs.js';\n\n/**\n * Resolving a key to a sentence. The whole of what a control needs from an i18n\n * library, and deliberately not i18next's `TFunction`.\n *\n * ⚠️ **This port is what makes the controls adoptable on their own.** They used\n * to import `createI18n` directly, so taking a table meant taking i18next,\n * react-i18next and a Spanish catalog — the first of the three composition\n * defects the tier register was written to catch. The i18next binding now lives\n * behind `@entifix/react-controls/i18next`, and the peers it needs are optional.\n */\nexport type Translate = (\n key: string,\n params?: Record<string, unknown>,\n) => string;\n\nexport interface Translator {\n readonly locale: Locale;\n readonly formatters: Formatters;\n /** `ns` is the namespace a caller asked for, or the default when omitted. */\n t(\n ns: string | undefined,\n key: string,\n params?: Record<string, unknown>,\n ): string;\n}\n\nconst I18nContext = createContext<Translator | null>(null);\n\nlet fallback: Translator | undefined;\n\n/** `'table.filters'` → the string at that path, or `undefined`. */\nconst at = (catalog: object, key: string): string | undefined => {\n let node: unknown = catalog;\n for (const segment of key.split('.')) {\n if (typeof node !== 'object' || node === null) return undefined;\n node = (node as Record<string, unknown>)[segment];\n }\n return typeof node === 'string' ? node : undefined;\n};\n\n/**\n * Resolves a key, honouring i18next's `_one`/`_other` plural suffixes when the\n * caller passed a `count`.\n *\n * ⚠️ **Two plural forms, not a CLDR rule set.** i18next asks `Intl.PluralRules`\n * and handles languages with six categories; this covers the two that Spanish\n * and English have, which is what this package's own catalog is written in. An\n * adopter whose locale needs more than that wants the real thing — which is\n * what `@entifix/react-controls/i18next` is, and why it exists.\n */\nconst lookup = (\n catalog: object,\n key: string,\n params?: Record<string, unknown>,\n): string | undefined => {\n const count = params?.['count'];\n if (typeof count === 'number') {\n const plural = at(catalog, `${key}_${count === 1 ? 'one' : 'other'}`);\n if (plural !== undefined) return plural;\n }\n return at(catalog, key);\n};\n\nconst interpolate = (text: string, params?: Record<string, unknown>): string =>\n params === undefined\n ? text\n : text.replace(/\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g, (whole, name: string) =>\n name in params ? String(params[name]) : whole,\n );\n\n/**\n * What a control renders when nobody mounted a provider — Storybook, a unit\n * spec, a page that forgot.\n *\n * Deliberately a working translator rather than a thrown error, unlike\n * `useTheme`. These controls render inside server components, and a control\n * that explodes on a missing ancestor is worse than one that renders the host's\n * default locale: the failure mode becomes \"this screen is in the default\n * language for a visitor who chose another\",\n * which the locale-switch e2e catches, not a blank page.\n *\n * It resolves against **this package's own catalog**, which is the point of the\n * catalog living here: the controls arrive already able to speak, so an adopter\n * who wants no i18n library at all still gets a working table rather than one\n * captioned `table.filters`. A key outside `controls` — a host's namespace, an\n * entity label — has nothing here to resolve against and comes back as itself.\n */\nfunction fallbackTranslator(): Translator {\n // Read on every call rather than once at load: a host declares its locales\n // from its own entry module, which may well evaluate after this one (#35).\n const locale = defaultLocale();\n const formatters = makeFormatters(locale);\n if (fallback?.locale === locale && fallback.formatters === formatters) {\n return fallback;\n }\n fallback = {\n locale,\n formatters,\n t: (ns, key, params) => {\n // `useTranslateKey` hands over a fully qualified `entity:gadget.label`,\n // because a runtime key carries its own namespace. i18next strips the\n // prefix and answers with the bare key when it cannot resolve one, and\n // this matches that so swapping the binding in or out changes nothing a\n // caller can see.\n const [prefix, ...rest] = key.split(':');\n const qualified = rest.length > 0;\n const namespace = qualified ? prefix : ns;\n const bare = qualified ? rest.join(':') : key;\n\n // A host may default to a locale this package ships no copy for; its own\n // English then beats a raw key.\n const catalog =\n fallbackCatalogFor(namespace ?? 'controls', locale) ??\n fallbackCatalogFor(namespace ?? 'controls', 'en');\n if (catalog === undefined) return bare;\n const text = lookup(catalog, bare, params);\n return text === undefined ? bare : interpolate(text, params);\n },\n };\n return fallback;\n}\n\nexport interface TranslatorProviderProps extends PropsWithChildren {\n readonly translator: Translator;\n}\n\n/**\n * Binds one translator to the subtree.\n *\n * A host with no i18n library builds one of these by hand; a host using\n * i18next mounts `I18nProvider` from `@entifix/react-controls/i18next`, which\n * builds it from a per-locale instance.\n */\nexport function TranslatorProvider({\n translator,\n children,\n}: TranslatorProviderProps) {\n const value = useMemo(() => translator, [translator]);\n return <I18nContext.Provider value={value}>{children}</I18nContext.Provider>;\n}\n\n/** The translator in scope, or the key-returning fallback. */\nexport function useTranslator(): Translator {\n return useContext(I18nContext) ?? fallbackTranslator();\n}\n\nexport function useLocale(): Locale {\n return useTranslator().locale;\n}\n\n/**\n * Locale-aware `Intl` wrappers. Every date and number a control renders goes\n * through these so the server and the browser agree on the output.\n */\nexport function useFormatters(): Formatters {\n return useTranslator().formatters;\n}\n\n/**\n * The translate function for one namespace.\n *\n * ⚠️ **Typed by the host, not by this package.** TypeScript permits exactly one\n * `declare module 'i18next' { interface CustomTypeOptions }` per compilation, so\n * the catalogs can be owned per package but the type gate cannot — a second\n * declaration is `TS2717`. entifix therefore ships each namespace's `Resources`\n * type and the host composes the single augmentation, which is what keeps every\n * `useT('shell')` and `useT('app')` call site compiling exactly as before.\n */\nexport function useT(ns?: string): Translate {\n const translator = useTranslator();\n return useMemo(\n () => (key, params) => translator.t(ns, key, params),\n [translator, ns],\n );\n}\n\nexport type TranslateKey = Translate;\n\n/**\n * Resolves a key that is only known at runtime — an entity's `labelKey`, one\n * value out of an enum vocabulary.\n *\n * Deliberately separate from {@link useT}, which stays strict. This is the one\n * place the typed-key guarantee is given up, and it is given up for keys that\n * `@entifix/core` cannot type: core carries `labelKey` as an opaque string\n * because it has no catalogs to check it against. Authored copy must go through\n * `useT` so a typo stays a compile error.\n */\nexport function useTranslateKey(): TranslateKey {\n return useT();\n}\n"],"names":["defaultLocale","makeFormatters","createContext","useContext","useMemo","fallbackCatalogFor","I18nContext","fallback","at","catalog","key","node","segment","split","undefined","lookup","params","count","plural","interpolate","text","replace","whole","name","String","fallbackTranslator","locale","formatters","t","ns","prefix","rest","qualified","length","namespace","bare","join","TranslatorProvider","translator","children","value","Provider","useTranslator","useLocale","useFormatters","useT","useTranslateKey"],"mappings":"AAAA;;AAEA,SACEA,aAAa,EAGbC,cAAc,QACT,gBAAgB;AAC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,CAACyB,QAAQ,GAAGC,KAAK,GAAGrB,IAAIG,KAAK,CAAC;YACpC,MAAMmB,YAAYD,KAAKE,MAAM,GAAG;YAChC,MAAMC,YAAYF,YAAYF,SAASD;YACvC,MAAMM,OAAOH,YAAYD,KAAKK,IAAI,CAAC,OAAO1B;YAE1C,yEAAyE;YACzE,gCAAgC;YAChC,MAAMD,WACJJ,sBAAAA,mBAAmB6B,oBAAAA,YAAa,YAAYR,mBAA5CrB,sBACAA,mBAAmB6B,oBAAAA,YAAa,YAAY;YAC9C,IAAIzB,YAAYK,WAAW,OAAOqB;YAClC,MAAMf,OAAOL,OAAON,SAAS0B,MAAMnB;YACnC,OAAOI,SAASN,YAAYqB,OAAOhB,YAAYC,MAAMJ;QACvD;IACF;IACA,OAAOT;AACT;AAMA;;;;;;CAMC,GACD,OAAO,SAAS8B,mBAAmB,EACjCC,UAAU,EACVC,QAAQ,EACgB;IACxB,MAAMC,QAAQpC,QAAQ,IAAMkC,YAAY;QAACA;KAAW;IACpD,qBAAO,KAAChC,YAAYmC,QAAQ;QAACD,OAAOA;kBAAQD;;AAC9C;AAEA,4DAA4D,GAC5D,OAAO,SAASG;QACPvC;IAAP,QAAOA,cAAAA,WAAWG,wBAAXH,cAA2BsB;AACpC;AAEA,OAAO,SAASkB;IACd,OAAOD,gBAAgBhB,MAAM;AAC/B;AAEA;;;CAGC,GACD,OAAO,SAASkB;IACd,OAAOF,gBAAgBf,UAAU;AACnC;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASkB,KAAKhB,EAAW;IAC9B,MAAMS,aAAaI;IACnB,OAAOtC,QACL,IAAM,CAACM,KAAKM,SAAWsB,WAAWV,CAAC,CAACC,IAAInB,KAAKM,SAC7C;QAACsB;QAAYT;KAAG;AAEpB;AAIA;;;;;;;;;CASC,GACD,OAAO,SAASiB;IACd,OAAOD;AACT"}
@@ -15,9 +15,10 @@ export interface MoneyInputProps extends Omit<NumberInputProps, 'value' | 'onCha
15
15
  * not reformatted under the cursor), and the field follows the stored value
16
16
  * only when it changes from outside.
17
17
  *
18
- * `1,000` is a thousand in any locale, since no two-decimal currency has
19
- * three; text with more decimals than the currency holds is refused by
20
- * validation rather than rounded (`parseScaled`).
18
+ * Text with more decimals than the currency holds is refused by validation
19
+ * rather than rounded, and three digits after the decimal separator of the
20
+ * formatting locale are decimals: where that is `.`, `1,000` is a thousand and
21
+ * `64.999` is refused (`parseScaled`).
21
22
  */
22
23
  export declare function MoneyInput({ value, onChange, currency, unit, locale, ...props }: MoneyInputProps): import("react").JSX.Element;
23
24
  //# sourceMappingURL=money-input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"money-input.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/money/money-input.tsx"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAkB,KAAK,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAE/E,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,gBAAgB,EAChB,OAAO,GAAG,UAAU,GAAG,WAAW,CACnC;IACC,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,GAAG,KAAK,EACT,EAAE,eAAe,+BA+CjB"}
1
+ {"version":3,"file":"money-input.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/money/money-input.tsx"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAkB,KAAK,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAE/E,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,gBAAgB,EAChB,OAAO,GAAG,UAAU,GAAG,WAAW,CACnC;IACC,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,GAAG,KAAK,EACT,EAAE,eAAe,+BA+CjB"}
@@ -2,7 +2,7 @@
2
2
  import { _ as _extends } from "@swc/helpers/_/_extends";
3
3
  import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
4
4
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- import { parseScaled, scaledToDecimal } from '@entifix/core';
5
+ import { formattingLocale, parseScaled, scaledToDecimal } from '@entifix/core';
6
6
  import { useEffect, useState } from 'react';
7
7
  import { NumberInput } from '../number-input/number-input.js';
8
8
  import { typedText, unparsedDraft } from '../number-input/unparsed.js';
@@ -13,9 +13,10 @@ import { fractionDigits, toMajorUnits } from './money-math.js';
13
13
  * not reformatted under the cursor), and the field follows the stored value
14
14
  * only when it changes from outside.
15
15
  *
16
- * `1,000` is a thousand in any locale, since no two-decimal currency has
17
- * three; text with more decimals than the currency holds is refused by
18
- * validation rather than rounded (`parseScaled`).
16
+ * Text with more decimals than the currency holds is refused by validation
17
+ * rather than rounded, and three digits after the decimal separator of the
18
+ * formatting locale are decimals: where that is `.`, `1,000` is a thousand and
19
+ * `64.999` is refused (`parseScaled`).
19
20
  */ export function MoneyInput(_0) {
20
21
  let { value, onChange, currency, unit, locale } = _0, props = _object_without_properties_loose(_0, [
21
22
  "value",
@@ -25,7 +26,7 @@ import { fractionDigits, toMajorUnits } from './money-math.js';
25
26
  "locale"
26
27
  ]);
27
28
  const digits = fractionDigits(currency);
28
- const display = (stored)=>stored === '' || !Number.isFinite(Number(stored)) ? typedText(stored) : new Intl.NumberFormat(locale, {
29
+ const display = (stored)=>stored === '' || !Number.isFinite(Number(stored)) ? typedText(stored) : new Intl.NumberFormat(formattingLocale(locale), {
29
30
  minimumFractionDigits: digits,
30
31
  maximumFractionDigits: digits,
31
32
  useGrouping: false
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/atoms/money/money-input.tsx"],"sourcesContent":["'use client';\n\nimport { parseScaled, scaledToDecimal } from '@entifix/core';\nimport { useEffect, useState } from 'react';\n\nimport {\n NumberInput,\n type NumberInputProps,\n} from '../number-input/number-input.js';\nimport { typedText, unparsedDraft } from '../number-input/unparsed.js';\nimport { fractionDigits, type MoneyUnit, toMajorUnits } from './money-math.js';\n\nexport interface MoneyInputProps extends Omit<\n NumberInputProps,\n 'value' | 'onChange' | 'inputMode'\n> {\n /** The stored amount, as a draft string (`'6499'`), or `''` for none. */\n value: string;\n /** Called with the stored amount as a draft string. */\n onChange: (value: string) => void;\n currency: string;\n unit: MoneyUnit;\n locale: string;\n}\n\n/**\n * Edits an amount in major units — what a person means by a price — and writes\n * back the stored unit. What was typed is kept as typed (a trailing `64,` is\n * not reformatted under the cursor), and the field follows the stored value\n * only when it changes from outside.\n *\n * `1,000` is a thousand in any locale, since no two-decimal currency has\n * three; text with more decimals than the currency holds is refused by\n * validation rather than rounded (`parseScaled`).\n */\nexport function MoneyInput({\n value,\n onChange,\n currency,\n unit,\n locale,\n ...props\n}: MoneyInputProps) {\n const digits = fractionDigits(currency);\n const display = (stored: string) =>\n stored === '' || !Number.isFinite(Number(stored))\n ? typedText(stored)\n : new Intl.NumberFormat(locale, {\n minimumFractionDigits: digits,\n maximumFractionDigits: digits,\n useGrouping: false,\n }).format(toMajorUnits(Number(stored), currency, unit));\n\n const [text, setText] = useState(() => display(value));\n const [emitted, setEmitted] = useState(value);\n\n useEffect(() => {\n if (value === emitted) return;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- an outside write (a reset, a load) replaces what was typed\n setText(display(value));\n setEmitted(value);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- `display` is derived from props already listed\n }, [value, emitted, currency, unit, locale]);\n\n return (\n <span className=\"inline-flex items-center gap-2xs\">\n <NumberInput\n {...props}\n inputMode={digits === 0 ? 'numeric' : 'decimal'}\n value={text}\n onChange={event => {\n const next = event.currentTarget.value;\n setText(next);\n const minor = parseScaled(next, digits, locale);\n const stored =\n minor === undefined\n ? unparsedDraft(next)\n : unit === 'minor'\n ? String(minor)\n : scaledToDecimal(minor, digits);\n setEmitted(stored);\n onChange(stored);\n }}\n />\n <span className=\"text-step-sm text-content-muted\" aria-hidden=\"true\">\n {currency}\n </span>\n </span>\n );\n}\n"],"names":["parseScaled","scaledToDecimal","useEffect","useState","NumberInput","typedText","unparsedDraft","fractionDigits","toMajorUnits","MoneyInput","value","onChange","currency","unit","locale","props","digits","display","stored","Number","isFinite","Intl","NumberFormat","minimumFractionDigits","maximumFractionDigits","useGrouping","format","text","setText","emitted","setEmitted","span","className","inputMode","event","next","currentTarget","minor","undefined","String","aria-hidden"],"mappings":"AAAA;;;;AAEA,SAASA,WAAW,EAAEC,eAAe,QAAQ,gBAAgB;AAC7D,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C,SACEC,WAAW,QAEN,kCAAkC;AACzC,SAASC,SAAS,EAAEC,aAAa,QAAQ,8BAA8B;AACvE,SAASC,cAAc,EAAkBC,YAAY,QAAQ,kBAAkB;AAe/E;;;;;;;;;CASC,GACD,OAAO,SAASC,WAAW,EAOT;QAPS,EACzBC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,MAAM,EAEU,OADbC;;;;;;;IAEH,MAAMC,SAAST,eAAeK;IAC9B,MAAMK,UAAU,CAACC,SACfA,WAAW,MAAM,CAACC,OAAOC,QAAQ,CAACD,OAAOD,WACrCb,UAAUa,UACV,IAAIG,KAAKC,YAAY,CAACR,QAAQ;YAC5BS,uBAAuBP;YACvBQ,uBAAuBR;YACvBS,aAAa;QACf,GAAGC,MAAM,CAAClB,aAAaW,OAAOD,SAASN,UAAUC;IAEvD,MAAM,CAACc,MAAMC,QAAQ,GAAGzB,SAAS,IAAMc,QAAQP;IAC/C,MAAM,CAACmB,SAASC,WAAW,GAAG3B,SAASO;IAEvCR,UAAU;QACR,IAAIQ,UAAUmB,SAAS;QACvB,yHAAyH;QACzHD,QAAQX,QAAQP;QAChBoB,WAAWpB;IACX,yGAAyG;IAC3G,GAAG;QAACA;QAAOmB;QAASjB;QAAUC;QAAMC;KAAO;IAE3C,qBACE,MAACiB;QAAKC,WAAU;;0BACd,KAAC5B,0BACKW;gBACJkB,WAAWjB,WAAW,IAAI,YAAY;gBACtCN,OAAOiB;gBACPhB,UAAUuB,CAAAA;oBACR,MAAMC,OAAOD,MAAME,aAAa,CAAC1B,KAAK;oBACtCkB,QAAQO;oBACR,MAAME,QAAQrC,YAAYmC,MAAMnB,QAAQF;oBACxC,MAAMI,SACJmB,UAAUC,YACNhC,cAAc6B,QACdtB,SAAS,UACP0B,OAAOF,SACPpC,gBAAgBoC,OAAOrB;oBAC/Bc,WAAWZ;oBACXP,SAASO;gBACX;;0BAEF,KAACa;gBAAKC,WAAU;gBAAkCQ,eAAY;0BAC3D5B;;;;AAIT"}
1
+ {"version":3,"sources":["../../../../src/ui/atoms/money/money-input.tsx"],"sourcesContent":["'use client';\n\nimport { formattingLocale, parseScaled, scaledToDecimal } from '@entifix/core';\nimport { useEffect, useState } from 'react';\n\nimport {\n NumberInput,\n type NumberInputProps,\n} from '../number-input/number-input.js';\nimport { typedText, unparsedDraft } from '../number-input/unparsed.js';\nimport { fractionDigits, type MoneyUnit, toMajorUnits } from './money-math.js';\n\nexport interface MoneyInputProps extends Omit<\n NumberInputProps,\n 'value' | 'onChange' | 'inputMode'\n> {\n /** The stored amount, as a draft string (`'6499'`), or `''` for none. */\n value: string;\n /** Called with the stored amount as a draft string. */\n onChange: (value: string) => void;\n currency: string;\n unit: MoneyUnit;\n locale: string;\n}\n\n/**\n * Edits an amount in major units — what a person means by a price — and writes\n * back the stored unit. What was typed is kept as typed (a trailing `64,` is\n * not reformatted under the cursor), and the field follows the stored value\n * only when it changes from outside.\n *\n * Text with more decimals than the currency holds is refused by validation\n * rather than rounded, and three digits after the decimal separator of the\n * formatting locale are decimals: where that is `.`, `1,000` is a thousand and\n * `64.999` is refused (`parseScaled`).\n */\nexport function MoneyInput({\n value,\n onChange,\n currency,\n unit,\n locale,\n ...props\n}: MoneyInputProps) {\n const digits = fractionDigits(currency);\n const display = (stored: string) =>\n stored === '' || !Number.isFinite(Number(stored))\n ? typedText(stored)\n : new Intl.NumberFormat(formattingLocale(locale), {\n minimumFractionDigits: digits,\n maximumFractionDigits: digits,\n useGrouping: false,\n }).format(toMajorUnits(Number(stored), currency, unit));\n\n const [text, setText] = useState(() => display(value));\n const [emitted, setEmitted] = useState(value);\n\n useEffect(() => {\n if (value === emitted) return;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- an outside write (a reset, a load) replaces what was typed\n setText(display(value));\n setEmitted(value);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- `display` is derived from props already listed\n }, [value, emitted, currency, unit, locale]);\n\n return (\n <span className=\"inline-flex items-center gap-2xs\">\n <NumberInput\n {...props}\n inputMode={digits === 0 ? 'numeric' : 'decimal'}\n value={text}\n onChange={event => {\n const next = event.currentTarget.value;\n setText(next);\n const minor = parseScaled(next, digits, locale);\n const stored =\n minor === undefined\n ? unparsedDraft(next)\n : unit === 'minor'\n ? String(minor)\n : scaledToDecimal(minor, digits);\n setEmitted(stored);\n onChange(stored);\n }}\n />\n <span className=\"text-step-sm text-content-muted\" aria-hidden=\"true\">\n {currency}\n </span>\n </span>\n );\n}\n"],"names":["formattingLocale","parseScaled","scaledToDecimal","useEffect","useState","NumberInput","typedText","unparsedDraft","fractionDigits","toMajorUnits","MoneyInput","value","onChange","currency","unit","locale","props","digits","display","stored","Number","isFinite","Intl","NumberFormat","minimumFractionDigits","maximumFractionDigits","useGrouping","format","text","setText","emitted","setEmitted","span","className","inputMode","event","next","currentTarget","minor","undefined","String","aria-hidden"],"mappings":"AAAA;;;;AAEA,SAASA,gBAAgB,EAAEC,WAAW,EAAEC,eAAe,QAAQ,gBAAgB;AAC/E,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C,SACEC,WAAW,QAEN,kCAAkC;AACzC,SAASC,SAAS,EAAEC,aAAa,QAAQ,8BAA8B;AACvE,SAASC,cAAc,EAAkBC,YAAY,QAAQ,kBAAkB;AAe/E;;;;;;;;;;CAUC,GACD,OAAO,SAASC,WAAW,EAOT;QAPS,EACzBC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,IAAI,EACJC,MAAM,EAEU,OADbC;;;;;;;IAEH,MAAMC,SAAST,eAAeK;IAC9B,MAAMK,UAAU,CAACC,SACfA,WAAW,MAAM,CAACC,OAAOC,QAAQ,CAACD,OAAOD,WACrCb,UAAUa,UACV,IAAIG,KAAKC,YAAY,CAACvB,iBAAiBe,SAAS;YAC9CS,uBAAuBP;YACvBQ,uBAAuBR;YACvBS,aAAa;QACf,GAAGC,MAAM,CAAClB,aAAaW,OAAOD,SAASN,UAAUC;IAEvD,MAAM,CAACc,MAAMC,QAAQ,GAAGzB,SAAS,IAAMc,QAAQP;IAC/C,MAAM,CAACmB,SAASC,WAAW,GAAG3B,SAASO;IAEvCR,UAAU;QACR,IAAIQ,UAAUmB,SAAS;QACvB,yHAAyH;QACzHD,QAAQX,QAAQP;QAChBoB,WAAWpB;IACX,yGAAyG;IAC3G,GAAG;QAACA;QAAOmB;QAASjB;QAAUC;QAAMC;KAAO;IAE3C,qBACE,MAACiB;QAAKC,WAAU;;0BACd,KAAC5B,0BACKW;gBACJkB,WAAWjB,WAAW,IAAI,YAAY;gBACtCN,OAAOiB;gBACPhB,UAAUuB,CAAAA;oBACR,MAAMC,OAAOD,MAAME,aAAa,CAAC1B,KAAK;oBACtCkB,QAAQO;oBACR,MAAME,QAAQrC,YAAYmC,MAAMnB,QAAQF;oBACxC,MAAMI,SACJmB,UAAUC,YACNhC,cAAc6B,QACdtB,SAAS,UACP0B,OAAOF,SACPpC,gBAAgBoC,OAAOrB;oBAC/Bc,WAAWZ;oBACXP,SAASO;gBACX;;0BAEF,KAACa;gBAAKC,WAAU;gBAAkCQ,eAAY;0BAC3D5B;;;;AAIT"}
@@ -1,4 +1,4 @@
1
- import type { MoneyFormat } from '@entifix/core';
1
+ import { type MoneyFormat } from '@entifix/core';
2
2
  export type MoneyUnit = MoneyFormat['unit'];
3
3
  /**
4
4
  * How many minor units a currency has, as `Intl` resolves it: 2 for GTQ and
@@ -11,8 +11,8 @@ export declare function toMajorUnits(amount: number, currency: string, unit: Mon
11
11
  /** A major-unit amount back in the unit it is stored in, rounded to it. */
12
12
  export declare function fromMajorUnits(major: number, currency: string, unit: MoneyUnit): number;
13
13
  /**
14
- * The amount as the reader's locale writes money: `Q64.99` in `en`, `64,99 GTQ`
15
- * or similar in `es`. Never the bare stored number — a till once printed
14
+ * The amount as the reader's formatting locale writes money: `Q64.99` in
15
+ * `es-GT`, `64,99 GTQ` or similar in `es`. Never the bare stored number — a till once printed
16
16
  * 6499 GTQ for 64,99.
17
17
  */
18
18
  export declare function formatMoney(amount: number, currency: string, unit: MoneyUnit, locale: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"money-math.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/money/money-math.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAA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AAE,MAAM,GACb,MAAM,CAKR;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CACxB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,GACpD,MAAM,GAAG,SAAS,CAIpB"}
@@ -1,3 +1,4 @@
1
+ import { formattingLocale } from '@entifix/core';
1
2
  /**
2
3
  * How many minor units a currency has, as `Intl` resolves it: 2 for GTQ and
3
4
  * USD, 0 for JPY, 3 for KWD. Read from the platform rather than a table, so a
@@ -18,11 +19,11 @@
18
19
  return unit === 'major' ? Number(major.toFixed(digits)) : Math.round(major * 10 ** digits);
19
20
  }
20
21
  /**
21
- * The amount as the reader's locale writes money: `Q64.99` in `en`, `64,99 GTQ`
22
- * or similar in `es`. Never the bare stored number — a till once printed
22
+ * The amount as the reader's formatting locale writes money: `Q64.99` in
23
+ * `es-GT`, `64,99 GTQ` or similar in `es`. Never the bare stored number — a till once printed
23
24
  * 6499 GTQ for 64,99.
24
25
  */ export function formatMoney(amount, currency, unit, locale) {
25
- return new Intl.NumberFormat(locale, {
26
+ return new Intl.NumberFormat(formattingLocale(locale), {
26
27
  style: 'currency',
27
28
  currency
28
29
  }).format(toMajorUnits(amount, currency, unit));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/atoms/money/money-math.ts"],"sourcesContent":["import type { MoneyFormat } from '@entifix/core';\n\nexport type MoneyUnit = MoneyFormat['unit'];\n\n/**\n * How many minor units a currency has, as `Intl` resolves it: 2 for GTQ and\n * USD, 0 for JPY, 3 for KWD. Read from the platform rather than a table, so a\n * currency nobody here thought of is still right.\n */\nexport function fractionDigits(currency: string): number {\n // Always set for `style: 'currency'`; the fallback only satisfies the type.\n /* v8 ignore next */\n return (\n new Intl.NumberFormat('en', {\n style: 'currency',\n currency,\n }).resolvedOptions().maximumFractionDigits ?? 2\n );\n}\n\n/** The amount in major units (64.99), whichever unit it is stored in. */\nexport function toMajorUnits(\n amount: number,\n currency: string,\n unit: MoneyUnit,\n): number {\n return unit === 'major' ? amount : amount / 10 ** fractionDigits(currency);\n}\n\n/** A major-unit amount back in the unit it is stored in, rounded to it. */\nexport function fromMajorUnits(\n major: number,\n currency: string,\n unit: MoneyUnit,\n): number {\n const digits = fractionDigits(currency);\n return unit === 'major'\n ? Number(major.toFixed(digits))\n : Math.round(major * 10 ** digits);\n}\n\n/**\n * The amount as the reader's locale writes money: `Q64.99` in `en`, `64,99 GTQ`\n * or similar in `es`. Never the bare stored number — a till once printed\n * 6499 GTQ for 64,99.\n */\nexport function formatMoney(\n amount: number,\n currency: string,\n unit: MoneyUnit,\n locale: string,\n): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(\n toMajorUnits(amount, currency, unit),\n );\n}\n\n/** The currency a money member reads in: fixed, or the record's own member. */\nexport function currencyOf(\n money: MoneyFormat,\n record: Readonly<Record<string, unknown>> | undefined,\n): string | undefined {\n if (money.currency !== undefined) return money.currency;\n const value = record?.[money.currencyMember];\n return typeof value === 'string' && value !== '' ? value : undefined;\n}\n"],"names":["fractionDigits","currency","Intl","NumberFormat","style","resolvedOptions","maximumFractionDigits","toMajorUnits","amount","unit","fromMajorUnits","major","digits","Number","toFixed","Math","round","formatMoney","locale","format","currencyOf","money","record","undefined","value","currencyMember"],"mappings":"AAIA;;;;CAIC,GACD,OAAO,SAASA,eAAeC,QAAgB;QAI3C;IAHF,4EAA4E;IAC5E,kBAAkB,GAClB,QACE,yCAAA,IAAIC,KAAKC,YAAY,CAAC,MAAM;QAC1BC,OAAO;QACPH;IACF,GAAGI,eAAe,GAAGC,qBAAqB,YAH1C,yCAG8C;AAElD;AAEA,uEAAuE,GACvE,OAAO,SAASC,aACdC,MAAc,EACdP,QAAgB,EAChBQ,IAAe;IAEf,OAAOA,SAAS,UAAUD,SAASA,SAAS,MAAMR,eAAeC;AACnE;AAEA,yEAAyE,GACzE,OAAO,SAASS,eACdC,KAAa,EACbV,QAAgB,EAChBQ,IAAe;IAEf,MAAMG,SAASZ,eAAeC;IAC9B,OAAOQ,SAAS,UACZI,OAAOF,MAAMG,OAAO,CAACF,WACrBG,KAAKC,KAAK,CAACL,QAAQ,MAAMC;AAC/B;AAEA;;;;CAIC,GACD,OAAO,SAASK,YACdT,MAAc,EACdP,QAAgB,EAChBQ,IAAe,EACfS,MAAc;IAEd,OAAO,IAAIhB,KAAKC,YAAY,CAACe,QAAQ;QAAEd,OAAO;QAAYH;IAAS,GAAGkB,MAAM,CAC1EZ,aAAaC,QAAQP,UAAUQ;AAEnC;AAEA,6EAA6E,GAC7E,OAAO,SAASW,WACdC,KAAkB,EAClBC,MAAqD;IAErD,IAAID,MAAMpB,QAAQ,KAAKsB,WAAW,OAAOF,MAAMpB,QAAQ;IACvD,MAAMuB,QAAQF,0BAAAA,MAAQ,CAACD,MAAMI,cAAc,CAAC;IAC5C,OAAO,OAAOD,UAAU,YAAYA,UAAU,KAAKA,QAAQD;AAC7D"}
1
+ {"version":3,"sources":["../../../../src/ui/atoms/money/money-math.ts"],"sourcesContent":["import { formattingLocale, type MoneyFormat } from '@entifix/core';\n\nexport type MoneyUnit = MoneyFormat['unit'];\n\n/**\n * How many minor units a currency has, as `Intl` resolves it: 2 for GTQ and\n * USD, 0 for JPY, 3 for KWD. Read from the platform rather than a table, so a\n * currency nobody here thought of is still right.\n */\nexport function fractionDigits(currency: string): number {\n // Always set for `style: 'currency'`; the fallback only satisfies the type.\n /* v8 ignore next */\n return (\n new Intl.NumberFormat('en', {\n style: 'currency',\n currency,\n }).resolvedOptions().maximumFractionDigits ?? 2\n );\n}\n\n/** The amount in major units (64.99), whichever unit it is stored in. */\nexport function toMajorUnits(\n amount: number,\n currency: string,\n unit: MoneyUnit,\n): number {\n return unit === 'major' ? amount : amount / 10 ** fractionDigits(currency);\n}\n\n/** A major-unit amount back in the unit it is stored in, rounded to it. */\nexport function fromMajorUnits(\n major: number,\n currency: string,\n unit: MoneyUnit,\n): number {\n const digits = fractionDigits(currency);\n return unit === 'major'\n ? Number(major.toFixed(digits))\n : Math.round(major * 10 ** digits);\n}\n\n/**\n * The amount as the reader's formatting locale writes money: `Q64.99` in\n * `es-GT`, `64,99 GTQ` or similar in `es`. Never the bare stored number — a till once printed\n * 6499 GTQ for 64,99.\n */\nexport function formatMoney(\n amount: number,\n currency: string,\n unit: MoneyUnit,\n locale: string,\n): string {\n return new Intl.NumberFormat(formattingLocale(locale), {\n style: 'currency',\n currency,\n }).format(toMajorUnits(amount, currency, unit));\n}\n\n/** The currency a money member reads in: fixed, or the record's own member. */\nexport function currencyOf(\n money: MoneyFormat,\n record: Readonly<Record<string, unknown>> | undefined,\n): string | undefined {\n if (money.currency !== undefined) return money.currency;\n const value = record?.[money.currencyMember];\n return typeof value === 'string' && value !== '' ? value : undefined;\n}\n"],"names":["formattingLocale","fractionDigits","currency","Intl","NumberFormat","style","resolvedOptions","maximumFractionDigits","toMajorUnits","amount","unit","fromMajorUnits","major","digits","Number","toFixed","Math","round","formatMoney","locale","format","currencyOf","money","record","undefined","value","currencyMember"],"mappings":"AAAA,SAASA,gBAAgB,QAA0B,gBAAgB;AAInE;;;;CAIC,GACD,OAAO,SAASC,eAAeC,QAAgB;QAI3C;IAHF,4EAA4E;IAC5E,kBAAkB,GAClB,QACE,yCAAA,IAAIC,KAAKC,YAAY,CAAC,MAAM;QAC1BC,OAAO;QACPH;IACF,GAAGI,eAAe,GAAGC,qBAAqB,YAH1C,yCAG8C;AAElD;AAEA,uEAAuE,GACvE,OAAO,SAASC,aACdC,MAAc,EACdP,QAAgB,EAChBQ,IAAe;IAEf,OAAOA,SAAS,UAAUD,SAASA,SAAS,MAAMR,eAAeC;AACnE;AAEA,yEAAyE,GACzE,OAAO,SAASS,eACdC,KAAa,EACbV,QAAgB,EAChBQ,IAAe;IAEf,MAAMG,SAASZ,eAAeC;IAC9B,OAAOQ,SAAS,UACZI,OAAOF,MAAMG,OAAO,CAACF,WACrBG,KAAKC,KAAK,CAACL,QAAQ,MAAMC;AAC/B;AAEA;;;;CAIC,GACD,OAAO,SAASK,YACdT,MAAc,EACdP,QAAgB,EAChBQ,IAAe,EACfS,MAAc;IAEd,OAAO,IAAIhB,KAAKC,YAAY,CAACJ,iBAAiBmB,SAAS;QACrDd,OAAO;QACPH;IACF,GAAGkB,MAAM,CAACZ,aAAaC,QAAQP,UAAUQ;AAC3C;AAEA,6EAA6E,GAC7E,OAAO,SAASW,WACdC,KAAkB,EAClBC,MAAqD;IAErD,IAAID,MAAMpB,QAAQ,KAAKsB,WAAW,OAAOF,MAAMpB,QAAQ;IACvD,MAAMuB,QAAQF,0BAAAA,MAAQ,CAACD,MAAMI,cAAc,CAAC;IAC5C,OAAO,OAAOD,UAAU,YAAYA,UAAU,KAAKA,QAAQD;AAC7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/react-controls",
3
- "version": "0.23.7",
3
+ "version": "0.23.8",
4
4
  "description": "Entity-agnostic React UI — table, form, filters, wizard, command palette — rendered from entity metadata, plus layout primitives.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,7 +19,7 @@
19
19
  "@headlessui/react": "^2.2.10",
20
20
  "class-variance-authority": "^0.7.1",
21
21
  "idb": "^8.0.4",
22
- "@entifix/core": "0.23.7"
22
+ "@entifix/core": "0.23.8"
23
23
  },
24
24
  "exports": {
25
25
  "./package.json": "./package.json",
@@ -55,8 +55,8 @@
55
55
  "react": "19.3.1",
56
56
  "react-i18next": "18.0.1",
57
57
  "storybook": "^10.6.6",
58
- "@entifix/i18n": "0.23.7",
59
- "@entifix/style": "0.23.7"
58
+ "@entifix/i18n": "0.23.8",
59
+ "@entifix/style": "0.23.8"
60
60
  },
61
61
  "nx": {
62
62
  "tags": [
@@ -111,7 +111,7 @@
111
111
  "i18next": ">=26 <28",
112
112
  "react": ">=19 <20",
113
113
  "react-i18next": ">=17 <19",
114
- "@entifix/i18n": "0.23.7"
114
+ "@entifix/i18n": "0.23.8"
115
115
  },
116
116
  "peerDependenciesMeta": {
117
117
  "@entifix/i18n": {