@salesforce/ui-theme-manager 11.63.0 → 11.64.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.
Files changed (45) hide show
  1. package/dist/authoring/core/ThemeManagerPanelRoot.d.cts +7 -0
  2. package/dist/authoring/core/ThemeManagerPanelRoot.d.ts +7 -0
  3. package/dist/authoring/core/ThemeManagerPanelRoot.d.ts.map +1 -1
  4. package/dist/authoring/core/components/BordersSection.d.ts.map +1 -1
  5. package/dist/authoring/core/components/ButtonSection.d.cts +7 -0
  6. package/dist/authoring/core/components/ButtonSection.d.ts +7 -0
  7. package/dist/authoring/core/components/ButtonSection.d.ts.map +1 -1
  8. package/dist/authoring/core/components/ScaleValueRow.d.cts +43 -0
  9. package/dist/authoring/core/components/ScaleValueRow.d.ts +43 -0
  10. package/dist/authoring/core/components/ScaleValueRow.d.ts.map +1 -0
  11. package/dist/authoring/core/components/SectionTabs.d.cts +23 -0
  12. package/dist/authoring/core/components/SectionTabs.d.ts +23 -0
  13. package/dist/authoring/core/components/SectionTabs.d.ts.map +1 -0
  14. package/dist/authoring/core/components/TypographySection.d.ts.map +1 -1
  15. package/dist/authoring/core/labels.d.cts +22 -5
  16. package/dist/authoring/core/labels.d.ts +22 -5
  17. package/dist/authoring/core/labels.d.ts.map +1 -1
  18. package/dist/authoring/react/index.js +1 -1
  19. package/dist/authoring/react/styles.css +1 -1
  20. package/dist/authoring/web-component/index.d.cts +8 -0
  21. package/dist/authoring/web-component/index.d.ts +8 -0
  22. package/dist/authoring/web-component/index.d.ts.map +1 -1
  23. package/dist/authoring/web-component/index.js +180 -19
  24. package/dist/protocol/brandCss.cjs +38 -1
  25. package/dist/protocol/brandCss.d.cts +19 -0
  26. package/dist/protocol/brandCss.d.ts +19 -0
  27. package/dist/protocol/brandCss.d.ts.map +1 -1
  28. package/dist/protocol/brandCss.js +39 -2
  29. package/dist/protocol/brandSearch.cjs +24 -10
  30. package/dist/protocol/brandSearch.d.cts +24 -0
  31. package/dist/protocol/brandSearch.d.ts +24 -0
  32. package/dist/protocol/brandSearch.d.ts.map +1 -1
  33. package/dist/protocol/brandSearch.js +24 -10
  34. package/dist/protocol/index.cjs +6 -0
  35. package/dist/protocol/index.js +8 -2
  36. package/dist/runtime/previewContent.cjs +496 -217
  37. package/dist/runtime/previewContent.d.cts +31 -12
  38. package/dist/runtime/previewContent.d.ts +31 -12
  39. package/dist/runtime/previewContent.d.ts.map +1 -1
  40. package/dist/runtime/previewContent.js +498 -219
  41. package/dist/runtime/theme-preview-runtime.js +2526 -0
  42. package/package.json +1 -1
  43. package/dist/authoring/core/components/AssetsSection.d.cts +0 -12
  44. package/dist/authoring/core/components/AssetsSection.d.ts +0 -12
  45. package/dist/authoring/core/components/AssetsSection.d.ts.map +0 -1
@@ -1,9 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const chroma = require("chroma-js");
3
4
  const brandResolver = require("./brandResolver.cjs");
4
5
  function formatDimension(dim) {
5
6
  return `${dim.value}${dim.unit}`;
6
7
  }
