@entifix/react-controls 0.23.6 → 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.
Files changed (83) hide show
  1. package/README.md +16 -0
  2. package/dist/i18n/catalog/en.d.ts.map +1 -1
  3. package/dist/i18n/catalog/en.js +2 -1
  4. package/dist/i18n/catalog/en.js.map +1 -1
  5. package/dist/i18n/catalog/es.d.ts +1 -0
  6. package/dist/i18n/catalog/es.d.ts.map +1 -1
  7. package/dist/i18n/catalog/es.js +2 -1
  8. package/dist/i18n/catalog/es.js.map +1 -1
  9. package/dist/i18n/catalog/index.d.ts +2 -0
  10. package/dist/i18n/catalog/index.d.ts.map +1 -1
  11. package/dist/i18n/i18n-context.d.ts.map +1 -1
  12. package/dist/i18n/i18n-context.js +5 -2
  13. package/dist/i18n/i18n-context.js.map +1 -1
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/primitives.d.ts +1 -0
  19. package/dist/primitives.d.ts.map +1 -1
  20. package/dist/primitives.js +1 -0
  21. package/dist/primitives.js.map +1 -1
  22. package/dist/ui/atoms/cell-value/cell-value.d.ts +2 -1
  23. package/dist/ui/atoms/cell-value/cell-value.d.ts.map +1 -1
  24. package/dist/ui/atoms/cell-value/cell-value.js +31 -5
  25. package/dist/ui/atoms/cell-value/cell-value.js.map +1 -1
  26. package/dist/ui/atoms/field-control/field-control.d.ts +2 -1
  27. package/dist/ui/atoms/field-control/field-control.d.ts.map +1 -1
  28. package/dist/ui/atoms/field-control/field-control.js +19 -0
  29. package/dist/ui/atoms/field-control/field-control.js.map +1 -1
  30. package/dist/ui/atoms/money/money-input.d.ts +5 -0
  31. package/dist/ui/atoms/money/money-input.d.ts.map +1 -1
  32. package/dist/ui/atoms/money/money-input.js +11 -13
  33. package/dist/ui/atoms/money/money-input.js.map +1 -1
  34. package/dist/ui/atoms/money/money-math.d.ts +3 -3
  35. package/dist/ui/atoms/money/money-math.d.ts.map +1 -1
  36. package/dist/ui/atoms/money/money-math.js +4 -3
  37. package/dist/ui/atoms/money/money-math.js.map +1 -1
  38. package/dist/ui/atoms/number-input/quantity-input.d.ts +19 -4
  39. package/dist/ui/atoms/number-input/quantity-input.d.ts.map +1 -1
  40. package/dist/ui/atoms/number-input/quantity-input.js +13 -5
  41. package/dist/ui/atoms/number-input/quantity-input.js.map +1 -1
  42. package/dist/ui/atoms/number-input/scaled-quantity-input.d.ts +16 -0
  43. package/dist/ui/atoms/number-input/scaled-quantity-input.d.ts.map +1 -0
  44. package/dist/ui/atoms/number-input/scaled-quantity-input.js +135 -0
  45. package/dist/ui/atoms/number-input/scaled-quantity-input.js.map +1 -0
  46. package/dist/ui/atoms/number-input/step-button.d.ts +3 -0
  47. package/dist/ui/atoms/number-input/step-button.d.ts.map +1 -0
  48. package/dist/ui/atoms/number-input/step-button.js +3 -0
  49. package/dist/ui/atoms/number-input/step-button.js.map +1 -0
  50. package/dist/ui/atoms/number-input/unparsed.d.ts +10 -0
  51. package/dist/ui/atoms/number-input/unparsed.d.ts.map +1 -0
  52. package/dist/ui/atoms/number-input/unparsed.js +10 -0
  53. package/dist/ui/atoms/number-input/unparsed.js.map +1 -0
  54. package/dist/ui/atoms/scaled/index.d.ts +5 -0
  55. package/dist/ui/atoms/scaled/index.d.ts.map +1 -0
  56. package/dist/ui/atoms/scaled/index.js +6 -0
  57. package/dist/ui/atoms/scaled/index.js.map +1 -0
  58. package/dist/ui/atoms/scaled/scaled-input.d.ts +24 -0
  59. package/dist/ui/atoms/scaled/scaled-input.d.ts.map +1 -0
  60. package/dist/ui/atoms/scaled/scaled-input.js +98 -0
  61. package/dist/ui/atoms/scaled/scaled-input.js.map +1 -0
  62. package/dist/ui/atoms/scaled/scaled-math.d.ts +13 -0
  63. package/dist/ui/atoms/scaled/scaled-math.d.ts.map +1 -0
  64. package/dist/ui/atoms/scaled/scaled-math.js +17 -0
  65. package/dist/ui/atoms/scaled/scaled-math.js.map +1 -0
  66. package/dist/ui/atoms/scaled/scaled-value.d.ts +14 -0
  67. package/dist/ui/atoms/scaled/scaled-value.d.ts.map +1 -0
  68. package/dist/ui/atoms/scaled/scaled-value.js +14 -0
  69. package/dist/ui/atoms/scaled/scaled-value.js.map +1 -0
  70. package/dist/ui/atoms/scaled/use-unit-label.d.ts +4 -0
  71. package/dist/ui/atoms/scaled/use-unit-label.d.ts.map +1 -0
  72. package/dist/ui/atoms/scaled/use-unit-label.js +11 -0
  73. package/dist/ui/atoms/scaled/use-unit-label.js.map +1 -0
  74. package/dist/ui/organisms/entity-detail-grid/entity-detail-grid.d.ts.map +1 -1
  75. package/dist/ui/organisms/entity-detail-grid/entity-detail-grid.js +1 -1
  76. package/dist/ui/organisms/entity-detail-grid/entity-detail-grid.js.map +1 -1
  77. package/dist/ui/organisms/entity-table/entity-table-slots.d.ts +6 -1
  78. package/dist/ui/organisms/entity-table/entity-table-slots.d.ts.map +1 -1
  79. package/dist/ui/organisms/entity-table/entity-table-slots.js.map +1 -1
  80. package/dist/ui/organisms/entity-table/use-entity-table-columns.d.ts.map +1 -1
  81. package/dist/ui/organisms/entity-table/use-entity-table-columns.js +2 -0
  82. package/dist/ui/organisms/entity-table/use-entity-table-columns.js.map +1 -1
  83. package/package.json +5 -5
@@ -1,11 +1,14 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { defaultLocale, EntityCollectionLink, EntityLink, isLocalizedText, localize } from '@entifix/core';
3
+ import { defaultLocale, EntityCollectionLink, EntityLink, formatScaled, isLocalizedText, localize } from '@entifix/core';
4
4
  import { useCallback } from 'react';
5
5
  import { useEnumLabel, useFormatters, useLocale, useT } from '../../../i18n/index.js';
6
6
  import { useReferenceLabel, useUnresolvedReference } from '../../utils/reference-labels.js';
7
7
  import { Money } from '../money/money.js';
8
8
  import { currencyOf } from '../money/money-math.js';
9
+ import { scaleOf } from '../scaled/scaled-math.js';
10
+ import { ScaledValue } from '../scaled/scaled-value.js';
11
+ import { useUnitLabel } from '../scaled/use-unit-label.js';
9
12
  import { Skeleton } from '../skeleton/index.js';
10
13
  import { StatusTag } from '../status-tag/index.js';
11
14
  /** Stand-in for an absent value, so an empty cell still reads as intentional. */ const EMPTY = '—';
