@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.
- package/LICENSE.md +17 -0
- package/README.md +41 -2
- package/dist/base.d.ts +7 -0
- package/dist/base.js +22 -0
- package/dist/cdn.js +1958 -0
- package/dist/components/accordion.d.ts +43 -0
- package/dist/components/accordion.js +83 -0
- package/dist/components/action-bar.d.ts +42 -0
- package/dist/components/action-bar.js +84 -0
- package/dist/components/action-menu.d.ts +89 -0
- package/dist/components/action-menu.js +283 -0
- package/dist/components/app-card.d.ts +57 -0
- package/dist/components/app-card.js +100 -0
- package/dist/components/avatar.d.ts +48 -0
- package/dist/components/avatar.js +82 -0
- package/dist/components/badge.d.ts +23 -0
- package/dist/components/badge.js +35 -0
- package/dist/components/banner.d.ts +36 -0
- package/dist/components/banner.js +88 -0
- package/dist/components/bottom-navigation.d.ts +48 -0
- package/dist/components/bottom-navigation.js +98 -0
- package/dist/components/bottom-sheet.d.ts +54 -0
- package/dist/components/bottom-sheet.js +133 -0
- package/dist/components/button.d.ts +53 -0
- package/dist/components/button.js +101 -0
- package/dist/components/card.d.ts +37 -0
- package/dist/components/card.js +58 -0
- package/dist/components/checkbox.d.ts +68 -0
- package/dist/components/checkbox.js +114 -0
- package/dist/components/comment.d.ts +76 -0
- package/dist/components/comment.js +170 -0
- package/dist/components/data-table.d.ts +132 -0
- package/dist/components/data-table.js +331 -0
- package/dist/components/empty-state.d.ts +49 -0
- package/dist/components/empty-state.js +94 -0
- package/dist/components/file-upload.d.ts +102 -0
- package/dist/components/file-upload.js +243 -0
- package/dist/components/filter-panel.d.ts +86 -0
- package/dist/components/filter-panel.js +128 -0
- package/dist/components/flash-offer-bar.d.ts +34 -0
- package/dist/components/flash-offer-bar.js +73 -0
- package/dist/components/grid.d.ts +39 -0
- package/dist/components/grid.js +42 -0
- package/dist/components/header-bar.d.ts +48 -0
- package/dist/components/header-bar.js +121 -0
- package/dist/components/icon.d.ts +30 -0
- package/dist/components/icon.js +36 -0
- package/dist/components/info-panel.d.ts +63 -0
- package/dist/components/info-panel.js +108 -0
- package/dist/components/layout.d.ts +45 -0
- package/dist/components/layout.js +67 -0
- package/dist/components/link-tabs.d.ts +40 -0
- package/dist/components/link-tabs.js +85 -0
- package/dist/components/menu-item.d.ts +68 -0
- package/dist/components/menu-item.js +64 -0
- package/dist/components/mobile-menu.d.ts +69 -0
- package/dist/components/mobile-menu.js +184 -0
- package/dist/components/modal.d.ts +46 -0
- package/dist/components/modal.js +59 -0
- package/dist/components/nav-item.d.ts +98 -0
- package/dist/components/nav-item.js +84 -0
- package/dist/components/nested-list.d.ts +105 -0
- package/dist/components/nested-list.js +279 -0
- package/dist/components/notification-panel.d.ts +121 -0
- package/dist/components/notification-panel.js +174 -0
- package/dist/components/option-group.d.ts +74 -0
- package/dist/components/option-group.js +172 -0
- package/dist/components/page-header.d.ts +58 -0
- package/dist/components/page-header.js +121 -0
- package/dist/components/page.d.ts +34 -0
- package/dist/components/page.js +41 -0
- package/dist/components/pagination.d.ts +64 -0
- package/dist/components/pagination.js +160 -0
- package/dist/components/progress-bar.d.ts +45 -0
- package/dist/components/progress-bar.js +81 -0
- package/dist/components/radio.d.ts +131 -0
- package/dist/components/radio.js +252 -0
- package/dist/components/report-tile.d.ts +65 -0
- package/dist/components/report-tile.js +112 -0
- package/dist/components/resource-list.d.ts +143 -0
- package/dist/components/resource-list.js +335 -0
- package/dist/components/save-bar.d.ts +58 -0
- package/dist/components/save-bar.js +128 -0
- package/dist/components/search.d.ts +78 -0
- package/dist/components/search.js +144 -0
- package/dist/components/select.d.ts +106 -0
- package/dist/components/select.js +338 -0
- package/dist/components/side-navigation.d.ts +51 -0
- package/dist/components/side-navigation.js +194 -0
- package/dist/components/side-panel.d.ts +50 -0
- package/dist/components/side-panel.js +73 -0
- package/dist/components/skeleton-display.d.ts +32 -0
- package/dist/components/skeleton-display.js +70 -0
- package/dist/components/skeleton.d.ts +41 -0
- package/dist/components/skeleton.js +59 -0
- package/dist/components/smart-tip.d.ts +62 -0
- package/dist/components/smart-tip.js +128 -0
- package/dist/components/spinner.d.ts +27 -0
- package/dist/components/spinner.js +48 -0
- package/dist/components/stack.d.ts +45 -0
- package/dist/components/stack.js +49 -0
- package/dist/components/status-tabs.d.ts +65 -0
- package/dist/components/status-tabs.js +158 -0
- package/dist/components/table-header.d.ts +84 -0
- package/dist/components/table-header.js +151 -0
- package/dist/components/tag.d.ts +39 -0
- package/dist/components/tag.js +68 -0
- package/dist/components/text-field.d.ts +101 -0
- package/dist/components/text-field.js +162 -0
- package/dist/components/thumbnail.d.ts +40 -0
- package/dist/components/thumbnail.js +61 -0
- package/dist/components/toast.d.ts +108 -0
- package/dist/components/toast.js +268 -0
- package/dist/components/toggle.d.ts +60 -0
- package/dist/components/toggle.js +108 -0
- package/dist/components/tooltip.d.ts +56 -0
- package/dist/components/tooltip.js +267 -0
- package/dist/custom-elements.json +13222 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +56 -0
- package/dist/overlay.d.ts +57 -0
- package/dist/overlay.js +205 -0
- package/dist/spacing.d.ts +6 -0
- package/dist/spacing.js +7 -0
- package/package.json +59 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { base, define } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* A whole admin page: the page header across the top, then the content on `bg-page` with page padding
|
|
5
|
+
* (`space-20`, or `space-10` when the page is 640px wide or less).
|
|
6
|
+
* `<cm-page><cm-page-header slot="header" heading="Orders"></cm-page-header><cm-layout>…</cm-layout></cm-page>`
|
|
7
|
+
* @element cm-page
|
|
8
|
+
* @slot header - A `cm-page-header`. Runs edge to edge.
|
|
9
|
+
* @slot - The page content, usually a `cm-layout`.
|
|
10
|
+
* @slot footer - A `cm-save-bar` or `cm-action-bar`, after the content.
|
|
11
|
+
*/
|
|
12
|
+
export class CmPage extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
/** Lets the content use every pixel of width (wide tables, reports). By default it stops at 1600px, centred. */
|
|
16
|
+
this.fullWidth = false;
|
|
17
|
+
/** Content at most 800px wide, centred: for settings and single-column forms. */
|
|
18
|
+
this.narrow = false;
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
return html `<slot name="header"></slot><div class="content" part="content"><slot></slot></div><slot name="footer"></slot>`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
CmPage.properties = {
|
|
25
|
+
fullWidth: { type: Boolean, attribute: 'full-width', reflect: true },
|
|
26
|
+
narrow: { type: Boolean, reflect: true },
|
|
27
|
+
};
|
|
28
|
+
CmPage.styles = [
|
|
29
|
+
base,
|
|
30
|
+
css `
|
|
31
|
+
:host { display: block; container: cm-page / inline-size; background: var(--cm-bg-page); min-block-size: 100%; }
|
|
32
|
+
.content {
|
|
33
|
+
box-sizing: content-box; max-inline-size: 1600px; margin-inline: auto;
|
|
34
|
+
padding: var(--cm-space-20);
|
|
35
|
+
}
|
|
36
|
+
:host([narrow]) .content { max-inline-size: 800px; }
|
|
37
|
+
:host([full-width]) .content { max-inline-size: none; }
|
|
38
|
+
@container cm-page (max-width: 640px) { .content { padding: var(--cm-space-10); } }
|
|
39
|
+
`,
|
|
40
|
+
];
|
|
41
|
+
define('cm-page', CmPage);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import './icon.js';
|
|
3
|
+
/**
|
|
4
|
+
* Moves through a long list one page at a time. A 60px bar under a list or table: rows per page on
|
|
5
|
+
* the left, "Showing 21–40 of 290" in the middle, and "Page [n] of N" with previous/next arrows on
|
|
6
|
+
* the right. On phones only the page field and arrows remain.
|
|
7
|
+
*
|
|
8
|
+
* The component does not load data: listen for `cm-page-change` and `cm-page-size-change`, fetch,
|
|
9
|
+
* then set `page` (and `total`) yourself.
|
|
10
|
+
* @element cm-pagination
|
|
11
|
+
* @fires cm-page-change - `detail: { page }` when the merchant asks for another page.
|
|
12
|
+
* @fires cm-page-size-change - `detail: { pageSize }` when rows per page changes. `page` resets to 1.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CmPagination extends LitElement {
|
|
15
|
+
#private;
|
|
16
|
+
static properties: {
|
|
17
|
+
page: {
|
|
18
|
+
type: NumberConstructor;
|
|
19
|
+
reflect: boolean;
|
|
20
|
+
};
|
|
21
|
+
total: {
|
|
22
|
+
type: NumberConstructor;
|
|
23
|
+
};
|
|
24
|
+
pageSize: {
|
|
25
|
+
type: NumberConstructor;
|
|
26
|
+
attribute: string;
|
|
27
|
+
};
|
|
28
|
+
pageSizes: {
|
|
29
|
+
type: ArrayConstructor;
|
|
30
|
+
attribute: string;
|
|
31
|
+
};
|
|
32
|
+
label: {};
|
|
33
|
+
resourceName: {
|
|
34
|
+
attribute: string;
|
|
35
|
+
};
|
|
36
|
+
_draft: {
|
|
37
|
+
state: boolean;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/** Current page, starting at 1. */
|
|
41
|
+
page: number;
|
|
42
|
+
/** Total number of items across all pages. 0 hides the summary. */
|
|
43
|
+
total: number;
|
|
44
|
+
/** Items per page. */
|
|
45
|
+
pageSize: number;
|
|
46
|
+
/** Choices for "Number of rows". Empty hides the picker. JSON in the attribute: `page-sizes="[10,20,50]"`. */
|
|
47
|
+
pageSizes: number[];
|
|
48
|
+
/** Accessible name of the navigation landmark. Change it when a page has two paginations. */
|
|
49
|
+
label: string;
|
|
50
|
+
/** Plural noun used in the summary, e.g. "products": "Showing 21–40 of 290 products". */
|
|
51
|
+
resourceName: string;
|
|
52
|
+
_draft: string | null;
|
|
53
|
+
static styles: import("lit").CSSResult[];
|
|
54
|
+
/** Number of pages, at least 1. */
|
|
55
|
+
get pageCount(): number;
|
|
56
|
+
/** Moves to a page (clamped to 1…pageCount) and fires `cm-page-change` if it changed. */
|
|
57
|
+
goTo(page: number): void;
|
|
58
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
59
|
+
}
|
|
60
|
+
declare global {
|
|
61
|
+
interface HTMLElementTagNameMap {
|
|
62
|
+
'cm-pagination': CmPagination;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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 _CmPagination_instances, _CmPagination_id, _CmPagination_onSize, _CmPagination_onKey;
|
|
7
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
8
|
+
import { base, define, nextId } from '../base.js';
|
|
9
|
+
import './icon.js';
|
|
10
|
+
/**
|
|
11
|
+
* Moves through a long list one page at a time. A 60px bar under a list or table: rows per page on
|
|
12
|
+
* the left, "Showing 21–40 of 290" in the middle, and "Page [n] of N" with previous/next arrows on
|
|
13
|
+
* the right. On phones only the page field and arrows remain.
|
|
14
|
+
*
|
|
15
|
+
* The component does not load data: listen for `cm-page-change` and `cm-page-size-change`, fetch,
|
|
16
|
+
* then set `page` (and `total`) yourself.
|
|
17
|
+
* @element cm-pagination
|
|
18
|
+
* @fires cm-page-change - `detail: { page }` when the merchant asks for another page.
|
|
19
|
+
* @fires cm-page-size-change - `detail: { pageSize }` when rows per page changes. `page` resets to 1.
|
|
20
|
+
*/
|
|
21
|
+
export class CmPagination extends LitElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
_CmPagination_instances.add(this);
|
|
25
|
+
/** Current page, starting at 1. */
|
|
26
|
+
this.page = 1;
|
|
27
|
+
/** Total number of items across all pages. 0 hides the summary. */
|
|
28
|
+
this.total = 0;
|
|
29
|
+
/** Items per page. */
|
|
30
|
+
this.pageSize = 20;
|
|
31
|
+
/** Choices for "Number of rows". Empty hides the picker. JSON in the attribute: `page-sizes="[10,20,50]"`. */
|
|
32
|
+
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
|
+
/** Plural noun used in the summary, e.g. "products": "Showing 21–40 of 290 products". */
|
|
36
|
+
this.resourceName = '';
|
|
37
|
+
this._draft = null;
|
|
38
|
+
_CmPagination_id.set(this, nextId('cm-pg'));
|
|
39
|
+
}
|
|
40
|
+
/** Number of pages, at least 1. */
|
|
41
|
+
get pageCount() {
|
|
42
|
+
return Math.max(1, Math.ceil((this.total || 0) / Math.max(1, this.pageSize)));
|
|
43
|
+
}
|
|
44
|
+
/** Moves to a page (clamped to 1…pageCount) and fires `cm-page-change` if it changed. */
|
|
45
|
+
goTo(page) {
|
|
46
|
+
const p = Math.min(this.pageCount, Math.max(1, Math.round(page) || 1));
|
|
47
|
+
this._draft = null;
|
|
48
|
+
if (p === this.page) {
|
|
49
|
+
this.requestUpdate();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.page = p;
|
|
53
|
+
this.dispatchEvent(new CustomEvent('cm-page-change', { detail: { page: p }, bubbles: true, composed: true }));
|
|
54
|
+
}
|
|
55
|
+
render() {
|
|
56
|
+
const count = this.pageCount;
|
|
57
|
+
const page = Math.min(count, Math.max(1, this.page));
|
|
58
|
+
const from = this.total ? (page - 1) * this.pageSize + 1 : 0;
|
|
59
|
+
const to = Math.min(this.total, page * this.pageSize);
|
|
60
|
+
const fmt = (n) => n.toLocaleString();
|
|
61
|
+
const sizes = this.pageSizes ?? [];
|
|
62
|
+
const noun = this.resourceName ? ` ${this.resourceName}` : '';
|
|
63
|
+
return html `
|
|
64
|
+
<nav part="bar" aria-label=${this.label}>
|
|
65
|
+
${sizes.length
|
|
66
|
+
? html `<div class="rows" part="rows">
|
|
67
|
+
<label for="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-s">Number of rows</label>
|
|
68
|
+
<span class="field"><select id="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-s" @change=${__classPrivateFieldGet(this, _CmPagination_instances, "m", _CmPagination_onSize)}>
|
|
69
|
+
${(sizes.includes(this.pageSize) ? sizes : [...sizes, this.pageSize].sort((a, b) => a - b))
|
|
70
|
+
.map((s) => html `<option value=${s} ?selected=${s === this.pageSize}>${s}</option>`)}
|
|
71
|
+
</select><cm-icon name="chevron-down" size="12"></cm-icon></span>
|
|
72
|
+
</div>`
|
|
73
|
+
: nothing}
|
|
74
|
+
<div class="summary" part="summary" role="status">${this.total ? `Showing ${fmt(from)}–${fmt(to)} of ${fmt(this.total)}${noun}` : nothing}</div>
|
|
75
|
+
<div class="pages" part="pages">
|
|
76
|
+
<span class="counter">
|
|
77
|
+
<label for="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-p">Page</label>
|
|
78
|
+
<input id="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-p" type="number" inputmode="numeric" min="1" max=${count}
|
|
79
|
+
.value=${this._draft ?? String(page)} aria-describedby="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-of"
|
|
80
|
+
@input=${(e) => (this._draft = e.target.value)}
|
|
81
|
+
@keydown=${__classPrivateFieldGet(this, _CmPagination_instances, "m", _CmPagination_onKey)}
|
|
82
|
+
@change=${(e) => this.goTo(Number(e.target.value))} />
|
|
83
|
+
<span id="${__classPrivateFieldGet(this, _CmPagination_id, "f")}-of">of ${fmt(count)}</span>
|
|
84
|
+
</span>
|
|
85
|
+
<span class="arrows">
|
|
86
|
+
<button class="prev" type="button" part="previous" aria-label="Previous page" ?disabled=${page <= 1}
|
|
87
|
+
@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}
|
|
89
|
+
@click=${() => this.goTo(page + 1)}><cm-icon name="chevron-right" size="12"></cm-icon></button>
|
|
90
|
+
</span>
|
|
91
|
+
</div>
|
|
92
|
+
</nav>
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
_CmPagination_id = new WeakMap(), _CmPagination_instances = new WeakSet(), _CmPagination_onSize = function _CmPagination_onSize(e) {
|
|
97
|
+
const size = Number(e.target.value);
|
|
98
|
+
if (size === this.pageSize)
|
|
99
|
+
return;
|
|
100
|
+
this.pageSize = size;
|
|
101
|
+
this.page = 1;
|
|
102
|
+
this.dispatchEvent(new CustomEvent('cm-page-size-change', { detail: { pageSize: size }, bubbles: true, composed: true }));
|
|
103
|
+
}, _CmPagination_onKey = function _CmPagination_onKey(e) {
|
|
104
|
+
if (e.key === 'Enter') {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
this.goTo(Number(e.target.value));
|
|
107
|
+
}
|
|
108
|
+
else if (e.key === 'Escape') {
|
|
109
|
+
this._draft = null;
|
|
110
|
+
e.target.value = String(this.page);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
CmPagination.properties = {
|
|
114
|
+
page: { type: Number, reflect: true },
|
|
115
|
+
total: { type: Number },
|
|
116
|
+
pageSize: { type: Number, attribute: 'page-size' },
|
|
117
|
+
pageSizes: { type: Array, attribute: 'page-sizes' },
|
|
118
|
+
label: {},
|
|
119
|
+
resourceName: { attribute: 'resource-name' },
|
|
120
|
+
_draft: { state: true },
|
|
121
|
+
};
|
|
122
|
+
CmPagination.styles = [
|
|
123
|
+
base,
|
|
124
|
+
css `
|
|
125
|
+
:host { display: block; }
|
|
126
|
+
nav {
|
|
127
|
+
display: flex; align-items: center; gap: var(--cm-space-20); min-height: 60px; padding: 0 var(--cm-space-20);
|
|
128
|
+
background: var(--cm-bg-surface); border-radius: var(--cm-radius-md); font-size: 14px;
|
|
129
|
+
}
|
|
130
|
+
.rows, .pages, .counter { display: flex; align-items: center; gap: var(--cm-space-10); white-space: nowrap; }
|
|
131
|
+
.summary { flex: 1; text-align: center; white-space: nowrap; }
|
|
132
|
+
.field { position: relative; display: inline-flex; }
|
|
133
|
+
select, input {
|
|
134
|
+
height: 34px; font: inherit; font-weight: 500; color: var(--cm-text-default); background: var(--cm-bg-surface);
|
|
135
|
+
border: var(--cm-border-1) solid var(--cm-border-input); border-radius: var(--cm-radius-sm);
|
|
136
|
+
}
|
|
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; }
|
|
139
|
+
input { width: 38px; padding: 0; text-align: center; -moz-appearance: textfield; }
|
|
140
|
+
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
|
|
141
|
+
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); }
|
|
143
|
+
button {
|
|
144
|
+
width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
|
|
145
|
+
color: var(--cm-icon-selected); background: var(--cm-bg-hover);
|
|
146
|
+
border: var(--cm-border-1) solid var(--cm-border-subtle); border-radius: var(--cm-radius-sm);
|
|
147
|
+
}
|
|
148
|
+
button:hover:not(:disabled) { border-color: var(--cm-border-strong); }
|
|
149
|
+
button:disabled { color: var(--cm-text-secondary); cursor: not-allowed; }
|
|
150
|
+
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
151
|
+
@media (max-width: 640px) {
|
|
152
|
+
nav { min-height: 50px; padding: 0 var(--cm-space-10); justify-content: space-between; }
|
|
153
|
+
.rows, .summary { display: none; }
|
|
154
|
+
.pages { flex: 1; justify-content: space-between; }
|
|
155
|
+
.arrows { display: contents; }
|
|
156
|
+
.prev { order: -1; }
|
|
157
|
+
}
|
|
158
|
+
`,
|
|
159
|
+
];
|
|
160
|
+
define('cm-pagination', CmPagination);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Shows how far a longer task has got (an import, an upload, a bulk update), or that it is running when the
|
|
4
|
+
* amount is unknown. A WAI-ARIA progressbar.
|
|
5
|
+
* @element cm-progress-bar
|
|
6
|
+
*/
|
|
7
|
+
export declare class CmProgressBar extends LitElement {
|
|
8
|
+
#private;
|
|
9
|
+
static properties: {
|
|
10
|
+
value: {
|
|
11
|
+
type: NumberConstructor;
|
|
12
|
+
};
|
|
13
|
+
label: {};
|
|
14
|
+
labelHidden: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
attribute: string;
|
|
17
|
+
};
|
|
18
|
+
showValue: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
attribute: string;
|
|
21
|
+
};
|
|
22
|
+
size: {
|
|
23
|
+
reflect: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/** Percent done, 0–100. Leave unset (or `null`) for an indeterminate bar when the amount is unknown. */
|
|
27
|
+
value: number | null;
|
|
28
|
+
/** What is in progress, shown above the bar and used as its accessible name. Required. */
|
|
29
|
+
label: string;
|
|
30
|
+
/** Keeps the label for screen readers only, when the surrounding text already says what is running. */
|
|
31
|
+
labelHidden: boolean;
|
|
32
|
+
/** Shows the percentage next to the label. Determinate bars only. */
|
|
33
|
+
showValue: boolean;
|
|
34
|
+
/** `small` (4px) inside rows and cards; `medium` (8px) for a page-level task. */
|
|
35
|
+
size: 'small' | 'medium';
|
|
36
|
+
static styles: import("lit").CSSResult[];
|
|
37
|
+
/** The value clamped to 0–100, or `null` when indeterminate. */
|
|
38
|
+
get clampedValue(): number | null;
|
|
39
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface HTMLElementTagNameMap {
|
|
43
|
+
'cm-progress-bar': CmProgressBar;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 _CmProgressBar_id;
|
|
7
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
8
|
+
import { base, define, nextId } from '../base.js';
|
|
9
|
+
/**
|
|
10
|
+
* Shows how far a longer task has got (an import, an upload, a bulk update), or that it is running when the
|
|
11
|
+
* amount is unknown. A WAI-ARIA progressbar.
|
|
12
|
+
* @element cm-progress-bar
|
|
13
|
+
*/
|
|
14
|
+
export class CmProgressBar extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
/** Percent done, 0–100. Leave unset (or `null`) for an indeterminate bar when the amount is unknown. */
|
|
18
|
+
this.value = null;
|
|
19
|
+
/** What is in progress, shown above the bar and used as its accessible name. Required. */
|
|
20
|
+
this.label = '';
|
|
21
|
+
/** Keeps the label for screen readers only, when the surrounding text already says what is running. */
|
|
22
|
+
this.labelHidden = false;
|
|
23
|
+
/** Shows the percentage next to the label. Determinate bars only. */
|
|
24
|
+
this.showValue = false;
|
|
25
|
+
/** `small` (4px) inside rows and cards; `medium` (8px) for a page-level task. */
|
|
26
|
+
this.size = 'medium';
|
|
27
|
+
_CmProgressBar_id.set(this, nextId('cm-progress'));
|
|
28
|
+
}
|
|
29
|
+
/** The value clamped to 0–100, or `null` when indeterminate. */
|
|
30
|
+
get clampedValue() {
|
|
31
|
+
const v = this.value;
|
|
32
|
+
if (v === null || v === undefined || Number.isNaN(Number(v)))
|
|
33
|
+
return null;
|
|
34
|
+
return Math.min(100, Math.max(0, Number(v)));
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
const v = this.clampedValue;
|
|
38
|
+
const labelId = `${__classPrivateFieldGet(this, _CmProgressBar_id, "f")}-label`;
|
|
39
|
+
return html `
|
|
40
|
+
<div class="head ${this.labelHidden ? 'vh' : ''}">
|
|
41
|
+
<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}
|
|
43
|
+
</div>
|
|
44
|
+
<div class="track ${v === null ? 'indeterminate' : ''}" part="track" role="progressbar"
|
|
45
|
+
aria-labelledby=${labelId} aria-valuemin="0" aria-valuemax="100"
|
|
46
|
+
aria-valuenow=${v === null ? nothing : Math.round(v)}
|
|
47
|
+
aria-valuetext=${v === null ? 'In progress' : `${Math.round(v)}%`}>
|
|
48
|
+
<div class="fill" part="fill" style=${v === null ? '' : `inline-size:${v}%`}></div>
|
|
49
|
+
</div>`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
_CmProgressBar_id = new WeakMap();
|
|
53
|
+
CmProgressBar.properties = {
|
|
54
|
+
value: { type: Number },
|
|
55
|
+
label: {},
|
|
56
|
+
labelHidden: { type: Boolean, attribute: 'label-hidden' },
|
|
57
|
+
showValue: { type: Boolean, attribute: 'show-value' },
|
|
58
|
+
size: { reflect: true },
|
|
59
|
+
};
|
|
60
|
+
CmProgressBar.styles = [
|
|
61
|
+
base,
|
|
62
|
+
css `
|
|
63
|
+
:host { display: block; }
|
|
64
|
+
.head { display: flex; justify-content: space-between; gap: var(--cm-space-10); margin-block-end: 6px; font-size: 14px; line-height: 20px; }
|
|
65
|
+
.value { color: var(--cm-text-tertiary); font-variant-numeric: tabular-nums; }
|
|
66
|
+
.vh {
|
|
67
|
+
position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; overflow: hidden;
|
|
68
|
+
clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
|
|
69
|
+
}
|
|
70
|
+
.track { position: relative; block-size: 8px; border-radius: var(--cm-radius-full); background: var(--cm-bg-inset); overflow: hidden; box-shadow: inset 0 0 0 1px var(--cm-border-default); }
|
|
71
|
+
:host([size='small']) .track { block-size: 4px; }
|
|
72
|
+
.fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: inherit; background: var(--cm-action-primary); transition: inline-size 0.2s ease; }
|
|
73
|
+
.indeterminate .fill { inline-size: 35%; animation: slide 1.4s ease-in-out infinite; }
|
|
74
|
+
@keyframes slide { from { inset-inline-start: -35%; } to { inset-inline-start: 100%; } }
|
|
75
|
+
@media (prefers-reduced-motion: reduce) {
|
|
76
|
+
.fill { transition: none; }
|
|
77
|
+
.indeterminate .fill { animation-duration: 4s; }
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
];
|
|
81
|
+
define('cm-progress-bar', CmProgressBar);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* One option in a `<cm-radio-group>`. On its own it does nothing: the group owns
|
|
4
|
+
* the value, the keyboard behaviour and the form submission.
|
|
5
|
+
* @element cm-radio
|
|
6
|
+
* @slot - Rich label content, used instead of `label`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CmRadio extends LitElement {
|
|
9
|
+
#private;
|
|
10
|
+
static shadowRootOptions: {
|
|
11
|
+
delegatesFocus: boolean;
|
|
12
|
+
mode: ShadowRootMode;
|
|
13
|
+
serializable?: boolean;
|
|
14
|
+
slotAssignment?: SlotAssignmentMode;
|
|
15
|
+
};
|
|
16
|
+
static properties: {
|
|
17
|
+
label: {};
|
|
18
|
+
description: {};
|
|
19
|
+
value: {
|
|
20
|
+
reflect: boolean;
|
|
21
|
+
};
|
|
22
|
+
checked: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
reflect: boolean;
|
|
25
|
+
};
|
|
26
|
+
disabled: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
reflect: boolean;
|
|
29
|
+
};
|
|
30
|
+
groupDisabled: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
reflect: boolean;
|
|
33
|
+
attribute: string;
|
|
34
|
+
};
|
|
35
|
+
_tabbable: {
|
|
36
|
+
state: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/** Visible label. Write it in sentence case. */
|
|
40
|
+
label: string;
|
|
41
|
+
/** Help text under the label, linked for screen readers. */
|
|
42
|
+
description: string;
|
|
43
|
+
/** The group's value when this option is selected. */
|
|
44
|
+
value: string;
|
|
45
|
+
/** Selected. Set by the group; set it in markup to choose the initial option. */
|
|
46
|
+
checked: boolean;
|
|
47
|
+
/** This option can't be chosen. Arrow keys skip it. */
|
|
48
|
+
disabled: boolean;
|
|
49
|
+
/** @internal Set by a disabled group. */
|
|
50
|
+
groupDisabled: boolean;
|
|
51
|
+
/** @internal Roving tab stop, managed by the group. */
|
|
52
|
+
_tabbable: boolean;
|
|
53
|
+
static styles: import("lit").CSSResult[];
|
|
54
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A set of `<cm-radio>` options where exactly one can be chosen. Behaves like a native radio group:
|
|
58
|
+
* one tab stop, arrow keys move and select, and the form receives the selected value.
|
|
59
|
+
* @element cm-radio-group
|
|
60
|
+
* @slot - The `<cm-radio>` options.
|
|
61
|
+
* @slot label - Rich label content, used instead of `label`.
|
|
62
|
+
* @fires change - When the merchant picks a different option.
|
|
63
|
+
* @fires input - Same moment as `change`, for frameworks that listen to `input`.
|
|
64
|
+
*/
|
|
65
|
+
export declare class CmRadioGroup extends LitElement {
|
|
66
|
+
#private;
|
|
67
|
+
static formAssociated: boolean;
|
|
68
|
+
static properties: {
|
|
69
|
+
label: {};
|
|
70
|
+
helpText: {
|
|
71
|
+
attribute: string;
|
|
72
|
+
};
|
|
73
|
+
error: {
|
|
74
|
+
reflect: boolean;
|
|
75
|
+
};
|
|
76
|
+
name: {
|
|
77
|
+
reflect: boolean;
|
|
78
|
+
};
|
|
79
|
+
value: {
|
|
80
|
+
reflect: boolean;
|
|
81
|
+
};
|
|
82
|
+
orientation: {
|
|
83
|
+
reflect: boolean;
|
|
84
|
+
};
|
|
85
|
+
required: {
|
|
86
|
+
type: BooleanConstructor;
|
|
87
|
+
reflect: boolean;
|
|
88
|
+
};
|
|
89
|
+
disabled: {
|
|
90
|
+
type: BooleanConstructor;
|
|
91
|
+
reflect: boolean;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/** Question above the options. Required for accessibility unless the group has an aria-label. */
|
|
95
|
+
label: string;
|
|
96
|
+
/** One sentence under the label in text-tertiary. */
|
|
97
|
+
helpText: string;
|
|
98
|
+
/** Error message; announced and linked to the group. */
|
|
99
|
+
error: string;
|
|
100
|
+
/** Form field name. */
|
|
101
|
+
name: string;
|
|
102
|
+
/** Value of the selected option; empty when nothing is selected. */
|
|
103
|
+
value: string;
|
|
104
|
+
/** `vertical` stacks options `space-20` apart; `horizontal` puts them in a row `space-30` apart. */
|
|
105
|
+
orientation: 'vertical' | 'horizontal';
|
|
106
|
+
/** The form will not submit until an option is chosen. */
|
|
107
|
+
required: boolean;
|
|
108
|
+
/** Blocks every option. Also set by a disabled `<fieldset>`. */
|
|
109
|
+
disabled: boolean;
|
|
110
|
+
static styles: import("lit").CSSResult[];
|
|
111
|
+
constructor();
|
|
112
|
+
connectedCallback(): void;
|
|
113
|
+
get form(): HTMLFormElement | null;
|
|
114
|
+
get validity(): ValidityState;
|
|
115
|
+
get validationMessage(): string;
|
|
116
|
+
checkValidity(): boolean;
|
|
117
|
+
reportValidity(): boolean;
|
|
118
|
+
formResetCallback(): void;
|
|
119
|
+
formDisabledCallback(d: boolean): void;
|
|
120
|
+
formStateRestoreCallback(state: string): void;
|
|
121
|
+
/** Focuses the selected option, or the first one. */
|
|
122
|
+
focus(options?: FocusOptions): void;
|
|
123
|
+
updated(changed: Map<string, unknown>): void;
|
|
124
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
125
|
+
}
|
|
126
|
+
declare global {
|
|
127
|
+
interface HTMLElementTagNameMap {
|
|
128
|
+
'cm-radio': CmRadio;
|
|
129
|
+
'cm-radio-group': CmRadioGroup;
|
|
130
|
+
}
|
|
131
|
+
}
|