8
+ const OKLCH_DISPLAY_VARS = [
9
+ "--tm-color-primary",
10
+ "--tm-color-secondary",
11
+ "--tm-color-accent",
12
+ "--tm-color-background",
13
+ "--tm-color-surface"
14
+ ];
15
+ function toOklchString(color) {
16
+ if (!color || !chroma.valid(color)) return void 0;
17
+ try {
18
+ const [l, c, h] = chroma(color).oklch();
19
+ const L = Number(l.toFixed(2));
20
+ const C = Number(c.toFixed(3));
21
+ const H = Number.isNaN(h) ? 0 : Number(h.toFixed(0));
22
+ return `oklch(${L} ${C} ${H})`;
23
+ } catch {
24
+ return void 0;
25
+ }
26
+ }
27
+ function oklchDisplayVars(variables) {
28
+ const out = {};
29
+ for (const colorVar of OKLCH_DISPLAY_VARS) {
30
+ const oklch = toOklchString(variables[colorVar]);
31
+ if (oklch) {
32
+ out[`${colorVar}-oklch`] = `"${oklch}"`;
33
+ }
34
+ }
35
+ return out;
36
+ }
7
37
  function buildFontStack(font) {
8
38
  if (typeof font === "string" && font.startsWith("{!$brand")) {
9
39
  return "system-ui, -apple-system, sans-serif";
@@ -234,12 +264,16 @@ function brandToVariables(brand) {
234
264
  if (brand.borderWeight?.none) {
235
265
  vars["--tm-border-weight-none"] = formatDimension(brand.borderWeight.none);
236
266
  }
267
+ Object.assign(vars, oklchDisplayVars(vars));
268
+ if (vars["--tm-border-radius"]) {
269
+ vars["--tm-border-radius-label"] = `"${vars["--tm-border-radius"]}"`;
270
+ }
237
271
  return vars;
238
272
  }
239
273
  function generateBrandCss(brand) {
240
274
  const resolved = brandResolver.resolveBrandTokens(brand);
241
275
  const vars = brandToVariables(resolved);
242
- const cssVars = Object.entries(vars).map(([key, value]) => ` ${key}: ${value};`).join("\n");
276
+ const cssVars = Object.entries(vars).filter(([key]) => !key.endsWith("-oklch") && !key.endsWith("-label")).map(([key, value]) => ` ${key}: ${value};`).join("\n");
243
277
  const title = brand["sfdc_cms:title"] ?? "Untitled Brand";
244
278
  return `/**
245
279
  * Brand: ${title}
@@ -251,5 +285,8 @@ ${cssVars}
251
285
  }
252
286
  `;
253
287
  }
288
+ exports.OKLCH_DISPLAY_VARS = OKLCH_DISPLAY_VARS;
254
289
  exports.brandToVariables = brandToVariables;
255
290
  exports.generateBrandCss = generateBrandCss;
291
+ exports.oklchDisplayVars = oklchDisplayVars;
292
+ exports.toOklchString = toOklchString;
@@ -1,4 +1,23 @@
1
1
  import { Brand } from './brandTypes.cjs';
2
+ /** Palette colors surfaced as live `oklch(...)` text in the brand preview card. */
3
+ export declare const OKLCH_DISPLAY_VARS: readonly ["--tm-color-primary", "--tm-color-secondary", "--tm-color-accent", "--tm-color-background", "--tm-color-surface"];
4
+ /**
5
+ * Formats a color as an `oklch(L C H)` display string (e.g. "oklch(0.72 0.16 131)").
6
+ *
7
+ * Uses chroma-js to convert into the OKLCh color space, then rounds for a compact,
8
+ * readable label: L to 2 decimals, C to 3, H to a whole degree, with trailing zeros
9
+ * trimmed by `Number()`. Achromatic colors report a hue of 0 (chroma yields NaN).
10
+ * Returns undefined for values chroma can't parse.
11
+ */
12
+ export declare function toOklchString(color: string | undefined): string | undefined;
13
+ /**
14
+ * Given a record of `--tm-*` variables, returns the `--tm-color-*-oklch` display
15
+ * companions for each palette color present: a quoted `oklch(...)` CSS `<string>`
16
+ * ready for `content: var(...)`. Shared by `brandToVariables` (so live updates
17
+ * carry fresh labels) and the preview generator (so the initial render — including
18
+ * the theme path — shows values).
19
+ */
20
+ export declare function oklchDisplayVars(variables: Record<string, string>): Record<string, string>;
2
21
  /**
3
22
  * Maps a resolved Brand object to CSS custom properties using the `--tm-*` prefix.
4
23
  * Reuses existing --tm-* variable names for semantic compatibility with the Theme preview.
@@ -1,4 +1,23 @@
1
1
  import { Brand } from './brandTypes.js';
2
+ /** Palette colors surfaced as live `oklch(...)` text in the brand preview card. */
3
+ export declare const OKLCH_DISPLAY_VARS: readonly ["--tm-color-primary", "--tm-color-secondary", "--tm-color-accent", "--tm-color-background", "--tm-color-surface"];
4
+ /**
5
+ * Formats a color as an `oklch(L C H)` display string (e.g. "oklch(0.72 0.16 131)").
6
+ *
7
+ * Uses chroma-js to convert into the OKLCh color space, then rounds for a compact,
8
+ * readable label: L to 2 decimals, C to 3, H to a whole degree, with trailing zeros
9
+ * trimmed by `Number()`. Achromatic colors report a hue of 0 (chroma yields NaN).
10
+ * Returns undefined for values chroma can't parse.
11
+ */
12
+ export declare function toOklchString(color: string | undefined): string | undefined;
13
+ /**
14
+ * Given a record of `--tm-*` variables, returns the `--tm-color-*-oklch` display
15
+ * companions for each palette color present: a quoted `oklch(...)` CSS `<string>`
16
+ * ready for `content: var(...)`. Shared by `brandToVariables` (so live updates
17
+ * carry fresh labels) and the preview generator (so the initial render — including
18
+ * the theme path — shows values).
19
+ */
20
+ export declare function oklchDisplayVars(variables: Record<string, string>): Record<string, string>;
2
21
  /**
3
22
  * Maps a resolved Brand object to CSS custom properties using the `--tm-*` prefix.
4
23
  * Reuses existing --tm-* variable names for semantic compatibility with the Theme preview.
@@ -1 +1 @@
1
- {"version":3,"file":"brandCss.d.ts","sourceRoot":"","sources":["../../src/protocol/brandCss.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAmC,MAAM,cAAc,CAAC;AAyD3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiPrE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAkBrD"}
1
+ {"version":3,"file":"brandCss.d.ts","sourceRoot":"","sources":["../../src/protocol/brandCss.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAmC,MAAM,cAAc,CAAC;AAS3E,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,6HAMrB,CAAC;AAEX;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAW3E;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAU1F;AAkDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+PrE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAsBrD"}
@@ -1,7 +1,37 @@
1
+ import chroma from "chroma-js";
1
2
  import { resolveBrandTokens } from "./brandResolver.js";
2
3
  function formatDimension(dim) {
3
4
  return `${dim.value}${dim.unit}`;
4
5
  }
6
+ const OKLCH_DISPLAY_VARS = [
7
+ "--tm-color-primary",
8
+ "--tm-color-secondary",
9
+ "--tm-color-accent",
10
+ "--tm-color-background",
11
+ "--tm-color-surface"
12
+ ];
13
+ function toOklchString(color) {
14
+ if (!color || !chroma.valid(color)) return void 0;
15
+ try {
16
+ const [l, c, h] = chroma(color).oklch();
17
+ const L = Number(l.toFixed(2));
18
+ const C = Number(c.toFixed(3));
19
+ const H = Number.isNaN(h) ? 0 : Number(h.toFixed(0));
20
+ return `oklch(${L} ${C} ${H})`;
21
+ } catch {
22
+ return void 0;
23
+ }
24
+ }
25
+ function oklchDisplayVars(variables) {
26
+ const out = {};
27
+ for (const colorVar of OKLCH_DISPLAY_VARS) {
28
+ const oklch = toOklchString(variables[colorVar]);
29
+ if (oklch) {
30
+ out[`${colorVar}-oklch`] = `"${oklch}"`;
31
+ }
32
+ }
33
+ return out;
34
+ }
5
35
  function buildFontStack(font) {
6
36
  if (typeof font === "string" && font.startsWith("{!$brand")) {
7
37
  return "system-ui, -apple-system, sans-serif";
@@ -232,12 +262,16 @@ function brandToVariables(brand) {
232
262
  if (brand.borderWeight?.none) {
233
263
  vars["--tm-border-weight-none"] = formatDimension(brand.borderWeight.none);
234
264
  }
265
+ Object.assign(vars, oklchDisplayVars(vars));
266
+ if (vars["--tm-border-radius"]) {
267
+ vars["--tm-border-radius-label"] = `"${vars["--tm-border-radius"]}"`;
268
+ }
235
269
  return vars;
236
270
  }
237
271
  function generateBrandCss(brand) {
238
272
  const resolved = resolveBrandTokens(brand);
239
273
  const vars = brandToVariables(resolved);
240
- const cssVars = Object.entries(vars).map(([key, value]) => ` ${key}: ${value};`).join("\n");
274
+ const cssVars = Object.entries(vars).filter(([key]) => !key.endsWith("-oklch") && !key.endsWith("-label")).map(([key, value]) => ` ${key}: ${value};`).join("\n");
241
275
  const title = brand["sfdc_cms:title"] ?? "Untitled Brand";
242
276
  return `/**
243
277
  * Brand: ${title}
@@ -250,6 +284,9 @@ ${cssVars}
250
284
  `;
251
285
  }
252
286
  export {
287
+ OKLCH_DISPLAY_VARS,
253
288
  brandToVariables,
254
- generateBrandCss
289
+ generateBrandCss,
290
+ oklchDisplayVars,
291
+ toOklchString
255
292
  };
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const MIN_SEARCH_QUERY_LENGTH = 3;
4
4
  const SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = 62;
5
+ const ALL_PUBLISHED_BRANDS_KEYWORD = "0ap";
6
+ const DEFAULT_BRAND_PRELOAD_LIMIT = 5;
5
7
  const DEFAULT_BRAND_SEARCH_OPTIONS = {
6
8
  searchLanguage: "en_US",
7
9
  channelType: "PublicUnauthenticated",
@@ -17,20 +19,29 @@ function resolveSearchApiVersion(apiVersion) {
17
19
  }
18
20
  function buildBrandSearchRequest(query, apiVersion, options = {}) {
19
21
  const version = resolveSearchApiVersion(apiVersion);
22
+ const input = {
23
+ searchKeyword: query,
24
+ searchLanguage: options.searchLanguage ?? DEFAULT_BRAND_SEARCH_OPTIONS.searchLanguage,
25
+ channelType: options.channelType ?? DEFAULT_BRAND_SEARCH_OPTIONS.channelType,
26
+ contentTypeFqn: options.contentTypeFqn ?? DEFAULT_BRAND_SEARCH_OPTIONS.contentTypeFqn
27
+ };
28
+ if (options.pageOffset !== void 0) {
29
+ input.pageOffset = options.pageOffset;
30
+ }
31
+ if (options.searchLimit !== void 0) {
32
+ input.searchLimit = options.searchLimit;
33
+ }
20
34
  return {
21
35
  path: `/services/data/v${version}/actions/standard/searchCmsChannelContent`,
22
- body: {
23
- inputs: [
24
- {
25
- searchKeyword: query,
26
- searchLanguage: options.searchLanguage ?? DEFAULT_BRAND_SEARCH_OPTIONS.searchLanguage,
27
- channelType: options.channelType ?? DEFAULT_BRAND_SEARCH_OPTIONS.channelType,
28
- contentTypeFqn: options.contentTypeFqn ?? DEFAULT_BRAND_SEARCH_OPTIONS.contentTypeFqn
29
- }
30
- ]
31
- }
36
+ body: { inputs: [input] }
32
37
  };
33
38
  }
39
+ function buildBrandPreloadRequest(apiVersion, limit = DEFAULT_BRAND_PRELOAD_LIMIT) {
40
+ return buildBrandSearchRequest(ALL_PUBLISHED_BRANDS_KEYWORD, apiVersion, {
41
+ pageOffset: 0,
42
+ searchLimit: limit
43
+ });
44
+ }
34
45
  function parseBrandSearchResponse(response) {
35
46
  const results = Array.isArray(response) ? response : [response];
36
47
  const result = results[0];
@@ -54,9 +65,12 @@ function parseBrandSearchResponse(response) {
54
65
  function getContentUrl(item) {
55
66
  return item.managedContentChannelDeliveryDetails?.find((detail) => detail?.contentUrl)?.contentUrl;
56
67
  }
68
+ exports.ALL_PUBLISHED_BRANDS_KEYWORD = ALL_PUBLISHED_BRANDS_KEYWORD;
69
+ exports.DEFAULT_BRAND_PRELOAD_LIMIT = DEFAULT_BRAND_PRELOAD_LIMIT;
57
70
  exports.DEFAULT_BRAND_SEARCH_OPTIONS = DEFAULT_BRAND_SEARCH_OPTIONS;
58
71
  exports.MIN_SEARCH_QUERY_LENGTH = MIN_SEARCH_QUERY_LENGTH;
59
72
  exports.SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION;
73
+ exports.buildBrandPreloadRequest = buildBrandPreloadRequest;
60
74
  exports.buildBrandSearchRequest = buildBrandSearchRequest;
61
75
  exports.getContentUrl = getContentUrl;
62
76
  exports.isValidSearchQuery = isValidSearchQuery;
@@ -21,6 +21,15 @@
21
21
  export declare const MIN_SEARCH_QUERY_LENGTH = 3;
22
22
  /** Minimum API version that exposes the `searchCmsChannelContent` action. */
23
23
  export declare const SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = 62;
24
+ /**
25
+ * Keyword that matches all published brands. Every published brand's key is
26
+ * prefixed with `0ap`, so searching that prefix returns the full published set —
27
+ * used to preload the org gallery so it isn't empty before the user searches.
28
+ * (Confirmed by the owners of the `searchCmsChannelContent` action.)
29
+ */
30
+ export declare const ALL_PUBLISHED_BRANDS_KEYWORD = "0ap";
31
+ /** Default page size for the brand preload (keep the initial gallery small). */
32
+ export declare const DEFAULT_BRAND_PRELOAD_LIMIT = 5;
24
33
  /** Default input parameters for a brand search on an unauthenticated channel. */
25
34
  export declare const DEFAULT_BRAND_SEARCH_OPTIONS: {
26
35
  readonly searchLanguage: "en_US";
@@ -59,6 +68,10 @@ export interface BrandSearchRequestInput {
59
68
  searchLanguage: string;
60
69
  channelType: string;
61
70
  contentTypeFqn: string;
71
+ /** Zero-based page offset for paginated results. Omitted when not provided. */
72
+ pageOffset?: number;
73
+ /** Maximum number of results to return. Omitted when not provided. */
74
+ searchLimit?: number;
62
75
  }
63
76
  /** Overridable subset of the search inputs; keyword is supplied separately. */
64
77
  export type BrandSearchOptions = Partial<Omit<BrandSearchRequestInput, "searchKeyword">>;
@@ -113,6 +126,17 @@ export declare function resolveSearchApiVersion(apiVersion: string): string;
113
126
  * @param options - Optional overrides for language, channel type, content type
114
127
  */
115
128
  export declare function buildBrandSearchRequest(query: string, apiVersion: string, options?: BrandSearchOptions): BrandSearchRequest;
129
+ /**
130
+ * Build a request that preloads the published brands for the org gallery. Uses
131
+ * the all-brands keyword prefix with a bounded page so the initial list isn't
132
+ * empty before the user runs a search. A thin wrapper over
133
+ * `buildBrandSearchRequest` — the host issues the POST as usual and feeds the
134
+ * response to `parseBrandSearchResponse`.
135
+ *
136
+ * @param apiVersion - The host connection's API version
137
+ * @param limit - Max brands to preload (defaults to `DEFAULT_BRAND_PRELOAD_LIMIT`)
138
+ */
139
+ export declare function buildBrandPreloadRequest(apiVersion: string, limit?: number): BrandSearchRequest;
116
140
  /**
117
141
  * Parse the raw `searchCmsChannelContent` response into items and a total.
118
142
  *
@@ -21,6 +21,15 @@
21
21
  export declare const MIN_SEARCH_QUERY_LENGTH = 3;
22
22
  /** Minimum API version that exposes the `searchCmsChannelContent` action. */
23
23
  export declare const SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = 62;
24
+ /**
25
+ * Keyword that matches all published brands. Every published brand's key is
26
+ * prefixed with `0ap`, so searching that prefix returns the full published set —
27
+ * used to preload the org gallery so it isn't empty before the user searches.
28
+ * (Confirmed by the owners of the `searchCmsChannelContent` action.)
29
+ */
30
+ export declare const ALL_PUBLISHED_BRANDS_KEYWORD = "0ap";
31
+ /** Default page size for the brand preload (keep the initial gallery small). */
32
+ export declare const DEFAULT_BRAND_PRELOAD_LIMIT = 5;
24
33
  /** Default input parameters for a brand search on an unauthenticated channel. */
25
34
  export declare const DEFAULT_BRAND_SEARCH_OPTIONS: {
26
35
  readonly searchLanguage: "en_US";
@@ -59,6 +68,10 @@ export interface BrandSearchRequestInput {
59
68
  searchLanguage: string;
60
69
  channelType: string;
61
70
  contentTypeFqn: string;
71
+ /** Zero-based page offset for paginated results. Omitted when not provided. */
72
+ pageOffset?: number;
73
+ /** Maximum number of results to return. Omitted when not provided. */
74
+ searchLimit?: number;
62
75
  }
63
76
  /** Overridable subset of the search inputs; keyword is supplied separately. */
64
77
  export type BrandSearchOptions = Partial<Omit<BrandSearchRequestInput, "searchKeyword">>;
@@ -113,6 +126,17 @@ export declare function resolveSearchApiVersion(apiVersion: string): string;
113
126
  * @param options - Optional overrides for language, channel type, content type
114
127
  */
115
128
  export declare function buildBrandSearchRequest(query: string, apiVersion: string, options?: BrandSearchOptions): BrandSearchRequest;
129
+ /**
130
+ * Build a request that preloads the published brands for the org gallery. Uses
131
+ * the all-brands keyword prefix with a bounded page so the initial list isn't
132
+ * empty before the user runs a search. A thin wrapper over
133
+ * `buildBrandSearchRequest` — the host issues the POST as usual and feeds the
134
+ * response to `parseBrandSearchResponse`.
135
+ *
136
+ * @param apiVersion - The host connection's API version
137
+ * @param limit - Max brands to preload (defaults to `DEFAULT_BRAND_PRELOAD_LIMIT`)
138
+ */
139
+ export declare function buildBrandPreloadRequest(apiVersion: string, limit?: number): BrandSearchRequest;
116
140
  /**
117
141
  * Parse the raw `searchCmsChannelContent` response into items and a total.
118
142
  *
@@ -1 +1 @@
1
- {"version":3,"file":"brandSearch.d.ts","sourceRoot":"","sources":["../../src/protocol/brandSearch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AAEH,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,6EAA6E;AAC7E,eAAO,MAAM,0CAA0C,KAAK,CAAC;AAE7D,iFAAiF;AACjF,eAAO,MAAM,4BAA4B;;;;CAI/B,CAAC;AAEX,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4BAA4B,CAAC,EAAE;QAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAChE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC,CAAC;AAEzF,kEAAkE;AAClE,MAAM,WAAW,kBAAkB;IACl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;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,MAAoC,GACzC,kBAAkB,CAKpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,GAAG,iBAAiB,CA6B7E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAGvE"}
@@ -1,5 +1,7 @@
1
1
  const MIN_SEARCH_QUERY_LENGTH = 3;
2
2
  const SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = 62;
3
+ const ALL_PUBLISHED_BRANDS_KEYWORD = "0ap";
4
+ const DEFAULT_BRAND_PRELOAD_LIMIT = 5;
3
5
  const DEFAULT_BRAND_SEARCH_OPTIONS = {
4
6
  searchLanguage: "en_US",
5
7
  channelType: "PublicUnauthenticated",
@@ -15,20 +17,29 @@ function resolveSearchApiVersion(apiVersion) {
15
17
  }
16
18
  function buildBrandSearchRequest(query, apiVersion, options = {}) {
17
19
  const version = resolveSearchApiVersion(apiVersion);
20
+ const input = {
21
+ searchKeyword: query,
22
+ searchLanguage: options.searchLanguage ?? DEFAULT_BRAND_SEARCH_OPTIONS.searchLanguage,
23
+ channelType: options.channelType ?? DEFAULT_BRAND_SEARCH_OPTIONS.channelType,
24
+ contentTypeFqn: options.contentTypeFqn ?? DEFAULT_BRAND_SEARCH_OPTIONS.contentTypeFqn
25
+ };
26
+ if (options.pageOffset !== void 0) {
27
+ input.pageOffset = options.pageOffset;
28
+ }
29
+ if (options.searchLimit !== void 0) {
30
+ input.searchLimit = options.searchLimit;
31
+ }
18
32
  return {
19
33
  path: `/services/data/v${version}/actions/standard/searchCmsChannelContent`,
20
- body: {
21
- inputs: [
22
- {
23
- searchKeyword: query,
24
- searchLanguage: options.searchLanguage ?? DEFAULT_BRAND_SEARCH_OPTIONS.searchLanguage,
25
- channelType: options.channelType ?? DEFAULT_BRAND_SEARCH_OPTIONS.channelType,
26
- contentTypeFqn: options.contentTypeFqn ?? DEFAULT_BRAND_SEARCH_OPTIONS.contentTypeFqn
27
- }
28
- ]
29
- }
34
+ body: { inputs: [input] }
30
35
  };
31
36
  }
37
+ function buildBrandPreloadRequest(apiVersion, limit = DEFAULT_BRAND_PRELOAD_LIMIT) {
38
+ return buildBrandSearchRequest(ALL_PUBLISHED_BRANDS_KEYWORD, apiVersion, {
39
+ pageOffset: 0,
40
+ searchLimit: limit
41
+ });
42
+ }
32
43
  function parseBrandSearchResponse(response) {
33
44
  const results = Array.isArray(response) ? response : [response];
34
45
  const result = results[0];
@@ -53,9 +64,12 @@ function getContentUrl(item) {
53
64
  return item.managedContentChannelDeliveryDetails?.find((detail) => detail?.contentUrl)?.contentUrl;
54
65
  }
55
66
  export {
67
+ ALL_PUBLISHED_BRANDS_KEYWORD,
68
+ DEFAULT_BRAND_PRELOAD_LIMIT,
56
69
  DEFAULT_BRAND_SEARCH_OPTIONS,
57
70
  MIN_SEARCH_QUERY_LENGTH,
58
71
  SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION,
72
+ buildBrandPreloadRequest,
59
73
  buildBrandSearchRequest,
60
74
  getContentUrl,
61
75
  isValidSearchQuery,
@@ -37,16 +37,22 @@ exports.unwrapBrandEnvelope = brandTypes.unwrapBrandEnvelope;
37
37
  exports.isBrandRef = brandResolver.isBrandRef;
38
38
  exports.resolveBrandTokens = brandResolver.resolveBrandTokens;
39
39
  exports.resolveRef = brandResolver.resolveRef;
40
+ exports.OKLCH_DISPLAY_VARS = brandCss.OKLCH_DISPLAY_VARS;
40
41
  exports.brandToVariables = brandCss.brandToVariables;
41
42
  exports.generateBrandCss = brandCss.generateBrandCss;
43
+ exports.oklchDisplayVars = brandCss.oklchDisplayVars;
44
+ exports.toOklchString = brandCss.toOklchString;
42
45
  exports.darkenColor = deriveColors.darkenColor;
43
46
  exports.deriveBrandColors = deriveColors.deriveBrandColors;
44
47
  exports.derivePrimaryAccentContrastDerived = deriveColors.derivePrimaryAccentContrastDerived;
45
48
  exports.derivePrimaryAccentDerived = deriveColors.derivePrimaryAccentDerived;
46
49
  exports.updateDerivedColors = deriveColors.updateDerivedColors;
50
+ exports.ALL_PUBLISHED_BRANDS_KEYWORD = brandSearch.ALL_PUBLISHED_BRANDS_KEYWORD;
51
+ exports.DEFAULT_BRAND_PRELOAD_LIMIT = brandSearch.DEFAULT_BRAND_PRELOAD_LIMIT;
47
52
  exports.DEFAULT_BRAND_SEARCH_OPTIONS = brandSearch.DEFAULT_BRAND_SEARCH_OPTIONS;
48
53
  exports.MIN_SEARCH_QUERY_LENGTH = brandSearch.MIN_SEARCH_QUERY_LENGTH;
49
54
  exports.SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION = brandSearch.SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION;
55
+ exports.buildBrandPreloadRequest = brandSearch.buildBrandPreloadRequest;
50
56
  exports.buildBrandSearchRequest = brandSearch.buildBrandSearchRequest;
51
57
  exports.getContentUrl = brandSearch.getContentUrl;
52
58
  exports.isValidSearchQuery = brandSearch.isValidSearchQuery;
@@ -4,11 +4,13 @@ import { createBuiltInThemes } from "./ootbThemes.js";
4
4
  import { camelToLabel, escapeHtml } from "./utils.js";
5
5
  import { getBrandLogoAltText, getBrandLogoUrl, getBrandTitle, unwrapBrandEnvelope } from "./brandTypes.js";
6
6
  import { isBrandRef, resolveBrandTokens, resolveRef } from "./brandResolver.js";
7
- import { brandToVariables, generateBrandCss } from "./brandCss.js";
7
+ import { OKLCH_DISPLAY_VARS, brandToVariables, generateBrandCss, oklchDisplayVars, toOklchString } from "./brandCss.js";
8
8
  import { darkenColor, deriveBrandColors, derivePrimaryAccentContrastDerived, derivePrimaryAccentDerived, updateDerivedColors } from "./deriveColors.js";
9
- import { DEFAULT_BRAND_SEARCH_OPTIONS, MIN_SEARCH_QUERY_LENGTH, SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION, buildBrandSearchRequest, getContentUrl, isValidSearchQuery, parseBrandSearchResponse, resolveSearchApiVersion } from "./brandSearch.js";
9
+ import { ALL_PUBLISHED_BRANDS_KEYWORD, DEFAULT_BRAND_PRELOAD_LIMIT, DEFAULT_BRAND_SEARCH_OPTIONS, MIN_SEARCH_QUERY_LENGTH, SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION, buildBrandPreloadRequest, buildBrandSearchRequest, getContentUrl, isValidSearchQuery, parseBrandSearchResponse, resolveSearchApiVersion } from "./brandSearch.js";
10
10
  const PROTOCOL_VERSION = "1.0.0";
11
11
  export {
12
+ ALL_PUBLISHED_BRANDS_KEYWORD,
13
+ DEFAULT_BRAND_PRELOAD_LIMIT,
12
14
  DEFAULT_BRAND_SEARCH_OPTIONS,
13
15
  MIN_SEARCH_QUERY_LENGTH,
14
16
  MSG_APPLY_VIBES,
@@ -26,9 +28,11 @@ export {
26
28
  MSG_UPDATE_COMPONENT_OVERRIDE,
27
29
  MSG_UPDATE_PROPERTY,
28
30
  MSG_UPDATE_THEME,
31
+ OKLCH_DISPLAY_VARS,
29
32
  PROTOCOL_VERSION,
30
33
  SEARCH_CMS_CHANNEL_CONTENT_MIN_API_VERSION,
31
34
  brandToVariables,
35
+ buildBrandPreloadRequest,
32
36
  buildBrandSearchRequest,
33
37
  camelToLabel,
34
38
  createBuiltInThemes,
@@ -45,11 +49,13 @@ export {
45
49
  getContentUrl,
46
50
  isBrandRef,
47
51
  isValidSearchQuery,
52
+ oklchDisplayVars,
48
53
  parseBrandSearchResponse,
49
54
  resolveBrandTokens,
50
55
  resolveRef,
51
56
  resolveSearchApiVersion,
52
57
  themeToVariables,
58
+ toOklchString,
53
59
  unwrapBrandEnvelope,
54
60
  updateDerivedColors
55
61
  };