@commmerce/ui 1.0.0-rc.3 → 1.0.0-rc.5

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 (101) hide show
  1. package/README.md +1 -1
  2. package/dist/base.d.ts +5 -0
  3. package/dist/base.js +10 -0
  4. package/dist/calendar.d.ts +95 -0
  5. package/dist/calendar.js +280 -0
  6. package/dist/cdn.js +721 -477
  7. package/dist/components/accordion.js +2 -2
  8. package/dist/components/action-bar.d.ts +12 -2
  9. package/dist/components/action-bar.js +10 -5
  10. package/dist/components/action-menu.d.ts +17 -4
  11. package/dist/components/action-menu.js +8 -5
  12. package/dist/components/app-card.d.ts +24 -2
  13. package/dist/components/app-card.js +25 -10
  14. package/dist/components/banner.d.ts +2 -2
  15. package/dist/components/banner.js +4 -3
  16. package/dist/components/bottom-navigation.d.ts +16 -4
  17. package/dist/components/bottom-navigation.js +10 -7
  18. package/dist/components/bottom-sheet.d.ts +4 -1
  19. package/dist/components/bottom-sheet.js +2 -2
  20. package/dist/components/checkbox.d.ts +12 -2
  21. package/dist/components/checkbox.js +7 -2
  22. package/dist/components/combobox.d.ts +186 -0
  23. package/dist/components/combobox.js +521 -0
  24. package/dist/components/comment.d.ts +27 -9
  25. package/dist/components/comment.js +14 -13
  26. package/dist/components/data-table.d.ts +14 -2
  27. package/dist/components/data-table.js +31 -10
  28. package/dist/components/date-picker.d.ts +179 -0
  29. package/dist/components/date-picker.js +336 -0
  30. package/dist/components/date-range-picker.d.ts +251 -0
  31. package/dist/components/date-range-picker.js +484 -0
  32. package/dist/components/file-upload.d.ts +30 -4
  33. package/dist/components/file-upload.js +37 -17
  34. package/dist/components/filter-panel.d.ts +29 -6
  35. package/dist/components/filter-panel.js +16 -14
  36. package/dist/components/flash-offer-bar.d.ts +18 -4
  37. package/dist/components/flash-offer-bar.js +13 -8
  38. package/dist/components/header-bar.d.ts +20 -4
  39. package/dist/components/header-bar.js +20 -13
  40. package/dist/components/icon.d.ts +7 -0
  41. package/dist/components/icon.js +9 -1
  42. package/dist/components/link-tabs.d.ts +16 -4
  43. package/dist/components/link-tabs.js +10 -7
  44. package/dist/components/mobile-menu.d.ts +19 -4
  45. package/dist/components/mobile-menu.js +16 -10
  46. package/dist/components/modal.d.ts +4 -1
  47. package/dist/components/nested-list.d.ts +22 -3
  48. package/dist/components/nested-list.js +25 -12
  49. package/dist/components/notification-panel.d.ts +26 -5
  50. package/dist/components/notification-panel.js +17 -11
  51. package/dist/components/option-group.d.ts +12 -2
  52. package/dist/components/option-group.js +13 -7
  53. package/dist/components/page-header.d.ts +18 -2
  54. package/dist/components/page-header.js +23 -10
  55. package/dist/components/pagination.d.ts +27 -4
  56. package/dist/components/pagination.js +28 -16
  57. package/dist/components/progress-bar.d.ts +12 -2
  58. package/dist/components/progress-bar.js +9 -4
  59. package/dist/components/radio.d.ts +12 -1
  60. package/dist/components/radio.js +12 -6
  61. package/dist/components/report-tile.d.ts +12 -1
  62. package/dist/components/report-tile.js +9 -4
  63. package/dist/components/resource-list.d.ts +36 -5
  64. package/dist/components/resource-list.js +50 -23
  65. package/dist/components/save-bar.d.ts +23 -6
  66. package/dist/components/save-bar.js +14 -12
  67. package/dist/components/search.d.ts +28 -7
  68. package/dist/components/search.js +18 -13
  69. package/dist/components/select.d.ts +12 -2
  70. package/dist/components/select.js +9 -4
  71. package/dist/components/side-navigation.d.ts +16 -4
  72. package/dist/components/side-navigation.js +16 -12
  73. package/dist/components/side-panel.d.ts +5 -2
  74. package/dist/components/side-panel.js +5 -3
  75. package/dist/components/skeleton-display.d.ts +6 -4
  76. package/dist/components/skeleton-display.js +4 -5
  77. package/dist/components/smart-tip.d.ts +25 -6
  78. package/dist/components/smart-tip.js +18 -12
  79. package/dist/components/spinner.d.ts +4 -3
  80. package/dist/components/spinner.js +5 -6
  81. package/dist/components/status-tabs.d.ts +12 -2
  82. package/dist/components/status-tabs.js +14 -8
  83. package/dist/components/table-header.d.ts +15 -2
  84. package/dist/components/table-header.js +13 -5
  85. package/dist/components/tag.d.ts +12 -2
  86. package/dist/components/tag.js +9 -4
  87. package/dist/components/text-field.d.ts +12 -2
  88. package/dist/components/text-field.js +9 -4
  89. package/dist/components/thumbnail.d.ts +12 -2
  90. package/dist/components/thumbnail.js +8 -3
  91. package/dist/components/toast.d.ts +14 -3
  92. package/dist/components/toast.js +20 -9
  93. package/dist/components/toggle.js +2 -0
  94. package/dist/custom-elements.json +16477 -6434
  95. package/dist/index.d.ts +7 -1
  96. package/dist/index.js +5 -1
  97. package/dist/localize.d.ts +130 -0
  98. package/dist/localize.js +232 -0
  99. package/dist/overlay.d.ts +8 -4
  100. package/dist/overlay.js +9 -12
  101. package/package.json +4 -4
