@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.
- package/README.md +5 -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 +19 -2
- package/dist/contract.js +19 -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/hooks.js +29 -5
- package/dist/index.d.ts +30 -30
- 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 +19 -2
- package/src/sdk-texts.js +155 -0
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 +
|
|
@@ -7029,7 +7040,10 @@ const CONTRACT = deepFreeze({
|
|
|
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,
|
|
7031
7042
|
// prefix, description, mode, size, count, colour, icon or type.
|
|
7032
|
-
|
|
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",
|
|
7033
7047
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7034
7048
|
hooks: HOOKS,
|
|
7035
7049
|
primitives: PRIMITIVES,
|
|
@@ -7635,4 +7649,7 @@ export {
|
|
|
7635
7649
|
sharedTranslationKey,
|
|
7636
7650
|
isSharedTranslationKey,
|
|
7637
7651
|
SHARED_TRANSLATION_KEYS,
|
|
7652
|
+
SDK_TEXTS,
|
|
7653
|
+
sdkText,
|
|
7654
|
+
fillSdkText,
|
|
7638
7655
|
};
|
package/src/sdk-texts.js
ADDED
|
@@ -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
|
+
}
|