@colixsystems/widget-sdk 0.362.0 → 0.364.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, localizedText } 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
@@ -7277,7 +7479,9 @@ const CONTRACT = deepFreeze({
7277
7479
  // column is `missing`, as the Studio and preview binders already showed.
7278
7480
  // 1.298.0 (sc-18635): additive — `localizedText(entry, locale, values)`
7279
7481
  // reads a nine-language text table; `no` and `nn` read `nb`.
7280
- version: "1.298.0",
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",
7281
7485
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7282
7486
  hooks: HOOKS,
7283
7487
  primitives: PRIMITIVES,
@@ -7887,5 +8091,6 @@ export {
7887
8091
  sdkText,
7888
8092
  fillSdkText,
7889
8093
  localizedText,
8094
+ LANGUAGE_ALIASES,
7890
8095
  formatDateForDisplay,
7891
8096
  };
@@ -41,6 +41,18 @@ export function normaliseFileImageResizeMode(mode) {
41
41
  return FILE_IMAGE_RESIZE_MODES.includes(mode) ? mode : "cover";
42
42
  }
43
43
 
44
+ const CONTENT_FIT_BY_RESIZE_MODE = Object.freeze({ cover: "cover", contain: "contain", stretch: "fill", center: "scale-down" });
45
+
46
+ /** expo-image's `contentFit` for a resize mode, fitting as React Native's would. */
47
+ export function fileImageContentFit(mode) {
48
+ return CONTENT_FIT_BY_RESIZE_MODE[normaliseFileImageResizeMode(mode)];
49
+ }
50
+
51
+ /** A URL whose path names an SVG, which React Native's own Image cannot draw. */
52
+ export function isSvgUrl(uri) {
53
+ return typeof uri === "string" && /\.svg$/i.test(uri.split(/[?#]/)[0]);
54
+ }
55
+
44
56
  /**
45
57
  * The URL a variant loads: its rung of the size ladder, else the original
46
58
  * (a file projected before the ladder shipped has no `urls`).
@@ -96,10 +108,11 @@ export function fileImageRadius(radius, radii) {
96
108
 
97
109
  /**
98
110
  * The loaded picture's pixel size, from either host's load event: React Native
99
- * reports `nativeEvent.source`, the web the decoded element's natural size.
111
+ * reports `nativeEvent.source`, expo-image `source`, the web the decoded
112
+ * element's natural size.
100
113
  */
101
114
  export function intrinsicSizeOf(event) {
102
- const native = event && event.nativeEvent;
115
+ const native = event && (event.nativeEvent || event);
103
116
  if (!native) return null;
104
117
  const source = native.source;
105
118
  if (source && positive(source.width) && positive(source.height)) {
@@ -1,8 +1,21 @@
1
1
  // `<FileImage>` (native). Binds ./file-image-view.js to React Native and the
2
2
  // native `<Skeleton>`; only the imports differ from ./file-image.js.
3
3
 
4
+ import { createElement } from "react";
4
5
  import { View, Image } from "react-native";
5
6
  import { Skeleton } from "./loading.native.js";
6
7
  import { makeFileImage } from "./file-image-view.js";
8
+ import { svgCapableImage } from "./svg-image.js";
7
9
 
8
- export const { FileImage } = makeFileImage({ View, Image }, Skeleton);
10
+ // Pinned in every export; only a dev client older than the pin lacks it.
11
+ function loadExpoImage() {
12
+ try {
13
+ return require("expo-image").Image;
14
+ } catch (_) {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ const PictureImage = svgCapableImage({ createElement, Image, ExpoImage: loadExpoImage() });
20
+
21
+ export const { FileImage } = makeFileImage({ View, Image: PictureImage }, Skeleton);
package/dist/host.d.ts CHANGED
@@ -805,3 +805,15 @@ export function normaliseContainerPattern(
805
805
  export function containerPatternTile(pattern: ContainerPattern): { size: number; paths: ContainerPatternPath[] };
806
806
  /** The tile as standalone SVG markup, for a CSS background. */
807
807
  export function containerPatternSvg(pattern: ContainerPattern): string;
808
+
809
+ /** Whether a URL's path names an SVG, which React Native's own Image cannot draw. */
810
+ export function isSvgUrl(uri: unknown): boolean;
811
+ /**
812
+ * A native image component: React Native's `Image`, or `ExpoImage` for an SVG's
813
+ * URL, fitted as its `resizeMode` asks. Takes React Native Image props.
814
+ */
815
+ export function svgCapableImage<P extends { source?: { uri?: string }; resizeMode?: string }>(parts: {
816
+ createElement: typeof import("react").createElement;
817
+ Image: import("react").ComponentType<P>;
818
+ ExpoImage: import("react").ComponentType<any> | null;
819
+ }): import("react").ComponentType<P>;
package/dist/host.js CHANGED
@@ -210,3 +210,7 @@ export {
210
210
  containerPatternTile,
211
211
  containerPatternSvg,
212
212
  } from "./container-pattern.js";
213
+
214
+ // sc-18973: an SVG picture on native, for <FileImage> and the export's logos.
215
+ export { isSvgUrl } from "./file-image-logic.js";
216
+ export { svgCapableImage } from "./svg-image.js";
package/dist/index.d.ts CHANGED
@@ -6567,6 +6567,13 @@ export function localizedText(
6567
6567
  values?: Record<string, string | number>,
6568
6568
  ): string;
6569
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
+
6570
6577
  // ------------------------------------------------------- theme derivation
6571
6578
  // sc-3696: the colour maths both hosts resolve `useTheme()` with. Exported so
6572
6579
  // the Player (frontend/src/services/widgetTheme.js) and the exported app's