@entifix/react-controls 0.20.3 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/i18n/catalog/en.d.ts.map +1 -1
  2. package/dist/i18n/catalog/en.js +7 -0
  3. package/dist/i18n/catalog/en.js.map +1 -1
  4. package/dist/i18n/catalog/es.d.ts +7 -0
  5. package/dist/i18n/catalog/es.d.ts.map +1 -1
  6. package/dist/i18n/catalog/es.js +7 -0
  7. package/dist/i18n/catalog/es.js.map +1 -1
  8. package/dist/i18n/catalog/index.d.ts +14 -0
  9. package/dist/i18n/catalog/index.d.ts.map +1 -1
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +3 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/primitives.d.ts +2 -0
  15. package/dist/primitives.d.ts.map +1 -1
  16. package/dist/primitives.js +2 -0
  17. package/dist/primitives.js.map +1 -1
  18. package/dist/ui/atoms/cell-value/cell-value.d.ts +6 -0
  19. package/dist/ui/atoms/cell-value/cell-value.d.ts.map +1 -1
  20. package/dist/ui/atoms/cell-value/cell-value.js +108 -14
  21. package/dist/ui/atoms/cell-value/cell-value.js.map +1 -1
  22. package/dist/ui/atoms/cell-value/index.d.ts +1 -0
  23. package/dist/ui/atoms/cell-value/index.d.ts.map +1 -1
  24. package/dist/ui/atoms/cell-value/index.js +1 -0
  25. package/dist/ui/atoms/cell-value/index.js.map +1 -1
  26. package/dist/ui/atoms/cell-value/use-record-label.d.ts +16 -0
  27. package/dist/ui/atoms/cell-value/use-record-label.d.ts.map +1 -0
  28. package/dist/ui/atoms/cell-value/use-record-label.js +55 -0
  29. package/dist/ui/atoms/cell-value/use-record-label.js.map +1 -0
  30. package/dist/ui/atoms/media-image/index.d.ts +2 -0
  31. package/dist/ui/atoms/media-image/index.d.ts.map +1 -0
  32. package/dist/ui/atoms/media-image/index.js +3 -0
  33. package/dist/ui/atoms/media-image/index.js.map +1 -0
  34. package/dist/ui/atoms/media-image/media-image.d.ts +46 -0
  35. package/dist/ui/atoms/media-image/media-image.d.ts.map +1 -0
  36. package/dist/ui/atoms/media-image/media-image.js +57 -0
  37. package/dist/ui/atoms/media-image/media-image.js.map +1 -0
  38. package/dist/ui/atoms/status-tag/status-tag.d.ts +6 -2
  39. package/dist/ui/atoms/status-tag/status-tag.d.ts.map +1 -1
  40. package/dist/ui/atoms/status-tag/status-tag.js.map +1 -1
  41. package/dist/ui/atoms/table/table.d.ts +4 -2
  42. package/dist/ui/atoms/table/table.d.ts.map +1 -1
  43. package/dist/ui/atoms/table/table.js +3 -1
  44. package/dist/ui/atoms/table/table.js.map +1 -1
  45. package/dist/ui/molecules/media-gallery/media-gallery.d.ts +30 -3
  46. package/dist/ui/molecules/media-gallery/media-gallery.d.ts.map +1 -1
  47. package/dist/ui/molecules/media-gallery/media-gallery.js +26 -6
  48. package/dist/ui/molecules/media-gallery/media-gallery.js.map +1 -1
  49. package/dist/ui/molecules/summary-tile/index.d.ts +2 -0
  50. package/dist/ui/molecules/summary-tile/index.d.ts.map +1 -0
  51. package/dist/ui/molecules/summary-tile/index.js +3 -0
  52. package/dist/ui/molecules/summary-tile/index.js.map +1 -0
  53. package/dist/ui/molecules/summary-tile/summary-tile.d.ts +57 -0
  54. package/dist/ui/molecules/summary-tile/summary-tile.d.ts.map +1 -0
  55. package/dist/ui/molecules/summary-tile/summary-tile.js +114 -0
  56. package/dist/ui/molecules/summary-tile/summary-tile.js.map +1 -0
  57. package/dist/ui/organisms/entity-form/entity-form.d.ts +1 -1
  58. package/dist/ui/organisms/entity-form/entity-form.d.ts.map +1 -1
  59. package/dist/ui/organisms/entity-form/entity-form.js +7 -6
  60. package/dist/ui/organisms/entity-form/entity-form.js.map +1 -1
  61. package/dist/ui/organisms/entity-form/entity-form.types.d.ts +0 -8
  62. package/dist/ui/organisms/entity-form/entity-form.types.d.ts.map +1 -1
  63. package/dist/ui/organisms/entity-form/entity-form.types.js.map +1 -1
  64. package/dist/ui/organisms/entity-table/card-roles.d.ts +10 -0
  65. package/dist/ui/organisms/entity-table/card-roles.d.ts.map +1 -0
  66. package/dist/ui/organisms/entity-table/card-roles.js +14 -0
  67. package/dist/ui/organisms/entity-table/card-roles.js.map +1 -0
  68. package/dist/ui/organisms/entity-table/entity-table-slots.d.ts +2 -0
  69. package/dist/ui/organisms/entity-table/entity-table-slots.d.ts.map +1 -1
  70. package/dist/ui/organisms/entity-table/entity-table-slots.js.map +1 -1
  71. package/dist/ui/organisms/entity-table/entity-table.d.ts.map +1 -1
  72. package/dist/ui/organisms/entity-table/entity-table.js +217 -173
  73. package/dist/ui/organisms/entity-table/entity-table.js.map +1 -1
  74. package/dist/ui/organisms/entity-table/pivot.d.ts +32 -5
  75. package/dist/ui/organisms/entity-table/pivot.d.ts.map +1 -1
  76. package/dist/ui/organisms/entity-table/pivot.js +42 -9
  77. package/dist/ui/organisms/entity-table/pivot.js.map +1 -1
  78. package/dist/ui/organisms/entity-table/use-entity-table-columns.d.ts.map +1 -1
  79. package/dist/ui/organisms/entity-table/use-entity-table-columns.js +6 -3
  80. package/dist/ui/organisms/entity-table/use-entity-table-columns.js.map +1 -1
  81. package/dist/ui/utils/reference-labels.d.ts +59 -0
  82. package/dist/ui/utils/reference-labels.d.ts.map +1 -0
  83. package/dist/ui/utils/reference-labels.js +49 -0
  84. package/dist/ui/utils/reference-labels.js.map +1 -0
  85. package/package.json +5 -5