@@ -35,7 +38,10 @@ function formatByType(value, type, linkLabelProperty, formatting) {
35
38
  case 'date':
36
39
  return formatting.formatters.date(value instanceof Date ? value : String(value));
37
40
  case 'number':
38
- return typeof value === 'number' ? formatting.formatters.number(value) : String(value);
41
+ if (typeof value !== 'number') return String(value);
42
+ // Words have no record to read a unit from, so only a fixed scale can
43
+ // be honoured here.
44
+ return formatting.fixedScale !== undefined && Number.isSafeInteger(value) ? formatScaled(value, formatting.fixedScale, formatting.locale) : formatting.formatters.number(value);
39
45
  case 'boolean':
40
46
  return value ? formatting.yes : formatting.no;
41
47
  case 'enum':
@@ -68,7 +74,9 @@ function formatByType(value, type, linkLabelProperty, formatting) {
68
74
  const formatters = useFormatters();
69
75
  const enumLabel = useEnumLabel();
70
76
  const locale = useLocale();
71
- return useCallback((descriptor)=>({
77
+ return useCallback((descriptor)=>{
78
+ var _descriptor_scaled;
79
+ return {
72
80
  formatters,
73
81
  yes: t('value.yes'),
74
82
  no: t('value.no'),
@@ -76,8 +84,10 @@ function formatByType(value, type, linkLabelProperty, formatting) {
76
84
  rowCount: (count)=>t('value.rowCount', {
77
85
  count
78
86
  }),
79
- locale
80
- }), [
87
+ locale,
88
+ fixedScale: (_descriptor_scaled = descriptor.scaled) == null ? void 0 : _descriptor_scaled.scale
89
+ };
90
+ }, [
81
91
  enumLabel,
82
92
  formatters,
83
93
  locale,
@@ -165,6 +175,7 @@ function formatByType(value, type, linkLabelProperty, formatting) {
165
175
  var _value_locale, _NUMERIC_CLASS_descriptor_type;
166
176
  const formatting = useCellFormatting();
167
177
  const locale = useLocale();
178
+ const unitLabel = useUnitLabel();
168
179
  if (value === undefined || value === null || value === '') {
169
180
  return /*#__PURE__*/ _jsx("span", {
170
181
  className: "text-content-muted",
@@ -194,6 +205,21 @@ function formatByType(value, type, linkLabelProperty, formatting) {
194
205
  });
195
206
  }
196
207
  }
208
+ // A scaled integer reads as the decimal it stands for, beside its unit. One
209
+ // whose record names no declared unit stays the number it is, as money
210
+ // without a currency does.
211
+ if (descriptor.scaled !== undefined) {
212
+ const stored = Number(value);
213
+ const resolved = scaleOf(descriptor.scaled, record);
214
+ if (resolved !== undefined && Number.isSafeInteger(stored)) {
215
+ return /*#__PURE__*/ _jsx(ScaledValue, {
216
+ value: stored,
217
+ scale: resolved.scale,
218
+ unit: unitLabel(descriptor.scaled, resolved.unit),
219
+ locale: locale
220
+ });
221
+ }
222
+ }
197
223
  // A relation whose target has not arrived yet holds its place with a
198
224
  // skeleton — the id is all it has, and the id is not what it means.
199
225
  if (value instanceof EntityLink && value.id != null && value.value === undefined || value instanceof EntityCollectionLink && value.ids.length > 0 && value.values === undefined) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/atoms/cell-value/cell-value.tsx"],"sourcesContent":["'use client';\n\nimport type { Formatters, Locale } from '@entifix/core';\nimport {\n defaultLocale,\n type Entity,\n EntityCollectionLink,\n type EntityFieldDescriptor,\n EntityLink,\n isLocalizedText,\n localize,\n type MetaAccessorType,\n} from '@entifix/core';\nimport { useCallback } from 'react';\n\nimport {\n useEnumLabel,\n useFormatters,\n useLocale,\n useT,\n} from '../../../i18n/index.js';\nimport {\n useReferenceLabel,\n useUnresolvedReference,\n} from '../../utils/reference-labels.js';\nimport { Money } from '../money/money.js';\nimport { currencyOf } from '../money/money-math.js';\nimport { Skeleton } from '../skeleton/index.js';\nimport { StatusTag } from '../status-tag/index.js';\n\n/** Stand-in for an absent value, so an empty cell still reads as intentional. */\nconst EMPTY = '—';\n\n/**\n * A link reads as its target's label once the target is loaded (embedded or\n * resolved). Never as its id: a key is not a name, and showing one fails the\n * reader who came to see which record it is (#200).\n */\nfunction entityLabel(\n target: Entity | undefined,\n linkLabelProperty: string,\n locale: Locale,\n): string | undefined {\n const label = (target as Record<string, unknown> | undefined)?.[\n linkLabelProperty\n ];\n if (label == null) return undefined;\n // A target labelled by a localized member reads in the reader's locale.\n return isLocalizedText(label) ? localize(label, locale) : String(label);\n}\n\nfunction formatLink(\n link: EntityLink<Entity>,\n linkLabelProperty: string,\n locale: Locale,\n): string {\n return link.id == null\n ? EMPTY\n : (entityLabel(link.value, linkLabelProperty, locale) ?? EMPTY);\n}\n\nfunction formatCollectionLink(\n link: EntityCollectionLink<Entity>,\n linkLabelProperty: string,\n locale: Locale,\n): string {\n return (link.values ?? [])\n .map(target => entityLabel(target, linkLabelProperty, locale) ?? EMPTY)\n .join(', ');\n}\n\n/**\n * Everything locale-dependent, resolved once by the component and handed down.\n * The formatters carry an explicit locale, which is what keeps a date rendered\n * on the server byte-identical to the same date rendered in the browser.\n */\ninterface CellFormatting {\n readonly formatters: Formatters;\n readonly yes: string;\n readonly no: string;\n readonly enumLabel: (value: string) => string;\n readonly rowCount: (count: number) => string;\n readonly locale: Locale;\n}\n\nfunction formatByType(\n value: unknown,\n type: MetaAccessorType,\n linkLabelProperty: string,\n formatting: CellFormatting,\n): string {\n switch (type) {\n case 'date':\n return formatting.formatters.date(\n value instanceof Date ? value : String(value),\n );\n case 'number':\n return typeof value === 'number'\n ? formatting.formatters.number(value)\n : String(value);\n case 'boolean':\n return value ? formatting.yes : formatting.no;\n case 'enum':\n return formatting.enumLabel(String(value));\n case 'link':\n return value instanceof EntityLink\n ? formatLink(value, linkLabelProperty, formatting.locale)\n : String(value);\n case 'linkCollection':\n return value instanceof EntityCollectionLink\n ? formatCollectionLink(value, linkLabelProperty, formatting.locale)\n : String(value);\n case 'scalarCollection':\n // The same comma list the draft holds, spaced for reading. Not `String`:\n // an array's own `toString` joins on a bare comma, which reads as one\n // run-on token in a narrow column.\n return Array.isArray(value) ? value.join(', ') : String(value);\n case 'composition':\n // Owned rows have no useful one-line form — a receipt's lines are not a\n // sentence — and the master's own screen is where they are read and\n // edited. So the cell reports the count and stops.\n return Array.isArray(value)\n ? formatting.rowCount(value.length)\n : String(value);\n case 'localized':\n // The reader's locale, falling back to the host's default; a value\n // that is not a text per locale has no reading worth guessing at.\n return isLocalizedText(value)\n ? (localize(value, formatting.locale) ?? '')\n : '';\n default:\n return String(value);\n }\n}\n\n/** The formatting {@link formatByType} reads, resolved for the reader. */\nfunction useCellFormatting(): (\n descriptor: EntityFieldDescriptor,\n) => CellFormatting {\n const t = useT();\n const formatters = useFormatters();\n const enumLabel = useEnumLabel();\n const locale = useLocale();\n return useCallback(\n descriptor => ({\n formatters,\n yes: t('value.yes'),\n no: t('value.no'),\n enumLabel: raw => enumLabel(descriptor, raw),\n rowCount: count => t('value.rowCount', { count }),\n locale,\n }),\n [enumLabel, formatters, locale, t],\n );\n}\n\n/**\n * A filled-in member's value as one line of text, exactly as its cell reads\n * it — for the places that need words rather than an element: a checkbox's\n * name, a confirm dialog's object, a toast.\n */\nexport function useValueText(): (\n value: unknown,\n descriptor: EntityFieldDescriptor,\n) => string {\n const formatting = useCellFormatting();\n return useCallback(\n (value, descriptor) =>\n formatByType(\n value,\n descriptor.type,\n descriptor.linkLabelProperty,\n formatting(descriptor),\n ),\n [formatting],\n );\n}\n\n/**\n * A reference reads as its target's name, in every state the read can be in\n * ([ADR 0030](../../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)):\n * a skeleton while it resolves (the noun and short id for a screen reader); the name; the entity's noun and the short id,\n * muted, when no record answered or the read failed — never an alert, since a\n * list that loaded has not failed because one name could not be read; and the\n * raw id, muted, when the host registered nothing to read it with.\n */\nfunction ReferenceValue({ entity, id }: { entity: string; id: string }) {\n const state = useReferenceLabel(entity, id);\n const unresolved = useUnresolvedReference();\n const locale = useLocale();\n switch (state.status) {\n case 'resolving':\n // The skeleton is hidden from assistive tech, so the noun and short id\n // stand in for it there: a record's title link is never nameless.\n return (\n <>\n <Skeleton shape=\"line\" className=\"w-16\" />\n <span className=\"sr-only\">{unresolved(entity, id)}</span>\n </>\n );\n case 'named': {\n const { label } = state;\n if (typeof label === 'string') return <span>{label}</span>;\n const text = localize(label, locale);\n return (label[locale] ?? '') === '' ? (\n <span lang={defaultLocale()}>{text}</span>\n ) : (\n <span>{text}</span>\n );\n }\n case 'unregistered':\n return <span className=\"text-content-muted\">{id}</span>;\n default:\n return (\n <span className=\"text-content-muted\">{unresolved(entity, id)}</span>\n );\n }\n}\n\n/**\n * Tabular figures, applied once, here — not on `--font-sans` and not per call\n * site. A column of numbers or dates must align on the digit; a paragraph must\n * not, because proportional figures are what prose is set in. The descriptor\n * already knows which is which, so the cell is the only place that has to.\n */\nconst NUMERIC_CLASS: Partial<Record<MetaAccessorType, string>> = {\n number: 'tabular-nums',\n date: 'tabular-nums',\n};\n\nexport interface CellValueProps {\n value: unknown;\n descriptor: EntityFieldDescriptor;\n /**\n * The record the value belongs to. A money member whose currency is another\n * member of the record (`money.currencyMember`) reads it from here.\n */\n record?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Renders one entity member according to its metadata type. Centralizing this\n * is what lets a table stay generic: a link, a date and a number all arrive as\n * \"the value of an accessor\", and only the descriptor decides how they read.\n */\nexport function CellValue({ value, descriptor, record }: CellValueProps) {\n const formatting = useCellFormatting();\n const locale = useLocale();\n\n if (value === undefined || value === null || value === '') {\n return <span className=\"text-content-muted\">{EMPTY}</span>;\n }\n\n // A key into another entity reads as that record's name, never as itself.\n if (descriptor.references !== undefined) {\n return (\n <ReferenceValue\n entity={descriptor.references.entity}\n id={String(value)}\n />\n );\n }\n\n // An amount reads as money in the reader's locale, never as the stored\n // number. A draft holds it as a string, so a numeric string counts too. A\n // currency the record does not carry leaves it a plain number rather than\n // guessing one.\n if (descriptor.money !== undefined) {\n const amount = typeof value === 'number' ? value : Number(value);\n const currency = currencyOf(descriptor.money, record);\n if (currency !== undefined && Number.isFinite(amount)) {\n return (\n <Money\n amount={amount}\n currency={currency}\n unit={descriptor.money.unit}\n locale={locale}\n />\n );\n }\n }\n\n // A relation whose target has not arrived yet holds its place with a\n // skeleton — the id is all it has, and the id is not what it means.\n if (\n (value instanceof EntityLink &&\n value.id != null &&\n value.value === undefined) ||\n (value instanceof EntityCollectionLink &&\n value.ids.length > 0 &&\n value.values === undefined)\n ) {\n return <Skeleton shape=\"line\" className=\"w-16\" />;\n }\n\n const text = formatByType(\n value,\n descriptor.type,\n descriptor.linkLabelProperty,\n formatting(descriptor),\n );\n\n if (text === '') {\n return <span className=\"text-content-muted\">{EMPTY}</span>;\n }\n\n // A status reads as a tag in its declared tone, its words beside the\n // colour; a value given no tone reads neutral. An enum that declared no\n // tones is not a status, and stays text.\n if (descriptor.type === 'enum' && descriptor.enumTones !== undefined) {\n return (\n <StatusTag tone={descriptor.enumTones[String(value)] ?? 'neutral'}>\n {text}\n </StatusTag>\n );\n }\n\n // Text the reader's locale lacks falls back to the default locale's, and is\n // marked as that language, so it is read in its own voice (WCAG 3.1.2).\n if (\n descriptor.type === 'localized' &&\n isLocalizedText(value) &&\n (value[locale] ?? '') === ''\n ) {\n return <span lang={defaultLocale()}>{text}</span>;\n }\n\n return (\n <span className={NUMERIC_CLASS[descriptor.type] ?? undefined}>{text}</span>\n );\n}\n"],"names":["defaultLocale","EntityCollectionLink","EntityLink","isLocalizedText","localize","useCallback","useEnumLabel","useFormatters","useLocale","useT","useReferenceLabel","useUnresolvedReference","Money","currencyOf","Skeleton","StatusTag","EMPTY","entityLabel","target","linkLabelProperty","locale","label","undefined","String","formatLink","link","id","value","formatCollectionLink","values","map","join","formatByType","type","formatting","formatters","date","Date","number","yes","no","enumLabel","Array","isArray","rowCount","length","useCellFormatting","t","descriptor","raw","count","useValueText","ReferenceValue","entity","state","unresolved","status","shape","className","span","text","lang","NUMERIC_CLASS","CellValue","record","references","money","amount","Number","currency","isFinite","unit","ids","enumTones","tone"],"mappings":"AAAA;;AAGA,SACEA,aAAa,EAEbC,oBAAoB,EAEpBC,UAAU,E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4EAA4E;IAC5E,wEAAwE;IACxE,IACEZ,WAAWf,IAAI,KAAK,eACpB9B,gBAAgBwB,UAChB,EAACA,gBAAAA,KAAK,CAACP,OAAO,YAAbO,gBAAiB,QAAQ,IAC1B;QACA,qBAAO,KAACgC;YAAKE,MAAM7D;sBAAkB4D;;IACvC;IAEA,qBACE,KAACD;QAAKD,SAAS,GAAEI,iCAAAA,aAAa,CAACd,WAAWf,IAAI,CAAC,YAA9B6B,iCAAkCxC;kBAAYsC;;AAEnE"}
1
+ {"version":3,"sources":["../../../../src/ui/atoms/cell-value/cell-value.tsx"],"sourcesContent":["'use client';\n\nimport type { Formatters, Locale } from '@entifix/core';\nimport {\n defaultLocale,\n type Entity,\n EntityCollectionLink,\n type EntityFieldDescriptor,\n EntityLink,\n formatScaled,\n isLocalizedText,\n localize,\n type MetaAccessorType,\n} from '@entifix/core';\nimport { useCallback } from 'react';\n\nimport {\n useEnumLabel,\n useFormatters,\n useLocale,\n useT,\n} from '../../../i18n/index.js';\nimport {\n useReferenceLabel,\n useUnresolvedReference,\n} from '../../utils/reference-labels.js';\nimport { Money } from '../money/money.js';\nimport { currencyOf } from '../money/money-math.js';\nimport { scaleOf } from '../scaled/scaled-math.js';\nimport { ScaledValue } from '../scaled/scaled-value.js';\nimport { useUnitLabel } from '../scaled/use-unit-label.js';\nimport { Skeleton } from '../skeleton/index.js';\nimport { StatusTag } from '../status-tag/index.js';\n\n/** Stand-in for an absent value, so an empty cell still reads as intentional. */\nconst EMPTY = '—';\n\n/**\n * A link reads as its target's label once the target is loaded (embedded or\n * resolved). Never as its id: a key is not a name, and showing one fails the\n * reader who came to see which record it is (#200).\n */\nfunction entityLabel(\n target: Entity | undefined,\n linkLabelProperty: string,\n locale: Locale,\n): string | undefined {\n const label = (target as Record<string, unknown> | undefined)?.[\n linkLabelProperty\n ];\n if (label == null) return undefined;\n // A target labelled by a localized member reads in the reader's locale.\n return isLocalizedText(label) ? localize(label, locale) : String(label);\n}\n\nfunction formatLink(\n link: EntityLink<Entity>,\n linkLabelProperty: string,\n locale: Locale,\n): string {\n return link.id == null\n ? EMPTY\n : (entityLabel(link.value, linkLabelProperty, locale) ?? EMPTY);\n}\n\nfunction formatCollectionLink(\n link: EntityCollectionLink<Entity>,\n linkLabelProperty: string,\n locale: Locale,\n): string {\n return (link.values ?? [])\n .map(target => entityLabel(target, linkLabelProperty, locale) ?? EMPTY)\n .join(', ');\n}\n\n/**\n * Everything locale-dependent, resolved once by the component and handed down.\n * The formatters carry an explicit locale, which is what keeps a date rendered\n * on the server byte-identical to the same date rendered in the browser.\n */\ninterface CellFormatting {\n readonly formatters: Formatters;\n readonly yes: string;\n readonly no: string;\n readonly enumLabel: (value: string) => string;\n readonly rowCount: (count: number) => string;\n readonly locale: Locale;\n readonly fixedScale: number | undefined;\n}\n\nfunction formatByType(\n value: unknown,\n type: MetaAccessorType,\n linkLabelProperty: string,\n formatting: CellFormatting,\n): string {\n switch (type) {\n case 'date':\n return formatting.formatters.date(\n value instanceof Date ? value : String(value),\n );\n case 'number':\n if (typeof value !== 'number') return String(value);\n // Words have no record to read a unit from, so only a fixed scale can\n // be honoured here.\n return formatting.fixedScale !== undefined && Number.isSafeInteger(value)\n ? formatScaled(value, formatting.fixedScale, formatting.locale)\n : formatting.formatters.number(value);\n case 'boolean':\n return value ? formatting.yes : formatting.no;\n case 'enum':\n return formatting.enumLabel(String(value));\n case 'link':\n return value instanceof EntityLink\n ? formatLink(value, linkLabelProperty, formatting.locale)\n : String(value);\n case 'linkCollection':\n return value instanceof EntityCollectionLink\n ? formatCollectionLink(value, linkLabelProperty, formatting.locale)\n : String(value);\n case 'scalarCollection':\n // The same comma list the draft holds, spaced for reading. Not `String`:\n // an array's own `toString` joins on a bare comma, which reads as one\n // run-on token in a narrow column.\n return Array.isArray(value) ? value.join(', ') : String(value);\n case 'composition':\n // Owned rows have no useful one-line form — a receipt's lines are not a\n // sentence — and the master's own screen is where they are read and\n // edited. So the cell reports the count and stops.\n return Array.isArray(value)\n ? formatting.rowCount(value.length)\n : String(value);\n case 'localized':\n // The reader's locale, falling back to the host's default; a value\n // that is not a text per locale has no reading worth guessing at.\n return isLocalizedText(value)\n ? (localize(value, formatting.locale) ?? '')\n : '';\n default:\n return String(value);\n }\n}\n\n/** The formatting {@link formatByType} reads, resolved for the reader. */\nfunction useCellFormatting(): (\n descriptor: EntityFieldDescriptor,\n) => CellFormatting {\n const t = useT();\n const formatters = useFormatters();\n const enumLabel = useEnumLabel();\n const locale = useLocale();\n return useCallback(\n descriptor => ({\n formatters,\n yes: t('value.yes'),\n no: t('value.no'),\n enumLabel: raw => enumLabel(descriptor, raw),\n rowCount: count => t('value.rowCount', { count }),\n locale,\n fixedScale: descriptor.scaled?.scale,\n }),\n [enumLabel, formatters, locale, t],\n );\n}\n\n/**\n * A filled-in member's value as one line of text, exactly as its cell reads\n * it — for the places that need words rather than an element: a checkbox's\n * name, a confirm dialog's object, a toast.\n */\nexport function useValueText(): (\n value: unknown,\n descriptor: EntityFieldDescriptor,\n) => string {\n const formatting = useCellFormatting();\n return useCallback(\n (value, descriptor) =>\n formatByType(\n value,\n descriptor.type,\n descriptor.linkLabelProperty,\n formatting(descriptor),\n ),\n [formatting],\n );\n}\n\n/**\n * A reference reads as its target's name, in every state the read can be in\n * ([ADR 0030](../../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)):\n * a skeleton while it resolves (the noun and short id for a screen reader); the name; the entity's noun and the short id,\n * muted, when no record answered or the read failed — never an alert, since a\n * list that loaded has not failed because one name could not be read; and the\n * raw id, muted, when the host registered nothing to read it with.\n */\nfunction ReferenceValue({ entity, id }: { entity: string; id: string }) {\n const state = useReferenceLabel(entity, id);\n const unresolved = useUnresolvedReference();\n const locale = useLocale();\n switch (state.status) {\n case 'resolving':\n // The skeleton is hidden from assistive tech, so the noun and short id\n // stand in for it there: a record's title link is never nameless.\n return (\n <>\n <Skeleton shape=\"line\" className=\"w-16\" />\n <span className=\"sr-only\">{unresolved(entity, id)}</span>\n </>\n );\n case 'named': {\n const { label } = state;\n if (typeof label === 'string') return <span>{label}</span>;\n const text = localize(label, locale);\n return (label[locale] ?? '') === '' ? (\n <span lang={defaultLocale()}>{text}</span>\n ) : (\n <span>{text}</span>\n );\n }\n case 'unregistered':\n return <span className=\"text-content-muted\">{id}</span>;\n default:\n return (\n <span className=\"text-content-muted\">{unresolved(entity, id)}</span>\n );\n }\n}\n\n/**\n * Tabular figures, applied once, here — not on `--font-sans` and not per call\n * site. A column of numbers or dates must align on the digit; a paragraph must\n * not, because proportional figures are what prose is set in. The descriptor\n * already knows which is which, so the cell is the only place that has to.\n */\nconst NUMERIC_CLASS: Partial<Record<MetaAccessorType, string>> = {\n number: 'tabular-nums',\n date: 'tabular-nums',\n};\n\nexport interface CellValueProps {\n value: unknown;\n descriptor: EntityFieldDescriptor;\n /**\n * The record the value belongs to. A money member whose currency is another\n * member of the record (`money.currencyMember`), and a scaled member whose\n * unit is (`scaled.unitMember`), read it from here.\n */\n record?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Renders one entity member according to its metadata type. Centralizing this\n * is what lets a table stay generic: a link, a date and a number all arrive as\n * \"the value of an accessor\", and only the descriptor decides how they read.\n */\nexport function CellValue({ value, descriptor, record }: CellValueProps) {\n const formatting = useCellFormatting();\n const locale = useLocale();\n const unitLabel = useUnitLabel();\n\n if (value === undefined || value === null || value === '') {\n return <span className=\"text-content-muted\">{EMPTY}</span>;\n }\n\n // A key into another entity reads as that record's name, never as itself.\n if (descriptor.references !== undefined) {\n return (\n <ReferenceValue\n entity={descriptor.references.entity}\n id={String(value)}\n />\n );\n }\n\n // An amount reads as money in the reader's locale, never as the stored\n // number. A draft holds it as a string, so a numeric string counts too. A\n // currency the record does not carry leaves it a plain number rather than\n // guessing one.\n if (descriptor.money !== undefined) {\n const amount = typeof value === 'number' ? value : Number(value);\n const currency = currencyOf(descriptor.money, record);\n if (currency !== undefined && Number.isFinite(amount)) {\n return (\n <Money\n amount={amount}\n currency={currency}\n unit={descriptor.money.unit}\n locale={locale}\n />\n );\n }\n }\n\n // A scaled integer reads as the decimal it stands for, beside its unit. One\n // whose record names no declared unit stays the number it is, as money\n // without a currency does.\n if (descriptor.scaled !== undefined) {\n const stored = Number(value);\n const resolved = scaleOf(descriptor.scaled, record);\n if (resolved !== undefined && Number.isSafeInteger(stored)) {\n return (\n <ScaledValue\n value={stored}\n scale={resolved.scale}\n unit={unitLabel(descriptor.scaled, resolved.unit)}\n locale={locale}\n />\n );\n }\n }\n\n // A relation whose target has not arrived yet holds its place with a\n // skeleton — the id is all it has, and the id is not what it means.\n if (\n (value instanceof EntityLink &&\n value.id != null &&\n value.value === undefined) ||\n (value instanceof EntityCollectionLink &&\n value.ids.length > 0 &&\n value.values === undefined)\n ) {\n return <Skeleton shape=\"line\" className=\"w-16\" />;\n }\n\n const text = formatByType(\n value,\n descriptor.type,\n descriptor.linkLabelProperty,\n formatting(descriptor),\n );\n\n if (text === '') {\n return <span className=\"text-content-muted\">{EMPTY}</span>;\n }\n\n // A status reads as a tag in its declared tone, its words beside the\n // colour; a value given no tone reads neutral. An enum that declared no\n // tones is not a status, and stays text.\n if (descriptor.type === 'enum' && descriptor.enumTones !== undefined) {\n return (\n <StatusTag tone={descriptor.enumTones[String(value)] ?? 'neutral'}>\n {text}\n </StatusTag>\n );\n }\n\n // Text the reader's locale lacks falls back to the default locale's, and is\n // marked as that language, so it is read in its own voice (WCAG 3.1.2).\n if (\n descriptor.type === 'localized' &&\n isLocalizedText(value) &&\n (value[locale] ?? '') === ''\n ) {\n return <span lang={defaultLocale()}>{text}</span>;\n }\n\n return (\n <span className={NUMERIC_CLASS[descriptor.type] ?? undefined}>{text}</span>\n );\n}\n"],"names":["defaultLocale","EntityCollectionLink","EntityLink","formatScaled","isLocalizedText","localize","useCallback","useEnumLabel","useFormatters","useLocale","useT","useReferenceLabel","useUnresolvedReference","Money","currencyOf","scaleOf","ScaledValue","useUnitLabel","Skeleton","StatusTag","EMPTY","entityLabel","target","linkLabelProperty","locale","label","undefined","String","formatLink","link","id","value","formatCollectionLink","values","map","join","formatByType","type","formatting","formatters","date","Date","fixedScale","Number","isSafeInteger","number","yes","no","enumLabel","Array","isArray","rowCount","length","useCellFormatting","t","descriptor","raw","count","scaled","scale","useValueText","ReferenceValue","entity","state","unresolved","status","shape","className","span","text","lang","NUMERIC_CLASS","CellValue","record","unitLabel","references","money","amount","currency","isFinite","unit","stored","resolved","ids","enumTones","tone"],"mappings":"AAAA;;AAGA,SACEA,aAAa,EAEbC,oBAAoB,EAEpBC,UAAU,EACVC,YAAY,EACZC,eAAe,EACfC,QAAQ,QAEH,gBAAgB;AACvB,SAASC,WAAW,QAAQ,QAAQ;AAEpC,SACEC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,IAAI,QACC,yBAAyB;AAChC,SACEC,iBAAiB,EACjBC,sBAAsB,QACjB,kCAAkC;AACzC,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,OAAO,QAAQ,2BAA2B;AACnD,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,YAAY,QAAQ,8BAA8B;AAC3D,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,SAAS,QAAQ,yBAAyB;AAEnD,+EAA+E,GAC/E,MAAMC,QAAQ;AAEd;;;;CAIC,GACD,SAASC,YACPC,MAA0B,EAC1BC,iBAAyB,EACzBC,MAAc;IAEd,MAAMC,QAASH,0BAAD,AAACA,MAAgD,CAC7DC,kBACD;IACD,IAAIE,SAAS,MAAM,OAAOC;IAC1B,wEAAwE;IACxE,OAAOtB,gBAAgBqB,SAASpB,SAASoB,OAAOD,UAAUG,OAAOF;AACnE;AAEA,SAASG,WACPC,IAAwB,EACxBN,iBAAyB,EACzBC,MAAc;QAITH;IAFL,OAAOQ,KAAKC,EAAE,IAAI,OACdV,SACCC,eAAAA,YAAYQ,KAAKE,KAAK,EAAER,mBAAmBC,mBAA3CH,eAAsDD;AA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ACA,qBAAO,KAACqC;YAAKE,MAAMtE;sBAAkBqE;;IACvC;IAEA,qBACE,KAACD;QAAKD,SAAS,GAAEI,iCAAAA,aAAa,CAAChB,WAAWlB,IAAI,CAAC,YAA9BkC,iCAAkC7C;kBAAY2C;;AAEnE"}
@@ -26,7 +26,8 @@ export interface FieldControlProps {
26
26
  id?: string;
27
27
  /**
28
28
  * The record being edited, as its draft. A money member whose currency is
29
- * another member (`money.currencyMember`) reads it from here.
29
+ * another member (`money.currencyMember`), and a scaled one whose unit is
30
+ * (`scaled.unitMember`), read it from here.
30
31
  */
31
32
  record?: Readonly<Record<string, unknown>>;
32
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"field-control.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/field-control/field-control.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAoB,MAAM,eAAe,CAAC;AAO7E,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,qBAAqB,CAAC;IAClC;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC5C;AAQD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,UAAU,EACV,KAAK,EACL,QAAQ,EACR,EAAE,EACF,MAAM,EACN,GAAG,IAAI,EACR,EAAE,iBAAiB,+BA2EnB"}
1
+ {"version":3,"file":"field-control.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/field-control/field-control.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAoB,MAAM,eAAe,CAAC;AAU7E,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,qBAAqB,CAAC;IAClC;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC5C;AAQD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,UAAU,EACV,KAAK,EACL,QAAQ,EACR,EAAE,EACF,MAAM,EACN,GAAG,IAAI,EACR,EAAE,iBAAiB,+BA8FnB"}
@@ -6,6 +6,9 @@ import { useEnumLabel, useLocale } from '../../../i18n/index.js';
6
6
  import { Checkbox, Select, TextInput } from '../field/index.js';
7
7
  import { MoneyInput } from '../money/money-input.js';
8
8
  import { currencyOf } from '../money/money-math.js';
9
+ import { ScaledInput } from '../scaled/scaled-input.js';
10
+ import { scaleOf } from '../scaled/scaled-math.js';
11
+ import { useUnitLabel } from '../scaled/use-unit-label.js';
9
12
  /** Native input type for the text-like controls; text is the default. */ const INPUT_TYPE = {
10
13
  number: 'number',
11
14
  date: 'date'
@@ -42,6 +45,7 @@ import { currencyOf } from '../money/money-math.js';
42
45
  var _INPUT_TYPE_descriptor_type;
43
46
  const enumLabel = useEnumLabel();
44
47
  const locale = useLocale();
48
+ const unitLabel = useUnitLabel();
45
49
  const disabled = descriptor.readonly || descriptor.type === 'link' || descriptor.type === 'linkCollection' || descriptor.type === 'composition';
46
50
  if (descriptor.type === 'boolean') {
47
51
  return /*#__PURE__*/ _jsx(Checkbox, _extends({
@@ -89,6 +93,21 @@ import { currencyOf } from '../money/money-math.js';
89
93
  onChange: onChange
90
94
  }));
91
95
  }
96
+ // A scaled integer is edited as the decimal it stands for. Unlike money it
97
+ // has no plain fallback: without a scale, `3` typed would be stored as 0.003.
98
+ if (descriptor.scaled !== undefined) {
99
+ const resolved = scaleOf(descriptor.scaled, record);
100
+ return /*#__PURE__*/ _jsx(ScaledInput, _extends({
101
+ id: id
102
+ }, aria, {
103
+ value: value,
104
+ scale: resolved == null ? void 0 : resolved.scale,
105
+ unit: unitLabel(descriptor.scaled, resolved == null ? void 0 : resolved.unit),
106
+ locale: locale,
107
+ disabled: disabled,
108
+ onChange: onChange
109
+ }));
110
+ }
92
111
  return /*#__PURE__*/ _jsx(TextInput, _extends({
93
112
  id: id
94
113
  }, aria, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/atoms/field-control/field-control.tsx"],"sourcesContent":["'use client';\n\nimport type { EntityFieldDescriptor, MetaAccessorType } from '@entifix/core';\n\nimport { useEnumLabel, useLocale } from '../../../i18n/index.js';\nimport { Checkbox, Select, TextInput } from '../field/index.js';\nimport { MoneyInput } from '../money/money-input.js';\nimport { currencyOf } from '../money/money-math.js';\n\nexport interface FieldControlProps {\n descriptor: EntityFieldDescriptor;\n /**\n * ARIA wiring the caller owns, because only the caller knows the shape it is\n * rendered into.\n *\n * A form labels its control with a `<label for>` and needs none of this; a\n * detail grid's cell has no label of its own — the column header is the\n * label, and the cell's message is the description — so it points at both by\n * id. Passing them through here rather than duplicating the type→input map\n * in the grid is what keeps one control deciding what a `date` member looks\n * like.\n */\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n 'aria-invalid'?: boolean;\n 'aria-required'?: boolean;\n /**\n * The draft value as a string — the shape a native input round-trips. A form\n * holds its whole draft as `Record<string, string>` and reconstructs typed\n * values only at submit, so the control never sees a domain value.\n */\n value: string;\n onChange: (value: string) => void;\n id?: string;\n /**\n * The record being edited, as its draft. A money member whose currency is\n * another member (`money.currencyMember`) reads it from here.\n */\n record?: Readonly<Record<string, unknown>>;\n}\n\n/** Native input type for the text-like controls; text is the default. */\nconst INPUT_TYPE: Partial<Record<MetaAccessorType, string>> = {\n number: 'number',\n date: 'date',\n};\n\n/**\n * The edit-mode inverse of {@link CellValue}: it turns one metadata descriptor\n * into the input that edits it. Centralizing the type→control choice is what\n * lets a form stay generic, the same way `CellValue` keeps a table generic.\n *\n * A relation (`link`/`linkCollection`) is rendered read-only here, deliberately:\n * editing one needs a picker that can search and page the target, which is a\n * different control with different dependencies. So this atom stays a pure\n * type→input map and a relation never falls back to a broken text box.\n *\n * For a to-one `link` that is only half the story — `EntityForm` wires the\n * picker in one level up from its `linkSources`, so the member does get an\n * editor, just not from here. A `linkCollection` has no editor anywhere yet\n * (#26), and read-only is all it gets. A `composition` is the same: its rows\n * need a detail grid, and a text box holding `[object Object]` would be\n * strictly worse than an honest disabled field.\n *\n * A `scalarCollection` is the exception among the collections and falls through\n * to the plain text input on purpose: a `string[]` has a lossless comma form,\n * so the draft it round-trips through *is* editable text. Splitting on the\n * comma is `reconstructEntity`'s half of that same contract.\n */\nexport function FieldControl({\n descriptor,\n value,\n onChange,\n id,\n record,\n ...aria\n}: FieldControlProps) {\n const enumLabel = useEnumLabel();\n const locale = useLocale();\n const disabled =\n descriptor.readonly ||\n descriptor.type === 'link' ||\n descriptor.type === 'linkCollection' ||\n descriptor.type === 'composition';\n\n if (descriptor.type === 'boolean') {\n return (\n <Checkbox\n id={id}\n {...aria}\n label={descriptor.label}\n checked={value === 'true'}\n disabled={disabled}\n onChange={event => onChange(String(event.currentTarget.checked))}\n />\n );\n }\n\n if (descriptor.type === 'enum') {\n return (\n <Select\n id={id}\n {...aria}\n value={value}\n disabled={disabled}\n onChange={event => onChange(event.currentTarget.value)}\n >\n <option value=\"\">—</option>\n {(descriptor.enumValues ?? []).map(option => (\n <option key={option} value={option}>\n {enumLabel(descriptor, option)}\n </option>\n ))}\n </Select>\n );\n }\n\n // An amount is edited in major units, in the reader's decimal separator,\n // and written back in the unit it is stored in. Without a currency to know\n // the minor units by, it stays a plain number field.\n const currency =\n descriptor.money === undefined\n ? undefined\n : currencyOf(descriptor.money, record);\n if (descriptor.money !== undefined && currency !== undefined) {\n return (\n <MoneyInput\n id={id}\n {...aria}\n value={value}\n currency={currency}\n unit={descriptor.money.unit}\n locale={locale}\n disabled={disabled}\n onChange={onChange}\n />\n );\n }\n\n return (\n <TextInput\n id={id}\n {...aria}\n // What the field is for, so a browser can fill it (WCAG 1.3.5).\n autoComplete={descriptor.autocomplete}\n type={INPUT_TYPE[descriptor.type] ?? 'text'}\n value={value}\n disabled={disabled}\n onChange={event => onChange(event.currentTarget.value)}\n />\n );\n}\n"],"names":["useEnumLabel","useLocale","Checkbox","Select","TextInput","MoneyInput","currencyOf","INPUT_TYPE","number","date","FieldControl","descriptor","value","onChange","id","record","aria","enumLabel","locale","disabled","readonly","type","label","checked","event","String","currentTarget","option","enumValues","map","currency","money","undefined","unit","autoComplete","autocomplete"],"mappings":"AAAA;;;;AAIA,SAASA,YAAY,EAAEC,SAAS,QAAQ,yBAAyB;AACjE,SAASC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,QAAQ,oBAAoB;AAChE,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,UAAU,QAAQ,yBAAyB;AAkCpD,uEAAuE,GACvE,MAAMC,aAAwD;IAC5DC,QAAQ;IACRC,MAAM;AACR;AAEA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,aAAa,EAOT;QAPS,EAC3BC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACRC,EAAE,EACFC,MAAM,EAEY,OADfC;;;;;;;QAsEOT;IApEV,MAAMU,YAAYjB;IAClB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QACPO,UAAUA;QACVN,UAAUW,CAAAA,QAASX,SAASW,MAAME,aAAa,CAACd,KAAK;;AAG3D"}
1
+ {"version":3,"sources":["../../../../src/ui/atoms/field-control/field-control.tsx"],"sourcesContent":["'use client';\n\nimport type { EntityFieldDescriptor, MetaAccessorType } from '@entifix/core';\n\nimport { useEnumLabel, useLocale } from '../../../i18n/index.js';\nimport { Checkbox, Select, TextInput } from '../field/index.js';\nimport { MoneyInput } from '../money/money-input.js';\nimport { currencyOf } from '../money/money-math.js';\nimport { ScaledInput } from '../scaled/scaled-input.js';\nimport { scaleOf } from '../scaled/scaled-math.js';\nimport { useUnitLabel } from '../scaled/use-unit-label.js';\n\nexport interface FieldControlProps {\n descriptor: EntityFieldDescriptor;\n /**\n * ARIA wiring the caller owns, because only the caller knows the shape it is\n * rendered into.\n *\n * A form labels its control with a `<label for>` and needs none of this; a\n * detail grid's cell has no label of its own — the column header is the\n * label, and the cell's message is the description — so it points at both by\n * id. Passing them through here rather than duplicating the type→input map\n * in the grid is what keeps one control deciding what a `date` member looks\n * like.\n */\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n 'aria-invalid'?: boolean;\n 'aria-required'?: boolean;\n /**\n * The draft value as a string — the shape a native input round-trips. A form\n * holds its whole draft as `Record<string, string>` and reconstructs typed\n * values only at submit, so the control never sees a domain value.\n */\n value: string;\n onChange: (value: string) => void;\n id?: string;\n /**\n * The record being edited, as its draft. A money member whose currency is\n * another member (`money.currencyMember`), and a scaled one whose unit is\n * (`scaled.unitMember`), read it from here.\n */\n record?: Readonly<Record<string, unknown>>;\n}\n\n/** Native input type for the text-like controls; text is the default. */\nconst INPUT_TYPE: Partial<Record<MetaAccessorType, string>> = {\n number: 'number',\n date: 'date',\n};\n\n/**\n * The edit-mode inverse of {@link CellValue}: it turns one metadata descriptor\n * into the input that edits it. Centralizing the type→control choice is what\n * lets a form stay generic, the same way `CellValue` keeps a table generic.\n *\n * A relation (`link`/`linkCollection`) is rendered read-only here, deliberately:\n * editing one needs a picker that can search and page the target, which is a\n * different control with different dependencies. So this atom stays a pure\n * type→input map and a relation never falls back to a broken text box.\n *\n * For a to-one `link` that is only half the story — `EntityForm` wires the\n * picker in one level up from its `linkSources`, so the member does get an\n * editor, just not from here. A `linkCollection` has no editor anywhere yet\n * (#26), and read-only is all it gets. A `composition` is the same: its rows\n * need a detail grid, and a text box holding `[object Object]` would be\n * strictly worse than an honest disabled field.\n *\n * A `scalarCollection` is the exception among the collections and falls through\n * to the plain text input on purpose: a `string[]` has a lossless comma form,\n * so the draft it round-trips through *is* editable text. Splitting on the\n * comma is `reconstructEntity`'s half of that same contract.\n */\nexport function FieldControl({\n descriptor,\n value,\n onChange,\n id,\n record,\n ...aria\n}: FieldControlProps) {\n const enumLabel = useEnumLabel();\n const locale = useLocale();\n const unitLabel = useUnitLabel();\n const disabled =\n descriptor.readonly ||\n descriptor.type === 'link' ||\n descriptor.type === 'linkCollection' ||\n descriptor.type === 'composition';\n\n if (descriptor.type === 'boolean') {\n return (\n <Checkbox\n id={id}\n {...aria}\n label={descriptor.label}\n checked={value === 'true'}\n disabled={disabled}\n onChange={event => onChange(String(event.currentTarget.checked))}\n />\n );\n }\n\n if (descriptor.type === 'enum') {\n return (\n <Select\n id={id}\n {...aria}\n value={value}\n disabled={disabled}\n onChange={event => onChange(event.currentTarget.value)}\n >\n <option value=\"\">—</option>\n {(descriptor.enumValues ?? []).map(option => (\n <option key={option} value={option}>\n {enumLabel(descriptor, option)}\n </option>\n ))}\n </Select>\n );\n }\n\n // An amount is edited in major units, in the reader's decimal separator,\n // and written back in the unit it is stored in. Without a currency to know\n // the minor units by, it stays a plain number field.\n const currency =\n descriptor.money === undefined\n ? undefined\n : currencyOf(descriptor.money, record);\n if (descriptor.money !== undefined && currency !== undefined) {\n return (\n <MoneyInput\n id={id}\n {...aria}\n value={value}\n currency={currency}\n unit={descriptor.money.unit}\n locale={locale}\n disabled={disabled}\n onChange={onChange}\n />\n );\n }\n\n // A scaled integer is edited as the decimal it stands for. Unlike money it\n // has no plain fallback: without a scale, `3` typed would be stored as 0.003.\n if (descriptor.scaled !== undefined) {\n const resolved = scaleOf(descriptor.scaled, record);\n return (\n <ScaledInput\n id={id}\n {...aria}\n value={value}\n scale={resolved?.scale}\n unit={unitLabel(descriptor.scaled, resolved?.unit)}\n locale={locale}\n disabled={disabled}\n onChange={onChange}\n />\n );\n }\n\n return (\n <TextInput\n id={id}\n {...aria}\n // What the field is for, so a browser can fill it (WCAG 1.3.5).\n autoComplete={descriptor.autocomplete}\n type={INPUT_TYPE[descriptor.type] ?? 'text'}\n value={value}\n disabled={disabled}\n onChange={event => onChange(event.currentTarget.value)}\n />\n );\n}\n"],"names":["useEnumLabel","useLocale","Checkbox","Select","TextInput","MoneyInput","currencyOf","ScaledInput","scaleOf","useUnitLabel","INPUT_TYPE","number","date","FieldControl","descriptor","value","onChange","id","record","aria","enumLabel","locale","unitLabel","disabled","readonly","type","label","checked","event","String","currentTarget","option","enumValues","map","currency","money","undefined","unit","scaled","resolved","scale","autoComplete","autocomplete"],"mappings":"AAAA;;;;AAIA,SAASA,YAAY,EAAEC,SAAS,QAAQ,yBAAyB;AACjE,SAASC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,QAAQ,oBAAoB;AAChE,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,OAAO,QAAQ,2BAA2B;AACnD,SAASC,YAAY,QAAQ,8BAA8B;AAmC3D,uEAAuE,GACvE,MAAMC,aAAwD;IAC5DC,QAAQ;IACRC,MAAM;AACR;AAEA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,aAAa,EAOT;QAPS,EAC3BC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACRC,EAAE,EACFC,MAAM,EAEY,OADfC;;;;;;;QAyFOT;IAvFV,MAAMU,YAAYpB;IAClB,MAAMqB,SAASpB;IACf,MAA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,OAAOA;YACPyB,KAAK,EAAED,4BAAAA,SAAUC,KAAK;YACtBH,MAAMf,UAAUR,WAAWwB,MAAM,EAAEC,4BAAAA,SAAUF,IAAI;YACjDhB,QAAQA;YACRE,UAAUA;YACVP,UAAUA;;IAGhB;IAEA,qBACE,KAACZ;QACCa,IAAIA;OACAE;QACJ,gEAAgE;QAChEsB,cAAc3B,WAAW4B,YAAY;QACrCjB,IAAI,GAAEf,8BAAAA,UAAU,CAACI,WAAWW,IAAI,CAAC,YAA3Bf,8BAA+B;QACrCK,OAAOA;QACPQ,UAAUA;QACVP,UAAUY,CAAAA,QAASZ,SAASY,MAAME,aAAa,CAACf,KAAK;;AAG3D"}
@@ -14,6 +14,11 @@ export interface MoneyInputProps extends Omit<NumberInputProps, 'value' | 'onCha
14
14
  * back the stored unit. What was typed is kept as typed (a trailing `64,` is
15
15
  * not reformatted under the cursor), and the field follows the stored value
16
16
  * only when it changes from outside.
17
+ *
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`).
17
22
  */
18
23
  export declare function MoneyInput({ value, onChange, currency, unit, locale, ...props }: MoneyInputProps): import("react").JSX.Element;
19
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":"AAIA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAEzB,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;AAkBD;;;;;GAKG;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,23 +2,21 @@
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 { formattingLocale, parseScaled, scaledToDecimal } from '@entifix/core';
5
6
  import { useEffect, useState } from 'react';
6
7
  import { NumberInput } from '../number-input/number-input.js';
7
- import { fractionDigits, fromMajorUnits, toMajorUnits } from './money-math.js';
8
- const parseMajor = (text)=>{
9
- // Accept either decimal separator: the last `,` or `.` is the decimal one.
10
- const normalised = text.trim().replace(/[\s']/g, '');
11
- if (normalised === '') return undefined;
12
- const last = Math.max(normalised.lastIndexOf(','), normalised.lastIndexOf('.'));
13
- const plain = last === -1 ? normalised : `${normalised.slice(0, last).replace(/[.,]/g, '')}.${normalised.slice(last + 1)}`;
14
- const major = Number(plain);
15
- return Number.isFinite(major) ? major : undefined;
16
- };
8
+ import { typedText, unparsedDraft } from '../number-input/unparsed.js';
9
+ import { fractionDigits, toMajorUnits } from './money-math.js';
17
10
  /**
18
11
  * Edits an amount in major units — what a person means by a price — and writes
19
12
  * back the stored unit. What was typed is kept as typed (a trailing `64,` is
20
13
  * not reformatted under the cursor), and the field follows the stored value
21
14
  * only when it changes from outside.
15
+ *
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`).
22
20
  */ export function MoneyInput(_0) {
23
21
  let { value, onChange, currency, unit, locale } = _0, props = _object_without_properties_loose(_0, [
24
22
  "value",
@@ -28,7 +26,7 @@ const parseMajor = (text)=>{
28
26
  "locale"
29
27
  ]);
30
28
  const digits = fractionDigits(currency);
31
- const display = (stored)=>stored === '' || !Number.isFinite(Number(stored)) ? stored : new Intl.NumberFormat(locale, {
29
+ const display = (stored)=>stored === '' || !Number.isFinite(Number(stored)) ? typedText(stored) : new Intl.NumberFormat(formattingLocale(locale), {
32
30
  minimumFractionDigits: digits,
33
31
  maximumFractionDigits: digits,
34
32
  useGrouping: false
@@ -57,8 +55,8 @@ const parseMajor = (text)=>{
57
55
  onChange: (event)=>{
58
56
  const next = event.currentTarget.value;
59
57
  setText(next);
60
- const major = parseMajor(next);
61
- const stored = major === undefined ? next.trim() === '' ? '' : next : String(fromMajorUnits(major, currency, unit));
58
+ const minor = parseScaled(next, digits, locale);
59
+ const stored = minor === undefined ? unparsedDraft(next) : unit === 'minor' ? String(minor) : scaledToDecimal(minor, digits);
62
60
  setEmitted(stored);
63
61
  onChange(stored);
64
62
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/atoms/money/money-input.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\nimport {\n NumberInput,\n type NumberInputProps,\n} from '../number-input/number-input.js';\nimport {\n fractionDigits,\n fromMajorUnits,\n type MoneyUnit,\n toMajorUnits,\n} 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\nconst parseMajor = (text: string): number | undefined => {\n // Accept either decimal separator: the last `,` or `.` is the decimal one.\n const normalised = text.trim().replace(/[\\s']/g, '');\n if (normalised === '') return undefined;\n const last = Math.max(\n normalised.lastIndexOf(','),\n normalised.lastIndexOf('.'),\n );\n const plain =\n last === -1\n ? normalised\n : `${normalised.slice(0, last).replace(/[.,]/g, '')}.${normalised.slice(last + 1)}`;\n const major = Number(plain);\n return Number.isFinite(major) ? major : undefined;\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 */\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 ? 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 major = parseMajor(next);\n const stored =\n major === undefined\n ? next.trim() === ''\n ? ''\n : next\n : String(fromMajorUnits(major, currency, unit));\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":["useEffect","useState","NumberInput","fractionDigits","fromMajorUnits","toMajorUnits","parseMajor","text","normalised","trim","replace","undefined","last","Math","max","lastIndexOf","plain","slice","major","Number","isFinite","MoneyInput","value","onChange","currency","unit","locale","props","digits","display","stored","Intl","NumberFormat","minimumFractionDigits","maximumFractionDigits","useGrouping","format","setText","emitted","setEmitted","span","className","inputMode","event","next","currentTarget","String","aria-hidden"],"mappings":"AAAA;;;;AAEA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAE5C,SACEC,WAAW,QAEN,kCAAkC;AACzC,SACEC,cAAc,EACdC,cAAc,EAEdC,YAAY,QACP,kBAAkB;AAezB,MAAMC,aAAa,CAACC;IAClB,2EAA2E;IAC3E,MAAMC,aAAaD,KAAKE,IAAI,GAAGC,OAAO,CAAC,UAAU;IACjD,IAAIF,eAAe,IAAI,OAAOG;IAC9B,MAAMC,OAAOC,KAAKC,GAAG,CACnBN,WAAWO,WAAW,CAAC,MACvBP,WAAWO,WAAW,CAAC;IAEzB,MAAMC,QACJJ,SAAS,CAAC,IACNJ,aACA,GAAGA,WAAWS,KAAK,CAAC,GAAGL,MAAMF,OAAO,CAAC,SAAS,IAAI,CAAC,EA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../../../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,GAAG,MAAM,CASvD;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,SAAS,GACd,MAAM,CAER;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,SAAS,GACd,MAAM,CAKR;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,MAAM,GACb,MAAM,CAIR;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
+ {"version":3,"file":"money-math.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/money/money-math.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEnE,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASvD;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,SAAS,GACd,MAAM,CAER;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,SAAS,GACd,MAAM,CAKR;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,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"}
@@ -4,6 +4,20 @@ interface QuantityInputBase {
4
4
  min?: number;
5
5
  max?: number;
6
6
  step?: number;
7
+ /**
8
+ * How many decimals a stored unit is: `3` reads `3500` as 3.5. Given, every
9
+ * number in these props is that stored integer and a typed entry is never
10
+ * clamped or rounded — one outside `min`, `max` or `step` is marked invalid
11
+ * and still reported, and text that is no number is reported as `NaN`.
12
+ * `0` is whole units under those same rules.
13
+ */
14
+ scale?: number;
15
+ /** With `scale`: the unit, as the reader names it. */
16
+ unit?: string;
17
+ /** With `scale`: the caller's own refusal, beside the field's. */
18
+ invalid?: boolean;
19
+ /** With `scale`: what describes the field, usually the refusal's message. */
20
+ 'aria-describedby'?: string;
7
21
  disabled?: boolean;
8
22
  id?: string;
9
23
  /**
@@ -34,9 +48,10 @@ export interface UncontrolledQuantityInputProps extends QuantityInputBase {
34
48
  }
35
49
  export type QuantityInputProps = ControlledQuantityInputProps | UncontrolledQuantityInputProps;
36
50
  /**
37
- * A count, on the WAI-ARIA spinbutton pattern: Up and Down step it, Home and
38
- * End jump to its bounds, and what is typed is committed on Enter or on
39
- * leaving the field, clamped to the bounds. The − and + beside it are named
51
+ * A count — or, given a `scale`, a measure: see that prop — on the WAI-ARIA
52
+ * spinbutton pattern: Up and Down step it, Home and End jump to its bounds,
53
+ * and a count typed is committed on Enter or on leaving the field, clamped
54
+ * to the bounds. The − and + beside it are named
40
55
  * "Decrease {label}" and "Increase {label}" and sit at `--target-min`; they are
41
56
  * out of the Tab order, as the pattern has them, because the arrow keys
42
57
  * already do what they do.
@@ -45,6 +60,6 @@ export type QuantityInputProps = ControlledQuantityInputProps | UncontrolledQuan
45
60
  * — the second is how a Server Action form uses it, since a server component
46
61
  * can pass neither a state nor a handler.
47
62
  */
48
- export declare function QuantityInput({ label, value: controlled, defaultValue, onChange, min, max, step, disabled, id, name, className, }: QuantityInputProps): import("react").JSX.Element;
63
+ export declare function QuantityInput(props: QuantityInputProps): import("react").JSX.Element;
49
64
  export {};
50
65
  //# sourceMappingURL=quantity-input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quantity-input.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/number-input/quantity-input.tsx"],"names":[],"mappings":"AAOA,UAAU,iBAAiB;IACzB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uFAAuF;AACvF,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,8BAA+B,SAAQ,iBAAiB;IACvE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,MAAM,kBAAkB,GAC5B,4BAA4B,GAAG,8BAA8B,CAAC;AAKhE;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EAAE,UAAU,EACjB,YAAY,EACZ,QAAQ,EACR,GAAO,EACP,GAAG,EACH,IAAQ,EACR,QAAgB,EAChB,EAAE,EACF,IAAI,EACJ,SAAS,GACV,EAAE,kBAAkB,+BAkFpB"}
1
+ {"version":3,"file":"quantity-input.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/number-input/quantity-input.tsx"],"names":[],"mappings":"AASA,UAAU,iBAAiB;IACzB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uFAAuF;AACvF,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,8BAA+B,SAAQ,iBAAiB;IACvE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,MAAM,kBAAkB,GAC5B,4BAA4B,GAAG,8BAA8B,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAMtD"}
@@ -1,13 +1,16 @@
1
1
  'use client';
2
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
4
  import { useEffect, useState } from 'react';
4
5
  import { useT } from '../../../i18n/index.js';
5
6
  import { cn } from '../../utils/cn.js';
6
- const STEP_BUTTON = 'flex min-h-(--target-min) min-w-(--target-min) shrink-0 items-center justify-center rounded-md border border-border-control bg-surface-elevated text-content hover:bg-surface disabled:cursor-not-allowed disabled:opacity-50';
7
+ import { ScaledQuantityInput } from './scaled-quantity-input.js';
8
+ import { STEP_BUTTON } from './step-button.js';
7
9
  /**
8
- * A count, on the WAI-ARIA spinbutton pattern: Up and Down step it, Home and
9
- * End jump to its bounds, and what is typed is committed on Enter or on
10
- * leaving the field, clamped to the bounds. The − and + beside it are named
10
+ * A count — or, given a `scale`, a measure: see that prop — on the WAI-ARIA
11
+ * spinbutton pattern: Up and Down step it, Home and End jump to its bounds,
12
+ * and a count typed is committed on Enter or on leaving the field, clamped
13
+ * to the bounds. The − and + beside it are named
11
14
  * "Decrease {label}" and "Increase {label}" and sit at `--target-min`; they are
12
15
  * out of the Tab order, as the pattern has them, because the arrow keys
13
16
  * already do what they do.
@@ -15,7 +18,12 @@ const STEP_BUTTON = 'flex min-h-(--target-min) min-w-(--target-min) shrink-0 ite
15
18
  * Controlled with `value` and `onChange`, or uncontrolled with `defaultValue`
16
19
  * — the second is how a Server Action form uses it, since a server component
17
20
  * can pass neither a state nor a handler.
18
- */ export function QuantityInput({ label, value: controlled, defaultValue, onChange, min = 0, max, step = 1, disabled = false, id, name, className }) {
21
+ */ export function QuantityInput(props) {
22
+ return props.scale === undefined ? /*#__PURE__*/ _jsx(CountInput, _extends({}, props)) : /*#__PURE__*/ _jsx(ScaledQuantityInput, _extends({}, props, {
23
+ scale: props.scale
24
+ }));
25
+ }
26
+ /** The count: what is typed is committed clamped to the bounds. */ function CountInput({ label, value: controlled, defaultValue, onChange, min = 0, max, step = 1, disabled = false, id, name, className }) {
19
27
  const t = useT();
20
28
  const [own, setOwn] = useState(defaultValue != null ? defaultValue : min);
21
29
  const value = controlled != null ? controlled : own;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/atoms/number-input/quantity-input.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyboardEvent, useEffect, useState } from 'react';\n\nimport { useT } from '../../../i18n/index.js';\nimport { cn } from '../../utils/cn.js';\n\ninterface QuantityInputBase {\n /** What is being counted; names the spinbutton and both of its buttons. */\n label: string;\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n id?: string;\n /**\n * Posts the count with the form it sits in, under this name — a server\n * action's form works without JavaScript, where the field is the only part\n * a reader can change, so the field itself carries it. The server clamps\n * what it receives: a typed value is only clamped here once committed.\n */\n name?: string;\n className?: string;\n}\n\n/** The caller owns the count: every committed change comes back through `onChange`. */\nexport interface ControlledQuantityInputProps extends QuantityInputBase {\n value: number;\n onChange: (value: number) => void;\n defaultValue?: never;\n}\n\n/**\n * The field owns the count, starting at `defaultValue` (or `min`). This is the\n * shape a server-rendered form takes: a server component cannot hand a client\n * one a function, and with `name` the count posts with the form, so the page\n * needs no client parent of its own. `onChange` still reports each commit.\n */\nexport interface UncontrolledQuantityInputProps extends QuantityInputBase {\n value?: never;\n defaultValue?: number;\n onChange?: (value: number) => void;\n}\n\nexport type QuantityInputProps =\n ControlledQuantityInputProps | UncontrolledQuantityInputProps;\n\nconst STEP_BUTTON =\n 'flex min-h-(--target-min) min-w-(--target-min) shrink-0 items-center justify-center rounded-md border border-border-control bg-surface-elevated text-content hover:bg-surface disabled:cursor-not-allowed disabled:opacity-50';\n\n/**\n * A count, on the WAI-ARIA spinbutton pattern: Up and Down step it, Home and\n * End jump to its bounds, and what is typed is committed on Enter or on\n * leaving the field, clamped to the bounds. The − and + beside it are named\n * \"Decrease {label}\" and \"Increase {label}\" and sit at `--target-min`; they are\n * out of the Tab order, as the pattern has them, because the arrow keys\n * already do what they do.\n *\n * Controlled with `value` and `onChange`, or uncontrolled with `defaultValue`\n * — the second is how a Server Action form uses it, since a server component\n * can pass neither a state nor a handler.\n */\nexport function QuantityInput({\n label,\n value: controlled,\n defaultValue,\n onChange,\n min = 0,\n max,\n step = 1,\n disabled = false,\n id,\n name,\n className,\n}: QuantityInputProps) {\n const t = useT();\n const [own, setOwn] = useState(defaultValue ?? min);\n const value = controlled ?? own;\n const [text, setText] = useState(String(value));\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- the value moved from outside (a step, a reset)\n setText(String(value));\n }, [value]);\n\n const clamp = (next: number) =>\n Math.min(max ?? Number.POSITIVE_INFINITY, Math.max(min, next));\n const set = (next: number) => {\n const clamped = clamp(next);\n setText(String(clamped));\n if (clamped === value) return;\n setOwn(clamped);\n onChange?.(clamped);\n };\n const commit = () => {\n const typed = Number.parseInt(text, 10);\n set(Number.isNaN(typed) ? value : typed);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n const next = {\n ArrowUp: value + step,\n ArrowDown: value - step,\n Home: min,\n End: max,\n }[event.key];\n if (event.key === 'Enter') {\n commit();\n return;\n }\n if (next === undefined) return;\n event.preventDefault();\n set(next);\n };\n\n return (\n <span className={cn('inline-flex items-center gap-3xs', className)}>\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={t('quantity.decrease', { label })}\n disabled={disabled || value <= min}\n onClick={() => set(value - step)}\n className={STEP_BUTTON}\n >\n <span aria-hidden=\"true\">−</span>\n </button>\n <input\n id={id}\n name={name}\n type=\"text\"\n role=\"spinbutton\"\n inputMode=\"numeric\"\n aria-label={label}\n aria-valuenow={value}\n aria-valuemin={min}\n aria-valuemax={max}\n disabled={disabled}\n value={text}\n onChange={event => setText(event.currentTarget.value)}\n onBlur={commit}\n onKeyDown={onKeyDown}\n className=\"w-16 min-h-(--target-min) rounded-lg border border-border-control bg-surface-elevated px-2xs py-3xs text-center text-step-sm text-content tabular-nums focus-ring disabled:cursor-not-allowed disabled:opacity-50\"\n />\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={t('quantity.increase', { label })}\n disabled={disabled || (max !== undefined && value >= max)}\n onClick={() => set(value + step)}\n className={STEP_BUTTON}\n >\n <span aria-hidden=\"true\">+</span>\n </button>\n </span>\n );\n}\n"],"names":["useEffect","useState","useT","cn","STEP_BUTTON","QuantityInput","label","value","controlled","defaultValue","onChange","min","max","step","disabled","id","name","className","t","own","setOwn","text","setText","String","clamp","next","Math","Number","POSITIVE_INFINITY","set","clamped","commit","typed","parseInt","isNaN","onKeyDown","event","ArrowUp","ArrowDown","Home","End","key","undefined","preventDefault","span","button","type","tabIndex","aria-label","onClick","aria-hidden","input","role","inputMode","aria-valuenow","aria-valuemin","aria-valuemax","currentTarget","onBlur"],"mappings":"AAAA;;AAEA,SAA6BA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEhE,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,EAAE,QAAQ,oBAAoB;AA0CvC,MAAMC,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AAU,CAAC;gBACXC,cAAY9B,EAAE,qBAAqB;oBAAEZ;gBAAM;gBAC3CQ,UAAUA,YAAYP,SAASI;gBAC/BsC,SAAS,IAAMpB,IAAItB,QAAQM;gBAC3BI,WAAWb;0BAEX,cAAA,KAACwC;oBAAKM,eAAY;8BAAO;;;0BAE3B,KAACC;gBACCpC,IAAIA;gBACJC,MAAMA;gBACN8B,MAAK;gBACLM,MAAK;gBACLC,WAAU;gBACVL,cAAY1C;gBACZgD,iBAAe/C;gBACfgD,iBAAe5C;gBACf6C,iBAAe5C;gBACfE,UAAUA;gBACVP,OAAOc;gBACPX,UAAU0B,CAAAA,QAASd,QAAQc,MAAMqB,aAAa,CAAClD,KAAK;gBACpDmD,QAAQ3B;gBACRI,WAAWA;gBACXlB,WAAU;;0BAEZ,KAAC4B;gBACCC,MAAK;gBACLC,UAAU,CAAC;gBACXC,cAAY9B,EAAE,qBAAqB;oBAAEZ;gBAAM;gBAC3CQ,UAAUA,YAAaF,QAAQ8B,aAAanC,SAASK;gBACrDqC,SAAS,IAAMpB,IAAItB,QAAQM;gBAC3BI,WAAWb;0BAEX,cAAA,KAACwC;oBAAKM,eAAY;8BAAO;;;;;AAIjC"}
1
+ {"version":3,"sources":["../../../../src/ui/atoms/number-input/quantity-input.tsx"],"sourcesContent":["'use client';\n\nimport { type KeyboardEvent, useEffect, useState } from 'react';\n\nimport { useT } from '../../../i18n/index.js';\nimport { cn } from '../../utils/cn.js';\nimport { ScaledQuantityInput } from './scaled-quantity-input.js';\nimport { STEP_BUTTON } from './step-button.js';\n\ninterface QuantityInputBase {\n /** What is being counted; names the spinbutton and both of its buttons. */\n label: string;\n min?: number;\n max?: number;\n step?: number;\n /**\n * How many decimals a stored unit is: `3` reads `3500` as 3.5. Given, every\n * number in these props is that stored integer and a typed entry is never\n * clamped or rounded — one outside `min`, `max` or `step` is marked invalid\n * and still reported, and text that is no number is reported as `NaN`.\n * `0` is whole units under those same rules.\n */\n scale?: number;\n /** With `scale`: the unit, as the reader names it. */\n unit?: string;\n /** With `scale`: the caller's own refusal, beside the field's. */\n invalid?: boolean;\n /** With `scale`: what describes the field, usually the refusal's message. */\n 'aria-describedby'?: string;\n disabled?: boolean;\n id?: string;\n /**\n * Posts the count with the form it sits in, under this name — a server\n * action's form works without JavaScript, where the field is the only part\n * a reader can change, so the field itself carries it. The server clamps\n * what it receives: a typed value is only clamped here once committed.\n */\n name?: string;\n className?: string;\n}\n\n/** The caller owns the count: every committed change comes back through `onChange`. */\nexport interface ControlledQuantityInputProps extends QuantityInputBase {\n value: number;\n onChange: (value: number) => void;\n defaultValue?: never;\n}\n\n/**\n * The field owns the count, starting at `defaultValue` (or `min`). This is the\n * shape a server-rendered form takes: a server component cannot hand a client\n * one a function, and with `name` the count posts with the form, so the page\n * needs no client parent of its own. `onChange` still reports each commit.\n */\nexport interface UncontrolledQuantityInputProps extends QuantityInputBase {\n value?: never;\n defaultValue?: number;\n onChange?: (value: number) => void;\n}\n\nexport type QuantityInputProps =\n ControlledQuantityInputProps | UncontrolledQuantityInputProps;\n\n/**\n * A count — or, given a `scale`, a measure: see that prop — on the WAI-ARIA\n * spinbutton pattern: Up and Down step it, Home and End jump to its bounds,\n * and a count typed is committed on Enter or on leaving the field, clamped\n * to the bounds. The − and + beside it are named\n * \"Decrease {label}\" and \"Increase {label}\" and sit at `--target-min`; they are\n * out of the Tab order, as the pattern has them, because the arrow keys\n * already do what they do.\n *\n * Controlled with `value` and `onChange`, or uncontrolled with `defaultValue`\n * — the second is how a Server Action form uses it, since a server component\n * can pass neither a state nor a handler.\n */\nexport function QuantityInput(props: QuantityInputProps) {\n return props.scale === undefined ? (\n <CountInput {...props} />\n ) : (\n <ScaledQuantityInput {...props} scale={props.scale} />\n );\n}\n\n/** The count: what is typed is committed clamped to the bounds. */\nfunction CountInput({\n label,\n value: controlled,\n defaultValue,\n onChange,\n min = 0,\n max,\n step = 1,\n disabled = false,\n id,\n name,\n className,\n}: QuantityInputProps) {\n const t = useT();\n const [own, setOwn] = useState(defaultValue ?? min);\n const value = controlled ?? own;\n const [text, setText] = useState(String(value));\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- the value moved from outside (a step, a reset)\n setText(String(value));\n }, [value]);\n\n const clamp = (next: number) =>\n Math.min(max ?? Number.POSITIVE_INFINITY, Math.max(min, next));\n const set = (next: number) => {\n const clamped = clamp(next);\n setText(String(clamped));\n if (clamped === value) return;\n setOwn(clamped);\n onChange?.(clamped);\n };\n const commit = () => {\n const typed = Number.parseInt(text, 10);\n set(Number.isNaN(typed) ? value : typed);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n const next = {\n ArrowUp: value + step,\n ArrowDown: value - step,\n Home: min,\n End: max,\n }[event.key];\n if (event.key === 'Enter') {\n commit();\n return;\n }\n if (next === undefined) return;\n event.preventDefault();\n set(next);\n };\n\n return (\n <span className={cn('inline-flex items-center gap-3xs', className)}>\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={t('quantity.decrease', { label })}\n disabled={disabled || value <= min}\n onClick={() => set(value - step)}\n className={STEP_BUTTON}\n >\n <span aria-hidden=\"true\">−</span>\n </button>\n <input\n id={id}\n name={name}\n type=\"text\"\n role=\"spinbutton\"\n inputMode=\"numeric\"\n aria-label={label}\n aria-valuenow={value}\n aria-valuemin={min}\n aria-valuemax={max}\n disabled={disabled}\n value={text}\n onChange={event => setText(event.currentTarget.value)}\n onBlur={commit}\n onKeyDown={onKeyDown}\n className=\"w-16 min-h-(--target-min) rounded-lg border border-border-control bg-surface-elevated px-2xs py-3xs text-center text-step-sm text-content tabular-nums focus-ring disabled:cursor-not-allowed disabled:opacity-50\"\n />\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={t('quantity.increase', { label })}\n disabled={disabled || (max !== undefined && value >= max)}\n onClick={() => set(value + step)}\n className={STEP_BUTTON}\n >\n <span aria-hidden=\"true\">+</span>\n </button>\n </span>\n );\n}\n"],"names":["useEffect","useState","useT","cn","ScaledQuantityInput","STEP_BUTTON","QuantityInput","props","scale","undefined","CountInput","label","value","controlled","defaultValue","onChange","min","max","step","disabled","id","name","className","t","own","setOwn","text","setText","String","clamp","next","Math","Number","POSITIVE_INFINITY","set","clamped","commit","typed","parseInt","isNaN","onKeyDown","event","ArrowUp","ArrowDown","Home","End","key","preventDefault","span","button","type","tabIndex","aria-label","onClick","aria-hidden","input","role","inputMode","aria-valuenow","aria-valuemin","aria-valuemax","currentTarget","onBlur"],"mappings":"AAAA;;;AAEA,SAA6BA,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAEhE,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,EAAE,QAAQ,oBAAoB;AACvC,SAASC,mBAAmB,QAAQ,6BAA6B;AACjE,SAASC,WAAW,QAAQ,mBAAmB;AAwD/C;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,cAAcC,KAAyB;IACrD,OAAOA,MAAMC,KAAK,KAAKC,0BACrB,KAACC,yBAAeH,wBAEhB,KAACH,kCAAwBG;QAAOC,OAAOD,MAAMC,KAAK;;AAEtD;AAEA,iEAAiE,GACjE,SAASE,WAAW,EAClBC,KAAK,EACLC,OAAOC,UAAU,EACjBC,YAAY,EACZC,QAAQ,EACRC,MAAM,CAAC,EACPC,GAAG,EACHC,OAAO,CAAC,EACRC,WAAW,KAAK,EAChBC,EAAE,EACFC,IAAI,EACJC,SAAS,EACU;IACnB,MAAMC,IAAIrB;IACV,MAAM,CAACsB,KAAKC,OAAO,GAAGxB,SAASa,uBAAAA,eAAgBE;IAC/C,MAAMJ,QAAQC,qBAAAA,aAAcW;IAC5B,MAAM,CAACE,MAAMC,QAAQ,GAAG1B,SAAS2B,OAAOhB;IAExCZ,UAAU;QACR,6GAA6G;QAC7G2B,QAAQC,OAAOhB;IACjB,GAAG;QAACA;KAAM;IAEV,MAAMiB,QAAQ,CAACC,OACbC,KAAKf,GAAG,CAACC,cAAAA,MAAOe,OAAOC,iBAAiB,EAAEF,KAAKd,GAAG,C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