@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
|
@@ -3,11 +3,29 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
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
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _CmFileUpload_instances, _CmFileUpload_internals, _CmFileUpload_id, _CmFileUpload_urls, _CmFileUpload_url, _CmFileUpload_onInputChange, _CmFileUpload_setOver, _CmFileUpload_zone;
|
|
6
|
+
var _CmFileUpload_instances, _CmFileUpload_internals, _CmFileUpload_id, _CmFileUpload_urls, _CmFileUpload_size, _CmFileUpload_url, _CmFileUpload_onInputChange, _CmFileUpload_setOver, _CmFileUpload_zone;
|
|
7
7
|
import { LitElement, 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';
|
|
10
|
-
const
|
|
11
|
+
const strings = defineStrings('fileUpload', {
|
|
12
|
+
/** Text inside the empty zone. */
|
|
13
|
+
prompt: 'Click here to upload',
|
|
14
|
+
/** Text of the tile that adds more files. */
|
|
15
|
+
addMore: 'Add more',
|
|
16
|
+
/** Accessible name of the list of chosen files. */
|
|
17
|
+
files: 'Chosen files',
|
|
18
|
+
/** Accessible name of each file's remove button. */
|
|
19
|
+
remove: 'Remove {name}',
|
|
20
|
+
/** File sizes. `{size}` is a number formatted for the locale. */
|
|
21
|
+
kilobytes: '{size} KB',
|
|
22
|
+
megabytes: '{size} MB',
|
|
23
|
+
/** Validation messages. */
|
|
24
|
+
required: 'Please choose a file.',
|
|
25
|
+
wrongType: '{name} is not an allowed file type',
|
|
26
|
+
tooLarge: '{name} is larger than {size}',
|
|
27
|
+
tooMany: 'You can add up to {max} files',
|
|
28
|
+
});
|
|
11
29
|
/** Does `file` match an `accept` list such as `image/*,.pdf`? */
|
|
12
30
|
function accepts(file, accept) {
|
|
13
31
|
if (!accept.trim())
|
|
@@ -23,7 +41,7 @@ function accepts(file, accept) {
|
|
|
23
41
|
* @fires change - When files are added or removed. Read `files`.
|
|
24
42
|
* @fires cm-reject - When chosen files are refused for type or size. `detail.files` lists them.
|
|
25
43
|
*/
|
|
26
|
-
export class CmFileUpload extends
|
|
44
|
+
export class CmFileUpload extends CmLocalizedElement {
|
|
27
45
|
constructor() {
|
|
28
46
|
super(...arguments);
|
|
29
47
|
_CmFileUpload_instances.add(this);
|
|
@@ -31,8 +49,6 @@ export class CmFileUpload extends LitElement {
|
|
|
31
49
|
this.label = '';
|
|
32
50
|
/** Rule shown next to the label in text-tertiary, e.g. "max. file size 300 KB". */
|
|
33
51
|
this.hint = '';
|
|
34
|
-
/** Text inside the zone. */
|
|
35
|
-
this.prompt = 'Click here to upload';
|
|
36
52
|
/** Form field name. */
|
|
37
53
|
this.name = '';
|
|
38
54
|
/** Allowed types, as for a native input: `image/*`, `.pdf,.csv`. Other files are refused. */
|
|
@@ -86,7 +102,7 @@ export class CmFileUpload extends LitElement {
|
|
|
86
102
|
if (msg)
|
|
87
103
|
__classPrivateFieldGet(this, _CmFileUpload_internals, "f").setValidity({ customError: true }, msg, input);
|
|
88
104
|
else if (this.required && !this.files.length)
|
|
89
|
-
__classPrivateFieldGet(this, _CmFileUpload_internals, "f").setValidity({ valueMissing: true },
|
|
105
|
+
__classPrivateFieldGet(this, _CmFileUpload_internals, "f").setValidity({ valueMissing: true }, this.t('required'), input);
|
|
90
106
|
else
|
|
91
107
|
__classPrivateFieldGet(this, _CmFileUpload_internals, "f").setValidity({});
|
|
92
108
|
}
|
|
@@ -97,11 +113,11 @@ export class CmFileUpload extends LitElement {
|
|
|
97
113
|
for (const f of incoming) {
|
|
98
114
|
if (!accepts(f, this.accept)) {
|
|
99
115
|
refused.push(f);
|
|
100
|
-
reasons.push(
|
|
116
|
+
reasons.push(this.t('wrongType', { name: f.name }));
|
|
101
117
|
}
|
|
102
118
|
else if (this.maxSize && f.size > this.maxSize) {
|
|
103
119
|
refused.push(f);
|
|
104
|
-
reasons.push(
|
|
120
|
+
reasons.push(this.t('tooLarge', { name: f.name, size: __classPrivateFieldGet(this, _CmFileUpload_instances, "m", _CmFileUpload_size).call(this, this.maxSize) }));
|
|
105
121
|
}
|
|
106
122
|
else
|
|
107
123
|
ok.push(f);
|
|
@@ -111,7 +127,7 @@ export class CmFileUpload extends LitElement {
|
|
|
111
127
|
next = this.files;
|
|
112
128
|
if (this.multiple && this.maxFiles && next.length > this.maxFiles) {
|
|
113
129
|
refused.push(...next.slice(this.maxFiles));
|
|
114
|
-
reasons.push(
|
|
130
|
+
reasons.push(this.t('tooMany', { max: this.maxFiles }));
|
|
115
131
|
next = next.slice(0, this.maxFiles);
|
|
116
132
|
}
|
|
117
133
|
this._rejected = reasons.join('. ');
|
|
@@ -143,12 +159,12 @@ export class CmFileUpload extends LitElement {
|
|
|
143
159
|
</div>`
|
|
144
160
|
: nothing}
|
|
145
161
|
${tile
|
|
146
|
-
? html `<ul class="grid" part="files" role="list" style="list-style:none;margin:0;padding:0" aria-label
|
|
162
|
+
? html `<ul class="grid" part="files" role="list" style="list-style:none;margin:0;padding:0" aria-label=${this.t('files')}>
|
|
147
163
|
${this.files.map((f) => html `<li class="file">
|
|
148
164
|
${f.type.startsWith('image/')
|
|
149
165
|
? html `<img src=${__classPrivateFieldGet(this, _CmFileUpload_instances, "m", _CmFileUpload_url).call(this, f)} alt=${f.name} />`
|
|
150
|
-
: html `<div class="doc"><cm-icon name="book" size="24"></cm-icon><span class="name">${f.name}</span><span class="size">${
|
|
151
|
-
${this.disabled ? nothing : html `<button type="button" class="remove" aria-label
|
|
166
|
+
: html `<div class="doc"><cm-icon name="book" size="24"></cm-icon><span class="name">${f.name}</span><span class="size">${__classPrivateFieldGet(this, _CmFileUpload_instances, "m", _CmFileUpload_size).call(this, f.size)}</span></div>`}
|
|
167
|
+
${this.disabled ? nothing : html `<button type="button" class="remove" aria-label=${this.t('remove', { name: f.name })} @click=${() => this.removeFile(f)}><cm-icon name="close" size="12"></cm-icon></button>`}
|
|
152
168
|
</li>`)}
|
|
153
169
|
${showZone ? html `<li>${__classPrivateFieldGet(this, _CmFileUpload_instances, "m", _CmFileUpload_zone).call(this, true)}</li>` : nothing}
|
|
154
170
|
</ul>`
|
|
@@ -157,7 +173,11 @@ export class CmFileUpload extends LitElement {
|
|
|
157
173
|
`;
|
|
158
174
|
}
|
|
159
175
|
}
|
|
160
|
-
_CmFileUpload_internals = new WeakMap(), _CmFileUpload_id = new WeakMap(), _CmFileUpload_urls = new WeakMap(), _CmFileUpload_instances = new WeakSet(),
|
|
176
|
+
_CmFileUpload_internals = new WeakMap(), _CmFileUpload_id = new WeakMap(), _CmFileUpload_urls = new WeakMap(), _CmFileUpload_instances = new WeakSet(), _CmFileUpload_size = function _CmFileUpload_size(n) {
|
|
177
|
+
return n >= 1024 * 1024
|
|
178
|
+
? this.t('megabytes', { size: this.formatNumber(+(n / 1024 / 1024).toFixed(1), { useGrouping: false }) })
|
|
179
|
+
: this.t('kilobytes', { size: this.formatNumber(Math.max(1, Math.round(n / 1024)), { useGrouping: false }) });
|
|
180
|
+
}, _CmFileUpload_url = function _CmFileUpload_url(f) {
|
|
161
181
|
let u = __classPrivateFieldGet(this, _CmFileUpload_urls, "f").get(f);
|
|
162
182
|
if (!u) {
|
|
163
183
|
u = URL.createObjectURL(f);
|
|
@@ -179,7 +199,7 @@ _CmFileUpload_internals = new WeakMap(), _CmFileUpload_id = new WeakMap(), _CmFi
|
|
|
179
199
|
aria-describedby=${described || nothing} aria-invalid=${this.error || this._rejected ? 'true' : nothing}
|
|
180
200
|
@change=${__classPrivateFieldGet(this, _CmFileUpload_instances, "m", _CmFileUpload_onInputChange)} @cancel=${(e) => e.stopPropagation()} />
|
|
181
201
|
<cm-icon name=${tile ? 'plus' : 'upload'} size=${tile ? 24 : 38}></cm-icon>
|
|
182
|
-
<span id="${__classPrivateFieldGet(this, _CmFileUpload_id, "f")}-p">${tile ? '
|
|
202
|
+
<span id="${__classPrivateFieldGet(this, _CmFileUpload_id, "f")}-p">${tile ? this.t('addMore') : this.prompt}</span>
|
|
183
203
|
</label>`;
|
|
184
204
|
};
|
|
185
205
|
CmFileUpload.formAssociated = true;
|
|
@@ -187,7 +207,7 @@ CmFileUpload.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFoc
|
|
|
187
207
|
CmFileUpload.properties = {
|
|
188
208
|
label: {},
|
|
189
209
|
hint: {},
|
|
190
|
-
prompt: {},
|
|
210
|
+
prompt: { string: 'prompt' },
|
|
191
211
|
name: { reflect: true },
|
|
192
212
|
accept: {},
|
|
193
213
|
multiple: { type: Boolean },
|
|
@@ -205,7 +225,7 @@ CmFileUpload.styles = [
|
|
|
205
225
|
:host { display: block; }
|
|
206
226
|
.head { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: var(--cm-space-10); margin-bottom: var(--cm-space-20); }
|
|
207
227
|
.label { font-size: var(--cm-type-heading-sm-size); font-weight: 600; }
|
|
208
|
-
.req { color: var(--cm-text-critical); margin-
|
|
228
|
+
.req { color: var(--cm-text-critical); margin-inline-start: 2px; }
|
|
209
229
|
.hint { font-size: 12px; color: var(--cm-text-tertiary); }
|
|
210
230
|
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 186px)); gap: var(--cm-space-30); }
|
|
211
231
|
.zone {
|
|
@@ -226,7 +246,7 @@ CmFileUpload.styles = [
|
|
|
226
246
|
.doc .name { font-size: 12px; word-break: break-all; }
|
|
227
247
|
.doc .size, .tile .size { font-size: 12px; color: var(--cm-text-tertiary); }
|
|
228
248
|
.remove {
|
|
229
|
-
position: absolute; top: -10px;
|
|
249
|
+
position: absolute; top: -10px; inset-inline-end: -10px; display: inline-flex; align-items: center; justify-content: center;
|
|
230
250
|
width: 24px; height: 24px; padding: 0; border-radius: var(--cm-radius-full); cursor: pointer;
|
|
231
251
|
background: var(--cm-bg-surface); color: var(--cm-icon-selected); border: var(--cm-border-1) solid var(--cm-border-input);
|
|
232
252
|
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { CmSidePanel } from './side-panel.js';
|
|
2
2
|
import './search.js';
|
|
3
3
|
import './button.js';
|
|
4
|
+
declare const strings: {
|
|
5
|
+
/** Title in the header. */
|
|
6
|
+
heading: string;
|
|
7
|
+
/** Accessible name and placeholder of the search field. */
|
|
8
|
+
searchLabel: string;
|
|
9
|
+
searchPlaceholder: string;
|
|
10
|
+
/** Text of the main and reset buttons. */
|
|
11
|
+
apply: string;
|
|
12
|
+
reset: string;
|
|
13
|
+
};
|
|
14
|
+
declare module '../localize.js' {
|
|
15
|
+
interface CmStrings {
|
|
16
|
+
filterPanel: typeof strings;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
4
19
|
/** Filter values: one entry per field name; a name used by several checked fields gives an array. */
|
|
5
20
|
export type FilterValues = Record<string, string | string[]>;
|
|
6
21
|
/**
|
|
@@ -26,17 +41,24 @@ export declare class CmFilterPanel extends CmSidePanel {
|
|
|
26
41
|
type: BooleanConstructor;
|
|
27
42
|
};
|
|
28
43
|
query: {};
|
|
44
|
+
heading: {
|
|
45
|
+
string: string;
|
|
46
|
+
};
|
|
29
47
|
searchLabel: {
|
|
30
48
|
attribute: string;
|
|
49
|
+
string: string;
|
|
31
50
|
};
|
|
32
51
|
searchPlaceholder: {
|
|
33
52
|
attribute: string;
|
|
53
|
+
string: string;
|
|
34
54
|
};
|
|
35
55
|
applyLabel: {
|
|
36
56
|
attribute: string;
|
|
57
|
+
string: string;
|
|
37
58
|
};
|
|
38
59
|
resetLabel: {
|
|
39
60
|
attribute: string;
|
|
61
|
+
string: string;
|
|
40
62
|
};
|
|
41
63
|
size: {
|
|
42
64
|
reflect: boolean;
|
|
@@ -48,25 +70,25 @@ export declare class CmFilterPanel extends CmSidePanel {
|
|
|
48
70
|
type: BooleanConstructor;
|
|
49
71
|
reflect: boolean;
|
|
50
72
|
};
|
|
51
|
-
heading: {};
|
|
52
73
|
label: {};
|
|
53
74
|
closeLabel: {
|
|
54
75
|
attribute: string;
|
|
76
|
+
string: string;
|
|
55
77
|
};
|
|
56
78
|
};
|
|
57
|
-
/** Title in the header. */
|
|
79
|
+
/** Title in the header. Default: the built-in string `heading` ("Search and Filter"). */
|
|
58
80
|
heading: string;
|
|
59
81
|
/** Shows a search field above the filters. */
|
|
60
82
|
search: boolean;
|
|
61
83
|
/** Text in the search field. */
|
|
62
84
|
query: string;
|
|
63
|
-
/** Accessible name of the search field. */
|
|
85
|
+
/** Accessible name of the search field. Default: the built-in string `searchLabel` ("Search"). */
|
|
64
86
|
searchLabel: string;
|
|
65
|
-
/** Placeholder of the search field. */
|
|
87
|
+
/** Placeholder of the search field. Default: the built-in string `searchPlaceholder` ("Search anything"). */
|
|
66
88
|
searchPlaceholder: string;
|
|
67
|
-
/** Text of the main button. */
|
|
89
|
+
/** Text of the main button. Default: the built-in string `apply` ("Search"). */
|
|
68
90
|
applyLabel: string;
|
|
69
|
-
/** Text of the reset button. */
|
|
91
|
+
/** Text of the reset button. Default: the built-in string `reset` ("Reset"). */
|
|
70
92
|
resetLabel: string;
|
|
71
93
|
static styles: import("lit").CSSResult[];
|
|
72
94
|
/** The `<form>` holding the fields: a direct child, or the first one inside the panel. */
|
|
@@ -84,3 +106,4 @@ declare global {
|
|
|
84
106
|
'cm-filter-panel': CmFilterPanel;
|
|
85
107
|
}
|
|
86
108
|
}
|
|
109
|
+
export {};
|
|
@@ -6,9 +6,20 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _CmFilterPanel_apply, _CmFilterPanel_reset;
|
|
7
7
|
import { html, css, nothing } from 'lit';
|
|
8
8
|
import { define } from '../base.js';
|
|
9
|
+
import { defineStrings } from '../localize.js';
|
|
9
10
|
import { CmSidePanel } from './side-panel.js';
|
|
10
11
|
import './search.js';
|
|
11
12
|
import './button.js';
|
|
13
|
+
const strings = defineStrings('filterPanel', {
|
|
14
|
+
/** Title in the header. */
|
|
15
|
+
heading: 'Search and Filter',
|
|
16
|
+
/** Accessible name and placeholder of the search field. */
|
|
17
|
+
searchLabel: 'Search',
|
|
18
|
+
searchPlaceholder: 'Search anything',
|
|
19
|
+
/** Text of the main and reset buttons. */
|
|
20
|
+
apply: 'Search',
|
|
21
|
+
reset: 'Reset',
|
|
22
|
+
});
|
|
12
23
|
/**
|
|
13
24
|
* "Search and Filter": a Side panel holding a search field and the fields that narrow a list (status, type,
|
|
14
25
|
* category, date range, tags), with Reset and Search at the bottom. Put the fields in a `<form>` in the panel
|
|
@@ -28,20 +39,10 @@ import './button.js';
|
|
|
28
39
|
export class CmFilterPanel extends CmSidePanel {
|
|
29
40
|
constructor() {
|
|
30
41
|
super(...arguments);
|
|
31
|
-
/** Title in the header. */
|
|
32
|
-
this.heading = 'Search and Filter';
|
|
33
42
|
/** Shows a search field above the filters. */
|
|
34
43
|
this.search = false;
|
|
35
44
|
/** Text in the search field. */
|
|
36
45
|
this.query = '';
|
|
37
|
-
/** Accessible name of the search field. */
|
|
38
|
-
this.searchLabel = 'Search';
|
|
39
|
-
/** Placeholder of the search field. */
|
|
40
|
-
this.searchPlaceholder = 'Search anything';
|
|
41
|
-
/** Text of the main button. */
|
|
42
|
-
this.applyLabel = 'Search';
|
|
43
|
-
/** Text of the reset button. */
|
|
44
|
-
this.resetLabel = 'Reset';
|
|
45
46
|
_CmFilterPanel_apply.set(this, () => {
|
|
46
47
|
const ok = this.dispatchEvent(new CustomEvent('cm-filter-apply', {
|
|
47
48
|
detail: { values: this.values, query: this.query }, bubbles: true, composed: true, cancelable: true,
|
|
@@ -112,10 +113,11 @@ CmFilterPanel.properties = {
|
|
|
112
113
|
...CmSidePanel.properties,
|
|
113
114
|
search: { type: Boolean },
|
|
114
115
|
query: {},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
heading: { string: 'heading' },
|
|
117
|
+
searchLabel: { attribute: 'search-label', string: 'searchLabel' },
|
|
118
|
+
searchPlaceholder: { attribute: 'search-placeholder', string: 'searchPlaceholder' },
|
|
119
|
+
applyLabel: { attribute: 'apply-label', string: 'apply' },
|
|
120
|
+
resetLabel: { attribute: 'reset-label', string: 'reset' },
|
|
119
121
|
};
|
|
120
122
|
CmFilterPanel.styles = [
|
|
121
123
|
...CmSidePanel.styles,
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
2
2
|
import './icon.js';
|
|
3
|
+
declare const strings: {
|
|
4
|
+
/** Accessible name of the bar's region. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Accessible name of the dismiss button. */
|
|
7
|
+
dismiss: string;
|
|
8
|
+
};
|
|
9
|
+
declare module '../localize.js' {
|
|
10
|
+
interface CmStrings {
|
|
11
|
+
flashOfferBar: typeof strings;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* A dark strip across the top of the page with one short offer or call to action, such as
|
|
5
16
|
* "Publish your store with a Commmerce plan - Click here to pick a plan". Links inside it are green.
|
|
@@ -8,7 +19,7 @@ import './icon.js';
|
|
|
8
19
|
* @slot icon - Replaces the leading icon.
|
|
9
20
|
* @fires cm-dismiss - When the close button is pressed (with `dismissible`). The bar hides itself unless the event is cancelled.
|
|
10
21
|
*/
|
|
11
|
-
export declare class CmFlashOfferBar extends
|
|
22
|
+
export declare class CmFlashOfferBar extends CmLocalizedElement {
|
|
12
23
|
#private;
|
|
13
24
|
static properties: {
|
|
14
25
|
icon: {};
|
|
@@ -16,13 +27,15 @@ export declare class CmFlashOfferBar extends LitElement {
|
|
|
16
27
|
type: BooleanConstructor;
|
|
17
28
|
reflect: boolean;
|
|
18
29
|
};
|
|
19
|
-
label: {
|
|
30
|
+
label: {
|
|
31
|
+
string: string;
|
|
32
|
+
};
|
|
20
33
|
};
|
|
21
34
|
/** Leading icon from @commmerce/icons. Empty hides it. */
|
|
22
35
|
icon: string;
|
|
23
36
|
/** Shows a close button. */
|
|
24
37
|
dismissible: boolean;
|
|
25
|
-
/** Accessible name of the bar's region. */
|
|
38
|
+
/** Accessible name of the bar's region. Default: the built-in string `label` ("Offer"). */
|
|
26
39
|
label: string;
|
|
27
40
|
static styles: import("lit").CSSResult[];
|
|
28
41
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -32,3 +45,4 @@ declare global {
|
|
|
32
45
|
'cm-flash-offer-bar': CmFlashOfferBar;
|
|
33
46
|
}
|
|
34
47
|
}
|
|
48
|
+
export {};
|
|
@@ -4,9 +4,16 @@ 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 _CmFlashOfferBar_instances, _CmFlashOfferBar_dismiss;
|
|
7
|
-
import {
|
|
7
|
+
import { html, css, nothing } from 'lit';
|
|
8
8
|
import { base, define } from '../base.js';
|
|
9
|
+
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
9
10
|
import './icon.js';
|
|
11
|
+
const strings = defineStrings('flashOfferBar', {
|
|
12
|
+
/** Accessible name of the bar's region. */
|
|
13
|
+
label: 'Offer',
|
|
14
|
+
/** Accessible name of the dismiss button. */
|
|
15
|
+
dismiss: 'Dismiss offer',
|
|
16
|
+
});
|
|
10
17
|
/**
|
|
11
18
|
* A dark strip across the top of the page with one short offer or call to action, such as
|
|
12
19
|
* "Publish your store with a Commmerce plan - Click here to pick a plan". Links inside it are green.
|
|
@@ -15,7 +22,7 @@ import './icon.js';
|
|
|
15
22
|
* @slot icon - Replaces the leading icon.
|
|
16
23
|
* @fires cm-dismiss - When the close button is pressed (with `dismissible`). The bar hides itself unless the event is cancelled.
|
|
17
24
|
*/
|
|
18
|
-
export class CmFlashOfferBar extends
|
|
25
|
+
export class CmFlashOfferBar extends CmLocalizedElement {
|
|
19
26
|
constructor() {
|
|
20
27
|
super(...arguments);
|
|
21
28
|
_CmFlashOfferBar_instances.add(this);
|
|
@@ -23,14 +30,12 @@ export class CmFlashOfferBar extends LitElement {
|
|
|
23
30
|
this.icon = 'send';
|
|
24
31
|
/** Shows a close button. */
|
|
25
32
|
this.dismissible = false;
|
|
26
|
-
/** Accessible name of the bar's region. */
|
|
27
|
-
this.label = 'Offer';
|
|
28
33
|
}
|
|
29
34
|
render() {
|
|
30
|
-
return html `<div class="bar" part="bar" role="region" aria-label=${this.label || '
|
|
35
|
+
return html `<div class="bar" part="bar" role="region" aria-label=${this.label || this.t('label')}>
|
|
31
36
|
<span class="icon" aria-hidden="true"><slot name="icon">${this.icon ? html `<cm-icon name=${this.icon} size="20"></cm-icon>` : nothing}</slot></span>
|
|
32
37
|
<span class="text"><slot></slot></span>
|
|
33
|
-
${this.dismissible ? html `<button type="button" class="close" part="close" aria-label
|
|
38
|
+
${this.dismissible ? html `<button type="button" class="close" part="close" aria-label=${this.t('dismiss')} @click=${__classPrivateFieldGet(this, _CmFlashOfferBar_instances, "m", _CmFlashOfferBar_dismiss)}><cm-icon name="close" size="18"></cm-icon></button>` : nothing}
|
|
34
39
|
</div>`;
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -42,7 +47,7 @@ _CmFlashOfferBar_instances = new WeakSet(), _CmFlashOfferBar_dismiss = function
|
|
|
42
47
|
CmFlashOfferBar.properties = {
|
|
43
48
|
icon: {},
|
|
44
49
|
dismissible: { type: Boolean, reflect: true },
|
|
45
|
-
label: {},
|
|
50
|
+
label: { string: 'label' },
|
|
46
51
|
};
|
|
47
52
|
CmFlashOfferBar.styles = [
|
|
48
53
|
base,
|
|
@@ -60,7 +65,7 @@ CmFlashOfferBar.styles = [
|
|
|
60
65
|
::slotted(a:hover) { text-decoration: underline; }
|
|
61
66
|
::slotted(a:focus-visible) { outline: 2px solid var(--cm-text-on-dark); outline-offset: 2px; border-radius: 2px; }
|
|
62
67
|
.close {
|
|
63
|
-
position: absolute;
|
|
68
|
+
position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); display: grid; place-items: center;
|
|
64
69
|
width: 32px; height: 32px; padding: 0; color: var(--cm-text-on-dark); background: none; border: 0; border-radius: 50%; cursor: pointer;
|
|
65
70
|
}
|
|
66
71
|
.close:hover { background: var(--cm-nav-active); }
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
2
2
|
import './icon.js';
|
|
3
3
|
import './avatar.js';
|
|
4
|
+
declare const strings: {
|
|
5
|
+
/** Accessible name of the header. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Accessible names of the store switcher, the wallet pill and the user pill. */
|
|
8
|
+
store: string;
|
|
9
|
+
balance: string;
|
|
10
|
+
account: string;
|
|
11
|
+
};
|
|
12
|
+
declare module '../localize.js' {
|
|
13
|
+
interface CmStrings {
|
|
14
|
+
headerBar: typeof strings;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
4
17
|
/**
|
|
5
18
|
* The white bar across the top of the admin: logo, store switcher, then account actions, the wallet
|
|
6
19
|
* balance and the signed-in user on the right. For Commmerce products only, not for apps.
|
|
@@ -15,7 +28,7 @@ import './avatar.js';
|
|
|
15
28
|
* @fires cm-wallet - When the wallet balance is pressed.
|
|
16
29
|
* @fires cm-account - When the user pill is pressed. Open the account menu in response.
|
|
17
30
|
*/
|
|
18
|
-
export declare class CmHeaderBar extends
|
|
31
|
+
export declare class CmHeaderBar extends CmLocalizedElement {
|
|
19
32
|
#private;
|
|
20
33
|
static properties: {
|
|
21
34
|
store: {};
|
|
@@ -26,7 +39,9 @@ export declare class CmHeaderBar extends LitElement {
|
|
|
26
39
|
avatarSrc: {
|
|
27
40
|
attribute: string;
|
|
28
41
|
};
|
|
29
|
-
label: {
|
|
42
|
+
label: {
|
|
43
|
+
string: string;
|
|
44
|
+
};
|
|
30
45
|
};
|
|
31
46
|
/** Current store's address or name, shown as the store switcher ("preprod.commmerce.com"). Empty hides it. */
|
|
32
47
|
store: string;
|
|
@@ -36,7 +51,7 @@ export declare class CmHeaderBar extends LitElement {
|
|
|
36
51
|
userName: string;
|
|
37
52
|
/** Avatar image URL. Without it, the initials of `user-name` are shown. */
|
|
38
53
|
avatarSrc: string;
|
|
39
|
-
/** Accessible name of the header's toolbar region. */
|
|
54
|
+
/** Accessible name of the header's toolbar region. Default: the built-in string `label` ("Admin"). */
|
|
40
55
|
label: string;
|
|
41
56
|
static styles: import("lit").CSSResult[];
|
|
42
57
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -46,3 +61,4 @@ declare global {
|
|
|
46
61
|
'cm-header-bar': CmHeaderBar;
|
|
47
62
|
}
|
|
48
63
|
}
|
|
64
|
+
export {};
|
|
@@ -4,10 +4,19 @@ 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 _CmHeaderBar_instances, _CmHeaderBar_fire;
|
|
7
|
-
import {
|
|
7
|
+
import { html, css, nothing } from 'lit';
|
|
8
8
|
import { base, define } from '../base.js';
|
|
9
|
+
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
9
10
|
import './icon.js';
|
|
10
11
|
import './avatar.js';
|
|
12
|
+
const strings = defineStrings('headerBar', {
|
|
13
|
+
/** Accessible name of the header. */
|
|
14
|
+
label: 'Admin',
|
|
15
|
+
/** Accessible names of the store switcher, the wallet pill and the user pill. */
|
|
16
|
+
store: 'Store: {store}. Switch store',
|
|
17
|
+
balance: 'Wallet balance {balance}',
|
|
18
|
+
account: 'Account: {name}',
|
|
19
|
+
});
|
|
11
20
|
/**
|
|
12
21
|
* The white bar across the top of the admin: logo, store switcher, then account actions, the wallet
|
|
13
22
|
* balance and the signed-in user on the right. For Commmerce products only, not for apps.
|
|
@@ -22,7 +31,7 @@ import './avatar.js';
|
|
|
22
31
|
* @fires cm-wallet - When the wallet balance is pressed.
|
|
23
32
|
* @fires cm-account - When the user pill is pressed. Open the account menu in response.
|
|
24
33
|
*/
|
|
25
|
-
export class CmHeaderBar extends
|
|
34
|
+
export class CmHeaderBar extends CmLocalizedElement {
|
|
26
35
|
constructor() {
|
|
27
36
|
super(...arguments);
|
|
28
37
|
_CmHeaderBar_instances.add(this);
|
|
@@ -34,21 +43,19 @@ export class CmHeaderBar extends LitElement {
|
|
|
34
43
|
this.userName = '';
|
|
35
44
|
/** Avatar image URL. Without it, the initials of `user-name` are shown. */
|
|
36
45
|
this.avatarSrc = '';
|
|
37
|
-
/** Accessible name of the header's toolbar region. */
|
|
38
|
-
this.label = 'Admin';
|
|
39
46
|
}
|
|
40
47
|
render() {
|
|
41
48
|
return html `
|
|
42
49
|
<header part="bar" role="banner" aria-label=${this.label || nothing}>
|
|
43
50
|
<div class="logo"><slot name="logo"></slot></div>
|
|
44
|
-
${this.store ? html `<button type="button" class="store" part="store" aria-haspopup="true" aria-label=${
|
|
51
|
+
${this.store ? html `<button type="button" class="store" part="store" aria-haspopup="true" aria-label=${this.t('store', { store: this.store })}
|
|
45
52
|
@click=${() => __classPrivateFieldGet(this, _CmHeaderBar_instances, "m", _CmHeaderBar_fire).call(this, 'cm-store-switch')}><span>${this.store}</span><cm-icon name="chevron-down" size="20"></cm-icon></button>` : nothing}
|
|
46
53
|
<span class="grow"></span>
|
|
47
54
|
<div class="end">
|
|
48
55
|
<div class="actions"><slot name="actions"></slot></div>
|
|
49
|
-
${this.balance ? html `<button type="button" class="pill" part="balance" aria-label=${
|
|
56
|
+
${this.balance ? html `<button type="button" class="pill" part="balance" aria-label=${this.t('balance', { balance: this.balance })}
|
|
50
57
|
@click=${() => __classPrivateFieldGet(this, _CmHeaderBar_instances, "m", _CmHeaderBar_fire).call(this, 'cm-wallet')}>${this.balance}</button>` : nothing}
|
|
51
|
-
${this.userName ? html `<button type="button" class="user" part="user" aria-haspopup="true" aria-label=${
|
|
58
|
+
${this.userName ? html `<button type="button" class="user" part="user" aria-haspopup="true" aria-label=${this.t('account', { name: this.userName })}
|
|
52
59
|
@click=${() => __classPrivateFieldGet(this, _CmHeaderBar_instances, "m", _CmHeaderBar_fire).call(this, 'cm-account')}><span class="name">${this.userName}</span>
|
|
53
60
|
<cm-avatar class="avatar" name=${this.userName} src=${this.avatarSrc} decorative></cm-avatar></button>` : nothing}
|
|
54
61
|
<slot name="end"></slot>
|
|
@@ -65,14 +72,14 @@ CmHeaderBar.properties = {
|
|
|
65
72
|
balance: {},
|
|
66
73
|
userName: { attribute: 'user-name' },
|
|
67
74
|
avatarSrc: { attribute: 'avatar-src' },
|
|
68
|
-
label: {},
|
|
75
|
+
label: { string: 'label' },
|
|
69
76
|
};
|
|
70
77
|
CmHeaderBar.styles = [
|
|
71
78
|
base,
|
|
72
79
|
css `
|
|
73
80
|
:host { display: block; background: var(--cm-bg-surface); container-type: inline-size; }
|
|
74
81
|
header {
|
|
75
|
-
display: flex; align-items: center; gap: var(--cm-space-20); min-height: 70px; padding: 10px var(--cm-space-20)
|
|
82
|
+
display: flex; align-items: center; gap: var(--cm-space-20); min-height: 70px; padding-block: 10px; padding-inline: 27px var(--cm-space-20);
|
|
76
83
|
}
|
|
77
84
|
.logo { display: flex; align-items: center; flex: none; }
|
|
78
85
|
::slotted([slot='logo']) { display: block; max-height: 24px; width: auto; }
|
|
@@ -81,7 +88,7 @@ CmHeaderBar.styles = [
|
|
|
81
88
|
background: none; cursor: pointer;
|
|
82
89
|
}
|
|
83
90
|
.store {
|
|
84
|
-
margin-
|
|
91
|
+
margin-inline-start: 60px; padding: 6px 8px; border: 0; border-radius: var(--cm-radius-sm); font-size: 18px; min-width: 0; flex: 0 1 auto;
|
|
85
92
|
}
|
|
86
93
|
.store span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
87
94
|
.store:hover { background: var(--cm-bg-hover); }
|
|
@@ -94,13 +101,13 @@ CmHeaderBar.styles = [
|
|
|
94
101
|
}
|
|
95
102
|
.pill:hover, .user:hover { background: var(--cm-bg-hover); }
|
|
96
103
|
.user {
|
|
97
|
-
min-height: 50px; padding: 4px
|
|
104
|
+
min-height: 50px; padding-block: 4px; padding-inline: 20px 6px; gap: var(--cm-space-20); font-size: 18px;
|
|
98
105
|
border: var(--cm-border-1) solid var(--cm-border-strong); border-radius: var(--cm-radius-full);
|
|
99
106
|
}
|
|
100
107
|
.avatar { --cm-avatar-size: 36px; }
|
|
101
108
|
button:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
102
109
|
@container (max-width: 1300px) {
|
|
103
|
-
.store { margin-
|
|
110
|
+
.store { margin-inline-start: var(--cm-space-20); }
|
|
104
111
|
}
|
|
105
112
|
@container (max-width: 1100px) {
|
|
106
113
|
.store { font-size: 16px; }
|
|
@@ -111,7 +118,7 @@ CmHeaderBar.styles = [
|
|
|
111
118
|
@container (max-width: 640px) {
|
|
112
119
|
header { min-height: 56px; gap: var(--cm-space-10); padding: 8px var(--cm-space-15); }
|
|
113
120
|
.actions, .pill { display: none; }
|
|
114
|
-
.store { margin-
|
|
121
|
+
.store { margin-inline-start: 0; font-size: 14px; }
|
|
115
122
|
.user { padding: 2px; min-height: 0; border-color: transparent; }
|
|
116
123
|
.user .name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
117
124
|
.avatar { --cm-avatar-size: 32px; }
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import { type IconName } from '@commmerce/icons';
|
|
3
|
+
/** Icons that point along the reading direction (back, forward, go). In right-to-left text they are mirrored. */
|
|
4
|
+
export declare const directionalIcons: readonly string[];
|
|
3
5
|
/**
|
|
4
6
|
* Line icon from @commmerce/icons. Decorative unless `label` is set.
|
|
7
|
+
* Icons that point forward or back (chevron-left/right, arrow-left, arrow-up-right, send) are mirrored in
|
|
8
|
+
* right-to-left text (`dir="rtl"`); all others never are.
|
|
5
9
|
* @element cm-icon
|
|
6
10
|
*/
|
|
7
11
|
export declare class CmIcon extends LitElement {
|
|
@@ -13,6 +17,7 @@ export declare class CmIcon extends LitElement {
|
|
|
13
17
|
type: NumberConstructor;
|
|
14
18
|
};
|
|
15
19
|
label: {};
|
|
20
|
+
mirror: {};
|
|
16
21
|
};
|
|
17
22
|
/** Icon from @commmerce/icons. See the Icons page for all names. */
|
|
18
23
|
name: IconName;
|
|
@@ -20,6 +25,8 @@ export declare class CmIcon extends LitElement {
|
|
|
20
25
|
size: number;
|
|
21
26
|
/** Accessible name. Leave empty when the icon sits next to text that says the same thing. */
|
|
22
27
|
label: string;
|
|
28
|
+
/** Mirroring in right-to-left text: `auto` mirrors only directional icons, `never` keeps any icon as drawn, `always` mirrors any icon. */
|
|
29
|
+
mirror: 'auto' | 'always' | 'never';
|
|
23
30
|
static styles: import("lit").CSSResult;
|
|
24
31
|
render(): import("lit-html").TemplateResult<2>;
|
|
25
32
|
}
|
package/dist/components/icon.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { LitElement, svg, css, nothing } from 'lit';
|
|
2
2
|
import { icons, dotted } from '@commmerce/icons';
|
|
3
3
|
import { define } from '../base.js';
|
|
4
|
+
/** Icons that point along the reading direction (back, forward, go). In right-to-left text they are mirrored. */
|
|
5
|
+
export const directionalIcons = ['chevron-left', 'chevron-right', 'arrow-left', 'arrow-up-right', 'send'];
|
|
4
6
|
/**
|
|
5
7
|
* Line icon from @commmerce/icons. Decorative unless `label` is set.
|
|
8
|
+
* Icons that point forward or back (chevron-left/right, arrow-left, arrow-up-right, send) are mirrored in
|
|
9
|
+
* right-to-left text (`dir="rtl"`); all others never are.
|
|
6
10
|
* @element cm-icon
|
|
7
11
|
*/
|
|
8
12
|
export class CmIcon extends LitElement {
|
|
@@ -14,6 +18,8 @@ export class CmIcon extends LitElement {
|
|
|
14
18
|
this.size = 18;
|
|
15
19
|
/** Accessible name. Leave empty when the icon sits next to text that says the same thing. */
|
|
16
20
|
this.label = '';
|
|
21
|
+
/** Mirroring in right-to-left text: `auto` mirrors only directional icons, `never` keeps any icon as drawn, `always` mirrors any icon. */
|
|
22
|
+
this.mirror = 'auto';
|
|
17
23
|
}
|
|
18
24
|
render() {
|
|
19
25
|
const d = icons[this.name] ?? icons.more;
|
|
@@ -21,16 +27,18 @@ export class CmIcon extends LitElement {
|
|
|
21
27
|
return svg `<svg width=${this.size} height=${this.size} viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
22
28
|
stroke-width=${sw} stroke-linecap="round" stroke-linejoin="round"
|
|
23
29
|
role=${this.label ? 'img' : nothing} aria-label=${this.label || nothing} aria-hidden=${this.label ? nothing : 'true'}
|
|
24
|
-
part="svg"><path d=${d}></path></svg>`;
|
|
30
|
+
part="svg" class=${(this.mirror === 'auto' ? directionalIcons.includes(this.name) : this.mirror === 'always') ? 'flip' : ''}><path d=${d}></path></svg>`;
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
CmIcon.properties = {
|
|
28
34
|
name: { reflect: true },
|
|
29
35
|
size: { type: Number },
|
|
30
36
|
label: {},
|
|
37
|
+
mirror: {},
|
|
31
38
|
};
|
|
32
39
|
CmIcon.styles = css `
|
|
33
40
|
:host { display: inline-flex; flex: none; color: inherit; line-height: 0; }
|
|
34
41
|
svg { display: block; }
|
|
42
|
+
:host(:dir(rtl)) svg.flip { transform: scaleX(-1); }
|
|
35
43
|
`;
|
|
36
44
|
define('cm-icon', CmIcon);
|