@commmerce/ui 0.0.0-stage → 1.0.0-rc.4
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,194 @@
|
|
|
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 _CmSideNavigation_instances, _CmSideNavigation_seen, _CmSideNavigation_observer, _CmSideNavigation_id, _CmSideNavigation_read, _CmSideNavigation_key, _CmSideNavigation_choose, _CmSideNavigation_focusables, _CmSideNavigation_onKeyDown, _CmSideNavigation_flatten, _CmSideNavigation_link;
|
|
13
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
14
|
+
import { base, define, nextId } from '../base.js';
|
|
15
|
+
import { readNavItems, watchNavItems, hasCurrent, fireNavigate, navValue } from './nav-item.js';
|
|
16
|
+
import './icon.js';
|
|
17
|
+
/**
|
|
18
|
+
* The admin's main menu: a black rounded panel down the left of the page, with an icon and a label per
|
|
19
|
+
* destination and sections that open to show their sub-items. For Commmerce products only, not for apps:
|
|
20
|
+
* apps are shown inside the admin, which already has this menu.
|
|
21
|
+
*
|
|
22
|
+
* Items come from `cm-nav-item` children or the `items` property, so every Commmerce product can use it.
|
|
23
|
+
* @element cm-side-navigation
|
|
24
|
+
* @slot - `cm-nav-item` elements (nest them for sub-items).
|
|
25
|
+
* @slot header - Optional content above the items, such as a store switcher on narrow layouts.
|
|
26
|
+
* @slot footer - Optional content below the items.
|
|
27
|
+
* @fires cm-navigate - When an item is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app instead of following the link.
|
|
28
|
+
* @fires cm-expand - When a section opens or closes. `detail: { item, expanded }`.
|
|
29
|
+
*/
|
|
30
|
+
export class CmSideNavigation extends LitElement {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
_CmSideNavigation_instances.add(this);
|
|
34
|
+
/** Items as data. Used instead of `cm-nav-item` children when set. */
|
|
35
|
+
this.items = [];
|
|
36
|
+
/** Accessible name of the navigation landmark. */
|
|
37
|
+
this.label = 'Main';
|
|
38
|
+
this._slotted = [];
|
|
39
|
+
this._open = new Set();
|
|
40
|
+
_CmSideNavigation_seen.set(this, new Set());
|
|
41
|
+
_CmSideNavigation_observer.set(this, void 0);
|
|
42
|
+
_CmSideNavigation_id.set(this, nextId('cm-sidenav'));
|
|
43
|
+
}
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
super.connectedCallback();
|
|
46
|
+
__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_read).call(this);
|
|
47
|
+
__classPrivateFieldSet(this, _CmSideNavigation_observer, watchNavItems(this, () => __classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_read).call(this)), "f");
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
super.disconnectedCallback();
|
|
51
|
+
__classPrivateFieldGet(this, _CmSideNavigation_observer, "f")?.disconnect();
|
|
52
|
+
}
|
|
53
|
+
/** The items in use. */
|
|
54
|
+
get navItems() { return this.items.length ? this.items : this._slotted; }
|
|
55
|
+
willUpdate() {
|
|
56
|
+
// Sections open when they hold the current page or ask to, the first time they are seen.
|
|
57
|
+
this.navItems.forEach((it, i) => {
|
|
58
|
+
const k = __classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_key).call(this, it, i);
|
|
59
|
+
if (__classPrivateFieldGet(this, _CmSideNavigation_seen, "f").has(k) || !it.items?.length)
|
|
60
|
+
return;
|
|
61
|
+
__classPrivateFieldGet(this, _CmSideNavigation_seen, "f").add(k);
|
|
62
|
+
if (it.expanded || hasCurrent(it))
|
|
63
|
+
this._open.add(k);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** Opens or closes the section at `index`. */
|
|
67
|
+
toggle(index, open) {
|
|
68
|
+
const it = this.navItems[index];
|
|
69
|
+
if (!it?.items?.length)
|
|
70
|
+
return;
|
|
71
|
+
const k = __classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_key).call(this, it, index);
|
|
72
|
+
const next = open ?? !this._open.has(k);
|
|
73
|
+
if (next === this._open.has(k))
|
|
74
|
+
return;
|
|
75
|
+
const s = new Set(this._open);
|
|
76
|
+
next ? s.add(k) : s.delete(k);
|
|
77
|
+
this._open = s;
|
|
78
|
+
this.dispatchEvent(new CustomEvent('cm-expand', { bubbles: true, composed: true, detail: { item: it, expanded: next } }));
|
|
79
|
+
}
|
|
80
|
+
render() {
|
|
81
|
+
return html `
|
|
82
|
+
<nav part="nav" aria-label=${this.label || 'Main'} @keydown=${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_onKeyDown)}>
|
|
83
|
+
<slot name="header"></slot>
|
|
84
|
+
<ul part="list">
|
|
85
|
+
${this.navItems.map((it, i) => {
|
|
86
|
+
if (!it.items?.length)
|
|
87
|
+
return html `<li>${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_link).call(this, it, '', { index: i })}</li>`;
|
|
88
|
+
const open = this._open.has(__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_key).call(this, it, i));
|
|
89
|
+
const sub = `${__classPrivateFieldGet(this, _CmSideNavigation_id, "f")}-${i}`;
|
|
90
|
+
return html `<li>
|
|
91
|
+
<button type="button" class="item parent ${hasCurrent(it) ? 'has-current' : ''}" part="item" data-index=${i}
|
|
92
|
+
aria-expanded=${open ? 'true' : 'false'} aria-controls=${sub} @click=${() => this.toggle(i)}>
|
|
93
|
+
${it.icon ? html `<cm-icon name=${it.icon} size="20"></cm-icon>` : nothing}<span class="label">${it.label}</span>${it.badge ? html `<span class="badge">${it.badge}</span>` : nothing}
|
|
94
|
+
<cm-icon class="chev" name="chevron-down" size="18"></cm-icon>
|
|
95
|
+
</button>
|
|
96
|
+
<ul class="sub" id=${sub} ?hidden=${!open} aria-label=${it.label}>
|
|
97
|
+
${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_flatten).call(this, it.items).map(([s, d]) => html `<li>${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_link).call(this, { ...s, icon: undefined }, d ? 'deep' : '', { parent: i })}</li>`)}
|
|
98
|
+
</ul>
|
|
99
|
+
</li>`;
|
|
100
|
+
})}
|
|
101
|
+
</ul>
|
|
102
|
+
<slot name="footer"></slot>
|
|
103
|
+
<slot hidden></slot>
|
|
104
|
+
</nav>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_CmSideNavigation_seen = new WeakMap(), _CmSideNavigation_observer = new WeakMap(), _CmSideNavigation_id = new WeakMap(), _CmSideNavigation_instances = new WeakSet(), _CmSideNavigation_read = function _CmSideNavigation_read() { this._slotted = readNavItems(this); }, _CmSideNavigation_key = function _CmSideNavigation_key(it, i) { return `${i}:${navValue(it)}`; }, _CmSideNavigation_choose = function _CmSideNavigation_choose(e, it) {
|
|
109
|
+
if (!fireNavigate(this, it))
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
}, _CmSideNavigation_focusables = function _CmSideNavigation_focusables() {
|
|
112
|
+
return [...this.renderRoot.querySelectorAll('.item')].filter((el) => !el.closest('[hidden]'));
|
|
113
|
+
}, _CmSideNavigation_onKeyDown = function _CmSideNavigation_onKeyDown(e) {
|
|
114
|
+
const t = e.composedPath()[0]?.closest?.('.item');
|
|
115
|
+
if (!t)
|
|
116
|
+
return;
|
|
117
|
+
const all = __classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_focusables).call(this);
|
|
118
|
+
const i = all.indexOf(t);
|
|
119
|
+
const idx = Number(t.dataset.index);
|
|
120
|
+
let next;
|
|
121
|
+
if (e.key === 'ArrowDown')
|
|
122
|
+
next = all[(i + 1) % all.length];
|
|
123
|
+
else if (e.key === 'ArrowUp')
|
|
124
|
+
next = all[(i - 1 + all.length) % all.length];
|
|
125
|
+
else if (e.key === 'Home')
|
|
126
|
+
next = all[0];
|
|
127
|
+
else if (e.key === 'End')
|
|
128
|
+
next = all[all.length - 1];
|
|
129
|
+
else if (e.key === 'ArrowRight' && t.classList.contains('parent')) {
|
|
130
|
+
this.toggle(idx, true);
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
else if (e.key === 'ArrowLeft') {
|
|
135
|
+
if (t.classList.contains('parent'))
|
|
136
|
+
this.toggle(idx, false);
|
|
137
|
+
else if (t.dataset.parent)
|
|
138
|
+
next = this.renderRoot.querySelector(`.parent[data-index="${t.dataset.parent}"]`) ?? undefined;
|
|
139
|
+
if (!next) {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else
|
|
145
|
+
return;
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
next?.focus();
|
|
148
|
+
}, _CmSideNavigation_flatten = function _CmSideNavigation_flatten(items, depth = 0) {
|
|
149
|
+
return items.flatMap((it) => [[it, depth], ...__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_flatten).call(this, it.items ?? [], depth + 1)]);
|
|
150
|
+
}, _CmSideNavigation_link = function _CmSideNavigation_link(it, cls, extra = {}) {
|
|
151
|
+
const inner = html `${it.icon ? html `<cm-icon name=${it.icon} size="20"></cm-icon>` : nothing}<span class="label">${it.label}</span>${it.badge ? html `<span class="badge">${it.badge}</span>` : nothing}`;
|
|
152
|
+
return it.href
|
|
153
|
+
? html `<a class="item ${cls}" part="item" href=${it.href} aria-current=${it.current ? 'page' : nothing}
|
|
154
|
+
data-index=${extra.index ?? nothing} data-parent=${extra.parent ?? nothing} @click=${(e) => __classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_choose).call(this, e, it)}>${inner}</a>`
|
|
155
|
+
: html `<button type="button" class="item ${cls}" part="item" aria-current=${it.current ? 'page' : nothing}
|
|
156
|
+
data-index=${extra.index ?? nothing} data-parent=${extra.parent ?? nothing} @click=${(e) => __classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_choose).call(this, e, it)}>${inner}</button>`;
|
|
157
|
+
};
|
|
158
|
+
CmSideNavigation.properties = {
|
|
159
|
+
items: { type: Array },
|
|
160
|
+
label: {},
|
|
161
|
+
_slotted: { state: true },
|
|
162
|
+
_open: { state: true },
|
|
163
|
+
};
|
|
164
|
+
CmSideNavigation.styles = [
|
|
165
|
+
base,
|
|
166
|
+
css `
|
|
167
|
+
:host { display: block; width: var(--cm-side-navigation-width, 250px); }
|
|
168
|
+
nav {
|
|
169
|
+
background: var(--cm-bg-dashboard); color: var(--cm-text-on-dark-secondary); border-radius: 16px;
|
|
170
|
+
padding: 14px 0; font-size: 16px; line-height: 1.25;
|
|
171
|
+
}
|
|
172
|
+
ul { list-style: none; margin: 0; padding: 0; }
|
|
173
|
+
.item {
|
|
174
|
+
display: flex; align-items: center; gap: 8px; width: calc(100% - 16px); min-height: 40px; margin: 0 8px; padding: 0 10px 0 12px;
|
|
175
|
+
font: inherit; color: inherit; text-align: start; text-decoration: none; background: none; border: 0; border-radius: 8px; cursor: pointer;
|
|
176
|
+
}
|
|
177
|
+
.item:hover { color: var(--cm-text-on-dark); background: var(--cm-nav-active); }
|
|
178
|
+
.item:focus-visible { outline: 2px solid var(--cm-text-on-dark); outline-offset: -2px; color: var(--cm-text-on-dark); }
|
|
179
|
+
.item[aria-current='page'] { color: var(--cm-text-on-dark); font-weight: 600; }
|
|
180
|
+
.parent.has-current { color: var(--cm-text-on-dark); }
|
|
181
|
+
.label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
182
|
+
.chev { transition: transform 0.15s; }
|
|
183
|
+
[aria-expanded='true'] .chev { transform: rotate(180deg); }
|
|
184
|
+
.badge {
|
|
185
|
+
flex: none; padding: 1px 6px; border-radius: var(--cm-radius-full); font-size: 10px; font-weight: 500;
|
|
186
|
+
letter-spacing: var(--cm-tracking-caps); text-transform: uppercase; color: var(--cm-text-on-dark); background: var(--cm-nav-badge);
|
|
187
|
+
}
|
|
188
|
+
.sub { padding: 2px 0 6px; }
|
|
189
|
+
.sub .item { min-height: 36px; padding-left: 40px; font-size: 14px; }
|
|
190
|
+
.sub .item.deep { padding-left: 56px; }
|
|
191
|
+
@media (prefers-reduced-motion: reduce) { .chev { transition: none; } }
|
|
192
|
+
`,
|
|
193
|
+
];
|
|
194
|
+
define('cm-side-navigation', CmSideNavigation);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CmOverlay } from '../overlay.js';
|
|
2
|
+
/**
|
|
3
|
+
* A panel that slides over the right edge of the page to show the details of one item (an enquiry, an
|
|
4
|
+
* order, a customer) without leaving the list. A black header with the title and a close button, the
|
|
5
|
+
* content, and an optional footer. On phones it becomes a card inset 16px from the screen edges.
|
|
6
|
+
*
|
|
7
|
+
* A native modal `<dialog>`: the page behind is inert, Esc and the backdrop ask to close through
|
|
8
|
+
* `cm-close`, page scrolling is locked, and focus returns to the opener.
|
|
9
|
+
* @element cm-side-panel
|
|
10
|
+
* @slot - The content.
|
|
11
|
+
* @slot footer - Actions at the bottom, right-aligned.
|
|
12
|
+
* @fires cm-open - After the panel opens.
|
|
13
|
+
* @fires cm-close - Before it closes from Esc, the backdrop or the close button. `detail: { reason }`. Cancelable.
|
|
14
|
+
* @fires cm-closed - After it has closed and focus has gone back.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CmSidePanel extends CmOverlay {
|
|
17
|
+
#private;
|
|
18
|
+
static properties: {
|
|
19
|
+
size: {
|
|
20
|
+
reflect: boolean;
|
|
21
|
+
};
|
|
22
|
+
_hasFooter: {
|
|
23
|
+
state: boolean;
|
|
24
|
+
};
|
|
25
|
+
open: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
reflect: boolean;
|
|
28
|
+
};
|
|
29
|
+
heading: {};
|
|
30
|
+
label: {};
|
|
31
|
+
closeLabel: {
|
|
32
|
+
attribute: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/** Width on larger screens: `small` (380px), `medium` (450px, default) or `large` (720px). */
|
|
36
|
+
size: 'small' | 'medium' | 'large';
|
|
37
|
+
_hasFooter: boolean;
|
|
38
|
+
connectedCallback(): void;
|
|
39
|
+
static styles: import("lit").CSSResult[];
|
|
40
|
+
/** Content between the header and the footer. Filter panel adds its search field here. */
|
|
41
|
+
protected renderBody(): import("lit-html").TemplateResult<1>;
|
|
42
|
+
protected renderFooter(): import("lit-html").TemplateResult<1>;
|
|
43
|
+
protected get showFooter(): boolean;
|
|
44
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
45
|
+
}
|
|
46
|
+
declare global {
|
|
47
|
+
interface HTMLElementTagNameMap {
|
|
48
|
+
'cm-side-panel': CmSidePanel;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 _CmSidePanel_instances, _CmSidePanel_slot;
|
|
7
|
+
import { html, css } from 'lit';
|
|
8
|
+
import { define } from '../base.js';
|
|
9
|
+
import { CmOverlay } from '../overlay.js';
|
|
10
|
+
/**
|
|
11
|
+
* A panel that slides over the right edge of the page to show the details of one item (an enquiry, an
|
|
12
|
+
* order, a customer) without leaving the list. A black header with the title and a close button, the
|
|
13
|
+
* content, and an optional footer. On phones it becomes a card inset 16px from the screen edges.
|
|
14
|
+
*
|
|
15
|
+
* A native modal `<dialog>`: the page behind is inert, Esc and the backdrop ask to close through
|
|
16
|
+
* `cm-close`, page scrolling is locked, and focus returns to the opener.
|
|
17
|
+
* @element cm-side-panel
|
|
18
|
+
* @slot - The content.
|
|
19
|
+
* @slot footer - Actions at the bottom, right-aligned.
|
|
20
|
+
* @fires cm-open - After the panel opens.
|
|
21
|
+
* @fires cm-close - Before it closes from Esc, the backdrop or the close button. `detail: { reason }`. Cancelable.
|
|
22
|
+
* @fires cm-closed - After it has closed and focus has gone back.
|
|
23
|
+
*/
|
|
24
|
+
export class CmSidePanel extends CmOverlay {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
_CmSidePanel_instances.add(this);
|
|
28
|
+
/** Width on larger screens: `small` (380px), `medium` (450px, default) or `large` (720px). */
|
|
29
|
+
this.size = 'medium';
|
|
30
|
+
this._hasFooter = false;
|
|
31
|
+
}
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
this._hasFooter = !!this.querySelector(':scope > [slot="footer"]');
|
|
35
|
+
}
|
|
36
|
+
/** Content between the header and the footer. Filter panel adds its search field here. */
|
|
37
|
+
renderBody() { return html `<slot></slot>`; }
|
|
38
|
+
renderFooter() { return html `<slot name="footer" @slotchange=${__classPrivateFieldGet(this, _CmSidePanel_instances, "m", _CmSidePanel_slot)}></slot>`; }
|
|
39
|
+
get showFooter() { return this._hasFooter; }
|
|
40
|
+
render() {
|
|
41
|
+
return this.renderDialog(html `<div class="panel" part="panel" tabindex="-1">
|
|
42
|
+
${this.renderHeader()}
|
|
43
|
+
<div class="body" part="body">${this.renderBody()}</div>
|
|
44
|
+
<footer class="foot" part="footer" ?hidden=${!this.showFooter}>${this.renderFooter()}</footer>
|
|
45
|
+
</div>`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
_CmSidePanel_instances = new WeakSet(), _CmSidePanel_slot = function _CmSidePanel_slot(e) { this._hasFooter = e.target.assignedElements().length > 0; };
|
|
49
|
+
CmSidePanel.properties = {
|
|
50
|
+
...CmOverlay.properties,
|
|
51
|
+
size: { reflect: true },
|
|
52
|
+
_hasFooter: { state: true },
|
|
53
|
+
};
|
|
54
|
+
CmSidePanel.styles = [
|
|
55
|
+
...CmOverlay.overlayStyles,
|
|
56
|
+
css `
|
|
57
|
+
dialog {
|
|
58
|
+
position: fixed; inset: 0 0 0 auto; height: 100dvh; width: min(var(--cm-side-panel-width, 450px), 100vw);
|
|
59
|
+
}
|
|
60
|
+
:host([size='small']) dialog { --cm-side-panel-width: 380px; }
|
|
61
|
+
:host([size='large']) dialog { --cm-side-panel-width: 720px; }
|
|
62
|
+
.panel { height: 100%; box-shadow: var(--cm-shadow-100); }
|
|
63
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
64
|
+
dialog[open] .panel { animation: cm-side-in 200ms ease-out; }
|
|
65
|
+
}
|
|
66
|
+
@keyframes cm-side-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
|
|
67
|
+
@media (max-width: 599px) {
|
|
68
|
+
dialog { inset: 16px; width: auto; height: auto; }
|
|
69
|
+
.panel { border-radius: var(--cm-radius-sm); }
|
|
70
|
+
}
|
|
71
|
+
`,
|
|
72
|
+
];
|
|
73
|
+
define('cm-side-panel', CmSidePanel);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* A whole-page loading placeholder: a page header bar and grey cards laid out like a detail page.
|
|
4
|
+
* Show it while the first data for a page loads, then replace it with the page. Announces "Loading"
|
|
5
|
+
* once to screen readers.
|
|
6
|
+
* @element cm-skeleton-display
|
|
7
|
+
*/
|
|
8
|
+
export declare class CmSkeletonDisplay extends LitElement {
|
|
9
|
+
static properties: {
|
|
10
|
+
layout: {
|
|
11
|
+
reflect: boolean;
|
|
12
|
+
};
|
|
13
|
+
navigation: {
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
reflect: boolean;
|
|
16
|
+
};
|
|
17
|
+
label: {};
|
|
18
|
+
};
|
|
19
|
+
/** `two-column` (main cards plus a side column, as on detail pages) or `one-column` (lists and settings). */
|
|
20
|
+
layout: 'two-column' | 'one-column';
|
|
21
|
+
/** Adds a 250px side-navigation placeholder on the left. Admin chrome: for Commmerce products only, not for apps. */
|
|
22
|
+
navigation: boolean;
|
|
23
|
+
/** What screen readers announce while it shows. */
|
|
24
|
+
label: string;
|
|
25
|
+
static styles: import("lit").CSSResult[];
|
|
26
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
27
|
+
}
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'cm-skeleton-display': CmSkeletonDisplay;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
2
|
+
import { base, define } from '../base.js';
|
|
3
|
+
// Card heights measured from the Figma "Skeleton Display" board (main column 910px, side column 390px).
|
|
4
|
+
const MAIN = [472, 90, 90, 251];
|
|
5
|
+
const SIDE = [94, 266, 134, 191, 138];
|
|
6
|
+
/**
|
|
7
|
+
* A whole-page loading placeholder: a page header bar and grey cards laid out like a detail page.
|
|
8
|
+
* Show it while the first data for a page loads, then replace it with the page. Announces "Loading"
|
|
9
|
+
* once to screen readers.
|
|
10
|
+
* @element cm-skeleton-display
|
|
11
|
+
*/
|
|
12
|
+
export class CmSkeletonDisplay extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
/** `two-column` (main cards plus a side column, as on detail pages) or `one-column` (lists and settings). */
|
|
16
|
+
this.layout = 'two-column';
|
|
17
|
+
/** Adds a 250px side-navigation placeholder on the left. Admin chrome: for Commmerce products only, not for apps. */
|
|
18
|
+
this.navigation = false;
|
|
19
|
+
/** What screen readers announce while it shows. */
|
|
20
|
+
this.label = 'Loading';
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
const bones = (hs) => hs.map((h) => html `<span class="bone" style="height:${h}px"></span>`);
|
|
24
|
+
return html `<div class="wrap" part="skeleton-display" aria-busy="true">
|
|
25
|
+
<span class="sr" role="status">${this.label}</span>
|
|
26
|
+
<div class="page" aria-hidden="true">
|
|
27
|
+
${this.navigation ? html `<span class="bone nav"></span>` : nothing}
|
|
28
|
+
<span class="bone head"></span>
|
|
29
|
+
<div class="body">
|
|
30
|
+
<div class="col main">${bones(this.layout === 'one-column' ? [472, 251] : MAIN)}</div>
|
|
31
|
+
<div class="col side">${bones(SIDE)}</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
CmSkeletonDisplay.properties = {
|
|
38
|
+
layout: { reflect: true },
|
|
39
|
+
navigation: { type: Boolean, reflect: true },
|
|
40
|
+
label: {},
|
|
41
|
+
};
|
|
42
|
+
CmSkeletonDisplay.styles = [
|
|
43
|
+
base,
|
|
44
|
+
css `
|
|
45
|
+
:host { display: block; }
|
|
46
|
+
.page { display: grid; grid-template-columns: 1fr; gap: var(--cm-space-10); }
|
|
47
|
+
:host([navigation]) .page { grid-template-columns: 250px minmax(0, 1fr); }
|
|
48
|
+
.nav { grid-row: span 2; border-radius: 14px; min-height: 100%; }
|
|
49
|
+
.body { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); gap: var(--cm-space-10); align-items: start; }
|
|
50
|
+
:host([layout='one-column']) .body { grid-template-columns: minmax(0, 1fr); }
|
|
51
|
+
:host([layout='one-column']) .side { display: none; }
|
|
52
|
+
.col { display: grid; gap: var(--cm-space-10); }
|
|
53
|
+
.bone {
|
|
54
|
+
display: block; border-radius: var(--cm-radius-md); background: var(--cm-bg-input-filled);
|
|
55
|
+
animation: pulse 1.6s ease-in-out infinite;
|
|
56
|
+
}
|
|
57
|
+
.head { height: 80px; }
|
|
58
|
+
@keyframes pulse { 50% { background: var(--cm-thumb-bg); } }
|
|
59
|
+
@media (prefers-reduced-motion: reduce) { .bone { animation: none; background: var(--cm-thumb-bg); } }
|
|
60
|
+
@media (forced-colors: active) { .bone { border: 1px solid CanvasText; } }
|
|
61
|
+
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
62
|
+
@media (max-width: 768px) {
|
|
63
|
+
:host([navigation]) .page { grid-template-columns: minmax(0, 1fr); }
|
|
64
|
+
.nav { display: none; }
|
|
65
|
+
.body { grid-template-columns: minmax(0, 1fr); }
|
|
66
|
+
.head { height: 60px; }
|
|
67
|
+
}
|
|
68
|
+
`,
|
|
69
|
+
];
|
|
70
|
+
define('cm-skeleton-display', CmSkeletonDisplay);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const THUMB: {
|
|
3
|
+
readonly small: 34;
|
|
4
|
+
readonly medium: 40;
|
|
5
|
+
readonly large: 50;
|
|
6
|
+
readonly xlarge: 186;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A grey placeholder shape shown where content is loading: lines of text, a product thumbnail or a block.
|
|
10
|
+
* Skeletons are hidden from assistive technology; mark the region that is loading with `aria-busy="true"`
|
|
11
|
+
* (or use `cm-skeleton-display`, which announces "Loading").
|
|
12
|
+
* @element cm-skeleton
|
|
13
|
+
*/
|
|
14
|
+
export declare class CmSkeleton extends LitElement {
|
|
15
|
+
static properties: {
|
|
16
|
+
variant: {
|
|
17
|
+
reflect: boolean;
|
|
18
|
+
};
|
|
19
|
+
lines: {
|
|
20
|
+
type: NumberConstructor;
|
|
21
|
+
};
|
|
22
|
+
size: {
|
|
23
|
+
reflect: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/** `text` (one or more lines), `thumbnail` (a square image placeholder) or `block` (fills the width; set a height). */
|
|
27
|
+
variant: 'text' | 'thumbnail' | 'block';
|
|
28
|
+
/** Number of text lines. The last of several lines is shorter, like a real paragraph. */
|
|
29
|
+
lines: number;
|
|
30
|
+
/** Thumbnail size from Figma: `small` 34px, `medium` 40px, `large` 50px, `xlarge` 186px. */
|
|
31
|
+
size: keyof typeof THUMB;
|
|
32
|
+
static styles: import("lit").CSSResult[];
|
|
33
|
+
connectedCallback(): void;
|
|
34
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
35
|
+
}
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'cm-skeleton': CmSkeleton;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { base, define } from '../base.js';
|
|
3
|
+
const THUMB = { small: 34, medium: 40, large: 50, xlarge: 186 };
|
|
4
|
+
/**
|
|
5
|
+
* A grey placeholder shape shown where content is loading: lines of text, a product thumbnail or a block.
|
|
6
|
+
* Skeletons are hidden from assistive technology; mark the region that is loading with `aria-busy="true"`
|
|
7
|
+
* (or use `cm-skeleton-display`, which announces "Loading").
|
|
8
|
+
* @element cm-skeleton
|
|
9
|
+
*/
|
|
10
|
+
export class CmSkeleton extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
/** `text` (one or more lines), `thumbnail` (a square image placeholder) or `block` (fills the width; set a height). */
|
|
14
|
+
this.variant = 'text';
|
|
15
|
+
/** Number of text lines. The last of several lines is shorter, like a real paragraph. */
|
|
16
|
+
this.lines = 1;
|
|
17
|
+
/** Thumbnail size from Figma: `small` 34px, `medium` 40px, `large` 50px, `xlarge` 186px. */
|
|
18
|
+
this.size = 'large';
|
|
19
|
+
}
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
super.connectedCallback();
|
|
22
|
+
this.setAttribute('aria-hidden', 'true');
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
if (this.variant === 'thumbnail') {
|
|
26
|
+
const px = THUMB[this.size] ?? THUMB.large;
|
|
27
|
+
return html `<span class="bone" part="bone" style="width:${px}px;height:${px}px"></span>`;
|
|
28
|
+
}
|
|
29
|
+
if (this.variant === 'block')
|
|
30
|
+
return html `<span class="bone block" part="bone"></span>`;
|
|
31
|
+
const n = Math.max(1, Math.floor(this.lines || 1));
|
|
32
|
+
return html `${Array.from({ length: n }, (_, i) => html `<span class="bone line ${n > 1 && i === n - 1 ? 'short' : ''}" part="bone"></span>`)}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
CmSkeleton.properties = {
|
|
36
|
+
variant: { reflect: true },
|
|
37
|
+
lines: { type: Number },
|
|
38
|
+
size: { reflect: true },
|
|
39
|
+
};
|
|
40
|
+
CmSkeleton.styles = [
|
|
41
|
+
base,
|
|
42
|
+
css `
|
|
43
|
+
:host { display: block; --cm-skeleton-height: 120px; }
|
|
44
|
+
:host([variant='thumbnail']) { display: inline-block; vertical-align: middle; }
|
|
45
|
+
.bone {
|
|
46
|
+
display: block; border-radius: var(--cm-radius-md); background: var(--cm-bg-input-filled);
|
|
47
|
+
animation: pulse 1.6s ease-in-out infinite;
|
|
48
|
+
}
|
|
49
|
+
.line { height: 12px; margin: 6px 0; border-radius: var(--cm-radius-sm); }
|
|
50
|
+
.line.short { width: 60%; }
|
|
51
|
+
.block { height: var(--cm-skeleton-height); }
|
|
52
|
+
@keyframes pulse { 50% { background: var(--cm-thumb-bg); } }
|
|
53
|
+
@media (prefers-reduced-motion: reduce) {
|
|
54
|
+
.bone { animation: none; background: var(--cm-thumb-bg); }
|
|
55
|
+
}
|
|
56
|
+
@media (forced-colors: active) { .bone { border: 1px solid CanvasText; } }
|
|
57
|
+
`,
|
|
58
|
+
];
|
|
59
|
+
define('cm-skeleton', CmSkeleton);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import './icon.js';
|
|
3
|
+
import './button.js';
|
|
4
|
+
/**
|
|
5
|
+
* A short, linked tip that points merchants to a guide or setting ("Importing and exporting products").
|
|
6
|
+
* The whole card is one link. Group tips in `cm-smart-tips`.
|
|
7
|
+
* @element cm-smart-tip
|
|
8
|
+
* @slot - One or two lines that say what the merchant gets from the guide.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CmSmartTip extends LitElement {
|
|
11
|
+
static properties: {
|
|
12
|
+
heading: {};
|
|
13
|
+
href: {};
|
|
14
|
+
target: {};
|
|
15
|
+
};
|
|
16
|
+
/** Tip title, at most two short lines. */
|
|
17
|
+
heading: string;
|
|
18
|
+
/** Where the tip leads. */
|
|
19
|
+
href: string;
|
|
20
|
+
/** Link target. `_blank` adds `rel="noopener noreferrer"` and tells screen readers it opens a new tab. */
|
|
21
|
+
target: string;
|
|
22
|
+
static styles: import("lit").CSSResult[];
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The "Smart tips" card on the home page: an optional dark tour banner on top, then a list of `cm-smart-tip` links.
|
|
28
|
+
* @element cm-smart-tips
|
|
29
|
+
* @slot - `cm-smart-tip` elements.
|
|
30
|
+
* @fires cm-tour - When the tour banner's button is pressed.
|
|
31
|
+
*/
|
|
32
|
+
export declare class CmSmartTips extends LitElement {
|
|
33
|
+
static properties: {
|
|
34
|
+
heading: {};
|
|
35
|
+
tourHeading: {
|
|
36
|
+
attribute: string;
|
|
37
|
+
};
|
|
38
|
+
tourAction: {
|
|
39
|
+
attribute: string;
|
|
40
|
+
};
|
|
41
|
+
headingLevel: {
|
|
42
|
+
type: NumberConstructor;
|
|
43
|
+
attribute: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** Title above the tips, shown in capitals. */
|
|
47
|
+
heading: string;
|
|
48
|
+
/** Text of the dark tour banner ("Take a tour of Commmerce"). Leave empty for no banner. */
|
|
49
|
+
tourHeading: string;
|
|
50
|
+
/** Label of the tour banner's button. */
|
|
51
|
+
tourAction: string;
|
|
52
|
+
/** Heading level of the title. Default 2. */
|
|
53
|
+
headingLevel: 2 | 3 | 4 | 5 | 6;
|
|
54
|
+
static styles: import("lit").CSSResult[];
|
|
55
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
56
|
+
}
|
|
57
|
+
declare global {
|
|
58
|
+
interface HTMLElementTagNameMap {
|
|
59
|
+
'cm-smart-tip': CmSmartTip;
|
|
60
|
+
'cm-smart-tips': CmSmartTips;
|
|
61
|
+
}
|
|
62
|
+
}
|