@commmerce/ui 1.0.0-rc.4 → 1.0.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 (103) hide show
  1. package/LICENSE.md +152 -17
  2. package/README.md +2 -3
  3. package/THIRD_PARTY_NOTICES.txt +175 -0
  4. package/dist/base.d.ts +5 -0
  5. package/dist/base.js +10 -0
  6. package/dist/calendar.d.ts +95 -0
  7. package/dist/calendar.js +280 -0
  8. package/dist/cdn.js +721 -477
  9. package/dist/components/accordion.js +2 -2
  10. package/dist/components/action-bar.d.ts +12 -2
  11. package/dist/components/action-bar.js +10 -5
  12. package/dist/components/action-menu.d.ts +17 -4
  13. package/dist/components/action-menu.js +8 -5
  14. package/dist/components/app-card.d.ts +24 -2
  15. package/dist/components/app-card.js +25 -10
  16. package/dist/components/banner.d.ts +2 -2
  17. package/dist/components/banner.js +4 -3
  18. package/dist/components/bottom-navigation.d.ts +16 -4
  19. package/dist/components/bottom-navigation.js +10 -7
  20. package/dist/components/bottom-sheet.d.ts +4 -1
  21. package/dist/components/bottom-sheet.js +2 -2
  22. package/dist/components/checkbox.d.ts +12 -2
  23. package/dist/components/checkbox.js +7 -2
  24. package/dist/components/combobox.d.ts +186 -0
  25. package/dist/components/combobox.js +521 -0
  26. package/dist/components/comment.d.ts +27 -9
  27. package/dist/components/comment.js +14 -13
  28. package/dist/components/data-table.d.ts +14 -2
  29. package/dist/components/data-table.js +31 -10
  30. package/dist/components/date-picker.d.ts +179 -0
  31. package/dist/components/date-picker.js +336 -0
  32. package/dist/components/date-range-picker.d.ts +251 -0
  33. package/dist/components/date-range-picker.js +484 -0
  34. package/dist/components/file-upload.d.ts +30 -4
  35. package/dist/components/file-upload.js +37 -17
  36. package/dist/components/filter-panel.d.ts +29 -6
  37. package/dist/components/filter-panel.js +16 -14
  38. package/dist/components/flash-offer-bar.d.ts +18 -4
  39. package/dist/components/flash-offer-bar.js +13 -8
  40. package/dist/components/header-bar.d.ts +20 -4
  41. package/dist/components/header-bar.js +20 -13
  42. package/dist/components/icon.d.ts +7 -0
  43. package/dist/components/icon.js +9 -1
  44. package/dist/components/link-tabs.d.ts +16 -4
  45. package/dist/components/link-tabs.js +10 -7
  46. package/dist/components/mobile-menu.d.ts +19 -4
  47. package/dist/components/mobile-menu.js +16 -10
  48. package/dist/components/modal.d.ts +4 -1
  49. package/dist/components/nested-list.d.ts +22 -3
  50. package/dist/components/nested-list.js +25 -12
  51. package/dist/components/notification-panel.d.ts +26 -5
  52. package/dist/components/notification-panel.js +17 -11
  53. package/dist/components/option-group.d.ts +12 -2
  54. package/dist/components/option-group.js +13 -7
  55. package/dist/components/page-header.d.ts +18 -2
  56. package/dist/components/page-header.js +23 -10
  57. package/dist/components/pagination.d.ts +27 -4
  58. package/dist/components/pagination.js +28 -16
  59. package/dist/components/progress-bar.d.ts +12 -2
  60. package/dist/components/progress-bar.js +9 -4
  61. package/dist/components/radio.d.ts +12 -1
  62. package/dist/components/radio.js +12 -6
  63. package/dist/components/report-tile.d.ts +12 -1
  64. package/dist/components/report-tile.js +9 -4
  65. package/dist/components/resource-list.d.ts +36 -5
  66. package/dist/components/resource-list.js +50 -23
  67. package/dist/components/save-bar.d.ts +23 -6
  68. package/dist/components/save-bar.js +14 -12
  69. package/dist/components/search.d.ts +28 -7
  70. package/dist/components/search.js +18 -13
  71. package/dist/components/select.d.ts +12 -2
  72. package/dist/components/select.js +9 -4
  73. package/dist/components/side-navigation.d.ts +16 -4
  74. package/dist/components/side-navigation.js +16 -12
  75. package/dist/components/side-panel.d.ts +5 -2
  76. package/dist/components/side-panel.js +5 -3
  77. package/dist/components/skeleton-display.d.ts +6 -4
  78. package/dist/components/skeleton-display.js +4 -5
  79. package/dist/components/smart-tip.d.ts +25 -6
  80. package/dist/components/smart-tip.js +18 -12
  81. package/dist/components/spinner.d.ts +4 -3
  82. package/dist/components/spinner.js +5 -6
  83. package/dist/components/status-tabs.d.ts +12 -2
  84. package/dist/components/status-tabs.js +14 -8
  85. package/dist/components/table-header.d.ts +15 -2
  86. package/dist/components/table-header.js +13 -5
  87. package/dist/components/tag.d.ts +12 -2
  88. package/dist/components/tag.js +9 -4
  89. package/dist/components/text-field.d.ts +12 -2
  90. package/dist/components/text-field.js +9 -4
  91. package/dist/components/thumbnail.d.ts +12 -2
  92. package/dist/components/thumbnail.js +8 -3
  93. package/dist/components/toast.d.ts +14 -3
  94. package/dist/components/toast.js +20 -9
  95. package/dist/components/toggle.js +2 -0
  96. package/dist/custom-elements.json +16477 -6434
  97. package/dist/index.d.ts +7 -1
  98. package/dist/index.js +5 -1
  99. package/dist/localize.d.ts +130 -0
  100. package/dist/localize.js +232 -0
  101. package/dist/overlay.d.ts +8 -4
  102. package/dist/overlay.js +9 -12
  103. package/package.json +5 -4
