@commmerce/ui 0.0.0-stage → 1.0.0-rc.3

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 (125) hide show
  1. package/LICENSE.md +17 -0
  2. package/README.md +41 -2
  3. package/dist/base.d.ts +7 -0
  4. package/dist/base.js +22 -0
  5. package/dist/cdn.js +1958 -0
  6. package/dist/components/accordion.d.ts +43 -0
  7. package/dist/components/accordion.js +83 -0
  8. package/dist/components/action-bar.d.ts +42 -0
  9. package/dist/components/action-bar.js +84 -0
  10. package/dist/components/action-menu.d.ts +89 -0
  11. package/dist/components/action-menu.js +283 -0
  12. package/dist/components/app-card.d.ts +57 -0
  13. package/dist/components/app-card.js +100 -0
  14. package/dist/components/avatar.d.ts +48 -0
  15. package/dist/components/avatar.js +82 -0
  16. package/dist/components/badge.d.ts +23 -0
  17. package/dist/components/badge.js +35 -0
  18. package/dist/components/banner.d.ts +36 -0
  19. package/dist/components/banner.js +88 -0
  20. package/dist/components/bottom-navigation.d.ts +48 -0
  21. package/dist/components/bottom-navigation.js +98 -0
  22. package/dist/components/bottom-sheet.d.ts +54 -0
  23. package/dist/components/bottom-sheet.js +133 -0
  24. package/dist/components/button.d.ts +53 -0
  25. package/dist/components/button.js +101 -0
  26. package/dist/components/card.d.ts +37 -0
  27. package/dist/components/card.js +58 -0
  28. package/dist/components/checkbox.d.ts +68 -0
  29. package/dist/components/checkbox.js +114 -0
  30. package/dist/components/comment.d.ts +76 -0
  31. package/dist/components/comment.js +170 -0
  32. package/dist/components/data-table.d.ts +132 -0
  33. package/dist/components/data-table.js +331 -0
  34. package/dist/components/empty-state.d.ts +49 -0
  35. package/dist/components/empty-state.js +94 -0
  36. package/dist/components/file-upload.d.ts +102 -0
  37. package/dist/components/file-upload.js +243 -0
  38. package/dist/components/filter-panel.d.ts +86 -0
  39. package/dist/components/filter-panel.js +128 -0
  40. package/dist/components/flash-offer-bar.d.ts +34 -0
  41. package/dist/components/flash-offer-bar.js +73 -0
  42. package/dist/components/grid.d.ts +39 -0
  43. package/dist/components/grid.js +42 -0
  44. package/dist/components/header-bar.d.ts +48 -0
  45. package/dist/components/header-bar.js +121 -0
  46. package/dist/components/icon.d.ts +30 -0
  47. package/dist/components/icon.js +36 -0
  48. package/dist/components/info-panel.d.ts +63 -0
  49. package/dist/components/info-panel.js +108 -0
  50. package/dist/components/layout.d.ts +45 -0
  51. package/dist/components/layout.js +67 -0
  52. package/dist/components/link-tabs.d.ts +40 -0
  53. package/dist/components/link-tabs.js +85 -0
  54. package/dist/components/menu-item.d.ts +68 -0
  55. package/dist/components/menu-item.js +64 -0
  56. package/dist/components/mobile-menu.d.ts +69 -0
  57. package/dist/components/mobile-menu.js +184 -0
  58. package/dist/components/modal.d.ts +46 -0
  59. package/dist/components/modal.js +59 -0
  60. package/dist/components/nav-item.d.ts +98 -0
  61. package/dist/components/nav-item.js +84 -0
  62. package/dist/components/nested-list.d.ts +105 -0
  63. package/dist/components/nested-list.js +279 -0
  64. package/dist/components/notification-panel.d.ts +121 -0
  65. package/dist/components/notification-panel.js +174 -0
  66. package/dist/components/option-group.d.ts +74 -0
  67. package/dist/components/option-group.js +172 -0
  68. package/dist/components/page-header.d.ts +58 -0
  69. package/dist/components/page-header.js +121 -0
  70. package/dist/components/page.d.ts +34 -0
  71. package/dist/components/page.js +41 -0
  72. package/dist/components/pagination.d.ts +64 -0
  73. package/dist/components/pagination.js +160 -0
  74. package/dist/components/progress-bar.d.ts +45 -0
  75. package/dist/components/progress-bar.js +81 -0
  76. package/dist/components/radio.d.ts +131 -0
  77. package/dist/components/radio.js +252 -0
  78. package/dist/components/report-tile.d.ts +65 -0
  79. package/dist/components/report-tile.js +112 -0
  80. package/dist/components/resource-list.d.ts +143 -0
  81. package/dist/components/resource-list.js +335 -0
  82. package/dist/components/save-bar.d.ts +58 -0
  83. package/dist/components/save-bar.js +128 -0
  84. package/dist/components/search.d.ts +78 -0
  85. package/dist/components/search.js +144 -0
  86. package/dist/components/select.d.ts +106 -0
  87. package/dist/components/select.js +338 -0
  88. package/dist/components/side-navigation.d.ts +51 -0
  89. package/dist/components/side-navigation.js +194 -0
  90. package/dist/components/side-panel.d.ts +50 -0
  91. package/dist/components/side-panel.js +73 -0
  92. package/dist/components/skeleton-display.d.ts +32 -0
  93. package/dist/components/skeleton-display.js +70 -0
  94. package/dist/components/skeleton.d.ts +41 -0
  95. package/dist/components/skeleton.js +59 -0
  96. package/dist/components/smart-tip.d.ts +62 -0
  97. package/dist/components/smart-tip.js +128 -0
  98. package/dist/components/spinner.d.ts +27 -0
  99. package/dist/components/spinner.js +48 -0
  100. package/dist/components/stack.d.ts +45 -0
  101. package/dist/components/stack.js +49 -0
  102. package/dist/components/status-tabs.d.ts +65 -0
  103. package/dist/components/status-tabs.js +158 -0
  104. package/dist/components/table-header.d.ts +84 -0
  105. package/dist/components/table-header.js +151 -0
  106. package/dist/components/tag.d.ts +39 -0
  107. package/dist/components/tag.js +68 -0
  108. package/dist/components/text-field.d.ts +101 -0
  109. package/dist/components/text-field.js +162 -0
  110. package/dist/components/thumbnail.d.ts +40 -0
  111. package/dist/components/thumbnail.js +61 -0
  112. package/dist/components/toast.d.ts +108 -0
  113. package/dist/components/toast.js +268 -0
  114. package/dist/components/toggle.d.ts +60 -0
  115. package/dist/components/toggle.js +108 -0
  116. package/dist/components/tooltip.d.ts +56 -0
  117. package/dist/components/tooltip.js +267 -0
  118. package/dist/custom-elements.json +13222 -0
  119. package/dist/index.d.ts +70 -0
  120. package/dist/index.js +56 -0
  121. package/dist/overlay.d.ts +57 -0
  122. package/dist/overlay.js +205 -0
  123. package/dist/spacing.d.ts +6 -0
  124. package/dist/spacing.js +7 -0
  125. package/package.json +59 -4
