@shoplix-ai/block-kit 3.0.0 → 3.2.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 +88 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/locale.d.ts +13 -2
- package/dist/locale.d.ts.map +1 -1
- package/dist/locale.js +22 -9
- package/dist/locale.js.map +1 -1
- package/dist/money.d.ts +29 -0
- package/dist/money.d.ts.map +1 -1
- package/dist/money.js +141 -1
- package/dist/money.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/words.d.ts +97 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +223 -0
- package/dist/words.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,7 +52,94 @@ written against this package and nothing else from the runtime. It holds:
|
|
|
52
52
|
currency, for display only: the total a buyer sees is always Shopify's),
|
|
53
53
|
`pickLocale` (the buyer's language from the Shop's languages with default
|
|
54
54
|
fallback), `localize` (one string out of a locale object), `textDirection`,
|
|
55
|
-
`imageSourceFor` (the rendition to paint at a given display width)
|
|
55
|
+
`imageSourceFor` (the rendition to paint at a given display width),
|
|
56
|
+
`platformWords`, the word catalog below, and `moneyParts`, `moneyText`,
|
|
57
|
+
`moneyAmount` and `discountPercent`, the money presentation below.
|
|
58
|
+
|
|
59
|
+
## The theme a renderer receives
|
|
60
|
+
|
|
61
|
+
`props.theme` is the Shop's tokens resolved once, by the schema package, for
|
|
62
|
+
every renderer alike: the phone's, the dashboard canvas twin and the CLI's dev
|
|
63
|
+
page. It carries thirteen colour roles, two type families, a corner radius and
|
|
64
|
+
a spacing rhythm, and never a leaf to follow.
|
|
65
|
+
|
|
66
|
+
The colour roles are `brand`, `accent`, `action`, `surface`, `elevated`,
|
|
67
|
+
`text`, `muted`, `border`, `sunken`, `subtle`, `overlay`, `success` and
|
|
68
|
+
`warning`. The last six answer on every theme, whether the merchant named them
|
|
69
|
+
or not: a theme that names none derives them from the palette it does carry, so
|
|
70
|
+
`border` is a hairline that shows on the merchant's own background, `sunken` a
|
|
71
|
+
well under it, `subtle` a dimmer ink than `muted`, `overlay` a scrim in their
|
|
72
|
+
own surface, and the two status colours step toward the merchant's text until
|
|
73
|
+
they are legible on the merchant's surface. A theme that names one wins over
|
|
74
|
+
the derivation. Draw a role rather than a hex: a merchant with a dark theme
|
|
75
|
+
gets an unreadable block otherwise.
|
|
76
|
+
|
|
77
|
+
A design decision too particular for a role goes in the per component tier,
|
|
78
|
+
which is free form and needs no contract change. Read one through
|
|
79
|
+
`componentTokenValue`, by its dotted path under that tier, with a theme role
|
|
80
|
+
behind it:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const line = componentTokenValue(theme, 'divider.line', theme.colors.border);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Two rules hold the convention together. The path names the Block Type first
|
|
87
|
+
and the part it draws second, so one Block Type's tokens sit in one group. The
|
|
88
|
+
fallback is always a theme role, never a literal: a merchant who names nothing
|
|
89
|
+
still gets their own palette, and the token is the escape hatch over it. A
|
|
90
|
+
token of another type is not drawn, the fallback is.
|
|
91
|
+
|
|
92
|
+
## The words a renderer owns
|
|
93
|
+
|
|
94
|
+
A renderer never carries its own literal. Every functional word the platform
|
|
95
|
+
puts on screen lives in one catalog, and a renderer reads it through
|
|
96
|
+
`platformWords(language, defaultLanguage)`:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const words = platformWords(language, defaultLanguage);
|
|
100
|
+
words.own('cart.checkout');
|
|
101
|
+
words.merchantOr(settings.label, 'cart.subtotal');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
A functional word is one the platform owns and the merchant never types:
|
|
105
|
+
Checkout, Sold out, Subtotal, Added, Could not add. Marketing copy, a trust
|
|
106
|
+
strip's promise or a promo card's headline, is merchant set localized text and
|
|
107
|
+
stays out of the catalog, because no catalog can guess it. Where a Block Type
|
|
108
|
+
lets the merchant overwrite a functional word, `merchantOr` takes their text
|
|
109
|
+
when they wrote a language the buyer reads and the catalog's word otherwise.
|
|
110
|
+
|
|
111
|
+
The catalog answers in English, Arabic and Turkish. A language it does not
|
|
112
|
+
carry falls back to English, written down here rather than left to whichever
|
|
113
|
+
string sits first in an object. Every language answers every key of
|
|
114
|
+
`WORD_KEYS`, which the type system and a test both hold; a word added in
|
|
115
|
+
English and nowhere else does not compile.
|
|
116
|
+
|
|
117
|
+
## How a price is written
|
|
118
|
+
|
|
119
|
+
Display money carries the string the Provider formatted in the buyer's language
|
|
120
|
+
and the decimal amount it was formatted from. **Every figure a block computes
|
|
121
|
+
comes from the amount**: reading a number back out of the formatted string
|
|
122
|
+
assumes the full stop is the decimal mark, which is wrong across most of Europe
|
|
123
|
+
and puts a confident nonsense percentage on a badge.
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
const percent = discountPercent(product.price, product.compareAtPrice);
|
|
127
|
+
const { digits, label } = moneyParts(product.price, language, theme.money);
|
|
128
|
+
const line = moneyText(product.price, language, theme.money);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`theme.money` is the digit style the design chose, and there are two.
|
|
132
|
+
`locale`, the default, draws the string the Provider wrote and no label beside
|
|
133
|
+
it. `latin` writes the digits from the amount in Latin numerals, grouped in
|
|
134
|
+
threes at the currency's own number of decimal places, with the currency's
|
|
135
|
+
short label beside them: how the Gulf commerce apps write a price in an Arabic
|
|
136
|
+
app. Money that carries no amount is drawn as the Provider wrote it, whatever
|
|
137
|
+
the style, so a block never loses a price it cannot restyle.
|
|
138
|
+
|
|
139
|
+
The short label comes from a maintained table of the currencies the platform
|
|
140
|
+
writes its own way, the Gulf currencies in Arabic among them. A currency the
|
|
141
|
+
table does not name takes the symbol the buyer's own language writes for it,
|
|
142
|
+
and the three letter code where the language writes none.
|
|
56
143
|
|
|
57
144
|
## Rows: what the host lays out
|
|
58
145
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,9 +11,12 @@ export { defineCodeBlock, shopBlocks } from './code-block.js';
|
|
|
11
11
|
export type { CodeBlock, CodeBlockModule } from './code-block.js';
|
|
12
12
|
export { CONTRACT_MAJOR, CONTRACT_VERSION } from './version.js';
|
|
13
13
|
export { resolveToken } from './tokens.js';
|
|
14
|
-
export { formatMoney } from './money.js';
|
|
14
|
+
export { discountPercent, formatMoney, moneyAmount, moneyParts, moneyText } from './money.js';
|
|
15
|
+
export type { MoneyParts } from './money.js';
|
|
15
16
|
export { imageSourceFor } from './renditions.js';
|
|
16
17
|
export type { ImageSource } from './renditions.js';
|
|
17
18
|
export { localize, pickLocale, textDirection } from './locale.js';
|
|
18
19
|
export type { ShopLanguages } from './locale.js';
|
|
20
|
+
export { CATALOG_LANGUAGES, WORD_KEYS, platformWords } from './words.js';
|
|
21
|
+
export type { PlatformWords, WordKey } from './words.js';
|
|
19
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7F,YAAY,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,GACd,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,mBA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YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC9D,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC9F,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACzE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@ export { defineBinding, defineSettings } from './authoring.js';
|
|
|
5
5
|
export { defineCodeBlock, shopBlocks } from './code-block.js';
|
|
6
6
|
export { CONTRACT_MAJOR, CONTRACT_VERSION } from './version.js';
|
|
7
7
|
export { resolveToken } from './tokens.js';
|
|
8
|
-
export { formatMoney } from './money.js';
|
|
8
|
+
export { discountPercent, formatMoney, moneyAmount, moneyParts, moneyText } from './money.js';
|
|
9
9
|
export { imageSourceFor } from './renditions.js';
|
|
10
10
|
export { localize, pickLocale, textDirection } from './locale.js';
|
|
11
|
+
export { CATALOG_LANGUAGES, WORD_KEYS, platformWords } from './words.js';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAY7F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAY7F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/locale.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface ShopLanguages {
|
|
|
4
4
|
readonly default: LocaleCode;
|
|
5
5
|
readonly supported: readonly LocaleCode[];
|
|
6
6
|
}
|
|
7
|
+
export declare const ENGLISH: LocaleCode;
|
|
8
|
+
export declare function baseOf(locale: string): string;
|
|
7
9
|
/**
|
|
8
10
|
* The buyer's language: the first preferred locale the Shop supports, by
|
|
9
11
|
* exact code, then by base language either way round; the Shop's default
|
|
@@ -11,8 +13,17 @@ export interface ShopLanguages {
|
|
|
11
13
|
*/
|
|
12
14
|
export declare function pickLocale(languages: ShopLanguages, preferred: readonly string[]): LocaleCode;
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
15
|
-
* language,
|
|
16
|
+
* The one string of a locale object the buyer can actually read: their own
|
|
17
|
+
* language, its base language, the Shop's default language, its base.
|
|
18
|
+
* Undefined when the text carries none of them, which is a caller's decision
|
|
19
|
+
* to make rather than a string to guess at.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readable(text: LocalizedText, language: LocaleCode, fallback: LocaleCode): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* One string out of a full locale object: the language the buyer reads, then
|
|
24
|
+
* English, then whatever the text carries. The last step is for merchant
|
|
25
|
+
* written text only, where one language the merchant typed beats nothing at
|
|
26
|
+
* all; a word the platform owns comes from the catalog instead.
|
|
16
27
|
*/
|
|
17
28
|
export declare function localize(text: LocalizedText, language: LocaleCode, fallback: LocaleCode): string;
|
|
18
29
|
export declare function textDirection(language: LocaleCode): TextDirection;
|
package/dist/locale.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../src/locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC;CAC3C;
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../src/locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC;CAC3C;AAID,eAAO,MAAM,OAAO,EAAE,UAAiB,CAAC;AAExC,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAQ7F;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,UAAU,GACnB,MAAM,GAAG,SAAS,CAQpB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,CAEhG;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,UAAU,GAAG,aAAa,CAEjE"}
|
package/dist/locale.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const RTL_LANGUAGES = new Set(['ar', 'he', 'fa', 'ur']);
|
|
2
|
-
|
|
2
|
+
export const ENGLISH = 'en';
|
|
3
|
+
export function baseOf(locale) {
|
|
3
4
|
return locale.split('-')[0].toLowerCase();
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
@@ -19,16 +20,28 @@ export function pickLocale(languages, preferred) {
|
|
|
19
20
|
return languages.default;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
-
* language,
|
|
23
|
+
* The one string of a locale object the buyer can actually read: their own
|
|
24
|
+
* language, its base language, the Shop's default language, its base.
|
|
25
|
+
* Undefined when the text carries none of them, which is a caller's decision
|
|
26
|
+
* to make rather than a string to guess at.
|
|
27
|
+
*/
|
|
28
|
+
export function readable(text, language, fallback) {
|
|
29
|
+
const candidates = [
|
|
30
|
+
text[language],
|
|
31
|
+
text[baseOf(language)],
|
|
32
|
+
text[fallback],
|
|
33
|
+
text[baseOf(fallback)],
|
|
34
|
+
];
|
|
35
|
+
return candidates.find((candidate) => candidate !== undefined && candidate.length > 0);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One string out of a full locale object: the language the buyer reads, then
|
|
39
|
+
* English, then whatever the text carries. The last step is for merchant
|
|
40
|
+
* written text only, where one language the merchant typed beats nothing at
|
|
41
|
+
* all; a word the platform owns comes from the catalog instead.
|
|
24
42
|
*/
|
|
25
43
|
export function localize(text, language, fallback) {
|
|
26
|
-
return (text[
|
|
27
|
-
text[baseOf(language)] ??
|
|
28
|
-
text[fallback] ??
|
|
29
|
-
text[baseOf(fallback)] ??
|
|
30
|
-
Object.values(text)[0] ??
|
|
31
|
-
'');
|
|
44
|
+
return readable(text, language, fallback) ?? text[ENGLISH] ?? Object.values(text)[0] ?? '';
|
|
32
45
|
}
|
|
33
46
|
export function textDirection(language) {
|
|
34
47
|
return RTL_LANGUAGES.has(baseOf(language)) ? 'rtl' : 'ltr';
|
package/dist/locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../src/locale.ts"],"names":[],"mappings":"AAQA,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAExD,
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../src/locale.ts"],"names":[],"mappings":"AAQA,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,OAAO,GAAe,IAAI,CAAC;AAExC,MAAM,UAAU,MAAM,CAAC,MAAc;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,SAAwB,EAAE,SAA4B;IAC/E,KAAK,MAAM,SAAS,IAAI,SAAS,EAAE,CAAC;QAClC,IAAI,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QACxE,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;IACxC,CAAC;IACD,OAAO,SAAS,CAAC,OAAO,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAmB,EACnB,QAAoB,EACpB,QAAoB;IAEpB,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,QAAQ,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KACvB,CAAC;IACF,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAmB,EAAE,QAAoB,EAAE,QAAoB;IACtF,OAAO,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAAoB;IAChD,OAAO,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7D,CAAC"}
|
package/dist/money.d.ts
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
import { type DisplayMoney, type MoneyStyle } from '@shoplix-ai/sdui-schema';
|
|
1
2
|
/**
|
|
2
3
|
* Display-only money, formatted on the device in the buyer's language. The
|
|
3
4
|
* charged price always comes from Shopify checkout, never from this string.
|
|
4
5
|
*/
|
|
5
6
|
export declare function formatMoney(amount: string | number, currencyCode: string, language: string): string | null;
|
|
7
|
+
/** The digits of a price and the short label of its currency, drawn side by side. */
|
|
8
|
+
export interface MoneyParts {
|
|
9
|
+
readonly digits: string;
|
|
10
|
+
readonly label: string;
|
|
11
|
+
}
|
|
12
|
+
/** The number behind display money; null where the Provider recorded none. */
|
|
13
|
+
export declare function moneyAmount(money: DisplayMoney | undefined): number | null;
|
|
14
|
+
/**
|
|
15
|
+
* A price in the two pieces a card lays out itself. Under the latin style the
|
|
16
|
+
* digits are written from the decimal amount and the label is the currency's
|
|
17
|
+
* short one; under every other style, and for money carrying no amount this
|
|
18
|
+
* can be written from, the price stays the one string the Provider wrote and
|
|
19
|
+
* there is no label beside it.
|
|
20
|
+
*
|
|
21
|
+
* The latin style groups in threes with a period decimal whatever grouping the
|
|
22
|
+
* buyer's own language writes, so an Indian English buyer reads 1,234,567.89
|
|
23
|
+
* rather than 12,34,567.89. A merchant wanting the buyer's own grouping takes
|
|
24
|
+
* the locale style.
|
|
25
|
+
*/
|
|
26
|
+
export declare function moneyParts(money: DisplayMoney, language: string, style?: MoneyStyle): MoneyParts;
|
|
27
|
+
/** One price on one line, in the style the theme chose. */
|
|
28
|
+
export declare function moneyText(money: DisplayMoney, language: string, style?: MoneyStyle): string;
|
|
29
|
+
/**
|
|
30
|
+
* The percent off for a badge, from the two decimal amounts of one currency.
|
|
31
|
+
* Null where either side carries no amount, where the currencies differ, or
|
|
32
|
+
* where the saving does not round to a percent worth drawing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function discountPercent(price: DisplayMoney, compareAt: DisplayMoney | undefined): number | null;
|
|
6
35
|
//# sourceMappingURL=money.d.ts.map
|
package/dist/money.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../src/money.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../src/money.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAajC;;;GAGG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CAYf;AAoDD,qFAAqF;AACrF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAI1E;AAyCD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,UAAgC,GACtC,UAAU,CAQZ;AAED,2DAA2D;AAC3D,wBAAgB,SAAS,CACvB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,UAAgC,GACtC,MAAM,CAGR;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,YAAY,GAAG,SAAS,GAClC,MAAM,GAAG,IAAI,CAOf"}
|
package/dist/money.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import { DEFAULT_MONEY_STYLE, } from '@shoplix-ai/sdui-schema';
|
|
2
|
+
import { readable } from './locale.js';
|
|
1
3
|
const CURRENCY_CODE = /^[A-Z]{3}$/;
|
|
4
|
+
/** The decimal shape the display contract records an amount in. */
|
|
5
|
+
const DECIMAL = /^\d+(\.\d+)?$/;
|
|
6
|
+
/** A float that can no longer hold the amount's whole part exactly. */
|
|
7
|
+
function representable(value) {
|
|
8
|
+
return Number.isSafeInteger(Math.trunc(value));
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* Display-only money, formatted on the device in the buyer's language. The
|
|
4
12
|
* charged price always comes from Shopify checkout, never from this string.
|
|
5
13
|
*/
|
|
6
14
|
export function formatMoney(amount, currencyCode, language) {
|
|
7
15
|
const value = typeof amount === 'number' ? amount : Number(amount);
|
|
8
|
-
if (!Number.isFinite(value) || !CURRENCY_CODE.test(currencyCode))
|
|
16
|
+
if (!Number.isFinite(value) || !representable(value) || !CURRENCY_CODE.test(currencyCode)) {
|
|
9
17
|
return null;
|
|
18
|
+
}
|
|
10
19
|
try {
|
|
11
20
|
return new Intl.NumberFormat(language, { style: 'currency', currency: currencyCode }).format(value);
|
|
12
21
|
}
|
|
@@ -14,4 +23,135 @@ export function formatMoney(amount, currencyCode, language) {
|
|
|
14
23
|
return `${amount} ${currencyCode}`;
|
|
15
24
|
}
|
|
16
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The short label the platform draws beside a price where it wants one of its
|
|
28
|
+
* own: the Gulf currencies in Arabic, whose ICU symbol carries a trailing full
|
|
29
|
+
* stop and direction marks a card does not draw. A currency this table does
|
|
30
|
+
* not name takes the symbol the buyer's own language writes for it, and the
|
|
31
|
+
* three letter code where the language writes none.
|
|
32
|
+
*/
|
|
33
|
+
const CURRENCY_LABELS = {
|
|
34
|
+
AED: { ar: 'د.إ' },
|
|
35
|
+
BHD: { ar: 'د.ب' },
|
|
36
|
+
EGP: { ar: 'ج.م' },
|
|
37
|
+
JOD: { ar: 'د.أ' },
|
|
38
|
+
KWD: { ar: 'د.ك' },
|
|
39
|
+
OMR: { ar: 'ر.ع' },
|
|
40
|
+
QAR: { ar: 'ر.ق' },
|
|
41
|
+
SAR: { ar: 'ر.س' },
|
|
42
|
+
USD: { ar: '$' },
|
|
43
|
+
};
|
|
44
|
+
/** The currencies written with other than two decimal places, by ISO 4217. */
|
|
45
|
+
const CURRENCY_PLACES = {
|
|
46
|
+
BHD: 3,
|
|
47
|
+
CLF: 4,
|
|
48
|
+
CLP: 0,
|
|
49
|
+
DJF: 0,
|
|
50
|
+
GNF: 0,
|
|
51
|
+
IQD: 3,
|
|
52
|
+
ISK: 0,
|
|
53
|
+
JOD: 3,
|
|
54
|
+
JPY: 0,
|
|
55
|
+
KMF: 0,
|
|
56
|
+
KRW: 0,
|
|
57
|
+
KWD: 3,
|
|
58
|
+
LYD: 3,
|
|
59
|
+
OMR: 3,
|
|
60
|
+
PYG: 0,
|
|
61
|
+
RWF: 0,
|
|
62
|
+
TND: 3,
|
|
63
|
+
UGX: 0,
|
|
64
|
+
UYI: 0,
|
|
65
|
+
UYW: 4,
|
|
66
|
+
VND: 0,
|
|
67
|
+
VUV: 0,
|
|
68
|
+
XAF: 0,
|
|
69
|
+
XOF: 0,
|
|
70
|
+
XPF: 0,
|
|
71
|
+
};
|
|
72
|
+
const DEFAULT_PLACES = 2;
|
|
73
|
+
/** The number behind display money; null where the Provider recorded none. */
|
|
74
|
+
export function moneyAmount(money) {
|
|
75
|
+
if (money?.amount === undefined)
|
|
76
|
+
return null;
|
|
77
|
+
const value = Number(money.amount);
|
|
78
|
+
return Number.isFinite(value) && representable(value) ? value : null;
|
|
79
|
+
}
|
|
80
|
+
function symbolOf(currencyCode, language) {
|
|
81
|
+
try {
|
|
82
|
+
const parts = new Intl.NumberFormat(language, {
|
|
83
|
+
style: 'currency',
|
|
84
|
+
currency: currencyCode,
|
|
85
|
+
currencyDisplay: 'narrowSymbol',
|
|
86
|
+
}).formatToParts(0);
|
|
87
|
+
return parts.find((part) => part.type === 'currency')?.value;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function currencyLabel(currencyCode, language) {
|
|
94
|
+
const named = CURRENCY_LABELS[currencyCode];
|
|
95
|
+
const own = named === undefined ? undefined : readable(named, language, language);
|
|
96
|
+
return own ?? symbolOf(currencyCode, language) ?? currencyCode;
|
|
97
|
+
}
|
|
98
|
+
/** A decimal amount at a currency's own number of places, rounded half up, never through a float. */
|
|
99
|
+
function atPlaces(amount, places) {
|
|
100
|
+
const [whole = '0', fraction = ''] = amount.split('.');
|
|
101
|
+
if (fraction.length <= places) {
|
|
102
|
+
return places === 0 ? whole : `${whole}.${fraction.padEnd(places, '0')}`;
|
|
103
|
+
}
|
|
104
|
+
const carry = Number(fraction[places]) >= 5 ? 1n : 0n;
|
|
105
|
+
const units = (BigInt(`${whole}${fraction.slice(0, places)}`) + carry)
|
|
106
|
+
.toString()
|
|
107
|
+
.padStart(places + 1, '0');
|
|
108
|
+
return places === 0 ? units : `${units.slice(0, -places)}.${units.slice(-places)}`;
|
|
109
|
+
}
|
|
110
|
+
function latinDigits(amount, currencyCode) {
|
|
111
|
+
const written = atPlaces(amount, CURRENCY_PLACES[currencyCode] ?? DEFAULT_PLACES);
|
|
112
|
+
const [whole = '0', fraction] = written.split('.');
|
|
113
|
+
const grouped = whole.replace(/\B(?=(\d{3})+$)/g, ',');
|
|
114
|
+
return fraction === undefined ? grouped : `${grouped}.${fraction}`;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A price in the two pieces a card lays out itself. Under the latin style the
|
|
118
|
+
* digits are written from the decimal amount and the label is the currency's
|
|
119
|
+
* short one; under every other style, and for money carrying no amount this
|
|
120
|
+
* can be written from, the price stays the one string the Provider wrote and
|
|
121
|
+
* there is no label beside it.
|
|
122
|
+
*
|
|
123
|
+
* The latin style groups in threes with a period decimal whatever grouping the
|
|
124
|
+
* buyer's own language writes, so an Indian English buyer reads 1,234,567.89
|
|
125
|
+
* rather than 12,34,567.89. A merchant wanting the buyer's own grouping takes
|
|
126
|
+
* the locale style.
|
|
127
|
+
*/
|
|
128
|
+
export function moneyParts(money, language, style = DEFAULT_MONEY_STYLE) {
|
|
129
|
+
if (style.digits !== 'latin' || money.amount === undefined || !DECIMAL.test(money.amount)) {
|
|
130
|
+
return { digits: money.formatted, label: '' };
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
digits: latinDigits(money.amount, money.currencyCode),
|
|
134
|
+
label: currencyLabel(money.currencyCode, language),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** One price on one line, in the style the theme chose. */
|
|
138
|
+
export function moneyText(money, language, style = DEFAULT_MONEY_STYLE) {
|
|
139
|
+
const { digits, label } = moneyParts(money, language, style);
|
|
140
|
+
return label === '' ? digits : `${digits} ${label}`;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The percent off for a badge, from the two decimal amounts of one currency.
|
|
144
|
+
* Null where either side carries no amount, where the currencies differ, or
|
|
145
|
+
* where the saving does not round to a percent worth drawing.
|
|
146
|
+
*/
|
|
147
|
+
export function discountPercent(price, compareAt) {
|
|
148
|
+
if (compareAt === undefined || compareAt.currencyCode !== price.currencyCode)
|
|
149
|
+
return null;
|
|
150
|
+
const now = moneyAmount(price);
|
|
151
|
+
const was = moneyAmount(compareAt);
|
|
152
|
+
if (now === null || was === null || was <= now)
|
|
153
|
+
return null;
|
|
154
|
+
const percent = Math.round((1 - now / was) * 100);
|
|
155
|
+
return percent === 0 ? null : percent;
|
|
156
|
+
}
|
|
17
157
|
//# sourceMappingURL=money.js.map
|
package/dist/money.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.js","sourceRoot":"","sources":["../src/money.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,MAAuB,EACvB,YAAoB,EACpB,QAAgB;IAEhB,MAAM,KAAK,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"money.js","sourceRoot":"","sources":["../src/money.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,mEAAmE;AACnE,MAAM,OAAO,GAAG,eAAe,CAAC;AAEhC,uEAAuE;AACvE,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,MAAM,CAAC,aAAa,CAAC,IAAI,CAA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CACvB,KAAmB,EACnB,QAAgB,EAChB,QAAoB,mBAAmB;IAEvC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAmB,EACnB,SAAmC;IAEnC,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,YAAY,KAAK,KAAK,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAC1F,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;IAClD,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;AACxC,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* The major is the compatibility line: a Shop package built against another
|
|
5
5
|
* major never meets this runtime, and a major bump is an announced event.
|
|
6
6
|
*/
|
|
7
|
-
export declare const CONTRACT_VERSION = "3.
|
|
7
|
+
export declare const CONTRACT_VERSION = "3.2.0";
|
|
8
8
|
export declare const CONTRACT_MAJOR = 3;
|
|
9
9
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* The major is the compatibility line: a Shop package built against another
|
|
5
5
|
* major never meets this runtime, and a major bump is an announced event.
|
|
6
6
|
*/
|
|
7
|
-
export const CONTRACT_VERSION = '3.
|
|
7
|
+
export const CONTRACT_VERSION = '3.2.0';
|
|
8
8
|
export const CONTRACT_MAJOR = 3;
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
package/dist/words.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { LocaleCode, LocalizedText } from '@shoplix-ai/sdui-schema';
|
|
2
|
+
/**
|
|
3
|
+
* Every functional word a platform renderer owns, in English. A functional
|
|
4
|
+
* word is one the platform puts on screen and the merchant never types:
|
|
5
|
+
* Checkout, Sold out, Subtotal, Added, Could not add. Marketing copy, a trust
|
|
6
|
+
* strip's promise or a promo card's headline, is merchant set localized text
|
|
7
|
+
* and has no place here, because no catalog can guess it.
|
|
8
|
+
*
|
|
9
|
+
* The key list is this table. A language that answers fewer keys does not
|
|
10
|
+
* compile, and a language the catalog does not carry falls back to English
|
|
11
|
+
* here, deliberately, rather than to whichever string happens to sit first in
|
|
12
|
+
* an object.
|
|
13
|
+
*/
|
|
14
|
+
declare const ENGLISH_WORDS: {
|
|
15
|
+
readonly 'cart.title': "Cart";
|
|
16
|
+
readonly 'cart.close': "Close";
|
|
17
|
+
readonly 'cart.empty': "Your cart is empty";
|
|
18
|
+
readonly 'cart.continue_shopping': "Continue shopping";
|
|
19
|
+
readonly 'cart.items_in_cart': "items in the cart";
|
|
20
|
+
readonly 'cart.subtotal': "Subtotal";
|
|
21
|
+
readonly 'cart.discount': "Discount";
|
|
22
|
+
readonly 'cart.line_discount': "Discount";
|
|
23
|
+
readonly 'cart.total': "Total";
|
|
24
|
+
readonly 'cart.estimated': "estimated";
|
|
25
|
+
readonly 'cart.checkout': "Checkout";
|
|
26
|
+
readonly 'cart.checkout_unavailable': "Checkout is unavailable right now. Please try again.";
|
|
27
|
+
readonly 'cart.remove': "Remove";
|
|
28
|
+
readonly 'cart.decrease': "Decrease quantity";
|
|
29
|
+
readonly 'cart.increase': "Increase quantity";
|
|
30
|
+
readonly 'cart.discount_code': "Discount code";
|
|
31
|
+
readonly 'cart.code_placeholder': "Enter a code";
|
|
32
|
+
readonly 'cart.apply': "Apply";
|
|
33
|
+
readonly 'cart.code_not_applicable': "This code is not valid for this cart";
|
|
34
|
+
readonly 'cart.note_label': "Order note";
|
|
35
|
+
readonly 'cart.note_placeholder': "Anything we should know?";
|
|
36
|
+
readonly 'cart.update_failed': "Could not update the cart";
|
|
37
|
+
readonly 'product.add_to_cart': "Add to cart";
|
|
38
|
+
readonly 'product.added': "Added to cart";
|
|
39
|
+
readonly 'product.add_failed': "Could not add";
|
|
40
|
+
readonly 'product.sold_out': "Sold out";
|
|
41
|
+
readonly 'product.in_stock': "In stock";
|
|
42
|
+
readonly 'product.out_of_stock': "Out of stock";
|
|
43
|
+
readonly 'product.only_left': "Only {count} left";
|
|
44
|
+
readonly 'product.brand': "Brand";
|
|
45
|
+
readonly 'product.type': "Type";
|
|
46
|
+
readonly 'search.title': "Search";
|
|
47
|
+
readonly 'search.placeholder': "Search";
|
|
48
|
+
readonly 'search.prompt': "Search the shop for a product";
|
|
49
|
+
readonly 'search.no_results': "Nothing matched your search";
|
|
50
|
+
readonly 'countdown.days': "Days";
|
|
51
|
+
readonly 'countdown.hours': "Hours";
|
|
52
|
+
readonly 'countdown.minutes': "Minutes";
|
|
53
|
+
readonly 'countdown.seconds': "Seconds";
|
|
54
|
+
readonly 'notifications.ask': "Want to know when your order ships?";
|
|
55
|
+
readonly 'notifications.turn_on': "Turn on";
|
|
56
|
+
readonly 'notifications.hide': "Hide this";
|
|
57
|
+
readonly 'notifications.order_updates': "Order updates";
|
|
58
|
+
readonly 'notifications.on': "On";
|
|
59
|
+
readonly 'notifications.off': "Off";
|
|
60
|
+
readonly 'screen.back': "Back";
|
|
61
|
+
readonly 'screen.unavailable': "Not available";
|
|
62
|
+
readonly 'screen.unavailable_body': "This page is not part of the shop any more.";
|
|
63
|
+
readonly 'screen.unreachable': "The shop could not be reached.";
|
|
64
|
+
readonly 'screen.retry': "Try again";
|
|
65
|
+
readonly 'account.title': "Account";
|
|
66
|
+
readonly 'account.language': "Language";
|
|
67
|
+
readonly 'account.country': "Country";
|
|
68
|
+
readonly 'account.about': "About";
|
|
69
|
+
readonly 'account.version': "Version";
|
|
70
|
+
readonly 'account.shop': "Shop";
|
|
71
|
+
readonly 'account.loading': "Loading the shop settings";
|
|
72
|
+
readonly 'account.no_markets': "No markets to choose from";
|
|
73
|
+
readonly 'account.notifications': "Notifications";
|
|
74
|
+
readonly 'account.privacy': "Privacy";
|
|
75
|
+
readonly 'account.share_diagnostics': "Share app diagnostics";
|
|
76
|
+
};
|
|
77
|
+
export type WordKey = keyof typeof ENGLISH_WORDS;
|
|
78
|
+
/** Every functional word key, for a caller that walks the catalog. */
|
|
79
|
+
export declare const WORD_KEYS: readonly WordKey[];
|
|
80
|
+
/** The languages the catalog answers in its own right. */
|
|
81
|
+
export declare const CATALOG_LANGUAGES: readonly LocaleCode[];
|
|
82
|
+
export interface PlatformWords {
|
|
83
|
+
/** The platform's own word for this key, in the buyer's language. */
|
|
84
|
+
own(key: WordKey): string;
|
|
85
|
+
/**
|
|
86
|
+
* The merchant's own text where they set one in a language the buyer reads,
|
|
87
|
+
* the platform's own word otherwise.
|
|
88
|
+
*/
|
|
89
|
+
merchantOr(text: LocalizedText | undefined, key: WordKey): string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The catalog bound to one buyer: their language for the platform's own words,
|
|
93
|
+
* their language and the Shop's default for a merchant's override of one.
|
|
94
|
+
*/
|
|
95
|
+
export declare function platformWords(language: LocaleCode, defaultLanguage: LocaleCode): PlatformWords;
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=words.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"words.d.ts","sourceRoot":"","sources":["../src/words.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGzE;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DT,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,MAAM,OAAO,aAAa,CAAC;AA0IjD,sEAAsE;AACtE,eAAO,MAAM,SAAS,EAAE,SAAS,OAAO,EAA4C,CAAC;AAErF,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,EAAE,SAAS,UAAU,EAAyB,CAAC;AAE7E,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,GAAG,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;CACnE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,GAAG,aAAa,CAO9F"}
|
package/dist/words.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { ENGLISH, baseOf, readable } from './locale.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every functional word a platform renderer owns, in English. A functional
|
|
4
|
+
* word is one the platform puts on screen and the merchant never types:
|
|
5
|
+
* Checkout, Sold out, Subtotal, Added, Could not add. Marketing copy, a trust
|
|
6
|
+
* strip's promise or a promo card's headline, is merchant set localized text
|
|
7
|
+
* and has no place here, because no catalog can guess it.
|
|
8
|
+
*
|
|
9
|
+
* The key list is this table. A language that answers fewer keys does not
|
|
10
|
+
* compile, and a language the catalog does not carry falls back to English
|
|
11
|
+
* here, deliberately, rather than to whichever string happens to sit first in
|
|
12
|
+
* an object.
|
|
13
|
+
*/
|
|
14
|
+
const ENGLISH_WORDS = {
|
|
15
|
+
'cart.title': 'Cart',
|
|
16
|
+
'cart.close': 'Close',
|
|
17
|
+
'cart.empty': 'Your cart is empty',
|
|
18
|
+
'cart.continue_shopping': 'Continue shopping',
|
|
19
|
+
'cart.items_in_cart': 'items in the cart',
|
|
20
|
+
'cart.subtotal': 'Subtotal',
|
|
21
|
+
'cart.discount': 'Discount',
|
|
22
|
+
'cart.line_discount': 'Discount',
|
|
23
|
+
'cart.total': 'Total',
|
|
24
|
+
'cart.estimated': 'estimated',
|
|
25
|
+
'cart.checkout': 'Checkout',
|
|
26
|
+
'cart.checkout_unavailable': 'Checkout is unavailable right now. Please try again.',
|
|
27
|
+
'cart.remove': 'Remove',
|
|
28
|
+
'cart.decrease': 'Decrease quantity',
|
|
29
|
+
'cart.increase': 'Increase quantity',
|
|
30
|
+
'cart.discount_code': 'Discount code',
|
|
31
|
+
'cart.code_placeholder': 'Enter a code',
|
|
32
|
+
'cart.apply': 'Apply',
|
|
33
|
+
'cart.code_not_applicable': 'This code is not valid for this cart',
|
|
34
|
+
'cart.note_label': 'Order note',
|
|
35
|
+
'cart.note_placeholder': 'Anything we should know?',
|
|
36
|
+
'cart.update_failed': 'Could not update the cart',
|
|
37
|
+
'product.add_to_cart': 'Add to cart',
|
|
38
|
+
'product.added': 'Added to cart',
|
|
39
|
+
'product.add_failed': 'Could not add',
|
|
40
|
+
'product.sold_out': 'Sold out',
|
|
41
|
+
'product.in_stock': 'In stock',
|
|
42
|
+
'product.out_of_stock': 'Out of stock',
|
|
43
|
+
'product.only_left': 'Only {count} left',
|
|
44
|
+
'product.brand': 'Brand',
|
|
45
|
+
'product.type': 'Type',
|
|
46
|
+
'search.title': 'Search',
|
|
47
|
+
'search.placeholder': 'Search',
|
|
48
|
+
'search.prompt': 'Search the shop for a product',
|
|
49
|
+
'search.no_results': 'Nothing matched your search',
|
|
50
|
+
'countdown.days': 'Days',
|
|
51
|
+
'countdown.hours': 'Hours',
|
|
52
|
+
'countdown.minutes': 'Minutes',
|
|
53
|
+
'countdown.seconds': 'Seconds',
|
|
54
|
+
'notifications.ask': 'Want to know when your order ships?',
|
|
55
|
+
'notifications.turn_on': 'Turn on',
|
|
56
|
+
'notifications.hide': 'Hide this',
|
|
57
|
+
'notifications.order_updates': 'Order updates',
|
|
58
|
+
'notifications.on': 'On',
|
|
59
|
+
'notifications.off': 'Off',
|
|
60
|
+
'screen.back': 'Back',
|
|
61
|
+
'screen.unavailable': 'Not available',
|
|
62
|
+
'screen.unavailable_body': 'This page is not part of the shop any more.',
|
|
63
|
+
'screen.unreachable': 'The shop could not be reached.',
|
|
64
|
+
'screen.retry': 'Try again',
|
|
65
|
+
'account.title': 'Account',
|
|
66
|
+
'account.language': 'Language',
|
|
67
|
+
'account.country': 'Country',
|
|
68
|
+
'account.about': 'About',
|
|
69
|
+
'account.version': 'Version',
|
|
70
|
+
'account.shop': 'Shop',
|
|
71
|
+
'account.loading': 'Loading the shop settings',
|
|
72
|
+
'account.no_markets': 'No markets to choose from',
|
|
73
|
+
'account.notifications': 'Notifications',
|
|
74
|
+
'account.privacy': 'Privacy',
|
|
75
|
+
'account.share_diagnostics': 'Share app diagnostics',
|
|
76
|
+
};
|
|
77
|
+
const ARABIC_WORDS = {
|
|
78
|
+
'cart.title': 'السلة',
|
|
79
|
+
'cart.close': 'إغلاق',
|
|
80
|
+
'cart.empty': 'سلتك فارغة',
|
|
81
|
+
'cart.continue_shopping': 'تابع التسوق',
|
|
82
|
+
'cart.items_in_cart': 'عناصر في السلة',
|
|
83
|
+
'cart.subtotal': 'المجموع الفرعي',
|
|
84
|
+
'cart.discount': 'الخصم',
|
|
85
|
+
'cart.line_discount': 'خصم',
|
|
86
|
+
'cart.total': 'الإجمالي',
|
|
87
|
+
'cart.estimated': 'تقديري',
|
|
88
|
+
'cart.checkout': 'الدفع',
|
|
89
|
+
'cart.checkout_unavailable': 'الدفع غير متاح حاليًا. حاول مرة أخرى.',
|
|
90
|
+
'cart.remove': 'إزالة',
|
|
91
|
+
'cart.decrease': 'تقليل الكمية',
|
|
92
|
+
'cart.increase': 'زيادة الكمية',
|
|
93
|
+
'cart.discount_code': 'رمز الخصم',
|
|
94
|
+
'cart.code_placeholder': 'أدخل الرمز',
|
|
95
|
+
'cart.apply': 'تطبيق',
|
|
96
|
+
'cart.code_not_applicable': 'هذا الرمز غير صالح لهذه السلة',
|
|
97
|
+
'cart.note_label': 'ملاحظة الطلب',
|
|
98
|
+
'cart.note_placeholder': 'هل من شيء يجب أن نعرفه؟',
|
|
99
|
+
'cart.update_failed': 'تعذّر تحديث السلة',
|
|
100
|
+
'product.add_to_cart': 'أضف إلى السلة',
|
|
101
|
+
'product.added': 'أُضيف إلى السلة',
|
|
102
|
+
'product.add_failed': 'تعذّرت الإضافة',
|
|
103
|
+
'product.sold_out': 'نفذت الكمية',
|
|
104
|
+
'product.in_stock': 'متوفر',
|
|
105
|
+
'product.out_of_stock': 'نفدت الكمية',
|
|
106
|
+
'product.only_left': 'المتبقي {count} فقط',
|
|
107
|
+
'product.brand': 'العلامة',
|
|
108
|
+
'product.type': 'النوع',
|
|
109
|
+
'search.title': 'بحث',
|
|
110
|
+
'search.placeholder': 'بحث',
|
|
111
|
+
'search.prompt': 'ابحث عن منتج في المتجر',
|
|
112
|
+
'search.no_results': 'لا نتائج لبحثك',
|
|
113
|
+
'countdown.days': 'أيام',
|
|
114
|
+
'countdown.hours': 'ساعات',
|
|
115
|
+
'countdown.minutes': 'دقائق',
|
|
116
|
+
'countdown.seconds': 'ثوان',
|
|
117
|
+
'notifications.ask': 'هل تريد معرفة موعد شحن طلبك؟',
|
|
118
|
+
'notifications.turn_on': 'تفعيل',
|
|
119
|
+
'notifications.hide': 'إخفاء',
|
|
120
|
+
'notifications.order_updates': 'تحديثات الطلب',
|
|
121
|
+
'notifications.on': 'مفعّلة',
|
|
122
|
+
'notifications.off': 'متوقفة',
|
|
123
|
+
'screen.back': 'رجوع',
|
|
124
|
+
'screen.unavailable': 'غير متاح',
|
|
125
|
+
'screen.unavailable_body': 'هذه الصفحة لم تعد جزءًا من المتجر.',
|
|
126
|
+
'screen.unreachable': 'تعذر الوصول إلى المتجر.',
|
|
127
|
+
'screen.retry': 'حاول مرة أخرى',
|
|
128
|
+
'account.title': 'الحساب',
|
|
129
|
+
'account.language': 'اللغة',
|
|
130
|
+
'account.country': 'الدولة',
|
|
131
|
+
'account.about': 'عن التطبيق',
|
|
132
|
+
'account.version': 'الإصدار',
|
|
133
|
+
'account.shop': 'المتجر',
|
|
134
|
+
'account.loading': 'جارٍ تحميل إعدادات المتجر',
|
|
135
|
+
'account.no_markets': 'لا أسواق للاختيار منها',
|
|
136
|
+
'account.notifications': 'الإشعارات',
|
|
137
|
+
'account.privacy': 'الخصوصية',
|
|
138
|
+
'account.share_diagnostics': 'مشاركة بيانات تشخيص التطبيق',
|
|
139
|
+
};
|
|
140
|
+
const TURKISH_WORDS = {
|
|
141
|
+
'cart.title': 'Sepet',
|
|
142
|
+
'cart.close': 'Kapat',
|
|
143
|
+
'cart.empty': 'Sepetiniz boş',
|
|
144
|
+
'cart.continue_shopping': 'Alışverişe devam et',
|
|
145
|
+
'cart.items_in_cart': 'sepetteki ürün',
|
|
146
|
+
'cart.subtotal': 'Ara toplam',
|
|
147
|
+
'cart.discount': 'İndirim',
|
|
148
|
+
'cart.line_discount': 'İndirim',
|
|
149
|
+
'cart.total': 'Toplam',
|
|
150
|
+
'cart.estimated': 'tahmini',
|
|
151
|
+
'cart.checkout': 'Ödeme',
|
|
152
|
+
'cart.checkout_unavailable': 'Ödeme şu anda kullanılamıyor. Lütfen tekrar deneyin.',
|
|
153
|
+
'cart.remove': 'Kaldır',
|
|
154
|
+
'cart.decrease': 'Adedi azalt',
|
|
155
|
+
'cart.increase': 'Adedi artır',
|
|
156
|
+
'cart.discount_code': 'İndirim kodu',
|
|
157
|
+
'cart.code_placeholder': 'Bir kod girin',
|
|
158
|
+
'cart.apply': 'Uygula',
|
|
159
|
+
'cart.code_not_applicable': 'Bu kod bu sepet için geçerli değil',
|
|
160
|
+
'cart.note_label': 'Sipariş notu',
|
|
161
|
+
'cart.note_placeholder': 'Bilmemiz gereken bir şey var mı?',
|
|
162
|
+
'cart.update_failed': 'Sepet güncellenemedi',
|
|
163
|
+
'product.add_to_cart': 'Sepete ekle',
|
|
164
|
+
'product.added': 'Sepete eklendi',
|
|
165
|
+
'product.add_failed': 'Eklenemedi',
|
|
166
|
+
'product.sold_out': 'Tükendi',
|
|
167
|
+
'product.in_stock': 'Stokta var',
|
|
168
|
+
'product.out_of_stock': 'Stokta yok',
|
|
169
|
+
'product.only_left': 'Yalnızca {count} adet kaldı',
|
|
170
|
+
'product.brand': 'Marka',
|
|
171
|
+
'product.type': 'Tür',
|
|
172
|
+
'search.title': 'Ara',
|
|
173
|
+
'search.placeholder': 'Ara',
|
|
174
|
+
'search.prompt': 'Mağazada bir ürün arayın',
|
|
175
|
+
'search.no_results': 'Aramanızla eşleşen bir sonuç yok',
|
|
176
|
+
'countdown.days': 'Gün',
|
|
177
|
+
'countdown.hours': 'Saat',
|
|
178
|
+
'countdown.minutes': 'Dakika',
|
|
179
|
+
'countdown.seconds': 'Saniye',
|
|
180
|
+
'notifications.ask': 'Siparişinizin ne zaman kargolandığını öğrenmek ister misiniz?',
|
|
181
|
+
'notifications.turn_on': 'Aç',
|
|
182
|
+
'notifications.hide': 'Bunu gizle',
|
|
183
|
+
'notifications.order_updates': 'Sipariş bildirimleri',
|
|
184
|
+
'notifications.on': 'Açık',
|
|
185
|
+
'notifications.off': 'Kapalı',
|
|
186
|
+
'screen.back': 'Geri',
|
|
187
|
+
'screen.unavailable': 'Kullanılamıyor',
|
|
188
|
+
'screen.unavailable_body': 'Bu sayfa artık mağazanın bir parçası değil.',
|
|
189
|
+
'screen.unreachable': 'Mağazaya ulaşılamadı.',
|
|
190
|
+
'screen.retry': 'Tekrar dene',
|
|
191
|
+
'account.title': 'Hesap',
|
|
192
|
+
'account.language': 'Dil',
|
|
193
|
+
'account.country': 'Ülke',
|
|
194
|
+
'account.about': 'Hakkında',
|
|
195
|
+
'account.version': 'Sürüm',
|
|
196
|
+
'account.shop': 'Mağaza',
|
|
197
|
+
'account.loading': 'Mağaza ayarları yükleniyor',
|
|
198
|
+
'account.no_markets': 'Seçilecek pazar yok',
|
|
199
|
+
'account.notifications': 'Bildirimler',
|
|
200
|
+
'account.privacy': 'Gizlilik',
|
|
201
|
+
'account.share_diagnostics': 'Uygulama tanılama verilerini paylaş',
|
|
202
|
+
};
|
|
203
|
+
const CATALOG = {
|
|
204
|
+
en: ENGLISH_WORDS,
|
|
205
|
+
ar: ARABIC_WORDS,
|
|
206
|
+
tr: TURKISH_WORDS,
|
|
207
|
+
};
|
|
208
|
+
/** Every functional word key, for a caller that walks the catalog. */
|
|
209
|
+
export const WORD_KEYS = Object.keys(ENGLISH_WORDS);
|
|
210
|
+
/** The languages the catalog answers in its own right. */
|
|
211
|
+
export const CATALOG_LANGUAGES = Object.keys(CATALOG);
|
|
212
|
+
/**
|
|
213
|
+
* The catalog bound to one buyer: their language for the platform's own words,
|
|
214
|
+
* their language and the Shop's default for a merchant's override of one.
|
|
215
|
+
*/
|
|
216
|
+
export function platformWords(language, defaultLanguage) {
|
|
217
|
+
const table = CATALOG[language] ?? CATALOG[baseOf(language)] ?? CATALOG[ENGLISH];
|
|
218
|
+
return {
|
|
219
|
+
own: (key) => table[key],
|
|
220
|
+
merchantOr: (text, key) => (text === undefined ? undefined : readable(text, language, defaultLanguage)) ?? table[key],
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=words.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"words.js","sourceRoot":"","sources":["../src/words.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,aAAa,GAAG;IACpB,YAAY,EAAE,MAAM;IACpB,YAAY,EAAE,OAAO;IACrB,YAAY,EAAE,oBAAoB;IAClC,wBAAwB,EAAE,mBAA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,OAAO,GAAwC;IACnD,EAAE,EAAE,aAAa;IACjB,EAAE,EAAE,YAAY;IAChB,EAAE,EAAE,aAAa;CAClB,CAAC;AAEF,sEAAsE;AACtE,MAAM,CAAC,MAAM,SAAS,GAAuB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAc,CAAC;AAErF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAA0B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAY7E;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAoB,EAAE,eAA2B;IAC7E,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAE,CAAC;IAClF,OAAO;QACL,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;QACxB,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CACxB,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC;KAC7F,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shoplix-ai/block-kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "The renderer contract every Block Type renderer is written against: what a renderer receives, how a Block Type is registered with its owner, the closed capability set, and the small helpers renderers share. Contract only, no renderers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@shoplix-ai/sdui-schema": "1.
|
|
29
|
+
"@shoplix-ai/sdui-schema": "1.10.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": ">=19.0.0"
|