@@ -1,10 +1,13 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { defaultLocale, EntityCollectionLink, EntityLink, isLocalizedText, localize } from '@entifix/core';
4
+ import { useCallback } from 'react';
4
5
  import { useEnumLabel, useFormatters, useLocale, useT } from '../../../i18n/index.js';
6
+ import { useReferenceLabel, useUnresolvedReference } from '../../utils/reference-labels.js';
5
7
  import { Money } from '../money/money.js';
6
8
  import { currencyOf } from '../money/money-math.js';
7
9
  import { Skeleton } from '../skeleton/index.js';
10
+ import { StatusTag } from '../status-tag/index.js';
8
11
  /** Stand-in for an absent value, so an empty cell still reads as intentional. */ const EMPTY = '—';
9
12
  /**
10
13
  * A link reads as its target's label once the target is loaded (embedded or
@@ -60,6 +63,91 @@ function formatByType(value, type, linkLabelProperty, formatting) {
60
63
  return String(value);
61
64
  }
62
65
  }
66
+ /** The formatting {@link formatByType} reads, resolved for the reader. */ function useCellFormatting() {
67
+ const t = useT();
68
+ const formatters = useFormatters();
69
+ const enumLabel = useEnumLabel();
70
+ const locale = useLocale();
71
+ return useCallback((descriptor)=>({
72
+ formatters,
73
+ yes: t('value.yes'),
74
+ no: t('value.no'),
75
+ enumLabel: (raw)=>enumLabel(descriptor, raw),
76
+ rowCount: (count)=>t('value.rowCount', {
77
+ count
78
+ }),
79
+ locale
80
+ }), [
81
+ enumLabel,
82
+ formatters,
83
+ locale,
84
+ t
85
+ ]);
86
+ }
87
+ /**
88
+ * A filled-in member's value as one line of text, exactly as its cell reads
89
+ * it — for the places that need words rather than an element: a checkbox's
90
+ * name, a confirm dialog's object, a toast.
91
+ */ export function useValueText() {
92
+ const formatting = useCellFormatting();
93
+ return useCallback((value, descriptor)=>formatByType(value, descriptor.type, descriptor.linkLabelProperty, formatting(descriptor)), [
94
+ formatting
95
+ ]);
96
+ }
97
+ /**
98
+ * A reference reads as its target's name, in every state the read can be in
99
+ * ([ADR 0030](../../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)):
100
+ * a skeleton while it resolves (the noun and short id for a screen reader); the name; the entity's noun and the short id,
101
+ * muted, when no record answered or the read failed — never an alert, since a
102
+ * list that loaded has not failed because one name could not be read; and the
103
+ * raw id, muted, when the host registered nothing to read it with.
104
+ */ function ReferenceValue({ entity, id }) {
105
+ const state = useReferenceLabel(entity, id);
106
+ const unresolved = useUnresolvedReference();
107
+ const locale = useLocale();
108
+ switch(state.status){
109
+ case 'resolving':
110
+ // The skeleton is hidden from assistive tech, so the noun and short id
111
+ // stand in for it there: a record's title link is never nameless.
112
+ return /*#__PURE__*/ _jsxs(_Fragment, {
113
+ children: [
114
+ /*#__PURE__*/ _jsx(Skeleton, {
115
+ shape: "line",
116
+ className: "w-16"
117
+ }),
118
+ /*#__PURE__*/ _jsx("span", {
119
+ className: "sr-only",
120
+ children: unresolved(entity, id)
121
+ })
122
+ ]
123
+ });
124
+ case 'named':
125
+ {
126
+ var _label_locale;
127
+ const { label } = state;
128
+ if (typeof label === 'string') return /*#__PURE__*/ _jsx("span", {
129
+ children: label
130
+ });
131
+ const text = localize(label, locale);
132
+ return ((_label_locale = label[locale]) != null ? _label_locale : '') === '' ? /*#__PURE__*/ _jsx("span", {
133
+ lang: defaultLocale(),
134
+ children: text
135
+ }) : /*#__PURE__*/ _jsx("span", {
136
+ children: text
137
+ });
138
+ }
139
+ case 'unregistered':
140
+ return /*#__PURE__*/ _jsx("span", {
141
+ className: "text-content-muted",
142
+ children: id
143
+ });
144
+ default:
145
+ return /*#__PURE__*/ _jsx("span", {
146
+ className: "text-content-muted",
147
+ children: unresolved(entity, id)
148
+ });
149
+ }
150
+ }
63
151
  /**
64
152
  * Tabular figures, applied once, here — not on `--font-sans` and not per call
65
153
  * site. A column of numbers or dates must align on the digit; a paragraph must
@@ -75,9 +163,7 @@ function formatByType(value, type, linkLabelProperty, formatting) {
75
163
  * "the value of an accessor", and only the descriptor decides how they read.
76
164
  */ export function CellValue({ value, descriptor, record }) {
77
165
  var _value_locale, _NUMERIC_CLASS_descriptor_type;
78
- const t = useT();
79
- const formatters = useFormatters();
80
- const enumLabel = useEnumLabel();
166
+ const formatting = useCellFormatting();
81
167
  const locale = useLocale();
82
168
  if (value === undefined || value === null || value === '') {
83
169
  return /*#__PURE__*/ _jsx("span", {
@@ -85,6 +171,13 @@ function formatByType(value, type, linkLabelProperty, formatting) {
85
171
  children: EMPTY
86
172
  });
87
173
  }
174
+ // A key into another entity reads as that record's name, never as itself.
175
+ if (descriptor.references !== undefined) {
176
+ return /*#__PURE__*/ _jsx(ReferenceValue, {
177
+ entity: descriptor.references.entity,
178
+ id: String(value)
179
+ });
180
+ }
88
181
  // An amount reads as money in the reader's locale, never as the stored
89
182
  // number. A draft holds it as a string, so a numeric string counts too. A
90
183
  // currency the record does not carry leaves it a plain number rather than
@@ -109,22 +202,23 @@ function formatByType(value, type, linkLabelProperty, formatting) {
109
202
  className: "w-16"
110
203
  });
111
204
  }