@@ -1,6 +1,35 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  import './icon.js';
3
3
  import './action-menu.js';
4
+ declare const itemStrings: {
5
+ /** Accessible name of a row's checkbox. */
6
+ select: string;
7
+ };
8
+ declare const strings: {
9
+ /** Default nouns, when `resource-name` isn't set. */
10
+ resourceName: string;
11
+ resourceNamePlural: string;
12
+ /** Visible label of the select-all box; `selectPageHidden` follows it for screen readers only. */
13
+ select: string;
14
+ selectPageHidden: string;
15
+ /** Accessible name of the menu next to the select-all box, and its choices. */
16
+ selectionOptions: string;
17
+ selectPage: string;
18
+ selectAll: string;
19
+ selectNone: string;
20
+ /** Selection status. `{resource}` is singular or plural to match `{count}`. */
21
+ selected: string;
22
+ allSelected: string;
23
+ clearSelection: string;
24
+ /** Accessible name of the spinner while loading. */
25
+ loading: string;
26
+ };
27
+ declare module '../localize.js' {
28
+ interface CmStrings {
29
+ resourceItem: typeof itemStrings;
30
+ resourceList: typeof strings;
31
+ }
32
+ }
4
33
  /**
5
34
  * A row in a `cm-resource-list`: a checkbox when the list is selectable, an optional thumbnail and
6
35
  * any content. With `href` the whole row is a link; otherwise clicking a selectable row ticks it.
@@ -10,7 +39,7 @@ import './action-menu.js';
10
39
  * @slot actions - Buttons at the end of the row. They do not toggle selection.
11
40
  * @fires cm-resource-select - `detail: { value, selected }` when the merchant ticks or unticks the row. The list handles it.
12
41
  */
