@colixsystems/widget-sdk 0.361.0 → 0.363.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.
package/dist/contract.js CHANGED
@@ -9,7 +9,7 @@
9
9
  // the compiler's generated layout `elevationStyles`, and widgets reading
10
10
  // `useTheme().elevation` — so a widget shadow and a container shadow match.
11
11
  import { COMPONENT_PROPS, COMPONENT_PROPS_ERROR_PREFIX, componentPropsError, tabItemKey } from "./component-props.js";
12
- import { COMPONENT_TEXTS, fillSdkText, textInLanguage } from "./sdk-texts.js";
12
+ import { COMPONENT_TEXTS, LANGUAGE_ALIASES, fillSdkText, localizedText } from "./sdk-texts.js";
13
13
  import { formatDateForDisplay } from "./date-label.js";
14
14
 
15
15
  const ELEVATION = Object.freeze({
@@ -4068,7 +4068,7 @@ const PRIMITIVES = [
4068
4068
  {
4069
4069
  name: "Select",
4070
4070
  description:
4071
- 'Themed picker for ONE value of a known list, or several with `multiple`. `<Select label="Status" value={status} onValueChange={setStatus} options={[{ value: "open", label: "Open" }, { value: "done", label: "Done" }]} placeholder="Choose a status" />` — the default way to let the user pick ONE of a known list. The trigger is the app\'s input field (Design > Components > Inputs) showing the chosen label; pressing it opens the options at SCREEN level, in a sheet painted from Design > Components > Dropdown menus, so no card or scroll container can clip them, and a long list scrolls inside the sheet. The trigger is a button that opens a dialog (expanded state included) and each option carries the option role and its selected state on both hosts; the list around them is a listbox on the web only. On the web Enter, Space or an arrow key opens it, the arrow keys, Home and End move between options, Enter or Space chooses, Escape closes, and focus returns to the trigger; on Android the back button closes it. Props: `options` (`[{ value, label, disabled?, testID? }]`, `value` a string or number, unique), `value`, `onValueChange(value, option)`, `placeholder` (default "Select"; every default text here is in the app\'s language, English or Swedish), `title` (the sheet\'s heading; defaults to a text `label`), `emptyText` (default "No options"), `label`, `helper`, `error`, `disabled`, `accessibilityLabel`, `closeAccessibilityLabel`, `background` / `textColor` / `borderColor` / `radius` / `height` to override one field, `style` (the trigger), `containerStyle`, `testID`; any other prop lands on the trigger. Use it rather than a dropdown of your own; when the request needs options it cannot show (colour swatches, photos with two-line captions), put a small swatch or photo picker in a `<Popover>` at its button, or a long or full-screen option list in a `<Modal>` (an emoji choice is `<EmojiPicker>`) — never an absolutely positioned list, which the widget\'s container clips on both hosts. MULTIPLE: `<Select multiple label="Tags" values={tags} onValuesChange={setTags} options={tagOptions} />` — the default way to let the user pick SEVERAL of a known list. The same trigger and sheet; each option shows a tick box and toggles, the listbox is multiselectable on the web, and the sheet\'s Done button commits the choice through `onValuesChange(values, options)` (values in listed order, called only when they changed); closing the sheet any other way (backdrop, Escape, Android back) keeps the previous choice. Space toggles the focused option on the web. The trigger shows the picked labels as small chips while they fit on its one line, otherwise "N selected" (`selectedCountText(count)` to translate it), and `placeholder` while nothing is picked; `doneText` (default "Done") names the button. In this mode `value` / `onValueChange` are ignored. A handful of options always shown inline is a `<ChipGroup selection="multiple">` of `<Chip>`s instead. SEARCHABLE: a long list the user should type to narrow. `searchable` filters the given `options` by label as they type; `onSearch(query)` hands you the trimmed query when the sheet opens (\"\") and once typing pauses (`searchDebounceMs`, default 250), and you answer with new `options` and `loading` meanwhile (`optionsError` when it failed); or pass `options` as an async function of the query and Select fetches, keeping only the latest answer. The sheet then leads with the app\'s search field (Design > Components > Search fields), shows a spinner while loading, `noResultsText` (default \"No results\") when a query finds nothing and `loadErrorText` on failure, and its rows take the Lists row height and padding when the theme sets them. It remembers the label of every option it has shown; pass `selectedOptions` for a saved value the first page may not hold, or the trigger shows the placeholder. An option may carry `leading` (an `<Avatar>`, an icon) drawn before its label. Picking people, groups or a table\'s records is `<PeoplePicker>`, which does all of this for you.',
4071
+ 'Themed picker for ONE value of a known list, or several with `multiple`. `<Select label="Status" value={status} onValueChange={setStatus} options={[{ value: "open", label: "Open" }, { value: "done", label: "Done" }]} placeholder="Choose a status" />` — the default way to let the user pick ONE of a known list. The trigger is the app\'s input field (Design > Components > Inputs) showing the chosen label; pressing it opens the options at SCREEN level, in a sheet painted from Design > Components > Dropdown menus, so no card or scroll container can clip them, and a long list scrolls inside the sheet. The trigger is a button that opens a dialog (expanded state included) and each option carries the option role and its selected state on both hosts; the list around them is a listbox on the web only. On the web Enter, Space or an arrow key opens it, the arrow keys, Home and End move between options, Enter or Space chooses, Escape closes, and focus returns to the trigger; on Android the back button closes it. Props: `options` (`[{ value, label, disabled?, testID? }]`, `value` a string or number, unique), `value`, `onValueChange(value, option)`, `placeholder` (default "Select"; every default text here is in the app\'s language), `title` (the sheet\'s heading; defaults to a text `label`), `emptyText` (default "No options"), `label`, `helper`, `error`, `disabled`, `accessibilityLabel`, `closeAccessibilityLabel`, `background` / `textColor` / `borderColor` / `radius` / `height` to override one field, `style` (the trigger), `containerStyle`, `testID`; any other prop lands on the trigger. Use it rather than a dropdown of your own; when the request needs options it cannot show (colour swatches, photos with two-line captions), put a small swatch or photo picker in a `<Popover>` at its button, or a long or full-screen option list in a `<Modal>` (an emoji choice is `<EmojiPicker>`) — never an absolutely positioned list, which the widget\'s container clips on both hosts. MULTIPLE: `<Select multiple label="Tags" values={tags} onValuesChange={setTags} options={tagOptions} />` — the default way to let the user pick SEVERAL of a known list. The same trigger and sheet; each option shows a tick box and toggles, the listbox is multiselectable on the web, and the sheet\'s Done button commits the choice through `onValuesChange(values, options)` (values in listed order, called only when they changed); closing the sheet any other way (backdrop, Escape, Android back) keeps the previous choice. Space toggles the focused option on the web. The trigger shows the picked labels as small chips while they fit on its one line, otherwise "N selected" (`selectedCountText(count)` to translate it), and `placeholder` while nothing is picked; `doneText` (default "Done") names the button. In this mode `value` / `onValueChange` are ignored. A handful of options always shown inline is a `<ChipGroup selection="multiple">` of `<Chip>`s instead. SEARCHABLE: a long list the user should type to narrow. `searchable` filters the given `options` by label as they type; `onSearch(query)` hands you the trimmed query when the sheet opens (\"\") and once typing pauses (`searchDebounceMs`, default 250), and you answer with new `options` and `loading` meanwhile (`optionsError` when it failed); or pass `options` as an async function of the query and Select fetches, keeping only the latest answer. The sheet then leads with the app\'s search field (Design > Components > Search fields), shows a spinner while loading, `noResultsText` (default \"No results\") when a query finds nothing and `loadErrorText` on failure, and its rows take the Lists row height and padding when the theme sets them. It remembers the label of every option it has shown; pass `selectedOptions` for a saved value the first page may not hold, or the trigger shows the placeholder. An option may carry `leading` (an `<Avatar>`, an icon) drawn before its label. Picking people, groups or a table\'s records is `<PeoplePicker>`, which does all of this for you.',
4072
4072
  rnComponent: null,
4073
4073
  docsUrl: null,
4074
4074
  },
@@ -5616,33 +5616,235 @@ function sharedTranslationKey(key) {
5616
5616
  return `${SHARED_TRANSLATION_PREFIX}${key}`;
5617
5617
  }
5618
5618
 
5619
- // The predefined set. Map of bare key -> { en, sv }. Swedish is shipped by
5620
- // hand because a lone word machine-translates to the wrong sense ("Cancel" ->
5621
- // "Avboka"); other languages are translated in the Translations admin and
5622
- // every widget inherits them. Adding/removing a key is a CONTRACT change (it
5623
- // grows the dictionary every tenant gets), so the list lives with the contract
5624
- // and the seeder reads it from here — never a second copy.
5619
+ // The predefined set. Map of bare key -> its text in each of the nine app
5620
+ // languages, written by hand because a lone word machine-translates to the
5621
+ // wrong sense ("Cancel" -> "Avboka"). Outside the nine, a base language is
5622
+ // machine-translated at seeding and any other language gets no row, so it
5623
+ // reads the base.
5624
+ // Adding/removing a key is a CONTRACT change (it grows the dictionary every
5625
+ // tenant gets), so the list lives with the contract and the seeder reads it
5626
+ // from here — never a second copy.
5625
5627
  const SHARED_TRANSLATION_KEYS = Object.freeze({
5626
- submit: { en: "Submit", sv: "Skicka" },
5627
- cancel: { en: "Cancel", sv: "Avbryt" },
5628
- save: { en: "Save", sv: "Spara" },
5629
- delete: { en: "Delete", sv: "Ta bort" },
5630
- edit: { en: "Edit", sv: "Redigera" },
5631
- close: { en: "Close", sv: "Stäng" },
5632
- confirm: { en: "Confirm", sv: "Bekräfta" },
5633
- back: { en: "Back", sv: "Tillbaka" },
5634
- next: { en: "Next", sv: "Nästa" },
5635
- previous: { en: "Previous", sv: "Föregående" },
5636
- yes: { en: "Yes", sv: "Ja" },
5637
- no: { en: "No", sv: "Nej" },
5638
- ok: { en: "OK", sv: "OK" },
5639
- loading: { en: "Loading…", sv: "Laddar…" },
5640
- search: { en: "Search", sv: "Sök" },
5641
- no_results: { en: "No results", sv: "Inga resultat" },
5642
- required: { en: "Required", sv: "Obligatoriskt" },
5643
- retry: { en: "Retry", sv: "Försök igen" },
5644
- add: { en: "Add", sv: "Lägg till" },
5645
- remove: { en: "Remove", sv: "Ta bort" },
5628
+ submit: {
5629
+ en: "Submit",
5630
+ da: "Send",
5631
+ de: "Absenden",
5632
+ es: "Enviar",
5633
+ fi: "Lähetä",
5634
+ fr: "Envoyer",
5635
+ it: "Invia",
5636
+ nb: "Send",
5637
+ sv: "Skicka",
5638
+ },
5639
+ cancel: {
5640
+ en: "Cancel",
5641
+ da: "Annuller",
5642
+ de: "Abbrechen",
5643
+ es: "Cancelar",
5644
+ fi: "Peruuta",
5645
+ fr: "Annuler",
5646
+ it: "Annulla",
5647
+ nb: "Avbryt",
5648
+ sv: "Avbryt",
5649
+ },
5650
+ save: {
5651
+ en: "Save",
5652
+ da: "Gem",
5653
+ de: "Speichern",
5654
+ es: "Guardar",
5655
+ fi: "Tallenna",
5656
+ fr: "Enregistrer",
5657
+ it: "Salva",
5658
+ nb: "Lagre",
5659
+ sv: "Spara",
5660
+ },
5661
+ delete: {
5662
+ en: "Delete",
5663
+ da: "Slet",
5664
+ de: "Löschen",
5665
+ es: "Eliminar",
5666
+ fi: "Poista",
5667
+ fr: "Supprimer",
5668
+ it: "Elimina",
5669
+ nb: "Slett",
5670
+ sv: "Ta bort",
5671
+ },
5672
+ edit: {
5673
+ en: "Edit",
5674
+ da: "Rediger",
5675
+ de: "Bearbeiten",
5676
+ es: "Editar",
5677
+ fi: "Muokkaa",
5678
+ fr: "Modifier",
5679
+ it: "Modifica",
5680
+ nb: "Rediger",
5681
+ sv: "Redigera",
5682
+ },
5683
+ close: {
5684
+ en: "Close",
5685
+ da: "Luk",
5686
+ de: "Schließen",
5687
+ es: "Cerrar",
5688
+ fi: "Sulje",
5689
+ fr: "Fermer",
5690
+ it: "Chiudi",
5691
+ nb: "Lukk",
5692
+ sv: "Stäng",
5693
+ },
5694
+ confirm: {
5695
+ en: "Confirm",
5696
+ da: "Bekræft",
5697
+ de: "Bestätigen",
5698
+ es: "Confirmar",
5699
+ fi: "Vahvista",
5700
+ fr: "Confirmer",
5701
+ it: "Conferma",
5702
+ nb: "Bekreft",
5703
+ sv: "Bekräfta",
5704
+ },
5705
+ back: {
5706
+ en: "Back",
5707
+ da: "Tilbage",
5708
+ de: "Zurück",
5709
+ es: "Volver",
5710
+ fi: "Takaisin",
5711
+ fr: "Retour",
5712
+ it: "Indietro",
5713
+ nb: "Tilbake",
5714
+ sv: "Tillbaka",
5715
+ },
5716
+ next: {
5717
+ en: "Next",
5718
+ da: "Næste",
5719
+ de: "Weiter",
5720
+ es: "Siguiente",
5721
+ fi: "Seuraava",
5722
+ fr: "Suivant",
5723
+ it: "Avanti",
5724
+ nb: "Neste",
5725
+ sv: "Nästa",
5726
+ },
5727
+ previous: {
5728
+ en: "Previous",
5729
+ da: "Forrige",
5730
+ de: "Vorherige",
5731
+ es: "Anterior",
5732
+ fi: "Edellinen",
5733
+ fr: "Précédent",
5734
+ it: "Precedente",
5735
+ nb: "Forrige",
5736
+ sv: "Föregående",
5737
+ },
5738
+ yes: {
5739
+ en: "Yes",
5740
+ da: "Ja",
5741
+ de: "Ja",
5742
+ es: "Sí",
5743
+ fi: "Kyllä",
5744
+ fr: "Oui",
5745
+ it: "Sì",
5746
+ nb: "Ja",
5747
+ sv: "Ja",
5748
+ },
5749
+ no: {
5750
+ en: "No",
5751
+ da: "Nej",
5752
+ de: "Nein",
5753
+ es: "No",
5754
+ fi: "Ei",
5755
+ fr: "Non",
5756
+ it: "No",
5757
+ nb: "Nei",
5758
+ sv: "Nej",
5759
+ },
5760
+ ok: {
5761
+ en: "OK",
5762
+ da: "OK",
5763
+ de: "OK",
5764
+ es: "OK",
5765
+ fi: "OK",
5766
+ fr: "OK",
5767
+ it: "OK",
5768
+ nb: "OK",
5769
+ sv: "OK",
5770
+ },
5771
+ loading: {
5772
+ en: "Loading…",
5773
+ da: "Indlæser…",
5774
+ de: "Wird geladen…",
5775
+ es: "Cargando…",
5776
+ fi: "Ladataan…",
5777
+ fr: "Chargement…",
5778
+ it: "Caricamento…",
5779
+ nb: "Laster…",
5780
+ sv: "Laddar…",
5781
+ },
5782
+ search: {
5783
+ en: "Search",
5784
+ da: "Søg",
5785
+ de: "Suchen",
5786
+ es: "Buscar",
5787
+ fi: "Hae",
5788
+ fr: "Rechercher",
5789
+ it: "Cerca",
5790
+ nb: "Søk",
5791
+ sv: "Sök",
5792
+ },
5793
+ no_results: {
5794
+ en: "No results",
5795
+ da: "Ingen resultater",
5796
+ de: "Keine Ergebnisse",
5797
+ es: "Sin resultados",
5798
+ fi: "Ei tuloksia",
5799
+ fr: "Aucun résultat",
5800
+ it: "Nessun risultato",
5801
+ nb: "Ingen resultater",
5802
+ sv: "Inga resultat",
5803
+ },
5804
+ required: {
5805
+ en: "Required",
5806
+ da: "Påkrævet",
5807
+ de: "Erforderlich",
5808
+ es: "Obligatorio",
5809
+ fi: "Pakollinen",
5810
+ fr: "Obligatoire",
5811
+ it: "Obbligatorio",
5812
+ nb: "Obligatorisk",
5813
+ sv: "Obligatoriskt",
5814
+ },
5815
+ retry: {
5816
+ en: "Retry",
5817
+ da: "Prøv igen",
5818
+ de: "Erneut versuchen",
5819
+ es: "Reintentar",
5820
+ fi: "Yritä uudelleen",
5821
+ fr: "Réessayer",
5822
+ it: "Riprova",
5823
+ nb: "Prøv igjen",
5824
+ sv: "Försök igen",
5825
+ },
5826
+ add: {
5827
+ en: "Add",
5828
+ da: "Tilføj",
5829
+ de: "Hinzufügen",
5830
+ es: "Añadir",
5831
+ fi: "Lisää",
5832
+ fr: "Ajouter",
5833
+ it: "Aggiungi",
5834
+ nb: "Legg til",
5835
+ sv: "Lägg till",
5836
+ },
5837
+ remove: {
5838
+ en: "Remove",
5839
+ da: "Fjern",
5840
+ de: "Entfernen",
5841
+ es: "Quitar",
5842
+ fi: "Poista",
5843
+ fr: "Retirer",
5844
+ it: "Rimuovi",
5845
+ nb: "Fjern",
5846
+ sv: "Ta bort",
5847
+ },
5646
5848
  });
5647
5849
 
5648
5850
  // True when `key` is one of the predefined shared keys — the discriminator
@@ -5663,7 +5865,7 @@ const SDK_TEXTS = Object.freeze({ ...SHARED_TRANSLATION_KEYS, ...COMPONENT_TEXTS
5663
5865
  /** `key`'s built-in text in `locale`, English when that language ships none. */
5664
5866
  function sdkText(key, locale, values) {
5665
5867
  const entry = SDK_TEXTS[key];
5666
- return entry ? textInLanguage(entry, locale, values) : key;
5868
+ return entry ? localizedText(entry, locale, values) : key;
5667
5869
  }
5668
5870
 
5669
5871
  const CONTRACT = deepFreeze({
@@ -7275,7 +7477,11 @@ const CONTRACT = deepFreeze({
7275
7477
  // 1.297.0: behaviour (sc-16663) — `useBoundColumns` no longer binds a key
7276
7478
  // to the first free column of its `dataType`; a name that matches no
7277
7479
  // column is `missing`, as the Studio and preview binders already showed.
7278
- version: "1.297.0",
7480
+ // 1.298.0 (sc-18635): additive — `localizedText(entry, locale, values)`
7481
+ // reads a nine-language text table; `no` and `nn` read `nb`.
7482
+ // 1.299.0: behaviour (sc-18751) — the components' default texts and the
7483
+ // shared keys ship all nine app languages, not English and Swedish only.
7484
+ version: "1.299.0",
7279
7485
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7280
7486
  hooks: HOOKS,
7281
7487
  primitives: PRIMITIVES,
@@ -7884,5 +8090,7 @@ export {
7884
8090
  SDK_TEXTS,
7885
8091
  sdkText,
7886
8092
  fillSdkText,
8093
+ localizedText,
8094
+ LANGUAGE_ALIASES,
7887
8095
  formatDateForDisplay,
7888
8096
  };
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { normaliseMode, partsToDate } from "./datetimepicker-format.js";
5
5
  import { WEEK_LENGTH } from "./datetimepicker-calendar.js";
6
- import { COMPONENT_TEXTS, textInLanguage } from "./sdk-texts.js";
6
+ import { COMPONENT_TEXTS, localizedText } from "./sdk-texts.js";
7
7
 
8
8
  const ENGLISH_MONTHS = [
9
9
  "January", "February", "March", "April", "May", "June",
@@ -80,7 +80,7 @@ export function relativeNowLabel(locale, mode) {
80
80
  const text = new Intl.RelativeTimeFormat(locale || undefined, { numeric: "auto" }).format(0, unit);
81
81
  return capitalise(text, locale);
82
82
  } catch {
83
- return textInLanguage(COMPONENT_TEXTS[unit === "day" ? "picker_today" : "picker_now"], locale);
83
+ return localizedText(COMPONENT_TEXTS[unit === "day" ? "picker_today" : "picker_now"], locale);
84
84
  }
85
85
  }
86
86
 
@@ -92,7 +92,7 @@ export function fieldName(locale, field) {
92
92
  } catch {
93
93
  // Older engines and Hermes lack `dateTimeField`.
94
94
  }
95
- return textInLanguage(COMPONENT_TEXTS[field === "hour" ? "picker_hour" : "picker_minute"], locale);
95
+ return localizedText(COMPONENT_TEXTS[field === "hour" ? "picker_hour" : "picker_minute"], locale);
96
96
  }
97
97
 
98
98
  export function twoDigits(value) {
package/dist/index.d.ts CHANGED
@@ -6545,6 +6545,35 @@ export interface MarkdownInputHandle {
6545
6545
  insertText(text: string): boolean;
6546
6546
  }
6547
6547
 
6548
+ // ------------------------------------------------------- localized text
6549
+
6550
+ /** One text in each language it ships, English required; a count text has `one` / `other` forms. */
6551
+ export type LocalizedTextEntry = { en: string | { one: string; other: string } } & Record<
6552
+ string,
6553
+ string | { one: string; other: string }
6554
+ >;
6555
+
6556
+ /**
6557
+ * `entry`'s text in `locale`, each `{name}` slot filled from `values`. Reads
6558
+ * the exact locale, then its primary language (`sv-SE` reads `sv`; `no` and
6559
+ * `nn` read `nb`), then English. A count text takes the form `values.count`
6560
+ * needs in that language, `other` without a count. A plain string entry only
6561
+ * has its slots filled. For the platform's built-in widgets: a marketplace
6562
+ * widget ships its text in `manifest.translations` and reads it with `useI18n().t`.
6563
+ */
6564
+ export function localizedText(
6565
+ entry: LocalizedTextEntry | string,
6566
+ locale: string | null | undefined,
6567
+ values?: Record<string, string | number>,
6568
+ ): string;
6569
+
6570
+ /**
6571
+ * The language codes `localizedText` reads as another language's text:
6572
+ * Norwegian `no` and `nn` read `nb`. The platform's translation seeder reads
6573
+ * the same map. Exported from `@colixsystems/widget-sdk/contract`.
6574
+ */
6575
+ export const LANGUAGE_ALIASES: Readonly<Record<string, string>>;
6576
+
6548
6577
  // ------------------------------------------------------- theme derivation
6549
6578
  // sc-3696: the colour maths both hosts resolve `useTheme()` with. Exported so
6550
6579
  // the Player (frontend/src/services/widgetTheme.js) and the exported app's
package/dist/index.js CHANGED
@@ -233,6 +233,7 @@ export {
233
233
  hexAlphaPercent,
234
234
  clampSpacingScale,
235
235
  scaleSpacing,
236
+ localizedText,
236
237
  } from "./contract.js";
237
238
  // sc-8104 — the curated emoji set ships WITH the SDK (plain string data, no
238
239
  // dependency), and the reaction model is shared so Newsfeed and Chat group
@@ -226,6 +226,7 @@ export {
226
226
  hexAlphaPercent,
227
227
  clampSpacingScale,
228
228
  scaleSpacing,
229
+ localizedText,
229
230
  } from "./contract.js";
230
231
  // sc-8104 — the curated emoji set ships WITH the SDK (plain string data, no
231
232
  // dependency), and the reaction model is shared so Newsfeed and Chat group