@dads-framework/ui 0.1.0 → 0.3.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 (155) hide show
  1. package/README.md +37 -7
  2. package/dist/copy/index.d.ts +17 -0
  3. package/dist/copy/index.d.ts.map +1 -0
  4. package/dist/copy/index.js +17 -0
  5. package/dist/copy/index.js.map +1 -0
  6. package/dist/copy/lib/catalog-parity.d.ts +55 -0
  7. package/dist/copy/lib/catalog-parity.d.ts.map +1 -0
  8. package/dist/copy/lib/catalog-parity.js +134 -0
  9. package/dist/copy/lib/catalog-parity.js.map +1 -0
  10. package/dist/copy/lib/copy-descriptor.d.ts +31 -0
  11. package/dist/copy/lib/copy-descriptor.d.ts.map +1 -0
  12. package/dist/copy/lib/copy-descriptor.js +35 -0
  13. package/dist/copy/lib/copy-descriptor.js.map +1 -0
  14. package/dist/copy/lib/create-copy-hook.d.ts +23 -0
  15. package/dist/copy/lib/create-copy-hook.d.ts.map +1 -0
  16. package/dist/copy/lib/create-copy-hook.js +17 -0
  17. package/dist/copy/lib/create-copy-hook.js.map +1 -0
  18. package/dist/copy/lib/english-chrome-case.d.ts +16 -0
  19. package/dist/copy/lib/english-chrome-case.d.ts.map +1 -0
  20. package/dist/copy/lib/english-chrome-case.js +111 -0
  21. package/dist/copy/lib/english-chrome-case.js.map +1 -0
  22. package/dist/copy/lib/formatted-values.d.ts +16 -0
  23. package/dist/copy/lib/formatted-values.d.ts.map +1 -0
  24. package/dist/copy/lib/formatted-values.js +15 -0
  25. package/dist/copy/lib/formatted-values.js.map +1 -0
  26. package/dist/copy/lib/glossary.d.ts +28 -0
  27. package/dist/copy/lib/glossary.d.ts.map +1 -0
  28. package/dist/copy/lib/glossary.js +22 -0
  29. package/dist/copy/lib/glossary.js.map +1 -0
  30. package/dist/copy/lib/locale-formatting.d.ts +62 -0
  31. package/dist/copy/lib/locale-formatting.d.ts.map +1 -0
  32. package/dist/copy/lib/locale-formatting.js +172 -0
  33. package/dist/copy/lib/locale-formatting.js.map +1 -0
  34. package/dist/copy/lib/locale-metadata.d.ts +15 -0
  35. package/dist/copy/lib/locale-metadata.d.ts.map +1 -0
  36. package/dist/copy/lib/locale-metadata.js +9 -0
  37. package/dist/copy/lib/locale-metadata.js.map +1 -0
  38. package/dist/copy/lib/locale-provider.d.ts +36 -0
  39. package/dist/copy/lib/locale-provider.d.ts.map +1 -0
  40. package/dist/copy/lib/locale-provider.js +41 -0
  41. package/dist/copy/lib/locale-provider.js.map +1 -0
  42. package/dist/copy/lib/localized-text.d.ts +41 -0
  43. package/dist/copy/lib/localized-text.d.ts.map +1 -0
  44. package/dist/copy/lib/localized-text.js +42 -0
  45. package/dist/copy/lib/localized-text.js.map +1 -0
  46. package/dist/copy/lib/logic/calendar-date-boundaries.d.ts +5 -0
  47. package/dist/copy/lib/logic/calendar-date-boundaries.d.ts.map +1 -0
  48. package/dist/copy/lib/logic/calendar-date-boundaries.js +69 -0
  49. package/dist/copy/lib/logic/calendar-date-boundaries.js.map +1 -0
  50. package/dist/copy/lib/logic/locale-provider-state.d.ts +12 -0
  51. package/dist/copy/lib/logic/locale-provider-state.d.ts.map +1 -0
  52. package/dist/copy/lib/logic/locale-provider-state.js +17 -0
  53. package/dist/copy/lib/logic/locale-provider-state.js.map +1 -0
  54. package/dist/copy/lib/merge-copy.d.ts +43 -0
  55. package/dist/copy/lib/merge-copy.d.ts.map +1 -0
  56. package/dist/copy/lib/merge-copy.js +26 -0
  57. package/dist/copy/lib/merge-copy.js.map +1 -0
  58. package/dist/copy/lib/placeholder-syntax.d.ts +12 -0
  59. package/dist/copy/lib/placeholder-syntax.d.ts.map +1 -0
  60. package/dist/copy/lib/placeholder-syntax.js +36 -0
  61. package/dist/copy/lib/placeholder-syntax.js.map +1 -0
  62. package/dist/copy/lib/product-vocabulary.d.ts +42 -0
  63. package/dist/copy/lib/product-vocabulary.d.ts.map +1 -0
  64. package/dist/copy/lib/product-vocabulary.js +126 -0
  65. package/dist/copy/lib/product-vocabulary.js.map +1 -0
  66. package/dist/copy/lib/resolve-initial-locale.d.ts +37 -0
  67. package/dist/copy/lib/resolve-initial-locale.d.ts.map +1 -0
  68. package/dist/copy/lib/resolve-initial-locale.js +55 -0
  69. package/dist/copy/lib/resolve-initial-locale.js.map +1 -0
  70. package/dist/copy/lib/translate.d.ts +18 -0
  71. package/dist/copy/lib/translate.d.ts.map +1 -0
  72. package/dist/copy/lib/translate.js +90 -0
  73. package/dist/copy/lib/translate.js.map +1 -0
  74. package/dist/copy/lib/use-locale-formatting.d.ts +18 -0
  75. package/dist/copy/lib/use-locale-formatting.d.ts.map +1 -0
  76. package/dist/copy/lib/use-locale-formatting.js +21 -0
  77. package/dist/copy/lib/use-locale-formatting.js.map +1 -0
  78. package/dist/data-table/components/data-table/data-table-date-filter.js +1 -1
  79. package/dist/data-table/components/data-table/data-table-date-filter.js.map +1 -1
  80. package/dist/data-table/components/data-table/data-table-faceted-filter.js +1 -1
  81. package/dist/data-table/components/data-table/data-table-faceted-filter.js.map +1 -1
  82. package/dist/data-table/components/data-table/data-table-filter-date-input.js +1 -1
  83. package/dist/data-table/components/data-table/data-table-filter-date-input.js.map +1 -1
  84. package/dist/data-table/components/data-table/data-table-filter-input-shared.d.ts +1 -1
  85. package/dist/data-table/components/data-table/data-table-filter-input-shared.d.ts.map +1 -1
  86. package/dist/data-table/components/data-table/data-table-filter-list-input.js +1 -1
  87. package/dist/data-table/components/data-table/data-table-filter-list-input.js.map +1 -1
  88. package/dist/data-table/components/data-table/data-table-filter-list-item.js +1 -1
  89. package/dist/data-table/components/data-table/data-table-filter-list-item.js.map +1 -1
  90. package/dist/data-table/components/data-table/data-table-filter-list.js +1 -1
  91. package/dist/data-table/components/data-table/data-table-filter-list.js.map +1 -1
  92. package/dist/data-table/components/data-table/data-table-filter-menu-item.js +1 -1
  93. package/dist/data-table/components/data-table/data-table-filter-menu-item.js.map +1 -1
  94. package/dist/data-table/components/data-table/data-table-filter-menu-value-selector.js +1 -1
  95. package/dist/data-table/components/data-table/data-table-filter-menu-value-selector.js.map +1 -1
  96. package/dist/data-table/components/data-table/data-table-pagination.js +1 -1
  97. package/dist/data-table/components/data-table/data-table-pagination.js.map +1 -1
  98. package/dist/data-table/components/data-table/data-table-slider-filter.js +1 -1
  99. package/dist/data-table/components/data-table/data-table-slider-filter.js.map +1 -1
  100. package/dist/data-table/components/data-table/data-table-sort-list.js +1 -1
  101. package/dist/data-table/components/data-table/data-table-sort-list.js.map +1 -1
  102. package/dist/data-table/components/data-table/data-table-toolbar.js +1 -1
  103. package/dist/data-table/components/data-table/data-table-toolbar.js.map +1 -1
  104. package/dist/data-table/components/data-table/filter-pill.js +1 -1
  105. package/dist/data-table/components/data-table/filter-pill.js.map +1 -1
  106. package/dist/data-table/copy/data-table-copy.d.ts +1 -1
  107. package/dist/data-table/copy/data-table-copy.d.ts.map +1 -1
  108. package/dist/data-table/copy/data-table-copy.js +1 -1
  109. package/dist/data-table/copy/data-table-copy.js.map +1 -1
  110. package/dist/data-table/lib/format.d.ts +1 -1
  111. package/dist/data-table/lib/format.d.ts.map +1 -1
  112. package/dist/display/components/ui/permission-decision-table.d.ts +17 -0
  113. package/dist/display/components/ui/permission-decision-table.d.ts.map +1 -0
  114. package/dist/display/components/ui/permission-decision-table.js +8 -0
  115. package/dist/display/components/ui/permission-decision-table.js.map +1 -0
  116. package/dist/display/index.d.ts +1 -0
  117. package/dist/display/index.d.ts.map +1 -1
  118. package/dist/display/index.js +1 -0
  119. package/dist/display/index.js.map +1 -1
  120. package/dist/elements/copy/elements-copy.d.ts +1 -1
  121. package/dist/elements/copy/elements-copy.d.ts.map +1 -1
  122. package/dist/elements/copy/elements-copy.js +1 -1
  123. package/dist/elements/copy/elements-copy.js.map +1 -1
  124. package/dist/overlays/components/attachment-viewer/attachment-viewer.js +1 -1
  125. package/dist/overlays/components/attachment-viewer/attachment-viewer.js.map +1 -1
  126. package/dist/overlays/components/attachment-viewer/image-stage.js +1 -1
  127. package/dist/overlays/components/attachment-viewer/image-stage.js.map +1 -1
  128. package/dist/overlays/components/attachment-viewer/pdf-document-view.js +1 -1
  129. package/dist/overlays/components/attachment-viewer/pdf-document-view.js.map +1 -1
  130. package/dist/overlays/copy/overlays-copy.d.ts +1 -1
  131. package/dist/overlays/copy/overlays-copy.d.ts.map +1 -1
  132. package/dist/overlays/copy/overlays-copy.js +1 -1
  133. package/dist/overlays/copy/overlays-copy.js.map +1 -1
  134. package/dist/page/components/attachment-list.js +1 -1
  135. package/dist/page/components/attachment-list.js.map +1 -1
  136. package/dist/page/components/list-view-tabs.js +1 -1
  137. package/dist/page/components/list-view-tabs.js.map +1 -1
  138. package/dist/page/copy/page-copy.d.ts +1 -1
  139. package/dist/page/copy/page-copy.d.ts.map +1 -1
  140. package/dist/page/copy/page-copy.js +1 -1
  141. package/dist/page/copy/page-copy.js.map +1 -1
  142. package/dist/shell/copy/shell-copy.d.ts +1 -1
  143. package/dist/shell/copy/shell-copy.d.ts.map +1 -1
  144. package/dist/shell/copy/shell-copy.js +1 -1
  145. package/dist/shell/copy/shell-copy.js.map +1 -1
  146. package/package.json +46 -4
  147. package/styles/base.css +63 -0
  148. package/styles/fonts.css +8 -0
  149. package/styles/index.css +14 -0
  150. package/styles/theme.css +140 -0
  151. package/styles/tokens.dark.css +95 -0
  152. package/styles/tokens.palette.css +90 -0
  153. package/styles/tokens.semantic.css +119 -0
  154. package/styles/utilities.css +12 -0
  155. package/tokens/default.tokens.json +1162 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-provider-state.d.ts","sourceRoot":"","sources":["../../../../src/copy/lib/logic/locale-provider-state.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,MAAM,IAAI;IACxD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,mEAAmE;AACnE,wBAAgB,6BAA6B,CAAC,OAAO,SAAS,MAAM,EAClE,YAAY,EAAE,OAAO,GACpB,mBAAmB,CAAC,OAAO,CAAC,CAE9B;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,OAAO,SAAS,MAAM,EACjD,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,EACnC,cAAc,EAAE,OAAO,GACtB,mBAAmB,CAAC,OAAO,CAAC,CAG9B;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,MAAM,EACxD,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,EACnC,YAAY,EAAE,OAAO,GACpB,mBAAmB,CAAC,OAAO,CAAC,CAG9B"}
