@colixsystems/widget-sdk 0.326.1 → 0.327.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.
@@ -15,6 +15,7 @@ import {
15
15
  useDatastoreSchema,
16
16
  useDirectory,
17
17
  useGroups,
18
+ useSdkTextDefaults,
18
19
  } from "./hooks.js";
19
20
  import {
20
21
  answersQuery,
@@ -38,6 +39,8 @@ const h = React.createElement;
38
39
  const NO_ROWS = Object.freeze([]);
39
40
  const NO_LOOKUPS = Object.freeze({ pending: [], next: 0 });
40
41
 
42
+ const PICKER_TEXT_KEYS = Object.freeze({ unknownText: "unknown", loadingText: "loading" });
43
+
41
44
  function serialize(query) {
42
45
  try {
43
46
  return JSON.stringify(query);
@@ -143,7 +146,8 @@ export function makePeoplePicker(rn) {
143
146
  );
144
147
  }
145
148
 
146
- function SourcePicker(props) {
149
+ function SourcePicker(ownProps) {
150
+ const props = useSdkTextDefaults(ownProps, PICKER_TEXT_KEYS);
147
151
  const {
148
152
  source,
149
153
  table,
@@ -155,8 +159,8 @@ export function makePeoplePicker(rn) {
155
159
  excludeIds,
156
160
  pageSize,
157
161
  showAvatars = true,
158
- unknownText = "Unknown",
159
- loadingText = "Loading…",
162
+ unknownText,
163
+ loadingText,
160
164
  loadErrorText,
161
165
  multiple = false,
162
166
  value,
@@ -6,7 +6,7 @@
6
6
  // an icon or a tab role. This one has the radio role and the app's look.
7
7
 
8
8
  import React from "react";
9
- import { useHostSharedText, useHostTheme, useStrictProps } from "./hooks.js";
9
+ import { useHostTheme, useSdkText, useStrictProps } from "./hooks.js";
10
10
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
11
11
  import { Icon } from "./icon.js";
12
12
  import { CHECKBOX_SIZE, CONTROL_MIN_TARGET, focusHaloStyle } from "./form-control-tokens.js";
@@ -173,7 +173,8 @@ export function makeRadioGroup(rn) {
173
173
  containerStyle,
174
174
  ...rest
175
175
  } = props;
176
- const requiredWord = useHostSharedText("required", "Required");
176
+ const text = useSdkText();
177
+ const requiredWord = text("required");
177
178
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
178
179
  const t = resolveRadioGroupTokens(theme);
179
180
  const kind = radioGroupVariant(variant);
@@ -8,7 +8,7 @@
8
8
  // hosts; only the input differs. Touch screens on the web are left unchanged.
9
9
 
10
10
  import React from "react";
11
- import { useHostSharedText, useHostTheme } from "./hooks.js";
11
+ import { useHostTheme, useSdkText } from "./hooks.js";
12
12
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
13
13
  import { flattenStyle } from "./flatten-style.js";
14
14
  import { Icon } from "./icon.js";
@@ -113,8 +113,9 @@ export function makeScrollView({ ScrollView: BaseScrollView, View, Pressable })
113
113
  const ScrollView = React.forwardRef(function ScrollView(props, ref) {
114
114
  const { showsScrollAffordance = true, ...rest } = props;
115
115
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
116
- const previousLabel = useHostSharedText("previous", "Previous");
117
- const nextLabel = useHostSharedText("next", "Next");
116
+ const text = useSdkText();
117
+ const previousLabel = text("previous");
118
+ const nextLabel = text("next");
118
119
  const [finePointer] = React.useState(() => matches(FINE_POINTER));
119
120
  const [edges, setEdges] = React.useState("none");
120
121
  const [hovered, setHovered] = React.useState(false);
@@ -0,0 +1,164 @@
1
+ // GENERATED from sdk-texts.js by scripts/generate-cjs.js — DO NOT EDIT.
2
+ // Change sdk-texts.js, then run `npm run generate:cjs` in packages/widget-sdk.
3
+ "use strict";
4
+
5
+ // The words SDK components show when the author passes none, in the app's
6
+ // language (ctx.i18n.locale on both hosts). contract.js joins this table with
7
+ // the shared translation keys into the ONE table every component reads, so no
8
+ // component carries its own translation (CLAUDE.md §3).
9
+ //
10
+ // These texts are never seeded into a workspace's dictionary: several carry a
11
+ // `{count}` or `{label}` slot that machine translation at seeding would mangle.
12
+ // Languages follow the shared keys: English and a hand-written Swedish; every
13
+ // other language falls back to English.
14
+
15
+ /**
16
+ * Per key: the text in each shipped language, English always present. A text
17
+ * with a `{count}` slot is `{ one, other }`, picked by the language's plural rule.
18
+ */
19
+ const COMPONENT_TEXTS = Object.freeze({
20
+ select_placeholder: { en: "Select", sv: "Välj" },
21
+ no_options: { en: "No options", sv: "Inga alternativ" },
22
+ done: { en: "Done", sv: "Klar" },
23
+ selected_count: {
24
+ en: { one: "{count} selected", other: "{count} selected" },
25
+ sv: { one: "{count} vald", other: "{count} valda" },
26
+ },
27
+ options_load_failed: { en: "Could not load the options", sv: "Det gick inte att läsa in alternativen" },
28
+ clear: { en: "Clear", sv: "Rensa" },
29
+ clear_search: { en: "Clear search", sv: "Rensa sökningen" },
30
+ unknown: { en: "Unknown", sv: "Okänd" },
31
+ dismiss: { en: "Dismiss", sv: "Stäng" },
32
+ select_date: { en: "Select date", sv: "Välj datum" },
33
+ select_time: { en: "Select time", sv: "Välj tid" },
34
+ select_date_time: { en: "Select date & time", sv: "Välj datum och tid" },
35
+
36
+ choose_file: { en: "Choose file", sv: "Välj fil" },
37
+ choose_files: { en: "Choose files", sv: "Välj filer" },
38
+ uploading: { en: "Uploading…", sv: "Laddar upp…" },
39
+ no_file_chosen: { en: "No file chosen", sv: "Ingen fil vald" },
40
+ no_files_chosen: { en: "No files chosen", sv: "Inga filer valda" },
41
+ file_type_rejected: { en: "That file type isn't accepted here.", sv: "Den filtypen tas inte emot här." },
42
+ single_file_kept: {
43
+ en: "Only one file can be added here, so the first was kept.",
44
+ sv: "Här går det bara att lägga till en fil, så den första behölls.",
45
+ },
46
+ drop_file: { en: "or drop a file here", sv: "eller släpp en fil här" },
47
+ drop_files: { en: "or drop files here", sv: "eller släpp filer här" },
48
+ file_choice_unavailable: { en: "Choosing files isn't available here.", sv: "Det går inte att välja filer här." },
49
+
50
+ filter_any: { en: "Any", sv: "Alla" },
51
+ filters: { en: "Filters", sv: "Filter" },
52
+ filters_active_count: {
53
+ en: { one: "{count} active", other: "{count} active" },
54
+ sv: { one: "{count} aktivt", other: "{count} aktiva" },
55
+ },
56
+ clear_all: { en: "Clear all", sv: "Rensa alla" },
57
+ apply: { en: "Apply", sv: "Använd" },
58
+ active_filters: { en: "Active filters", sv: "Aktiva filter" },
59
+ remove_named: { en: "Remove {label}", sv: "Ta bort {label}" },
60
+ sort: { en: "Sort", sv: "Sortera" },
61
+ sorted_ascending: { en: "sorted ascending", sv: "sorterad stigande" },
62
+ sorted_descending: { en: "sorted descending", sv: "sorterad fallande" },
63
+
64
+ move_item: { en: "Move {item}", sv: "Flytta {item}" },
65
+ move_hint: {
66
+ en: "Drag to move it, or open the move options. The arrow keys move it too.",
67
+ sv: "Dra för att flytta, eller öppna flyttalternativen. Piltangenterna flyttar också.",
68
+ },
69
+ move_up: { en: "Move up", sv: "Flytta upp" },
70
+ move_down: { en: "Move down", sv: "Flytta ned" },
71
+ move_to_top: { en: "Move to top", sv: "Flytta högst upp" },
72
+ move_to_bottom: { en: "Move to bottom", sv: "Flytta längst ned" },
73
+ move_to_column: { en: "Move to {column}", sv: "Flytta till {column}" },
74
+ moved: { en: "{item} moved to position {position} of {total}", sv: "{item} flyttades till plats {position} av {total}" },
75
+ moved_to_column: { en: "{item} moved to {column}, position {position}", sv: "{item} flyttades till {column}, plats {position}" },
76
+
77
+ choose_emoji: { en: "Choose an emoji", sv: "Välj en emoji" },
78
+ close_emoji_picker: { en: "Close the emoji picker", sv: "Stäng emojiväljaren" },
79
+ search_emoji: { en: "Search emoji", sv: "Sök emoji" },
80
+ no_emoji_found: { en: "No emoji found", sv: "Inga emojier hittades" },
81
+ emoji_recent: { en: "Recent", sv: "Senaste" },
82
+ emoji_smileys: { en: "Smileys & Emotion", sv: "Smileys och känslor" },
83
+ emoji_people: { en: "People & Body", sv: "Människor och kropp" },
84
+ emoji_animals: { en: "Animals & Nature", sv: "Djur och natur" },
85
+ emoji_food: { en: "Food & Drink", sv: "Mat och dryck" },
86
+ emoji_activity: { en: "Activity", sv: "Aktiviteter" },
87
+ emoji_travel: { en: "Travel & Places", sv: "Resor och platser" },
88
+ emoji_objects: { en: "Objects", sv: "Föremål" },
89
+ emoji_symbols: { en: "Symbols", sv: "Symboler" },
90
+ emoji_flags: { en: "Flags", sv: "Flaggor" },
91
+
92
+ format_bold: { en: "Bold", sv: "Fetstil" },
93
+ format_italic: { en: "Italic", sv: "Kursiv" },
94
+ format_code: { en: "Code", sv: "Kod" },
95
+ format_heading: { en: "Heading", sv: "Rubrik" },
96
+ format_subheading: { en: "Subheading", sv: "Underrubrik" },
97
+ format_bulleted_list: { en: "Bulleted list", sv: "Punktlista" },
98
+ format_numbered_list: { en: "Numbered list", sv: "Numrerad lista" },
99
+ table: { en: "Table", sv: "Tabell" },
100
+ insert_table: { en: "Insert table", sv: "Infoga tabell" },
101
+ link: { en: "Link", sv: "Länk" },
102
+ insert_link: { en: "Insert link", sv: "Infoga länk" },
103
+ table_row_short: { en: "+ Row", sv: "+ Rad" },
104
+ table_add_row: { en: "Add row", sv: "Lägg till rad" },
105
+ table_column_short: { en: "+ Column", sv: "+ Kolumn" },
106
+ table_add_column: { en: "Add column", sv: "Lägg till kolumn" },
107
+ table_remove_row_short: { en: "− Row", sv: "− Rad" },
108
+ table_remove_row: { en: "Remove row", sv: "Ta bort rad" },
109
+ table_remove_column_short: { en: "− Column", sv: "− Kolumn" },
110
+ table_remove_column: { en: "Remove column", sv: "Ta bort kolumn" },
111
+ delete_table: { en: "Delete table", sv: "Ta bort tabell" },
112
+ link_text: { en: "Link text", sv: "Länktext" },
113
+ link_text_placeholder: { en: "Text the reader sees", sv: "Texten som läsaren ser" },
114
+ link_to_page: { en: "A page in this app", sv: "En sida i appen" },
115
+ link_to_url: { en: "An external URL", sv: "En extern webbadress" },
116
+ link_page: { en: "Page", sv: "Sida" },
117
+ link_address: { en: "Address", sv: "Adress" },
118
+ link_address_label: { en: "Link address", sv: "Länkadress" },
119
+ });
120
+
121
+ /** The language of `entry` that `locale` reads: itself, its primary language (`sv-SE` reads `sv`), else English. */
122
+ function languageIn(entry, locale) {
123
+ const ships = (language) => Object.prototype.hasOwnProperty.call(entry, language);
124
+ if (typeof locale === "string" && locale) {
125
+ if (ships(locale)) return locale;
126
+ const primary = locale.split(/[-_]/)[0].toLowerCase();
127
+ if (ships(primary)) return primary;
128
+ }
129
+ return "en";
130
+ }
131
+
132
+ function pluralCategory(language, count) {
133
+ try {
134
+ return new Intl.PluralRules(language).select(count);
135
+ } catch {
136
+ return count === 1 ? "one" : "other";
137
+ }
138
+ }
139
+
140
+ /**
141
+ * `entry`'s text in `locale`, slots filled from `values`. A plural text takes
142
+ * the form `values.count` needs, and `other` when no count is given.
143
+ */
144
+ function textInLanguage(entry, locale, values) {
145
+ const language = languageIn(entry, locale);
146
+ const text = entry[language];
147
+ if (typeof text === "string") return fillSdkText(text, values);
148
+ const count = values ? Number(values.count) : NaN;
149
+ const form = Number.isFinite(count) ? text[pluralCategory(language, count)] : undefined;
150
+ return fillSdkText(form || text.other, values);
151
+ }
152
+
153
+ /** `text` with each `{name}` slot replaced by `values[name]`. */
154
+ function fillSdkText(text, values) {
155
+ if (!values) return text;
156
+ return String(text).replace(/\{(\w+)\}/g, (slot, name) =>
157
+ Object.prototype.hasOwnProperty.call(values, name) ? String(values[name]) : slot,
158
+ );
159
+ }
160
+ module.exports = {
161
+ COMPONENT_TEXTS,
162
+ textInLanguage,
163
+ fillSdkText,
164
+ };
@@ -0,0 +1,155 @@
1
+ // The words SDK components show when the author passes none, in the app's
2
+ // language (ctx.i18n.locale on both hosts). contract.js joins this table with
3
+ // the shared translation keys into the ONE table every component reads, so no
4
+ // component carries its own translation (CLAUDE.md §3).
5
+ //
6
+ // These texts are never seeded into a workspace's dictionary: several carry a
7
+ // `{count}` or `{label}` slot that machine translation at seeding would mangle.
8
+ // Languages follow the shared keys: English and a hand-written Swedish; every
9
+ // other language falls back to English.
10
+
11
+ /**
12
+ * Per key: the text in each shipped language, English always present. A text
13
+ * with a `{count}` slot is `{ one, other }`, picked by the language's plural rule.
14
+ */
15
+ export const COMPONENT_TEXTS = Object.freeze({
16
+ select_placeholder: { en: "Select", sv: "Välj" },
17
+ no_options: { en: "No options", sv: "Inga alternativ" },
18
+ done: { en: "Done", sv: "Klar" },
19
+ selected_count: {
20
+ en: { one: "{count} selected", other: "{count} selected" },
21
+ sv: { one: "{count} vald", other: "{count} valda" },
22
+ },
23
+ options_load_failed: { en: "Could not load the options", sv: "Det gick inte att läsa in alternativen" },
24
+ clear: { en: "Clear", sv: "Rensa" },
25
+ clear_search: { en: "Clear search", sv: "Rensa sökningen" },
26
+ unknown: { en: "Unknown", sv: "Okänd" },
27
+ dismiss: { en: "Dismiss", sv: "Stäng" },
28
+ select_date: { en: "Select date", sv: "Välj datum" },
29
+ select_time: { en: "Select time", sv: "Välj tid" },
30
+ select_date_time: { en: "Select date & time", sv: "Välj datum och tid" },
31
+
32
+ choose_file: { en: "Choose file", sv: "Välj fil" },
33
+ choose_files: { en: "Choose files", sv: "Välj filer" },
34
+ uploading: { en: "Uploading…", sv: "Laddar upp…" },
35
+ no_file_chosen: { en: "No file chosen", sv: "Ingen fil vald" },
36
+ no_files_chosen: { en: "No files chosen", sv: "Inga filer valda" },
37
+ file_type_rejected: { en: "That file type isn't accepted here.", sv: "Den filtypen tas inte emot här." },
38
+ single_file_kept: {
39
+ en: "Only one file can be added here, so the first was kept.",
40
+ sv: "Här går det bara att lägga till en fil, så den första behölls.",
41
+ },
42
+ drop_file: { en: "or drop a file here", sv: "eller släpp en fil här" },
43
+ drop_files: { en: "or drop files here", sv: "eller släpp filer här" },
44
+ file_choice_unavailable: { en: "Choosing files isn't available here.", sv: "Det går inte att välja filer här." },
45
+
46
+ filter_any: { en: "Any", sv: "Alla" },
47
+ filters: { en: "Filters", sv: "Filter" },
48
+ filters_active_count: {
49
+ en: { one: "{count} active", other: "{count} active" },
50
+ sv: { one: "{count} aktivt", other: "{count} aktiva" },
51
+ },
52
+ clear_all: { en: "Clear all", sv: "Rensa alla" },
53
+ apply: { en: "Apply", sv: "Använd" },
54
+ active_filters: { en: "Active filters", sv: "Aktiva filter" },
55
+ remove_named: { en: "Remove {label}", sv: "Ta bort {label}" },
56
+ sort: { en: "Sort", sv: "Sortera" },
57
+ sorted_ascending: { en: "sorted ascending", sv: "sorterad stigande" },
58
+ sorted_descending: { en: "sorted descending", sv: "sorterad fallande" },
59
+
60
+ move_item: { en: "Move {item}", sv: "Flytta {item}" },
61
+ move_hint: {
62
+ en: "Drag to move it, or open the move options. The arrow keys move it too.",
63
+ sv: "Dra för att flytta, eller öppna flyttalternativen. Piltangenterna flyttar också.",
64
+ },
65
+ move_up: { en: "Move up", sv: "Flytta upp" },
66
+ move_down: { en: "Move down", sv: "Flytta ned" },
67
+ move_to_top: { en: "Move to top", sv: "Flytta högst upp" },
68
+ move_to_bottom: { en: "Move to bottom", sv: "Flytta längst ned" },
69
+ move_to_column: { en: "Move to {column}", sv: "Flytta till {column}" },
70
+ moved: { en: "{item} moved to position {position} of {total}", sv: "{item} flyttades till plats {position} av {total}" },
71
+ moved_to_column: { en: "{item} moved to {column}, position {position}", sv: "{item} flyttades till {column}, plats {position}" },
72
+
73
+ choose_emoji: { en: "Choose an emoji", sv: "Välj en emoji" },
74
+ close_emoji_picker: { en: "Close the emoji picker", sv: "Stäng emojiväljaren" },
75
+ search_emoji: { en: "Search emoji", sv: "Sök emoji" },
76
+ no_emoji_found: { en: "No emoji found", sv: "Inga emojier hittades" },
77
+ emoji_recent: { en: "Recent", sv: "Senaste" },
78
+ emoji_smileys: { en: "Smileys & Emotion", sv: "Smileys och känslor" },
79
+ emoji_people: { en: "People & Body", sv: "Människor och kropp" },
80
+ emoji_animals: { en: "Animals & Nature", sv: "Djur och natur" },
81
+ emoji_food: { en: "Food & Drink", sv: "Mat och dryck" },
82
+ emoji_activity: { en: "Activity", sv: "Aktiviteter" },
83
+ emoji_travel: { en: "Travel & Places", sv: "Resor och platser" },
84
+ emoji_objects: { en: "Objects", sv: "Föremål" },
85
+ emoji_symbols: { en: "Symbols", sv: "Symboler" },
86
+ emoji_flags: { en: "Flags", sv: "Flaggor" },
87
+
88
+ format_bold: { en: "Bold", sv: "Fetstil" },
89
+ format_italic: { en: "Italic", sv: "Kursiv" },
90
+ format_code: { en: "Code", sv: "Kod" },
91
+ format_heading: { en: "Heading", sv: "Rubrik" },
92
+ format_subheading: { en: "Subheading", sv: "Underrubrik" },
93
+ format_bulleted_list: { en: "Bulleted list", sv: "Punktlista" },
94
+ format_numbered_list: { en: "Numbered list", sv: "Numrerad lista" },
95
+ table: { en: "Table", sv: "Tabell" },
96
+ insert_table: { en: "Insert table", sv: "Infoga tabell" },
97
+ link: { en: "Link", sv: "Länk" },
98
+ insert_link: { en: "Insert link", sv: "Infoga länk" },
99
+ table_row_short: { en: "+ Row", sv: "+ Rad" },
100
+ table_add_row: { en: "Add row", sv: "Lägg till rad" },
101
+ table_column_short: { en: "+ Column", sv: "+ Kolumn" },
102
+ table_add_column: { en: "Add column", sv: "Lägg till kolumn" },
103
+ table_remove_row_short: { en: "− Row", sv: "− Rad" },
104
+ table_remove_row: { en: "Remove row", sv: "Ta bort rad" },
105
+ table_remove_column_short: { en: "− Column", sv: "− Kolumn" },
106
+ table_remove_column: { en: "Remove column", sv: "Ta bort kolumn" },
107
+ delete_table: { en: "Delete table", sv: "Ta bort tabell" },
108
+ link_text: { en: "Link text", sv: "Länktext" },
109
+ link_text_placeholder: { en: "Text the reader sees", sv: "Texten som läsaren ser" },
110
+ link_to_page: { en: "A page in this app", sv: "En sida i appen" },
111
+ link_to_url: { en: "An external URL", sv: "En extern webbadress" },
112
+ link_page: { en: "Page", sv: "Sida" },
113
+ link_address: { en: "Address", sv: "Adress" },
114
+ link_address_label: { en: "Link address", sv: "Länkadress" },
115
+ });
116
+
117
+ /** The language of `entry` that `locale` reads: itself, its primary language (`sv-SE` reads `sv`), else English. */
118
+ function languageIn(entry, locale) {
119
+ const ships = (language) => Object.prototype.hasOwnProperty.call(entry, language);
120
+ if (typeof locale === "string" && locale) {
121
+ if (ships(locale)) return locale;
122
+ const primary = locale.split(/[-_]/)[0].toLowerCase();
123
+ if (ships(primary)) return primary;
124
+ }
125
+ return "en";
126
+ }
127
+
128
+ function pluralCategory(language, count) {
129
+ try {
130
+ return new Intl.PluralRules(language).select(count);
131
+ } catch {
132
+ return count === 1 ? "one" : "other";
133
+ }
134
+ }
135
+
136
+ /**
137
+ * `entry`'s text in `locale`, slots filled from `values`. A plural text takes
138
+ * the form `values.count` needs, and `other` when no count is given.
139
+ */
140
+ export function textInLanguage(entry, locale, values) {
141
+ const language = languageIn(entry, locale);
142
+ const text = entry[language];
143
+ if (typeof text === "string") return fillSdkText(text, values);
144
+ const count = values ? Number(values.count) : NaN;
145
+ const form = Number.isFinite(count) ? text[pluralCategory(language, count)] : undefined;
146
+ return fillSdkText(form || text.other, values);
147
+ }
148
+
149
+ /** `text` with each `{name}` slot replaced by `values[name]`. */
150
+ export function fillSdkText(text, values) {
151
+ if (!values) return text;
152
+ return String(text).replace(/\{(\w+)\}/g, (slot, name) =>
153
+ Object.prototype.hasOwnProperty.call(values, name) ? String(values[name]) : slot,
154
+ );
155
+ }
@@ -5,12 +5,13 @@
5
5
  // differ only in where the primitives come from.
6
6
 
7
7
  import React from "react";
8
- import { useHostTheme } from "./hooks.js";
8
+ import { useHostTheme, useSdkTextDefaults } from "./hooks.js";
9
9
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
10
10
  import { resolveSearchFieldTokens, searchFieldLayout } from "./search-field-tokens.js";
11
11
  import { shareRef, spokenLabel } from "./form-control-logic.js";
12
12
 
13
13
  const h = React.createElement;
14
+ const SEARCH_TEXT_KEYS = Object.freeze({ placeholder: "search", clearAccessibilityLabel: "clear_search" });
14
15
 
15
16
  /**
16
17
  * Bind the shared search field to one platform's primitives.
@@ -20,13 +21,14 @@ const h = React.createElement;
20
21
  export function makeSearchField(rn) {
21
22
  const { TextField } = rn;
22
23
 
23
- const SearchField = React.forwardRef(function SearchField(props, ref) {
24
+ const SearchField = React.forwardRef(function SearchField(ownProps, ref) {
25
+ const props = useSdkTextDefaults(ownProps, SEARCH_TEXT_KEYS);
24
26
  const {
25
27
  value,
26
28
  onChangeText,
27
29
  onClear,
28
- placeholder = "Search",
29
- clearAccessibilityLabel = "Clear search",
30
+ placeholder,
31
+ clearAccessibilityLabel,
30
32
  label,
31
33
  disabled = false,
32
34
  accessibilityLabel,
@@ -2,11 +2,6 @@
2
2
  // sheet opens, the draft a `multiple` select edits until Done, and what its
3
3
  // trigger shows. Both hosts share them, and the node suite tests them.
4
4
 
5
- /** The default trigger text once the picked labels no longer fit. */
6
- export function defaultSelectedCountText(count) {
7
- return `${count} selected`;
8
- }
9
-
10
5
  /** A `values` prop as a list; anything else is no choice. */
11
6
  export function valueList(values) {
12
7
  return Array.isArray(values) ? values : [];
@@ -10,7 +10,7 @@
10
10
  // it is held, or each pause in typing asks `onSearch` / async `options`.
11
11
 
12
12
  import React from "react";
13
- import { useHostSharedText, useHostTheme, useStrictProps } from "./hooks.js";
13
+ import { useHostTheme, useSdkText, useSdkTextDefaults, useStrictProps } from "./hooks.js";
14
14
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
15
15
  import { Icon } from "./icon.js";
16
16
  import { TEXT_FIELD_TOKEN_NAMES } from "./text-field-tokens.js";
@@ -36,7 +36,6 @@ import { makeFieldFrame } from "./form-control-view.js";
36
36
  import { checkboxBox } from "./checkbox-view.js";
37
37
  import {
38
38
  committedValues,
39
- defaultSelectedCountText,
40
39
  initialFocusIndex,
41
40
  pickedOptions,
42
41
  sameValues,
@@ -58,6 +57,17 @@ import {
58
57
  } from "./select-search-logic.js";
59
58
 
60
59
  const h = React.createElement;
60
+ // The default each text prop takes, from the SDK text table.
61
+ const SELECT_TEXT_KEYS = Object.freeze({
62
+ doneText: "done",
63
+ placeholder: "select_placeholder",
64
+ emptyText: "no_options",
65
+ searchPlaceholder: "search",
66
+ noResultsText: "no_results",
67
+ loadingText: "loading",
68
+ loadErrorText: "options_load_failed",
69
+ });
70
+
61
71
  // Wide enough that no picked chip shrinks while it is measured.
62
72
  const MEASURE_SPAN = 10000;
63
73
  // A compact chip that fits the field's own line, so the trigger keeps its height.
@@ -223,8 +233,6 @@ export function makeSelect(rn) {
223
233
  // both hosts, so a narrow trigger never grows to hold them.
224
234
  function MultiSummary({ t, picked, placeholder, selectedCountText, testID }) {
225
235
  const [widths, setWidths] = React.useState(UNMEASURED);
226
- const countText =
227
- typeof selectedCountText === "function" ? selectedCountText : defaultSelectedCountText;
228
236
  const measure = (key) => (event) => {
229
237
  const width = event.nativeEvent.layout.width;
230
238
  setWidths((own) => (own[key] === width ? own : { ...own, [key]: width }));
@@ -255,7 +263,7 @@ export function makeSelect(rn) {
255
263
  numberOfLines: 1,
256
264
  style: { ...text, color: mode === "count" ? t.textColor : t.placeholderColor },
257
265
  },
258
- mode === "count" ? countText(picked.length) : placeholder,
266
+ mode === "count" ? selectedCountText(picked.length) : placeholder,
259
267
  ),
260
268
  picked.length > 0
261
269
  ? h(
@@ -331,20 +339,22 @@ export function makeSelect(rn) {
331
339
  });
332
340
  }
333
341
 
334
- const Select = React.forwardRef(function Select(props, ref) {
335
- useStrictProps("Select", props);
342
+ const Select = React.forwardRef(function Select(ownProps, ref) {
343
+ useStrictProps("Select", ownProps);
344
+ const text = useSdkText();
345
+ const props = useSdkTextDefaults(ownProps, SELECT_TEXT_KEYS);
336
346
  const {
337
347
  value,
338
348
  onValueChange,
339
349
  multiple = false,
340
350
  values,
341
351
  onValuesChange,
342
- selectedCountText = defaultSelectedCountText,
343
- doneText = "Done",
352
+ selectedCountText,
353
+ doneText,
344
354
  options,
345
- placeholder = "Select",
355
+ placeholder,
346
356
  title,
347
- emptyText = "No options",
357
+ emptyText,
348
358
  label,
349
359
  helper,
350
360
  error,
@@ -363,10 +373,10 @@ export function makeSelect(rn) {
363
373
  loading: loadingProp = false,
364
374
  optionsError,
365
375
  selectedOptions,
366
- searchPlaceholder = "Search",
367
- noResultsText = "No results",
368
- loadingText = "Loading…",
369
- loadErrorText = "Could not load the options",
376
+ searchPlaceholder,
377
+ noResultsText,
378
+ loadingText,
379
+ loadErrorText,
370
380
  ...others
371
381
  } = props;
372
382
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
@@ -377,7 +387,9 @@ export function makeSelect(rn) {
377
387
  else rest[key] = own;
378
388
  }
379
389
  const t = resolveFormControlTokens(theme, overrides);
380
- const requiredWord = useHostSharedText("required", "Required");
390
+ const requiredWord = text("required");
391
+ const countText =
392
+ typeof selectedCountText === "function" ? selectedCountText : (count) => text("selected_count", { count });
381
393
  const [open, setOpen] = React.useState(false);
382
394
  // Null until the person ticks something: an untouched sheet follows `values`.
383
395
  const [ownDraft, setDraft] = React.useState(null);
@@ -515,7 +527,7 @@ export function makeSelect(rn) {
515
527
  ],
516
528
  },
517
529
  multiple
518
- ? h(MultiSummary, { t, picked, placeholder, selectedCountText, testID })
530
+ ? h(MultiSummary, { t, picked, placeholder, selectedCountText: countText, testID })
519
531
  : h(
520
532
  Text,
521
533
  {
@@ -3,7 +3,7 @@
3
3
  // app's `<ListRow>`s, so the list wears the theme's `list` scope.
4
4
 
5
5
  import React from "react";
6
- import { useHostTheme } from "./hooks.js";
6
+ import { useHostLocale, useHostTheme } from "./hooks.js";
7
7
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
8
8
  import { measureNode } from "./drag-kit-view.js";
9
9
  import {
@@ -79,7 +79,7 @@ export function makeSortableList(rn, kit) {
79
79
  }) {
80
80
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
81
81
  const tokens = resolveSortableTokens(theme);
82
- const words = resolveSortableLabels(labels);
82
+ const words = resolveSortableLabels(labels, useHostLocale());
83
83
  const list = Array.isArray(items) ? items : [];
84
84
  const keys = list.map((item, i) => itemKey(item, i, keyExtractor));
85
85
  const order = keys.join("\u0000");
@@ -5,6 +5,8 @@
5
5
  // window rectangle from `measureInWindow`, so no parent padding or scroll
6
6
  // offset enters a comparison.
7
7
 
8
+ import { sdkText } from "./contract.js";
9
+
8
10
  /** How far a press must travel before it becomes a drag rather than a tap. */
9
11
  export const DRAG_SLOP = 6;
10
12
  /** The band at a narrow board's edge that scrolls it while a card is held there. */
@@ -14,24 +16,36 @@ export const AUTO_SCROLL_MAX_STEP = 16;
14
16
  /** A column's width when a narrow board scrolls its columns sideways. */
15
17
  export const BOARD_COLUMN_WIDTH = 280;
16
18
 
17
- /** The words a move announces and its controls carry; `{item}` and the like are filled in. */
18
- export const DEFAULT_SORTABLE_LABELS = Object.freeze({
19
- handle: "Move {item}",
20
- hint: "Drag to move it, or open the move options. The arrow keys move it too.",
21
- moveUp: "Move up",
22
- moveDown: "Move down",
23
- moveToTop: "Move to top",
24
- moveToBottom: "Move to bottom",
25
- moveToColumn: "Move to {column}",
26
- moved: "{item} moved to position {position} of {total}",
27
- movedToColumn: "{item} moved to {column}, position {position}",
19
+ // Each label's entry in the SDK text table.
20
+ const SORTABLE_LABEL_KEYS = Object.freeze({
21
+ handle: "move_item",
22
+ hint: "move_hint",
23
+ moveUp: "move_up",
24
+ moveDown: "move_down",
25
+ moveToTop: "move_to_top",
26
+ moveToBottom: "move_to_bottom",
27
+ moveToColumn: "move_to_column",
28
+ moved: "moved",
29
+ movedToColumn: "moved_to_column",
28
30
  });
29
31
 
30
- /** The labels a widget passed, over the defaults; a blank entry keeps the default. */
31
- export function resolveSortableLabels(labels) {
32
- const out = { ...DEFAULT_SORTABLE_LABELS };
32
+ function sortableLabelsIn(locale) {
33
+ const out = {};
34
+ for (const [name, key] of Object.entries(SORTABLE_LABEL_KEYS)) out[name] = sdkText(key, locale);
35
+ return out;
36
+ }
37
+
38
+ /** The words a move announces and its controls carry; `{item}` and the like are filled in. */
39
+ export const DEFAULT_SORTABLE_LABELS = Object.freeze(sortableLabelsIn("en"));
40
+
41
+ /**
42
+ * The labels a widget passed, over the defaults in `locale`; a blank entry
43
+ * keeps the default.
44
+ */
45
+ export function resolveSortableLabels(labels, locale) {
46
+ const out = sortableLabelsIn(locale);
33
47
  if (!labels || typeof labels !== "object") return out;
34
- for (const name of Object.keys(DEFAULT_SORTABLE_LABELS)) {
48
+ for (const name of Object.keys(SORTABLE_LABEL_KEYS)) {
35
49
  if (typeof labels[name] === "string" && labels[name] !== "") out[name] = labels[name];
36
50
  }
37
51
  return out;
@@ -3,7 +3,7 @@
3
3
  // from, so the hosts cannot drift.
4
4
 
5
5
  import React from "react";
6
- import { useHostSharedText, useHostTheme } from "./hooks.js";
6
+ import { useHostTheme, useSdkText } from "./hooks.js";
7
7
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
8
8
  import { Icon } from "./icon.js";
9
9
  import { TEXT_FIELD_TOKEN_NAMES } from "./text-field-tokens.js";
@@ -99,7 +99,8 @@ export function makeTextField(rn) {
99
99
  ...others
100
100
  } = props;
101
101
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
102
- const requiredWord = useHostSharedText("required", "Required");
102
+ const text = useSdkText();
103
+ const requiredWord = text("required");
103
104
  const [focused, setFocused] = React.useState(false);
104
105
  const overrides = {};
105
106
  const rest = {};