@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
@@ -10,8 +10,13 @@ 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 _CmOptionGroup_instances, _CmOptionGroup_internals, _CmOptionGroup_id, _CmOptionGroup_defaultValue, _CmOptionGroup_observer, _CmOptionGroup_readChildren, _CmOptionGroup_select, _CmOptionGroup_onKeyDown;
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';
16
+ const strings = defineStrings('optionGroup', {
17
+ /** Validation message when `required` and nothing is chosen. */
18
+ required: 'Please select one of these options.',
19
+ });
15
20
  /**
16
21
  * A row of outlined buttons where exactly one is selected (black), used to switch a form between
17
22
  * types, such as offer types. Behaves like a native radio group: one tab stop, arrow keys move and
@@ -23,7 +28,7 @@ import { base, define, nextId } from '../base.js';
23
28
  * @fires change - When the merchant picks a different option.
24
29
  * @fires input - Same moment as `change`.
25
30
  */
26
- export class CmOptionGroup extends LitElement {
31
+ export class CmOptionGroup extends CmLocalizedElement {
27
32
  constructor() {
28
33
  super(...arguments);
29
34
  _CmOptionGroup_instances.add(this);
@@ -77,7 +82,7 @@ export class CmOptionGroup extends LitElement {
77
82
  __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").setFormValue(this.value || null, this.value);
78
83
  const anchor = this.renderRoot.querySelector('button') ?? undefined;
79
84
  if (this.required && !this.value)
80
- __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").setValidity({ valueMissing: true }, 'Please select one of these options.', anchor);
85
+ __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").setValidity({ valueMissing: true }, this.t('required'), anchor);
81
86
  else
82
87
  __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").setValidity({});
83
88
  }
@@ -117,12 +122,13 @@ _CmOptionGroup_internals = new WeakMap(), _CmOptionGroup_id = new WeakMap(), _Cm
117
122
  this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
118
123
  this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
119
124
  }, _CmOptionGroup_onKeyDown = function _CmOptionGroup_onKeyDown(e, i) {
125
+ const key = logicalKey(e, this);
120
126
  const en = this.items.flatMap((o, j) => (o.disabled ? [] : [j]));
121
127
  const pos = en.indexOf(i);
122
128
  let next;
123
- if (e.key === 'ArrowRight' || e.key === 'ArrowDown')
129
+ if (key === 'ArrowRight' || e.key === 'ArrowDown')
124
130
  next = en[(pos + 1) % en.length];
125
- else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp')
131
+ else if (key === 'ArrowLeft' || e.key === 'ArrowUp')
126
132
  next = en[(pos - 1 + en.length) % en.length];
127
133
  else if (e.key === 'Home')
128
134
  next = en[0];
@@ -149,7 +155,7 @@ CmOptionGroup.styles = [
149
155
  css `
150
156
  :host { display: block; }
151
157
  .label { display: block; margin-bottom: var(--cm-space-20); font-size: var(--cm-type-heading-sm-size); font-weight: 600; }
152
- .req { color: var(--cm-text-critical); margin-left: 2px; }
158
+ .req { color: var(--cm-text-critical); margin-inline-start: 2px; }
153
159
  .options { display: flex; flex-wrap: wrap; gap: var(--cm-space-20); }
154
160
  button {
155
161
  height: 46px; padding: 0 var(--cm-space-20); font: inherit; font-size: 16px; font-weight: 500; white-space: nowrap;
@@ -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 of the back link on narrow screens. */
5
+ back: string;
6
+ /** Accessible name of the breadcrumb navigation. */
7
+ breadcrumbs: string;
8
+ /** Accessible names of the record arrows and their group. */
9
+ records: string;
10
+ previous: string;
11
+ next: string;
12
+ };
13
+ declare module '../localize.js' {
14
+ interface CmStrings {
15
+ pageHeader: typeof strings;
16
+ }
17
+ }
3
18
  /** One breadcrumb link above the page title. */
4
19
  export interface Breadcrumb {
5
20
  label: string;
@@ -15,7 +30,7 @@ export interface Breadcrumb {
15
30
  * @fires cm-previous - When the previous-record arrow is pressed (with `pagination`).
16
31
  * @fires cm-next - When the next-record arrow is pressed (with `pagination`).
17
32
  */
18
- export declare class CmPageHeader extends LitElement {
33
+ export declare class CmPageHeader extends CmLocalizedElement {
19
34
  #private;
20
35
  static properties: {
21
36
  heading: {};
@@ -56,3 +71,4 @@ declare global {
56
71
  'cm-page-header': CmPageHeader;
57
72
  }
58
73
  }
74
+ export {};
@@ -4,9 +4,20 @@ 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 _CmPageHeader_instances, _CmPageHeader_emit;
7
- import { LitElement, html, css, nothing } from 'lit';
7
+ import { html, css, nothing } from 'lit';
8
8
  import { base, define } from '../base.js';
9
+ import { CmLocalizedElement, defineStrings } from '../localize.js';
9
10
  import './icon.js';
11
+ const strings = defineStrings('pageHeader', {
12
+ /** Accessible name of the back link on narrow screens. */
13
+ back: 'Back to {label}',
14
+ /** Accessible name of the breadcrumb navigation. */
15
+ breadcrumbs: 'Breadcrumb',
16
+ /** Accessible names of the record arrows and their group. */
17
+ records: 'Records',
18
+ previous: 'Previous',
19
+ next: 'Next',
20
+ });
10
21
  /**
11
22
  * Top of an admin page: breadcrumbs, the page title and the page's main actions.
12
23
  * The Figma file calls this the "Save Bar" (80px desktop, 50px mobile).
@@ -17,7 +28,7 @@ import './icon.js';
17
28
  * @fires cm-previous - When the previous-record arrow is pressed (with `pagination`).
18
29
  * @fires cm-next - When the next-record arrow is pressed (with `pagination`).
19
30
  */
20
- export class CmPageHeader extends LitElement {
31
+ export class CmPageHeader extends CmLocalizedElement {
21
32
  constructor() {
22
33
  super(...arguments);
23
34
  _CmPageHeader_instances.add(this);
@@ -41,11 +52,11 @@ export class CmPageHeader extends LitElement {
41
52
  return html `<header part="header">
42
53
  <div class="lead">
43
54
  ${parent
44
- ? html `<a class="back" part="back" href=${parent.href} aria-label=${`Back to ${parent.label}`}><cm-icon name="chevron-left" size="20"></cm-icon></a>`
55
+ ? html `<a class="back" part="back" href=${parent.href} aria-label=${this.t('back', { label: parent.label })}><cm-icon name="chevron-left" size="20"></cm-icon></a>`
45
56
  : nothing}
46
57
  <div class="titles">
47
58
  ${crumbs.length
48
- ? html `<nav aria-label="Breadcrumb" part="breadcrumbs"><ol>
59
+ ? html `<nav aria-label=${this.t('breadcrumbs')} part="breadcrumbs"><ol>
49
60
  ${crumbs.map((c) => html `<li>${c.href ? html `<a href=${c.href}>${c.label}</a>` : c.label}</li>`)}
50
61
  <li><span aria-current="page">${this.heading}</span></li>
51
62
  </ol></nav>`
@@ -55,9 +66,9 @@ export class CmPageHeader extends LitElement {
55
66
  </div>
56
67
  <div class="actions">
57
68
  ${this.pagination
58
- ? html `<div class="arrows" role="group" aria-label="Records">
59
- <button class="arrow" type="button" aria-label="Previous" ?disabled=${!this.hasPrevious} @click=${() => __classPrivateFieldGet(this, _CmPageHeader_instances, "m", _CmPageHeader_emit).call(this, 'cm-previous')}><cm-icon name="chevron-left" size="16"></cm-icon></button>
60
- <button class="arrow" type="button" aria-label="Next" ?disabled=${!this.hasNext} @click=${() => __classPrivateFieldGet(this, _CmPageHeader_instances, "m", _CmPageHeader_emit).call(this, 'cm-next')}><cm-icon name="chevron-right" size="16"></cm-icon></button>
69
+ ? html `<div class="arrows" role="group" aria-label=${this.t('records')}>
70
+ <button class="arrow" type="button" aria-label=${this.t('previous')} ?disabled=${!this.hasPrevious} @click=${() => __classPrivateFieldGet(this, _CmPageHeader_instances, "m", _CmPageHeader_emit).call(this, 'cm-previous')}><cm-icon name="chevron-left" size="16"></cm-icon></button>
71
+ <button class="arrow" type="button" aria-label=${this.t('next')} ?disabled=${!this.hasNext} @click=${() => __classPrivateFieldGet(this, _CmPageHeader_instances, "m", _CmPageHeader_emit).call(this, 'cm-next')}><cm-icon name="chevron-right" size="16"></cm-icon></button>
61
72
  </div>`
62
73
  : nothing}
63
74
  <slot name="actions"></slot>
@@ -98,7 +109,7 @@ CmPageHeader.styles = [
98
109
  font-size: 26px; font-weight: 500; line-height: 1.2;
99
110
  }
100
111
  .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
101
- .actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-20); margin-left: auto; }
112
+ .actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-20); margin-inline-start: auto; }
102
113
  .arrows { display: flex; gap: var(--cm-space-10); }