@@ -1,6 +1,15 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  import { type NavItem } from './nav-item.js';
3
3
  import './icon.js';
4
+ declare const strings: {
5
+ /** Accessible name of the navigation landmark. */
6
+ label: string;
7
+ };
8
+ declare module '../localize.js' {
9
+ interface CmStrings {
10
+ sideNavigation: typeof strings;
11
+ }
12
+ }
4
13
  /**
5
14
  * The admin's main menu: a black rounded panel down the left of the page, with an icon and a label per
6
15
  * destination and sections that open to show their sub-items. For Commmerce products only, not for apps:
@@ -14,13 +23,15 @@ import './icon.js';
14
23
  * @fires cm-navigate - When an item is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app instead of following the link.
15
24
  * @fires cm-expand - When a section opens or closes. `detail: { item, expanded }`.
16
25
  */
17
- export declare class CmSideNavigation extends LitElement {
26
+ export declare class CmSideNavigation extends CmLocalizedElement {
18
27
  #private;
19
28
  static properties: {
20
29
  items: {
21
30
  type: ArrayConstructor;
22
31
  };
23
- label: {};
32
+ label: {
33
+ string: string;
34
+ };
24
35
  _slotted: {
25
36
  state: boolean;
26
37
  };
@@ -30,7 +41,7 @@ export declare class CmSideNavigation extends LitElement {
30
41
  };
31
42
  /** Items as data. Used instead of `cm-nav-item` children when set. */
32
43
  items: NavItem[];
33
- /** Accessible name of the navigation landmark. */
44
+ /** Accessible name of the navigation landmark. Default: the built-in string `label` ("Main"). */
34
45
  label: string;
35
46
  _slotted: NavItem[];
36
47
  _open: Set<string>;
@@ -49,3 +60,4 @@ declare global {
49
60
  'cm-side-navigation': CmSideNavigation;
50
61
  }
51
62
  }
63
+ export {};
@@ -10,10 +10,15 @@ 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 _CmSideNavigation_instances, _CmSideNavigation_seen, _CmSideNavigation_observer, _CmSideNavigation_id, _CmSideNavigation_read, _CmSideNavigation_key, _CmSideNavigation_choose, _CmSideNavigation_focusables, _CmSideNavigation_onKeyDown, _CmSideNavigation_flatten, _CmSideNavigation_link;
13
- import { LitElement, html, css, nothing } from 'lit';
14
- import { base, define, nextId } from '../base.js';
13
+ import { html, css, nothing } from 'lit';
14
+ import { base, define, nextId, logicalKey } from '../base.js';
15
+ import { CmLocalizedElement, defineStrings } from '../localize.js';
15
16
  import { readNavItems, watchNavItems, hasCurrent, fireNavigate, navValue } from './nav-item.js';
16
17
  import './icon.js';
18
+ const strings = defineStrings('sideNavigation', {
19
+ /** Accessible name of the navigation landmark. */
20
+ label: 'Main',
21
+ });
17
22
  /**
18
23
  * The admin's main menu: a black rounded panel down the left of the page, with an icon and a label per
19
24
  * destination and sections that open to show their sub-items. For Commmerce products only, not for apps:
@@ -27,14 +32,12 @@ import './icon.js';
27
32
  * @fires cm-navigate - When an item is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app instead of following the link.
28
33
  * @fires cm-expand - When a section opens or closes. `detail: { item, expanded }`.
29
34
  */
30
- export class CmSideNavigation extends LitElement {
35
+ export class CmSideNavigation extends CmLocalizedElement {
31
36
  constructor() {
32
37
  super(...arguments);
33
38
  _CmSideNavigation_instances.add(this);
34
39
  /** Items as data. Used instead of `cm-nav-item` children when set. */
35
40
  this.items = [];
36
- /** Accessible name of the navigation landmark. */
37
- this.label = 'Main';
38
41
  this._slotted = [];
39
42
  this._open = new Set();
40
43
  _CmSideNavigation_seen.set(this, new Set());
@@ -79,7 +82,7 @@ export class CmSideNavigation extends LitElement {
79
82
  }
80
83
  render() {
81
84
  return html `
82
- <nav part="nav" aria-label=${this.label || 'Main'} @keydown=${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_onKeyDown)}>
85
+ <nav part="nav" aria-label=${this.label || this.t('label')} @keydown=${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_onKeyDown)}>
83
86
  <slot name="header"></slot>
84
87
  <ul part="list">
85
88
  ${this.navItems.map((it, i) => {
@@ -117,6 +120,7 @@ _CmSideNavigation_seen = new WeakMap(), _CmSideNavigation_observer = new WeakMap
117
120
  const all = __classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_focusables).call(this);
118
121
  const i = all.indexOf(t);
119
122
  const idx = Number(t.dataset.index);
123
+ const key = logicalKey(e, this);
120
124
  let next;
121
125
  if (e.key === 'ArrowDown')
122
126
  next = all[(i + 1) % all.length];
@@ -126,12 +130,12 @@ _CmSideNavigation_seen = new WeakMap(), _CmSideNavigation_observer = new WeakMap
126
130
  next = all[0];
127
131
  else if (e.key === 'End')
128
132
  next = all[all.length - 1];
129
- else if (e.key === 'ArrowRight' && t.classList.contains('parent')) {
133
+ else if (key === 'ArrowRight' && t.classList.contains('parent')) {
130
134
  this.toggle(idx, true);
131
135
  e.preventDefault();
132
136
  return;
133
137
  }
134
- else if (e.key === 'ArrowLeft') {
138
+ else if (key === 'ArrowLeft') {
135
139
  if (t.classList.contains('parent'))
136
140
  this.toggle(idx, false);
137
141
  else if (t.dataset.parent)
@@ -157,7 +161,7 @@ _CmSideNavigation_seen = new WeakMap(), _CmSideNavigation_observer = new WeakMap
157
161
  };
158
162
  CmSideNavigation.properties = {
159
163
  items: { type: Array },
160
- label: {},
164
+ label: { string: 'label' },
161
165
  _slotted: { state: true },
162
166
  _open: { state: true },
163
167
  };
@@ -171,7 +175,7 @@ CmSideNavigation.styles = [
171
175
  }
172
176
  ul { list-style: none; margin: 0; padding: 0; }
173
177
  .item {
174
- display: flex; align-items: center; gap: 8px; width: calc(100% - 16px); min-height: 40px; margin: 0 8px; padding: 0 10px 0 12px;
178
+ display: flex; align-items: center; gap: 8px; width: calc(100% - 16px); min-height: 40px; margin: 0 8px; padding-block: 0; padding-inline: 12px 10px;
175
179
  font: inherit; color: inherit; text-align: start; text-decoration: none; background: none; border: 0; border-radius: 8px; cursor: pointer;
176
180
  }
177
181
  .item:hover { color: var(--cm-text-on-dark); background: var(--cm-nav-active); }
@@ -186,8 +190,8 @@ CmSideNavigation.styles = [
186
190
  letter-spacing: var(--cm-tracking-caps); text-transform: uppercase; color: var(--cm-text-on-dark); background: var(--cm-nav-badge);
187
191
  }
188
192
  .sub { padding: 2px 0 6px; }
189
- .sub .item { min-height: 36px; padding-left: 40px; font-size: 14px; }
190
- .sub .item.deep { padding-left: 56px; }
193
+ .sub .item { min-height: 36px; padding-inline-start: 40px; font-size: 14px; }
194
+ .sub .item.deep { padding-inline-start: 56px; }
191
195
  @media (prefers-reduced-motion: reduce) { .chev { transition: none; } }
192
196
  `,
193
197
  ];
@@ -1,6 +1,6 @@
1
1
  import { CmOverlay } from '../overlay.js';
2
2
  /**
3
- * A panel that slides over the right edge of the page to show the details of one item (an enquiry, an
3
+ * A panel that slides over the right edge of the page (the left edge in right-to-left pages) to show the details of one item (an enquiry, an
4
4
  * order, a customer) without leaving the list. A black header with the title and a close button, the
5
5
  * content, and an optional footer. On phones it becomes a card inset 16px from the screen edges.
6
6
  *
@@ -26,10 +26,13 @@ export declare class CmSidePanel extends CmOverlay {
26
26
  type: BooleanConstructor;
27
27
  reflect: boolean;
28
28
  };
29
- heading: {};
29
+ heading: {
30
+ string: string;
31
+ };
30
32
  label: {};
31
33
  closeLabel: {
32
34
  attribute: string;
35
+ string: string;
33
36
  };
34
37
  };
35
38
  /** Width on larger screens: `small` (380px), `medium` (450px, default) or `large` (720px). */
@@ -8,7 +8,7 @@ import { html, css } from 'lit';
8
8
  import { define } from '../base.js';
9
9
  import { CmOverlay } from '../overlay.js';
10
10
  /**
11
- * A panel that slides over the right edge of the page to show the details of one item (an enquiry, an
11
+ * A panel that slides over the right edge of the page (the left edge in right-to-left pages) to show the details of one item (an enquiry, an
12
12
  * order, a customer) without leaving the list. A black header with the title and a close button, the
13
13
  * content, and an optional footer. On phones it becomes a card inset 16px from the screen edges.
14
14
  *
@@ -55,7 +55,7 @@ CmSidePanel.styles = [
55
55
  ...CmOverlay.overlayStyles,
56
56
  css `
57
57
  dialog {
58
- position: fixed; inset: 0 0 0 auto; height: 100dvh; width: min(var(--cm-side-panel-width, 450px), 100vw);
58
+ position: fixed; inset-block: 0; inset-inline: auto 0; height: 100dvh; width: min(var(--cm-side-panel-width, 450px), 100vw);
59
59
  }
60
60
  :host([size='small']) dialog { --cm-side-panel-width: 380px; }
61
61
  :host([size='large']) dialog { --cm-side-panel-width: 720px; }
@@ -63,7 +63,9 @@ CmSidePanel.styles = [
63
63
  @media (prefers-reduced-motion: no-preference) {
64
64
  dialog[open] .panel { animation: cm-side-in 200ms ease-out; }
65
65
  }
66
- @keyframes cm-side-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
66
+ /* Slides in from the end edge: from the right, or from the left in right-to-left pages. */
67
+ dialog:dir(rtl) { --_cm-side-from: -24px; }
68
+ @keyframes cm-side-in { from { transform: translateX(var(--_cm-side-from, 24px)); opacity: 0; } to { transform: none; opacity: 1; } }
67
69
  @media (max-width: 599px) {
68
70
  dialog { inset: 16px; width: auto; height: auto; }
69
71
  .panel { border-radius: var(--cm-radius-sm); }
@@ -1,11 +1,11 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  /**
3
3
  * A whole-page loading placeholder: a page header bar and grey cards laid out like a detail page.
4
4
  * Show it while the first data for a page loads, then replace it with the page. Announces "Loading"
5
5
  * once to screen readers.
6
6
  * @element cm-skeleton-display
7
7
  */
8
- export declare class CmSkeletonDisplay extends LitElement {
8
+ export declare class CmSkeletonDisplay extends CmLocalizedElement {
9
9
  static properties: {
10
10
  layout: {
11
11
  reflect: boolean;
@@ -14,13 +14,15 @@ export declare class CmSkeletonDisplay extends LitElement {
14
14
  type: BooleanConstructor;
15
15
  reflect: boolean;
16
16
  };
17
- label: {};
17
+ label: {
18
+ string: string;
19
+ };
18
20
  };
19
21
  /** `two-column` (main cards plus a side column, as on detail pages) or `one-column` (lists and settings). */
20
22
  layout: 'two-column' | 'one-column';
21
23
  /** Adds a 250px side-navigation placeholder on the left. Admin chrome: for Commmerce products only, not for apps. */
22
24
  navigation: boolean;
23
- /** What screen readers announce while it shows. */
25
+ /** What screen readers announce while it shows. Default: the built-in string `loading` ("Loading"). */
24
26
  label: string;
25
27
  static styles: import("lit").CSSResult[];
26
28
  render(): import("lit-html").TemplateResult<1>;
@@ -1,5 +1,6 @@
1
- import { LitElement, html, css, nothing } from 'lit';
1
+ import { html, css, nothing } from 'lit';
2
2
  import { base, define } from '../base.js';
3
+ import { CmLocalizedElement } from '../localize.js';
3
4
  // Card heights measured from the Figma "Skeleton Display" board (main column 910px, side column 390px).
4
5
  const MAIN = [472, 90, 90, 251];
5
6
  const SIDE = [94, 266, 134, 191, 138];
@@ -9,15 +10,13 @@ const SIDE = [94, 266, 134, 191, 138];
9
10
  * once to screen readers.
10
11
  * @element cm-skeleton-display
11
12
  */
12
- export class CmSkeletonDisplay extends LitElement {
13
+ export class CmSkeletonDisplay extends CmLocalizedElement {
13
14
  constructor() {
14
15
  super(...arguments);
15
16
  /** `two-column` (main cards plus a side column, as on detail pages) or `one-column` (lists and settings). */
16
17
  this.layout = 'two-column';
17
18
  /** Adds a 250px side-navigation placeholder on the left. Admin chrome: for Commmerce products only, not for apps. */
18
19
  this.navigation = false;
19
- /** What screen readers announce while it shows. */
20
- this.label = 'Loading';
21
20
  }
22
21
  render() {
23
22
  const bones = (hs) => hs.map((h) => html `<span class="bone" style="height:${h}px"></span>`);
@@ -37,7 +36,7 @@ export class CmSkeletonDisplay extends LitElement {
37
36
  CmSkeletonDisplay.properties = {
38
37
  layout: { reflect: true },
39
38
  navigation: { type: Boolean, reflect: true },
40
- label: {},
39
+ label: { string: 'loading' },
41
40
  };
42
41
  CmSkeletonDisplay.styles = [
43
42
  base,
@@ -1,13 +1,28 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  import './icon.js';
3
3
  import './button.js';
4
+ declare const tipStrings: {
5
+ /** Read after the tip when `target="_blank"`. */
6
+ newTab: string;
7
+ };
8
+ declare const strings: {
9
+ /** Title above the tips, and the tour banner's button. */
10
+ heading: string;
11
+ tourAction: string;
12
+ };
13
+ declare module '../localize.js' {
14
+ interface CmStrings {
15
+ smartTip: typeof tipStrings;
16
+ smartTips: typeof strings;
17
+ }
18
+ }
4
19
  /**
5
20
  * A short, linked tip that points merchants to a guide or setting ("Importing and exporting products").
6
21
  * The whole card is one link. Group tips in `cm-smart-tips`.
7
22
  * @element cm-smart-tip
8
23
  * @slot - One or two lines that say what the merchant gets from the guide.
9
24
  */
10
- export declare class CmSmartTip extends LitElement {
25
+ export declare class CmSmartTip extends CmLocalizedElement {
11
26
  static properties: {
12
27
  heading: {};
13
28
  href: {};
@@ -29,25 +44,28 @@ export declare class CmSmartTip extends LitElement {
29
44
  * @slot - `cm-smart-tip` elements.
30
45
  * @fires cm-tour - When the tour banner's button is pressed.
31
46
  */
32
- export declare class CmSmartTips extends LitElement {
47
+ export declare class CmSmartTips extends CmLocalizedElement {
33
48
  static properties: {
34
- heading: {};
49
+ heading: {
50
+ string: string;
51
+ };
35
52
  tourHeading: {
36
53
  attribute: string;
37
54
  };
38
55
  tourAction: {
39
56
  attribute: string;
57
+ string: string;
40
58
  };
41
59
  headingLevel: {
42
60
  type: NumberConstructor;
43
61
  attribute: string;
44
62
  };
45
63
  };
46
- /** Title above the tips, shown in capitals. */
64
+ /** Title above the tips, shown in capitals. Default: the built-in string `heading` ("Smart tips"). */
47
65
  heading: string;
48
66
  /** Text of the dark tour banner ("Take a tour of Commmerce"). Leave empty for no banner. */
49
67
  tourHeading: string;
50
- /** Label of the tour banner's button. */
68
+ /** Label of the tour banner's button. Default: the built-in string `tourAction` ("Start"). */
51
69
  tourAction: string;
52
70
  /** Heading level of the title. Default 2. */
53
71
  headingLevel: 2 | 3 | 4 | 5 | 6;
@@ -60,3 +78,4 @@ declare global {
60
78
  'cm-smart-tips': CmSmartTips;
61
79
  }
62
80
  }
81
+ export {};
@@ -1,14 +1,24 @@
1
- import { LitElement, html, css, nothing } from 'lit';
1
+ import { html, css, nothing } from 'lit';
2
2
  import { base, define } from '../base.js';
3
+ import { CmLocalizedElement, defineStrings } from '../localize.js';
3
4
  import './icon.js';
4
5
  import './button.js';
6
+ const tipStrings = defineStrings('smartTip', {
7
+ /** Read after the tip when `target="_blank"`. */
8
+ newTab: '(opens in a new tab)',
9
+ });
10
+ const strings = defineStrings('smartTips', {
11
+ /** Title above the tips, and the tour banner's button. */
12
+ heading: 'Smart tips',
13
+ tourAction: 'Start',
14
+ });
5
15
  /**
6
16
  * A short, linked tip that points merchants to a guide or setting ("Importing and exporting products").
7
17
  * The whole card is one link. Group tips in `cm-smart-tips`.
8
18
  * @element cm-smart-tip
9
19
  * @slot - One or two lines that say what the merchant gets from the guide.
10
20
  */
11
- export class CmSmartTip extends LitElement {
21
+ export class CmSmartTip extends CmLocalizedElement {
12
22
  constructor() {
13
23
  super(...arguments);
14
24
  /** Tip title, at most two short lines. */
@@ -29,7 +39,7 @@ export class CmSmartTip extends LitElement {
29
39
  <span class="text">
30
40
  <span class="title" part="heading">${this.heading}</span>
31
41
  <span class="desc" part="description"><slot></slot></span>
32
- ${blank ? html `<span style="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)">(opens in a new tab)</span>` : nothing}
42
+ ${blank ? html `<span style="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)">${this.t('newTab')}</span>` : nothing}
33
43
  </span>
34
44
  <span class="go" aria-hidden="true"><cm-icon name="arrow-up-right" size="16"></cm-icon></span>
35
45
  </a>`;
@@ -45,7 +55,7 @@ CmSmartTip.styles = [
45
55
  css `
46
56
  :host { display: block; }
47
57
  a {
48
- display: flex; align-items: flex-start; gap: var(--cm-space-10); padding: var(--cm-space-20) var(--cm-space-10) var(--cm-space-20) var(--cm-space-10);
58
+ display: flex; align-items: flex-start; gap: var(--cm-space-10); padding: var(--cm-space-20) var(--cm-space-10);
49
59
  min-height: 104px; background: var(--cm-bg-surface); color: var(--cm-text-default); text-decoration: none;
50
60
  border: var(--cm-border-1) solid var(--cm-border-default); border-radius: var(--cm-radius-md);
51
61
  }
@@ -68,15 +78,11 @@ define('cm-smart-tip', CmSmartTip);
68
78
  * @slot - `cm-smart-tip` elements.
69
79
  * @fires cm-tour - When the tour banner's button is pressed.
70
80
  */
71
- export class CmSmartTips extends LitElement {
81
+ export class CmSmartTips extends CmLocalizedElement {
72
82
  constructor() {
73
83
  super(...arguments);
74
- /** Title above the tips, shown in capitals. */
75
- this.heading = 'Smart tips';
76
84
  /** Text of the dark tour banner ("Take a tour of Commmerce"). Leave empty for no banner. */
77
85
  this.tourHeading = '';
78
- /** Label of the tour banner's button. */
79
- this.tourAction = 'Start';
80
86
  /** Heading level of the title. Default 2. */
81
87
  this.headingLevel = 2;
82
88
  }
@@ -98,9 +104,9 @@ export class CmSmartTips extends LitElement {
98
104
  }
99
105
  }
100
106
  CmSmartTips.properties = {
101
- heading: {},
107
+ heading: { string: 'heading' },
102
108
  tourHeading: { attribute: 'tour-heading' },
103
- tourAction: { attribute: 'tour-action' },
109
+ tourAction: { attribute: 'tour-action', string: 'tourAction' },
104
110
  headingLevel: { type: Number, attribute: 'heading-level' },
105
111
  };
106
112
  CmSmartTips.styles = [
@@ -109,7 +115,7 @@ CmSmartTips.styles = [
109
115
  :host { display: block; }
110
116
  .card { display: flex; flex-direction: column; gap: var(--cm-space-10); }
111
117
  .tour {
112
- display: flex; align-items: center; gap: var(--cm-space-10); min-height: 60px; padding: var(--cm-space-12) 14px var(--cm-space-12) var(--cm-space-20);
118
+ display: flex; align-items: center; gap: var(--cm-space-10); min-height: 60px; padding-block: var(--cm-space-12); padding-inline: var(--cm-space-20) 14px;
113
119
  border-radius: var(--cm-radius-md); background: var(--cm-bg-panel-header); color: var(--cm-text-on-dark);
114
120
  }
115
121
  .tour-icon {
@@ -1,21 +1,22 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  /**
3
3
  * Shows that something is loading when the wait is short or its length unknown. Announced to screen readers
4
4
  * through a status role with a text label.
5
5
  * @element cm-spinner
6
6
  */
7
- export declare class CmSpinner extends LitElement {
7
+ export declare class CmSpinner extends CmLocalizedElement {
8
8
  static properties: {
9
9
  size: {
10
10
  reflect: boolean;
11
11
  };
12
12
  accessibleLabel: {
13
13
  attribute: string;
14
+ string: string;
14
15
  };
15
16
  };
16
17
  /** `small` (20px) for inline use in buttons, rows and fields; `large` (44px) for a section or page. */
17
18
  size: 'small' | 'large';
18
- /** What screen readers announce. Name what is loading when it helps: "Loading orders". */
19
+ /** What screen readers announce. Name what is loading when it helps: "Loading orders". Default: the built-in string `loading` ("Loading"). */
19
20
  accessibleLabel: string;
20
21
  static styles: import("lit").CSSResult[];
21
22
  render(): import("lit-html").TemplateResult<1>;
@@ -1,17 +1,16 @@
1
- import { LitElement, html, css } from 'lit';
1
+ import { html, css } from 'lit';
2
2
  import { base, define } from '../base.js';
3
+ import { CmLocalizedElement } from '../localize.js';
3
4
  /**
4
5
  * Shows that something is loading when the wait is short or its length unknown. Announced to screen readers
5
6
  * through a status role with a text label.
6
7
  * @element cm-spinner
7
8
  */
8
- export class CmSpinner extends LitElement {
9
+ export class CmSpinner extends CmLocalizedElement {
9
10
  constructor() {
10
11
  super(...arguments);
11
12
  /** `small` (20px) for inline use in buttons, rows and fields; `large` (44px) for a section or page. */
12
13
  this.size = 'large';
13
- /** What screen readers announce. Name what is loading when it helps: "Loading orders". */
14
- this.accessibleLabel = 'Loading';
15
14
  }
16
15
  render() {
17
16
  const sw = this.size === 'small' ? 2.5 : 3;
@@ -20,13 +19,13 @@ export class CmSpinner extends LitElement {
20
19
  <circle class="track" cx="12" cy="12" r="10" fill="none" stroke-width=${sw}></circle>
21
20
  <path class="arc" d="M12 2a10 10 0 0 1 10 10" fill="none" stroke-width=${sw} stroke-linecap="round"></path>
22
21
  </svg>
23
- <span class="vh">${this.accessibleLabel || 'Loading'}</span>
22
+ <span class="vh">${this.accessibleLabel || this.t('loading')}</span>
24
23
  </span>`;
25
24
  }
26
25
  }
27
26
  CmSpinner.properties = {
28
27
  size: { reflect: true },
29
- accessibleLabel: { attribute: 'accessible-label' },
28
+ accessibleLabel: { attribute: 'accessible-label', string: 'loading' },
30
29
  };
31
30
  CmSpinner.styles = [
32
31
  base,
@@ -1,4 +1,4 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  /** One status tab. */
3
3
  export interface StatusTab {
4
4
  value: string;
@@ -7,6 +7,15 @@ export interface StatusTab {
7
7
  count?: number;
8
8
  disabled?: boolean;
9
9
  }
10
+ declare const strings: {
11
+ /** Accessible name of the tab list when the element has no `aria-label`. */
12
+ label: string;
13
+ };
14
+ declare module '../localize.js' {
15
+ interface CmStrings {
16
+ statusTabs: typeof strings;
17
+ }
18
+ }
10
19
  /**
11
20
  * A row of statuses that filters the list under it, such as All, Unprocessed, Processing, Fulfilled.
12
21
  * The chosen status is black and underlined; the others are grey. Each label can carry a count.
@@ -18,7 +27,7 @@ export interface StatusTab {
18
27
  * @slot - `<option value="…" count="23">Label</option>` elements. `disabled` and `selected` are honoured.
19
28
  * @fires change - When the merchant picks another status. Read `value`.
20
29
  */
21
- export declare class CmStatusTabs extends LitElement {
30
+ export declare class CmStatusTabs extends CmLocalizedElement {
22
31
  #private;
23
32
  static properties: {
24
33
  value: {
@@ -63,3 +72,4 @@ declare global {
63
72
  'cm-status-tabs': CmStatusTabs;
64
73
  }
65
74
  }
75
+ export {};
@@ -4,8 +4,13 @@ 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 _CmStatusTabs_instances, _CmStatusTabs_observer, _CmStatusTabs_readChildren, _CmStatusTabs_current, _CmStatusTabs_select, _CmStatusTabs_onKeyDown;
7
- import { LitElement, html, css, nothing } from 'lit';
8
- import { base, define } from '../base.js';
7
+ import { html, css, nothing } from 'lit';
8
+ import { base, define, logicalKey } from '../base.js';
9
+ import { CmLocalizedElement, defineStrings } from '../localize.js';
10
+ const strings = defineStrings('statusTabs', {
11
+ /** Accessible name of the tab list when the element has no `aria-label`. */
12
+ label: 'Status',
13
+ });
9
14
  /**
10
15
  * A row of statuses that filters the list under it, such as All, Unprocessed, Processing, Fulfilled.
11
16
  * The chosen status is black and underlined; the others are grey. Each label can carry a count.
@@ -17,7 +22,7 @@ import { base, define } from '../base.js';
17
22
  * @slot - `<option value="…" count="23">Label</option>` elements. `disabled` and `selected` are honoured.
18
23
  * @fires change - When the merchant picks another status. Read `value`.
19
24
  */
20
- export class CmStatusTabs extends LitElement {
25
+ export class CmStatusTabs extends CmLocalizedElement {
21
26
  constructor() {
22
27
  super(...arguments);
23
28
  _CmStatusTabs_instances.add(this);
@@ -67,11 +72,11 @@ export class CmStatusTabs extends LitElement {
67
72
  const items = this.items;
68
73
  const cur = __classPrivateFieldGet(this, _CmStatusTabs_instances, "m", _CmStatusTabs_current).call(this, items);
69
74
  return html `
70
- <div class="tabs" part="tabs" role="tablist" aria-label=${this.getAttribute('aria-label') || 'Status'}>
75
+ <div class="tabs" part="tabs" role="tablist" aria-label=${this.getAttribute('aria-label') || this.t('label')}>
71
76
  ${items.map((t, i) => html `<button type="button" role="tab" part="tab" aria-selected=${i === cur ? 'true' : 'false'}
72
77
  tabindex=${i === cur ? '0' : '-1'} ?disabled=${!!t.disabled}
73
78
  @click=${() => __classPrivateFieldGet(this, _CmStatusTabs_instances, "m", _CmStatusTabs_select).call(this, i)} @keydown=${(e) => __classPrivateFieldGet(this, _CmStatusTabs_instances, "m", _CmStatusTabs_onKeyDown).call(this, e, i)}>${t.label}${t.count !== undefined && !Number.isNaN(t.count)
74
- ? html ` <span class="count">(</span> ${t.count.toLocaleString()} <span class="count">)</span>`
79
+ ? html ` <span class="count">(</span> ${this.formatNumber(t.count)} <span class="count">)</span>`
75
80
  : nothing}</button>`)}
76
81
  </div>
77
82
  <slot></slot>
@@ -103,12 +108,13 @@ _CmStatusTabs_observer = new WeakMap(), _CmStatusTabs_instances = new WeakSet(),
103
108
  this.value = t.value;
104
109
  this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
105
110
  }, _CmStatusTabs_onKeyDown = function _CmStatusTabs_onKeyDown(e, i) {
111
+ const key = logicalKey(e, this);
106
112
  const en = this.items.flatMap((t, j) => (t.disabled ? [] : [j]));
107
113
  const pos = en.indexOf(i);
108
114
  let next;
109
- if (e.key === 'ArrowRight')
115
+ if (key === 'ArrowRight')
110
116
  next = en[(pos + 1) % en.length];
111
- else if (e.key === 'ArrowLeft')
117
+ else if (key === 'ArrowLeft')
112
118
  next = en[(pos - 1 + en.length) % en.length];
113
119
  else if (e.key === 'Home')
114
120
  next = en[0];
@@ -140,7 +146,7 @@ CmStatusTabs.styles = [
140
146
  background: none; border: 0; cursor: pointer;
141
147
  }
142
148
  button::after {
143
- content: ''; position: absolute; left: 0; right: 0; bottom: 4px; height: 2px; border-radius: 1px; background: transparent;
149
+ content: ''; position: absolute; inset-inline: 0; bottom: 4px; height: 2px; border-radius: 1px; background: transparent;
144
150
  }
145
151
  button:hover:not(:disabled) { color: var(--cm-text-default); }
146
152
  button[aria-selected='true'] { color: var(--cm-text-default); }
@@ -1,5 +1,17 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
2
  import './icon.js';
3
+ declare const strings: {
4
+ /** Accessible name of the select-all box. */
5
+ selectAll: string;
6
+ /** Read after a sortable column's name (outside a table). `{direction}` is the common `ascending` or `descending`. */
7
+ sorted: string;
8
+ sortable: string;
9
+ };
10
+ declare module '../localize.js' {
11
+ interface CmStrings {
12
+ tableHeader: typeof strings;
13
+ }
14
+ }
3
15
  /** One column of a table header. */
4
16
  export interface TableColumn {
5
17
  /** Identifies the column in `cm-sort`. Defaults to the label. */
@@ -25,7 +37,7 @@ export interface TableColumn {
25
37
  * @fires cm-select-all - `detail: { checked }` when the select-all box is toggled.
26
38
  * @cssprop --cm-table-columns - Column widths, e.g. `2fr 1fr 1fr 120px`. Default: equal columns.
27
39
  */
28
- export declare class CmTableHeader extends LitElement {
40
+ export declare class CmTableHeader extends CmLocalizedElement {
29
41
  #private;
30
42
  static properties: {
31
43
  columns: {
@@ -82,3 +94,4 @@ declare global {
82
94
  'cm-table-header': CmTableHeader;
83
95
  }
84
96
  }
97
+ export {};