@commmerce/ui 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendar.js +2 -0
- package/dist/cdn.js +1004 -645
- package/dist/components/action-menu.d.ts +28 -1
- package/dist/components/action-menu.js +86 -17
- package/dist/components/badge.d.ts +3 -2
- package/dist/components/badge.js +4 -3
- package/dist/components/bottom-sheet.js +1 -1
- package/dist/components/button.d.ts +5 -1
- package/dist/components/button.js +18 -6
- package/dist/components/card.d.ts +38 -0
- package/dist/components/card.js +77 -12
- package/dist/components/checkbox.js +7 -2
- package/dist/components/color-field.js +2 -0
- package/dist/components/combobox.d.ts +27 -2
- package/dist/components/combobox.js +109 -15
- package/dist/components/data-table.d.ts +127 -9
- package/dist/components/data-table.js +577 -67
- package/dist/components/date-picker.d.ts +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-range-picker.d.ts +1 -1
- package/dist/components/date-range-picker.js +2 -2
- package/dist/components/empty-state.d.ts +8 -6
- package/dist/components/empty-state.js +26 -17
- package/dist/components/file-upload.d.ts +49 -4
- package/dist/components/file-upload.js +136 -29
- package/dist/components/layout.d.ts +2 -2
- package/dist/components/layout.js +5 -5
- package/dist/components/menu-item.d.ts +18 -0
- package/dist/components/menu-item.js +8 -0
- package/dist/components/page-header.d.ts +6 -0
- package/dist/components/page-header.js +22 -5
- package/dist/components/pagination.d.ts +3 -2
- package/dist/components/pagination.js +13 -10
- package/dist/components/radio.js +4 -2
- package/dist/components/resource-list.d.ts +28 -3
- package/dist/components/resource-list.js +47 -15
- package/dist/components/search.d.ts +2 -2
- package/dist/components/search.js +4 -2
- package/dist/components/segmented-control.js +1 -1
- package/dist/components/select.d.ts +11 -1
- package/dist/components/select.js +17 -4
- package/dist/components/side-navigation.d.ts +1 -1
- package/dist/components/side-navigation.js +5 -3
- package/dist/components/signature-field.js +2 -2
- package/dist/components/status-tabs.d.ts +24 -4
- package/dist/components/status-tabs.js +82 -9
- package/dist/components/table-header.d.ts +1 -1
- package/dist/components/table-header.js +3 -3
- package/dist/components/tag.d.ts +7 -0
- package/dist/components/tag.js +6 -3
- package/dist/components/text-field.d.ts +1 -1
- package/dist/components/text-field.js +3 -1
- package/dist/components/toggle.js +3 -1
- package/dist/components/tooltip.d.ts +5 -2
- package/dist/components/tooltip.js +14 -9
- package/dist/custom-elements.json +1594 -137
- package/dist/density.d.ts +21 -0
- package/dist/density.js +46 -0
- package/dist/field.d.ts +9 -5
- package/dist/field.js +16 -10
- package/dist/index.d.ts +1 -1
- package/dist/popover.js +1 -1
- package/package.json +3 -3
|
@@ -2,6 +2,7 @@ import { type PropertyValues } from 'lit';
|
|
|
2
2
|
import { CmLocalizedElement } from '../localize.js';
|
|
3
3
|
import { type MenuItem } from './menu-item.js';
|
|
4
4
|
import './icon.js';
|
|
5
|
+
import './spinner.js';
|
|
5
6
|
declare const strings: {
|
|
6
7
|
/** Text of the trigger button (its accessible name when `icon-only`), and the menu's name. */
|
|
7
8
|
label: string;
|
|
@@ -14,7 +15,11 @@ declare module '../localize.js' {
|
|
|
14
15
|
/**
|
|
15
16
|
* A button that opens a short list of actions: row actions in a table ("Cancel shipment", "Change tracking
|
|
16
17
|
* info"), "Add…" menus, or the account menu with the merchant's name and email on top. The highlighted choice
|
|
17
|
-
* is black with white text.
|
|
18
|
+
* is black with white text; a destructive (`critical`) choice turns red on red instead.
|
|
19
|
+
*
|
|
20
|
+
* Rows (owner standard, 1.6): 36px (32px with `density="compact"`, 44px on touch screens), 12px side padding,
|
|
21
|
+
* 14px text, 16px icons, an optional shortcut hint at 12px in grey, and 12px section headings. The same rows as the
|
|
22
|
+
* options of `cm-select` and `cm-combobox`.
|
|
18
23
|
*
|
|
19
24
|
* Follows the WAI-ARIA menu button pattern: the trigger has `aria-haspopup` and `aria-expanded`; ↓/↑ (or
|
|
20
25
|
* Enter/Space) open it, ↓/↑ Home/End and the first letter move between choices, Enter/Space choose, Esc closes
|
|
@@ -22,6 +27,11 @@ declare module '../localize.js' {
|
|
|
22
27
|
* @element cm-action-menu
|
|
23
28
|
* @slot - `cm-menu-item`s, with `<hr>` between groups.
|
|
24
29
|
* @slot trigger - Your own trigger button (optional). The menu sets its ARIA state.
|
|
30
|
+
* @csspart trigger - The built-in trigger button.
|
|
31
|
+
* @csspart menu - The floating panel.
|
|
32
|
+
* @csspart item - Each choice.
|
|
33
|
+
* @csspart shortcut - A choice's shortcut hint.
|
|
34
|
+
* @csspart section - A section heading.
|
|
25
35
|
* @fires cm-select - When a choice is made. `detail: { value, item }`. Cancelable: for link items, `preventDefault()` stops the navigation.
|
|
26
36
|
* @fires cm-toggle - When the menu opens or closes. `detail: { open }`.
|
|
27
37
|
*/
|
|
@@ -51,6 +61,17 @@ export declare class CmActionMenu extends CmLocalizedElement {
|
|
|
51
61
|
};
|
|
52
62
|
heading: {};
|
|
53
63
|
subheading: {};
|
|
64
|
+
density: {
|
|
65
|
+
reflect: boolean;
|
|
66
|
+
};
|
|
67
|
+
loading: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
reflect: boolean;
|
|
70
|
+
};
|
|
71
|
+
disabled: {
|
|
72
|
+
type: BooleanConstructor;
|
|
73
|
+
reflect: boolean;
|
|
74
|
+
};
|
|
54
75
|
_slotted: {
|
|
55
76
|
state: boolean;
|
|
56
77
|
};
|
|
@@ -79,6 +100,12 @@ export declare class CmActionMenu extends CmLocalizedElement {
|
|
|
79
100
|
heading: string;
|
|
80
101
|
/** Smaller line under the heading, e.g. the email. */
|
|
81
102
|
subheading: string;
|
|
103
|
+
/** Row height: `comfortable` 36px rows (the default) or `compact` 32px rows for dense tables and toolbars. Since 1.6. */
|
|
104
|
+
density?: 'comfortable' | 'compact';
|
|
105
|
+
/** Shows a spinner row instead of the choices while you load them (the menu is `aria-busy`). Since 1.6. */
|
|
106
|
+
loading: boolean;
|
|
107
|
+
/** The built-in trigger can't be used (it is a disabled button); a slotted trigger is yours to disable. Since 1.6. */
|
|
108
|
+
disabled: boolean;
|
|
82
109
|
_slotted: MenuItem[];
|
|
83
110
|
_active: number;
|
|
84
111
|
_custom: boolean;
|
|
@@ -9,12 +9,13 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
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
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _CmActionMenu_instances, _CmActionMenu_observer, _CmActionMenu_id, _CmActionMenu_typed, _CmActionMenu_typedAt, _CmActionMenu_read, _CmActionMenu_outside, _CmActionMenu_trigger, _CmActionMenu_enabled, _CmActionMenu_setOpen, _CmActionMenu_focusActive, _CmActionMenu_triggerKey, _CmActionMenu_triggerClick, _CmActionMenu_move, _CmActionMenu_menuKey, _CmActionMenu_choose, _CmActionMenu_item;
|
|
12
|
+
var _CmActionMenu_instances, _CmActionMenu_observer, _CmActionMenu_id, _CmActionMenu_typed, _CmActionMenu_typedAt, _CmActionMenu_read, _CmActionMenu_outside, _CmActionMenu_trigger, _CmActionMenu_enabled, _CmActionMenu_setOpen, _CmActionMenu_focusActive, _CmActionMenu_triggerKey, _CmActionMenu_triggerClick, _CmActionMenu_move, _CmActionMenu_menuKey, _CmActionMenu_choose, _CmActionMenu_item, _CmActionMenu_rows;
|
|
13
13
|
import { html, css, nothing } from 'lit';
|
|
14
14
|
import { base, define, nextId } from '../base.js';
|
|
15
15
|
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
16
16
|
import { readMenuItems, watchMenuItems } from './menu-item.js';
|
|
17
17
|
import './icon.js';
|
|
18
|
+
import './spinner.js';
|
|
18
19
|
const strings = defineStrings('actionMenu', {
|
|
19
20
|
/** Text of the trigger button (its accessible name when `icon-only`), and the menu's name. */
|
|
20
21
|
label: 'Actions',
|
|
@@ -22,7 +23,11 @@ const strings = defineStrings('actionMenu', {
|
|
|
22
23
|
/**
|
|
23
24
|
* A button that opens a short list of actions: row actions in a table ("Cancel shipment", "Change tracking
|
|
24
25
|
* info"), "Add…" menus, or the account menu with the merchant's name and email on top. The highlighted choice
|
|
25
|
-
* is black with white text.
|
|
26
|
+
* is black with white text; a destructive (`critical`) choice turns red on red instead.
|
|
27
|
+
*
|
|
28
|
+
* Rows (owner standard, 1.6): 36px (32px with `density="compact"`, 44px on touch screens), 12px side padding,
|
|
29
|
+
* 14px text, 16px icons, an optional shortcut hint at 12px in grey, and 12px section headings. The same rows as the
|
|
30
|
+
* options of `cm-select` and `cm-combobox`.
|
|
26
31
|
*
|
|
27
32
|
* Follows the WAI-ARIA menu button pattern: the trigger has `aria-haspopup` and `aria-expanded`; ↓/↑ (or
|
|
28
33
|
* Enter/Space) open it, ↓/↑ Home/End and the first letter move between choices, Enter/Space choose, Esc closes
|
|
@@ -30,6 +35,11 @@ const strings = defineStrings('actionMenu', {
|
|
|
30
35
|
* @element cm-action-menu
|
|
31
36
|
* @slot - `cm-menu-item`s, with `<hr>` between groups.
|
|
32
37
|
* @slot trigger - Your own trigger button (optional). The menu sets its ARIA state.
|
|
38
|
+
* @csspart trigger - The built-in trigger button.
|
|
39
|
+
* @csspart menu - The floating panel.
|
|
40
|
+
* @csspart item - Each choice.
|
|
41
|
+
* @csspart shortcut - A choice's shortcut hint.
|
|
42
|
+
* @csspart section - A section heading.
|
|
33
43
|
* @fires cm-select - When a choice is made. `detail: { value, item }`. Cancelable: for link items, `preventDefault()` stops the navigation.
|
|
34
44
|
* @fires cm-toggle - When the menu opens or closes. `detail: { open }`.
|
|
35
45
|
*/
|
|
@@ -53,6 +63,10 @@ export class CmActionMenu extends CmLocalizedElement {
|
|
|
53
63
|
this.heading = '';
|
|
54
64
|
/** Smaller line under the heading, e.g. the email. */
|
|
55
65
|
this.subheading = '';
|
|
66
|
+
/** Shows a spinner row instead of the choices while you load them (the menu is `aria-busy`). Since 1.6. */
|
|
67
|
+
this.loading = false;
|
|
68
|
+
/** The built-in trigger can't be used (it is a disabled button); a slotted trigger is yours to disable. Since 1.6. */
|
|
69
|
+
this.disabled = false;
|
|
56
70
|
this._slotted = [];
|
|
57
71
|
this._active = -1;
|
|
58
72
|
this._custom = false;
|
|
@@ -63,6 +77,8 @@ export class CmActionMenu extends CmLocalizedElement {
|
|
|
63
77
|
_CmActionMenu_outside.set(this, (e) => { if (this.open && !e.composedPath().includes(this))
|
|
64
78
|
__classPrivateFieldGet(this, _CmActionMenu_instances, "m", _CmActionMenu_setOpen).call(this, false); });
|
|
65
79
|
_CmActionMenu_triggerKey.set(this, (e) => {
|
|
80
|
+
if (this.disabled)
|
|
81
|
+
return;
|
|
66
82
|
if (e.key === 'ArrowDown') {
|
|
67
83
|
e.preventDefault();
|
|
68
84
|
this.show('first');
|
|
@@ -77,7 +93,8 @@ export class CmActionMenu extends CmLocalizedElement {
|
|
|
77
93
|
this.hide(true);
|
|
78
94
|
}
|
|
79
95
|
});
|
|
80
|
-
_CmActionMenu_triggerClick.set(this, () => { if (this.
|
|
96
|
+
_CmActionMenu_triggerClick.set(this, () => { if (this.disabled)
|
|
97
|
+
return; if (this.open)
|
|
81
98
|
this.hide();
|
|
82
99
|
else
|
|
83
100
|
this.show(); });
|
|
@@ -162,7 +179,7 @@ export class CmActionMenu extends CmLocalizedElement {
|
|
|
162
179
|
set('aria-controls', `${__classPrivateFieldGet(this, _CmActionMenu_id, "f")}-m`);
|
|
163
180
|
}
|
|
164
181
|
}
|
|
165
|
-
if (changed.has('open') && this.open && this._active < 0) {
|
|
182
|
+
if ((changed.has('open') || changed.has('loading')) && this.open && this._active < 0) {
|
|
166
183
|
const en = __classPrivateFieldGet(this, _CmActionMenu_instances, "m", _CmActionMenu_enabled).call(this);
|
|
167
184
|
this._active = en[0] ?? -1;
|
|
168
185
|
this.updateComplete.then(() => __classPrivateFieldGet(this, _CmActionMenu_instances, "m", _CmActionMenu_focusActive).call(this));
|
|
@@ -175,14 +192,16 @@ export class CmActionMenu extends CmLocalizedElement {
|
|
|
175
192
|
? html `<slot name="trigger" @click=${__classPrivateFieldGet(this, _CmActionMenu_triggerClick, "f")} @keydown=${__classPrivateFieldGet(this, _CmActionMenu_triggerKey, "f")} @slotchange=${() => __classPrivateFieldGet(this, _CmActionMenu_instances, "m", _CmActionMenu_read).call(this)}></slot>`
|
|
176
193
|
: html `<button type="button" class="trigger ${this.iconOnly ? 'icon' : ''}" part="trigger" aria-haspopup="menu"
|
|
177
194
|
aria-expanded=${String(this.open)} aria-controls="${__classPrivateFieldGet(this, _CmActionMenu_id, "f")}-m" aria-label=${this.iconOnly ? name : nothing}
|
|
178
|
-
@click=${__classPrivateFieldGet(this, _CmActionMenu_triggerClick, "f")} @keydown=${__classPrivateFieldGet(this, _CmActionMenu_triggerKey, "f")}>${this.iconOnly
|
|
195
|
+
?disabled=${this.disabled} @click=${__classPrivateFieldGet(this, _CmActionMenu_triggerClick, "f")} @keydown=${__classPrivateFieldGet(this, _CmActionMenu_triggerKey, "f")}>${this.iconOnly
|
|
179
196
|
? html `<cm-icon name=${this.icon} size="18"></cm-icon>`
|
|
180
197
|
: html `<span>${name}</span><cm-icon name="chevron-down" size="14"></cm-icon>`}</button>`;
|
|
181
198
|
return html `${trigger}
|
|
182
199
|
<div class="pop" part="menu" ?hidden=${!this.open}>
|
|
183
200
|
${this.heading ? html `<div class="head" part="heading"><strong>${this.heading}</strong>${this.subheading ? html `<span>${this.subheading}</span>` : nothing}</div>` : nothing}
|
|
184
|
-
<div role="menu" id="${__classPrivateFieldGet(this, _CmActionMenu_id, "f")}-m" aria-label=${this.heading || this.label} @keydown=${__classPrivateFieldGet(this, _CmActionMenu_menuKey, "f")}>
|
|
185
|
-
${
|
|
201
|
+
<div role="menu" id="${__classPrivateFieldGet(this, _CmActionMenu_id, "f")}-m" aria-label=${this.heading || this.label} aria-busy=${this.loading ? 'true' : nothing} @keydown=${__classPrivateFieldGet(this, _CmActionMenu_menuKey, "f")}>
|
|
202
|
+
${this.loading
|
|
203
|
+
? html `<div class="loading" role="presentation"><cm-spinner size="small" aria-hidden="true"></cm-spinner><span>${this.t('loading')}</span></div>`
|
|
204
|
+
: __classPrivateFieldGet(this, _CmActionMenu_instances, "m", _CmActionMenu_rows).call(this, items)}
|
|
186
205
|
</div>
|
|
187
206
|
</div>
|
|
188
207
|
<slot hidden></slot>`;
|
|
@@ -195,7 +214,11 @@ _CmActionMenu_observer = new WeakMap(), _CmActionMenu_id = new WeakMap(), _CmAct
|
|
|
195
214
|
if (this._custom)
|
|
196
215
|
return this.querySelector(':scope > [slot="trigger"]');
|
|
197
216
|
return this.renderRoot.querySelector('.trigger');
|
|
198
|
-
}, _CmActionMenu_enabled = function _CmActionMenu_enabled() {
|
|
217
|
+
}, _CmActionMenu_enabled = function _CmActionMenu_enabled() {
|
|
218
|
+
if (this.loading)
|
|
219
|
+
return [];
|
|
220
|
+
return this.menuItems.map((it, i) => (!it.divider && !it.heading && !it.disabled ? i : -1)).filter((i) => i >= 0);
|
|
221
|
+
}, _CmActionMenu_setOpen = function _CmActionMenu_setOpen(v) {
|
|
199
222
|
if (this.open === v)
|
|
200
223
|
return;
|
|
201
224
|
this.open = v;
|
|
@@ -220,7 +243,8 @@ _CmActionMenu_observer = new WeakMap(), _CmActionMenu_id = new WeakMap(), _CmAct
|
|
|
220
243
|
if (it.divider)
|
|
221
244
|
return html `<div role="separator"></div>`;
|
|
222
245
|
const cls = `item${it.critical ? ' critical' : ''}${i === this._active ? ' active' : ''}`;
|
|
223
|
-
const inner = html `${it.icon ? html `<cm-icon name=${it.icon} size="16"></cm-icon>` : nothing}<span>${it.label}</span
|
|
246
|
+
const inner = html `${it.icon ? html `<cm-icon name=${it.icon} size="16"></cm-icon>` : nothing}<span class="label">${it.label}</span>${it.shortcut
|
|
247
|
+
? html `<span class="shortcut" part="shortcut" aria-hidden="true">${it.shortcut}</span>` : nothing}`;
|
|
224
248
|
const common = {
|
|
225
249
|
over: () => { if (!it.disabled)
|
|
226
250
|
this._active = i; },
|
|
@@ -228,9 +252,26 @@ _CmActionMenu_observer = new WeakMap(), _CmActionMenu_id = new WeakMap(), _CmAct
|
|
|
228
252
|
};
|
|
229
253
|
return it.href && !it.disabled
|
|
230
254
|
? html `<a class=${cls} part="item" role="menuitem" tabindex="-1" data-i=${i} href=${it.href}
|
|
231
|
-
@pointerenter=${common.over} @click=${common.click}>${inner}</a>`
|
|
255
|
+
aria-keyshortcuts=${it.shortcut || nothing} @pointerenter=${common.over} @click=${common.click}>${inner}</a>`
|
|
232
256
|
: html `<button type="button" class=${cls} part="item" role="menuitem" tabindex="-1" data-i=${i}
|
|
233
|
-
aria-disabled=${it.disabled ? 'true' : nothing} @pointerenter=${common.over} @click=${common.click}>${inner}</button>`;
|
|
257
|
+
aria-disabled=${it.disabled ? 'true' : nothing} aria-keyshortcuts=${it.shortcut || nothing} @pointerenter=${common.over} @click=${common.click}>${inner}</button>`;
|
|
258
|
+
}, _CmActionMenu_rows = function _CmActionMenu_rows(items) {
|
|
259
|
+
const out = [];
|
|
260
|
+
for (let i = 0; i < items.length; i++) {
|
|
261
|
+
const it = items[i];
|
|
262
|
+
if (!it.heading) {
|
|
263
|
+
out.push(__classPrivateFieldGet(this, _CmActionMenu_instances, "m", _CmActionMenu_item).call(this, it, i));
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
const id = `${__classPrivateFieldGet(this, _CmActionMenu_id, "f")}-h${i}`;
|
|
267
|
+
const members = [];
|
|
268
|
+
let j = i + 1;
|
|
269
|
+
for (; j < items.length && !items[j].heading && !items[j].divider; j++)
|
|
270
|
+
members.push(__classPrivateFieldGet(this, _CmActionMenu_instances, "m", _CmActionMenu_item).call(this, items[j], j));
|
|
271
|
+
out.push(html `<div role="group" aria-labelledby=${id}><div class="section" part="section" id=${id} role="presentation">${it.label}</div>${members}</div>`);
|
|
272
|
+
i = j - 1;
|
|
273
|
+
}
|
|
274
|
+
return out;
|
|
234
275
|
};
|
|
235
276
|
CmActionMenu.properties = {
|
|
236
277
|
items: { type: Array },
|
|
@@ -242,6 +283,9 @@ CmActionMenu.properties = {
|
|
|
242
283
|
align: { reflect: true },
|
|
243
284
|
heading: {},
|
|
244
285
|
subheading: {},
|
|
286
|
+
density: { reflect: true },
|
|
287
|
+
loading: { type: Boolean, reflect: true },
|
|
288
|
+
disabled: { type: Boolean, reflect: true },
|
|
245
289
|
_slotted: { state: true },
|
|
246
290
|
_active: { state: true },
|
|
247
291
|
_custom: { state: true },
|
|
@@ -256,31 +300,56 @@ CmActionMenu.styles = [
|
|
|
256
300
|
border-radius: var(--cm-radius-sm); cursor: pointer;
|
|
257
301
|
}
|
|
258
302
|
.trigger.icon { width: var(--cm-control-height-md, 36px); padding: 0; justify-content: center; border-color: transparent; background: none; }
|
|
259
|
-
.trigger:hover { background: var(--cm-bg-hover); }
|
|
260
|
-
|
|
303
|
+
.trigger:hover:not(:disabled) { background: var(--cm-bg-hover); }
|
|
304
|
+
.trigger:disabled { color: var(--cm-text-secondary); border-color: var(--cm-border-subtle); background: var(--cm-bg-input-filled); cursor: not-allowed; }
|
|
305
|
+
.trigger.icon:disabled { background: none; }
|
|
306
|
+
.trigger:active { background: color-mix(in srgb, var(--cm-bg-hover), var(--cm-text-default) 8%); }
|
|
307
|
+
.trigger[aria-expanded='true'] { background: var(--cm-bg-hover); }
|
|
308
|
+
/* Touch screens (1.6, like cm-button): the trigger is drawn 40px (40 x 40 icon-only) with a 44px hit area. */
|
|
309
|
+
@media (pointer: coarse) {
|
|
310
|
+
.trigger { position: relative; min-height: var(--cm-control-height-lg, 40px); } .trigger.icon { width: var(--cm-control-height-lg, 40px); }
|
|
311
|
+
.trigger::after { content: ''; position: absolute; inset: -2px; }
|
|
312
|
+
.item { min-height: var(--cm-control-height-touch, 44px); }
|
|
313
|
+
}
|
|
261
314
|
.trigger:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
262
315
|
.pop {
|
|
263
|
-
position: absolute; z-index: 20; top: calc(100% + 4px); inset-inline-start: 0; min-width: 180px; max-width: min(320px, calc(100vw - 32px));
|
|
316
|
+
position: absolute; z-index: 20; top: calc(100% + 4px); inset-inline-start: 0; width: max-content; min-width: 180px; max-width: min(320px, calc(100vw - 32px));
|
|
264
317
|
padding: var(--cm-space-4); text-align: start; background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-subtle);
|
|
265
318
|
border-radius: var(--cm-radius-md); box-shadow: var(--cm-shadow-md);
|
|
266
319
|
}
|
|
267
320
|
:host([align='end']) .pop { inset-inline-start: auto; inset-inline-end: 0; }
|
|
268
321
|
.pop[hidden] { display: none; }
|
|
269
|
-
.head { padding: var(--cm-space-4) var(--cm-space-
|
|
322
|
+
.head { padding: var(--cm-space-4) var(--cm-space-12) var(--cm-space-8); margin-bottom: 4px; border-bottom: var(--cm-border-1) solid var(--cm-border-subtle); overflow-wrap: anywhere; }
|
|
270
323
|
.head strong { display: block; font-size: 14px; font-weight: 500; }
|
|
271
324
|
.head span { display: block; font-size: var(--cm-font-size-12); color: var(--cm-text-tertiary); }
|
|
272
325
|
[role='menu'] { display: flex; flex-direction: column; outline: none; }
|
|
273
326
|
.item {
|
|
274
|
-
display: flex; align-items: center; gap: var(--cm-space-8); width: 100%; min-height: var(--cm-control-height-
|
|
327
|
+
display: flex; align-items: center; gap: var(--cm-space-8); width: 100%; min-height: var(--cm-control-height-md, 36px); padding: var(--cm-space-4) var(--cm-space-12); font: inherit; font-size: var(--cm-font-size-14); line-height: var(--cm-line-height-14);
|
|
275
328
|
color: var(--cm-text-default); text-align: start; text-decoration: none; background: none; border: 0; border-radius: var(--cm-radius-sm);
|
|
276
329
|
cursor: pointer; outline: none;
|
|
277
330
|
}
|
|
331
|
+
:host([density='compact']) .item { min-height: var(--cm-control-height-sm, 32px); }
|
|
332
|
+
.item cm-icon { flex: none; }
|
|
333
|
+
.label { flex: 1; min-width: 0; }
|
|
334
|
+
.shortcut { flex: none; padding-inline-start: var(--cm-space-16); font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12); color: var(--cm-text-tertiary); }
|
|
278
335
|
.item.critical { color: var(--cm-text-critical); }
|
|
279
|
-
.item[aria-disabled='true'] { color: var(--cm-text-secondary); cursor:
|
|
336
|
+
.item[aria-disabled='true'] { color: var(--cm-text-secondary); cursor: not-allowed; }
|
|
337
|
+
.item[aria-disabled='true'] .shortcut { color: var(--cm-text-secondary); }
|
|
280
338
|
.item.active:not([aria-disabled='true']), .item:not([aria-disabled='true']):hover {
|
|
281
339
|
background: var(--cm-bg-panel-header); color: var(--cm-text-on-dark);
|
|
282
340
|
}
|
|
341
|
+
.item.active:not([aria-disabled='true']) .shortcut, .item:not([aria-disabled='true']):hover .shortcut { color: var(--cm-text-on-dark-secondary); }
|
|
342
|
+
.item:not([aria-disabled='true']):active { background: color-mix(in srgb, var(--cm-bg-panel-header), var(--cm-text-on-dark) 16%); }
|
|
343
|
+
.item.critical.active:not([aria-disabled='true']), .item.critical:not([aria-disabled='true']):hover { background: var(--cm-bg-critical); color: var(--cm-text-critical); }
|
|
344
|
+
.item.critical.active .shortcut, .item.critical:hover .shortcut { color: var(--cm-text-critical); }
|
|
345
|
+
.item.critical:not([aria-disabled='true']):active { background: color-mix(in srgb, var(--cm-bg-critical), var(--cm-text-critical) 12%); }
|
|
283
346
|
.item.active:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 1px; }
|
|
347
|
+
[role='group'] { display: flex; flex-direction: column; }
|
|
348
|
+
.section {
|
|
349
|
+
padding: var(--cm-space-8) var(--cm-space-12) var(--cm-space-4); font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12);
|
|
350
|
+
font-weight: 500; color: var(--cm-text-tertiary);
|
|
351
|
+
}
|
|
352
|
+
.loading { display: flex; align-items: center; gap: var(--cm-space-8); min-height: var(--cm-control-height-md, 36px); padding: var(--cm-space-4) var(--cm-space-12); font-size: var(--cm-font-size-14); color: var(--cm-text-tertiary); }
|
|
284
353
|
[role='separator'] { height: 0; margin: 4px 0; border-top: var(--cm-border-1) solid var(--cm-border-subtle); }
|
|
285
354
|
`,
|
|
286
355
|
];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import { type Tone } from '../base.js';
|
|
3
3
|
/**
|
|
4
|
-
* Status pill in sentence case ("Order placed", "5 open"): 12px medium text on a tinted
|
|
5
|
-
* sentence case; since 1.5 it is shown as written (it was upper-cased with wide
|
|
4
|
+
* Status pill in sentence case ("Order placed", "5 open"): 12px medium text on a tinted 24px pill (owner standard, 1.6;
|
|
5
|
+
* 20px in 1.5). Write the text in sentence case; since 1.5 it is shown as written (it was upper-cased with wide
|
|
6
|
+
* letter-spacing before).
|
|
6
7
|
* @element cm-badge
|
|
7
8
|
* @slot - Status text.
|
|
8
9
|
*/
|
package/dist/components/badge.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { base, define } from '../base.js';
|
|
3
3
|
/**
|
|
4
|
-
* Status pill in sentence case ("Order placed", "5 open"): 12px medium text on a tinted
|
|
5
|
-
* sentence case; since 1.5 it is shown as written (it was upper-cased with wide
|
|
4
|
+
* Status pill in sentence case ("Order placed", "5 open"): 12px medium text on a tinted 24px pill (owner standard, 1.6;
|
|
5
|
+
* 20px in 1.5). Write the text in sentence case; since 1.5 it is shown as written (it was upper-cased with wide
|
|
6
|
+
* letter-spacing before).
|
|
6
7
|
* @element cm-badge
|
|
7
8
|
* @slot - Status text.
|
|
8
9
|
*/
|
|
@@ -22,7 +23,7 @@ CmBadge.styles = [
|
|
|
22
23
|
css `
|
|
23
24
|
:host { display: inline-flex; vertical-align: middle; }
|
|
24
25
|
span {
|
|
25
|
-
display: inline-flex; align-items: center; height:
|
|
26
|
+
display: inline-flex; align-items: center; box-sizing: border-box; height: 24px; padding: 0 var(--cm-space-8); white-space: nowrap;
|
|
26
27
|
font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12); font-weight: 500; font-variant-numeric: tabular-nums;
|
|
27
28
|
border-radius: var(--cm-radius-full); background: var(--cm-bg-tag); color: var(--cm-text-default);
|
|
28
29
|
}
|
|
@@ -53,7 +53,7 @@ export class CmBottomSheet extends CmOverlay {
|
|
|
53
53
|
__classPrivateFieldGet(this, _CmBottomSheet_observer, "f")?.disconnect();
|
|
54
54
|
}
|
|
55
55
|
render() {
|
|
56
|
-
const items = this.sheetItems.filter((it) => !it.divider);
|
|
56
|
+
const items = this.sheetItems.filter((it) => !it.divider && !it.heading);
|
|
57
57
|
const icons = items.some((it) => it.icon);
|
|
58
58
|
return this.renderDialog(html `<div class="panel" part="panel" tabindex="-1">
|
|
59
59
|
<button type="button" class="x" part="close" aria-label=${this.closeLabel || this.t('close')} @click=${() => this.requestClose('close-button')}>
|
|
@@ -61,7 +61,11 @@ export declare class CmButton extends CmLocalizedElement {
|
|
|
61
61
|
};
|
|
62
62
|
/** `primary` = black fill (one per group); `secondary` = white fill with a grey outline, like a field (since 1.5; was a black outline). */
|
|
63
63
|
variant: 'primary' | 'secondary';
|
|
64
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* `large` 40px (save bars, page actions), `medium` 36px (default), `slim` 32px (toolbars, table rows). Text is 14px (13px on slim).
|
|
66
|
+
* On touch screens (`pointer: coarse`) every size is drawn at least 40px tall (icon-only: 40 x 40) and its hit area reaches
|
|
67
|
+
* 44px. Owner standard since 1.6 (1.5 drew 44px on touch screens; sizes before 1.5 were 46, 32 and 24px).
|
|
68
|
+
*/
|
|
65
69
|
size: 'large' | 'medium' | 'slim';
|
|
66
70
|
/** Form behaviour when inside a `<form>`: `submit` submits it, `reset` resets it. */
|
|
67
71
|
type: 'button' | 'submit' | 'reset';
|
|
@@ -40,7 +40,11 @@ export class CmButton extends CmLocalizedElement {
|
|
|
40
40
|
super();
|
|
41
41
|
/** `primary` = black fill (one per group); `secondary` = white fill with a grey outline, like a field (since 1.5; was a black outline). */
|
|
42
42
|
this.variant = 'secondary';
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* `large` 40px (save bars, page actions), `medium` 36px (default), `slim` 32px (toolbars, table rows). Text is 14px (13px on slim).
|
|
45
|
+
* On touch screens (`pointer: coarse`) every size is drawn at least 40px tall (icon-only: 40 x 40) and its hit area reaches
|
|
46
|
+
* 44px. Owner standard since 1.6 (1.5 drew 44px on touch screens; sizes before 1.5 were 46, 32 and 24px).
|
|
47
|
+
*/
|
|
44
48
|
this.size = 'medium';
|
|
45
49
|
/** Form behaviour when inside a `<form>`: `submit` submits it, `reset` resets it. */
|
|
46
50
|
this.type = 'button';
|
|
@@ -122,12 +126,12 @@ CmButton.styles = [
|
|
|
122
126
|
css `
|
|
123
127
|
:host { display: inline-flex; vertical-align: middle; }
|
|
124
128
|
.btn {
|
|
125
|
-
display: inline-flex; align-items: center; justify-content: center; gap: var(--cm-space-8);
|
|
129
|
+
position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--cm-space-8);
|
|
126
130
|
width: 100%; font: inherit; font-weight: 500; line-height: 1; white-space: nowrap;
|
|
127
131
|
border-radius: var(--cm-radius-sm); border: var(--cm-border-1) solid transparent;
|
|
128
132
|
cursor: pointer; text-decoration: none;
|
|
129
133
|
}
|
|
130
|
-
/* 1.
|
|
134
|
+
/* Owner standard (1.6): large 40, medium 36, slim 32 (--cm-control-height-*); 14px text, 13px on slim. 40 on touch screens. */
|
|
131
135
|
:host([size='large']) .btn { height: var(--cm-control-height-lg, 40px); padding: 0 var(--cm-space-20); font-size: var(--cm-font-size-14); }
|
|
132
136
|
.btn, :host([size='medium']) .btn { height: var(--cm-control-height-md, 36px); padding: 0 var(--cm-space-16); font-size: var(--cm-font-size-14); }
|
|
133
137
|
:host([size='slim']) .btn { height: var(--cm-control-height-sm, 32px); padding: 0 var(--cm-space-12); font-size: var(--cm-font-size-13); }
|
|
@@ -164,6 +168,12 @@ CmButton.styles = [
|
|
|
164
168
|
background: color-mix(in srgb, var(--_tone) 80%, var(--cm-text-default));
|
|
165
169
|
border-color: color-mix(in srgb, var(--_tone) 80%, var(--cm-text-default));
|
|
166
170
|
}
|
|
171
|
+
/* Pressed (1.6): a step darker than hover (lighter in dark), so a tap shows before the action lands. */
|
|
172
|
+
:host(:not([variant='primary']):not([tone]):not([disabled]):not([loading])) .btn:active { background: color-mix(in srgb, var(--cm-bg-hover), var(--cm-text-default) 8%); }
|
|
173
|
+
:host([variant='primary']:not([tone]):not([disabled]):not([loading])) .btn:active {
|
|
174
|
+
background: color-mix(in srgb, var(--cm-action-primary-hover), var(--cm-action-primary) 50%); border-color: color-mix(in srgb, var(--cm-action-primary-hover), var(--cm-action-primary) 50%);
|
|
175
|
+
}
|
|
176
|
+
:host([tone]:not([disabled]):not([loading])) .btn:active { filter: brightness(0.92); }
|
|
167
177
|
.btn:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
168
178
|
.spinner {
|
|
169
179
|
width: 1em; height: 1em; border-radius: 50%;
|
|
@@ -178,10 +188,12 @@ CmButton.styles = [
|
|
|
178
188
|
:host([icon-only][size='large']) .btn { width: var(--cm-control-height-lg, 40px); }
|
|
179
189
|
:host([icon-only]) .btn, :host([icon-only][size='medium']) .btn { width: var(--cm-control-height-md, 36px); }
|
|
180
190
|
:host([icon-only][size='slim']) .btn { width: var(--cm-control-height-sm, 32px); }
|
|
181
|
-
/* Touch screens: every button is at least
|
|
191
|
+
/* Touch screens (owner standard, 1.6): every button is drawn at least 40px tall (icon-only: 40 x 40), whatever its
|
|
192
|
+
size, and an invisible margin 2px all round makes the hit area 44px (WCAG 2.5.5 target size). */
|
|
182
193
|
@media (pointer: coarse) {
|
|
183
|
-
.btn { min-height: var(--cm-control-height-
|
|
184
|
-
:host([icon-only]) .btn { min-width: var(--cm-control-height-
|
|
194
|
+
.btn { min-height: var(--cm-control-height-lg, 40px); }
|
|
195
|
+
:host([icon-only]) .btn { min-width: var(--cm-control-height-lg, 40px); }
|
|
196
|
+
.btn::after { content: ''; position: absolute; inset: -2px; }
|
|
185
197
|
}
|
|
186
198
|
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
187
199
|
.count {
|
|
@@ -2,6 +2,15 @@ import { LitElement } from 'lit';
|
|
|
2
2
|
/**
|
|
3
3
|
* White section card with optional title, description and header actions.
|
|
4
4
|
*
|
|
5
|
+
* Three variants (owner standard, 1.6): `standard` (the default: 24px padding, 16px between header and body, a subtle
|
|
6
|
+
* border), `compact` (16px padding: dashboards, task summaries, metrics) and `interactive` (the whole card opens
|
|
7
|
+
* something: hover, pressed, focus and `selected` states; set `href` for a link, or listen for `cm-action`).
|
|
8
|
+
* Combine them with a space: `variant="interactive compact"`. On phones (640px or less) every card has 16px padding.
|
|
9
|
+
*
|
|
10
|
+
* An interactive card is one control: its heading (or `label`) is a link or button stretched over the whole card, so
|
|
11
|
+
* keyboard users reach it with Tab and press it with Enter (and Space, for a button). Controls in the `actions` slot
|
|
12
|
+
* stay separately clickable above it; don't put other controls in the body of an interactive card.
|
|
13
|
+
*
|
|
5
14
|
* On narrow cards the header wraps instead of squeezing the heading: the title adornment moves under the heading
|
|
6
15
|
* when both don't fit on one line, and the actions move under the title when the title would be narrower than
|
|
7
16
|
* about 12 characters. Wide cards keep everything on one row.
|
|
@@ -10,6 +19,10 @@ import { LitElement } from 'lit';
|
|
|
10
19
|
* @slot actions - Header actions (buttons, links), at the end of the header. Since 1.3 they also show on a card with no
|
|
11
20
|
* `heading` or `description`, in a row of their own at the top of the card.
|
|
12
21
|
* @slot title-adornment - Badge or icon next to the title.
|
|
22
|
+
* @csspart card - The card's box.
|
|
23
|
+
* @csspart title - The heading.
|
|
24
|
+
* @csspart control - The link or button an interactive card is pressed through (stretched over the card).
|
|
25
|
+
* @fires cm-action - An interactive card without `href` was pressed (click, Enter or Space). Not fired by the header actions. Since 1.6.
|
|
13
26
|
*/
|
|
14
27
|
export declare class CmCard extends LitElement {
|
|
15
28
|
#private;
|
|
@@ -24,6 +37,16 @@ export declare class CmCard extends LitElement {
|
|
|
24
37
|
type: NumberConstructor;
|
|
25
38
|
attribute: string;
|
|
26
39
|
};
|
|
40
|
+
variant: {
|
|
41
|
+
reflect: boolean;
|
|
42
|
+
};
|
|
43
|
+
href: {};
|
|
44
|
+
target: {};
|
|
45
|
+
selected: {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
reflect: boolean;
|
|
48
|
+
};
|
|
49
|
+
label: {};
|
|
27
50
|
};
|
|
28
51
|
/** Card title, rendered as a heading at `heading-level`. */
|
|
29
52
|
heading: string;
|
|
@@ -33,7 +56,22 @@ export declare class CmCard extends LitElement {
|
|
|
33
56
|
flush: boolean;
|
|
34
57
|
/** Heading level for the title, so pages keep a correct outline. Default 2. */
|
|
35
58
|
headingLevel: 2 | 3 | 4 | 5 | 6;
|
|
59
|
+
/**
|
|
60
|
+
* `standard` (default: 24px padding), `compact` (16px padding, for dashboards, task summaries and metrics) or
|
|
61
|
+
* `interactive` (the whole card is a link or button, with hover, pressed, focus and selected states). Combine
|
|
62
|
+
* with a space, e.g. `interactive compact`. Phones always get 16px padding. Since 1.6.
|
|
63
|
+
*/
|
|
64
|
+
variant: 'standard' | 'compact' | 'interactive' | 'interactive compact' | 'compact interactive';
|
|
65
|
+
/** Interactive cards: the address the card opens. Without it the card is a button that fires `cm-action`. Since 1.6. */
|
|
66
|
+
href: string;
|
|
67
|
+
/** Link target when `href` is set. `_blank` adds `rel="noopener noreferrer"`. Since 1.6. */
|
|
68
|
+
target: string;
|
|
69
|
+
/** Interactive cards: shows the card as chosen (a 2px dark outline). A button card reports it as pressed, a link card as the current one. Since 1.6. */
|
|
70
|
+
selected: boolean;
|
|
71
|
+
/** Interactive cards without a `heading`: the accessible name of the card's link or button. Since 1.6. */
|
|
72
|
+
label: string;
|
|
36
73
|
static styles: import("lit").CSSResult[];
|
|
74
|
+
willUpdate(): void;
|
|
37
75
|
render(): import("lit-html").TemplateResult<1>;
|
|
38
76
|
}
|
|
39
77
|
declare global {
|