@shoplix-ai/block-kit 4.6.0 → 5.16.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 +116 -10
- package/dist/account-links.d.ts +96 -0
- package/dist/account-links.d.ts.map +1 -0
- package/dist/account-links.js +121 -0
- package/dist/account-links.js.map +1 -0
- package/dist/address-list.d.ts +58 -0
- package/dist/address-list.d.ts.map +1 -0
- package/dist/address-list.js +57 -0
- package/dist/address-list.js.map +1 -0
- package/dist/buy-box.d.ts +8 -0
- package/dist/buy-box.d.ts.map +1 -1
- package/dist/buy-box.js +8 -0
- package/dist/buy-box.js.map +1 -1
- package/dist/capabilities.d.ts +12 -2
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js.map +1 -1
- package/dist/category-grid.d.ts +92 -0
- package/dist/category-grid.d.ts.map +1 -0
- package/dist/category-grid.js +123 -0
- package/dist/category-grid.js.map +1 -0
- package/dist/color-choice.d.ts +4 -0
- package/dist/color-choice.d.ts.map +1 -0
- package/dist/color-choice.js +11 -0
- package/dist/color-choice.js.map +1 -0
- package/dist/content-direction.d.ts +10 -0
- package/dist/content-direction.d.ts.map +1 -0
- package/dist/content-direction.js +20 -0
- package/dist/content-direction.js.map +1 -0
- package/dist/contract.d.ts +20 -14
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +3 -2
- package/dist/contract.js.map +1 -1
- package/dist/description.d.ts +60 -0
- package/dist/description.d.ts.map +1 -0
- package/dist/description.js +332 -0
- package/dist/description.js.map +1 -0
- package/dist/hero-banner.d.ts +10 -1
- package/dist/hero-banner.d.ts.map +1 -1
- package/dist/hero-banner.js +17 -0
- package/dist/hero-banner.js.map +1 -1
- package/dist/index.d.ts +32 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/listing-filters.d.ts +114 -0
- package/dist/listing-filters.d.ts.map +1 -0
- package/dist/listing-filters.js +195 -0
- package/dist/listing-filters.js.map +1 -0
- package/dist/listing-toolbar.d.ts +117 -0
- package/dist/listing-toolbar.d.ts.map +1 -0
- package/dist/listing-toolbar.js +130 -0
- package/dist/listing-toolbar.js.map +1 -0
- package/dist/money.d.ts +7 -0
- package/dist/money.d.ts.map +1 -1
- package/dist/money.js +15 -0
- package/dist/money.js.map +1 -1
- package/dist/navigation.d.ts +10 -2
- package/dist/navigation.d.ts.map +1 -1
- package/dist/orders.d.ts +162 -0
- package/dist/orders.d.ts.map +1 -0
- package/dist/orders.js +302 -0
- package/dist/orders.js.map +1 -0
- package/dist/product-card.d.ts +4 -0
- package/dist/product-card.d.ts.map +1 -1
- package/dist/product-card.js +4 -0
- package/dist/product-card.js.map +1 -1
- package/dist/product-gallery.d.ts +3 -0
- package/dist/product-gallery.d.ts.map +1 -1
- package/dist/product-gallery.js +3 -0
- package/dist/product-gallery.js.map +1 -1
- package/dist/product-specs.d.ts +33 -2
- package/dist/product-specs.d.ts.map +1 -1
- package/dist/product-specs.js +51 -2
- package/dist/product-specs.js.map +1 -1
- package/dist/product-summary.d.ts +12 -1
- package/dist/product-summary.d.ts.map +1 -1
- package/dist/product-summary.js +29 -0
- package/dist/product-summary.js.map +1 -1
- package/dist/profile-header.d.ts +30 -0
- package/dist/profile-header.d.ts.map +1 -0
- package/dist/profile-header.js +36 -0
- package/dist/profile-header.js.map +1 -0
- package/dist/promo-banner.d.ts +11 -1
- package/dist/promo-banner.d.ts.map +1 -1
- package/dist/promo-banner.js +24 -0
- package/dist/promo-banner.js.map +1 -1
- package/dist/section-header.d.ts +5 -1
- package/dist/section-header.d.ts.map +1 -1
- package/dist/section-header.js +5 -1
- package/dist/section-header.js.map +1 -1
- package/dist/sign-in.d.ts +28 -0
- package/dist/sign-in.d.ts.map +1 -0
- package/dist/sign-in.js +27 -0
- package/dist/sign-in.js.map +1 -0
- package/dist/store-header.d.ts +49 -6
- package/dist/store-header.d.ts.map +1 -1
- package/dist/store-header.js +59 -5
- package/dist/store-header.js.map +1 -1
- package/dist/variant-choice.d.ts +14 -0
- package/dist/variant-choice.d.ts.map +1 -1
- package/dist/variant-choice.js +36 -0
- package/dist/variant-choice.js.map +1 -1
- package/dist/variant-rows.d.ts +33 -0
- package/dist/variant-rows.d.ts.map +1 -0
- package/dist/variant-rows.js +52 -0
- package/dist/variant-rows.js.map +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +2 -2
- package/dist/version.js.map +1 -1
- package/dist/words.d.ts +185 -0
- package/dist/words.d.ts.map +1 -1
- package/dist/words.js +530 -4
- package/dist/words.js.map +1 -1
- package/package.json +2 -2
package/dist/product-specs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
1
|
+
import type { ColorChoice, LocaleCode, ProductDisplay, ProductSectionProps, ProductSectionType, ProductSpecificationsBlock, ShippingReturnsBlock, ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
2
2
|
/** The parts of the product specs, each with the theme role it draws unless a component token names another. */
|
|
3
3
|
declare const PRODUCT_SPECS_ROLES: {
|
|
4
4
|
readonly surface: "elevated";
|
|
@@ -12,6 +12,7 @@ declare const PRODUCT_SPECS_ROLES: {
|
|
|
12
12
|
readonly glyph_surface: "sunken";
|
|
13
13
|
readonly glyph: "text";
|
|
14
14
|
readonly note: "muted";
|
|
15
|
+
readonly ledger_label: "muted";
|
|
15
16
|
};
|
|
16
17
|
export type ProductSpecsPart = keyof typeof PRODUCT_SPECS_ROLES;
|
|
17
18
|
export type ProductSpecsColors = Readonly<Record<ProductSpecsPart, string>>;
|
|
@@ -19,7 +20,37 @@ export type ProductSpecsColors = Readonly<Record<ProductSpecsPart, string>>;
|
|
|
19
20
|
* Every colour the specs draw, one per part, with `product_specs.<part>` as
|
|
20
21
|
* the escape hatch over each theme role. The body and the table's values take
|
|
21
22
|
* the text role rather than the muted one: a size chart is read, not skimmed.
|
|
23
|
+
* The three sections of the product page read the same table, so a theme
|
|
24
|
+
* paints them as it painted the specs, and a surface the merchant chose for
|
|
25
|
+
* one section wins over it.
|
|
22
26
|
*/
|
|
23
|
-
export declare function productSpecsColors(theme: ThemeStyle
|
|
27
|
+
export declare function productSpecsColors(theme: ThemeStyle, settings?: {
|
|
28
|
+
readonly surface?: ColorChoice;
|
|
29
|
+
}): ProductSpecsColors;
|
|
30
|
+
/** The catalog's title of each section of the product page, the one the specs drew over it. */
|
|
31
|
+
export declare const PRODUCT_SECTION_TITLES: {
|
|
32
|
+
readonly product_description: "product.details";
|
|
33
|
+
readonly product_specifications: "product.specifications";
|
|
34
|
+
readonly shipping_returns: "product.shipping_returns";
|
|
35
|
+
};
|
|
36
|
+
/** A section's title: the merchant's own where they wrote one the buyer reads, the catalog's otherwise. */
|
|
37
|
+
export declare function productSectionTitle(type: ProductSectionType, title: ProductSectionProps['title'], language: LocaleCode, defaultLanguage: LocaleCode): string;
|
|
38
|
+
export interface ProductSpecRow {
|
|
39
|
+
readonly key: string;
|
|
40
|
+
readonly label: string;
|
|
41
|
+
readonly value: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The rows the table draws: the facts table of the product's description
|
|
45
|
+
* first where the block reads it, then the merchant's own rows, and the facts
|
|
46
|
+
* the Storefront answers where neither says anything, so a merchant who has
|
|
47
|
+
* written nothing still gets a table rather than a heading over a gap.
|
|
48
|
+
*/
|
|
49
|
+
export declare function productSpecRows(specs: ProductSpecificationsBlock['props']['specs'], product: ProductDisplay, language: LocaleCode, defaultLanguage: LocaleCode, options?: {
|
|
50
|
+
readonly descriptionTable?: boolean;
|
|
51
|
+
}): ProductSpecRow[];
|
|
52
|
+
export type ShippingRow = NonNullable<ShippingReturnsBlock['props']['shipping']>[number];
|
|
53
|
+
/** The shipping rows a card draws: every row whose title the buyer can read, in the merchant's order. */
|
|
54
|
+
export declare function shippingRowsOf(shipping: readonly ShippingRow[] | undefined, language: LocaleCode, defaultLanguage: LocaleCode): ShippingRow[];
|
|
24
55
|
export {};
|
|
25
56
|
//# sourceMappingURL=product-specs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-specs.d.ts","sourceRoot":"","sources":["../src/product-specs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"product-specs.d.ts","sourceRoot":"","sources":["../src/product-specs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,UAAU,EACX,MAAM,yBAAyB,CAAC;AAOjC,gHAAgH;AAChH,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;CAasC,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5E;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,QAAQ,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,GAChD,kBAAkB,CAGpB;AAED,+FAA+F;AAC/F,eAAO,MAAM,sBAAsB;;;;CAIqB,CAAC;AAEzD,2GAA2G;AAC3G,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,EACnC,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,UAAU,GAC1B,MAAM,CAER;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EACnD,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,UAAU,EAC3B,OAAO,GAAE;IAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,GACpD,cAAc,EAAE,CAmBlB;AAED,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzF,yGAAyG;AACzG,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,EAC5C,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,UAAU,GAC1B,WAAW,EAAE,CAEf"}
|
package/dist/product-specs.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { colorChoiceOf } from './color-choice.js';
|
|
2
|
+
import { localize } from './locale.js';
|
|
1
3
|
import { partColors } from './part-colors.js';
|
|
4
|
+
import { platformWords } from './words.js';
|
|
5
|
+
import { descriptionFacts } from './description.js';
|
|
2
6
|
/** The parts of the product specs, each with the theme role it draws unless a component token names another. */
|
|
3
7
|
const PRODUCT_SPECS_ROLES = {
|
|
4
8
|
surface: 'elevated',
|
|
@@ -12,13 +16,58 @@ const PRODUCT_SPECS_ROLES = {
|
|
|
12
16
|
glyph_surface: 'sunken',
|
|
13
17
|
glyph: 'text',
|
|
14
18
|
note: 'muted',
|
|
19
|
+
ledger_label: 'muted',
|
|
15
20
|
};
|
|
16
21
|
/**
|
|
17
22
|
* Every colour the specs draw, one per part, with `product_specs.<part>` as
|
|
18
23
|
* the escape hatch over each theme role. The body and the table's values take
|
|
19
24
|
* the text role rather than the muted one: a size chart is read, not skimmed.
|
|
25
|
+
* The three sections of the product page read the same table, so a theme
|
|
26
|
+
* paints them as it painted the specs, and a surface the merchant chose for
|
|
27
|
+
* one section wins over it.
|
|
20
28
|
*/
|
|
21
|
-
export function productSpecsColors(theme) {
|
|
22
|
-
|
|
29
|
+
export function productSpecsColors(theme, settings = {}) {
|
|
30
|
+
const table = partColors(theme, 'product_specs', PRODUCT_SPECS_ROLES);
|
|
31
|
+
return { ...table, surface: colorChoiceOf(theme, settings.surface) ?? table.surface };
|
|
32
|
+
}
|
|
33
|
+
/** The catalog's title of each section of the product page, the one the specs drew over it. */
|
|
34
|
+
export const PRODUCT_SECTION_TITLES = {
|
|
35
|
+
product_description: 'product.details',
|
|
36
|
+
product_specifications: 'product.specifications',
|
|
37
|
+
shipping_returns: 'product.shipping_returns',
|
|
38
|
+
};
|
|
39
|
+
/** A section's title: the merchant's own where they wrote one the buyer reads, the catalog's otherwise. */
|
|
40
|
+
export function productSectionTitle(type, title, language, defaultLanguage) {
|
|
41
|
+
return platformWords(language, defaultLanguage).merchantOr(title, PRODUCT_SECTION_TITLES[type]);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The rows the table draws: the facts table of the product's description
|
|
45
|
+
* first where the block reads it, then the merchant's own rows, and the facts
|
|
46
|
+
* the Storefront answers where neither says anything, so a merchant who has
|
|
47
|
+
* written nothing still gets a table rather than a heading over a gap.
|
|
48
|
+
*/
|
|
49
|
+
export function productSpecRows(specs, product, language, defaultLanguage, options = {}) {
|
|
50
|
+
const described = options.descriptionTable === true ? descriptionFacts(product) : [];
|
|
51
|
+
const typed = (specs ?? [])
|
|
52
|
+
.map((row, index) => ({
|
|
53
|
+
key: `typed-${index}`,
|
|
54
|
+
label: localize(row.name, language, defaultLanguage),
|
|
55
|
+
value: localize(row.value, language, defaultLanguage),
|
|
56
|
+
}))
|
|
57
|
+
.filter((row) => row.label !== '');
|
|
58
|
+
if (described.length > 0 || typed.length > 0)
|
|
59
|
+
return [...described, ...typed];
|
|
60
|
+
const words = platformWords(language, defaultLanguage);
|
|
61
|
+
const known = [
|
|
62
|
+
{ key: 'vendor', word: 'product.brand', value: product.vendor },
|
|
63
|
+
{ key: 'productType', word: 'product.type', value: product.productType },
|
|
64
|
+
];
|
|
65
|
+
return known
|
|
66
|
+
.filter((fact) => fact.value !== undefined && fact.value !== '')
|
|
67
|
+
.map((fact) => ({ key: fact.key, label: words.own(fact.word), value: fact.value }));
|
|
68
|
+
}
|
|
69
|
+
/** The shipping rows a card draws: every row whose title the buyer can read, in the merchant's order. */
|
|
70
|
+
export function shippingRowsOf(shipping, language, defaultLanguage) {
|
|
71
|
+
return (shipping ?? []).filter((row) => localize(row.title, language, defaultLanguage) !== '');
|
|
23
72
|
}
|
|
24
73
|
//# sourceMappingURL=product-specs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-specs.js","sourceRoot":"","sources":["../src/product-specs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"product-specs.js","sourceRoot":"","sources":["../src/product-specs.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAgB,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,gHAAgH;AAChH,MAAM,mBAAmB,GAAG;IAC1B,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,QAAQ;IACd,aAAa,EAAE,QAAQ;IACvB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,UAAU;IAChB,aAAa,EAAE,QAAQ;IACvB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,OAAO;CACwC,CAAC;AAMhE;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAiB,EAC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leCode, MoneyStyle, ProductSummaryBlock, ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
2
|
+
import type { ChosenPrice } from './variant-rows.js';
|
|
2
3
|
/** The parts of the product summary, each with the theme role it draws unless a component token names another. */
|
|
3
4
|
declare const PRODUCT_SUMMARY_ROLES: {
|
|
4
5
|
readonly sheet: "elevated";
|
|
@@ -15,6 +16,10 @@ declare const PRODUCT_SUMMARY_ROLES: {
|
|
|
15
16
|
readonly stock_ink: "text";
|
|
16
17
|
readonly saving_surface: "sunken";
|
|
17
18
|
readonly saving_ink: "success";
|
|
19
|
+
readonly byline: "muted";
|
|
20
|
+
readonly amount: "text";
|
|
21
|
+
readonly struck: "muted";
|
|
22
|
+
readonly off: "action";
|
|
18
23
|
};
|
|
19
24
|
export type ProductSummaryPart = keyof typeof PRODUCT_SUMMARY_ROLES;
|
|
20
25
|
export type ProductSummaryColors = Readonly<Record<ProductSummaryPart, string>>;
|
|
@@ -25,5 +30,11 @@ export type ProductSummaryColors = Readonly<Record<ProductSummaryPart, string>>;
|
|
|
25
30
|
* whole product screen with it.
|
|
26
31
|
*/
|
|
27
32
|
export declare function productSummaryColors(theme: ThemeStyle): ProductSummaryColors;
|
|
33
|
+
/**
|
|
34
|
+
* What the summary says the compare-at price saves, in the way the merchant
|
|
35
|
+
* chose: the amount ("Save 36.190 KWD"), the percent ("−17%"), or nothing.
|
|
36
|
+
* Nothing either where the chosen variant saves nothing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function savingText(chosen: ChosenPrice, saving: ProductSummaryBlock['props']['saving'], language: LocaleCode, defaultLanguage: LocaleCode, money: MoneyStyle | undefined): string | null;
|
|
28
39
|
export {};
|
|
29
40
|
//# sourceMappingURL=product-summary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-summary.d.ts","sourceRoot":"","sources":["../src/product-summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"product-summary.d.ts","sourceRoot":"","sources":["../src/product-summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,kHAAkH;AAClH,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;CAmBoC,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,qBAAqB,CAAC;AAEpE,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,oBAAoB,CAE5E;AAID;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAC9C,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,UAAU,EAC3B,KAAK,EAAE,UAAU,GAAG,SAAS,GAC5B,MAAM,GAAG,IAAI,CAaf"}
|
package/dist/product-summary.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { derivedMoney, discountPercent, moneyAmount } from './money.js';
|
|
1
2
|
import { partColors } from './part-colors.js';
|
|
3
|
+
import { platformWords } from './words.js';
|
|
2
4
|
/** The parts of the product summary, each with the theme role it draws unless a component token names another. */
|
|
3
5
|
const PRODUCT_SUMMARY_ROLES = {
|
|
4
6
|
sheet: 'elevated',
|
|
@@ -15,6 +17,10 @@ const PRODUCT_SUMMARY_ROLES = {
|
|
|
15
17
|
stock_ink: 'text',
|
|
16
18
|
saving_surface: 'sunken',
|
|
17
19
|
saving_ink: 'success',
|
|
20
|
+
byline: 'muted',
|
|
21
|
+
amount: 'text',
|
|
22
|
+
struck: 'muted',
|
|
23
|
+
off: 'action',
|
|
18
24
|
};
|
|
19
25
|
/**
|
|
20
26
|
* Every colour the summary draws, one per part, with `product_summary.<part>`
|
|
@@ -25,4 +31,27 @@ const PRODUCT_SUMMARY_ROLES = {
|
|
|
25
31
|
export function productSummaryColors(theme) {
|
|
26
32
|
return partColors(theme, 'product_summary', PRODUCT_SUMMARY_ROLES);
|
|
27
33
|
}
|
|
34
|
+
const MINUS = '\u2212';
|
|
35
|
+
/**
|
|
36
|
+
* What the summary says the compare-at price saves, in the way the merchant
|
|
37
|
+
* chose: the amount ("Save 36.190 KWD"), the percent ("−17%"), or nothing.
|
|
38
|
+
* Nothing either where the chosen variant saves nothing.
|
|
39
|
+
*/
|
|
40
|
+
export function savingText(chosen, saving, language, defaultLanguage, money) {
|
|
41
|
+
const { price, compareAt } = chosen;
|
|
42
|
+
if (compareAt === undefined || saving === 'none')
|
|
43
|
+
return null;
|
|
44
|
+
if (compareAt.currencyCode !== price.currencyCode)
|
|
45
|
+
return null;
|
|
46
|
+
if (saving === 'percent') {
|
|
47
|
+
const percent = discountPercent(price, compareAt);
|
|
48
|
+
return percent === null ? null : `${MINUS}${percent}%`;
|
|
49
|
+
}
|
|
50
|
+
const now = moneyAmount(price);
|
|
51
|
+
const then = moneyAmount(compareAt);
|
|
52
|
+
if (now === null || then === null || then <= now)
|
|
53
|
+
return null;
|
|
54
|
+
const saved = derivedMoney(then - now, price.currencyCode, language, money);
|
|
55
|
+
return `${platformWords(language, defaultLanguage).own('product.save')} ${saved.digits} ${saved.label}`.trim();
|
|
56
|
+
}
|
|
28
57
|
//# sourceMappingURL=product-summary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-summary.js","sourceRoot":"","sources":["../src/product-summary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"product-summary.js","sourceRoot":"","sources":["../src/product-summary.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YA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K,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,OAAO,GAAG,CAAC;IACzD,CAAC;IACD,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACpC,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC;IAC9D,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,GAAG,GAAG,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5E,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;AACjH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CustomerDisplay, ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
2
|
+
/** The parts of the profile header, each with the theme role it draws unless a component token names another. */
|
|
3
|
+
declare const PROFILE_HEADER_ROLES: {
|
|
4
|
+
readonly avatar: "sunken";
|
|
5
|
+
readonly initials: "text";
|
|
6
|
+
readonly name: "text";
|
|
7
|
+
readonly email: "muted";
|
|
8
|
+
readonly edit: "elevated";
|
|
9
|
+
readonly edit_border: "border";
|
|
10
|
+
readonly edit_glyph: "text";
|
|
11
|
+
readonly title: "text";
|
|
12
|
+
readonly subtitle: "muted";
|
|
13
|
+
readonly button: "action";
|
|
14
|
+
};
|
|
15
|
+
export type ProfileHeaderPart = keyof typeof PROFILE_HEADER_ROLES;
|
|
16
|
+
export type ProfileHeaderColors = Readonly<Record<ProfileHeaderPart, string>>;
|
|
17
|
+
/**
|
|
18
|
+
* Every colour the profile header draws, one per part, with
|
|
19
|
+
* `profile_header.<part>` over each theme role. The title, the subtitle and
|
|
20
|
+
* the button are what it draws while nobody is signed in.
|
|
21
|
+
*/
|
|
22
|
+
export declare function profileHeaderColors(theme: ThemeStyle): ProfileHeaderColors;
|
|
23
|
+
/**
|
|
24
|
+
* The letters an avatar draws for a shopper: the first of each name they
|
|
25
|
+
* gave, or the first of the display name for one who gave none. A letter is
|
|
26
|
+
* taken whole, so a script with no capitals stands as it is written.
|
|
27
|
+
*/
|
|
28
|
+
export declare function customerInitials(customer: Pick<CustomerDisplay, 'firstName' | 'lastName' | 'displayName'>): string;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=profile-header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-header.d.ts","sourceRoot":"","sources":["../src/profile-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG3E,iHAAiH;AACjH,QAAA,MAAM,oBAAoB;;;;;;;;;;;CAWqC,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAElE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9E;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB,CAE1E;AAOD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,UAAU,GAAG,aAAa,CAAC,GACxE,MAAM,CAGR"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { partColors } from './part-colors.js';
|
|
2
|
+
/** The parts of the profile header, each with the theme role it draws unless a component token names another. */
|
|
3
|
+
const PROFILE_HEADER_ROLES = {
|
|
4
|
+
avatar: 'sunken',
|
|
5
|
+
initials: 'text',
|
|
6
|
+
name: 'text',
|
|
7
|
+
email: 'muted',
|
|
8
|
+
edit: 'elevated',
|
|
9
|
+
edit_border: 'border',
|
|
10
|
+
edit_glyph: 'text',
|
|
11
|
+
title: 'text',
|
|
12
|
+
subtitle: 'muted',
|
|
13
|
+
button: 'action',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Every colour the profile header draws, one per part, with
|
|
17
|
+
* `profile_header.<part>` over each theme role. The title, the subtitle and
|
|
18
|
+
* the button are what it draws while nobody is signed in.
|
|
19
|
+
*/
|
|
20
|
+
export function profileHeaderColors(theme) {
|
|
21
|
+
return partColors(theme, 'profile_header', PROFILE_HEADER_ROLES);
|
|
22
|
+
}
|
|
23
|
+
function firstLetter(word) {
|
|
24
|
+
const [letter] = Array.from((word ?? '').trim());
|
|
25
|
+
return letter === undefined ? '' : letter.toLocaleUpperCase();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The letters an avatar draws for a shopper: the first of each name they
|
|
29
|
+
* gave, or the first of the display name for one who gave none. A letter is
|
|
30
|
+
* taken whole, so a script with no capitals stands as it is written.
|
|
31
|
+
*/
|
|
32
|
+
export function customerInitials(customer) {
|
|
33
|
+
const named = `${firstLetter(customer.firstName)}${firstLetter(customer.lastName)}`;
|
|
34
|
+
return named === '' ? firstLetter(customer.displayName) : named;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=profile-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-header.js","sourceRoot":"","sources":["../src/profile-header.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,iHAAiH;AACjH,MAAM,oBAAoB,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,QAAQ;IACrB,UAAU,EAAE,MAAM;IAClB,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,QAAQ;CAC6C,CAAC;AAMhE;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAiB;IACnD,OAAO,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,WAAW,CAAC,IAAwB;IAC3C,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACjD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAyE;IAEzE,MAAM,KAAK,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IACpF,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClE,CAAC"}
|
package/dist/promo-banner.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
1
|
+
import { type LocaleCode, type ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
2
2
|
/** The parts of a promo card, each with the theme role it draws unless a component token names another. */
|
|
3
3
|
declare const PROMO_BANNER_ROLES: {
|
|
4
4
|
readonly artwork: "sunken";
|
|
@@ -20,5 +20,15 @@ export declare function promoBannerColors(theme: ThemeStyle): PromoBannerColors;
|
|
|
20
20
|
* softer than its cards.
|
|
21
21
|
*/
|
|
22
22
|
export declare function promoBannerRadius(theme: ThemeStyle): number;
|
|
23
|
+
/** How many promotions a banner stacks, in the form the buyer's language counts them in. */
|
|
24
|
+
export declare function promoSetLabel(cards: number, language: LocaleCode, defaultLanguage: LocaleCode): string;
|
|
25
|
+
/**
|
|
26
|
+
* The name a screen reader reads for one promo card. A card in a set of more
|
|
27
|
+
* than one says which of how many it is, beside the merchant's own words where
|
|
28
|
+
* they wrote any and in place of them where they wrote none; a card standing
|
|
29
|
+
* alone is its words, or the platform's word for a promotion. The merchant's
|
|
30
|
+
* words go in last, so text of theirs that looks like a slot stays as written.
|
|
31
|
+
*/
|
|
32
|
+
export declare function promoCardLabel(merchantLabel: string, cardIndex: number, cards: number, language: LocaleCode, defaultLanguage: LocaleCode): string;
|
|
23
33
|
export {};
|
|
24
34
|
//# sourceMappingURL=promo-banner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promo-banner.d.ts","sourceRoot":"","sources":["../src/promo-banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"promo-banner.d.ts","sourceRoot":"","sources":["../src/promo-banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIhG,2GAA2G;AAC3G,QAAA,MAAM,kBAAkB;;;;;CAKuC,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAE9D,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE3D;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,UAAU,GAC1B,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,UAAU,GAC1B,MAAM,CAUR"}
|
package/dist/promo-banner.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { componentTokenValue } from '@shoplix-ai/sdui-schema';
|
|
2
2
|
import { partColors } from './part-colors.js';
|
|
3
|
+
import { countedWord, platformWords } from './words.js';
|
|
3
4
|
/** The parts of a promo card, each with the theme role it draws unless a component token names another. */
|
|
4
5
|
const PROMO_BANNER_ROLES = {
|
|
5
6
|
artwork: 'sunken',
|
|
@@ -23,4 +24,27 @@ export function promoBannerColors(theme) {
|
|
|
23
24
|
export function promoBannerRadius(theme) {
|
|
24
25
|
return componentTokenValue(theme, 'promo_banner.radius', theme.radius);
|
|
25
26
|
}
|
|
27
|
+
/** How many promotions a banner stacks, in the form the buyer's language counts them in. */
|
|
28
|
+
export function promoSetLabel(cards, language, defaultLanguage) {
|
|
29
|
+
return countedWord('promo.cards', cards, language, defaultLanguage);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The name a screen reader reads for one promo card. A card in a set of more
|
|
33
|
+
* than one says which of how many it is, beside the merchant's own words where
|
|
34
|
+
* they wrote any and in place of them where they wrote none; a card standing
|
|
35
|
+
* alone is its words, or the platform's word for a promotion. The merchant's
|
|
36
|
+
* words go in last, so text of theirs that looks like a slot stays as written.
|
|
37
|
+
*/
|
|
38
|
+
export function promoCardLabel(merchantLabel, cardIndex, cards, language, defaultLanguage) {
|
|
39
|
+
const words = platformWords(language, defaultLanguage);
|
|
40
|
+
if (cards <= 1)
|
|
41
|
+
return merchantLabel === '' ? words.own('promo.promotion') : merchantLabel;
|
|
42
|
+
const slots = {
|
|
43
|
+
position: String(cardIndex + 1),
|
|
44
|
+
count: String(cards),
|
|
45
|
+
label: merchantLabel,
|
|
46
|
+
};
|
|
47
|
+
const pattern = words.own(merchantLabel === '' ? 'promo.card_of' : 'promo.card_named');
|
|
48
|
+
return pattern.replace(/\{(position|count|label)\}/g, (_slot, name) => slots[name]);
|
|
49
|
+
}
|
|
26
50
|
//# sourceMappingURL=promo-banner.js.map
|
package/dist/promo-banner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promo-banner.js","sourceRoot":"","sources":["../src/promo-banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"promo-banner.js","sourceRoot":"","sources":["../src/promo-banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAoC,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAExD,2GAA2G;AAC3G,MAAM,kBAAkB,GAAG;IACzB,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,QAAQ;CAC2C,CAAC;AAMhE;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAiB;IACjD,OAAO,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAiB;IACjD,OAAO,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;AACzE,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,aAAa,CAC3B,KAAa,EACb,QAAoB,EACpB,eAA2B;IAE3B,OAAO,WAAW,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,aAAqB,EACrB,SAAiB,EACjB,KAAa,EACb,QAAoB,EACpB,eAA2B;IAE3B,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACvD,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,aAAa,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAC3F,MAAM,KAAK,GAA2B;QACpC,QAAQ,EAAE,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;QAC/B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;QACpB,KAAK,EAAE,aAAa;KACrB,CAAC;IACF,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,aAAa,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;IACvF,OAAO,OAAO,CAAC,OAAO,CAAC,6BAA6B,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC,CAAC;AAC/F,CAAC"}
|
package/dist/section-header.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* The parts of the section header, each with the theme role it draws unless a
|
|
4
|
+
* component token names another. The collection heading draws the title part
|
|
5
|
+
* alone.
|
|
6
|
+
*/
|
|
3
7
|
declare const SECTION_HEADER_ROLES: {
|
|
4
8
|
readonly title: "text";
|
|
5
9
|
readonly link: "action";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-header.d.ts","sourceRoot":"","sources":["../src/section-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D
|
|
1
|
+
{"version":3,"file":"section-header.d.ts","sourceRoot":"","sources":["../src/section-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;;;GAIG;AACH,QAAA,MAAM,oBAAoB;;;CAGqC,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAElE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB,CAE1E"}
|
package/dist/section-header.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { partColors } from './part-colors.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* The parts of the section header, each with the theme role it draws unless a
|
|
4
|
+
* component token names another. The collection heading draws the title part
|
|
5
|
+
* alone.
|
|
6
|
+
*/
|
|
3
7
|
const SECTION_HEADER_ROLES = {
|
|
4
8
|
title: 'text',
|
|
5
9
|
link: 'action',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-header.js","sourceRoot":"","sources":["../src/section-header.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"section-header.js","sourceRoot":"","sources":["../src/section-header.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,oBAAoB,GAAG;IAC3B,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,QAAQ;CAC+C,CAAC;AAMhE;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAiB;IACnD,OAAO,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
2
|
+
/** The parts of the sign-in block, each with the theme role it draws unless a component token names another. */
|
|
3
|
+
declare const SIGN_IN_ROLES: {
|
|
4
|
+
readonly title: "text";
|
|
5
|
+
readonly subtitle: "muted";
|
|
6
|
+
readonly label: "text";
|
|
7
|
+
readonly field: "surface";
|
|
8
|
+
readonly field_border: "border";
|
|
9
|
+
readonly input: "text";
|
|
10
|
+
readonly placeholder: "subtle";
|
|
11
|
+
readonly error: "warning";
|
|
12
|
+
readonly button: "action";
|
|
13
|
+
readonly note: "muted";
|
|
14
|
+
readonly terms: "text";
|
|
15
|
+
};
|
|
16
|
+
export type SignInPart = keyof typeof SIGN_IN_ROLES;
|
|
17
|
+
export type SignInColors = Readonly<Record<SignInPart, string>>;
|
|
18
|
+
/**
|
|
19
|
+
* Every colour the sign-in block draws, one per part, with `sign_in.<part>` as
|
|
20
|
+
* the escape hatch over each theme role. The words on a solid button are
|
|
21
|
+
* whichever of ink and paper stands out on it.
|
|
22
|
+
*
|
|
23
|
+
* @deprecated The sign-in block is retired: no draft places it, and only a
|
|
24
|
+
* Release published before still carries it. Kept until the next major.
|
|
25
|
+
*/
|
|
26
|
+
export declare function signInColors(theme: ThemeStyle): SignInColors;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=sign-in.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.d.ts","sourceRoot":"","sources":["../src/sign-in.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D,gHAAgH;AAChH,QAAA,MAAM,aAAa;;;;;;;;;;;;CAY4C,CAAC;AAEhE,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,aAAa,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,CAE5D"}
|
package/dist/sign-in.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { partColors } from './part-colors.js';
|
|
2
|
+
/** The parts of the sign-in block, each with the theme role it draws unless a component token names another. */
|
|
3
|
+
const SIGN_IN_ROLES = {
|
|
4
|
+
title: 'text',
|
|
5
|
+
subtitle: 'muted',
|
|
6
|
+
label: 'text',
|
|
7
|
+
field: 'surface',
|
|
8
|
+
field_border: 'border',
|
|
9
|
+
input: 'text',
|
|
10
|
+
placeholder: 'subtle',
|
|
11
|
+
error: 'warning',
|
|
12
|
+
button: 'action',
|
|
13
|
+
note: 'muted',
|
|
14
|
+
terms: 'text',
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Every colour the sign-in block draws, one per part, with `sign_in.<part>` as
|
|
18
|
+
* the escape hatch over each theme role. The words on a solid button are
|
|
19
|
+
* whichever of ink and paper stands out on it.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated The sign-in block is retired: no draft places it, and only a
|
|
22
|
+
* Release published before still carries it. Kept until the next major.
|
|
23
|
+
*/
|
|
24
|
+
export function signInColors(theme) {
|
|
25
|
+
return partColors(theme, 'sign_in', SIGN_IN_ROLES);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=sign-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../src/sign-in.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,gHAAgH;AAChH,MAAM,aAAa,GAAG;IACpB,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,SAAS;IAChB,YAAY,EAAE,QAAQ;IACtB,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,MAAM;CACgD,CAAC;AAMhE;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,OAAO,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/store-header.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocaleCode, type SearchBarBlock, type StoreHeaderBlock, type ThemeStyle } from '@shoplix-ai/sdui-schema';
|
|
2
2
|
/** The parts of the store header, each with the theme role it draws unless a component token names another. */
|
|
3
3
|
declare const STORE_HEADER_ROLES: {
|
|
4
4
|
readonly bar: "elevated";
|
|
@@ -13,22 +13,65 @@ declare const STORE_HEADER_ROLES: {
|
|
|
13
13
|
readonly drawer_ink: "text";
|
|
14
14
|
readonly drawer_subtle: "subtle";
|
|
15
15
|
readonly drawer_divider: "border";
|
|
16
|
-
readonly
|
|
16
|
+
readonly drawer_group: "sunken";
|
|
17
17
|
};
|
|
18
|
-
export type StoreHeaderPart = keyof typeof STORE_HEADER_ROLES;
|
|
18
|
+
export type StoreHeaderPart = keyof typeof STORE_HEADER_ROLES | 'scrim';
|
|
19
19
|
export type StoreHeaderColors = Readonly<Record<StoreHeaderPart, string>>;
|
|
20
|
+
/** The dim behind the open menu: dark, the way the Cart Drawer dims, and no theme role, since a theme's overlay is a wash. */
|
|
21
|
+
export declare const STORE_MENU_DIM = "rgba(0, 0, 0, 0.35)";
|
|
20
22
|
/**
|
|
21
23
|
* Every colour the store header draws, one per part, with `store_header.<part>`
|
|
22
|
-
* as the escape hatch over each theme role
|
|
23
|
-
*
|
|
24
|
-
* chrome their shopper sees cannot
|
|
24
|
+
* as the escape hatch over each theme role, and over the dark dim behind the
|
|
25
|
+
* open menu. The phone's header and its web twin read this one table, so the
|
|
26
|
+
* chrome a merchant sees on the canvas and the chrome their shopper sees cannot
|
|
27
|
+
* disagree.
|
|
25
28
|
*/
|
|
26
29
|
export declare function storeHeaderColors(theme: ThemeStyle): StoreHeaderColors;
|
|
30
|
+
/** How tall a row of the open menu stands and how large its words are, in points. */
|
|
31
|
+
export interface StoreMenuMetrics {
|
|
32
|
+
readonly rowHeight: number;
|
|
33
|
+
readonly labelSize: number;
|
|
34
|
+
}
|
|
35
|
+
/** The menu's rows as the theme sizes them, 48 points tall with 16 point words where it names nothing. */
|
|
36
|
+
export declare function storeMenuMetrics(theme: ThemeStyle): StoreMenuMetrics;
|
|
27
37
|
/**
|
|
28
38
|
* What the cart badge writes, or nothing at all for an empty cart. Both readers
|
|
29
39
|
* cap it the same way, so a merchant never sees a count on the canvas the phone
|
|
30
40
|
* would not draw.
|
|
31
41
|
*/
|
|
32
42
|
export declare function cartBadgeCount(totalQuantity: number): string | null;
|
|
43
|
+
/** What the search entry holds in one language: the lead, the hints it types, its steady label, and the line for the letters typed so far. */
|
|
44
|
+
export interface SearchEntryWords {
|
|
45
|
+
readonly lead: string;
|
|
46
|
+
readonly hints: readonly string[];
|
|
47
|
+
readonly label: string;
|
|
48
|
+
readonly line: (typed: string) => string;
|
|
49
|
+
}
|
|
50
|
+
type SearchBarSettings = SearchBarBlock['props'];
|
|
51
|
+
type SearchEntrySettings = Pick<StoreHeaderBlock['props'], 'searchPlaceholder' | 'typeSearchHints' | 'searchHintLead' | 'searchHints'>;
|
|
52
|
+
/**
|
|
53
|
+
* The search bar's words in the buyer's language, the one rule the phone and
|
|
54
|
+
* its canvas twin read. Typing off, or no hint in the buyer's language or the
|
|
55
|
+
* Shop's default, holds the placeholder.
|
|
56
|
+
*/
|
|
57
|
+
export declare function searchBarWords(settings: Pick<SearchBarSettings, 'placeholder' | 'typeHints' | 'hintLead' | 'hints'>, language: LocaleCode, defaultLanguage: LocaleCode): SearchEntryWords;
|
|
58
|
+
/** The store header's search entry in the buyer's language, read by the rule of the search bar. */
|
|
59
|
+
export declare function searchEntryWords(settings: SearchEntrySettings, language: LocaleCode, defaultLanguage: LocaleCode): SearchEntryWords;
|
|
60
|
+
/** The box the search entry stands in: its size and corner in points, its colours, its band. */
|
|
61
|
+
export interface SearchEntryBox {
|
|
62
|
+
readonly height: number;
|
|
63
|
+
readonly radius: number;
|
|
64
|
+
readonly surface: string;
|
|
65
|
+
readonly stroke: string;
|
|
66
|
+
readonly ink: string;
|
|
67
|
+
readonly band: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The search entry's box as the merchant set it on the search bar, and the
|
|
71
|
+
* entry the store header drew for every part they left out, so a search moved
|
|
72
|
+
* out of the header draws as it drew there, on the header's band. The
|
|
73
|
+
* header's entry is this box with nothing set.
|
|
74
|
+
*/
|
|
75
|
+
export declare function searchEntryBox(theme: ThemeStyle, settings?: Pick<SearchBarSettings, 'height' | 'radius' | 'surface' | 'stroke' | 'ink'>): SearchEntryBox;
|
|
33
76
|
export {};
|
|
34
77
|
//# sourceMappingURL=store-header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-header.d.ts","sourceRoot":"","sources":["../src/store-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"store-header.d.ts","sourceRoot":"","sources":["../src/store-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEf,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAMjC,+GAA+G;AAC/G,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;CAcuC,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,kBAAkB,GAAG,OAAO,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1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