@commmerce/ui 1.0.0-rc.4 → 1.0.0-rc.5
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/README.md +1 -1
- package/dist/base.d.ts +5 -0
- package/dist/base.js +10 -0
- package/dist/calendar.d.ts +95 -0
- package/dist/calendar.js +280 -0
- package/dist/cdn.js +721 -477
- package/dist/components/accordion.js +2 -2
- package/dist/components/action-bar.d.ts +12 -2
- package/dist/components/action-bar.js +10 -5
- package/dist/components/action-menu.d.ts +17 -4
- package/dist/components/action-menu.js +8 -5
- package/dist/components/app-card.d.ts +24 -2
- package/dist/components/app-card.js +25 -10
- package/dist/components/banner.d.ts +2 -2
- package/dist/components/banner.js +4 -3
- package/dist/components/bottom-navigation.d.ts +16 -4
- package/dist/components/bottom-navigation.js +10 -7
- package/dist/components/bottom-sheet.d.ts +4 -1
- package/dist/components/bottom-sheet.js +2 -2
- package/dist/components/checkbox.d.ts +12 -2
- package/dist/components/checkbox.js +7 -2
- package/dist/components/combobox.d.ts +186 -0
- package/dist/components/combobox.js +521 -0
- package/dist/components/comment.d.ts +27 -9
- package/dist/components/comment.js +14 -13
- package/dist/components/data-table.d.ts +14 -2
- package/dist/components/data-table.js +31 -10
- package/dist/components/date-picker.d.ts +179 -0
- package/dist/components/date-picker.js +336 -0
- package/dist/components/date-range-picker.d.ts +251 -0
- package/dist/components/date-range-picker.js +484 -0
- package/dist/components/file-upload.d.ts +30 -4
- package/dist/components/file-upload.js +37 -17
- package/dist/components/filter-panel.d.ts +29 -6
- package/dist/components/filter-panel.js +16 -14
- package/dist/components/flash-offer-bar.d.ts +18 -4
- package/dist/components/flash-offer-bar.js +13 -8
- package/dist/components/header-bar.d.ts +20 -4
- package/dist/components/header-bar.js +20 -13
- package/dist/components/icon.d.ts +7 -0
- package/dist/components/icon.js +9 -1
- package/dist/components/link-tabs.d.ts +16 -4
- package/dist/components/link-tabs.js +10 -7
- package/dist/components/mobile-menu.d.ts +19 -4
- package/dist/components/mobile-menu.js +16 -10
- package/dist/components/modal.d.ts +4 -1
- package/dist/components/nested-list.d.ts +22 -3
- package/dist/components/nested-list.js +25 -12
- package/dist/components/notification-panel.d.ts +26 -5
- package/dist/components/notification-panel.js +17 -11
- package/dist/components/option-group.d.ts +12 -2
- package/dist/components/option-group.js +13 -7
- package/dist/components/page-header.d.ts +18 -2
- package/dist/components/page-header.js +23 -10
- package/dist/components/pagination.d.ts +27 -4
- package/dist/components/pagination.js +28 -16
- package/dist/components/progress-bar.d.ts +12 -2
- package/dist/components/progress-bar.js +9 -4
- package/dist/components/radio.d.ts +12 -1
- package/dist/components/radio.js +12 -6
- package/dist/components/report-tile.d.ts +12 -1
- package/dist/components/report-tile.js +9 -4
- package/dist/components/resource-list.d.ts +36 -5
- package/dist/components/resource-list.js +50 -23
- package/dist/components/save-bar.d.ts +23 -6
- package/dist/components/save-bar.js +14 -12
- package/dist/components/search.d.ts +28 -7
- package/dist/components/search.js +18 -13
- package/dist/components/select.d.ts +12 -2
- package/dist/components/select.js +9 -4
- package/dist/components/side-navigation.d.ts +16 -4
- package/dist/components/side-navigation.js +16 -12
- package/dist/components/side-panel.d.ts +5 -2
- package/dist/components/side-panel.js +5 -3
- package/dist/components/skeleton-display.d.ts +6 -4
- package/dist/components/skeleton-display.js +4 -5
- package/dist/components/smart-tip.d.ts +25 -6
- package/dist/components/smart-tip.js +18 -12
- package/dist/components/spinner.d.ts +4 -3
- package/dist/components/spinner.js +5 -6
- package/dist/components/status-tabs.d.ts +12 -2
- package/dist/components/status-tabs.js +14 -8
- package/dist/components/table-header.d.ts +15 -2
- package/dist/components/table-header.js +13 -5
- package/dist/components/tag.d.ts +12 -2
- package/dist/components/tag.js +9 -4
- package/dist/components/text-field.d.ts +12 -2
- package/dist/components/text-field.js +9 -4
- package/dist/components/thumbnail.d.ts +12 -2
- package/dist/components/thumbnail.js +8 -3
- package/dist/components/toast.d.ts +14 -3
- package/dist/components/toast.js +20 -9
- package/dist/components/toggle.js +2 -0
- package/dist/custom-elements.json +16477 -6434
- package/dist/index.d.ts +7 -1
- package/dist/index.js +5 -1
- package/dist/localize.d.ts +130 -0
- package/dist/localize.js +232 -0
- package/dist/overlay.d.ts +8 -4
- package/dist/overlay.js +9 -12
- package/package.json +4 -4
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
2
2
|
import { type NavItem } from './nav-item.js';
|
|
3
|
+
declare const strings: {
|
|
4
|
+
/** Accessible name of the navigation landmark. */
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
declare module '../localize.js' {
|
|
8
|
+
interface CmStrings {
|
|
9
|
+
linkTabs: typeof strings;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* A row of links between sibling pages, such as the sections of Settings or the parts of a product
|
|
5
14
|
* (Details, Variants, Inventory). It looks like Status tabs but each tab is a link to its own page:
|
|
@@ -10,20 +19,22 @@ import { type NavItem } from './nav-item.js';
|
|
|
10
19
|
* @slot - `cm-nav-item` elements with `href`; mark the page you are on `current`.
|
|
11
20
|
* @fires cm-navigate - When a tab is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app.
|
|
12
21
|
*/
|
|
13
|
-
export declare class CmLinkTabs extends
|
|
22
|
+
export declare class CmLinkTabs extends CmLocalizedElement {
|
|
14
23
|
#private;
|
|
15
24
|
static properties: {
|
|
16
25
|
items: {
|
|
17
26
|
type: ArrayConstructor;
|
|
18
27
|
};
|
|
19
|
-
label: {
|
|
28
|
+
label: {
|
|
29
|
+
string: string;
|
|
30
|
+
};
|
|
20
31
|
_slotted: {
|
|
21
32
|
state: boolean;
|
|
22
33
|
};
|
|
23
34
|
};
|
|
24
35
|
/** Tabs as data (`{ label, href, current }`). Used instead of `cm-nav-item` children when set. */
|
|
25
36
|
items: NavItem[];
|
|
26
|
-
/** Accessible name of the navigation, e.g. "Settings sections". */
|
|
37
|
+
/** Accessible name of the navigation, e.g. "Settings sections". Default: the built-in string `label` ("Sections"). */
|
|
27
38
|
label: string;
|
|
28
39
|
_slotted: NavItem[];
|
|
29
40
|
static styles: import("lit").CSSResult[];
|
|
@@ -38,3 +49,4 @@ declare global {
|
|
|
38
49
|
'cm-link-tabs': CmLinkTabs;
|
|
39
50
|
}
|
|
40
51
|
}
|
|
52
|
+
export {};
|
|
@@ -10,9 +10,14 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
12
|
var _CmLinkTabs_instances, _CmLinkTabs_observer, _CmLinkTabs_read;
|
|
13
|
-
import {
|
|
13
|
+
import { html, css, nothing } from 'lit';
|
|
14
14
|
import { base, define } from '../base.js';
|
|
15
|
+
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
15
16
|
import { readNavItems, watchNavItems, fireNavigate } from './nav-item.js';
|
|
17
|
+
const strings = defineStrings('linkTabs', {
|
|
18
|
+
/** Accessible name of the navigation landmark. */
|
|
19
|
+
label: 'Sections',
|
|
20
|
+
});
|
|
16
21
|
/**
|
|
17
22
|
* A row of links between sibling pages, such as the sections of Settings or the parts of a product
|
|
18
23
|
* (Details, Variants, Inventory). It looks like Status tabs but each tab is a link to its own page:
|
|
@@ -23,14 +28,12 @@ import { readNavItems, watchNavItems, fireNavigate } from './nav-item.js';
|
|
|
23
28
|
* @slot - `cm-nav-item` elements with `href`; mark the page you are on `current`.
|
|
24
29
|
* @fires cm-navigate - When a tab is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app.
|
|
25
30
|
*/
|
|
26
|
-
export class CmLinkTabs extends
|
|
31
|
+
export class CmLinkTabs extends CmLocalizedElement {
|
|
27
32
|
constructor() {
|
|
28
33
|
super(...arguments);
|
|
29
34
|
_CmLinkTabs_instances.add(this);
|
|
30
35
|
/** Tabs as data (`{ label, href, current }`). Used instead of `cm-nav-item` children when set. */
|
|
31
36
|
this.items = [];
|
|
32
|
-
/** Accessible name of the navigation, e.g. "Settings sections". */
|
|
33
|
-
this.label = 'Sections';
|
|
34
37
|
this._slotted = [];
|
|
35
38
|
_CmLinkTabs_observer.set(this, void 0);
|
|
36
39
|
}
|
|
@@ -46,7 +49,7 @@ export class CmLinkTabs extends LitElement {
|
|
|
46
49
|
/** The tabs in use. */
|
|
47
50
|
get tabs() { return this.items.length ? this.items : this._slotted; }
|
|
48
51
|
render() {
|
|
49
|
-
return html `<nav part="nav" aria-label=${this.label || '
|
|
52
|
+
return html `<nav part="nav" aria-label=${this.label || this.t('label')}>
|
|
50
53
|
<ul part="tabs">${this.tabs.map((t) => html `<li><a part="tab" href=${t.href || '#'} aria-current=${t.current ? 'page' : nothing}
|
|
51
54
|
@click=${(e) => { if (!fireNavigate(this, t))
|
|
52
55
|
e.preventDefault(); }}>${t.label}${t.badge ? html `<span class="badge">(${t.badge})</span>` : nothing}</a></li>`)}</ul>
|
|
@@ -57,7 +60,7 @@ export class CmLinkTabs extends LitElement {
|
|
|
57
60
|
_CmLinkTabs_observer = new WeakMap(), _CmLinkTabs_instances = new WeakSet(), _CmLinkTabs_read = function _CmLinkTabs_read() { this._slotted = readNavItems(this); };
|
|
58
61
|
CmLinkTabs.properties = {
|
|
59
62
|
items: { type: Array },
|
|
60
|
-
label: {},
|
|
63
|
+
label: { string: 'label' },
|
|
61
64
|
_slotted: { state: true },
|
|
62
65
|
};
|
|
63
66
|
CmLinkTabs.styles = [
|
|
@@ -73,7 +76,7 @@ CmLinkTabs.styles = [
|
|
|
73
76
|
position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0 14px;
|
|
74
77
|
font-size: 16px; font-weight: 500; color: var(--cm-text-tertiary); text-decoration: none;
|
|
75
78
|
}
|
|
76
|
-
a::after { content: ''; position: absolute;
|
|
79
|
+
a::after { content: ''; position: absolute; inset-inline: 0; bottom: -1px; height: 2px; border-radius: 1px; background: transparent; }
|
|
77
80
|
a:hover { color: var(--cm-text-default); }
|
|
78
81
|
a[aria-current='page'] { color: var(--cm-text-default); }
|
|
79
82
|
a[aria-current='page']::after { background: var(--cm-border-strong); }
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
2
2
|
import { type NavItem } from './nav-item.js';
|
|
3
3
|
import './icon.js';
|
|
4
|
+
declare const strings: {
|
|
5
|
+
/** Accessible name of the navigation landmark. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Heading of the store and user card, and the line above the store name. */
|
|
8
|
+
profile: string;
|
|
9
|
+
store: string;
|
|
10
|
+
};
|
|
11
|
+
declare module '../localize.js' {
|
|
12
|
+
interface CmStrings {
|
|
13
|
+
mobileMenu: typeof strings;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
4
16
|
/**
|
|
5
17
|
* The admin's full menu on phones, opened from "More" in the Bottom navigation. A grey page of white
|
|
6
18
|
* rounded cards: the store and the signed-in user first, then labelled sections of rows. Rows with
|
|
@@ -14,7 +26,7 @@ import './icon.js';
|
|
|
14
26
|
* @fires cm-store-switch - When the store card is pressed.
|
|
15
27
|
* @fires cm-account - When the user row is pressed.
|
|
16
28
|
*/
|
|
17
|
-
export declare class CmMobileMenu extends
|
|
29
|
+
export declare class CmMobileMenu extends CmLocalizedElement {
|
|
18
30
|
#private;
|
|
19
31
|
static properties: {
|
|
20
32
|
items: {
|
|
@@ -30,7 +42,9 @@ export declare class CmMobileMenu extends LitElement {
|
|
|
30
42
|
avatarSrc: {
|
|
31
43
|
attribute: string;
|
|
32
44
|
};
|
|
33
|
-
label: {
|
|
45
|
+
label: {
|
|
46
|
+
string: string;
|
|
47
|
+
};
|
|
34
48
|
_slotted: {
|
|
35
49
|
state: boolean;
|
|
36
50
|
};
|
|
@@ -48,7 +62,7 @@ export declare class CmMobileMenu extends LitElement {
|
|
|
48
62
|
userEmail: string;
|
|
49
63
|
/** Avatar image URL. Without it, the first letter of the name is shown. */
|
|
50
64
|
avatarSrc: string;
|
|
51
|
-
/** Accessible name of the navigation landmark. */
|
|
65
|
+
/** Accessible name of the navigation landmark. Default: the built-in string `label` ("Menu"). */
|
|
52
66
|
label: string;
|
|
53
67
|
_slotted: NavItem[];
|
|
54
68
|
/** Path of the open sub-page as [section, row], or null on the main page. */
|
|
@@ -67,3 +81,4 @@ declare global {
|
|
|
67
81
|
'cm-mobile-menu': CmMobileMenu;
|
|
68
82
|
}
|
|
69
83
|
}
|
|
84
|
+
export {};
|
|
@@ -10,10 +10,18 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
12
|
var _CmMobileMenu_instances, _CmMobileMenu_observer, _CmMobileMenu_id, _CmMobileMenu_read, _CmMobileMenu_open, _CmMobileMenu_fire, _CmMobileMenu_row, _CmMobileMenu_profile;
|
|
13
|
-
import {
|
|
13
|
+
import { html, css, nothing } from 'lit';
|
|
14
14
|
import { base, define, nextId } from '../base.js';
|
|
15
|
+
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
15
16
|
import { readNavItems, watchNavItems, fireNavigate } from './nav-item.js';
|
|
16
17
|
import './icon.js';
|
|
18
|
+
const strings = defineStrings('mobileMenu', {
|
|
19
|
+
/** Accessible name of the navigation landmark. */
|
|
20
|
+
label: 'Menu',
|
|
21
|
+
/** Heading of the store and user card, and the line above the store name. */
|
|
22
|
+
profile: 'Profile',
|
|
23
|
+
store: 'Logged in to store',
|
|
24
|
+
});
|
|
17
25
|
/**
|
|
18
26
|
* The admin's full menu on phones, opened from "More" in the Bottom navigation. A grey page of white
|
|
19
27
|
* rounded cards: the store and the signed-in user first, then labelled sections of rows. Rows with
|
|
@@ -27,7 +35,7 @@ import './icon.js';
|
|
|
27
35
|
* @fires cm-store-switch - When the store card is pressed.
|
|
28
36
|
* @fires cm-account - When the user row is pressed.
|
|
29
37
|
*/
|
|
30
|
-
export class CmMobileMenu extends
|
|
38
|
+
export class CmMobileMenu extends CmLocalizedElement {
|
|
31
39
|
constructor() {
|
|
32
40
|
super(...arguments);
|
|
33
41
|
_CmMobileMenu_instances.add(this);
|
|
@@ -41,8 +49,6 @@ export class CmMobileMenu extends LitElement {
|
|
|
41
49
|
this.userEmail = '';
|
|
42
50
|
/** Avatar image URL. Without it, the first letter of the name is shown. */
|
|
43
51
|
this.avatarSrc = '';
|
|
44
|
-
/** Accessible name of the navigation landmark. */
|
|
45
|
-
this.label = 'Menu';
|
|
46
52
|
this._slotted = [];
|
|
47
53
|
/** Path of the open sub-page as [section, row], or null on the main page. */
|
|
48
54
|
this._page = null;
|
|
@@ -72,7 +78,7 @@ export class CmMobileMenu extends LitElement {
|
|
|
72
78
|
const secs = this.sections;
|
|
73
79
|
const page = this._page ? secs[this._page[0]]?.items?.[this._page[1]] : undefined;
|
|
74
80
|
if (page) {
|
|
75
|
-
return html `<nav part="nav" class="sub" aria-label=${this.label || '
|
|
81
|
+
return html `<nav part="nav" class="sub" aria-label=${this.label || this.t('label')} id="${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-sub"
|
|
76
82
|
@keydown=${(e) => { if (e.key === 'Escape') {
|
|
77
83
|
e.preventDefault();
|
|
78
84
|
this.back();
|
|
@@ -82,7 +88,7 @@ export class CmMobileMenu extends LitElement {
|
|
|
82
88
|
<slot hidden></slot>
|
|
83
89
|
</nav>`;
|
|
84
90
|
}
|
|
85
|
-
return html `<nav part="nav" aria-label=${this.label || '
|
|
91
|
+
return html `<nav part="nav" aria-label=${this.label || this.t('label')}>
|
|
86
92
|
${__classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_profile).call(this)}
|
|
87
93
|
${secs.map((sec, s) => {
|
|
88
94
|
const hid = `${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-s${s}`;
|
|
@@ -118,10 +124,10 @@ _CmMobileMenu_observer = new WeakMap(), _CmMobileMenu_id = new WeakMap(), _CmMob
|
|
|
118
124
|
return nothing;
|
|
119
125
|
const initial = this.userName.trim().charAt(0).toUpperCase();
|
|
120
126
|
return html `<section aria-labelledby="${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-profile">
|
|
121
|
-
<h2 class="heading" id="${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-profile"
|
|
127
|
+
<h2 class="heading" id="${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-profile">${this.t('profile')}</h2>
|
|
122
128
|
<ul class="card">
|
|
123
129
|
${this.store ? html `<li><button type="button" class="row" part="row" @click=${() => __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_fire).call(this, 'cm-store-switch')}>
|
|
124
|
-
<span class="stack"><span class="eyebrow"
|
|
130
|
+
<span class="stack"><span class="eyebrow">${this.t('store')}</span><span>${this.store}</span></span>
|
|
125
131
|
<cm-icon class="chev" name="chevron-right" size="16"></cm-icon></button></li>` : nothing}
|
|
126
132
|
${this.userName ? html `<li><button type="button" class="row" part="row" @click=${() => __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_fire).call(this, 'cm-account')}>
|
|
127
133
|
<span class="avatar">${this.avatarSrc ? html `<img src=${this.avatarSrc} alt="">` : html `<span aria-hidden="true">${initial}</span>`}</span>
|
|
@@ -136,7 +142,7 @@ CmMobileMenu.properties = {
|
|
|
136
142
|
userName: { attribute: 'user-name' },
|
|
137
143
|
userEmail: { attribute: 'user-email' },
|
|
138
144
|
avatarSrc: { attribute: 'avatar-src' },
|
|
139
|
-
label: {},
|
|
145
|
+
label: { string: 'label' },
|
|
140
146
|
_slotted: { state: true },
|
|
141
147
|
_page: { state: true },
|
|
142
148
|
};
|
|
@@ -152,7 +158,7 @@ CmMobileMenu.styles = [
|
|
|
152
158
|
.card { list-style: none; margin: 0; padding: 0 15px; background: var(--cm-bg-surface); border-radius: 12px; }
|
|
153
159
|
.card > li + li { border-top: var(--cm-border-1) solid var(--cm-border-default); }
|
|
154
160
|
.row {
|
|
155
|
-
display: flex; align-items: center; gap: var(--cm-space-15); width: 100%; min-height: 51px; padding: 8px
|
|
161
|
+
display: flex; align-items: center; gap: var(--cm-space-15); width: 100%; min-height: 51px; padding-block: 8px; padding-inline: 6px 4px;
|
|
156
162
|
font: inherit; font-size: 18px; font-weight: 500; color: var(--cm-text-default); text-align: start; text-decoration: none;
|
|
157
163
|
background: none; border: 0; cursor: pointer;
|
|
158
164
|
}
|
|
@@ -26,10 +26,13 @@ export declare class CmModal extends CmOverlay {
|
|
|
26
26
|
type: BooleanConstructor;
|
|
27
27
|
reflect: boolean;
|
|
28
28
|
};
|
|
29
|
-
heading: {
|
|
29
|
+
heading: {
|
|
30
|
+
string: string;
|
|
31
|
+
};
|
|
30
32
|
label: {};
|
|
31
33
|
closeLabel: {
|
|
32
34
|
attribute: string;
|
|
35
|
+
string: string;
|
|
33
36
|
};
|
|
34
37
|
};
|
|
35
38
|
/** Width: `small` (400px, confirmations), `medium` (620px, default) or `large` (900px, lists and tables). Never wider than the screen. */
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
2
2
|
import './icon.js';
|
|
3
|
+
declare const itemStrings: {
|
|
4
|
+
/** Accessible name of the drag handle, and the keyboard hint read with it. */
|
|
5
|
+
reorder: string;
|
|
6
|
+
hint: string;
|
|
7
|
+
/** Announced after a move. */
|
|
8
|
+
moved: string;
|
|
9
|
+
};
|
|
10
|
+
declare const listStrings: {
|
|
11
|
+
/** Accessible name of the show/hide button. */
|
|
12
|
+
show: string;
|
|
13
|
+
hide: string;
|
|
14
|
+
};
|
|
15
|
+
declare module '../localize.js' {
|
|
16
|
+
interface CmStrings {
|
|
17
|
+
nestedItem: typeof itemStrings;
|
|
18
|
+
nestedList: typeof listStrings;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
3
21
|
/**
|
|
4
22
|
* One row in a `cm-nested-list`: a 60px bordered row with a label and actions (toggle, edit, delete).
|
|
5
23
|
* Put more `cm-nested-item`s inside it to nest them; each level is indented.
|
|
@@ -8,7 +26,7 @@ import './icon.js';
|
|
|
8
26
|
* @slot actions - Controls at the end of the row: a badge, a toggle, edit and delete buttons.
|
|
9
27
|
* @fires cm-reorder - Bubbles from the moved item: `detail: { item, from, to }` (positions among its siblings). Cancelable.
|
|
10
28
|
*/
|
|
11
|
-
export declare class CmNestedItem extends
|
|
29
|
+
export declare class CmNestedItem extends CmLocalizedElement {
|
|
12
30
|
#private;
|
|
13
31
|
static properties: {
|
|
14
32
|
label: {};
|
|
@@ -56,7 +74,7 @@ export declare class CmNestedItem extends LitElement {
|
|
|
56
74
|
* @fires cm-reorder - When a row is moved. See `cm-nested-item`.
|
|
57
75
|
* @fires cm-toggle - `detail: { open }` when a collapsible list is shown or hidden.
|
|
58
76
|
*/
|
|
59
|
-
export declare class CmNestedList extends
|
|
77
|
+
export declare class CmNestedList extends CmLocalizedElement {
|
|
60
78
|
#private;
|
|
61
79
|
static properties: {
|
|
62
80
|
heading: {};
|
|
@@ -103,3 +121,4 @@ declare global {
|
|
|
103
121
|
'cm-nested-item': CmNestedItem;
|
|
104
122
|
}
|
|
105
123
|
}
|
|
124
|
+
export {};
|
|
@@ -4,9 +4,22 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _CmNestedItem_instances, _a, _CmNestedItem_internals, _CmNestedItem_onHandleKey, _CmNestedItem_onDragStart, _CmNestedItem_onDragOver, _CmNestedItem_clearDrop, _CmNestedItem_onDrop, _CmNestedList_instances, _CmNestedList_id, _CmNestedList_toggle, _CmNestedList_syncSortable;
|
|
7
|
-
import {
|
|
7
|
+
import { html, css, nothing } from 'lit';
|
|
8
8
|
import { base, define, nextId } from '../base.js';
|
|
9
|
+
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
9
10
|
import './icon.js';
|
|
11
|
+
const itemStrings = defineStrings('nestedItem', {
|
|
12
|
+
/** Accessible name of the drag handle, and the keyboard hint read with it. */
|
|
13
|
+
reorder: 'Reorder {label}',
|
|
14
|
+
hint: 'Press up or down arrow to move.',
|
|
15
|
+
/** Announced after a move. */
|
|
16
|
+
moved: '{label} moved to position {position} of {total}.',
|
|
17
|
+
});
|
|
18
|
+
const listStrings = defineStrings('nestedList', {
|
|
19
|
+
/** Accessible name of the show/hide button. */
|
|
20
|
+
show: 'Show {heading}',
|
|
21
|
+
hide: 'Hide {heading}',
|
|
22
|
+
});
|
|
10
23
|
/**
|
|
11
24
|
* One row in a `cm-nested-list`: a 60px bordered row with a label and actions (toggle, edit, delete).
|
|
12
25
|
* Put more `cm-nested-item`s inside it to nest them; each level is indented.
|
|
@@ -15,7 +28,7 @@ import './icon.js';
|
|
|
15
28
|
* @slot actions - Controls at the end of the row: a badge, a toggle, edit and delete buttons.
|
|
16
29
|
* @fires cm-reorder - Bubbles from the moved item: `detail: { item, from, to }` (positions among its siblings). Cancelable.
|
|
17
30
|
*/
|
|
18
|
-
export class CmNestedItem extends
|
|
31
|
+
export class CmNestedItem extends CmLocalizedElement {
|
|
19
32
|
constructor() {
|
|
20
33
|
super();
|
|
21
34
|
_CmNestedItem_instances.add(this);
|
|
@@ -54,19 +67,19 @@ export class CmNestedItem extends LitElement {
|
|
|
54
67
|
return false;
|
|
55
68
|
const ref = sibs[to];
|
|
56
69
|
ref.parentElement.insertBefore(this, to > from ? ref.nextSibling : ref);
|
|
57
|
-
this.closest('cm-nested-list')?.announce(
|
|
70
|
+
this.closest('cm-nested-list')?.announce(this.t('moved', { label: this.label, position: to + 1, total: sibs.length }));
|
|
58
71
|
return true;
|
|
59
72
|
}
|
|
60
73
|
render() {
|
|
61
74
|
return html `
|
|
62
75
|
<div class="row" part="row" @dragover=${__classPrivateFieldGet(this, _CmNestedItem_instances, "m", _CmNestedItem_onDragOver)} @dragleave=${__classPrivateFieldGet(this, _CmNestedItem_instances, "m", _CmNestedItem_clearDrop)} @drop=${__classPrivateFieldGet(this, _CmNestedItem_instances, "m", _CmNestedItem_onDrop)}>
|
|
63
76
|
${this.sortable
|
|
64
|
-
? html `<button class="handle" type="button" part="handle" draggable="true" aria-label=${
|
|
77
|
+
? html `<button class="handle" type="button" part="handle" draggable="true" aria-label=${this.t('reorder', { label: this.label })}
|
|
65
78
|
aria-describedby="hint"
|
|
66
79
|
@keydown=${__classPrivateFieldGet(this, _CmNestedItem_instances, "m", _CmNestedItem_onHandleKey)} @dragstart=${__classPrivateFieldGet(this, _CmNestedItem_instances, "m", _CmNestedItem_onDragStart)}
|
|
67
80
|
@dragend=${() => { this.classList.remove('dragging'); _a.dragged = null; }}><cm-icon name="drag" size="18"></cm-icon></button>`
|
|
68
81
|
: nothing}
|
|
69
|
-
${this.sortable ? html `<span class="sr" id="hint"
|
|
82
|
+
${this.sortable ? html `<span class="sr" id="hint">${this.t('hint')}</span>` : nothing}
|
|
70
83
|
<span class="label" part="label">${this.label}</span>
|
|
71
84
|
<span class="actions" part="actions"><slot name="actions"></slot></span>
|
|
72
85
|
</div>
|
|
@@ -160,17 +173,17 @@ CmNestedItem.styles = [
|
|
|
160
173
|
.label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
161
174
|
.actions { display: flex; align-items: center; gap: var(--cm-space-15); }
|
|
162
175
|
.handle {
|
|
163
|
-
display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 34px; margin-
|
|
176
|
+
display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 34px; margin-inline-start: -6px; padding: 0;
|
|
164
177
|
color: var(--cm-icon-selected); background: none; border: 0; border-radius: var(--cm-radius-xs); cursor: grab;
|
|
165
178
|
}
|
|
166
179
|
.handle:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
167
180
|
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
168
|
-
.children { margin: var(--cm-space-10) 0
|
|
181
|
+
.children { margin-block: var(--cm-space-10) 0; margin-inline: 50px 0; display: flex; flex-direction: column; gap: var(--cm-space-10); }
|
|
169
182
|
.children:not(.has) { display: none; }
|
|
170
183
|
@media (max-width: 640px) {
|
|
171
184
|
.row { min-height: 50px; padding: 0 var(--cm-space-10); gap: var(--cm-space-10); font-size: 14px; }
|
|
172
185
|
.actions { gap: var(--cm-space-10); }
|
|
173
|
-
.children { margin-
|
|
186
|
+
.children { margin-inline-start: var(--cm-space-20); }
|
|
174
187
|
}
|
|
175
188
|
`,
|
|
176
189
|
];
|
|
@@ -188,7 +201,7 @@ define('cm-nested-item', CmNestedItem);
|
|
|
188
201
|
* @fires cm-reorder - When a row is moved. See `cm-nested-item`.
|
|
189
202
|
* @fires cm-toggle - `detail: { open }` when a collapsible list is shown or hidden.
|
|
190
203
|
*/
|
|
191
|
-
export class CmNestedList extends
|
|
204
|
+
export class CmNestedList extends CmLocalizedElement {
|
|
192
205
|
constructor() {
|
|
193
206
|
super(...arguments);
|
|
194
207
|
_CmNestedList_instances.add(this);
|
|
@@ -223,7 +236,7 @@ export class CmNestedList extends LitElement {
|
|
|
223
236
|
<span class="actions"><slot name="actions"></slot></span>
|
|
224
237
|
${this.collapsible
|
|
225
238
|
? html `<button class="toggle" type="button" part="toggle" aria-expanded=${shown ? 'true' : 'false'} aria-controls="${__classPrivateFieldGet(this, _CmNestedList_id, "f")}-rows"
|
|
226
|
-
aria-label=${
|
|
239
|
+
aria-label=${this.t(shown ? 'hide' : 'show', { heading: this.heading })} @click=${__classPrivateFieldGet(this, _CmNestedList_instances, "m", _CmNestedList_toggle)}>
|
|
227
240
|
<cm-icon name=${shown ? 'chevron-up' : 'chevron-down'} size="14"></cm-icon></button>`
|
|
228
241
|
: nothing}
|
|
229
242
|
</div>
|
|
@@ -265,13 +278,13 @@ CmNestedList.styles = [
|
|
|
265
278
|
}
|
|
266
279
|
.toggle:hover { background: var(--cm-action-primary-hover); }
|
|
267
280
|
.toggle:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
268
|
-
.rows { display: flex; flex-direction: column; gap: var(--cm-space-10); margin: var(--cm-space-15) 0
|
|
281
|
+
.rows { display: flex; flex-direction: column; gap: var(--cm-space-10); margin-block: var(--cm-space-15) 0; margin-inline: 50px 0; }
|
|
269
282
|
.rows[hidden] { display: none; }
|
|
270
283
|
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
271
284
|
@media (max-width: 640px) {
|
|
272
285
|
.bar { min-height: 60px; padding: 0 var(--cm-space-10); gap: var(--cm-space-10); }
|
|
273
286
|
.title { font-size: 18px; }
|
|
274
|
-
.rows { margin-
|
|
287
|
+
.rows { margin-inline-start: var(--cm-space-10); }
|
|
275
288
|
.toggle { width: 30px; height: 30px; }
|
|
276
289
|
}
|
|
277
290
|
`,
|
|
@@ -17,6 +17,21 @@ export interface NotificationItem {
|
|
|
17
17
|
/** Identifies it in `cm-select`. Defaults to the href, then the label. */
|
|
18
18
|
value?: string;
|
|
19
19
|
}
|
|
20
|
+
declare const strings: {
|
|
21
|
+
/** Title in the header. */
|
|
22
|
+
heading: string;
|
|
23
|
+
/** Text of the link to all notifications. */
|
|
24
|
+
more: string;
|
|
25
|
+
/** Shown when there are no notifications. */
|
|
26
|
+
empty: string;
|
|
27
|
+
/** Read before an unread notification. */
|
|
28
|
+
unread: string;
|
|
29
|
+
};
|
|
30
|
+
declare module '../localize.js' {
|
|
31
|
+
interface CmStrings {
|
|
32
|
+
notificationPanel: typeof strings;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
20
35
|
/**
|
|
21
36
|
* A notification in markup, read by `cm-notification-panel`. Its text is the label. Renders nothing itself.
|
|
22
37
|
* @element cm-notification-item
|
|
@@ -54,7 +69,7 @@ export declare class CmNotificationItem extends LitElement {
|
|
|
54
69
|
render(): null;
|
|
55
70
|
}
|
|
56
71
|
/**
|
|
57
|
-
* The list of recent notifications, opened from the bell in the header bar: a panel under the top-right corner
|
|
72
|
+
* The list of recent notifications, opened from the bell in the header bar: a panel under the top-right corner (top-left in right-to-left pages)
|
|
58
73
|
* of the page with a black "Notifications" header, one row per notification (a coloured icon for its kind,
|
|
59
74
|
* what happened, and when), and "See more notifications" at the bottom. On phones it spans the screen width.
|
|
60
75
|
*
|
|
@@ -76,11 +91,16 @@ export declare class CmNotificationPanel extends CmOverlay {
|
|
|
76
91
|
moreHref: {
|
|
77
92
|
attribute: string;
|
|
78
93
|
};
|
|
94
|
+
heading: {
|
|
95
|
+
string: string;
|
|
96
|
+
};
|
|
79
97
|
moreLabel: {
|
|
80
98
|
attribute: string;
|
|
99
|
+
string: string;
|
|
81
100
|
};
|
|
82
101
|
emptyText: {
|
|
83
102
|
attribute: string;
|
|
103
|
+
string: string;
|
|
84
104
|
};
|
|
85
105
|
_slotted: {
|
|
86
106
|
state: boolean;
|
|
@@ -89,21 +109,21 @@ export declare class CmNotificationPanel extends CmOverlay {
|
|
|
89
109
|
type: BooleanConstructor;
|
|
90
110
|
reflect: boolean;
|
|
91
111
|
};
|
|
92
|
-
heading: {};
|
|
93
112
|
label: {};
|
|
94
113
|
closeLabel: {
|
|
95
114
|
attribute: string;
|
|
115
|
+
string: string;
|
|
96
116
|
};
|
|
97
117
|
};
|
|
98
|
-
/** Title in the header. */
|
|
118
|
+
/** Title in the header. Default: the built-in string `heading` ("Notifications"). */
|
|
99
119
|
heading: string;
|
|
100
120
|
/** Notifications as data, used instead of children when set. */
|
|
101
121
|
items: NotificationItem[];
|
|
102
122
|
/** Link to all notifications. Empty hides it. */
|
|
103
123
|
moreHref: string;
|
|
104
|
-
/** Text of that link. */
|
|
124
|
+
/** Text of that link. Default: the built-in string `more` ("See more notifications"). */
|
|
105
125
|
moreLabel: string;
|
|
106
|
-
/** Shown when there are no notifications. */
|
|
126
|
+
/** Shown when there are no notifications. Default: the built-in string `empty` ("No notifications yet."). */
|
|
107
127
|
emptyText: string;
|
|
108
128
|
_slotted: NotificationItem[];
|
|
109
129
|
static styles: import("lit").CSSResult[];
|
|
@@ -119,3 +139,4 @@ declare global {
|
|
|
119
139
|
'cm-notification-item': CmNotificationItem;
|
|
120
140
|
}
|
|
121
141
|
}
|
|
142
|
+
export {};
|
|
@@ -13,7 +13,18 @@ var _CmNotificationPanel_instances, _CmNotificationPanel_observer, _CmNotificati
|
|
|
13
13
|
import { LitElement, html, css, nothing } from 'lit';
|
|
14
14
|
import { define } from '../base.js';
|
|
15
15
|
import { CmOverlay } from '../overlay.js';
|
|
16
|
+
import { defineStrings } from '../localize.js';
|
|
16
17
|
import './icon.js';
|
|
18
|
+
const strings = defineStrings('notificationPanel', {
|
|
19
|
+
/** Title in the header. */
|
|
20
|
+
heading: 'Notifications',
|
|
21
|
+
/** Text of the link to all notifications. */
|
|
22
|
+
more: 'See more notifications',
|
|
23
|
+
/** Shown when there are no notifications. */
|
|
24
|
+
empty: 'No notifications yet.',
|
|
25
|
+
/** Read before an unread notification. */
|
|
26
|
+
unread: 'Unread: ',
|
|
27
|
+
});
|
|
17
28
|
const ICONS = { information: 'bag', attention: 'alert', success: 'check-circle', critical: 'x-circle' };
|
|
18
29
|
/**
|
|
19
30
|
* A notification in markup, read by `cm-notification-panel`. Its text is the label. Renders nothing itself.
|
|
@@ -45,7 +56,7 @@ CmNotificationItem.properties = {
|
|
|
45
56
|
CmNotificationItem.styles = css `:host { display: none; }`;
|
|
46
57
|
define('cm-notification-item', CmNotificationItem);
|
|
47
58
|
/**
|
|
48
|
-
* The list of recent notifications, opened from the bell in the header bar: a panel under the top-right corner
|
|
59
|
+
* The list of recent notifications, opened from the bell in the header bar: a panel under the top-right corner (top-left in right-to-left pages)
|
|
49
60
|
* of the page with a black "Notifications" header, one row per notification (a coloured icon for its kind,
|
|
50
61
|
* what happened, and when), and "See more notifications" at the bottom. On phones it spans the screen width.
|
|
51
62
|
*
|
|
@@ -62,16 +73,10 @@ export class CmNotificationPanel extends CmOverlay {
|
|
|
62
73
|
constructor() {
|
|
63
74
|
super(...arguments);
|
|
64
75
|
_CmNotificationPanel_instances.add(this);
|
|
65
|
-
/** Title in the header. */
|
|
66
|
-
this.heading = 'Notifications';
|
|
67
76
|
/** Notifications as data, used instead of children when set. */
|
|
68
77
|
this.items = [];
|
|
69
78
|
/** Link to all notifications. Empty hides it. */
|
|
70
79
|
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
80
|
this._slotted = [];
|
|
76
81
|
_CmNotificationPanel_observer.set(this, void 0);
|
|
77
82
|
}
|
|
@@ -119,7 +124,7 @@ _CmNotificationPanel_observer = new WeakMap(), _CmNotificationPanel_instances =
|
|
|
119
124
|
}, _CmNotificationPanel_row = function _CmNotificationPanel_row(it) {
|
|
120
125
|
const tone = it.tone ?? 'information';
|
|
121
126
|
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"
|
|
127
|
+
<span class="label">${it.unread ? html `<span class="vh">${this.t('unread')}</span>` : nothing}${it.label}</span>
|
|
123
128
|
${it.time ? html `<time>${it.time}</time>` : nothing}`;
|
|
124
129
|
const cls = `row${it.unread ? ' unread' : ''}`;
|
|
125
130
|
return it.href
|
|
@@ -130,15 +135,16 @@ CmNotificationPanel.properties = {
|
|
|
130
135
|
...CmOverlay.properties,
|
|
131
136
|
items: { type: Array },
|
|
132
137
|
moreHref: { attribute: 'more-href' },
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
heading: { string: 'heading' },
|
|
139
|
+
moreLabel: { attribute: 'more-label', string: 'more' },
|
|
140
|
+
emptyText: { attribute: 'empty-text', string: 'empty' },
|
|
135
141
|
_slotted: { state: true },
|
|
136
142
|
};
|
|
137
143
|
CmNotificationPanel.styles = [
|
|
138
144
|
...CmOverlay.overlayStyles,
|
|
139
145
|
css `
|
|
140
146
|
dialog {
|
|
141
|
-
position: fixed; inset: var(--cm-notification-panel-top, 64px) var(--cm-notification-panel-end, 20px)
|
|
147
|
+
position: fixed; inset-block: var(--cm-notification-panel-top, 64px) auto; inset-inline: auto var(--cm-notification-panel-end, 20px);
|
|
142
148
|
width: min(380px, calc(100vw - 32px));
|
|
143
149
|
}
|
|
144
150
|
.panel { max-height: calc(100dvh - var(--cm-notification-panel-top, 64px) - 16px); border-radius: var(--cm-radius-sm); box-shadow: var(--cm-shadow-100); }
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
2
2
|
import type { SelectOption } from './select.js';
|
|
3
|
+
declare const strings: {
|
|
4
|
+
/** Validation message when `required` and nothing is chosen. */
|
|
5
|
+
required: string;
|
|
6
|
+
};
|
|
7
|
+
declare module '../localize.js' {
|
|
8
|
+
interface CmStrings {
|
|
9
|
+
optionGroup: typeof strings;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* A row of outlined buttons where exactly one is selected (black), used to switch a form between
|
|
5
14
|
* types, such as offer types. Behaves like a native radio group: one tab stop, arrow keys move and
|
|
@@ -11,7 +20,7 @@ import type { SelectOption } from './select.js';
|
|
|
11
20
|
* @fires change - When the merchant picks a different option.
|
|
12
21
|
* @fires input - Same moment as `change`.
|
|
13
22
|
*/
|
|
14
|
-
export declare class CmOptionGroup extends
|
|
23
|
+
export declare class CmOptionGroup extends CmLocalizedElement {
|
|
15
24
|
#private;
|
|
16
25
|
static formAssociated: boolean;
|
|
17
26
|
static properties: {
|
|
@@ -72,3 +81,4 @@ declare global {
|
|
|
72
81
|
'cm-option-group': CmOptionGroup;
|
|
73
82
|
}
|
|
74
83
|
}
|
|
84
|
+
export {};
|