103
114
  .arrow, .back {
104
115
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
@@ -109,8 +120,10 @@ CmPageHeader.styles = [
109
120
  .arrow:disabled { color: var(--cm-text-secondary); border-color: var(--cm-border-default); cursor: not-allowed; }
110
121
  .back { display: none; border: 0; flex: none; text-decoration: none; }
111
122
  @media (max-width: 640px) {
112
- header { flex-wrap: nowrap; min-height: 50px; padding: var(--cm-space-10); gap: var(--cm-space-10); }
113
- .lead { flex: 1 1 auto; }
123
+ /* Title and actions share one row while they fit; otherwise the actions wrap below, so nothing spills sideways. */
124
+ header { min-height: 50px; padding: var(--cm-space-10); gap: var(--cm-space-10); }
125
+ .lead { flex: 1 1 160px; }
126
+ .actions { flex: 0 1 auto; min-width: 0; max-width: 100%; justify-content: flex-end; }
114
127
  nav { display: none; }
115
128
  .back { display: inline-flex; }
116
129
  h1 { font-size: 18px; font-weight: 600; }
@@ -1,5 +1,25 @@
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 navigation landmark. */
5
+ label: string;
6
+ /** Label of the rows-per-page picker. */
7
+ rows: string;
8
+ /** The summary. `{resource}` is `resource-name`, or empty. */
9
+ summary: string;
10
+ /** Label of the page field. */
11
+ page: string;
12
+ /** After the page field. */
13
+ of: string;
14
+ /** Accessible names of the arrows. */
15
+ previous: string;
16
+ next: string;
17
+ };
18
+ declare module '../localize.js' {
19
+ interface CmStrings {
20
+ pagination: typeof strings;
21
+ }
22
+ }
3
23
  /**
4
24
  * Moves through a long list one page at a time. A 60px bar under a list or table: rows per page on
5
25
  * the left, "Showing 21–40 of 290" in the middle, and "Page [n] of N" with previous/next arrows on
@@ -11,7 +31,7 @@ import './icon.js';
11
31
  * @fires cm-page-change - `detail: { page }` when the merchant asks for another page.
12
32
  * @fires cm-page-size-change - `detail: { pageSize }` when rows per page changes. `page` resets to 1.
13
33
  */
14
- export declare class CmPagination extends LitElement {
34
+ export declare class CmPagination extends CmLocalizedElement {
15
35
  #private;
16
36
  static properties: {
17
37
  page: {
@@ -29,7 +49,9 @@ export declare class CmPagination extends LitElement {
29
49
  type: ArrayConstructor;
30
50
  attribute: string;
31
51
  };
32
- label: {};
52
+ label: {
53
+ string: string;
54
+ };
33
55
  resourceName: {
34
56
  attribute: string;
35
57
  };
@@ -45,7 +67,7 @@ export declare class CmPagination extends LitElement {
45
67
  pageSize: number;
46
68
  /** Choices for "Number of rows". Empty hides the picker. JSON in the attribute: `page-sizes="[10,20,50]"`. */
47
69
  pageSizes: number[];
48
- /** Accessible name of the navigation landmark. Change it when a page has two paginations. */
70
+ /** Accessible name of the navigation landmark. Change it when a page has two paginations. Default: the built-in string `label` ("Pagination"). */
49
71
  label: string;
50
72
  /** Plural noun used in the summary, e.g. "products": "Showing 21–40 of 290 products". */
51
73
  resourceName: string;
@@ -62,3 +84,4 @@ declare global {
62
84
  'cm-pagination': CmPagination;
63
85
  }
64
86
  }
87
+ export {};
@@ -4,9 +4,25 @@ 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 _CmPagination_instances, _CmPagination_id, _CmPagination_onSize, _CmPagination_onKey;
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 } from '../localize.js';
9
10
  import './icon.js';
11
+ const strings = defineStrings('pagination', {
12
+ /** Accessible name of the navigation landmark. */
13
+ label: 'Pagination',
14
+ /** Label of the rows-per-page picker. */
15
+ rows: 'Number of rows',
16
+ /** The summary. `{resource}` is `resource-name`, or empty. */
17
+ summary: 'Showing {from}–{to} of {total} {resource}',
18
+ /** Label of the page field. */
19
+ page: 'Page',
20
+ /** After the page field. */
21
+ of: 'of {count}',
22
+ /** Accessible names of the arrows. */
23
+ previous: 'Previous page',
24
+ next: 'Next page',
25
+ });
10
26
  /**
11
27
  * Moves through a long list one page at a time. A 60px bar under a list or table: rows per page on
12
28
  * the left, "Showing 21–40 of 290" in the middle, and "Page [n] of N" with previous/next arrows on
@@ -18,7 +34,7 @@ import './icon.js';
18
34
  * @fires cm-page-change - `detail: { page }` when the merchant asks for another page.
19
35
  * @fires cm-page-size-change - `detail: { pageSize }` when rows per page changes. `page` resets to 1.
20
36
  */
21
- export class CmPagination extends LitElement {
37
+ export class CmPagination extends CmLocalizedElement {
22
38
  constructor() {
23
39
  super(...arguments);
24
40
  _CmPagination_instances.add(this);
@@ -30,8 +46,6 @@ export class CmPagination extends LitElement {
30
46
  this.pageSize = 20;
31
47
  /** Choices for "Number of rows". Empty hides the picker. JSON in the attribute: `page-sizes="[10,20,50]"`. */
32
48
  this.pageSizes = [10, 20, 50, 100];
33
- /** Accessible name of the navigation landmark. Change it when a page has two paginations. */
34
- this.label = 'Pagination';
35
49
  /** Plural noun used in the summary, e.g. "products": "Showing 21–40 of 290 products". */
36
50
  this.resourceName = '';
37
51
  this._draft = null;
@@ -57,35 +71,33 @@ export class CmPagination extends LitElement {
57
71
  const page = Math.min(count, Math.max(1, this.page));
58
72
  const from = this.total ? (page - 1) * this.pageSize + 1 : 0;
59
73
  const to = Math.min(this.total, page * this.pageSize);
60
- const fmt = (n) => n.toLocaleString();
61
74
  const sizes = this.pageSizes ?? [];
62
- const noun = this.resourceName ? ` ${this.resourceName}` : '';
63
75
  return html `
64
76
  <nav part="bar" aria-label=${this.label}>
65
77
  ${sizes.length
66
78
  ? html `<div class="rows" part="rows">
67
- <label for="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-s">Number of rows</label>
79
+ <label for="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-s">${this.t('rows')}</label>
68
80
  <span class="field"><select id="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-s" @change=${__classPrivateFieldGet(this, _CmPagination_instances, "m", _CmPagination_onSize)}>
69
81
  ${(sizes.includes(this.pageSize) ? sizes : [...sizes, this.pageSize].sort((a, b) => a - b))
70
82
  .map((s) => html `<option value=${s} ?selected=${s === this.pageSize}>${s}</option>`)}
71
83
  </select><cm-icon name="chevron-down" size="12"></cm-icon></span>
72
84
  </div>`
73
85
  : nothing}
74
- <div class="summary" part="summary" role="status">${this.total ? `Showing ${fmt(from)}–${fmt(to)} of ${fmt(this.total)}${noun}` : nothing}</div>
86
+ <div class="summary" part="summary" role="status">${this.total ? this.t('summary', { from, to, total: this.total, resource: this.resourceName }).replace(/\s+/g, ' ').trim() : nothing}</div>
75
87
  <div class="pages" part="pages">
76
88
  <span class="counter">
77
- <label for="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-p">Page</label>
89
+ <label for="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-p">${this.t('page')}</label>
78
90
  <input id="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-p" type="number" inputmode="numeric" min="1" max=${count}
79
91
  .value=${this._draft ?? String(page)} aria-describedby="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-of"
80
92
  @input=${(e) => (this._draft = e.target.value)}
81
93
  @keydown=${__classPrivateFieldGet(this, _CmPagination_instances, "m", _CmPagination_onKey)}
82
94
  @change=${(e) => this.goTo(Number(e.target.value))} />
83
- <span id="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-of">of ${fmt(count)}</span>
95
+ <span id="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-of">${this.t('of', { count })}</span>
84
96
  </span>
85
97
  <span class="arrows">
86
- <button class="prev" type="button" part="previous" aria-label="Previous page" ?disabled=${page <= 1}
98
+ <button class="prev" type="button" part="previous" aria-label=${this.t('previous')} ?disabled=${page <= 1}
87
99
  @click=${() => this.goTo(page - 1)}><cm-icon name="chevron-left" size="12"></cm-icon></button>
88
- <button class="next" type="button" part="next" aria-label="Next page" ?disabled=${page >= count}
100
+ <button class="next" type="button" part="next" aria-label=${this.t('next')} ?disabled=${page >= count}
89
101
  @click=${() => this.goTo(page + 1)}><cm-icon name="chevron-right" size="12"></cm-icon></button>
90
102
  </span>
91
103
  </div>
@@ -115,7 +127,7 @@ CmPagination.properties = {
115
127
  total: { type: Number },
116
128
  pageSize: { type: Number, attribute: 'page-size' },
117
129
  pageSizes: { type: Array, attribute: 'page-sizes' },
118
- label: {},
130
+ label: { string: 'label' },
119
131
  resourceName: { attribute: 'resource-name' },
120
132
  _draft: { state: true },
121
133
  };
@@ -134,12 +146,12 @@ CmPagination.styles = [
134
146
  height: 34px; font: inherit; font-weight: 500; color: var(--cm-text-default); background: var(--cm-bg-surface);
135
147
  border: var(--cm-border-1) solid var(--cm-border-input); border-radius: var(--cm-radius-sm);
136
148
  }
137
- select { appearance: none; padding: 0 28px 0 10px; min-width: 56px; cursor: pointer; }
138
- .field cm-icon { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
149
+ select { appearance: none; padding-block: 0; padding-inline: 10px 28px; min-width: 56px; cursor: pointer; }
150
+ .field cm-icon { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
139
151
  input { width: 38px; padding: 0; text-align: center; -moz-appearance: textfield; }
140
152
  input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
141
153
  select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
142
- .arrows { display: flex; gap: var(--cm-space-10); margin-left: var(--cm-space-10); }
154
+ .arrows { display: flex; gap: var(--cm-space-10); margin-inline-start: var(--cm-space-10); }
143
155
  button {
144
156
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
145
157
  color: var(--cm-icon-selected); background: var(--cm-bg-hover);
@@ -1,10 +1,19 @@
1
- import { LitElement } from 'lit';
1
+ import { CmLocalizedElement } from '../localize.js';
2
+ declare const strings: {
3
+ /** Read while the progress is indeterminate (no `value`). */
4
+ inProgress: string;
5
+ };
6
+ declare module '../localize.js' {
7
+ interface CmStrings {
8
+ progressBar: typeof strings;
9
+ }
10
+ }
2
11
  /**
3
12
  * Shows how far a longer task has got (an import, an upload, a bulk update), or that it is running when the
4
13
  * amount is unknown. A WAI-ARIA progressbar.
5
14
  * @element cm-progress-bar
6
15
  */
7
- export declare class CmProgressBar extends LitElement {
16
+ export declare class CmProgressBar extends CmLocalizedElement {
8
17
  #private;
9
18
  static properties: {
10
19
  value: {
@@ -43,3 +52,4 @@ declare global {
43
52
  'cm-progress-bar': CmProgressBar;
44
53
  }
45
54
  }
55
+ export {};
@@ -4,14 +4,19 @@ 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 _CmProgressBar_id;
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 } from '../localize.js';
10
+ const strings = defineStrings('progressBar', {
11
+ /** Read while the progress is indeterminate (no `value`). */
12
+ inProgress: 'In progress',
13
+ });
9
14
  /**
10
15
  * Shows how far a longer task has got (an import, an upload, a bulk update), or that it is running when the
11
16
  * amount is unknown. A WAI-ARIA progressbar.
12
17
  * @element cm-progress-bar
13
18
  */
14
- export class CmProgressBar extends LitElement {
19
+ export class CmProgressBar extends CmLocalizedElement {
15
20
  constructor() {
16
21
  super(...arguments);
17
22
  /** Percent done, 0–100. Leave unset (or `null`) for an indeterminate bar when the amount is unknown. */
@@ -39,12 +44,12 @@ export class CmProgressBar extends LitElement {
39
44
  return html `
40
45
  <div class="head ${this.labelHidden ? 'vh' : ''}">
41
46
  <span id=${labelId} part="label">${this.label}</span>
42
- ${this.showValue && v !== null ? html `<span class="value" aria-hidden="true">${Math.round(v)}%</span>` : nothing}
47
+ ${this.showValue && v !== null ? html `<span class="value" aria-hidden="true">${this.formatNumber(Math.round(v) / 100, { style: 'percent' })}</span>` : nothing}
43
48
  </div>
44
49
  <div class="track ${v === null ? 'indeterminate' : ''}" part="track" role="progressbar"
45
50
  aria-labelledby=${labelId} aria-valuemin="0" aria-valuemax="100"
46
51
  aria-valuenow=${v === null ? nothing : Math.round(v)}
47
- aria-valuetext=${v === null ? 'In progress' : `${Math.round(v)}%`}>
52
+ aria-valuetext=${v === null ? this.t('inProgress') : this.formatNumber(Math.round(v) / 100, { style: 'percent' })}>
48
53
  <div class="fill" part="fill" style=${v === null ? '' : `inline-size:${v}%`}></div>
49
54
  </div>`;
50
55
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
+ import { CmLocalizedElement } from '../localize.js';
2
3
  /**
3
4
  * One option in a `<cm-radio-group>`. On its own it does nothing: the group owns
4
5
  * the value, the keyboard behaviour and the form submission.
@@ -53,6 +54,15 @@ export declare class CmRadio extends LitElement {
53
54
  static styles: import("lit").CSSResult[];
54
55
  render(): import("lit-html").TemplateResult<1>;
55
56
  }
57
+ declare const strings: {
58
+ /** Validation message when `required` and nothing is chosen. */
59
+ required: string;
60
+ };
61
+ declare module '../localize.js' {
62
+ interface CmStrings {
63
+ radioGroup: typeof strings;
64
+ }
65
+ }
56
66
  /**
57
67
  * A set of `<cm-radio>` options where exactly one can be chosen. Behaves like a native radio group:
58
68
  * one tab stop, arrow keys move and select, and the form receives the selected value.
@@ -62,7 +72,7 @@ export declare class CmRadio extends LitElement {
62
72
  * @fires change - When the merchant picks a different option.
63
73
  * @fires input - Same moment as `change`, for frameworks that listen to `input`.
64
74
  */
65
- export declare class CmRadioGroup extends LitElement {
75
+ export declare class CmRadioGroup extends CmLocalizedElement {
66
76
  #private;
67
77
  static formAssociated: boolean;
68
78
  static properties: {
@@ -129,3 +139,4 @@ declare global {
129
139
  'cm-radio-group': CmRadioGroup;
130
140
  }
131
141
  }
142
+ export {};
@@ -11,7 +11,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
11
11
  };
12
12
  var _CmRadio_id, _CmRadioGroup_instances, _CmRadioGroup_internals, _CmRadioGroup_id, _CmRadioGroup_defaultValue, _CmRadioGroup_pristine, _CmRadioGroup_rendered, _CmRadioGroup_adopting, _CmRadioGroup_adoptInitial, _CmRadioGroup_onSlotChange, _CmRadioGroup_radios, _CmRadioGroup_enabled, _CmRadioGroup_sync, _CmRadioGroup_select, _CmRadioGroup_onClick, _CmRadioGroup_onKeyDown, _CmRadioGroup_hasLabel;
13
13
  import { LitElement, html, css, nothing } from 'lit';
14
- import { base, define, nextId } from '../base.js';
14
+ import { base, define, nextId, logicalKey } from '../base.js';
15
+ import { CmLocalizedElement, defineStrings } from '../localize.js';
15
16
  /**
16
17
  * One option in a `<cm-radio-group>`. On its own it does nothing: the group owns
17
18
  * the value, the keyboard behaviour and the form submission.
@@ -83,6 +84,10 @@ CmRadio.styles = [
83
84
  `,
84
85
  ];
85
86
  define('cm-radio', CmRadio);
87
+ const strings = defineStrings('radioGroup', {
88
+ /** Validation message when `required` and nothing is chosen. */
89
+ required: 'Please select one of these options.',
90
+ });
86
91
  /**
87
92
  * A set of `<cm-radio>` options where exactly one can be chosen. Behaves like a native radio group:
88
93
  * one tab stop, arrow keys move and select, and the form receives the selected value.
@@ -92,7 +97,7 @@ define('cm-radio', CmRadio);
92
97
  * @fires change - When the merchant picks a different option.
93
98
  * @fires input - Same moment as `change`, for frameworks that listen to `input`.
94
99
  */
95
- export class CmRadioGroup extends LitElement {
100
+ export class CmRadioGroup extends CmLocalizedElement {
96
101
  constructor() {
97
102
  super();
98
103
  _CmRadioGroup_instances.add(this);
@@ -146,10 +151,11 @@ export class CmRadioGroup extends LitElement {
146
151
  return;
147
152
  const list = __classPrivateFieldGet(this, _CmRadioGroup_instances, "m", _CmRadioGroup_enabled).call(this);
148
153
  const i = list.indexOf(r);
154
+ const key = logicalKey(e, this);
149
155
  let next;
150
- if (e.key === 'ArrowDown' || e.key === 'ArrowRight')
156
+ if (e.key === 'ArrowDown' || key === 'ArrowRight')
151
157
  next = list[(i + 1) % list.length];
152
- else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft')
158
+ else if (e.key === 'ArrowUp' || key === 'ArrowLeft')
153
159
  next = list[(i - 1 + list.length) % list.length];
154
160
  else if (e.key === ' ')
155
161
  next = r.disabled ? undefined : r;
@@ -188,7 +194,7 @@ export class CmRadioGroup extends LitElement {
188
194
  if (this.error)
189
195
  __classPrivateFieldGet(this, _CmRadioGroup_internals, "f").setValidity({ customError: true }, this.error, anchor);
190
196
  else if (this.required && !this.value)
191
- __classPrivateFieldGet(this, _CmRadioGroup_internals, "f").setValidity({ valueMissing: true }, 'Please select one of these options.', anchor);
197
+ __classPrivateFieldGet(this, _CmRadioGroup_internals, "f").setValidity({ valueMissing: true }, this.t('required'), anchor);
192
198
  else
193
199
  __classPrivateFieldGet(this, _CmRadioGroup_internals, "f").setValidity({});
194
200
  }
@@ -242,7 +248,7 @@ CmRadioGroup.styles = [
242
248
  :host { display: block; }
243
249
  .group { display: flex; flex-direction: column; gap: var(--cm-space-10); }
244
250
  .label { font-size: var(--cm-type-label-size); color: var(--cm-text-default); }
245
- .req { color: var(--cm-text-critical); margin-left: 2px; }
251
+ .req { color: var(--cm-text-critical); margin-inline-start: 2px; }
246
252
  .help, .error { margin: 0; font-size: 12px; color: var(--cm-text-tertiary); }
247
253
  .error { color: var(--cm-text-critical); }
248
254
  .options { display: flex; flex-direction: column; align-items: flex-start; gap: var(--cm-space-20); padding-top: var(--cm-space-10); }
@@ -1,6 +1,16 @@
1
1
  import { LitElement } from 'lit';
2
+ import { CmLocalizedElement } from '../localize.js';
2
3
  import type { IconName } from '@commmerce/icons';
3
4
  import './icon.js';
5
+ declare const strings: {
6
+ /** Read after the label of a pinned report. */
7
+ pinned: string;
8
+ };
9
+ declare module '../localize.js' {
10
+ interface CmStrings {
11
+ reportTile: typeof strings;
12
+ }
13
+ }
4
14
  /**
5
15
  * A square tile that opens one report: a large icon over a short name, e.g. "Hourly sales".
6
16
  * A pinned tile shows a pin in its corner. With `href` the tile is a link; without, a button.
@@ -8,7 +18,7 @@ import './icon.js';
8
18
  * @slot icon - Your own 58px illustration, used instead of `icon`.
9
19
  * @fires click - When a tile without `href` is chosen.
10
20
  */
11
- export declare class CmReportTile extends LitElement {
21
+ export declare class CmReportTile extends CmLocalizedElement {
12
22
  static properties: {
13
23
  label: {};
14
24
  icon: {};
@@ -63,3 +73,4 @@ declare global {
63
73
  'cm-report-tiles': CmReportTiles;
64
74
  }
65
75
  }
76
+ export {};
@@ -1,6 +1,11 @@
1
1
  import { LitElement, 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';
5
+ const strings = defineStrings('reportTile', {
6
+ /** Read after the label of a pinned report. */
7
+ pinned: ', pinned',
8
+ });
4
9
  /**
5
10
  * A square tile that opens one report: a large icon over a short name, e.g. "Hourly sales".
6
11
  * A pinned tile shows a pin in its corner. With `href` the tile is a link; without, a button.
@@ -8,7 +13,7 @@ import './icon.js';
8
13
  * @slot icon - Your own 58px illustration, used instead of `icon`.
9
14
  * @fires click - When a tile without `href` is chosen.
10
15
  */
11
- export class CmReportTile extends LitElement {
16
+ export class CmReportTile extends CmLocalizedElement {
12
17
  constructor() {
13
18
  super(...arguments);
14
19
  /** Report name, two or three words. */
@@ -24,7 +29,7 @@ export class CmReportTile extends LitElement {
24
29
  const inner = html `
25
30
  <span class="icon" aria-hidden="true"><slot name="icon"><cm-icon name=${this.icon} size="58"></cm-icon></slot></span>
26
31
  <span class="label">${this.label}</span>
27
- ${this.pinned ? html `<span class="pin" part="pin"><cm-icon name="pin" size="18"></cm-icon><span class="sr">, pinned</span></span>` : nothing}
32
+ ${this.pinned ? html `<span class="pin" part="pin"><cm-icon name="pin" size="18"></cm-icon><span class="sr">${this.t('pinned')}</span></span>` : nothing}
28
33
  `;
29
34
  return this.href
30
35
  ? html `<a class="tile" part="tile" href=${this.href}>${inner}</a>`
@@ -52,13 +57,13 @@ CmReportTile.styles = [
52
57
  .tile:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
53
58
  .icon { display: inline-flex; color: var(--cm-icon-selected); }
54
59
  ::slotted([slot='icon']) { width: 58px; height: 58px; }
55
- .pin { position: absolute; top: 10px; right: 10px; color: var(--cm-icon-selected); }
60
+ .pin { position: absolute; top: 10px; inset-inline-end: 10px; color: var(--cm-icon-selected); }
56
61
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
57
62
  @media (max-width: 640px) {
58
63
  .tile { height: 118px; gap: var(--cm-space-10); font-size: 12px; }
59
64
  .icon cm-icon::part(svg) { width: 38px; height: 38px; }
60
65
  ::slotted([slot='icon']) { width: 38px; height: 38px; }
61
- .pin { top: 8px; right: 8px; }
66
+ .pin { top: 8px; inset-inline-end: 8px; }
62
67
  }
63
68
  `,
64
69
  ];