@colixsystems/widget-sdk 0.326.0 → 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.
- package/README.md +9 -1
- package/dist/banner-view.js +6 -4
- package/dist/board-view.js +2 -2
- package/dist/chart-view.js +2 -4
- package/dist/confirm-dialog-view.js +5 -4
- package/dist/contract.cjs +21 -2
- package/dist/contract.js +21 -2
- package/dist/data-table-logic.js +10 -6
- package/dist/data-table-view.js +4 -6
- package/dist/datetimepicker-format.js +6 -4
- package/dist/datetimepicker-view.js +6 -5
- package/dist/emoji-picker-view.js +27 -15
- package/dist/file-upload-view.js +34 -12
- package/dist/filter-bar-view.js +42 -24
- package/dist/form-view.js +3 -2
- package/dist/group-id-text.cjs +49 -0
- package/dist/group-id-text.js +42 -0
- package/dist/hooks.js +29 -5
- package/dist/index.d.ts +30 -30
- package/dist/linter.cjs +3 -35
- package/dist/linter.js +3 -35
- package/dist/loading-view.js +3 -5
- package/dist/markdown-input-view.js +20 -22
- package/dist/markdown-link-dialog.js +16 -14
- package/dist/modal-view.js +5 -4
- package/dist/overlay-view.js +4 -3
- package/dist/people-picker-view.js +7 -3
- package/dist/radio-group-view.js +3 -2
- package/dist/scroll-view.js +4 -3
- package/dist/sdk-texts.cjs +164 -0
- package/dist/sdk-texts.js +155 -0
- package/dist/search-field-view.js +6 -4
- package/dist/select-logic.js +0 -5
- package/dist/select-view.js +29 -17
- package/dist/sortable-list-view.js +2 -2
- package/dist/sortable-logic.js +29 -15
- package/dist/text-field-view.js +3 -2
- package/package.json +3 -2
- package/src/contract.js +21 -2
- package/src/sdk-texts.js +155 -0
|
@@ -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(
|
|
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
|
|
29
|
-
clearAccessibilityLabel
|
|
30
|
+
placeholder,
|
|
31
|
+
clearAccessibilityLabel,
|
|
30
32
|
label,
|
|
31
33
|
disabled = false,
|
|
32
34
|
accessibilityLabel,
|
package/dist/select-logic.js
CHANGED
|
@@ -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 : [];
|
package/dist/select-view.js
CHANGED
|
@@ -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 {
|
|
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" ?
|
|
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(
|
|
335
|
-
useStrictProps("Select",
|
|
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
|
|
343
|
-
doneText
|
|
352
|
+
selectedCountText,
|
|
353
|
+
doneText,
|
|
344
354
|
options,
|
|
345
|
-
placeholder
|
|
355
|
+
placeholder,
|
|
346
356
|
title,
|
|
347
|
-
emptyText
|
|
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
|
|
367
|
-
noResultsText
|
|
368
|
-
loadingText
|
|
369
|
-
loadErrorText
|
|
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 =
|
|
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");
|
package/dist/sortable-logic.js
CHANGED
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
handle: "
|
|
20
|
-
hint: "
|
|
21
|
-
moveUp: "
|
|
22
|
-
moveDown: "
|
|
23
|
-
moveToTop: "
|
|
24
|
-
moveToBottom: "
|
|
25
|
-
moveToColumn: "
|
|
26
|
-
moved: "
|
|
27
|
-
movedToColumn: "
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
const out =
|
|
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(
|
|
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;
|
package/dist/text-field-view.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// from, so the hosts cannot drift.
|
|
4
4
|
|
|
5
5
|
import React from "react";
|
|
6
|
-
import {
|
|
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
|
|
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 = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.327.0",
|
|
4
4
|
"description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
"src/webbundle.js",
|
|
64
64
|
"src/dev-shims.js",
|
|
65
65
|
"src/contract.js",
|
|
66
|
-
"src/component-props.js"
|
|
66
|
+
"src/component-props.js",
|
|
67
|
+
"src/sdk-texts.js"
|
|
67
68
|
],
|
|
68
69
|
"scripts": {
|
|
69
70
|
"build": "node scripts/build.js",
|
package/src/contract.js
CHANGED
|
@@ -9,6 +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
13
|
|
|
13
14
|
const ELEVATION = Object.freeze({
|
|
14
15
|
none: Object.freeze({}),
|
|
@@ -3952,7 +3953,7 @@ const PRIMITIVES = [
|
|
|
3952
3953
|
{
|
|
3953
3954
|
name: "Select",
|
|
3954
3955
|
description:
|
|
3955
|
-
'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"), `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.',
|
|
3956
|
+
'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.',
|
|
3956
3957
|
rnComponent: null,
|
|
3957
3958
|
docsUrl: null,
|
|
3958
3959
|
},
|
|
@@ -5522,6 +5523,16 @@ function isSharedTranslationKey(key) {
|
|
|
5522
5523
|
);
|
|
5523
5524
|
}
|
|
5524
5525
|
|
|
5526
|
+
// sc-16877 — every default text an SDK component shows: the shared keys a
|
|
5527
|
+
// workspace's dictionary can reword, plus the component texts in sdk-texts.js.
|
|
5528
|
+
const SDK_TEXTS = Object.freeze({ ...SHARED_TRANSLATION_KEYS, ...COMPONENT_TEXTS });
|
|
5529
|
+
|
|
5530
|
+
/** `key`'s built-in text in `locale`, English when that language ships none. */
|
|
5531
|
+
function sdkText(key, locale, values) {
|
|
5532
|
+
const entry = SDK_TEXTS[key];
|
|
5533
|
+
return entry ? textInLanguage(entry, locale, values) : key;
|
|
5534
|
+
}
|
|
5535
|
+
|
|
5525
5536
|
const CONTRACT = deepFreeze({
|
|
5526
5537
|
// REQ-WSDK-PLATFORM bump:
|
|
5527
5538
|
// - `vettedImports` is a new field (rich allowlist with platforms +
|
|
@@ -7027,7 +7038,12 @@ const CONTRACT = deepFreeze({
|
|
|
7027
7038
|
// `editable={false}` locks the field and its toolbar.
|
|
7028
7039
|
// 1.265.0: `font` is a field type, and a font named in the source is
|
|
7029
7040
|
// `no-hardcoded-design` with no licence (sc-17364).
|
|
7030
|
-
|
|
7041
|
+
// 1.265.1: narrower lint — `group-ids-as-text` passes a group's name,
|
|
7042
|
+
// prefix, description, mode, size, count, colour, icon or type.
|
|
7043
|
+
// 1.266.0: behaviour (sc-16877) — a component's default texts (Select's
|
|
7044
|
+
// "Select", "Done", "No options", …) are in the app's language: English
|
|
7045
|
+
// and Swedish ship, any other language reads English.
|
|
7046
|
+
version: "1.266.0",
|
|
7031
7047
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7032
7048
|
hooks: HOOKS,
|
|
7033
7049
|
primitives: PRIMITIVES,
|
|
@@ -7633,4 +7649,7 @@ export {
|
|
|
7633
7649
|
sharedTranslationKey,
|
|
7634
7650
|
isSharedTranslationKey,
|
|
7635
7651
|
SHARED_TRANSLATION_KEYS,
|
|
7652
|
+
SDK_TEXTS,
|
|
7653
|
+
sdkText,
|
|
7654
|
+
fillSdkText,
|
|
7636
7655
|
};
|