@@ -0,0 +1,335 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
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';
8
+ import { base, define, nextId } from '../base.js';
9
+ import './icon.js';
10
+ import './action-menu.js';
11
+ const checkboxStyles = css `
12
+ .check { position: relative; display: inline-flex; flex: none; width: 20px; height: 20px; }
13
+ .check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
14
+ .check input:disabled { cursor: not-allowed; }
15
+ .box {
16
+ width: 100%; height: 100%; display: inline-flex; align-items: center; justify-content: center; pointer-events: none;
17
+ color: var(--cm-icon-selected); background: var(--cm-bg-surface);
18
+ border: var(--cm-border-1) solid var(--cm-border-strong); border-radius: var(--cm-radius-xs);
19
+ }
20
+ .dash { width: 50%; height: 2px; background: currentColor; }
21
+ .check input:focus-visible + .box { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
22
+ .check input:disabled + .box { border-color: var(--cm-border-default); background: var(--cm-bg-input-filled); }
23
+ `;
24
+ /**
25
+ * A row in a `cm-resource-list`: a checkbox when the list is selectable, an optional thumbnail and
26
+ * any content. With `href` the whole row is a link; otherwise clicking a selectable row ticks it.
27
+ * @element cm-resource-item
28
+ * @slot - Row content: name, details, badges. Lay columns out with `--cm-table-columns` to line up with a table header.
29
+ * @slot media - A 50px thumbnail (34px on phones): a `cm-thumbnail` (recommended; `alt=""` when the row names the product) or an `<img>`.
30
+ * @slot actions - Buttons at the end of the row. They do not toggle selection.
31
+ * @fires cm-resource-select - `detail: { value, selected }` when the merchant ticks or unticks the row. The list handles it.
32
+ */
33
+ export class CmResourceItem extends LitElement {
34
+ constructor() {
35
+ super();
36
+ _CmResourceItem_instances.add(this);
37
+ /** Identifies the row in the list's `selected` array. */
38
+ this.value = '';
39
+ /** The row is ticked. */
40
+ this.selected = false;
41
+ /** The row cannot be selected or opened. */
42
+ this.disabled = false;
43
+ /** Makes the row a link to the resource's page. */
44
+ this.href = '';
45
+ /** Name for the checkbox and link, e.g. the product name. Defaults to the row's text. */
46
+ this.label = '';
47
+ /** Shows the checkbox. Set by the parent list from its own `selectable`. */
48
+ this.selectable = false;
49
+ _CmResourceItem_internals.set(this, this.attachInternals());
50
+ __classPrivateFieldGet(this, _CmResourceItem_internals, "f").role = 'listitem';
51
+ }
52
+ connectedCallback() {
53
+ super.connectedCallback();
54
+ // Also as an attribute, so checkers that don't read ElementInternals (axe-core) see the list item too.
55
+ if (!this.hasAttribute('role'))
56
+ this.setAttribute('role', 'listitem');
57
+ }
58
+ /** Accessible name: `label` or the row's text. */
59
+ get name() {
60
+ return this.label || this.textContent.replace(/\s+/g, ' ').trim();
61
+ }
62
+ /** Ticks or unticks the row and fires `cm-resource-select`. */
63
+ toggle(force) {
64
+ if (this.disabled)
65
+ return;
66
+ const next = force ?? !this.selected;
67
+ if (next === this.selected)
68
+ return;
69
+ this.selected = next;
70
+ this.dispatchEvent(new CustomEvent('cm-resource-select', { detail: { value: this.value, selected: next }, bubbles: true, composed: true }));
71
+ }
72
+ render() {
73
+ return html `
74
+ ${this.href && !this.disabled ? html `<a href=${this.href} part="link"><span class="sr">${this.name}</span></a>` : nothing}
75
+ <div class="row" part="row" @click=${__classPrivateFieldGet(this, _CmResourceItem_instances, "m", _CmResourceItem_onRowClick)}>
76
+ ${this.selectable
77
+ ? html `<span class="check" part="checkbox"><input type="checkbox" aria-label=${`Select ${this.name}`} .checked=${this.selected}
78
+ ?disabled=${this.disabled} @change=${(e) => this.toggle(e.target.checked)} />
79
+ <span class="box" aria-hidden="true">${this.selected ? html `<cm-icon name="check" size="14"></cm-icon>` : nothing}</span></span>`
80
+ : nothing}
81
+ <span class="media"><slot name="media"></slot></span>
82
+ <div class="content" part="content"><slot></slot></div>
83
+ <div class="actions" part="actions"><slot name="actions"></slot></div>
84
+ </div>
85
+ `;
86
+ }
87
+ }
88
+ _CmResourceItem_internals = new WeakMap(), _CmResourceItem_instances = new WeakSet(), _CmResourceItem_onRowClick = function _CmResourceItem_onRowClick(e) {
89
+ if (!this.selectable || this.href || this.disabled)
90
+ return;
91
+ const path = e.composedPath();
92
+ if (path.some((n) => n instanceof HTMLElement && n !== this && n.matches('a, button, input, select, textarea, label, [role="button"], cm-button')))
93
+ return;
94
+ if (getSelection()?.toString())
95
+ return;
96
+ this.toggle();
97
+ };
98
+ CmResourceItem.properties = {
99
+ value: { reflect: true },
100
+ selected: { type: Boolean, reflect: true },
101
+ disabled: { type: Boolean, reflect: true },
102
+ href: {},
103
+ label: {},
104
+ selectable: { type: Boolean, reflect: true },
105
+ };
106
+ CmResourceItem.styles = [
107
+ base,
108
+ checkboxStyles,
109
+ css `
110
+ :host { display: block; position: relative; border-bottom: var(--cm-border-1) solid var(--cm-border-default); }
111
+ :host(:last-child) { border-bottom: 0; }
112
+ .row {
113
+ display: flex; align-items: center; gap: var(--cm-space-20); min-height: 70px; padding: var(--cm-space-20) var(--cm-space-10);
114
+ font-size: 16px; line-height: 18px;
115
+ }
116
+ :host(:hover:not([disabled])) .row, :host([selected]) .row { background: var(--cm-bg-inset); }
117
+ :host([selectable]:not([href]):not([disabled])) .row { cursor: pointer; }
118
+ :host([disabled]) .row { color: var(--cm-text-tertiary); }
119
+ .media { display: contents; }
120
+ ::slotted([slot='media']) {
121
+ flex: none; width: 50px; height: 50px; object-fit: cover; border-radius: var(--cm-radius-sm); background: var(--cm-thumb-bg);
122
+ }
123
+ ::slotted(cm-thumbnail[slot='media']) { --cm-thumbnail-size: 50px; background: none; }
124
+ .content { flex: 1; min-width: 0; }
125
+ a { position: absolute; inset: 0; z-index: 0; border-radius: var(--cm-radius-xs); }
126
+ a:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: -2px; }
127
+ .check, .actions { position: relative; z-index: 1; }
128
+ .actions { display: flex; gap: var(--cm-space-10); }
129
+ .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
130
+ @media (max-width: 640px) {
131
+ .row { gap: var(--cm-space-10); min-height: 64px; padding: 15px 0; font-size: 14px; }
132
+ .check { width: 18px; height: 18px; }
133
+ ::slotted([slot='media']) { width: 34px; height: 34px; }
134
+ ::slotted(cm-thumbnail[slot='media']) { --cm-thumbnail-size: 34px; }
135
+ }
136
+ `,
137
+ ];
138
+ define('cm-resource-item', CmResourceItem);
139
+ /**
140
+ * A list of products, orders, customers or other resources, with optional bulk selection.
141
+ * When `selectable`, a toolbar shows a select-all box with a menu (this page, all matching, none), bulk actions once something is selected,
142
+ * "2 products selected" and, when there are more results than rows, a button to select all of them.
143
+ * Put a `cm-table-header` in the `header` slot for column names and `cm-pagination` under the list.
144
+ * @element cm-resource-list
145
+ * @slot - `cm-resource-item` rows.
146
+ * @slot header - A `cm-table-header` (or anything) between the toolbar and the rows.
147
+ * @slot bulk-actions - Buttons that act on the selection, e.g. "Bulk orders". Shown once a row is selected.
148
+ * @slot actions - Buttons at the end of the toolbar, e.g. "Customise columns".
149
+ * @slot empty - Shown instead of the rows when there are none, e.g. a `cm-empty-state`.
150
+ * @fires cm-selection-change - `detail: { selected, all }`: values of the selected rows, and whether every matching resource (all `total`) is selected.
151
+ */
152
+ export class CmResourceList extends LitElement {
153
+ constructor() {
154
+ super();
155
+ _CmResourceList_instances.add(this);
156
+ /** Rows get checkboxes and the selection toolbar appears. */
157
+ this.selectable = false;
158
+ /** Number of resources matching the current filter across all pages. When higher than the rows shown, offers "Select all". */
159
+ this.total = 0;
160
+ /** Singular noun, e.g. "product". */
161
+ this.resourceName = 'item';
162
+ /** Plural noun. Defaults to the singular plus "s". */
163
+ this.resourceNamePlural = '';
164
+ /** Dims the rows and shows a spinner while results load. */
165
+ this.loading = false;
166
+ /** Every matching resource is selected, not just the rows on this page. */
167
+ this.allSelected = false;
168
+ /** Hides the menu next to the select box (select this page, select all matching, select none). */
169
+ this.hideSelectMenu = false;
170
+ /** Accessible name of the list, e.g. "Products". Defaults to the plural noun. */
171
+ this.label = '';
172
+ this._count = 0;
173
+ this._rows = 0;
174
+ _CmResourceList_id.set(this, nextId('cm-rl'));
175
+ _CmResourceList_menuSelect.set(this, (e) => {
176
+ e.stopPropagation(); // the list's own menu: don't leak its cm-select to the page
177
+ const v = e.detail.value;
178
+ if (v === 'page')
179
+ this.selectPage(true);
180
+ else if (v === 'all')
181
+ this.selectAll();
182
+ else if (v === 'none')
183
+ this.clearSelection();
184
+ });
185
+ this.addEventListener('cm-resource-select', (e) => {
186
+ if (e.target === this)
187
+ return;
188
+ this.allSelected = false;
189
+ __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this);
190
+ __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_emit).call(this);
191
+ });
192
+ }
193
+ /** The `cm-resource-item` rows. */
194
+ get items() {
195
+ return [...this.querySelectorAll(':scope > cm-resource-item')];
196
+ }
197
+ /** Values of the selected rows on this page. */
198
+ get selected() {
199
+ return this.items.filter((i) => i.selected).map((i) => i.value);
200
+ }
201
+ /** Ticks or unticks every enabled row on this page. */
202
+ selectPage(select = true) {
203
+ this.items.forEach((i) => { if (!i.disabled)
204
+ i.selected = select; });
205
+ if (!select)
206
+ this.allSelected = false;
207
+ __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this);
208
+ __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_emit).call(this);
209
+ }
210
+ /** Selects every matching resource (`total`), including rows on other pages. */
211
+ selectAll() {
212
+ this.items.forEach((i) => { if (!i.disabled)
213
+ i.selected = true; });
214
+ this.allSelected = true;
215
+ __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this);
216
+ __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_emit).call(this);
217
+ }
218
+ /** Clears the selection. */
219
+ clearSelection() { this.selectPage(false); }
220
+ updated(changed) {
221
+ if (changed.has('selectable'))
222
+ __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this);
223
+ }
224
+ render() {
225
+ const n = this._count;
226
+ const rows = this._rows;
227
+ const enabled = this.items.filter((i) => !i.disabled).length;
228
+ const all = enabled > 0 && n >= enabled;
229
+ const fmt = (x) => x.toLocaleString();
230
+ const plural = __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_plural).call(this);
231
+ const noun = (x) => (x === 1 ? this.resourceName : plural);
232
+ const more = this.total > rows;
233
+ let status = nothing;
234
+ if (this.allSelected) {
235
+ status = html `All ${fmt(Math.max(this.total, n))} ${plural} selected. <button type="button" @click=${() => this.clearSelection()}>Clear selection</button>`;
236
+ }
237
+ 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}`;
240
+ }
241
+ return html `
242
+ ${this.selectable
243
+ ? html `<div class="toolbar" part="toolbar">
244
+ <span class="select" part="select">
245
+ <span class="check"><input id="${__classPrivateFieldGet(this, _CmResourceList_id, "f")}-all" type="checkbox" .checked=${all} .indeterminate=${n > 0 && !all}
246
+ ?disabled=${!enabled} @change=${(e) => this.selectPage(e.target.checked)} />
247
+ <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"
250
+ .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 },
254
+ ]} @cm-select=${__classPrivateFieldGet(this, _CmResourceList_menuSelect, "f")}></cm-action-menu>`}
255
+ </span>
256
+ <span class="bulk" ?hidden=${!n}><slot name="bulk-actions"></slot></span>
257
+ <span class="status" part="status" role="status">${status}</span>
258
+ <span class="actions"><slot name="actions"></slot></span>
259
+ </div>`
260
+ : nothing}
261
+ <div class="header"><slot name="header" @slotchange=${(e) => e.target.parentElement.classList.toggle('has', e.target.assignedElements().length > 0)}></slot></div>
262
+ <div class="body">
263
+ <div class="list" part="list" role="list" aria-label=${this.label || plural.replace(/^./, (c) => c.toUpperCase())} aria-busy=${this.loading ? 'true' : 'false'}>
264
+ <slot @slotchange=${() => __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this)}></slot>
265
+ </div>
266
+ ${this.loading ? html `<span class="spinner" part="spinner" role="progressbar" aria-label=${`Loading ${plural}`}></span>` : nothing}
267
+ </div>
268
+ <div class="empty ${rows || this.loading ? '' : 'show'}"><slot name="empty"></slot></div>
269
+ `;
270
+ }
271
+ }
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() {
273
+ const items = this.items;
274
+ items.forEach((i) => (i.selectable = this.selectable));
275
+ this._rows = items.length;
276
+ this._count = items.filter((i) => i.selected).length;
277
+ }, _CmResourceList_emit = function _CmResourceList_emit() {
278
+ this.dispatchEvent(new CustomEvent('cm-selection-change', { detail: { selected: this.selected, all: this.allSelected }, bubbles: true, composed: true }));
279
+ };
280
+ CmResourceList.properties = {
281
+ selectable: { type: Boolean, reflect: true },
282
+ total: { type: Number },
283
+ resourceName: { attribute: 'resource-name' },
284
+ resourceNamePlural: { attribute: 'resource-name-plural' },
285
+ loading: { type: Boolean, reflect: true },
286
+ allSelected: { type: Boolean, attribute: 'all-selected', reflect: true },
287
+ hideSelectMenu: { type: Boolean, attribute: 'hide-select-menu' },
288
+ label: {},
289
+ _count: { state: true },
290
+ _rows: { state: true },
291
+ };
292
+ CmResourceList.styles = [
293
+ base,
294
+ checkboxStyles,
295
+ css `
296
+ :host { display: block; position: relative; background: var(--cm-bg-surface); border-radius: var(--cm-radius-md); }
297
+ .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-20); padding: var(--cm-space-20) var(--cm-space-20) 0; }
298
+ .select {
299
+ display: inline-flex; align-items: center; gap: var(--cm-space-10); height: 40px; padding: 0 var(--cm-space-10);
300
+ font-size: 14px; background: var(--cm-bg-inset); border: var(--cm-border-1) solid var(--cm-border-default); border-radius: var(--cm-radius-sm);
301
+ }
302
+ .select .check { width: 16px; height: 16px; }
303
+ .select label { cursor: pointer; }
304
+ .select cm-action-menu { margin-inline-start: -6px; }
305
+ .select cm-action-menu::part(trigger) { width: 28px; min-height: 28px; }
306
+ .bulk { display: flex; gap: var(--cm-space-10); }
307
+ .bulk[hidden] { display: none; }
308
+ .status { flex: 1; text-align: center; font-size: 16px; }
309
+ .status button { font: inherit; font-weight: 500; color: inherit; text-decoration: underline; background: none; border: 0; padding: 0; cursor: pointer; }
310
+ .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; }
312
+ .header { display: block; padding: var(--cm-space-20) var(--cm-space-20) 0; }
313
+ .header:not(.has) { display: none; }
314
+ .body { position: relative; }
315
+ .list { padding: 0 var(--cm-space-20) var(--cm-space-10); }
316
+ :host([loading]) .list ::slotted(*) { opacity: 0.4; }
317
+ .spinner {
318
+ position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%;
319
+ border: 4px solid var(--cm-thumb-bg); border-top-color: var(--cm-icon-selected); animation: spin 0.8s linear infinite;
320
+ }
321
+ @keyframes spin { to { transform: rotate(360deg); } }
322
+ @media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
323
+ .empty:not(.show) { display: none; }
324
+ .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
325
+ @media (max-width: 640px) {
326
+ .toolbar { gap: var(--cm-space-10); padding: var(--cm-space-10) var(--cm-space-10) 0; }
327
+ .select { height: 32px; font-size: 12px; }
328
+ .status { flex-basis: 100%; order: 3; text-align: left; font-size: 12px; }
329
+ .header { padding: var(--cm-space-10) var(--cm-space-10) 0; }
330
+ .list { padding: 0 var(--cm-space-10); }
331
+ .spinner { width: 30px; height: 30px; margin: -15px; border-width: 3px; }
332
+ }
333
+ `,
334
+ ];
335
+ define('cm-resource-list', CmResourceList);
@@ -0,0 +1,58 @@
1
+ import { LitElement } from 'lit';
2
+ import './button.js';
3
+ /**
4
+ * Asks the merchant to save or discard unsaved changes. Hidden until `open` (or, with `form`,
5
+ * until a field in that form changes). Built on the Figma "Bottom Tab" save variant.
6
+ * @element cm-save-bar
7
+ * @fires cm-save - Save pressed (cancelable). With `form`, the default submits that form.
8
+ * @fires cm-discard - Discard pressed (cancelable). With `form`, the default resets that form and closes the bar.
9
+ */
10
+ export declare class CmSaveBar extends LitElement {
11
+ #private;
12
+ static properties: {
13
+ open: {
14
+ type: BooleanConstructor;
15
+ reflect: boolean;
16
+ };
17
+ message: {};
18
+ saveLabel: {
19
+ attribute: string;
20
+ };
21
+ discardLabel: {
22
+ attribute: string;
23
+ };
24
+ loading: {
25
+ type: BooleanConstructor;
26
+ reflect: boolean;
27
+ };
28
+ saveDisabled: {
29
+ type: BooleanConstructor;
30
+ attribute: string;
31
+ };
32
+ form: {};
33
+ };
34
+ /** Shows the bar. Set it when the page has unsaved changes. */
35
+ open: boolean;
36
+ /** The question or status shown next to the buttons. */
37
+ message: string;
38
+ /** Primary button label. */
39
+ saveLabel: string;
40
+ /** Secondary button label. */
41
+ discardLabel: string;
42
+ /** Shows a spinner on Save and blocks both buttons while saving. */
43
+ loading: boolean;
44
+ /** Disables Save, for example while the form has errors. */
45
+ saveDisabled: boolean;
46
+ /** ID of a `<form>` to watch: the bar opens on input, Save submits it and Discard resets it. */
47
+ form: string;
48
+ static styles: import("lit").CSSResult[];
49
+ connectedCallback(): void;
50
+ disconnectedCallback(): void;
51
+ updated(changed: Map<string, unknown>): void;
52
+ render(): import("lit-html").TemplateResult<1>;
53
+ }
54
+ declare global {
55
+ interface HTMLElementTagNameMap {
56
+ 'cm-save-bar': CmSaveBar;
57
+ }
58
+ }
@@ -0,0 +1,128 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
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';
14
+ import { base, define } from '../base.js';
15
+ import './button.js';
16
+ /**
17
+ * Asks the merchant to save or discard unsaved changes. Hidden until `open` (or, with `form`,
18
+ * until a field in that form changes). Built on the Figma "Bottom Tab" save variant.
19
+ * @element cm-save-bar
20
+ * @fires cm-save - Save pressed (cancelable). With `form`, the default submits that form.
21
+ * @fires cm-discard - Discard pressed (cancelable). With `form`, the default resets that form and closes the bar.
22
+ */
23
+ export class CmSaveBar extends LitElement {
24
+ constructor() {
25
+ super(...arguments);
26
+ _CmSaveBar_instances.add(this);
27
+ /** Shows the bar. Set it when the page has unsaved changes. */
28
+ 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
+ /** Shows a spinner on Save and blocks both buttons while saving. */
36
+ this.loading = false;
37
+ /** Disables Save, for example while the form has errors. */
38
+ this.saveDisabled = false;
39
+ /** ID of a `<form>` to watch: the bar opens on input, Save submits it and Discard resets it. */
40
+ this.form = '';
41
+ _CmSaveBar_watched.set(this, null);
42
+ _CmSaveBar_onDirty.set(this, () => { this.open = true; });
43
+ _CmSaveBar_onReset.set(this, () => { this.open = false; });
44
+ }
45
+ connectedCallback() {
46
+ super.connectedCallback();
47
+ queueMicrotask(() => __classPrivateFieldGet(this, _CmSaveBar_instances, "m", _CmSaveBar_watch).call(this));
48
+ }
49
+ disconnectedCallback() {
50
+ super.disconnectedCallback();
51
+ __classPrivateFieldGet(this, _CmSaveBar_instances, "m", _CmSaveBar_unwatch).call(this);
52
+ }
53
+ updated(changed) {
54
+ if (changed.has('form') && this.isConnected)
55
+ __classPrivateFieldGet(this, _CmSaveBar_instances, "m", _CmSaveBar_watch).call(this);
56
+ }
57
+ render() {
58
+ return html `<div class="bar" part="bar" role="region" aria-label=${this.message}>
59
+ <p class="message" part="message" role="status">${this.open ? this.message : ''}</p>
60
+ <div class="actions">
61
+ <cm-button size="large" ?disabled=${this.loading} @click=${__classPrivateFieldGet(this, _CmSaveBar_instances, "m", _CmSaveBar_discard)}>${this.discardLabel}</cm-button>
62
+ <cm-button size="large" variant="primary" ?loading=${this.loading} ?disabled=${this.saveDisabled} @click=${__classPrivateFieldGet(this, _CmSaveBar_instances, "m", _CmSaveBar_save)}>${this.saveLabel}</cm-button>
63
+ </div>
64
+ </div>`;
65
+ }
66
+ }
67
+ _CmSaveBar_watched = new WeakMap(), _CmSaveBar_onDirty = new WeakMap(), _CmSaveBar_onReset = new WeakMap(), _CmSaveBar_instances = new WeakSet(), _CmSaveBar_watch = function _CmSaveBar_watch() {
68
+ __classPrivateFieldGet(this, _CmSaveBar_instances, "m", _CmSaveBar_unwatch).call(this);
69
+ const f = this.form ? this.getRootNode().getElementById?.(this.form) : null;
70
+ if (f instanceof HTMLFormElement) {
71
+ __classPrivateFieldSet(this, _CmSaveBar_watched, f, "f");
72
+ f.addEventListener('input', __classPrivateFieldGet(this, _CmSaveBar_onDirty, "f"));
73
+ f.addEventListener('change', __classPrivateFieldGet(this, _CmSaveBar_onDirty, "f"));
74
+ f.addEventListener('reset', __classPrivateFieldGet(this, _CmSaveBar_onReset, "f"));
75
+ }
76
+ }, _CmSaveBar_unwatch = function _CmSaveBar_unwatch() {
77
+ const f = __classPrivateFieldGet(this, _CmSaveBar_watched, "f");
78
+ if (!f)
79
+ return;
80
+ f.removeEventListener('input', __classPrivateFieldGet(this, _CmSaveBar_onDirty, "f"));
81
+ f.removeEventListener('change', __classPrivateFieldGet(this, _CmSaveBar_onDirty, "f"));
82
+ f.removeEventListener('reset', __classPrivateFieldGet(this, _CmSaveBar_onReset, "f"));
83
+ __classPrivateFieldSet(this, _CmSaveBar_watched, null, "f");
84
+ }, _CmSaveBar_emit = function _CmSaveBar_emit(name) {
85
+ return this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, cancelable: true }));
86
+ }, _CmSaveBar_save = function _CmSaveBar_save() {
87
+ if (this.loading || this.saveDisabled)
88
+ return;
89
+ if (__classPrivateFieldGet(this, _CmSaveBar_instances, "m", _CmSaveBar_emit).call(this, 'cm-save') && __classPrivateFieldGet(this, _CmSaveBar_watched, "f"))
90
+ __classPrivateFieldGet(this, _CmSaveBar_watched, "f").requestSubmit();
91
+ }, _CmSaveBar_discard = function _CmSaveBar_discard() {
92
+ if (this.loading)
93
+ return;
94
+ if (__classPrivateFieldGet(this, _CmSaveBar_instances, "m", _CmSaveBar_emit).call(this, 'cm-discard') && __classPrivateFieldGet(this, _CmSaveBar_watched, "f")) {
95
+ __classPrivateFieldGet(this, _CmSaveBar_watched, "f").reset();
96
+ this.open = false;
97
+ }
98
+ };
99
+ CmSaveBar.properties = {
100
+ open: { type: Boolean, reflect: true },
101
+ message: {},
102
+ saveLabel: { attribute: 'save-label' },
103
+ discardLabel: { attribute: 'discard-label' },
104
+ loading: { type: Boolean, reflect: true },
105
+ saveDisabled: { type: Boolean, attribute: 'save-disabled' },
106
+ form: {},
107
+ };
108
+ CmSaveBar.styles = [
109
+ base,
110
+ css `
111
+ :host { display: block; position: sticky; bottom: 0; z-index: 20; }
112
+ :host(:not([open])) { display: none; }
113
+ .bar {
114
+ display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--cm-space-20);
115
+ min-height: 80px; padding: var(--cm-space-15) var(--cm-space-20);
116
+ background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-card);
117
+ border-radius: var(--cm-radius-md); box-shadow: var(--cm-shadow-100);
118
+ }
119
+ .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; }
121
+ @media (max-width: 640px) {
122
+ .bar { min-height: 68px; padding: var(--cm-space-10); gap: var(--cm-space-10); }
123
+ .message { font-size: 14px; font-weight: 500; }
124
+ .actions { gap: var(--cm-space-10); }
125
+ }
126
+ `,
127
+ ];
128
+ define('cm-save-bar', CmSaveBar);
@@ -0,0 +1,78 @@
1
+ import { LitElement } from 'lit';
2
+ import './icon.js';
3
+ /**
4
+ * Search box for the top of lists and tables, with an optional filter button.
5
+ * Participates in native forms.
6
+ * @element cm-search
7
+ * @fires input - On every keystroke, and when cleared.
8
+ * @fires change - When the value is committed (Enter or blur after typing, or clear).
9
+ * @fires cm-search - When the merchant presses Enter. `detail.value` is the query.
10
+ * @fires cm-filter - When the filter button is pressed. Open a filter panel in response.
11
+ */
12
+ export declare class CmSearch extends LitElement {
13
+ #private;
14
+ static formAssociated: boolean;
15
+ static shadowRootOptions: {
16
+ delegatesFocus: boolean;
17
+ mode: ShadowRootMode;
18
+ serializable?: boolean;
19
+ slotAssignment?: SlotAssignmentMode;
20
+ };
21
+ static properties: {
22
+ label: {};
23
+ name: {
24
+ reflect: boolean;
25
+ };
26
+ value: {};
27
+ placeholder: {};
28
+ filter: {
29
+ type: BooleanConstructor;
30
+ };
31
+ filterLabel: {
32
+ attribute: string;
33
+ };
34
+ filterCount: {
35
+ type: NumberConstructor;
36
+ attribute: string;
37
+ };
38
+ size: {
39
+ reflect: boolean;
40
+ };
41
+ disabled: {
42
+ type: BooleanConstructor;
43
+ reflect: boolean;
44
+ };
45
+ };
46
+ /** Accessible name, read by screen readers but not shown. Say what is searched: "Search orders". */
47
+ label: string;
48
+ /** Form field name. */
49
+ name: string;
50
+ /** Current query. Updated on every keystroke. */
51
+ value: string;
52
+ /** Example query, shown in text-tertiary. */
53
+ placeholder: string;
54
+ /** Shows the filter button at the end of the box. */
55
+ filter: boolean;
56
+ /** Accessible name of the filter button. */
57
+ filterLabel: string;
58
+ /** Number of filters applied; shown on the filter button when above 0. */
59
+ filterCount: number;
60
+ /** `default` is 42px (table headers, mobile); `large` is 46px (page-level search). */
61
+ size: 'default' | 'large';
62
+ /** Blocks interaction. Also set by a disabled `<fieldset>`. */
63
+ disabled: boolean;
64
+ static styles: import("lit").CSSResult[];
65
+ connectedCallback(): void;
66
+ get form(): HTMLFormElement | null;
67
+ checkValidity(): boolean;
68
+ formResetCallback(): void;
69
+ formDisabledCallback(d: boolean): void;
70
+ formStateRestoreCallback(state: string): void;
71
+ updated(): void;
72
+ render(): import("lit-html").TemplateResult<1>;
73
+ }
74
+ declare global {
75
+ interface HTMLElementTagNameMap {
76
+ 'cm-search': CmSearch;
77
+ }
78
+ }