112
- const text = formatByType(value, descriptor.type, descriptor.linkLabelProperty, {
113
- formatters,
114
- yes: t('value.yes'),
115
- no: t('value.no'),
116
- enumLabel: (raw)=>enumLabel(descriptor, raw),
117
- rowCount: (count)=>t('value.rowCount', {
118
- count
119
- }),
120
- locale
121
- });
205
+ const text = formatByType(value, descriptor.type, descriptor.linkLabelProperty, formatting(descriptor));
122
206
  if (text === '') {
123
207
  return /*#__PURE__*/ _jsx("span", {
124
208
  className: "text-content-muted",
125
209
  children: EMPTY
126
210
  });
127
211
  }
212
+ // A status reads as a tag in its declared tone, its words beside the
213
+ // colour; a value given no tone reads neutral. An enum that declared no
214
+ // tones is not a status, and stays text.
215
+ if (descriptor.type === 'enum' && descriptor.enumTones !== undefined) {
216
+ var _descriptor_enumTones_String;
217
+ return /*#__PURE__*/ _jsx(StatusTag, {
218
+ tone: (_descriptor_enumTones_String = descriptor.enumTones[String(value)]) != null ? _descriptor_enumTones_String : 'neutral',
219
+ children: text
220
+ });
221
+ }
128
222
  // Text the reader's locale lacks falls back to the default locale's, and is
129
223
  // marked as that language, so it is read in its own voice (WCAG 3.1.2).