@@ -0,0 +1,17 @@
1
+ /** Begin with the locale resolved from account/browser signals. */
2
+ export function initializeLocaleProviderState(signalLocale) {
3
+ return { signalLocale, selectedLocale: signalLocale };
4
+ }
5
+ /** Apply an explicit in-session selection without changing its signal origin. */
6
+ export function selectLocale(state, selectedLocale) {
7
+ if (state.selectedLocale === selectedLocale)
8
+ return state;
9
+ return { ...state, selectedLocale };
10
+ }
11
+ /** Follow a changed saved/browser signal; unchanged signals keep local choice. */
12
+ export function followLocaleSignals(state, signalLocale) {
13
+ if (state.signalLocale === signalLocale)
14
+ return state;
15
+ return { signalLocale, selectedLocale: signalLocale };
16
+ }
17
+ //# sourceMappingURL=locale-provider-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-provider-state.js","sourceRoot":"","sources":["../../../../src/copy/lib/logic/locale-provider-state.ts"],"names":[],"mappings":"AAMA,mEAAmE;AACnE,MAAM,UAAU,6BAA6B,CAC3C,YAAqB;IAErB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AACxD,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAC1B,KAAmC,EACnC,cAAuB;IAEvB,IAAI,KAAK,CAAC,cAAc,KAAK,cAAc;QAAE,OAAO,KAAK,CAAC;IAC1D,OAAO,EAAE,GAAG,KAAK,EAAE,cAAc,EAAE,CAAC;AACtC,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,mBAAmB,CACjC,KAAmC,EACnC,YAAqB;IAErB,IAAI,KAAK,CAAC,YAAY,KAAK,YAAY;QAAE,OAAO,KAAK,CAAC;IACtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AACxD,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { CopyCatalog, LocalizedText } from "./localized-text.js";
2
+ /**
3
+ * Every feature's catalog, gathered in one place for PROOF — never for
4
+ * resolution.
5
+ *
6
+ * A component resolves through its own feature's catalog and reads only the
7
+ * locale from context, which is what makes editing an orders label affect
8
+ * orders and nothing else. The merged object exists so two checks have
9
+ * something to sweep: the duplicate-key throw below, and the glossary
10
+ * conformance test. A component that ever resolves through the merged catalog
11
+ * turns every label edit into an app-wide edit, and is a regression even
12
+ * though nothing would visibly break.
13
+ *
14
+ * The app declares the file paths at the merge site because the app is the one
15
+ * place that knows them all — and a violation has to name a file a human can
16
+ * open, not a key floating free of its owner.
17
+ */
18
+ /** One feature's catalog, with the path a reader would have to open. */
19
+ export type CopySource = {
20
+ readonly file: string;
21
+ readonly entries: CopyCatalog;
22
+ };
23
+ /** Where a merged phrase came from, kept so a failure can name its file. */
24
+ export type MergedCopyEntry = {
25
+ readonly text: LocalizedText;
26
+ readonly file: string;
27
+ };
28
+ /** Key → phrase and provenance, across every registered catalog. */
29
+ export type MergedCopy = ReadonlyMap<string, MergedCopyEntry>;
30
+ /**
31
+ * Merge every registered catalog, refusing a key two features both declare.
32
+ *
33
+ * The throw is at merge time, and the app's merge site is a module nothing in
34
+ * the running app imports — so what a duplicate key actually breaks is
35
+ * the application’s catalog check,
36
+ * before the change can land. Deliberately not at browser module load: a
37
+ * collision is an authoring mistake, and turning one into a blank screen for a
38
+ * reader would be a worse wall than a red suite, not a stronger one. Key
39
+ * prefixes are per feature (`orders.*`, `products.*`, `glossary.*`), so a
40
+ * collision means a real mistake and not routine friction.
41
+ */
42
+ export declare function mergeCopy(sources: readonly CopySource[]): MergedCopy;
43
+ //# sourceMappingURL=merge-copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-copy.d.ts","sourceRoot":"","sources":["../../../src/copy/lib/merge-copy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEtE;;;;;;;;;;;;;;;GAeG;AAEH,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAcpE"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Merge every registered catalog, refusing a key two features both declare.
3
+ *
4
+ * The throw is at merge time, and the app's merge site is a module nothing in
5
+ * the running app imports — so what a duplicate key actually breaks is
6
+ * the application’s catalog check,
7
+ * before the change can land. Deliberately not at browser module load: a
8
+ * collision is an authoring mistake, and turning one into a blank screen for a
9
+ * reader would be a worse wall than a red suite, not a stronger one. Key
10
+ * prefixes are per feature (`orders.*`, `products.*`, `glossary.*`), so a
11
+ * collision means a real mistake and not routine friction.
12
+ */
13
+ export function mergeCopy(sources) {
14
+ const merged = new Map();
15
+ for (const source of sources) {
16
+ for (const [key, text] of Object.entries(source.entries)) {
17
+ const existing = merged.get(key);
18
+ if (existing) {
19
+ throw new Error(`copy key "${key}" is declared twice — by ${existing.file} and by ${source.file}. Two features cannot own the same key; prefix each catalog with its own feature name.`);
20
+ }
21
+ merged.set(key, { text, file: source.file });
22
+ }
23
+ }
24
+ return merged;
25
+ }
26
+ //# sourceMappingURL=merge-copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-copy.js","sourceRoot":"","sources":["../../../src/copy/lib/merge-copy.ts"],"names":[],"mappings":"AAkCA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,OAA8B;IACtD,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAClD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CACb,aAAa,GAAG,4BAA4B,QAAQ,CAAC,IAAI,WAAW,MAAM,CAAC,IAAI,wFAAwF,CACxK,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /** The interpolation names and malformed brace tokens authored in one phrase. */
2
+ export type PlaceholderSyntax = {
3
+ readonly names: ReadonlySet<string>;
4
+ readonly malformed: readonly string[];
5
+ };
6
+ /**
7
+ * Read `{name}` slots while retaining malformed brace text for an actionable
8
+ * authoring error. Placeholder names are code identifiers, not translated
9
+ * prose, so their grammar stays deliberately ASCII and stable across locales.
10
+ */
11
+ export declare function inspectPlaceholderSyntax(phrase: string): PlaceholderSyntax;
12
+ //# sourceMappingURL=placeholder-syntax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placeholder-syntax.d.ts","sourceRoot":"","sources":["../../../src/copy/lib/placeholder-syntax.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC,CAAC;AAIF;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CA8B1E"}
@@ -0,0 +1,36 @@
1
+ const PLACEHOLDER_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
2
+ /**
3
+ * Read `{name}` slots while retaining malformed brace text for an actionable
4
+ * authoring error. Placeholder names are code identifiers, not translated
5
+ * prose, so their grammar stays deliberately ASCII and stable across locales.
6
+ */
7
+ export function inspectPlaceholderSyntax(phrase) {
8
+ const names = new Set();
9
+ const malformed = [];
10
+ let cursor = 0;
11
+ while (cursor < phrase.length) {
12
+ const opening = phrase.indexOf("{", cursor);
13
+ const closing = phrase.indexOf("}", cursor);
14
+ if (closing !== -1 && (opening === -1 || closing < opening)) {
15
+ malformed.push("}");
16
+ cursor = closing + 1;
17
+ continue;
18
+ }
19
+ if (opening === -1)
20
+ break;
21
+ const end = phrase.indexOf("}", opening + 1);
22
+ if (end === -1) {
23
+ malformed.push(phrase.slice(opening));
24
+ break;
25
+ }
26
+ const token = phrase.slice(opening, end + 1);
27
+ const name = phrase.slice(opening + 1, end);
28
+ if (PLACEHOLDER_NAME.test(name))
29
+ names.add(name);
30
+ else
31
+ malformed.push(token);
32
+ cursor = end + 1;
33
+ }
34
+ return { names, malformed };
35
+ }
36
+ //# sourceMappingURL=placeholder-syntax.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placeholder-syntax.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,CAAC;YAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;;YAC5C,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { MergedCopy } from "./merge-copy.js";
2
+ /**
3
+ * Words a product refuses on its own customer surfaces — the shape, not the
4
+ * words.
5
+ *
6
+ * A refused word is the wrong name for something the product ships, and the
7
+ * correction is a sentence rather than a swap.
8
+ * Which words those are is the product's business, so only the three kinds of refusal live here.
9
+ */
10
+ /** One catalog phrase that uses an internal noun on a customer surface. */
11
+ export type ProductVocabularyViolation = {
12
+ readonly key: string;
13
+ readonly file: string;
14
+ readonly locale: string;
15
+ readonly found: string;
16
+ readonly guidance: string;
17
+ };
18
+ /**
19
+ * One refused word, every spelling it takes, and what to write instead.
20
+ *
21
+ * Three kinds, because a refusal is rarely unconditional:
22
+ * - plain — the word is wrong wherever it appears;
23
+ * - `rightAfter` — the word is right in one compound and wrong alone, so the
24
+ * word before it decides (`work assignment` against `role assignment`);
25
+ * - `onlyAsAName` — the word is ordinary English and only wrong when it names
26
+ * a screen (`people with access` against a page called `People`).
27
+ *
28
+ * Matching is whole-word and, apart from `onlyAsAName`, case-insensitive; a
29
+ * space inside a spelling matches any run of whitespace.
30
+ */
31
+ export type RefusedWord = {
32
+ readonly words: readonly string[];
33
+ readonly guidance: string;
34
+ readonly rightAfter?: string;
35
+ readonly onlyAsAName?: true;
36
+ };
37
+ export type ProductVocabulary = readonly RefusedWord[];
38
+ /** Declare a product's refused words, exactly as `defineCopy` and `defineGlossary`. */
39
+ export declare function defineProductVocabulary<const T extends ProductVocabulary>(vocabulary: T): T;
40
+ /** Find customer-facing nouns that conflict with a product's settled vocabulary. */
41
+ export declare function checkProductVocabulary(merged: MergedCopy, vocabulary: ProductVocabulary): readonly ProductVocabularyViolation[];
42
+ //# sourceMappingURL=product-vocabulary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-vocabulary.d.ts","sourceRoot":"","sources":["../../../src/copy/lib/product-vocabulary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,SAAS,WAAW,EAAE,CAAC;AAEvD,uFAAuF;AACvF,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,CAAC,SAAS,iBAAiB,EACvE,UAAU,EAAE,CAAC,GACZ,CAAC,CAEH;AA0JD,oFAAoF;AACpF,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,iBAAiB,GAC5B,SAAS,0BAA0B,EAAE,CAavC"}
@@ -0,0 +1,126 @@
1
+ /** Declare a product's refused words, exactly as `defineCopy` and `defineGlossary`. */
2
+ export function defineProductVocabulary(vocabulary) {
3
+ return vocabulary;
4
+ }
5
+ /** Key segments that mean "this phrase NAMES something" rather than says it. */
6
+ const SURFACE_NAME_SEGMENTS = new Set([
7
+ "action",
8
+ "affordance",
9
+ "button",
10
+ "column",
11
+ "heading",
12
+ "label",
13
+ "menu",
14
+ "nav",
15
+ "tab",
16
+ "title",
17
+ ]);
18
+ const UNICODE_WORD_START = "(?:^|[^\\p{L}\\p{N}_])";
19
+ const UNICODE_WORD_END = "(?=$|[^\\p{L}\\p{N}_])";
20
+ const NAMES_A_SURFACE_AFTER = /^\s+(?:area|page|screen|section)\b/iu;
21
+ function escaped(word) {
22
+ return word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23
+ }
24
+ /**
25
+ * Every spelling as one alternation, longest spelling still reachable.
26
+ *
27
+ * `set` before `sets` would win at the same position, but the whole-word
28
+ * lookahead refuses the shorter one and the regex falls through to the longer,
29
+ * so the order the product wrote them in does not matter.
30
+ */
31
+ function anySpellingOf(words) {
32
+ return words.map((word) => escaped(word).replace(/\s+/g, "\\s+")).join("|");
33
+ }
34
+ function firstWholeWordMatch(phrase, spellings) {
35
+ const match = new RegExp(`${UNICODE_WORD_START}(${spellings})${UNICODE_WORD_END}`, "iu").exec(phrase);
36
+ return match?.[1];
37
+ }
38
+ function isSurfaceNameKey(key) {
39
+ const segments = key.split(".");
40
+ const last = segments.at(-1);
41
+ return (segments.some((segment) => SURFACE_NAME_SEGMENTS.has(segment)) ||
42
+ (last !== undefined && /(?:heading|label|title)$/i.test(last)));
43
+ }
44
+ /** Where the captured word starts in the phrase, past the boundary character. */
45
+ function matchStart(match, found) {
46
+ return match.index + match[0].lastIndexOf(found);
47
+ }
48
+ /** The first use of the word that is NOT part of the compound it belongs to. */
49
+ function firstUseOutside(phrase, spellings, compoundStart) {
50
+ const uses = new RegExp(`${UNICODE_WORD_START}(${spellings})${UNICODE_WORD_END}`, "giu");
51
+ for (const match of phrase.matchAll(uses)) {
52
+ const found = match[1];
53
+ if (found === undefined)
54
+ continue;
55
+ const before = phrase.slice(0, matchStart(match, found));
56
+ const isCompound = new RegExp(`${UNICODE_WORD_START}${escaped(compoundStart)}\\s+$`, "iu").test(before);
57
+ if (!isCompound)
58
+ return found;
59
+ }
60
+ return undefined;
61
+ }
62
+ /** `people` becomes `People` — the one spelling that can be naming something. */
63
+ function asAName(word) {
64
+ const [first] = word;
65
+ return first === undefined
66
+ ? word
67
+ : first.toLocaleUpperCase("en") + word.slice(1);
68
+ }
69
+ /**
70
+ * The first use of the word AS A NAME: capitalized mid-phrase, or opening a
71
+ * phrase that goes on to say area, page, screen or section.
72
+ *
73
+ * A phrase starts with a capital whatever it means, so position zero alone
74
+ * proves nothing — that is the whole reason this is not a plain match.
75
+ */
76
+ function firstUseAsAName(phrase, words) {
77
+ const names = new RegExp(`${UNICODE_WORD_START}(${anySpellingOf(words.map(asAName))})${UNICODE_WORD_END}`, "gu");
78
+ for (const match of phrase.matchAll(names)) {
79
+ const found = match[1];
80
+ if (found === undefined)
81
+ continue;
82
+ const start = matchStart(match, found);
83
+ if (start > 0)
84
+ return found;
85
+ if (NAMES_A_SURFACE_AFTER.test(phrase.slice(start + found.length))) {
86
+ return found;
87
+ }
88
+ }
89
+ return undefined;
90
+ }
91
+ function foundIn(key, phrase, refused) {
92
+ const spellings = anySpellingOf(refused.words);
93
+ if (refused.onlyAsAName === true && !isSurfaceNameKey(key)) {
94
+ return firstUseAsAName(phrase, refused.words);
95
+ }
96
+ if (refused.rightAfter !== undefined) {
97
+ return firstUseOutside(phrase, spellings, refused.rightAfter);
98
+ }
99
+ return firstWholeWordMatch(phrase, spellings);
100
+ }
101
+ function findingsFor(key, phrase, vocabulary) {
102
+ const findings = [];
103
+ for (const refused of vocabulary) {
104
+ const found = foundIn(key, phrase, refused);
105
+ if (found !== undefined) {
106
+ findings.push({ found, guidance: refused.guidance });
107
+ }
108
+ }
109
+ return findings;
110
+ }
111
+ /** Find customer-facing nouns that conflict with a product's settled vocabulary. */
112
+ export function checkProductVocabulary(merged, vocabulary) {
113
+ const violations = [];
114
+ for (const [key, entry] of merged) {
115
+ for (const finding of findingsFor(key, entry.text.en, vocabulary)) {
116
+ violations.push({
117
+ key,
118
+ file: entry.file,
119
+ locale: "en",
120
+ ...finding,
121
+ });
122
+ }
123
+ }
124
+ return violations;
125
+ }
126
+ //# sourceMappingURL=product-vocabulary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-vocabulary.js","sourceRoot":"","sources":["../../../src/copy/lib/product-vocabulary.ts"],"names":[],"mappings":"AA0CA,uFAAuF;AACvF,MAAM,UAAU,uBAAuB,CACrC,UAAa;IAEb,OAAO,UAAU,CAAC;AACpB,CAAC;AAOD,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,QAAQ;IACR,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,OAAO;IACP,MAAM;IACN,KAAK;IACL,KAAK;IACL,OAAO;CACR,CAAC,CAAC;AACH,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;AACpD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,qBAAqB,GAAG,sCAAsC,CAAC;AAErE,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,KAAwB;IAC7C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAAc,EACd,SAAiB;IAEjB,MAAM,KAAK,GAAG,IAAI,MAAM,CACtB,GAAG,kBAAkB,IAAI,SAAS,IAAI,gBAAgB,EAAE,EACxD,IAAI,CACL,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACf,OAAO,KAAK,EAAE,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0,0 +1,37 @@
1
+ import { type Locale } from "./localized-text.js";
2
+ /**
3
+ * Which language a reader gets from signals in priority order.
4
+ *
5
+ * A reader's language is a property of the READER, not of the tenant they are
6
+ * looking at — a bilingual operator working two organizations would otherwise
7
+ * change language by changing workspace. `organizations.locale` and
8
+ * `facilities.locale` exist in the schema and nothing reads them; that is
9
+ * deliberate and recorded, not an oversight.
10
+ *
11
+ * `preferred` is the seam the identity-owned User Settings document arrives
12
+ * through. A saved locale wins; null means Automatic and follows the browser.
13
+ * Nothing here reads or writes browser storage, because a preference stored in
14
+ * two places is a preference that disagrees with itself.
15
+ */
16
+ /** The language every reader gets when no signal names a supported one. */
17
+ export declare const DEFAULT_LOCALE: Locale;
18
+ export type LocaleSignals = {
19
+ /** The reader's saved choice; null means Automatic/browser fallback. */
20
+ readonly preferred?: string | null | undefined;
21
+ /** What the browser says the reader reads, most-wanted first. */
22
+ readonly browserLanguages?: readonly string[] | undefined;
23
+ };
24
+ /**
25
+ * The supported locale a language tag names, or nothing.
26
+ *
27
+ * Region-tolerant by necessity: browsers send `es-MX`, `es-419` and `en-GB`,
28
+ * and a reader who asked for Mexican Spanish wants Spanish rather than English.
29
+ * The supported list is a parameter so this can be proven against a second
30
+ * locale today, before one ships.
31
+ */
32
+ export declare function matchSupportedLocale<const TLocale extends string>(tag: string, supported: readonly TLocale[]): TLocale | undefined;
33
+ /** Saved choice, then the browser's list in order, then the given fallback. */
34
+ export declare function resolveLocaleFromSignals<const TLocale extends string>(signals: LocaleSignals, supported: readonly TLocale[], fallback: TLocale): TLocale;
35
+ /** Saved choice, then the browser's list in order, then English. */
36
+ export declare function resolveInitialLocale(signals: LocaleSignals): Locale;
37
+ //# sourceMappingURL=resolve-initial-locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-initial-locale.d.ts","sourceRoot":"","sources":["../../../src/copy/lib/resolve-initial-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAErE;;;;;;;;;;;;;GAaG;AAEH,2EAA2E;AAC3E,eAAO,MAAM,cAAc,EAAE,MAA6B,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,iEAAiE;IACjE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAC3D,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,OAAO,SAAS,MAAM,EAC/D,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,OAAO,EAAE,GAC5B,OAAO,GAAG,SAAS,CAOrB;AAED,+EAA+E;AAC/E,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,OAAO,SAAS,MAAM,EACnE,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,SAAS,OAAO,EAAE,EAC7B,QAAQ,EAAE,OAAO,GAChB,OAAO,CAYT;AAED,oEAAoE;AACpE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAEnE"}
@@ -0,0 +1,55 @@
1
+ import { SUPPORTED_LOCALES } from "./localized-text.js";
2
+ /**
3
+ * Which language a reader gets from signals in priority order.
4
+ *
5
+ * A reader's language is a property of the READER, not of the tenant they are
6
+ * looking at — a bilingual operator working two organizations would otherwise
7
+ * change language by changing workspace. `organizations.locale` and
8
+ * `facilities.locale` exist in the schema and nothing reads them; that is
9
+ * deliberate and recorded, not an oversight.
10
+ *
11
+ * `preferred` is the seam the identity-owned User Settings document arrives
12
+ * through. A saved locale wins; null means Automatic and follows the browser.
13
+ * Nothing here reads or writes browser storage, because a preference stored in
14
+ * two places is a preference that disagrees with itself.
15
+ */
16
+ /** The language every reader gets when no signal names a supported one. */
17
+ export const DEFAULT_LOCALE = SUPPORTED_LOCALES[0];
18
+ /**
19
+ * The supported locale a language tag names, or nothing.
20
+ *
21
+ * Region-tolerant by necessity: browsers send `es-MX`, `es-419` and `en-GB`,
22
+ * and a reader who asked for Mexican Spanish wants Spanish rather than English.
23
+ * The supported list is a parameter so this can be proven against a second
24
+ * locale today, before one ships.
25
+ */
26
+ export function matchSupportedLocale(tag, supported) {
27
+ const normalized = tag.trim().toLowerCase();
28
+ if (normalized === "")
29
+ return undefined;
30
+ const exact = supported.find((locale) => locale.toLowerCase() === normalized);
31
+ if (exact !== undefined)
32
+ return exact;
33
+ const primarySubtag = normalized.split("-")[0];
34
+ return supported.find((locale) => locale.toLowerCase() === primarySubtag);
35
+ }
36
+ /** Saved choice, then the browser's list in order, then the given fallback. */
37
+ export function resolveLocaleFromSignals(signals, supported, fallback) {
38
+ const candidates = [
39
+ ...(signals.preferred === undefined || signals.preferred === null
40
+ ? []
41
+ : [signals.preferred]),
42
+ ...(signals.browserLanguages ?? []),
43
+ ];
44
+ for (const candidate of candidates) {
45
+ const matched = matchSupportedLocale(candidate, supported);
46
+ if (matched !== undefined)
47
+ return matched;
48
+ }
49
+ return fallback;
50
+ }
51
+ /** Saved choice, then the browser's list in order, then English. */
52
+ export function resolveInitialLocale(signals) {
53
+ return resolveLocaleFromSignals(signals, SUPPORTED_LOCALES, DEFAULT_LOCALE);
54
+ }
55
+ //# sourceMappingURL=resolve-initial-locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-initial-locale.js","sourceRoot":"","sources":["../../../src/copy/lib/resolve-initial-locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,qBAAqB,CAAC;AAErE;;;;;;;;;;;;;GAaG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAW,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAS3D;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAW,EACX,SAA6B;IAE7B,MAAM,UAAU,GAAG,GAAG,CAAC,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from "./copy-descriptor.js";
2
+ import { type CopyCatalog, type Locale } from "./localized-text.js";
3
+ /** The plural categories a catalog may spell, as key suffixes. */
4
+ export type PluralCategory = "zero" | "one" | "two" | "few" | "many" | "other";
5
+ /**
6
+ * The base key behind a plural pair — `orders.holders` from
7
+ * `orders.holders_one` / `orders.holders_other`.
8
+ */
9
+ export type PluralBaseKey<Key extends string> = Key extends `${infer Base}_${PluralCategory}` ? Base : never;
10
+ /**
11
+ * Every key a caller may name: the ones the catalog declares, plus the base of
12
+ * each plural pair. A base key exists only because its suffixed forms do, so
13
+ * the typed-key guarantee survives the plural idiom.
14
+ */
15
+ export type CopyKey<Catalog extends CopyCatalog> = (keyof Catalog & string) | PluralBaseKey<keyof Catalog & string>;
16
+ /** Resolve a key or a descriptor against one catalog, in one language. */
17
+ export declare function translate(catalog: CopyCatalog, locale: Locale, keyOrDescriptor: string | CopyDescriptor, vars?: CopyVars, count?: number): string;
18
+ //# sourceMappingURL=translate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../../src/copy/lib/translate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,QAAQ,EAEd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EAEZ,MAAM,qBAAqB,CAAC;AAwB7B,kEAAkE;AAClE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/E;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,GAAG,SAAS,MAAM,IAC1C,GAAG,SAAS,GAAG,MAAM,IAAI,IAAI,cAAc,EAAE,GAAG,IAAI,GAAG,KAAK,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,OAAO,CAAC,OAAO,SAAS,WAAW,IAC7C,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC;AAsGnE,0EAA0E;AAC1E,wBAAgB,SAAS,CACvB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GAAG,cAAc,EACxC,IAAI,CAAC,EAAE,QAAQ,EACf,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAKR"}
@@ -0,0 +1,90 @@
1
+ import { copy, isCopyDescriptor, } from "./copy-descriptor.js";
2
+ import { formatInteger, formatNumber } from "./locale-formatting.js";
3
+ import { resolveLocalizedText, } from "./localized-text.js";
4
+ import { inspectPlaceholderSyntax } from "./placeholder-syntax.js";
5
+ /**
6
+ * Turn a key into the sentence a reader sees.
7
+ *
8
+ * Three behaviors, and one refusal.
9
+ *
10
+ * **Interpolation** fills `{name}` slots from `vars`. **Plurals** pick
11
+ * `<key>_one` / `<key>_other` through `Intl.PluralRules`, which is a browser
12
+ * builtin and knows each language's own categories — Spanish has a `many` that
13
+ * English does not, and the catalog can answer it without this file learning
14
+ * grammar. **Nesting** resolves a `vars` value that is itself a descriptor
15
+ * depth-first, so a sentence can carry an independently pluralized fragment.
16
+ *
17
+ * The refusal: a key the catalog does not declare THROWS. Rendering the key
18
+ * would put `orders.page.titel` on a customer's screen and pass every test that
19
+ * did not happen to read that string. Typed keys make this unreachable from
20
+ * TypeScript; the throw covers the cases types cannot see, such as a plural
21
+ * form the catalog forgot.
22
+ */
23
+ const PLACEHOLDER = /\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
24
+ function selectPluralKey(catalog, locale, key, count) {
25
+ const category = new Intl.PluralRules(locale).select(count);
26
+ const candidates = [`${key}_${category}`, `${key}_other`, key];
27
+ const declared = candidates.find((candidate) => catalog[candidate] !== undefined);
28
+ if (declared === undefined) {
29
+ throw new Error(`copy key "${key}" pluralizes but the catalog declares neither "${key}_${category}" nor "${key}_other"`);
30
+ }
31
+ return declared;
32
+ }
33
+ function phraseFor(catalog, locale, descriptor) {
34
+ const key = descriptor.count === undefined
35
+ ? descriptor.key
36
+ : selectPluralKey(catalog, locale, descriptor.key, descriptor.count);
37
+ const text = catalog[key];
38
+ if (text === undefined) {
39
+ throw new Error(`copy key "${key}" is not declared in this catalog — a key is never rendered as itself`);
40
+ }
41
+ return resolveLocalizedText(text, locale);
42
+ }
43
+ function resolveVars(catalog, locale, descriptor) {
44
+ const resolved = {};
45
+ // A pluralized sentence almost always says its own number, so `{count}`
46
+ // fills itself; an explicit var of the same name still wins.
47
+ if (descriptor.count !== undefined) {
48
+ resolved["count"] = formatInteger(descriptor.count, locale);
49
+ }
50
+ for (const [name, copyVariable] of Object.entries(descriptor.vars ?? {})) {
51
+ resolved[name] = isCopyDescriptor(copyVariable)
52
+ ? render(catalog, locale, copyVariable)
53
+ : typeof copyVariable === "number"
54
+ ? formatNumber(copyVariable, locale, { maximumFractionDigits: 20 })
55
+ : copyVariable;
56
+ }
57
+ return resolved;
58
+ }
59
+ function interpolate(phrase, vars, key) {
60
+ const [malformed] = inspectPlaceholderSyntax(phrase).malformed;
61
+ if (malformed !== undefined) {
62
+ throw new Error(`copy key "${key}" contains malformed placeholder ${malformed}; use {name} with letters, numbers, or underscores`);
63
+ }
64
+ let filled = "";
65
+ let cursor = 0;
66
+ for (const match of phrase.matchAll(PLACEHOLDER)) {
67
+ const name = match[1];
68
+ if (name === undefined)
69
+ continue;
70
+ const replacement = vars[name];
71
+ if (replacement === undefined) {
72
+ throw new Error(`copy key "${key}" interpolates {${name}} and nothing was given for it`);
73
+ }
74
+ filled += phrase.slice(cursor, match.index) + replacement;
75
+ cursor = match.index + match[0].length;
76
+ }
77
+ return filled + phrase.slice(cursor);
78
+ }
79
+ function render(catalog, locale, descriptor) {
80
+ const phrase = phraseFor(catalog, locale, descriptor);
81
+ return interpolate(phrase, resolveVars(catalog, locale, descriptor), descriptor.key);
82
+ }
83
+ /** Resolve a key or a descriptor against one catalog, in one language. */
84
+ export function translate(catalog, locale, keyOrDescriptor, vars, count) {
85
+ const descriptor = isCopyDescriptor(keyOrDescriptor)
86
+ ? keyOrDescriptor
87
+ : copy(keyOrDescriptor, vars, count);
88
+ return render(catalog, locale, descriptor);
89
+ }
90
+ //# sourceMappingURL=translate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.js","sourceRoot":"","sources":["../../../src/copy/lib/translate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAGJ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAGL,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,GAAG,+BAA+B,CAAC;AAoBpD,SAAS,eAAe,CACtB,OAAoB,EACpB,MAAc,EACd,GAAW,EACX,KAAa;IAEb,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,CAAC,GAAG,GAAG,IAAI,QAAQ,EAAE,EAAE,GAAG,GAAG,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAC9B,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,SAAS,CAChD,CAAC;IACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,aAAa,GAAG,kDAAkD,GAAG,IAAI,QAAQ,UAAU,GAAG,SAAS,CACxG,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,SAAS,CAChB,OAAoB,EACpB,MAAc,EACd,UAA0B;IAE1B,MAAM,GAAG,GACP,UAA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d,eAAwC,EACxC,IAAe,EACf,KAAc;IAEd,MAAM,UAAU,GAAG,gBAAgB,CAAC,eAAe,CAAC;QAClD,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type ExplicitCurrencyFormatOptions, type ExplicitDateTimeFormatOptions, type ListFormatOptions, type RelativeTimeFormatUnit } from "./locale-formatting.js";
2
+ /** Locale-bound presentation functions for a React render tree. */
3
+ export type LocaleFormatting = {
4
+ readonly formatDateTime: (value: Date | number | string, options: ExplicitDateTimeFormatOptions) => string;
5
+ readonly formatNumber: (value: number | bigint, options?: Intl.NumberFormatOptions) => string;
6
+ readonly formatInteger: (value: number | bigint) => string;
7
+ readonly formatExactDecimal: (value: string) => string;
8
+ readonly formatCurrency: (value: number | bigint, currency: string, options?: ExplicitCurrencyFormatOptions) => string;
9
+ readonly formatList: (values: readonly string[], options?: ListFormatOptions) => string;
10
+ readonly formatRelativeTime: (value: number, unit: RelativeTimeFormatUnit) => string;
11
+ readonly formatTimeZoneName: (timeZone: string, at: Date | number | string) => string | null;
12
+ readonly selectOrdinalCategory: (value: number) => Intl.LDMLPluralRule;
13
+ readonly compareHumanLabels: (left: string, right: string) => number;
14
+ readonly humanTextIncludes: (value: string, query: string) => boolean;
15
+ };
16
+ /** Bind every formatter to the same reader locale as the copy hooks. */
17
+ export declare function useLocaleFormatting(): LocaleFormatting;
18
+ //# sourceMappingURL=use-locale-formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-locale-formatting.d.ts","sourceRoot":"","sources":["../../../src/copy/lib/use-locale-formatting.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAUlC,KAAK,iBAAiB,EACtB,KAAK,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,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CACvE,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,mBAAmB,IAAI,gBAAgB,CAyBtD"}
@@ -0,0 +1,21 @@
1
+ import { useMemo } from "react";
2
+ import { compareHumanLabels, formatCurrency, formatDateTime, formatExactDecimal, formatInteger, formatList, formatNumber, formatRelativeTime, formatTimeZoneName, humanTextIncludes, selectOrdinalCategory, } from "./locale-formatting.js";
3
+ import { useLocale } from "./locale-provider.js";
4
+ /** Bind every formatter to the same reader locale as the copy hooks. */
5
+ export function useLocaleFormatting() {
6
+ const locale = useLocale();
7
+ return useMemo(() => ({
8
+ formatDateTime: (value, options) => formatDateTime(value, locale, options),
9
+ formatNumber: (value, options) => formatNumber(value, locale, options),
10
+ formatInteger: (value) => formatInteger(value, locale),
11
+ formatExactDecimal: (value) => formatExactDecimal(value, locale),
12
+ formatCurrency: (value, currency, options) => formatCurrency(value, locale, currency, options),
13
+ formatList: (values, options) => formatList(values, locale, options),
14
+ formatRelativeTime: (value, unit) => formatRelativeTime(value, unit, locale),
15
+ formatTimeZoneName: (timeZone, at) => formatTimeZoneName(timeZone, locale, at),
16
+ selectOrdinalCategory: (value) => selectOrdinalCategory(value, locale),
17
+ compareHumanLabels: (left, right) => compareHumanLabels(left, right, locale),
18
+ humanTextIncludes: (value, query) => humanTextIncludes(value, query, locale),
19
+ }), [locale]);
20
+ }
21
+ //# sourceMappingURL=use-locale-formatting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-locale-formatting.js","sourceRoot":"","sources":["../../../src/copy/lib/use-locale-formatting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EACL,kBAAkB,EAGlB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAGjB,qB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