13
- export declare class CmResourceItem extends LitElement {
42
+ export declare class CmResourceItem extends CmLocalizedElement {
14
43
  #private;
15
44
  static properties: {
16
45
  value: {
@@ -65,7 +94,7 @@ export declare class CmResourceItem extends LitElement {
65
94
  * @slot empty - Shown instead of the rows when there are none, e.g. a `cm-empty-state`.
66
95
  * @fires cm-selection-change - `detail: { selected, all }`: values of the selected rows, and whether every matching resource (all `total`) is selected.
67
96
  */
68
- export declare class CmResourceList extends LitElement {
97
+ export declare class CmResourceList extends CmLocalizedElement {
69
98
  #private;
70
99
  static properties: {
71
100
  selectable: {
@@ -77,6 +106,7 @@ export declare class CmResourceList extends LitElement {
77
106
  };
78
107
  resourceName: {
79
108
  attribute: string;
109
+ string: string;
80
110
  };
81
111
  resourceNamePlural: {
82
112
  attribute: string;
@@ -106,9 +136,9 @@ export declare class CmResourceList extends LitElement {
106
136
  selectable: boolean;
107
137
  /** Number of resources matching the current filter across all pages. When higher than the rows shown, offers "Select all". */
108
138
  total: number;
109
- /** Singular noun, e.g. "product". */
139
+ /** Singular noun, e.g. "product". Default: the built-in string `resourceName` ("item"). */
110
140
  resourceName: string;
111
- /** Plural noun. Defaults to the singular plus "s". */
141
+ /** Plural noun. Defaults to the singular plus "s" (or the built-in `resourceNamePlural`, "items", when `resource-name` isn't set). */
112
142
  resourceNamePlural: string;
113
143
  /** Dims the rows and shows a spinner while results load. */
114
144
  loading: boolean;
@@ -141,3 +171,4 @@ declare global {
141
171
  'cm-resource-item': CmResourceItem;
142
172
  }
143
173
  }
174
+ export {};
@@ -4,10 +4,34 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _CmResourceItem_instances, _CmResourceItem_internals, _CmResourceItem_onRowClick, _CmResourceList_instances, _CmResourceList_id, _CmResourceList_plural, _CmResourceList_sync, _CmResourceList_emit, _CmResourceList_menuSelect;
7
- import { LitElement, html, css, nothing } from 'lit';
7
+ import { html, css, nothing } from 'lit';
8
8
  import { base, define, nextId } from '../base.js';
9
+ import { CmLocalizedElement, defineStrings, pluralCategory } from '../localize.js';
9
10
  import './icon.js';
10
11
  import './action-menu.js';
12
+ const itemStrings = defineStrings('resourceItem', {
13
+ /** Accessible name of a row's checkbox. */
14
+ select: 'Select {name}',
15
+ });
16
+ const strings = defineStrings('resourceList', {
17
+ /** Default nouns, when `resource-name` isn't set. */
18
+ resourceName: 'item',
19
+ resourceNamePlural: 'items',
20
+ /** Visible label of the select-all box; `selectPageHidden` follows it for screen readers only. */
21
+ select: 'Select',
22
+ selectPageHidden: 'all {count} {resource} on this page',
23
+ /** Accessible name of the menu next to the select-all box, and its choices. */
24
+ selectionOptions: 'Selection options',
25
+ selectPage: 'Select all {count} on this page',
26
+ selectAll: 'Select all {count} {resource}',
27
+ selectNone: 'Select none',
28
+ /** Selection status. `{resource}` is singular or plural to match `{count}`. */
29
+ selected: '{count} {resource} selected.',
30
+ allSelected: 'All {count} {resource} selected.',
31
+ clearSelection: 'Clear selection',
32
+ /** Accessible name of the spinner while loading. */
33
+ loading: 'Loading {resource}',
34
+ });
11
35
  const checkboxStyles = css `
12
36
  .check { position: relative; display: inline-flex; flex: none; width: 20px; height: 20px; }
13
37
  .check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
@@ -30,7 +54,7 @@ const checkboxStyles = css `
30
54
  * @slot actions - Buttons at the end of the row. They do not toggle selection.
31
55
  * @fires cm-resource-select - `detail: { value, selected }` when the merchant ticks or unticks the row. The list handles it.
32
56
  */
33
- export class CmResourceItem extends LitElement {
57
+ export class CmResourceItem extends CmLocalizedElement {
34
58
  constructor() {
35
59
  super();
36
60
  _CmResourceItem_instances.add(this);
@@ -74,7 +98,7 @@ export class CmResourceItem extends LitElement {
74
98
  ${this.href && !this.disabled ? html `<a href=${this.href} part="link"><span class="sr">${this.name}</span></a>` : nothing}
75
99
  <div class="row" part="row" @click=${__classPrivateFieldGet(this, _CmResourceItem_instances, "m", _CmResourceItem_onRowClick)}>
76
100
  ${this.selectable
77
- ? html `<span class="check" part="checkbox"><input type="checkbox" aria-label=${`Select ${this.name}`} .checked=${this.selected}
101
+ ? html `<span class="check" part="checkbox"><input type="checkbox" aria-label=${this.t('select', { name: this.name })} .checked=${this.selected}
78
102
  ?disabled=${this.disabled} @change=${(e) => this.toggle(e.target.checked)} />
79
103
  <span class="box" aria-hidden="true">${this.selected ? html `<cm-icon name="check" size="14"></cm-icon>` : nothing}</span></span>`
80
104
  : nothing}
@@ -149,7 +173,7 @@ define('cm-resource-item', CmResourceItem);
149
173
  * @slot empty - Shown instead of the rows when there are none, e.g. a `cm-empty-state`.
150
174
  * @fires cm-selection-change - `detail: { selected, all }`: values of the selected rows, and whether every matching resource (all `total`) is selected.
151
175
  */
152
- export class CmResourceList extends LitElement {
176
+ export class CmResourceList extends CmLocalizedElement {
153
177
  constructor() {
154
178
  super();
155
179
  _CmResourceList_instances.add(this);
@@ -157,9 +181,7 @@ export class CmResourceList extends LitElement {
157
181
  this.selectable = false;
158
182
  /** Number of resources matching the current filter across all pages. When higher than the rows shown, offers "Select all". */
159
183
  this.total = 0;
160
- /** Singular noun, e.g. "product". */
161
- this.resourceName = 'item';
162
- /** Plural noun. Defaults to the singular plus "s". */
184
+ /** Plural noun. Defaults to the singular plus "s" (or the built-in `resourceNamePlural`, "items", when `resource-name` isn't set). */
163
185
  this.resourceNamePlural = '';
164
186
  /** Dims the rows and shows a spinner while results load. */
165
187
  this.loading = false;
@@ -226,17 +248,16 @@ export class CmResourceList extends LitElement {
226
248
  const rows = this._rows;
227
249
  const enabled = this.items.filter((i) => !i.disabled).length;
228
250
  const all = enabled > 0 && n >= enabled;
229
- const fmt = (x) => x.toLocaleString();
230
251
  const plural = __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_plural).call(this);
231
- const noun = (x) => (x === 1 ? this.resourceName : plural);
252
+ const noun = (x) => (pluralCategory(x, this.locale) === 'one' ? this.resourceName : plural);
232
253
  const more = this.total > rows;
233
254
  let status = nothing;
234
255
  if (this.allSelected) {
235
- status = html `All ${fmt(Math.max(this.total, n))} ${plural} selected. <button type="button" @click=${() => this.clearSelection()}>Clear selection</button>`;
256
+ status = html `${this.t('allSelected', { count: Math.max(this.total, n), resource: plural })} <button type="button" @click=${() => this.clearSelection()}>${this.t('clearSelection')}</button>`;
236
257
  }
237
258
  else if (n) {
238
- status = html `${fmt(n)} ${noun(n)} selected.${all && more
239
- ? html ` <button type="button" @click=${() => this.selectAll()}>Select all ${fmt(this.total)} ${plural}</button>` : nothing}`;
259
+ status = html `${this.t('selected', { count: n, resource: noun(n) })}${all && more
260
+ ? html ` <button type="button" @click=${() => this.selectAll()}>${this.t('selectAll', { count: this.total, resource: plural })}</button>` : nothing}`;
240
261
  }
241
262
  return html `
242
263
  ${this.selectable
@@ -245,12 +266,12 @@ export class CmResourceList extends LitElement {
245
266
  <span class="check"><input id="${__classPrivateFieldGet(this, _CmResourceList_id, "f")}-all" type="checkbox" .checked=${all} .indeterminate=${n > 0 && !all}
246
267
  ?disabled=${!enabled} @change=${(e) => this.selectPage(e.target.checked)} />
247
268
  <span class="box" aria-hidden="true">${n > 0 && !all ? html `<span class="dash"></span>` : all ? html `<cm-icon name="check" size="12"></cm-icon>` : nothing}</span></span>
248
- <label for="${__classPrivateFieldGet(this, _CmResourceList_id, "f")}-all">Select<span class="sr"> all ${fmt(rows)} ${noun(rows)} on this page</span></label>
249
- ${this.hideSelectMenu ? nothing : html `<cm-action-menu icon-only icon="chevron-down" part="select-menu" label="Selection options"
269
+ <label for="${__classPrivateFieldGet(this, _CmResourceList_id, "f")}-all">${this.t('select')}<span class="sr"> ${this.t('selectPageHidden', { count: rows, resource: noun(rows) })}</span></label>
270
+ ${this.hideSelectMenu ? nothing : html `<cm-action-menu icon-only icon="chevron-down" part="select-menu" label=${this.t('selectionOptions')}
250
271
  .items=${[
251
- { label: `Select all ${fmt(enabled)} on this page`, value: 'page', disabled: !enabled },
252
- ...(more ? [{ label: `Select all ${fmt(this.total)} ${plural}`, value: 'all' }] : []),
253
- { label: 'Select none', value: 'none', disabled: !n && !this.allSelected },
272
+ { label: this.t('selectPage', { count: enabled }), value: 'page', disabled: !enabled },
273
+ ...(more ? [{ label: this.t('selectAll', { count: this.total, resource: plural }), value: 'all' }] : []),
274
+ { label: this.t('selectNone'), value: 'none', disabled: !n && !this.allSelected },
254
275
  ]} @cm-select=${__classPrivateFieldGet(this, _CmResourceList_menuSelect, "f")}></cm-action-menu>`}
255
276
  </span>
256
277
  <span class="bulk" ?hidden=${!n}><slot name="bulk-actions"></slot></span>
@@ -263,13 +284,19 @@ export class CmResourceList extends LitElement {
263
284
  <div class="list" part="list" role="list" aria-label=${this.label || plural.replace(/^./, (c) => c.toUpperCase())} aria-busy=${this.loading ? 'true' : 'false'}>
264
285
  <slot @slotchange=${() => __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this)}></slot>
265
286
  </div>
266
- ${this.loading ? html `<span class="spinner" part="spinner" role="progressbar" aria-label=${`Loading ${plural}`}></span>` : nothing}
287
+ ${this.loading ? html `<span class="spinner" part="spinner" role="progressbar" aria-label=${this.t('loading', { resource: plural })}></span>` : nothing}
267
288
  </div>
268
289
  <div class="empty ${rows || this.loading ? '' : 'show'}"><slot name="empty"></slot></div>
269
290
  `;
270
291
  }
271
292
  }
272
- _CmResourceList_id = new WeakMap(), _CmResourceList_menuSelect = new WeakMap(), _CmResourceList_instances = new WeakSet(), _CmResourceList_plural = function _CmResourceList_plural() { return this.resourceNamePlural || `${this.resourceName}s`; }, _CmResourceList_sync = function _CmResourceList_sync() {
293
+ _CmResourceList_id = new WeakMap(), _CmResourceList_menuSelect = new WeakMap(), _CmResourceList_instances = new WeakSet(), _CmResourceList_plural = function _CmResourceList_plural() {
294
+ if (this.resourceNamePlural)
295
+ return this.resourceNamePlural;
296
+ const own = this.resourceName;
297
+ // A custom singular keeps the old rule (plus "s"); the built-in noun has its own plural.
298
+ return own !== this.t('resourceName') ? `${own}s` : this.t('resourceNamePlural');
299
+ }, _CmResourceList_sync = function _CmResourceList_sync() {
273
300
  const items = this.items;
274
301
  items.forEach((i) => (i.selectable = this.selectable));
275
302
  this._rows = items.length;
@@ -280,7 +307,7 @@ _CmResourceList_id = new WeakMap(), _CmResourceList_menuSelect = new WeakMap(),
280
307
  CmResourceList.properties = {
281
308
  selectable: { type: Boolean, reflect: true },
282
309
  total: { type: Number },
283
- resourceName: { attribute: 'resource-name' },
310
+ resourceName: { attribute: 'resource-name', string: 'resourceName' },
284
311
  resourceNamePlural: { attribute: 'resource-name-plural' },
285
312
  loading: { type: Boolean, reflect: true },
286
313
  allSelected: { type: Boolean, attribute: 'all-selected', reflect: true },
@@ -308,14 +335,14 @@ CmResourceList.styles = [
308
335
  .status { flex: 1; text-align: center; font-size: 16px; }
309
336
  .status button { font: inherit; font-weight: 500; color: inherit; text-decoration: underline; background: none; border: 0; padding: 0; cursor: pointer; }
310
337
  .status button:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
311
- .actions { display: flex; gap: var(--cm-space-10); margin-left: auto; }
338
+ .actions { display: flex; gap: var(--cm-space-10); margin-inline-start: auto; }
312
339
  .header { display: block; padding: var(--cm-space-20) var(--cm-space-20) 0; }
313
340
  .header:not(.has) { display: none; }
314
341
  .body { position: relative; }
315
342
  .list { padding: 0 var(--cm-space-20) var(--cm-space-10); }
316
343
  :host([loading]) .list ::slotted(*) { opacity: 0.4; }
317
344
  .spinner {
318
- position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%;
345
+ position: absolute; inset-inline-start: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%;
319
346
  border: 4px solid var(--cm-thumb-bg); border-top-color: var(--cm-icon-selected); animation: spin 0.8s linear infinite;
320
347
  }
321
348
  @keyframes spin { to { transform: rotate(360deg); } }
@@ -325,7 +352,7 @@ CmResourceList.styles = [
325
352
  @media (max-width: 640px) {
326
353
  .toolbar { gap: var(--cm-space-10); padding: var(--cm-space-10) var(--cm-space-10) 0; }
327
354
  .select { height: 32px; font-size: 12px; }
328
- .status { flex-basis: 100%; order: 3; text-align: left; font-size: 12px; }
355
+ .status { flex-basis: 100%; order: 3; text-align: start; font-size: 12px; }
329
356
  .header { padding: var(--cm-space-10) var(--cm-space-10) 0; }
330
357
  .list { padding: 0 var(--cm-space-10); }
331
358
  .spinner { width: 30px; height: 30px; margin: -15px; border-width: 3px; }
@@ -1,5 +1,17 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  import './button.js';
3
+ declare const strings: {
4
+ /** The message next to the buttons. */
5
+ message: string;
6
+ /** The two buttons. */
7
+ save: string;
8
+ discard: string;
9
+ };
10
+ declare module '../localize.js' {
11
+ interface CmStrings {
12
+ saveBar: typeof strings;
13
+ }
14
+ }
3
15
  /**
4
16
  * Asks the merchant to save or discard unsaved changes. Hidden until `open` (or, with `form`,
5
17
  * until a field in that form changes). Built on the Figma "Bottom Tab" save variant.
@@ -7,19 +19,23 @@ import './button.js';
7
19
  * @fires cm-save - Save pressed (cancelable). With `form`, the default submits that form.
8
20
  * @fires cm-discard - Discard pressed (cancelable). With `form`, the default resets that form and closes the bar.
9
21
  */
10
- export declare class CmSaveBar extends LitElement {
22
+ export declare class CmSaveBar extends CmLocalizedElement {
11
23
  #private;
12
24
  static properties: {
13
25
  open: {
14
26
  type: BooleanConstructor;
15
27
  reflect: boolean;
16
28
  };
17
- message: {};
29
+ message: {
30
+ string: string;
31
+ };
18
32
  saveLabel: {
19
33
  attribute: string;
34
+ string: string;
20
35
  };
21
36
  discardLabel: {
22
37
  attribute: string;
38
+ string: string;
23
39
  };
24
40
  loading: {
25
41
  type: BooleanConstructor;
@@ -33,11 +49,11 @@ export declare class CmSaveBar extends LitElement {
33
49
  };
34
50
  /** Shows the bar. Set it when the page has unsaved changes. */
35
51
  open: boolean;
36
- /** The question or status shown next to the buttons. */
52
+ /** The question or status shown next to the buttons. Default: the built-in string `message` ("Unsaved changes"). */
37
53
  message: string;
38
- /** Primary button label. */
54
+ /** Primary button label. Default: the built-in string `save` ("Save"). */
39
55
  saveLabel: string;
40
- /** Secondary button label. */
56
+ /** Secondary button label. Default: the built-in string `discard` ("Discard"). */
41
57
  discardLabel: string;
42
58
  /** Shows a spinner on Save and blocks both buttons while saving. */
43
59
  loading: boolean;
@@ -56,3 +72,4 @@ declare global {
56
72
  'cm-save-bar': CmSaveBar;
57
73
  }
58
74
  }
75
+ export {};
@@ -10,9 +10,17 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
12
  var _CmSaveBar_instances, _CmSaveBar_watched, _CmSaveBar_onDirty, _CmSaveBar_onReset, _CmSaveBar_watch, _CmSaveBar_unwatch, _CmSaveBar_emit, _CmSaveBar_save, _CmSaveBar_discard;
13
- import { LitElement, html, css } from 'lit';
13
+ import { html, css } from 'lit';
14
14
  import { base, define } from '../base.js';
15
+ import { CmLocalizedElement, defineStrings } from '../localize.js';
15
16
  import './button.js';
17
+ const strings = defineStrings('saveBar', {
18
+ /** The message next to the buttons. */
19
+ message: 'Unsaved changes',
20
+ /** The two buttons. */
21
+ save: 'Save',
22
+ discard: 'Discard',
23
+ });
16
24
  /**
17
25
  * Asks the merchant to save or discard unsaved changes. Hidden until `open` (or, with `form`,
18
26
  * until a field in that form changes). Built on the Figma "Bottom Tab" save variant.
@@ -20,18 +28,12 @@ import './button.js';
20
28
  * @fires cm-save - Save pressed (cancelable). With `form`, the default submits that form.
21
29
  * @fires cm-discard - Discard pressed (cancelable). With `form`, the default resets that form and closes the bar.
22
30
  */
23
- export class CmSaveBar extends LitElement {
31
+ export class CmSaveBar extends CmLocalizedElement {
24
32
  constructor() {
25
33
  super(...arguments);
26
34
  _CmSaveBar_instances.add(this);
27
35
  /** Shows the bar. Set it when the page has unsaved changes. */
28
36
  this.open = false;
29
- /** The question or status shown next to the buttons. */
30
- this.message = 'Unsaved changes';
31
- /** Primary button label. */
32
- this.saveLabel = 'Save';
33
- /** Secondary button label. */
34
- this.discardLabel = 'Discard';
35
37
  /** Shows a spinner on Save and blocks both buttons while saving. */
36
38
  this.loading = false;
37
39
  /** Disables Save, for example while the form has errors. */
@@ -98,9 +100,9 @@ _CmSaveBar_watched = new WeakMap(), _CmSaveBar_onDirty = new WeakMap(), _CmSaveB
98
100
  };
99
101
  CmSaveBar.properties = {
100
102
  open: { type: Boolean, reflect: true },
101
- message: {},
102
- saveLabel: { attribute: 'save-label' },
103
- discardLabel: { attribute: 'discard-label' },
103
+ message: { string: 'message' },
104
+ saveLabel: { attribute: 'save-label', string: 'save' },
105
+ discardLabel: { attribute: 'discard-label', string: 'discard' },
104
106
  loading: { type: Boolean, reflect: true },
105
107
  saveDisabled: { type: Boolean, attribute: 'save-disabled' },
106
108
  form: {},
@@ -117,7 +119,7 @@ CmSaveBar.styles = [
117
119
  border-radius: var(--cm-radius-md); box-shadow: var(--cm-shadow-100);
118
120
  }
119
121
  .message { flex: 1 1 200px; margin: 0; font-size: 20px; font-weight: 600; }
120
- .actions { flex: none; display: flex; gap: var(--cm-space-20); margin-left: auto; }
122
+ .actions { flex: none; display: flex; gap: var(--cm-space-20); margin-inline-start: auto; }
121
123
  @media (max-width: 640px) {
122
124
  .bar { min-height: 68px; padding: var(--cm-space-10); gap: var(--cm-space-10); }
123
125
  .message { font-size: 14px; font-weight: 500; }
@@ -1,5 +1,20 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  import './icon.js';
3
+ declare const strings: {
4
+ /** Accessible name and placeholder of the field. */
5
+ label: string;
6
+ placeholder: string;
7
+ /** Accessible name of the filter button, and of it with filters applied. */
8
+ filter: string;
9
+ filterApplied: string;
10
+ /** Accessible name of the clear button. */
11
+ clear: string;
12
+ };
13
+ declare module '../localize.js' {
14
+ interface CmStrings {
15
+ search: typeof strings;
16
+ }
17
+ }
3
18
  /**
4
19
  * Search box for the top of lists and tables, with an optional filter button.
5
20
  * Participates in native forms.
@@ -9,7 +24,7 @@ import './icon.js';
9
24
  * @fires cm-search - When the merchant presses Enter. `detail.value` is the query.
10
25
  * @fires cm-filter - When the filter button is pressed. Open a filter panel in response.
11
26
  */
12
- export declare class CmSearch extends LitElement {
27
+ export declare class CmSearch extends CmLocalizedElement {
13
28
  #private;
14
29
  static formAssociated: boolean;
15
30
  static shadowRootOptions: {
@@ -19,17 +34,22 @@ export declare class CmSearch extends LitElement {
19
34
  slotAssignment?: SlotAssignmentMode;
20
35
  };
21
36
  static properties: {
22
- label: {};
37
+ label: {
38
+ string: string;
39
+ };
23
40
  name: {
24
41
  reflect: boolean;
25
42
  };
26
43
  value: {};
27
- placeholder: {};
44
+ placeholder: {
45
+ string: string;
46
+ };
28
47
  filter: {
29
48
  type: BooleanConstructor;
30
49
  };
31
50
  filterLabel: {
32
51
  attribute: string;
52
+ string: string;
33
53
  };
34
54
  filterCount: {
35
55
  type: NumberConstructor;
@@ -43,17 +63,17 @@ export declare class CmSearch extends LitElement {
43
63
  reflect: boolean;
44
64
  };
45
65
  };
46
- /** Accessible name, read by screen readers but not shown. Say what is searched: "Search orders". */
66
+ /** Accessible name, read by screen readers but not shown. Say what is searched: "Search orders". Default: the built-in string `label` ("Search"). */
47
67
  label: string;
48
68
  /** Form field name. */
49
69
  name: string;
50
70
  /** Current query. Updated on every keystroke. */
51
71
  value: string;
52
- /** Example query, shown in text-tertiary. */
72
+ /** Example query, shown in text-tertiary. Default: the built-in string `placeholder` ("Search"). */
53
73
  placeholder: string;
54
74
  /** Shows the filter button at the end of the box. */
55
75
  filter: boolean;
56
- /** Accessible name of the filter button. */
76
+ /** Accessible name of the filter button. Default: the built-in string `filter` ("Filter"). */
57
77
  filterLabel: string;
58
78
  /** Number of filters applied; shown on the filter button when above 0. */
59
79
  filterCount: number;
@@ -76,3 +96,4 @@ declare global {
76
96
  'cm-search': CmSearch;
77
97
  }
78
98
  }
99
+ export {};
@@ -13,7 +13,18 @@ var _CmSearch_instances, _CmSearch_internals, _CmSearch_id, _CmSearch_defaultVal
13
13
  import { LitElement, html, css, nothing } from 'lit';
14
14
  import { live } from 'lit/directives/live.js';
15
15
  import { base, define, nextId } from '../base.js';
16
+ import { CmLocalizedElement, defineStrings } from '../localize.js';
16
17
  import './icon.js';
18
+ const strings = defineStrings('search', {
19
+ /** Accessible name and placeholder of the field. */
20
+ label: 'Search',
21
+ placeholder: 'Search',
22
+ /** Accessible name of the filter button, and of it with filters applied. */
23
+ filter: 'Filter',
24
+ filterApplied: '{label} ({count} applied)',
25
+ /** Accessible name of the clear button. */
26
+ clear: 'Clear search',
27
+ });
17
28
  /**
18
29
  * Search box for the top of lists and tables, with an optional filter button.
19
30
  * Participates in native forms.
@@ -23,22 +34,16 @@ import './icon.js';
23
34
  * @fires cm-search - When the merchant presses Enter. `detail.value` is the query.
24
35
  * @fires cm-filter - When the filter button is pressed. Open a filter panel in response.
25
36
  */
26
- export class CmSearch extends LitElement {
37
+ export class CmSearch extends CmLocalizedElement {
27
38
  constructor() {
28
39
  super(...arguments);
29
40
  _CmSearch_instances.add(this);
30
- /** Accessible name, read by screen readers but not shown. Say what is searched: "Search orders". */
31
- this.label = 'Search';
32
41
  /** Form field name. */
33
42
  this.name = '';
34
43
  /** Current query. Updated on every keystroke. */
35
44
  this.value = '';
36
- /** Example query, shown in text-tertiary. */
37
- this.placeholder = 'Search';
38
45
  /** Shows the filter button at the end of the box. */
39
46
  this.filter = false;
40
- /** Accessible name of the filter button. */
41
- this.filterLabel = 'Filter';
42
47
  /** Number of filters applied; shown on the filter button when above 0. */
43
48
  this.filterCount = 0;
44
49
  /** `default` is 42px (table headers, mobile); `large` is 46px (page-level search). */
@@ -67,11 +72,11 @@ export class CmSearch extends LitElement {
67
72
  aria-label=${this.label} .value=${live(this.value)} placeholder=${this.placeholder || nothing} ?disabled=${this.disabled}
68
73
  @input=${__classPrivateFieldGet(this, _CmSearch_instances, "m", _CmSearch_onInput)} @change=${() => __classPrivateFieldGet(this, _CmSearch_instances, "m", _CmSearch_fire).call(this, 'change')} @keydown=${__classPrivateFieldGet(this, _CmSearch_instances, "m", _CmSearch_onKeyDown)} />
69
74
  ${this.value && !this.disabled
70
- ? html `<button type="button" class="clear" part="clear" aria-label="Clear search" @click=${__classPrivateFieldGet(this, _CmSearch_instances, "m", _CmSearch_clear)}><cm-icon name="close" size="14"></cm-icon></button>`
75
+ ? html `<button type="button" class="clear" part="clear" aria-label=${this.t('clear')} @click=${__classPrivateFieldGet(this, _CmSearch_instances, "m", _CmSearch_clear)}><cm-icon name="close" size="14"></cm-icon></button>`
71
76
  : nothing}
72
77
  ${this.filter
73
78
  ? html `<button type="button" class="filter" part="filter" ?disabled=${this.disabled}
74
- aria-label=${this.filterCount > 0 ? `${this.filterLabel} (${this.filterCount} applied)` : this.filterLabel}
79
+ aria-label=${this.filterCount > 0 ? this.t('filterApplied', { label: this.filterLabel, count: this.filterCount }) : this.filterLabel}
75
80
  @click=${() => __classPrivateFieldGet(this, _CmSearch_instances, "m", _CmSearch_fire).call(this, 'cm-filter')}><cm-icon name="filter" size="18"></cm-icon>${this.filterCount > 0 ? html `<span class="count" aria-hidden="true">${this.filterCount}</span>` : nothing}</button>`
76
81
  : nothing}
77
82
  </div>`;
@@ -97,12 +102,12 @@ _CmSearch_internals = new WeakMap(), _CmSearch_id = new WeakMap(), _CmSearch_def
97
102
  CmSearch.formAssociated = true;
98
103
  CmSearch.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
99
104
  CmSearch.properties = {
100
- label: {},
105
+ label: { string: 'label' },
101
106
  name: { reflect: true },
102
107
  value: {},
103
- placeholder: {},
108
+ placeholder: { string: 'placeholder' },
104
109
  filter: { type: Boolean },
105
- filterLabel: { attribute: 'filter-label' },
110
+ filterLabel: { attribute: 'filter-label', string: 'filter' },
106
111
  filterCount: { type: Number, attribute: 'filter-count' },
107
112
  size: { reflect: true },
108
113
  disabled: { type: Boolean, reflect: true },
@@ -133,7 +138,7 @@ CmSearch.styles = [
133
138
  button:hover { background: var(--cm-bg-hover); }
134
139
  button:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 0; }
135
140
  .count {
136
- position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--cm-radius-full);
141
+ position: absolute; top: -2px; inset-inline-end: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--cm-radius-full);
137
142
  background: var(--cm-action-primary); color: var(--cm-action-primary-text); font-size: 10px; line-height: 16px;
138
143
  }
139
144
  :host([disabled]) .box { background: var(--cm-bg-input-filled); border-color: var(--cm-border-default); }
@@ -1,5 +1,14 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  import './icon.js';
3
+ declare const strings: {
4
+ /** Validation message when `required` and nothing is chosen. */
5
+ required: string;
6
+ };
7
+ declare module '../localize.js' {
8
+ interface CmStrings {
9
+ select: typeof strings;
10
+ }
11
+ }
3
12
  export interface SelectOption {
4
13
  value: string;
5
14
  label: string;
@@ -16,7 +25,7 @@ export interface SelectOption {
16
25
  * @fires change - When the merchant picks a different option.
17
26
  * @fires input - Same moment as `change`.
18
27
  */
19
- export declare class CmSelect extends LitElement {
28
+ export declare class CmSelect extends CmLocalizedElement {
20
29
  #private;
21
30
  static formAssociated: boolean;
22
31
  static shadowRootOptions: {
@@ -104,3 +113,4 @@ declare global {
104
113
  'cm-select': CmSelect;
105
114
  }
106
115
  }
116
+ export {};
@@ -12,7 +12,12 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
12
12
  var _CmSelect_instances, _CmSelect_internals, _CmSelect_id, _CmSelect_defaultValue, _CmSelect_typed, _CmSelect_typedAt, _CmSelect_observer, _CmSelect_readChildren, _CmSelect_enabledIndexes, _CmSelect_show, _CmSelect_hide, _CmSelect_commit, _CmSelect_move, _CmSelect_typeahead, _CmSelect_onKeyDown, _CmSelect_onOutside, _CmSelect_onBoxClick, _CmSelect_focusBox;
13
13
  import { LitElement, html, css, nothing } from 'lit';
14
14
  import { base, define, nextId } from '../base.js';
15
+ import { CmLocalizedElement, defineStrings } from '../localize.js';
15
16
  import './icon.js';
17
+ const strings = defineStrings('select', {
18
+ /** Validation message when `required` and nothing is chosen. */
19
+ required: 'Please select an item in the list.',
20
+ });
16
21
  /**
17
22
  * Dropdown field: a labelled box that opens a list of options and shows the chosen one.
18
23
  * A custom listbox (the WAI-ARIA "select-only combobox" pattern) so the open list can match the
@@ -24,7 +29,7 @@ import './icon.js';
24
29
  * @fires change - When the merchant picks a different option.
25
30
  * @fires input - Same moment as `change`.
26
31
  */
27
- export class CmSelect extends LitElement {
32
+ export class CmSelect extends CmLocalizedElement {
28
33
  constructor() {
29
34
  super(...arguments);
30
35
  _CmSelect_instances.add(this);
@@ -186,7 +191,7 @@ export class CmSelect extends LitElement {
186
191
  if (this.error)
187
192
  __classPrivateFieldGet(this, _CmSelect_internals, "f").setValidity({ customError: true }, this.error, box);
188
193
  else if (this.required && !this.value)
189
- __classPrivateFieldGet(this, _CmSelect_internals, "f").setValidity({ valueMissing: true }, 'Please select an item in the list.', box);
194
+ __classPrivateFieldGet(this, _CmSelect_internals, "f").setValidity({ valueMissing: true }, this.t('required'), box);
190
195
  else
191
196
  __classPrivateFieldGet(this, _CmSelect_internals, "f").setValidity({});
192
197
  if ((changed.has('_active') || changed.has('open')) && this.open) {
@@ -300,7 +305,7 @@ CmSelect.styles = [
300
305
  :host { display: block; position: relative; }
301
306
  .field { display: flex; flex-direction: column; gap: var(--cm-space-10); }
302
307
  .label { font-size: var(--cm-type-label-size); color: var(--cm-text-default); cursor: default; }
303
- .req { color: var(--cm-text-critical); margin-left: 2px; }
308
+ .req { color: var(--cm-text-critical); margin-inline-start: 2px; }
304
309
  .wrap { position: relative; }
305
310
  .box {
306
311
  display: flex; align-items: center; gap: var(--cm-space-10); width: 100%; height: 42px; padding: 0 var(--cm-space-10);
@@ -315,7 +320,7 @@ CmSelect.styles = [
315
320
  :host([error]:not([error=''])) .box { border-color: var(--cm-border-critical); }
316
321
  :host([disabled]) .box { background: var(--cm-bg-input-filled); color: var(--cm-text-secondary); border-color: var(--cm-border-default); cursor: not-allowed; }
317
322
  [role='listbox'] {
318
- position: absolute; z-index: 20; top: calc(100% + var(--cm-space-10)); left: 0; right: 0;
323
+ position: absolute; z-index: 20; top: calc(100% + var(--cm-space-10)); inset-inline: 0;
319
324
  max-height: 242px; overflow-y: auto; margin: 0; padding: var(--cm-space-10) 0; list-style: none;
320
325
  background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-default);
321
326
  border-radius: var(--cm-radius-md); box-shadow: var(--cm-shadow-100);