130
224
  if (descriptor.type === 'localized' && isLocalizedText(value) && ((_value_locale = value[locale]) != null ? _value_locale : '') === '') {
@@ -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';\n\nimport {\n useEnumLabel,\n useFormatters,\n useLocale,\n useT,\n} from '../../../i18n/index.js';\nimport { Money } from '../money/money.js';\nimport { currencyOf } from '../money/money-math.js';\nimport { Skeleton } from '../skeleton/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/**\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 t = useT();\n const formatters = useFormatters();\n const enumLabel = useEnumLabel();\n const locale = useLocale();\n\n if (value === undefined || value === null || value === '') {\n return <span className=\"text-content-muted\">{EMPTY}</span>;\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 {\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 );\n\n if (text === '') {\n return <span className=\"text-content-muted\">{EMPTY}</span>;\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","useEnumLabel","useFormatters","useLocale","useT","Money","currencyOf","Skeleton","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","NUMERIC_CLASS","CellValue","descriptor","record","t","span","className","money","amount","Number","currency","isFinite","unit","ids","shape","text","raw","count","lang"],"mappings":"AAAA;;AAGA,SACEA,aAAa,EAE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4B,OAAO5B;QAC1D,MAAM6B,WAAW1C,WAAWkC,WAAWK,KAAK,EAAEJ;QAC9C,IAAIO,aAAalC,aAAaiC,OAAOE,QAAQ,CAACH,SAAS;YACrD,qBACE,KAACzC;gBACCyC,QAAQA;gBACRE,UAAUA;gBACVE,MAAMV,WAAWK,KAAK,CAACK,IAAI;gBAC3BtC,QAAQA;;QAGd;IACF;IAEA,qEAAqE;IACrE,oEAAoE;IACpE,IACE,AAACO,iBAAiBrB,cAChBqB,MAAMD,EAAE,IAAI,QACZC,MAAMA,KAAK,KAAKL,aACjBK,iBAAiBtB,wBAChBsB,MAAMgC,GAAG,CAACd,MAAM,GAAG,KACnBlB,MAAME,MAAM,KAAKP,WACnB;QACA,qBAAO,KAACP;YAAS6C,OAAM;YAAOR,WAAU;;IAC1C;IAEA,MAAMS,OAAO7B,aACXL,OACAqB,WAAWf,IAAI,EACfe,WAAW7B,iBAAiB,EAC5B;QACEgB;QACAI,KAAKW,EAAE;QACPV,IAAIU,EAAE;QACNT,WAAWqB,CAAAA,MAAOrB,UAAUO,YAAYc;QACxClB,UAAUmB,CAAAA,QAASb,EAAE,kBAAkB;gBAAEa;YAAM;QAC/C3C;IACF;IAGF,IAAIyC,SAAS,IAAI;QACf,qBAAO,KAACV;YAAKC,WAAU;sBAAsBpC;;IAC/C;IAEA,4EAA4E;IAC5E,wEAAwE;IACxE,IACEgC,WAAWf,IAAI,KAAK,eACpB1B,gBAAgBoB,UAChB,EAACA,gBAAAA,KAAK,CAACP,OAAO,YAAbO,gBAAiB,QAAQ,IAC1B;QACA,qBAAO,KAACwB;YAAKa,MAAM5D;sBAAkByD;;IACvC;IAEA,qBACE,KAACV;QAAKC,SAAS,GAAEN,iCAAAA,aAAa,CAACE,WAAWf,IAAI,CAAC,YAA9Ba,iCAAkCxB;kBAAYuC;;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 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,EACVC,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,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,OAAOnB,gBAAgBkB,SAASjB,SAASiB,OAAOD,UAAUG,OAAOF;AACnE;AAEA,SAASG,WACPC,IAAwB,EACxBN,iBAAyB,EACzBC,MAAc;QAITH;IAFL,OAAOQ,KAAKC,EAAE,IAAI,OACdV,SACCC,eAAAA,YAAYQ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,MAAM,GAAG,KACnBlB,MAAME,MAAM,KAAKP,WACnB;QACA,qBAAO,KAACR;YAAS2C,OAAM;YAAOC,WAAU;;IAC1C;IAEA,MAAME,OAAO5B,aACXL,OACAqB,WAAWf,IAAI,EACfe,WAAW7B,iBAAiB,EAC5Be,WAAWc;IAGb,IAAIY,SAAS,IAAI;QACf,qBAAO,KAACD;YAAKD,WAAU;sBAAsB1C;;IAC/C;IAEA,qEAAqE;IACrE,wEAAwE;IACxE,yCAAyC;IACzC,IAAIgC,WAAWf,IAAI,KAAK,UAAUe,WAAWyB,SAAS,KAAKnD,WAAW;YAEjD0B;QADnB,qBACE,KAACjC;YAAU2D,IAAI,GAAE1B,+BAAAA,WAAWyB,SAAS,CAAClD,OAAOI,OAAO,YAAnCqB,+BAAuC;sBACrDY;;IAGP;IAEA,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,2 +1,3 @@
1
1
  export * from './cell-value.js';
2
+ export * from './use-record-label.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/cell-value/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/cell-value/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from './cell-value.js';
2
+ export * from './use-record-label.js';
2
3
 
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/atoms/cell-value/index.ts"],"sourcesContent":["export * from './cell-value.js';\n"],"names":[],"mappings":"AAAA,cAAc,kBAAkB"}
1
+ {"version":3,"sources":["../../../../src/ui/atoms/cell-value/index.ts"],"sourcesContent":["export * from './cell-value.js';\nexport * from './use-record-label.js';\n"],"names":[],"mappings":"AAAA,cAAc,kBAAkB;AAChC,cAAc,wBAAwB"}
@@ -0,0 +1,16 @@
1
+ import { type ChildConstructor } from '@entifix/core';
2
+ /**
3
+ * What a record is called, in words — the one derivation every surface that
4
+ * names a record reads: a row's checkbox and title, a card's heading, a
5
+ * confirm dialog's object, the typed delete policy, a breadcrumb, a toast
6
+ * ([ADR 0030](../../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)).
7
+ *
8
+ * Core's `recordLabel()` decides **which** member names the record; this puts
9
+ * it into the reader's language: a value as its cell reads it, a reference by
10
+ * its target's name (or the target's noun and short id until that is known),
11
+ * and otherwise the entity's own noun with the record's short id. Never a
12
+ * whole id, except a reference the host registered nothing to read — which is
13
+ * the developer's cue, not the reader's.
14
+ */
15
+ export declare function useRecordLabel(): (entityConstructor: ChildConstructor, record: object | undefined) => string;
16
+ //# sourceMappingURL=use-record-label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-record-label.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/cell-value/use-record-label.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AAUvB;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,IAAI,CAChC,iBAAiB,EAAE,gBAAgB,EACnC,MAAM,EAAE,MAAM,GAAG,SAAS,KACvB,MAAM,CAgCV"}
@@ -0,0 +1,55 @@
1
+ 'use client';
2
+ import { _ as _extends } from "@swc/helpers/_/_extends";
3
+ import { findMetaEntity, recordLabel } from '@entifix/core';
4
+ import { useCallback } from 'react';
5
+ import { useEntityNoun, useT } from '../../../i18n/index.js';
6
+ import { useReferenceLabels, useUnresolvedReference } from '../../utils/reference-labels.js';
7
+ import { useValueText } from './cell-value.js';
8
+ /**
9
+ * What a record is called, in words — the one derivation every surface that
10
+ * names a record reads: a row's checkbox and title, a card's heading, a
11
+ * confirm dialog's object, the typed delete policy, a breadcrumb, a toast
12
+ * ([ADR 0030](../../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)).
13
+ *
14
+ * Core's `recordLabel()` decides **which** member names the record; this puts
15
+ * it into the reader's language: a value as its cell reads it, a reference by
16
+ * its target's name (or the target's noun and short id until that is known),
17
+ * and otherwise the entity's own noun with the record's short id. Never a
18
+ * whole id, except a reference the host registered nothing to read — which is
19
+ * the developer's cue, not the reader's.
20
+ */ export function useRecordLabel() {
21
+ const valueText = useValueText();
22
+ const lookup = useReferenceLabels();
23
+ const unresolved = useUnresolvedReference();
24
+ const t = useT();
25
+ const noun = useEntityNoun();
26
+ return useCallback((entityConstructor, record)=>{
27
+ var _findMetaEntity;
28
+ const label = recordLabel(entityConstructor, record);
29
+ if (label.kind === 'value') return valueText(label.value, label.member);
30
+ if (label.kind === 'reference') {
31
+ const state = lookup.label(label.entity, label.id);
32
+ if (state.status === 'named') {
33
+ return valueText(state.label, _extends({}, label.member, {
34
+ type: typeof state.label === 'string' ? 'string' : 'localized'
35
+ }));
36
+ }
37
+ return state.status === 'unregistered' ? label.id : unresolved(label.entity, label.id);
38
+ }
39
+ const entityNoun = noun((_findMetaEntity = findMetaEntity(entityConstructor)) != null ? _findMetaEntity : {
40
+ name: entityConstructor.name
41
+ });
42
+ return label.shortId === undefined ? entityNoun : t('reference.unresolved', {
43
+ noun: entityNoun,
44
+ id: label.shortId
45
+ });
46
+ }, [
47
+ lookup,
48
+ noun,
49
+ t,
50
+ unresolved,
51
+ valueText
52
+ ]);
53
+ }
54
+
55
+ //# sourceMappingURL=use-record-label.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/ui/atoms/cell-value/use-record-label.ts"],"sourcesContent":["'use client';\n\nimport {\n type ChildConstructor,\n findMetaEntity,\n recordLabel,\n} from '@entifix/core';\nimport { useCallback } from 'react';\n\nimport { useEntityNoun, useT } from '../../../i18n/index.js';\nimport {\n useReferenceLabels,\n useUnresolvedReference,\n} from '../../utils/reference-labels.js';\nimport { useValueText } from './cell-value.js';\n\n/**\n * What a record is called, in words — the one derivation every surface that\n * names a record reads: a row's checkbox and title, a card's heading, a\n * confirm dialog's object, the typed delete policy, a breadcrumb, a toast\n * ([ADR 0030](../../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)).\n *\n * Core's `recordLabel()` decides **which** member names the record; this puts\n * it into the reader's language: a value as its cell reads it, a reference by\n * its target's name (or the target's noun and short id until that is known),\n * and otherwise the entity's own noun with the record's short id. Never a\n * whole id, except a reference the host registered nothing to read — which is\n * the developer's cue, not the reader's.\n */\nexport function useRecordLabel(): (\n entityConstructor: ChildConstructor,\n record: object | undefined,\n) => string {\n const valueText = useValueText();\n const lookup = useReferenceLabels();\n const unresolved = useUnresolvedReference();\n const t = useT();\n const noun = useEntityNoun();\n\n return useCallback(\n (entityConstructor, record) => {\n const label = recordLabel(entityConstructor, record);\n if (label.kind === 'value') return valueText(label.value, label.member);\n if (label.kind === 'reference') {\n const state = lookup.label(label.entity, label.id);\n if (state.status === 'named') {\n return valueText(state.label, {\n ...label.member,\n type: typeof state.label === 'string' ? 'string' : 'localized',\n });\n }\n return state.status === 'unregistered'\n ? label.id\n : unresolved(label.entity, label.id);\n }\n const entityNoun = noun(\n findMetaEntity(entityConstructor) ?? { name: entityConstructor.name },\n );\n return label.shortId === undefined\n ? entityNoun\n : t('reference.unresolved', { noun: entityNoun, id: label.shortId });\n },\n [lookup, noun, t, unresolved, valueText],\n );\n}\n"],"names":["findMetaEntity","recordLabel","useCallback","useEntityNoun","useT","useReferenceLabels","useUnresolvedReference","useValueText","useRecordLabel","valueText","lookup","unresolved","t","noun","entityConstructor","record","label","kind","value","member","state","entity","id","status","type","entityNoun","name","shortId","undefined"],"mappings":"AAAA;;AAEA,SAEEA,cAAc,EACdC,WAAW,QACN,gBAAgB;AACvB,SAASC,WAAW,QAAQ,QAAQ;AAEpC,SAASC,aAAa,EAAEC,IAAI,QAAQ,yBAAyB;AAC7D,SACEC,kBAAkB,EAClBC,sBAAsB,QACjB,kCAAkC;AACzC,SAASC,YAAY,QAAQ,kBAAkB;AAE/C;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC;IAId,MAAMC,YAAYF;IAClB,MAAMG,SAASL;IACf,MAAMM,aAAaL;IACnB,MAAMM,IAAIR;IACV,MAAMS,OAAOV;IAEb,OAAOD,YACL,CAACY,mBAAmBC;YAgBhBf;QAfF,MAAMgB,QAAQf,YAAYa,mBAAmBC;QAC7C,IAAIC,MAAMC,IAAI,KAAK,SAAS,OAAOR,UAAUO,MAAME,KAAK,EAAEF,MAAMG,MAAM;QACtE,IAAIH,MAAMC,IAAI,KAAK,aAAa;YAC9B,MAAMG,QAAQV,OAAOM,KAAK,CAACA,MAAMK,MAAM,EAAEL,MAAMM,EAAE;YACjD,IAAIF,MAAMG,MAAM,KAAK,SAAS;gBAC5B,OAAOd,UAAUW,MAAMJ,KAAK,EAAE,aACzBA,MAAMG,MAAM;oBACfK,MAAM,OAAOJ,MAAMJ,KAAK,KAAK,WAAW,WAAW;;YAEvD;YACA,OAAOI,MAAMG,MAAM,KAAK,iBACpBP,MAAMM,EAAE,GACRX,WAAWK,MAAMK,MAAM,EAAEL,MAAMM,EAAE;QACvC;QACA,MAAMG,aAAaZ,MACjBb,kBAAAA,eAAec,8BAAfd,kBAAqC;YAAE0B,MAAMZ,kBAAkBY,IAAI;QAAC;QAEtE,OAAOV,MAAMW,OAAO,KAAKC,YACrBH,aACAb,EAAE,wBAAwB;YAAEC,MAAMY;YAAYH,IAAIN,MAAMW,OAAO;QAAC;IACtE,GACA;QAACjB;QAAQG;QAAMD;QAAGD;QAAYF;KAAU;AAE5C"}
@@ -0,0 +1,2 @@
1
+ export * from './media-image.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/media-image/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './media-image.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/ui/atoms/media-image/index.ts"],"sourcesContent":["export * from './media-image.js';\n"],"names":[],"mappings":"AAAA,cAAc,mBAAmB"}
@@ -0,0 +1,46 @@
1
+ import type { ComponentPropsWithoutRef } from 'react';
2
+ /**
3
+ * The widths a {@link MediaImageLoader} is asked for, narrow to wide. A fixed
4
+ * ladder rather than one per caller: every image on a host is cut at the same
5
+ * few sizes, which is what lets a resizing service cache them.
6
+ */
7
+ export declare const MEDIA_IMAGE_WIDTHS: readonly [320, 480, 640, 960, 1280, 1920];
8
+ /**
9
+ * The URL of `src` resized to `width` pixels wide. Supplied by the host, which
10
+ * knows which service, if any, can resize its images; without one, an image
11
+ * is served as it is.
12
+ */
13
+ export type MediaImageLoader = (src: string, width: number) => string;
14
+ export interface MediaImageProps extends Omit<ComponentPropsWithoutRef<'img'>, 'src' | 'alt' | 'width' | 'height' | 'sizes' | 'srcSet' | 'loading' | 'decoding' | 'fetchPriority'> {
15
+ src: string;
16
+ /** What the image shows. Empty only for an image that adds nothing to the text beside it. */
17
+ alt: string;
18
+ /** Intrinsic width in pixels, when known. */
19
+ width?: number;
20
+ /** Intrinsic height in pixels, when known. */
21
+ height?: number;
22
+ /**
23
+ * Width over height of the box the image is shown in. The box is reserved
24
+ * before the image arrives, so nothing below it moves when it does.
25
+ * Defaults to `1`, a square.
26
+ */
27
+ aspectRatio?: number;
28
+ /** How wide the image is shown at, as a `sizes` attribute (`(min-width: 48rem) 50vw, 100vw`). */
29
+ sizes: string;
30
+ /**
31
+ * The image is the first thing a reader sees: fetched first and at once,
32
+ * never lazily. One per page at most.
33
+ */
34
+ priority?: boolean;
35
+ /** Resizes `src` per width; given, the image offers one candidate per {@link MEDIA_IMAGE_WIDTHS}. */
36
+ loader?: MediaImageLoader;
37
+ }
38
+ /**
39
+ * One image, sized for where it is shown. Its box is reserved by aspect
40
+ * ratio, so a late image shifts nothing; it is fetched lazily unless it is the
41
+ * `priority` one; and with a host `loader` it offers a `srcset` the browser
42
+ * picks the smallest fitting candidate from. Without a loader there is nothing
43
+ * to choose between, and no `srcset` is written. Server-safe.
44
+ */
45
+ export declare function MediaImage({ src, alt, width, height, aspectRatio, sizes, priority, loader, className, style, ...props }: MediaImageProps): import("react").JSX.Element;
46
+ //# sourceMappingURL=media-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-image.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/media-image/media-image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAItD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,2CAA4C,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEtE,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAC3C,wBAAwB,CAAC,KAAK,CAAC,EAC7B,KAAK,GACL,KAAK,GACL,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SAAS,GACT,UAAU,GACV,eAAe,CAClB;IACC,GAAG,EAAE,MAAM,CAAC;IACZ,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qGAAqG;IACrG,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,GAAG,EACH,KAAK,EACL,MAAM,EACN,WAAe,EACf,KAAK,EACL,QAAgB,EAChB,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,eAAe,+BAqBjB"}
@@ -0,0 +1,57 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { cn } from '../../utils/cn.js';
5
+ /**
6
+ * The widths a {@link MediaImageLoader} is asked for, narrow to wide. A fixed
7
+ * ladder rather than one per caller: every image on a host is cut at the same
8
+ * few sizes, which is what lets a resizing service cache them.
9
+ */ export const MEDIA_IMAGE_WIDTHS = [
10
+ 320,
11
+ 480,
12
+ 640,
13
+ 960,
14
+ 1280,
15
+ 1920
16
+ ];
17
+ /**
18
+ * One image, sized for where it is shown. Its box is reserved by aspect
19
+ * ratio, so a late image shifts nothing; it is fetched lazily unless it is the
20
+ * `priority` one; and with a host `loader` it offers a `srcset` the browser
21
+ * picks the smallest fitting candidate from. Without a loader there is nothing
22
+ * to choose between, and no `srcset` is written. Server-safe.
23
+ */ export function MediaImage(_0) {
24
+ let { src, alt, width, height, aspectRatio = 1, sizes, priority = false, loader, className, style } = _0, props = _object_without_properties_loose(_0, [
25
+ "src",
26
+ "alt",
27
+ "width",
28
+ "height",
29
+ "aspectRatio",
30
+ "sizes",
31
+ "priority",
32
+ "loader",
33
+ "className",
34
+ "style"
35
+ ]);
36
+ const srcSet = loader === undefined ? undefined : MEDIA_IMAGE_WIDTHS.map((w)=>`${loader(src, w)} ${w}w`).join(', ');
37
+ return /*#__PURE__*/ _jsx("img", _extends({
38
+ src: src,
39
+ alt: alt,
40
+ width: width,
41
+ height: height,
42
+ sizes: sizes,
43
+ srcSet: srcSet
44
+ }, priority ? {
45
+ fetchPriority: 'high'
46
+ } : {
47
+ loading: 'lazy',
48
+ decoding: 'async'
49
+ }, {
50
+ className: cn('block h-auto w-full object-contain', className),
51
+ style: _extends({
52
+ aspectRatio
53
+ }, style)
54
+ }, props));
55
+ }
56
+
57
+ //# sourceMappingURL=media-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/ui/atoms/media-image/media-image.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef } from 'react';\n\nimport { cn } from '../../utils/cn.js';\n\n/**\n * The widths a {@link MediaImageLoader} is asked for, narrow to wide. A fixed\n * ladder rather than one per caller: every image on a host is cut at the same\n * few sizes, which is what lets a resizing service cache them.\n */\nexport const MEDIA_IMAGE_WIDTHS = [320, 480, 640, 960, 1280, 1920] as const;\n\n/**\n * The URL of `src` resized to `width` pixels wide. Supplied by the host, which\n * knows which service, if any, can resize its images; without one, an image\n * is served as it is.\n */\nexport type MediaImageLoader = (src: string, width: number) => string;\n\nexport interface MediaImageProps extends Omit<\n ComponentPropsWithoutRef<'img'>,\n | 'src'\n | 'alt'\n | 'width'\n | 'height'\n | 'sizes'\n | 'srcSet'\n | 'loading'\n | 'decoding'\n | 'fetchPriority'\n> {\n src: string;\n /** What the image shows. Empty only for an image that adds nothing to the text beside it. */\n alt: string;\n /** Intrinsic width in pixels, when known. */\n width?: number;\n /** Intrinsic height in pixels, when known. */\n height?: number;\n /**\n * Width over height of the box the image is shown in. The box is reserved\n * before the image arrives, so nothing below it moves when it does.\n * Defaults to `1`, a square.\n */\n aspectRatio?: number;\n /** How wide the image is shown at, as a `sizes` attribute (`(min-width: 48rem) 50vw, 100vw`). */\n sizes: string;\n /**\n * The image is the first thing a reader sees: fetched first and at once,\n * never lazily. One per page at most.\n */\n priority?: boolean;\n /** Resizes `src` per width; given, the image offers one candidate per {@link MEDIA_IMAGE_WIDTHS}. */\n loader?: MediaImageLoader;\n}\n\n/**\n * One image, sized for where it is shown. Its box is reserved by aspect\n * ratio, so a late image shifts nothing; it is fetched lazily unless it is the\n * `priority` one; and with a host `loader` it offers a `srcset` the browser\n * picks the smallest fitting candidate from. Without a loader there is nothing\n * to choose between, and no `srcset` is written. Server-safe.\n */\nexport function MediaImage({\n src,\n alt,\n width,\n height,\n aspectRatio = 1,\n sizes,\n priority = false,\n loader,\n className,\n style,\n ...props\n}: MediaImageProps) {\n const srcSet =\n loader === undefined\n ? undefined\n : MEDIA_IMAGE_WIDTHS.map(w => `${loader(src, w)} ${w}w`).join(', ');\n return (\n <img\n src={src}\n alt={alt}\n width={width}\n height={height}\n sizes={sizes}\n srcSet={srcSet}\n {...(priority\n ? { fetchPriority: 'high' as const }\n : { loading: 'lazy' as const, decoding: 'async' as const })}\n className={cn('block h-auto w-full object-contain', className)}\n style={{ aspectRatio, ...style }}\n {...props}\n />\n );\n}\n"],"names":["cn","MEDIA_IMAGE_WIDTHS","MediaImage","src","alt","width","height","aspectRatio","sizes","priority","loader","className","style","props","srcSet","undefined","map","w","join","img","fetchPriority","loading","decoding"],"mappings":";;;AAEA,SAASA,EAAE,QAAQ,oBAAoB;AAEvC;;;;CAIC,GACD,OAAO,MAAMC,qBAAqB;IAAC;IAAK;IAAK;IAAK;IAAK;IAAM;CAAK,CAAU;AA6C5E;;;;;;CAMC,GACD,OAAO,SAASC,WAAW,EAYT;QAZS,EACzBC,GAAG,EACHC,GAAG,EACHC,KAAK,EACLC,MAAM,EACNC,cAAc,CAAC,EACfC,KAAK,EACLC,WAAW,KAAK,EAChBC,MAAM,EACNC,SAAS,EACTC,KAAK,EAEW,OADbC;;;;;;;;;;;;IAEH,MAAMC,SACJJ,WAAWK,YACPA,YACAd,mBAAmBe,GAAG,CAACC,CAAAA,IAAK,GAAGP,OAAOP,KAAKc,GAAG,CAAC,EAAEA,EAAE,CAAC,CAAC,EAAEC,IAAI,CAAC;IAClE,qBACE,KAACC;QACChB,KAAKA;QACLC,KAAKA;QACLC,OAAOA;QACPC,QAAQA;QACRE,OAAOA;QACPM,QAAQA;OACHL,WACD;QAAEW,eAAe;IAAgB,IACjC;QAAEC,SAAS;QAAiBC,UAAU;IAAiB;QAC3DX,WAAWX,GAAG,sCAAsCW;QACpDC,OAAO;YAAEL;WAAgBK;OACrBC;AAGV"}
@@ -1,6 +1,10 @@
1
+ import type { EnumTone } from '@entifix/core';
1
2
  import type { ComponentPropsWithoutRef, ReactNode } from 'react';
2
- import { type Tone } from '../alert/tone.js';
3
- export type StatusTagTone = Tone | 'neutral';
3
+ /**
4
+ * The tones a status reads in. One vocabulary with core's {@link EnumTone},
5
+ * so an enum member's declared `enumTones` render here unmapped.
6
+ */
7
+ export type StatusTagTone = EnumTone;
4
8
  export interface StatusTagProps extends Omit<ComponentPropsWithoutRef<'span'>, 'children'> {
5
9
  tone: StatusTagTone;
6
10
  /** The status in words. Required and non-empty: colour is never the only carrier (WCAG 1.4.1). */
@@ -1 +1 @@
1
- {"version":3,"file":"status-tag.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/status-tag/status-tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,KAAK,IAAI,EAAgB,MAAM,kBAAkB,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;AAO7C,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,wBAAwB,CAAC,MAAM,CAAC,EAChC,UAAU,CACX;IACC,IAAI,EAAE,aAAa,CAAC;IACpB,kGAAkG;IAClG,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,+BAoBhB"}
1
+ {"version":3,"file":"status-tag.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/status-tag/status-tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKjE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;AAOrC,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,wBAAwB,CAAC,MAAM,CAAC,EAChC,UAAU,CACX;IACC,IAAI,EAAE,aAAa,CAAC;IACpB,kGAAkG;IAClG,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,+BAoBhB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/ui/atoms/status-tag/status-tag.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ReactNode } from 'react';\n\nimport { cn } from '../../utils/cn.js';\nimport { type Tone, TONE_SURFACE } from '../alert/tone.js';\n\nexport type StatusTagTone = Tone | 'neutral';\n\nconst TONE_CLASS: Record<StatusTagTone, string> = {\n ...TONE_SURFACE,\n neutral: 'border-border bg-surface text-content-muted',\n};\n\nexport interface StatusTagProps extends Omit<\n ComponentPropsWithoutRef<'span'>,\n 'children'\n> {\n tone: StatusTagTone;\n /** The status in words. Required and non-empty: colour is never the only carrier (WCAG 1.4.1). */\n children: string;\n /** A glyph before the words; decorative, so hidden from assistive technology. */\n icon?: ReactNode;\n}\n\n/**\n * A record's status as a small tag: a tone and the words for it. The words are\n * mandatory, and an empty string throws rather than rendering a coloured dot\n * that means something only to people who can see the colour. Server-safe.\n */\nexport function StatusTag({\n tone,\n icon,\n className,\n children,\n ...props\n}: StatusTagProps) {\n if (children.trim() === '') {\n throw new Error(\n 'StatusTag needs its status in words: colour alone carries nothing for someone who cannot see it.',\n );\n }\n return (\n <span\n data-tone={tone}\n className={cn(\n 'inline-flex items-center gap-3xs rounded-full border px-2xs text-step-xs font-medium whitespace-nowrap',\n TONE_CLASS[tone],\n className,\n )}\n {...props}\n >\n {icon !== undefined && <span aria-hidden=\"true\">{icon}</span>}\n {children}\n </span>\n );\n}\n"],"names":["cn","TONE_SURFACE","TONE_CLASS","neutral","StatusTag","tone","icon","className","children","props","trim","Error","span","data-tone","undefined","aria-hidden"],"mappings":";;;AAEA,SAASA,EAAE,QAAQ,oBAAoB;AACvC,SAAoBC,YAAY,QAAQ,mBAAmB;AAI3D,MAAMC,aAA4C,aAC7CD;IACHE,SAAS;;AAcX;;;;CAIC,GACD,OAAO,SAASC,UAAU,EAMT;QANS,EACxBC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,QAAQ,EAEO,OADZC;;;;;;IAEH,IAAID,SAASE,IAAI,OAAO,IAAI;QAC1B,MAAM,IAAIC,MACR;IAEJ;IACA,qBACE,MAACC;QACCC,aAAWR;QACXE,WAAWP,GACT,0GACAE,UAAU,CAACG,KAAK,EAChBE;OAEEE;;YAEHH,SAASQ,2BAAa,KAACF;gBAAKG,eAAY;0BAAQT;;YAChDE;;;AAGP"}
1
+ {"version":3,"sources":["../../../../src/ui/atoms/status-tag/status-tag.tsx"],"sourcesContent":["import type { EnumTone } from '@entifix/core';\nimport type { ComponentPropsWithoutRef, ReactNode } from 'react';\n\nimport { cn } from '../../utils/cn.js';\nimport { TONE_SURFACE } from '../alert/tone.js';\n\n/**\n * The tones a status reads in. One vocabulary with core's {@link EnumTone},\n * so an enum member's declared `enumTones` render here unmapped.\n */\nexport type StatusTagTone = EnumTone;\n\nconst TONE_CLASS: Record<StatusTagTone, string> = {\n ...TONE_SURFACE,\n neutral: 'border-border bg-surface text-content-muted',\n};\n\nexport interface StatusTagProps extends Omit<\n ComponentPropsWithoutRef<'span'>,\n 'children'\n> {\n tone: StatusTagTone;\n /** The status in words. Required and non-empty: colour is never the only carrier (WCAG 1.4.1). */\n children: string;\n /** A glyph before the words; decorative, so hidden from assistive technology. */\n icon?: ReactNode;\n}\n\n/**\n * A record's status as a small tag: a tone and the words for it. The words are\n * mandatory, and an empty string throws rather than rendering a coloured dot\n * that means something only to people who can see the colour. Server-safe.\n */\nexport function StatusTag({\n tone,\n icon,\n className,\n children,\n ...props\n}: StatusTagProps) {\n if (children.trim() === '') {\n throw new Error(\n 'StatusTag needs its status in words: colour alone carries nothing for someone who cannot see it.',\n );\n }\n return (\n <span\n data-tone={tone}\n className={cn(\n 'inline-flex items-center gap-3xs rounded-full border px-2xs text-step-xs font-medium whitespace-nowrap',\n TONE_CLASS[tone],\n className,\n )}\n {...props}\n >\n {icon !== undefined && <span aria-hidden=\"true\">{icon}</span>}\n {children}\n </span>\n );\n}\n"],"names":["cn","TONE_SURFACE","TONE_CLASS","neutral","StatusTag","tone","icon","className","children","props","trim","Error","span","data-tone","undefined","aria-hidden"],"mappings":";;;AAGA,SAASA,EAAE,QAAQ,oBAAoB;AACvC,SAASC,YAAY,QAAQ,mBAAmB;AAQhD,MAAMC,aAA4C,aAC7CD;IACHE,SAAS;;AAcX;;;;CAIC,GACD,OAAO,SAASC,UAAU,EAMT;QANS,EACxBC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,QAAQ,EAEO,OADZC;;;;;;IAEH,IAAID,SAASE,IAAI,OAAO,IAAI;QAC1B,MAAM,IAAIC,MACR;IAEJ;IACA,qBACE,MAACC;QACCC,aAAWR;QACXE,WAAWP,GACT,0GACAE,UAAU,CAACG,KAAK,EAChBE;OAEEE;;YAEHH,SAASQ,2BAAa,KAACF;gBAAKG,eAAY;0BAAQT;;YAChDE;;;AAGP"}
@@ -1,7 +1,9 @@
1
- import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
1
+ import { type ComponentPropsWithoutRef, type CSSProperties, type ReactNode } from 'react';
2
2
  export interface TableProps extends ComponentPropsWithoutRef<'table'> {
3
3
  /** Class names for the scroll container wrapping the `<table>`. */
4
4
  containerClassName?: string;
5
+ /** Inline style on that container — the scroll padding a sticky column needs. */
6
+ containerStyle?: CSSProperties;
5
7
  /**
6
8
  * What the table holds — "Clientes, 12 resultados". It names the table and,
7
9
  * once the table overflows its container, the scroll region too.
@@ -19,7 +21,7 @@ export interface TableProps extends ComponentPropsWithoutRef<'table'> {
19
21
  * caption, so a keyboard can scroll it — and one that fits is neither, so it
20
22
  * adds no tab stop that does nothing.
21
23
  */
22
- export declare function Table({ className, containerClassName, caption, captionClassName, children, ...props }: TableProps): import("react").JSX.Element;
24
+ export declare function Table({ className, containerClassName, containerStyle, caption, captionClassName, children, ...props }: TableProps): import("react").JSX.Element;
23
25
  export declare function TableHead({ className, ...props }: ComponentPropsWithoutRef<'thead'>): import("react").JSX.Element;
24
26
  export declare function TableBody({ className, ...props }: ComponentPropsWithoutRef<'tbody'>): import("react").JSX.Element;
25
27
  export declare function TableRow({ className, ...props }: ComponentPropsWithoutRef<'tr'>): import("react").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/table/table.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAIf,MAAM,WAAW,UAAW,SAAQ,wBAAwB,CAAC,OAAO,CAAC;IACnE,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAyBD;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,EACpB,SAAS,EACT,kBAAkB,EAClB,OAAO,EACP,gBAA4B,EAC5B,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,UAAU,+BAoCZ;AAED,wBAAgB,SAAS,CAAC,EACxB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,OAAO,CAAC,+BAanC;AAED,wBAAgB,SAAS,CAAC,EACxB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,OAAO,CAAC,+BAInC;AAED,wBAAgB,QAAQ,CAAC,EACvB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,IAAI,CAAC,+BAUhC;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAUxD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAChD,wBAAwB,CAAC,IAAI,CAAC,EAC9B,OAAO,CACR;IACC,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB;AAED,wBAAgB,eAAe,CAAC,EAC9B,KAAe,EACf,SAAS,EACT,GAAG,KAAK,EACT,EAAE,oBAAoB,+BAYtB;AAED,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,wBAAwB,CAAC,IAAI,CAAC,EAC9B,OAAO,CACR;IACC,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAe,EACf,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,+BAOhB;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,IAAI,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,+BAatD"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/ui/atoms/table/table.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,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AAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,+BAOhB;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,IAAI,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,+BAatD"}
@@ -32,9 +32,10 @@ import { cn } from '../../utils/cn.js';
32
32
  * caption, so a keyboard can scroll it — and one that fits is neither, so it
33
33
  * adds no tab stop that does nothing.
34
34
  */ export function Table(_0) {
35
- let { className, containerClassName, caption, captionClassName = 'sr-only', children } = _0, props = _object_without_properties_loose(_0, [
35
+ let { className, containerClassName, containerStyle, caption, captionClassName = 'sr-only', children } = _0, props = _object_without_properties_loose(_0, [
36
36
  "className",
37
37
  "containerClassName",
38
+ "containerStyle",
38
39
  "caption",
39
40
  "captionClassName",
40
41
  "children"
@@ -45,6 +46,7 @@ import { cn } from '../../utils/cn.js';
45
46
  const named = caption !== undefined;
46
47
  return /*#__PURE__*/ _jsx("div", _extends({
47
48
  ref: container,
49
+ style: containerStyle,
48
50
  "data-overflows": overflows || undefined
49
51
  }, overflows && {
50
52
  tabIndex: 0,