@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.
@@ -10,7 +10,7 @@
10
10
  // button. The applied filters sit beneath as removable chips at every width.
11
11
 
12
12
  import React from "react";
13
- import { useContainerWidth, useHostTheme } from "./hooks.js";
13
+ import { useContainerWidth, useHostTheme, useSdkText, useSdkTextDefaults } from "./hooks.js";
14
14
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
15
15
  import { DEFAULT_SEARCH_DEBOUNCE_MS, createDebouncer, normaliseQuery } from "./select-search-logic.js";
16
16
  import {
@@ -30,6 +30,16 @@ import {
30
30
  const h = React.createElement;
31
31
  const NO_FILTERS = Object.freeze({});
32
32
  const MAX_UNECHOED = 20;
33
+ const FILTER_TEXT_KEYS = Object.freeze({
34
+ searchPlaceholder: "search",
35
+ anyText: "filter_any",
36
+ filtersText: "filters",
37
+ clearAllText: "clear_all",
38
+ applyText: "apply",
39
+ clearText: "clear",
40
+ activeFiltersText: "active_filters",
41
+ removeText: "remove_named",
42
+ });
33
43
 
34
44
  function part(testID, name) {
35
45
  return testID ? `${testID}-${name}` : undefined;
@@ -128,7 +138,8 @@ export function makeFilterBar(rn) {
128
138
  }
129
139
 
130
140
  function SortSelect({ sort, value, onPick, compact, testID }) {
131
- const label = typeof sort.label === "string" ? sort.label : "Sort";
141
+ const sortText = useSdkText()("sort");
142
+ const label = typeof sort.label === "string" ? sort.label : sortText;
132
143
  return h(Select, {
133
144
  title: label,
134
145
  options: Array.isArray(sort.options) ? sort.options : [],
@@ -145,27 +156,34 @@ export function makeFilterBar(rn) {
145
156
  });
146
157
  }
147
158
 
148
- function FilterBar({
149
- query,
150
- onQueryChange,
151
- queryDebounceMs = DEFAULT_SEARCH_DEBOUNCE_MS,
152
- facets,
153
- value,
154
- onChange,
155
- sort,
156
- searchPlaceholder = "Search",
157
- anyText = "Any",
158
- filtersText = "Filters",
159
- activeCountText = "{count} active",
160
- clearAllText = "Clear all",
161
- applyText = "Apply",
162
- clearText = "Clear",
163
- activeFiltersText = "Active filters",
164
- removeText = "Remove {label}",
165
- closeAccessibilityLabel,
166
- style,
167
- testID,
168
- }) {
159
+ function FilterBar(ownProps) {
160
+ const {
161
+ query,
162
+ onQueryChange,
163
+ queryDebounceMs = DEFAULT_SEARCH_DEBOUNCE_MS,
164
+ facets,
165
+ value,
166
+ onChange,
167
+ sort,
168
+ searchPlaceholder,
169
+ anyText,
170
+ filtersText,
171
+ activeCountText,
172
+ clearAllText,
173
+ applyText,
174
+ clearText,
175
+ activeFiltersText,
176
+ removeText,
177
+ closeAccessibilityLabel,
178
+ style,
179
+ testID,
180
+ } = useSdkTextDefaults(ownProps, FILTER_TEXT_KEYS);
181
+ const text = useSdkText();
182
+ // The built-in text picks its plural form; an author's is a template.
183
+ const activeCount = (count) =>
184
+ activeCountText === undefined
185
+ ? text("filters_active_count", { count })
186
+ : fillText(activeCountText, "count", count);
169
187
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
170
188
  const spacing = theme.spacing || DEFAULT_THEME_TOKENS.spacing;
171
189
  const gap = spacing.sm;
@@ -258,7 +276,7 @@ export function makeFilterBar(rn) {
258
276
  title: filtersButtonText(filtersText, applied.length),
259
277
  accessibilityLabel:
260
278
  applied.length > 0
261
- ? `${filtersText}, ${fillText(activeCountText, "count", applied.length)}`
279
+ ? `${filtersText}, ${activeCount(applied.length)}`
262
280
  : filtersText,
263
281
  icon: "sliders-horizontal",
264
282
  variant: "secondary",
package/dist/form-view.js CHANGED
@@ -8,7 +8,7 @@
8
8
  // renderer live in ./form-layout-logic.js.
9
9
 
10
10
  import React from "react";
11
- import { useContainerWidth, useHostSharedText, useHostTheme } from "./hooks.js";
11
+ import { useContainerWidth, useHostTheme, useSdkText } from "./hooks.js";
12
12
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
13
13
  import { resolveGridGap } from "./grid-logic.js";
14
14
  import { resolveFormControlTokens } from "./form-control-tokens.js";
@@ -217,7 +217,8 @@ export function makeForm(rn) {
217
217
  function FormField({ label, required = false, helper, error, disabled = false, children, style, testID }) {
218
218
  const theme = useThemeTokens();
219
219
  const t = resolveFormControlTokens(theme);
220
- const requiredWord = useHostSharedText("required", "Required");
220
+ const text = useSdkText();
221
+ const requiredWord = text("required");
221
222
  const noteId = React.useId();
222
223
  const items = React.Children.toArray(children);
223
224
  const only = items.length === 1 ? items[0] : null;
package/dist/hooks.js CHANGED
@@ -43,6 +43,9 @@ import {
43
43
  widgetTranslationKey,
44
44
  sharedTranslationKey,
45
45
  isSharedTranslationKey,
46
+ // sc-16877 — the built-in default texts components fall back to.
47
+ sdkText,
48
+ fillSdkText,
46
49
  formatMoneyIn,
47
50
  normaliseCurrencyCode,
48
51
  // sc-5717 — "is this key still at its declared default", shared with the
@@ -274,12 +277,33 @@ function hostTranslation(hostT, key) {
274
277
  return hit ? text : null;
275
278
  }
276
279
 
277
- // @internal — a predefined shared string in the host's language, or
278
- // `fallback` outside a widget context. Not re-exported from index.js.
279
- export function useHostSharedText(key, fallback) {
280
+ // @internal — `text(key, values?)`: a component's default text in the app's
281
+ // language. The workspace's wording of a shared key wins, then the SDK's own
282
+ // table (CONTRACT `sdkText`), then English. Not re-exported from index.js.
283
+ export function useSdkText() {
280
284
  const ctx = useContext(HostWidgetContext);
281
- const hostT = ctx && ctx.i18n && typeof ctx.i18n.t === "function" ? ctx.i18n.t : null;
282
- return (hostT && hostTranslation(hostT, sharedTranslationKey(key))) || fallback;
285
+ const i18n = ctx ? ctx.i18n : undefined;
286
+ const hostT = i18n && typeof i18n.t === "function" ? i18n.t : null;
287
+ const locale = i18n && typeof i18n.locale === "string" ? i18n.locale : undefined;
288
+ return useCallback(
289
+ (key, values) => {
290
+ const own =
291
+ hostT && isSharedTranslationKey(key) ? hostTranslation(hostT, sharedTranslationKey(key)) : null;
292
+ return own === null ? sdkText(key, locale, values) : fillSdkText(own, values);
293
+ },
294
+ [hostT, locale],
295
+ );
296
+ }
297
+
298
+ // @internal — `props` with each prop named in `keys` the author left out set
299
+ // to its default text; `null` stays, as a destructuring default leaves it.
300
+ export function useSdkTextDefaults(props, keys) {
301
+ const text = useSdkText();
302
+ const resolved = { ...props };
303
+ for (const [prop, key] of Object.entries(keys)) {
304
+ resolved[prop] = props[prop] === undefined ? text(key) : props[prop];
305
+ }
306
+ return resolved;
283
307
  }
284
308
 
285
309
  /**
package/dist/index.d.ts CHANGED
@@ -4701,7 +4701,7 @@ export const DataTable: <Row = Record<string, any>>(
4701
4701
  showHeader?: boolean;
4702
4702
  /** Placeholder rows while `rows` is still empty. */
4703
4703
  loading?: boolean;
4704
- /** The empty state's title and message; the message defaults to "No results". */
4704
+ /** The empty state's title and message; the message defaults to "No results", in the app's language. */
4705
4705
  emptyTitle?: ReactNode;
4706
4706
  emptyMessage?: ReactNode;
4707
4707
  /** The words a sort is spoken with, in the widget's language. */
@@ -5112,13 +5112,13 @@ export interface SelectSearchProps<V extends string | number = string | number>
5112
5112
  * saved choice outside the first page), so the trigger names them.
5113
5113
  */
5114
5114
  selectedOptions?: Array<SelectOption<V>>;
5115
- /** Default "Search". */
5115
+ /** Default "Search", in the app's language. */
5116
5116
  searchPlaceholder?: string;
5117
- /** Shown when a query finds nothing. Default "No results". */
5117
+ /** Shown when a query finds nothing. Default "No results", in the app's language. */
5118
5118
  noResultsText?: string;
5119
- /** Default "Loading…". */
5119
+ /** Default "Loading…", in the app's language. */
5120
5120
  loadingText?: string;
5121
- /** Default "Could not load the options". */
5121
+ /** Default "Could not load the options", in the app's language. */
5122
5122
  loadErrorText?: string;
5123
5123
  }
5124
5124
 
@@ -5132,11 +5132,11 @@ export type SelectBaseProps<V extends string | number = string | number> = FormC
5132
5132
  * mode) that resolves to them; only its latest answer is shown.
5133
5133
  */
5134
5134
  options: Array<SelectOption<V>> | ((query: string) => Promise<Array<SelectOption<V>>>);
5135
- /** Shown while nothing is chosen. Default "Select". */
5135
+ /** Shown while nothing is chosen. Default "Select", in the app's language. */
5136
5136
  placeholder?: string;
5137
5137
  /** The sheet's heading. Defaults to a text `label`. */
5138
5138
  title?: string;
5139
- /** Shown in the sheet when `options` is empty. Default "No options". */
5139
+ /** Shown in the sheet when `options` is empty. Default "No options", in the app's language. */
5140
5140
  emptyText?: string;
5141
5141
  closeAccessibilityLabel?: string;
5142
5142
  /** The trigger. */
@@ -5185,7 +5185,7 @@ export const Select: <V extends string | number = string | number>(
5185
5185
  onValuesChange?: (values: V[], options: Array<SelectOption<V>>) => void;
5186
5186
  /** The trigger's text when the chips do not fit. Default `${count} selected`. */
5187
5187
  selectedCountText?: (count: number) => string;
5188
- /** The sheet's confirm button. Default "Done". */
5188
+ /** The sheet's confirm button. Default "Done", in the app's language. */
5189
5189
  doneText?: string;
5190
5190
  }),
5191
5191
  ) => any;
@@ -5233,7 +5233,7 @@ export const PeoplePicker: (
5233
5233
  pageSize?: number;
5234
5234
  /** Draw an avatar before each user or group. Default true. */
5235
5235
  showAvatars?: boolean;
5236
- /** A saved value whose row is gone, or a row with no name. Default "Unknown". */
5236
+ /** A saved value whose row is gone, or a row with no name. Default "Unknown", in the app's language. */
5237
5237
  unknownText?: string;
5238
5238
  } & (
5239
5239
  | {
@@ -5298,26 +5298,26 @@ export const FilterBar: (props: {
5298
5298
  options: Array<SelectOption>;
5299
5299
  value?: string | number | null;
5300
5300
  onChange: (value: string | number) => void;
5301
- /** Default "Sort". */
5301
+ /** Default "Sort", in the app's language. */
5302
5302
  label?: string;
5303
5303
  };
5304
- /** Default "Search". */
5304
+ /** Default "Search", in the app's language. */
5305
5305
  searchPlaceholder?: string;
5306
- /** A facet with nothing picked. Default "Any". */
5306
+ /** A facet with nothing picked. Default "Any", in the app's language. */
5307
5307
  anyText?: string;
5308
- /** The narrow button and the sheet's title. Default "Filters". */
5308
+ /** The narrow button and the sheet's title. Default "Filters", in the app's language. */
5309
5309
  filtersText?: string;
5310
- /** Spoken after the button's name; `{count}` is the number applied. Default "{count} active". */
5310
+ /** Spoken after the button's name; `{count}` is the number applied. Default "{count} active", in the app's language. */
5311
5311
  activeCountText?: string | ((count: number) => string);
5312
- /** Default "Clear all". */
5312
+ /** Default "Clear all", in the app's language. */
5313
5313
  clearAllText?: string;
5314
- /** Default "Apply". */
5314
+ /** Default "Apply", in the app's language. */
5315
5315
  applyText?: string;
5316
- /** Empties the sheet's facets and puts its sort on the first option. Default "Clear". */
5316
+ /** Empties the sheet's facets and puts its sort on the first option. Default "Clear", in the app's language. */
5317
5317
  clearText?: string;
5318
- /** Names the chip group. Default "Active filters". */
5318
+ /** Names the chip group. Default "Active filters", in the app's language. */
5319
5319
  activeFiltersText?: string;
5320
- /** A chip's remove control; `{label}` is the chip. Default "Remove {label}". */
5320
+ /** A chip's remove control; `{label}` is the chip. Default "Remove {label}", in the app's language. */
5321
5321
  removeText?: string | ((label: string) => string);
5322
5322
  closeAccessibilityLabel?: string;
5323
5323
  /** The outer box; its padding is not counted into the measured width. */
@@ -5358,9 +5358,9 @@ export const SearchField: (props: FormControlProps & {
5358
5358
  iconPosition?: SearchIconPosition;
5359
5359
  /** Called after the clear control empties the field. */
5360
5360
  onClear?: () => void;
5361
- /** Default "Search". */
5361
+ /** Default "Search", in the app's language. */
5362
5362
  placeholder?: string;
5363
- /** Default "Clear search". */
5363
+ /** Default "Clear search", in the app's language. */
5364
5364
  clearAccessibilityLabel?: string;
5365
5365
  /** The input; its flex, margin, width and position keys go to the box around it. */
5366
5366
  style?: any;
@@ -5466,7 +5466,7 @@ export const Banner: (props: {
5466
5466
  action?: { label: string; onPress: () => void; accessibilityLabel?: string; testID?: string };
5467
5467
  /** Shows a close control; hide the banner in the handler. */
5468
5468
  onDismiss?: () => void;
5469
- /** Default "Dismiss". */
5469
+ /** Default "Dismiss", in the app's language. */
5470
5470
  dismissAccessibilityLabel?: string;
5471
5471
  /** For hosts rendering outside a widget context; widgets omit it. */
5472
5472
  theme?: any;
@@ -5688,11 +5688,11 @@ export const FileUpload: (props: FormControlProps & FieldRequiredProps & {
5688
5688
  onReject?: (files: PickedFile[], reason: "type" | "count") => void;
5689
5689
  /** Shows the uploading state and locks the field. */
5690
5690
  uploading?: boolean;
5691
- /** Default "Choose file", or "Choose files" when `multiple`. */
5691
+ /** Default "Choose file", or "Choose files" when `multiple`, in the app's language. */
5692
5692
  buttonLabel?: string;
5693
5693
  /** Default "outlined". */
5694
5694
  buttonVariant?: "primary" | "secondary" | "outlined";
5695
- /** Default "Uploading…". */
5695
+ /** Default "Uploading…", in the app's language. */
5696
5696
  uploadingLabel?: string;
5697
5697
  /** Shown while nothing is chosen, where no drop is possible. */
5698
5698
  emptyLabel?: string;
@@ -5758,7 +5758,7 @@ export const Menu: (props: {
5758
5758
  accessibilityLabel?: string;
5759
5759
  /** Default "bottom"; it flips at the screen edge. */
5760
5760
  placement?: PopoverPlacement;
5761
- /** The sheet backdrop's name. Default "Close". */
5761
+ /** The sheet backdrop's name. Default "Close", in the app's language. */
5762
5762
  closeAccessibilityLabel?: string;
5763
5763
  /** On the panel; the item list takes `-items`. */
5764
5764
  testID?: string;
@@ -5784,7 +5784,7 @@ export const Popover: (props: {
5784
5784
  /** Default "bottom"; it flips at the screen edge. */
5785
5785
  placement?: PopoverPlacement;
5786
5786
  accessibilityLabel?: string;
5787
- /** The sheet backdrop's name. Default "Close". */
5787
+ /** The sheet backdrop's name. Default "Close", in the app's language. */
5788
5788
  closeAccessibilityLabel?: string;
5789
5789
  /** On the panel. */
5790
5790
  testID?: string;
@@ -5818,18 +5818,18 @@ export const Tooltip: (props: {
5818
5818
  * the English default.
5819
5819
  */
5820
5820
  export interface SortableLabels {
5821
- /** The handle's name and its options' title. Default "Move {item}". */
5821
+ /** The handle's name and its options' title. Default "Move {item}", in the app's language. */
5822
5822
  handle?: string;
5823
5823
  hint?: string;
5824
5824
  moveUp?: string;
5825
5825
  moveDown?: string;
5826
5826
  moveToTop?: string;
5827
5827
  moveToBottom?: string;
5828
- /** Default "Move to {column}". */
5828
+ /** Default "Move to {column}", in the app's language. */
5829
5829
  moveToColumn?: string;
5830
- /** Default "{item} moved to position {position} of {total}". */
5830
+ /** Default "{item} moved to position {position} of {total}", in the app's language. */
5831
5831
  moved?: string;
5832
- /** Default "{item} moved to {column}, position {position}". */
5832
+ /** Default "{item} moved to {column}, position {position}", in the app's language. */
5833
5833
  movedToColumn?: string;
5834
5834
  }
5835
5835
 
@@ -2,9 +2,8 @@
2
2
  // (`loading.js` / `loading.native.js`) differ only in their primitives.
3
3
 
4
4
  import React from "react";
5
- import { useHostTheme, useHostSharedText } from "./hooks.js";
5
+ import { useHostTheme, useSdkText } from "./hooks.js";
6
6
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
7
- import { CONTRACT } from "./contract.js";
8
7
  import { resolveListTokens, listRowFrame } from "./list-tokens.js";
9
8
  import { textRoleStyle } from "./text-roles.js";
10
9
  import { flattenStyle } from "./flatten-style.js";
@@ -24,7 +23,6 @@ import {
24
23
  SKELETON_LIST_ROW_LINE_WIDTHS,
25
24
  } from "./loading-tokens.js";
26
25
 
27
- const LOADING_FALLBACK = CONTRACT.sharedTranslationKeys.loading.en;
28
26
  const FILL = { position: "absolute", top: 0, right: 0, bottom: 0, left: 0 };
29
27
  const TRACK_OPACITY = 0.2;
30
28
  const HIDDEN = { "aria-hidden": true, importantForAccessibility: "no-hide-descendants" };
@@ -153,7 +151,7 @@ export function makeLoading(rn, { useNativeDriver }) {
153
151
  testID,
154
152
  }) {
155
153
  const theme = useLoadingTheme(explicitTheme);
156
- const loadingText = useHostSharedText("loading", LOADING_FALLBACK);
154
+ const loadingText = useSdkText()("loading");
157
155
  const moving = !useReducedMotion();
158
156
  useSharedLoop(turn, moving);
159
157
 
@@ -286,7 +284,7 @@ export function makeLoading(rn, { useNativeDriver }) {
286
284
  function Skeleton(props) {
287
285
  const { shape, accessibilityLabel, theme: explicitTheme, style, testID } = props;
288
286
  const theme = useLoadingTheme(explicitTheme);
289
- const loadingText = useHostSharedText("loading", LOADING_FALLBACK);
287
+ const loadingText = useSdkText()("loading");
290
288
  const nested = React.useContext(RegionContext);
291
289
  // The outermost skeleton pulses as one; the bones inside it never animate.
292
290
  const moving = !useReducedMotion() && !nested;
@@ -14,36 +14,33 @@
14
14
  // component is defined once here so the hosts cannot drift (CLAUDE.md §3, §8).
15
15
 
16
16
  import React from "react";
17
- import { useHostTheme } from "./hooks.js";
17
+ import { useHostTheme, useSdkText } from "./hooks.js";
18
18
  import { resolveRichTextTokens } from "./richtext-tokens.js";
19
19
  import { makeMarkdownLinkDialog } from "./markdown-link-dialog.js";
20
20
 
21
+ // A `label` is shown as is; a `labelText` / `spokenText` is a key in the SDK
22
+ // text table, shown in the app's language.
21
23
  const TOOLS = Object.freeze([
22
- { key: "bold", label: "B", accessibilityLabel: "Bold", weight: "700" },
23
- { key: "italic", label: "I", accessibilityLabel: "Italic", italic: true },
24
- { key: "code", label: "‹›", accessibilityLabel: "Code" },
25
- { key: "heading2", label: "H2", accessibilityLabel: "Heading" },
26
- { key: "heading3", label: "H3", accessibilityLabel: "Subheading" },
27
- { key: "bullet", label: "•", accessibilityLabel: "Bulleted list" },
28
- { key: "ordered", label: "1.", accessibilityLabel: "Numbered list" },
29
- { key: "table", label: "Table", accessibilityLabel: "Insert table" },
24
+ { key: "bold", label: "B", spokenText: "format_bold", weight: "700" },
25
+ { key: "italic", label: "I", spokenText: "format_italic", italic: true },
26
+ { key: "code", label: "‹›", spokenText: "format_code" },
27
+ { key: "heading2", label: "H2", spokenText: "format_heading" },
28
+ { key: "heading3", label: "H3", spokenText: "format_subheading" },
29
+ { key: "bullet", label: "•", spokenText: "format_bulleted_list" },
30
+ { key: "ordered", label: "1.", spokenText: "format_numbered_list" },
31
+ { key: "table", labelText: "table", spokenText: "insert_table" },
30
32
  // sc-7349: a link needs a target no selection supplies, so this opens a form.
31
- {
32
- key: "link",
33
- label: "Link",
34
- accessibilityLabel: "Insert link",
35
- opensDialog: true,
36
- },
33
+ { key: "link", labelText: "link", spokenText: "insert_link", opensDialog: true },
37
34
  ]);
38
35
 
39
36
  // Shown while the caret is in a table: a phone keyboard has no Tab key to
40
37
  // grow one, and a table must be removable without selecting around it.
41
38
  const TABLE_TOOLS = Object.freeze([
42
- { key: "addRow", label: "+ Row", accessibilityLabel: "Add row" },
43
- { key: "addColumn", label: "+ Column", accessibilityLabel: "Add column" },
44
- { key: "removeRow", label: "− Row", accessibilityLabel: "Remove row" },
45
- { key: "removeColumn", label: "− Column", accessibilityLabel: "Remove column" },
46
- { key: "removeTable", label: "Delete table", accessibilityLabel: "Delete table" },
39
+ { key: "addRow", labelText: "table_row_short", spokenText: "table_add_row" },
40
+ { key: "addColumn", labelText: "table_column_short", spokenText: "table_add_column" },
41
+ { key: "removeRow", labelText: "table_remove_row_short", spokenText: "table_remove_row" },
42
+ { key: "removeColumn", labelText: "table_remove_column_short", spokenText: "table_remove_column" },
43
+ { key: "removeTable", labelText: "delete_table", spokenText: "delete_table" },
47
44
  ]);
48
45
 
49
46
  export function makeMarkdownInput(rn, Modal, Button, EditorField) {
@@ -66,6 +63,7 @@ export function makeMarkdownInput(rn, Modal, Button, EditorField) {
66
63
  editable = true,
67
64
  }) {
68
65
  const theme = useHostTheme();
66
+ const text = useSdkText();
69
67
  const tokens = React.useMemo(() => resolveRichTextTokens(theme), [theme]);
70
68
  const fieldRef = React.useRef(null);
71
69
  const [linkLabel, setLinkLabel] = React.useState(null);
@@ -123,7 +121,7 @@ export function makeMarkdownInput(rn, Modal, Button, EditorField) {
123
121
  onPress: () => pressTool(tool),
124
122
  disabled: !editable,
125
123
  accessibilityRole: "button",
126
- accessibilityLabel: tool.accessibilityLabel,
124
+ accessibilityLabel: text(tool.spokenText),
127
125
  testID: testID ? `${testID}-${tool.key}` : undefined,
128
126
  style: {
129
127
  minWidth: 36,
@@ -149,7 +147,7 @@ export function makeMarkdownInput(rn, Modal, Button, EditorField) {
149
147
  fontStyle: tool.italic ? "italic" : "normal",
150
148
  },
151
149
  },
152
- tool.label,
150
+ tool.labelText ? text(tool.labelText) : tool.label,
153
151
  ),
154
152
  ),
155
153
  ),
@@ -11,7 +11,7 @@
11
11
  // (see markdown-input.js / .native.js), so the two hosts cannot drift.
12
12
 
13
13
  import React from "react";
14
- import { useHostTheme } from "./hooks.js";
14
+ import { useHostTheme, useSdkText } from "./hooks.js";
15
15
  import { resolveRichTextTokens } from "./richtext-tokens.js";
16
16
 
17
17
  // The page list scrolls rather than growing an app's 40 pages past the panel.
@@ -45,6 +45,7 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
45
45
  function LinkForm({ form, pageList, canPickPage, testID }) {
46
46
  const { label, setLabel, url, setUrl, pageId, setPageId, mode, setMode } = form;
47
47
  const theme = useHostTheme();
48
+ const text = useSdkText();
48
49
  const tokens = React.useMemo(() => resolveRichTextTokens(theme), [theme]);
49
50
 
50
51
  const inputStyle = {
@@ -58,7 +59,7 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
58
59
  padding: tokens.markerGap,
59
60
  };
60
61
 
61
- const tab = (key, text) =>
62
+ const tab = (key, title) =>
62
63
  React.createElement(
63
64
  Pressable,
64
65
  {
@@ -90,7 +91,7 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
90
91
  color: mode === key ? tokens.onAccent : tokens.color,
91
92
  },
92
93
  },
93
- text,
94
+ title,
94
95
  ),
95
96
  );
96
97
 
@@ -99,13 +100,13 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
99
100
  null,
100
101
  React.createElement(
101
102
  Field,
102
- { label: "Link text", tokens },
103
+ { label: text("link_text"), tokens },
103
104
  React.createElement(TextInput, {
104
105
  value: label,
105
106
  onChangeText: setLabel,
106
- placeholder: "Text the reader sees",
107
+ placeholder: text("link_text_placeholder"),
107
108
  placeholderTextColor: tokens.mutedColor,
108
- accessibilityLabel: "Link text",
109
+ accessibilityLabel: text("link_text"),
109
110
  style: inputStyle,
110
111
  testID: testID ? `${testID}-label` : undefined,
111
112
  }),
@@ -120,15 +121,15 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
120
121
  accessibilityRole: "tablist",
121
122
  style: { flexDirection: "row", marginBottom: tokens.blockGap },
122
123
  },
123
- tab("page", "A page in this app"),
124
- tab("url", "An external URL"),
124
+ tab("page", text("link_to_page")),
125
+ tab("url", text("link_to_url")),
125
126
  )
126
127
  : null,
127
128
 
128
129
  mode === "page" && canPickPage
129
130
  ? React.createElement(
130
131
  Field,
131
- { label: "Page", tokens },
132
+ { label: text("link_page"), tokens },
132
133
  React.createElement(
133
134
  ScrollView,
134
135
  {
@@ -176,13 +177,13 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
176
177
  )
177
178
  : React.createElement(
178
179
  Field,
179
- { label: "Address", tokens },
180
+ { label: text("link_address"), tokens },
180
181
  React.createElement(TextInput, {
181
182
  value: url,
182
183
  onChangeText: setUrl,
183
184
  placeholder: "https://example.com",
184
185
  placeholderTextColor: tokens.mutedColor,
185
- accessibilityLabel: "Link address",
186
+ accessibilityLabel: text("link_address_label"),
186
187
  autoCapitalize: "none",
187
188
  autoCorrect: false,
188
189
  keyboardType: "url",
@@ -211,6 +212,7 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
211
212
  initialLabel,
212
213
  testID,
213
214
  }) {
215
+ const text = useSdkText();
214
216
  const pageList = Array.isArray(pages) ? pages.filter((p) => p && p.id) : [];
215
217
  const canPickPage = pageList.length > 0;
216
218
 
@@ -247,10 +249,10 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
247
249
  const actions = React.createElement(
248
250
  React.Fragment,
249
251
  null,
250
- action("cancel", "Cancel", { variant: "secondary", onPress: onClose }),
252
+ action("cancel", text("cancel"), { variant: "secondary", onPress: onClose }),
251
253
  // Disabled until there is somewhere to go — an empty target would
252
254
  // write `[text]()`, which reads as a link and goes nowhere.
253
- action("insert", "Insert link", { disabled: !target, onPress: submit }),
255
+ action("insert", text("insert_link"), { disabled: !target, onPress: submit }),
254
256
  );
255
257
 
256
258
  return React.createElement(
@@ -259,7 +261,7 @@ export function makeMarkdownLinkDialog(rn, Modal, Button) {
259
261
  visible: !!visible,
260
262
  onRequestClose: onClose,
261
263
  size: "sm",
262
- title: "Insert link",
264
+ title: text("insert_link"),
263
265
  footer: actions,
264
266
  testID: testID ? `${testID}-dialog` : undefined,
265
267
  },
@@ -5,7 +5,7 @@
5
5
  // primitives come from, so the web Player and the Expo export cannot drift.
6
6
 
7
7
  import React from "react";
8
- import { ThemeScope, useHostTheme } from "./hooks.js";
8
+ import { ThemeScope, useHostTheme, useSdkText } from "./hooks.js";
9
9
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
10
10
  import { Icon } from "./icon.js";
11
11
  import { overlayCornerStyle } from "./overlay-tokens.js";
@@ -107,7 +107,7 @@ export function makeModal(rn, Overlay) {
107
107
  * native has no equivalent.
108
108
  * @param {{current: any}} [props.initialFocusRef] — the element focused on
109
109
  * open instead of the dialog itself; web only, a no-op on native.
110
- * @param {string} [props.closeAccessibilityLabel] — default "Close".
110
+ * @param {string} [props.closeAccessibilityLabel] — default "Close", in the app's language.
111
111
  * @param {string} [props.accessibilityLabel] — names a dialog with no title.
112
112
  * @param {string} [props.testID] — on the panel; the close button, body and
113
113
  * footer take `-close`, `-body` and `-footer`.
@@ -123,12 +123,13 @@ export function makeModal(rn, Overlay) {
123
123
  dismissOnBackdropPress = true,
124
124
  role = "dialog",
125
125
  initialFocusRef,
126
- closeAccessibilityLabel = "Close",
126
+ closeAccessibilityLabel,
127
127
  accessibilityLabel,
128
128
  testID,
129
129
  children,
130
130
  }) {
131
131
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
132
+ const closeText = useSdkText()("close");
132
133
  const deviceInsets = useSafeAreaInsets();
133
134
  const titleId = React.useId();
134
135
  const t = React.useMemo(
@@ -187,7 +188,7 @@ export function makeModal(rn, Overlay) {
187
188
  {
188
189
  onPress: close,
189
190
  accessibilityRole: "button",
190
- accessibilityLabel: closeAccessibilityLabel,
191
+ accessibilityLabel: closeAccessibilityLabel === undefined ? closeText : closeAccessibilityLabel,
191
192
  testID: part("close"),
192
193
  style: ({ pressed }) => closeStyle(pressed),
193
194
  },
@@ -15,7 +15,7 @@
15
15
  // the hosts cannot drift (CLAUDE.md §3, §8).
16
16
 
17
17
  import React from "react";
18
- import { useHostTheme } from "./hooks.js";
18
+ import { useHostTheme, useSdkText } from "./hooks.js";
19
19
  import { overlayFrameStyles, resolveOverlayTokens } from "./overlay-tokens.js";
20
20
 
21
21
  // Kept clickable, but out of the tab order and the accessibility tree.
@@ -95,7 +95,7 @@ export function makeOverlay(rn) {
95
95
  role = "dialog",
96
96
  accessibilityLabel,
97
97
  accessibilityLabelledBy,
98
- closeAccessibilityLabel = "Close",
98
+ closeAccessibilityLabel,
99
99
  initialFocusRef,
100
100
  panelFrame: PanelFrame,
101
101
  anchoredAt,
@@ -106,6 +106,7 @@ export function makeOverlay(rn) {
106
106
  children,
107
107
  }) {
108
108
  const theme = useHostTheme();
109
+ const closeText = useSdkText()("close");
109
110
  const tokens = React.useMemo(
110
111
  () => resolveOverlayTokens(theme, size, presentation),
111
112
  [theme, size, presentation],
@@ -166,7 +167,7 @@ export function makeOverlay(rn) {
166
167
  ...(backdropAccessible
167
168
  ? {
168
169
  accessibilityRole: "button",
169
- accessibilityLabel: closeAccessibilityLabel,
170
+ accessibilityLabel: closeAccessibilityLabel === undefined ? closeText : closeAccessibilityLabel,
170
171
  }
171
172
  : SILENT_BACKDROP),
172
173
  })