@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,174 @@
|
|
|
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 _CmNotificationPanel_instances, _CmNotificationPanel_observer, _CmNotificationPanel_read, _CmNotificationPanel_choose, _CmNotificationPanel_row;
|
|
13
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
14
|
+
import { define } from '../base.js';
|
|
15
|
+
import { CmOverlay } from '../overlay.js';
|
|
16
|
+
import './icon.js';
|
|
17
|
+
const ICONS = { information: 'bag', attention: 'alert', success: 'check-circle', critical: 'x-circle' };
|
|
18
|
+
/**
|
|
19
|
+
* A notification in markup, read by `cm-notification-panel`. Its text is the label. Renders nothing itself.
|
|
20
|
+
* @element cm-notification-item
|
|
21
|
+
*/
|
|
22
|
+
export class CmNotificationItem extends LitElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
/** When, as shown: "1 min ago". */
|
|
26
|
+
this.time = '';
|
|
27
|
+
/** `information` (default), `attention`, `success` or `critical`. */
|
|
28
|
+
this.tone = 'information';
|
|
29
|
+
/** Where the notification leads. */
|
|
30
|
+
this.href = '';
|
|
31
|
+
/** Not read yet. */
|
|
32
|
+
this.unread = false;
|
|
33
|
+
/** Identifies it in `cm-select`. */
|
|
34
|
+
this.value = '';
|
|
35
|
+
}
|
|
36
|
+
render() { return null; }
|
|
37
|
+
}
|
|
38
|
+
CmNotificationItem.properties = {
|
|
39
|
+
time: { reflect: true },
|
|
40
|
+
tone: { reflect: true },
|
|
41
|
+
href: { reflect: true },
|
|
42
|
+
unread: { type: Boolean, reflect: true },
|
|
43
|
+
value: { reflect: true },
|
|
44
|
+
};
|
|
45
|
+
CmNotificationItem.styles = css `:host { display: none; }`;
|
|
46
|
+
define('cm-notification-item', CmNotificationItem);
|
|
47
|
+
/**
|
|
48
|
+
* The list of recent notifications, opened from the bell in the header bar: a panel under the top-right corner
|
|
49
|
+
* of the page with a black "Notifications" header, one row per notification (a coloured icon for its kind,
|
|
50
|
+
* what happened, and when), and "See more notifications" at the bottom. On phones it spans the screen width.
|
|
51
|
+
*
|
|
52
|
+
* A native modal `<dialog>`: the page behind is dimmed and inert, Esc and the backdrop ask to close through
|
|
53
|
+
* `cm-close`, scrolling is locked, and focus returns to the bell.
|
|
54
|
+
* @element cm-notification-panel
|
|
55
|
+
* @slot - `cm-notification-item`s.
|
|
56
|
+
* @fires cm-select - When a notification is chosen. `detail: { value, item }`. Cancelable: `preventDefault()` stops a link, to route in your app.
|
|
57
|
+
* @fires cm-open - After the panel opens.
|
|
58
|
+
* @fires cm-close - Before it closes. `detail: { reason }`. Cancelable.
|
|
59
|
+
* @fires cm-closed - After it has closed.
|
|
60
|
+
*/
|
|
61
|
+
export class CmNotificationPanel extends CmOverlay {
|
|
62
|
+
constructor() {
|
|
63
|
+
super(...arguments);
|
|
64
|
+
_CmNotificationPanel_instances.add(this);
|
|
65
|
+
/** Title in the header. */
|
|
66
|
+
this.heading = 'Notifications';
|
|
67
|
+
/** Notifications as data, used instead of children when set. */
|
|
68
|
+
this.items = [];
|
|
69
|
+
/** Link to all notifications. Empty hides it. */
|
|
70
|
+
this.moreHref = '';
|
|
71
|
+
/** Text of that link. */
|
|
72
|
+
this.moreLabel = 'See more notifications';
|
|
73
|
+
/** Shown when there are no notifications. */
|
|
74
|
+
this.emptyText = 'No notifications yet.';
|
|
75
|
+
this._slotted = [];
|
|
76
|
+
_CmNotificationPanel_observer.set(this, void 0);
|
|
77
|
+
}
|
|
78
|
+
connectedCallback() {
|
|
79
|
+
super.connectedCallback();
|
|
80
|
+
__classPrivateFieldGet(this, _CmNotificationPanel_instances, "m", _CmNotificationPanel_read).call(this);
|
|
81
|
+
__classPrivateFieldSet(this, _CmNotificationPanel_observer, new MutationObserver(() => __classPrivateFieldGet(this, _CmNotificationPanel_instances, "m", _CmNotificationPanel_read).call(this)), "f");
|
|
82
|
+
__classPrivateFieldGet(this, _CmNotificationPanel_observer, "f").observe(this, { childList: true, subtree: true, attributes: true, characterData: true });
|
|
83
|
+
}
|
|
84
|
+
disconnectedCallback() {
|
|
85
|
+
super.disconnectedCallback();
|
|
86
|
+
__classPrivateFieldGet(this, _CmNotificationPanel_observer, "f")?.disconnect();
|
|
87
|
+
}
|
|
88
|
+
/** The notifications in use. */
|
|
89
|
+
get notifications() { return this.items.length ? this.items : this._slotted; }
|
|
90
|
+
render() {
|
|
91
|
+
const list = this.notifications;
|
|
92
|
+
return this.renderDialog(html `<div class="panel" part="panel" tabindex="-1">
|
|
93
|
+
${this.renderHeader()}
|
|
94
|
+
${list.length
|
|
95
|
+
? html `<ul class="list" part="list">${list.map((it) => html `<li>${__classPrivateFieldGet(this, _CmNotificationPanel_instances, "m", _CmNotificationPanel_row).call(this, it)}</li>`)}</ul>`
|
|
96
|
+
: html `<p class="empty">${this.emptyText}</p>`}
|
|
97
|
+
${this.moreHref ? html `<a class="more" part="more" href=${this.moreHref}>${this.moreLabel}</a>` : nothing}
|
|
98
|
+
<slot hidden></slot>
|
|
99
|
+
</div>`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_CmNotificationPanel_observer = new WeakMap(), _CmNotificationPanel_instances = new WeakSet(), _CmNotificationPanel_read = function _CmNotificationPanel_read() {
|
|
103
|
+
this._slotted = Array.from(this.querySelectorAll(':scope > cm-notification-item')).map((c) => {
|
|
104
|
+
const a = (n) => c.getAttribute(n) || undefined;
|
|
105
|
+
return {
|
|
106
|
+
label: (c.textContent ?? '').trim(), time: a('time'), tone: a('tone') ?? 'information', href: a('href'),
|
|
107
|
+
unread: c.hasAttribute('unread') || undefined, value: a('value'),
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}, _CmNotificationPanel_choose = function _CmNotificationPanel_choose(e, it) {
|
|
111
|
+
const ok = this.dispatchEvent(new CustomEvent('cm-select', {
|
|
112
|
+
detail: { value: it.value ?? it.href ?? it.label, item: it }, bubbles: true, composed: true, cancelable: true,
|
|
113
|
+
}));
|
|
114
|
+
if (!ok) {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.requestClose('action');
|
|
119
|
+
}, _CmNotificationPanel_row = function _CmNotificationPanel_row(it) {
|
|
120
|
+
const tone = it.tone ?? 'information';
|
|
121
|
+
const inner = html `<span class="ic ${tone}" aria-hidden="true"><cm-icon name=${ICONS[tone] ?? 'bell'} size="14"></cm-icon></span>
|
|
122
|
+
<span class="label">${it.unread ? html `<span class="vh">Unread: </span>` : nothing}${it.label}</span>
|
|
123
|
+
${it.time ? html `<time>${it.time}</time>` : nothing}`;
|
|
124
|
+
const cls = `row${it.unread ? ' unread' : ''}`;
|
|
125
|
+
return it.href
|
|
126
|
+
? html `<a class=${cls} part="row" href=${it.href} @click=${(e) => __classPrivateFieldGet(this, _CmNotificationPanel_instances, "m", _CmNotificationPanel_choose).call(this, e, it)}>${inner}</a>`
|
|
127
|
+
: html `<button type="button" class=${cls} part="row" @click=${(e) => __classPrivateFieldGet(this, _CmNotificationPanel_instances, "m", _CmNotificationPanel_choose).call(this, e, it)}>${inner}</button>`;
|
|
128
|
+
};
|
|
129
|
+
CmNotificationPanel.properties = {
|
|
130
|
+
...CmOverlay.properties,
|
|
131
|
+
items: { type: Array },
|
|
132
|
+
moreHref: { attribute: 'more-href' },
|
|
133
|
+
moreLabel: { attribute: 'more-label' },
|
|
134
|
+
emptyText: { attribute: 'empty-text' },
|
|
135
|
+
_slotted: { state: true },
|
|
136
|
+
};
|
|
137
|
+
CmNotificationPanel.styles = [
|
|
138
|
+
...CmOverlay.overlayStyles,
|
|
139
|
+
css `
|
|
140
|
+
dialog {
|
|
141
|
+
position: fixed; inset: var(--cm-notification-panel-top, 64px) var(--cm-notification-panel-end, 20px) auto auto;
|
|
142
|
+
width: min(380px, calc(100vw - 32px));
|
|
143
|
+
}
|
|
144
|
+
.panel { max-height: calc(100dvh - var(--cm-notification-panel-top, 64px) - 16px); border-radius: var(--cm-radius-sm); box-shadow: var(--cm-shadow-100); }
|
|
145
|
+
.list { flex: 1 1 auto; min-height: 0; overflow: auto; margin: 0; padding: 0; list-style: none; }
|
|
146
|
+
.list li:nth-child(even) .row { background: var(--cm-bg-hover); }
|
|
147
|
+
.row {
|
|
148
|
+
display: flex; align-items: center; gap: var(--cm-space-10); width: 100%; min-height: 40px; padding: 8px var(--cm-space-15);
|
|
149
|
+
font: inherit; font-size: 13px; line-height: 18px; color: var(--cm-text-default); text-align: start; text-decoration: none;
|
|
150
|
+
background: var(--cm-bg-surface); border: 0; cursor: pointer;
|
|
151
|
+
}
|
|
152
|
+
.row:hover { text-decoration: underline; }
|
|
153
|
+
.row:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: -2px; }
|
|
154
|
+
.ic { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: var(--cm-radius-xs); }
|
|
155
|
+
.information { background: var(--cm-bg-information-soft); color: var(--cm-text-information); }
|
|
156
|
+
.attention { background: var(--cm-bg-attention); color: var(--cm-text-attention); }
|
|
157
|
+
.success { background: var(--cm-bg-success-soft); color: var(--cm-text-success); }
|
|
158
|
+
.critical { background: var(--cm-bg-critical); color: var(--cm-text-critical); }
|
|
159
|
+
.label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
160
|
+
.unread .label { font-weight: 600; }
|
|
161
|
+
time { flex: none; font-size: 11px; color: var(--cm-text-tertiary); }
|
|
162
|
+
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
163
|
+
.more {
|
|
164
|
+
display: block; flex: none; padding: 10px; font-size: 12px; text-align: center; color: var(--cm-text-default);
|
|
165
|
+
border-top: var(--cm-border-1) solid var(--cm-border-default);
|
|
166
|
+
}
|
|
167
|
+
.more:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: -2px; }
|
|
168
|
+
.empty { margin: 0; padding: var(--cm-space-20); font-size: 13px; text-align: center; color: var(--cm-text-tertiary); }
|
|
169
|
+
@media (max-width: 599px) {
|
|
170
|
+
dialog { inset: var(--cm-notification-panel-top, 56px) 8px auto 8px; width: auto; }
|
|
171
|
+
}
|
|
172
|
+
`,
|
|
173
|
+
];
|
|
174
|
+
define('cm-notification-panel', CmNotificationPanel);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { SelectOption } from './select.js';
|
|
3
|
+
/**
|
|
4
|
+
* A row of outlined buttons where exactly one is selected (black), used to switch a form between
|
|
5
|
+
* types, such as offer types. Behaves like a native radio group: one tab stop, arrow keys move and
|
|
6
|
+
* select, and the form receives the selected value.
|
|
7
|
+
*
|
|
8
|
+
* Options come from `<option>` children or the `options` property.
|
|
9
|
+
* @element cm-option-group
|
|
10
|
+
* @slot - `<option value="…">Label</option>` elements. `disabled` and `selected` are honoured.
|
|
11
|
+
* @fires change - When the merchant picks a different option.
|
|
12
|
+
* @fires input - Same moment as `change`.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CmOptionGroup extends LitElement {
|
|
15
|
+
#private;
|
|
16
|
+
static formAssociated: boolean;
|
|
17
|
+
static properties: {
|
|
18
|
+
label: {};
|
|
19
|
+
name: {
|
|
20
|
+
reflect: boolean;
|
|
21
|
+
};
|
|
22
|
+
value: {};
|
|
23
|
+
options: {
|
|
24
|
+
type: ArrayConstructor;
|
|
25
|
+
};
|
|
26
|
+
required: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
reflect: boolean;
|
|
29
|
+
};
|
|
30
|
+
disabled: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
reflect: boolean;
|
|
33
|
+
};
|
|
34
|
+
_slotted: {
|
|
35
|
+
state: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/** Heading above the options, e.g. "Select offer type". Without one, give the element an `aria-label`. */
|
|
39
|
+
label: string;
|
|
40
|
+
/** Form field name. */
|
|
41
|
+
name: string;
|
|
42
|
+
/** Value of the selected option; empty when nothing is selected. */
|
|
43
|
+
value: string;
|
|
44
|
+
/** Options as strings or `{ value, label, disabled }`. Used instead of `<option>` children when set. */
|
|
45
|
+
options: Array<string | SelectOption>;
|
|
46
|
+
/** The form will not submit until an option is chosen. */
|
|
47
|
+
required: boolean;
|
|
48
|
+
/** Blocks every option. Also set by a disabled `<fieldset>`. */
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
_slotted: SelectOption[];
|
|
51
|
+
static styles: import("lit").CSSResult[];
|
|
52
|
+
connectedCallback(): void;
|
|
53
|
+
disconnectedCallback(): void;
|
|
54
|
+
get form(): HTMLFormElement | null;
|
|
55
|
+
get validity(): ValidityState;
|
|
56
|
+
get validationMessage(): string;
|
|
57
|
+
checkValidity(): boolean;
|
|
58
|
+
reportValidity(): boolean;
|
|
59
|
+
formResetCallback(): void;
|
|
60
|
+
formDisabledCallback(d: boolean): void;
|
|
61
|
+
formStateRestoreCallback(state: string): void;
|
|
62
|
+
/** Focuses the selected option, or the first one. */
|
|
63
|
+
focus(options?: FocusOptions): void;
|
|
64
|
+
/** The options in use, normalised. */
|
|
65
|
+
get items(): SelectOption[];
|
|
66
|
+
firstUpdated(): void;
|
|
67
|
+
updated(): void;
|
|
68
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
69
|
+
}
|
|
70
|
+
declare global {
|
|
71
|
+
interface HTMLElementTagNameMap {
|
|
72
|
+
'cm-option-group': CmOptionGroup;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
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 _CmOptionGroup_instances, _CmOptionGroup_internals, _CmOptionGroup_id, _CmOptionGroup_defaultValue, _CmOptionGroup_observer, _CmOptionGroup_readChildren, _CmOptionGroup_select, _CmOptionGroup_onKeyDown;
|
|
13
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
14
|
+
import { base, define, nextId } from '../base.js';
|
|
15
|
+
/**
|
|
16
|
+
* A row of outlined buttons where exactly one is selected (black), used to switch a form between
|
|
17
|
+
* types, such as offer types. Behaves like a native radio group: one tab stop, arrow keys move and
|
|
18
|
+
* select, and the form receives the selected value.
|
|
19
|
+
*
|
|
20
|
+
* Options come from `<option>` children or the `options` property.
|
|
21
|
+
* @element cm-option-group
|
|
22
|
+
* @slot - `<option value="…">Label</option>` elements. `disabled` and `selected` are honoured.
|
|
23
|
+
* @fires change - When the merchant picks a different option.
|
|
24
|
+
* @fires input - Same moment as `change`.
|
|
25
|
+
*/
|
|
26
|
+
export class CmOptionGroup extends LitElement {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
_CmOptionGroup_instances.add(this);
|
|
30
|
+
/** Heading above the options, e.g. "Select offer type". Without one, give the element an `aria-label`. */
|
|
31
|
+
this.label = '';
|
|
32
|
+
/** Form field name. */
|
|
33
|
+
this.name = '';
|
|
34
|
+
/** Value of the selected option; empty when nothing is selected. */
|
|
35
|
+
this.value = '';
|
|
36
|
+
/** Options as strings or `{ value, label, disabled }`. Used instead of `<option>` children when set. */
|
|
37
|
+
this.options = [];
|
|
38
|
+
/** The form will not submit until an option is chosen. */
|
|
39
|
+
this.required = false;
|
|
40
|
+
/** Blocks every option. Also set by a disabled `<fieldset>`. */
|
|
41
|
+
this.disabled = false;
|
|
42
|
+
this._slotted = [];
|
|
43
|
+
_CmOptionGroup_internals.set(this, this.attachInternals());
|
|
44
|
+
_CmOptionGroup_id.set(this, nextId('cm-og'));
|
|
45
|
+
_CmOptionGroup_defaultValue.set(this, '');
|
|
46
|
+
_CmOptionGroup_observer.set(this, new MutationObserver(() => __classPrivateFieldGet(this, _CmOptionGroup_instances, "m", _CmOptionGroup_readChildren).call(this)));
|
|
47
|
+
}
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
super.connectedCallback();
|
|
50
|
+
__classPrivateFieldGet(this, _CmOptionGroup_instances, "m", _CmOptionGroup_readChildren).call(this);
|
|
51
|
+
__classPrivateFieldGet(this, _CmOptionGroup_observer, "f").observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['value', 'label', 'disabled', 'selected'] });
|
|
52
|
+
}
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
super.disconnectedCallback();
|
|
55
|
+
__classPrivateFieldGet(this, _CmOptionGroup_observer, "f").disconnect();
|
|
56
|
+
}
|
|
57
|
+
get form() { return __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").form; }
|
|
58
|
+
get validity() { return __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").validity; }
|
|
59
|
+
get validationMessage() { return __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").validationMessage; }
|
|
60
|
+
checkValidity() { return __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").checkValidity(); }
|
|
61
|
+
reportValidity() { return __classPrivateFieldGet(this, _CmOptionGroup_internals, "f").reportValidity(); }
|
|
62
|
+
formResetCallback() { this.value = __classPrivateFieldGet(this, _CmOptionGroup_defaultValue, "f"); }
|
|
63
|
+
formDisabledCallback(d) { this.disabled = d; }
|
|
64
|
+
formStateRestoreCallback(state) { this.value = state; }
|
|
65
|
+
/** Focuses the selected option, or the first one. */
|
|
66
|
+
focus(options) {
|
|
67
|
+
this.renderRoot.querySelector('button[tabindex="0"]')?.focus(options);
|
|
68
|
+
}
|
|
69
|
+
/** The options in use, normalised. */
|
|
70
|
+
get items() {
|
|
71
|
+
if (!this.options.length)
|
|
72
|
+
return this._slotted;
|
|
73
|
+
return this.options.map((o) => (typeof o === 'string' ? { value: o, label: o } : o));
|
|
74
|
+
}
|
|
75
|
+
firstUpdated() { __classPrivateFieldSet(this, _CmOptionGroup_defaultValue, __classPrivateFieldGet(this, _CmOptionGroup_defaultValue, "f") || this.value, "f"); }
|
|
76
|
+
updated() {
|
|
77
|
+
__classPrivateFieldGet(this, _CmOptionGroup_internals, "f").setFormValue(this.value || null, this.value);
|
|
78
|
+
const anchor = this.renderRoot.querySelector('button') ?? undefined;
|
|
79
|
+
if (this.required && !this.value)
|
|
80
|
+
__classPrivateFieldGet(this, _CmOptionGroup_internals, "f").setValidity({ valueMissing: true }, 'Please select one of these options.', anchor);
|
|
81
|
+
else
|
|
82
|
+
__classPrivateFieldGet(this, _CmOptionGroup_internals, "f").setValidity({});
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
const items = this.items;
|
|
86
|
+
const sel = items.findIndex((o) => o.value === this.value && !o.disabled);
|
|
87
|
+
const stop = sel >= 0 ? sel : items.findIndex((o) => !o.disabled);
|
|
88
|
+
const hostLabel = this.getAttribute('aria-label');
|
|
89
|
+
return html `
|
|
90
|
+
${this.label ? html `<span class="label" id="${__classPrivateFieldGet(this, _CmOptionGroup_id, "f")}-l" part="label">${this.label}${this.required ? html `<span class="req" aria-hidden="true">*</span>` : nothing}</span>` : nothing}
|
|
91
|
+
<div class="options" part="options" role="radiogroup"
|
|
92
|
+
aria-labelledby=${this.label ? `${__classPrivateFieldGet(this, _CmOptionGroup_id, "f")}-l` : nothing} aria-label=${!this.label && hostLabel ? hostLabel : nothing}
|
|
93
|
+
aria-required=${this.required ? 'true' : nothing}>
|
|
94
|
+
${items.map((o, i) => html `<button type="button" role="radio" part="option" aria-checked=${o.value === this.value ? 'true' : 'false'}
|
|
95
|
+
tabindex=${i === stop ? '0' : '-1'} ?disabled=${this.disabled || !!o.disabled}
|
|
96
|
+
@click=${() => __classPrivateFieldGet(this, _CmOptionGroup_instances, "m", _CmOptionGroup_select).call(this, i)} @keydown=${(e) => __classPrivateFieldGet(this, _CmOptionGroup_instances, "m", _CmOptionGroup_onKeyDown).call(this, e, i)}>${o.label}</button>`)}
|
|
97
|
+
</div>
|
|
98
|
+
<slot></slot>
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_CmOptionGroup_internals = new WeakMap(), _CmOptionGroup_id = new WeakMap(), _CmOptionGroup_defaultValue = new WeakMap(), _CmOptionGroup_observer = new WeakMap(), _CmOptionGroup_instances = new WeakSet(), _CmOptionGroup_readChildren = function _CmOptionGroup_readChildren() {
|
|
103
|
+
const opts = [...this.querySelectorAll('option')];
|
|
104
|
+
this._slotted = opts.map((o) => ({ value: o.value, label: o.label || o.textContent.trim(), disabled: o.disabled }));
|
|
105
|
+
if (!this.hasUpdated && !this.value) {
|
|
106
|
+
this.value = opts.find((o) => o.hasAttribute('selected'))?.value ?? '';
|
|
107
|
+
__classPrivateFieldSet(this, _CmOptionGroup_defaultValue, this.value, "f");
|
|
108
|
+
}
|
|
109
|
+
}, _CmOptionGroup_select = function _CmOptionGroup_select(i) {
|
|
110
|
+
const o = this.items[i];
|
|
111
|
+
if (!o || o.disabled || this.disabled)
|
|
112
|
+
return;
|
|
113
|
+
this.updateComplete.then(() => this.renderRoot.querySelectorAll('button')[i]?.focus());
|
|
114
|
+
if (o.value === this.value)
|
|
115
|
+
return;
|
|
116
|
+
this.value = o.value;
|
|
117
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
118
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
119
|
+
}, _CmOptionGroup_onKeyDown = function _CmOptionGroup_onKeyDown(e, i) {
|
|
120
|
+
const en = this.items.flatMap((o, j) => (o.disabled ? [] : [j]));
|
|
121
|
+
const pos = en.indexOf(i);
|
|
122
|
+
let next;
|
|
123
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowDown')
|
|
124
|
+
next = en[(pos + 1) % en.length];
|
|
125
|
+
else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp')
|
|
126
|
+
next = en[(pos - 1 + en.length) % en.length];
|
|
127
|
+
else if (e.key === 'Home')
|
|
128
|
+
next = en[0];
|
|
129
|
+
else if (e.key === 'End')
|
|
130
|
+
next = en[en.length - 1];
|
|
131
|
+
else
|
|
132
|
+
return;
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
if (next !== undefined)
|
|
135
|
+
__classPrivateFieldGet(this, _CmOptionGroup_instances, "m", _CmOptionGroup_select).call(this, next);
|
|
136
|
+
};
|
|
137
|
+
CmOptionGroup.formAssociated = true;
|
|
138
|
+
CmOptionGroup.properties = {
|
|
139
|
+
label: {},
|
|
140
|
+
name: { reflect: true },
|
|
141
|
+
value: {},
|
|
142
|
+
options: { type: Array },
|
|
143
|
+
required: { type: Boolean, reflect: true },
|
|
144
|
+
disabled: { type: Boolean, reflect: true },
|
|
145
|
+
_slotted: { state: true },
|
|
146
|
+
};
|
|
147
|
+
CmOptionGroup.styles = [
|
|
148
|
+
base,
|
|
149
|
+
css `
|
|
150
|
+
:host { display: block; }
|
|
151
|
+
.label { display: block; margin-bottom: var(--cm-space-20); font-size: var(--cm-type-heading-sm-size); font-weight: 600; }
|
|
152
|
+
.req { color: var(--cm-text-critical); margin-left: 2px; }
|
|
153
|
+
.options { display: flex; flex-wrap: wrap; gap: var(--cm-space-20); }
|
|
154
|
+
button {
|
|
155
|
+
height: 46px; padding: 0 var(--cm-space-20); font: inherit; font-size: 16px; font-weight: 500; white-space: nowrap;
|
|
156
|
+
color: var(--cm-text-default); background: var(--cm-bg-hover); cursor: pointer;
|
|
157
|
+
border: var(--cm-border-1) solid var(--cm-border-input); border-radius: var(--cm-radius-sm);
|
|
158
|
+
}
|
|
159
|
+
button:hover { border-color: var(--cm-border-strong); }
|
|
160
|
+
button[aria-checked='true'] { background: var(--cm-action-primary); color: var(--cm-action-primary-text); border-color: var(--cm-action-primary); }
|
|
161
|
+
button:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
162
|
+
button:disabled { background: var(--cm-bg-input-filled); color: var(--cm-text-secondary); border-color: var(--cm-border-default); cursor: not-allowed; }
|
|
163
|
+
button[aria-checked='true']:disabled { background: var(--cm-action-disabled); color: var(--cm-action-disabled-text); }
|
|
164
|
+
slot { display: none; }
|
|
165
|
+
@media (max-width: 640px) {
|
|
166
|
+
.label { font-size: var(--cm-type-heading-sm-resp-size); }
|
|
167
|
+
.options { gap: var(--cm-space-10); }
|
|
168
|
+
button { height: 42px; padding: 0 var(--cm-space-15); font-size: 14px; }
|
|
169
|
+
}
|
|
170
|
+
`,
|
|
171
|
+
];
|
|
172
|
+
define('cm-option-group', CmOptionGroup);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import './icon.js';
|
|
3
|
+
/** One breadcrumb link above the page title. */
|
|
4
|
+
export interface Breadcrumb {
|
|
5
|
+
label: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Top of an admin page: breadcrumbs, the page title and the page's main actions.
|
|
10
|
+
* The Figma file calls this the "Save Bar" (80px desktop, 50px mobile).
|
|
11
|
+
* On narrow screens the breadcrumbs collapse to a back link to the parent page.
|
|
12
|
+
* @element cm-page-header
|
|
13
|
+
* @slot actions - Buttons, right-aligned, secondary first and the primary action last (large size).
|
|
14
|
+
* @slot title-adornment - Badge or count next to the title.
|
|
15
|
+
* @fires cm-previous - When the previous-record arrow is pressed (with `pagination`).
|
|
16
|
+
* @fires cm-next - When the next-record arrow is pressed (with `pagination`).
|
|
17
|
+
*/
|
|
18
|
+
export declare class CmPageHeader extends LitElement {
|
|
19
|
+
#private;
|
|
20
|
+
static properties: {
|
|
21
|
+
heading: {};
|
|
22
|
+
breadcrumbs: {
|
|
23
|
+
type: ArrayConstructor;
|
|
24
|
+
};
|
|
25
|
+
pagination: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
reflect: boolean;
|
|
28
|
+
};
|
|
29
|
+
hasPrevious: {
|
|
30
|
+
type: BooleanConstructor;
|
|
31
|
+
attribute: string;
|
|
32
|
+
};
|
|
33
|
+
hasNext: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
attribute: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/** Page title, rendered as the page's `<h1>` and as the last (current) breadcrumb. */
|
|
39
|
+
heading: string;
|
|
40
|
+
/**
|
|
41
|
+
* Parent pages, outermost first, as `{label, href}`. Don't include the current page.
|
|
42
|
+
* In HTML pass JSON: `breadcrumbs='[{"label":"Products","href":"/products"}]'`.
|
|
43
|
+
*/
|
|
44
|
+
breadcrumbs: Breadcrumb[];
|
|
45
|
+
/** Shows previous/next arrows for stepping through records (orders, products). */
|
|
46
|
+
pagination: boolean;
|
|
47
|
+
/** Enables the previous arrow. */
|
|
48
|
+
hasPrevious: boolean;
|
|
49
|
+
/** Enables the next arrow. */
|
|
50
|
+
hasNext: boolean;
|
|
51
|
+
static styles: import("lit").CSSResult[];
|
|
52
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
53
|
+
}
|
|
54
|
+
declare global {
|
|
55
|
+
interface HTMLElementTagNameMap {
|
|
56
|
+
'cm-page-header': CmPageHeader;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
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 _CmPageHeader_instances, _CmPageHeader_emit;
|
|
7
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
8
|
+
import { base, define } from '../base.js';
|
|
9
|
+
import './icon.js';
|
|
10
|
+
/**
|
|
11
|
+
* Top of an admin page: breadcrumbs, the page title and the page's main actions.
|
|
12
|
+
* The Figma file calls this the "Save Bar" (80px desktop, 50px mobile).
|
|
13
|
+
* On narrow screens the breadcrumbs collapse to a back link to the parent page.
|
|
14
|
+
* @element cm-page-header
|
|
15
|
+
* @slot actions - Buttons, right-aligned, secondary first and the primary action last (large size).
|
|
16
|
+
* @slot title-adornment - Badge or count next to the title.
|
|
17
|
+
* @fires cm-previous - When the previous-record arrow is pressed (with `pagination`).
|
|
18
|
+
* @fires cm-next - When the next-record arrow is pressed (with `pagination`).
|
|
19
|
+
*/
|
|
20
|
+
export class CmPageHeader extends LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
_CmPageHeader_instances.add(this);
|
|
24
|
+
/** Page title, rendered as the page's `<h1>` and as the last (current) breadcrumb. */
|
|
25
|
+
this.heading = '';
|
|
26
|
+
/**
|
|
27
|
+
* Parent pages, outermost first, as `{label, href}`. Don't include the current page.
|
|
28
|
+
* In HTML pass JSON: `breadcrumbs='[{"label":"Products","href":"/products"}]'`.
|
|
29
|
+
*/
|
|
30
|
+
this.breadcrumbs = [];
|
|
31
|
+
/** Shows previous/next arrows for stepping through records (orders, products). */
|
|
32
|
+
this.pagination = false;
|
|
33
|
+
/** Enables the previous arrow. */
|
|
34
|
+
this.hasPrevious = false;
|
|
35
|
+
/** Enables the next arrow. */
|
|
36
|
+
this.hasNext = false;
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
const crumbs = Array.isArray(this.breadcrumbs) ? this.breadcrumbs : [];
|
|
40
|
+
const parent = [...crumbs].reverse().find((c) => c.href);
|
|
41
|
+
return html `<header part="header">
|
|
42
|
+
<div class="lead">
|
|
43
|
+
${parent
|
|
44
|
+
? html `<a class="back" part="back" href=${parent.href} aria-label=${`Back to ${parent.label}`}><cm-icon name="chevron-left" size="20"></cm-icon></a>`
|
|
45
|
+
: nothing}
|
|
46
|
+
<div class="titles">
|
|
47
|
+
${crumbs.length
|
|
48
|
+
? html `<nav aria-label="Breadcrumb" part="breadcrumbs"><ol>
|
|
49
|
+
${crumbs.map((c) => html `<li>${c.href ? html `<a href=${c.href}>${c.label}</a>` : c.label}</li>`)}
|
|
50
|
+
<li><span aria-current="page">${this.heading}</span></li>
|
|
51
|
+
</ol></nav>`
|
|
52
|
+
: nothing}
|
|
53
|
+
<h1 part="title"><span class="text">${this.heading}</span><slot name="title-adornment"></slot></h1>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="actions">
|
|
57
|
+
${this.pagination
|
|
58
|
+
? html `<div class="arrows" role="group" aria-label="Records">
|
|
59
|
+
<button class="arrow" type="button" aria-label="Previous" ?disabled=${!this.hasPrevious} @click=${() => __classPrivateFieldGet(this, _CmPageHeader_instances, "m", _CmPageHeader_emit).call(this, 'cm-previous')}><cm-icon name="chevron-left" size="16"></cm-icon></button>
|
|
60
|
+
<button class="arrow" type="button" aria-label="Next" ?disabled=${!this.hasNext} @click=${() => __classPrivateFieldGet(this, _CmPageHeader_instances, "m", _CmPageHeader_emit).call(this, 'cm-next')}><cm-icon name="chevron-right" size="16"></cm-icon></button>
|
|
61
|
+
</div>`
|
|
62
|
+
: nothing}
|
|
63
|
+
<slot name="actions"></slot>
|
|
64
|
+
</div>
|
|
65
|
+
</header>`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_CmPageHeader_instances = new WeakSet(), _CmPageHeader_emit = function _CmPageHeader_emit(name) {
|
|
69
|
+
this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true }));
|
|
70
|
+
};
|
|
71
|
+
CmPageHeader.properties = {
|
|
72
|
+
heading: {},
|
|
73
|
+
breadcrumbs: { type: Array },
|
|
74
|
+
pagination: { type: Boolean, reflect: true },
|
|
75
|
+
hasPrevious: { type: Boolean, attribute: 'has-previous' },
|
|
76
|
+
hasNext: { type: Boolean, attribute: 'has-next' },
|
|
77
|
+
};
|
|
78
|
+
CmPageHeader.styles = [
|
|
79
|
+
base,
|
|
80
|
+
css `
|
|
81
|
+
:host { display: block; }
|
|
82
|
+
header {
|
|
83
|
+
display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--cm-space-20);
|
|
84
|
+
min-height: 80px; padding: var(--cm-space-12) var(--cm-space-20);
|
|
85
|
+
background: var(--cm-bg-surface); border-bottom: var(--cm-border-1) solid var(--cm-border-default);
|
|
86
|
+
}
|
|
87
|
+
.lead { flex: 1 1 280px; display: flex; align-items: center; gap: var(--cm-space-10); min-width: 0; }
|
|
88
|
+
.titles { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
89
|
+
nav ol { display: flex; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--cm-text-tertiary); }
|
|
90
|
+
nav li { white-space: nowrap; }
|
|
91
|
+
nav li + li::before { content: '/'; padding: 0 0.35em; }
|
|
92
|
+
nav a { color: inherit; text-decoration: none; border-radius: var(--cm-radius-xs); }
|
|
93
|
+
nav a:hover { color: var(--cm-text-default); text-decoration: underline; }
|
|
94
|
+
nav a:focus-visible, .back:focus-visible, .arrow:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
95
|
+
nav [aria-current] { color: var(--cm-text-default); }
|
|
96
|
+
h1 {
|
|
97
|
+
display: flex; align-items: center; gap: var(--cm-space-10); margin: 0; min-width: 0;
|
|
98
|
+
font-size: 26px; font-weight: 500; line-height: 1.2;
|
|
99
|
+
}
|
|
100
|
+
.text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
101
|
+
.actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-20); margin-left: auto; }
|
|
102
|
+
.arrows { display: flex; gap: var(--cm-space-10); }
|
|
103
|
+
.arrow, .back {
|
|
104
|
+
display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
|
|
105
|
+
border: var(--cm-border-1) solid var(--cm-border-input); border-radius: var(--cm-radius-sm);
|
|
106
|
+
background: var(--cm-bg-surface); color: var(--cm-icon-selected); cursor: pointer;
|
|
107
|
+
}
|
|
108
|
+
.arrow:hover:not(:disabled), .back:hover { background: var(--cm-bg-hover); }
|
|
109
|
+
.arrow:disabled { color: var(--cm-text-secondary); border-color: var(--cm-border-default); cursor: not-allowed; }
|
|
110
|
+
.back { display: none; border: 0; flex: none; text-decoration: none; }
|
|
111
|
+
@media (max-width: 640px) {
|
|
112
|
+
header { flex-wrap: nowrap; min-height: 50px; padding: var(--cm-space-10); gap: var(--cm-space-10); }
|
|
113
|
+
.lead { flex: 1 1 auto; }
|
|
114
|
+
nav { display: none; }
|
|
115
|
+
.back { display: inline-flex; }
|
|
116
|
+
h1 { font-size: 18px; font-weight: 600; }
|
|
117
|
+
.actions { gap: var(--cm-space-10); }
|
|
118
|
+
}
|
|
119
|
+
`,
|
|
120
|
+
];
|
|
121
|
+
define('cm-page-header', CmPageHeader);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* A whole admin page: the page header across the top, then the content on `bg-page` with page padding
|
|
4
|
+
* (`space-20`, or `space-10` when the page is 640px wide or less).
|
|
5
|
+
* `<cm-page><cm-page-header slot="header" heading="Orders"></cm-page-header><cm-layout>…</cm-layout></cm-page>`
|
|
6
|
+
* @element cm-page
|
|
7
|
+
* @slot header - A `cm-page-header`. Runs edge to edge.
|
|
8
|
+
* @slot - The page content, usually a `cm-layout`.
|
|
9
|
+
* @slot footer - A `cm-save-bar` or `cm-action-bar`, after the content.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CmPage extends LitElement {
|
|
12
|
+
static properties: {
|
|
13
|
+
fullWidth: {
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
attribute: string;
|
|
16
|
+
reflect: boolean;
|
|
17
|
+
};
|
|
18
|
+
narrow: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
reflect: boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** Lets the content use every pixel of width (wide tables, reports). By default it stops at 1600px, centred. */
|
|
24
|
+
fullWidth: boolean;
|
|
25
|
+
/** Content at most 800px wide, centred: for settings and single-column forms. */
|
|
26
|
+
narrow: boolean;
|
|
27
|
+
static styles: import("lit").CSSResult[];
|
|
28
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
29
|
+
}
|
|
30
|
+
declare global {
|
|
31
|
+
interface HTMLElementTagNameMap {
|
|
32
|
+
'cm-page': CmPage;
|
|
33
|
+
}
|
|
34
|
+
}
|