@commmerce/ui 1.1.1 → 1.3.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.d.ts +38 -0
- package/dist/calendar.js +109 -0
- package/dist/cdn.js +1010 -533
- package/dist/components/board.d.ts +338 -0
- package/dist/components/board.js +1017 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +25 -0
- package/dist/components/card.d.ts +7 -1
- package/dist/components/card.js +58 -7
- package/dist/components/color-field.d.ts +153 -0
- package/dist/components/color-field.js +369 -0
- package/dist/components/combobox.d.ts +17 -4
- package/dist/components/combobox.js +55 -23
- package/dist/components/date-picker.d.ts +49 -5
- package/dist/components/date-picker.js +211 -48
- package/dist/components/empty-state.d.ts +19 -4
- package/dist/components/empty-state.js +59 -5
- package/dist/components/file-upload.d.ts +33 -0
- package/dist/components/file-upload.js +80 -9
- package/dist/components/global-search.js +2 -7
- package/dist/components/metric.d.ts +97 -0
- package/dist/components/metric.js +168 -0
- package/dist/components/nested-list.d.ts +33 -1
- package/dist/components/nested-list.js +197 -18
- package/dist/components/option-group.d.ts +15 -6
- package/dist/components/option-group.js +25 -6
- package/dist/components/page-header.js +3 -2
- package/dist/components/resource-list.d.ts +14 -2
- package/dist/components/resource-list.js +48 -6
- package/dist/components/select.d.ts +20 -3
- package/dist/components/select.js +35 -11
- package/dist/components/table-header.d.ts +14 -0
- package/dist/components/table-header.js +21 -0
- package/dist/components/text-field.d.ts +36 -2
- package/dist/components/text-field.js +86 -14
- package/dist/components/timeline.d.ts +210 -0
- package/dist/components/timeline.js +380 -0
- package/dist/custom-elements.json +9371 -4963
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/move-model.d.ts +93 -0
- package/dist/move-model.js +169 -0
- package/dist/popover.d.ts +24 -0
- package/dist/popover.js +59 -0
- package/package.json +3 -3
|
@@ -22,9 +22,10 @@ const strings = defineStrings('optionGroup', {
|
|
|
22
22
|
* types, such as offer types. Behaves like a native radio group: one tab stop, arrow keys move and
|
|
23
23
|
* select, and the form receives the selected value.
|
|
24
24
|
*
|
|
25
|
-
* Options come from `<option>` children or the `options` property.
|
|
25
|
+
* Options come from `<option>` children or the `options` property. A `tone` on an option (`<option tone="success">`
|
|
26
|
+
* or `{ tone }`, since 1.3) colours it by the outcome it records: outlined in the tone, filled in it when selected.
|
|
26
27
|
* @element cm-option-group
|
|
27
|
-
* @slot - `<option value="…">Label</option>` elements. `disabled` and `
|
|
28
|
+
* @slot - `<option value="…">Label</option>` elements. `disabled`, `selected` and `tone` (`success`, `critical`) are honoured.
|
|
28
29
|
* @fires change - When the merchant picks a different option.
|
|
29
30
|
* @fires input - Same moment as `change`.
|
|
30
31
|
*/
|
|
@@ -38,7 +39,7 @@ export class CmOptionGroup extends CmLocalizedElement {
|
|
|
38
39
|
this.name = '';
|
|
39
40
|
/** Value of the selected option; empty when nothing is selected. */
|
|
40
41
|
this.value = '';
|
|
41
|
-
/** Options as strings or `{ value, label, disabled }`. Used instead of `<option>` children when set. */
|
|
42
|
+
/** Options as strings or `{ value, label, disabled, tone }`. Used instead of `<option>` children when set. */
|
|
42
43
|
this.options = [];
|
|
43
44
|
/** The form will not submit until an option is chosen. */
|
|
44
45
|
this.required = false;
|
|
@@ -53,7 +54,7 @@ export class CmOptionGroup extends CmLocalizedElement {
|
|
|
53
54
|
connectedCallback() {
|
|
54
55
|
super.connectedCallback();
|
|
55
56
|
__classPrivateFieldGet(this, _CmOptionGroup_instances, "m", _CmOptionGroup_readChildren).call(this);
|
|
56
|
-
__classPrivateFieldGet(this, _CmOptionGroup_observer, "f").observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['value', 'label', 'disabled', 'selected'] });
|
|
57
|
+
__classPrivateFieldGet(this, _CmOptionGroup_observer, "f").observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['value', 'label', 'disabled', 'selected', 'tone'] });
|
|
57
58
|
}
|
|
58
59
|
disconnectedCallback() {
|
|
59
60
|
super.disconnectedCallback();
|
|
@@ -96,7 +97,7 @@ export class CmOptionGroup extends CmLocalizedElement {
|
|
|
96
97
|
<div class="options" part="options" role="radiogroup"
|
|
97
98
|
aria-labelledby=${this.label ? `${__classPrivateFieldGet(this, _CmOptionGroup_id, "f")}-l` : nothing} aria-label=${!this.label && hostLabel ? hostLabel : nothing}
|
|
98
99
|
aria-required=${this.required ? 'true' : nothing}>
|
|
99
|
-
${items.map((o, i) => html `<button type="button" role="radio" part="option" aria-checked=${o.value === this.value ? 'true' : 'false'}
|
|
100
|
+
${items.map((o, i) => html `<button type="button" role="radio" part="option" class=${o.tone === 'critical' || o.tone === 'success' ? `tone-${o.tone}` : nothing} aria-checked=${o.value === this.value ? 'true' : 'false'}
|
|
100
101
|
tabindex=${i === stop ? '0' : '-1'} ?disabled=${this.disabled || !!o.disabled}
|
|
101
102
|
@click=${() => __classPrivateFieldGet(this, _CmOptionGroup_instances, "m", _CmOptionGroup_select).call(this, i)} @keydown=${(e) => __classPrivateFieldGet(this, _CmOptionGroup_instances, "m", _CmOptionGroup_onKeyDown).call(this, e, i)}>${o.label}</button>`)}
|
|
102
103
|
</div>
|
|
@@ -106,7 +107,13 @@ export class CmOptionGroup extends CmLocalizedElement {
|
|
|
106
107
|
}
|
|
107
108
|
_CmOptionGroup_internals = new WeakMap(), _CmOptionGroup_id = new WeakMap(), _CmOptionGroup_defaultValue = new WeakMap(), _CmOptionGroup_observer = new WeakMap(), _CmOptionGroup_instances = new WeakSet(), _CmOptionGroup_readChildren = function _CmOptionGroup_readChildren() {
|
|
108
109
|
const opts = [...this.querySelectorAll('option')];
|
|
109
|
-
this._slotted = opts.map((o) =>
|
|
110
|
+
this._slotted = opts.map((o) => {
|
|
111
|
+
const opt = { value: o.value, label: o.label || o.textContent.trim(), disabled: o.disabled };
|
|
112
|
+
const tone = o.getAttribute('tone');
|
|
113
|
+
if (tone === 'critical' || tone === 'success')
|
|
114
|
+
opt.tone = tone;
|
|
115
|
+
return opt;
|
|
116
|
+
});
|
|
110
117
|
if (!this.hasUpdated && !this.value) {
|
|
111
118
|
this.value = opts.find((o) => o.hasAttribute('selected'))?.value ?? '';
|
|
112
119
|
__classPrivateFieldSet(this, _CmOptionGroup_defaultValue, this.value, "f");
|
|
@@ -167,6 +174,18 @@ CmOptionGroup.styles = [
|
|
|
167
174
|
button:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
168
175
|
button:disabled { background: var(--cm-bg-input-filled); color: var(--cm-text-secondary); border-color: var(--cm-border-default); cursor: not-allowed; }
|
|
169
176
|
button[aria-checked='true']:disabled { background: var(--cm-action-disabled); color: var(--cm-action-disabled-text); }
|
|
177
|
+
/* Tones (1.3), the same token pairs as cm-button's tones (packages/tokens/scripts/contrast.mjs). Unselected: tone
|
|
178
|
+
text and outline on bg-surface (text-critical on bg-hover is under 4.5:1 in dark), hover tints it. Selected:
|
|
179
|
+
filled with the tone's text colour under action-primary-text; hover darkens it towards text-default. Selected
|
|
180
|
+
and unselected differ by fill, not only hue; disabled options look like any disabled option. */
|
|
181
|
+
button.tone-critical:not(:disabled) { --_tone: var(--cm-text-critical); --_edge: var(--cm-border-critical); --_tint: var(--cm-bg-critical); }
|
|
182
|
+
button.tone-success:not(:disabled) { --_tone: var(--cm-text-success); --_edge: var(--cm-text-success); --_tint: var(--cm-bg-success-soft); }
|
|
183
|
+
button[class^='tone-']:not(:disabled) { background: var(--cm-bg-surface); color: var(--_tone); border-color: var(--_edge); }
|
|
184
|
+
button[class^='tone-']:not(:disabled):hover { background: linear-gradient(var(--_tint), var(--_tint)) var(--cm-bg-surface); }
|
|
185
|
+
button[class^='tone-'][aria-checked='true']:not(:disabled) { background: var(--_tone); border-color: var(--_tone); color: var(--cm-action-primary-text); }
|
|
186
|
+
button[class^='tone-'][aria-checked='true']:not(:disabled):hover {
|
|
187
|
+
background: color-mix(in srgb, var(--_tone) 80%, var(--cm-text-default)); border-color: color-mix(in srgb, var(--_tone) 80%, var(--cm-text-default));
|
|
188
|
+
}
|
|
170
189
|
slot { display: none; }
|
|
171
190
|
@media (max-width: 640px) {
|
|
172
191
|
.label { font-size: var(--cm-type-heading-sm-resp-size); }
|
|
@@ -105,10 +105,11 @@ CmPageHeader.styles = [
|
|
|
105
105
|
nav a:focus-visible, .back:focus-visible, .arrow:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
106
106
|
nav [aria-current] { color: var(--cm-text-default); }
|
|
107
107
|
h1 {
|
|
108
|
-
display: flex; align-items: center; gap: var(--cm-space-10); margin: 0; min-width: 0;
|
|
108
|
+
display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--cm-space-10); margin: 0; min-width: 0;
|
|
109
109
|
font-size: 26px; font-weight: 500; line-height: 1.2;
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
/* The title keeps at least about 12 characters; badges in title-adornment wrap below it instead of pushing the page wider. */
|
|
112
|
+
.text { flex: 0 1 auto; min-width: min(12ch, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
112
113
|
.actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-20); margin-inline-start: auto; }
|
|
113
114
|
.arrows { display: flex; gap: var(--cm-space-10); }
|
|
114
115
|
.arrow, .back {
|
|
@@ -34,7 +34,7 @@ declare module '../localize.js' {
|
|
|
34
34
|
* A row in a `cm-resource-list`: a checkbox when the list is selectable, an optional thumbnail and
|
|
35
35
|
* any content. With `href` the whole row is a link; otherwise clicking a selectable row ticks it.
|
|
36
36
|
* @element cm-resource-item
|
|
37
|
-
* @slot - Row content: name, details, badges.
|
|
37
|
+
* @slot - Row content: name, details, badges. To line up with a `cm-table-header`, set `columns` and give one element per column.
|
|
38
38
|
* @slot media - A 50px thumbnail (34px on phones): a `cm-thumbnail` (recommended; `alt=""` when the row names the product) or an `<img>`.
|
|
39
39
|
* @slot actions - Buttons at the end of the row. They do not toggle selection.
|
|
40
40
|
* @fires cm-resource-select - `detail: { value, selected }` when the merchant ticks or unticks the row. The list handles it.
|
|
@@ -59,6 +59,10 @@ export declare class CmResourceItem extends CmLocalizedElement {
|
|
|
59
59
|
type: BooleanConstructor;
|
|
60
60
|
reflect: boolean;
|
|
61
61
|
};
|
|
62
|
+
columns: {
|
|
63
|
+
type: BooleanConstructor;
|
|
64
|
+
reflect: boolean;
|
|
65
|
+
};
|
|
62
66
|
};
|
|
63
67
|
/** Identifies the row in the list's `selected` array. */
|
|
64
68
|
value: string;
|
|
@@ -72,6 +76,11 @@ export declare class CmResourceItem extends CmLocalizedElement {
|
|
|
72
76
|
label: string;
|
|
73
77
|
/** Shows the checkbox. Set by the parent list from its own `selectable`. */
|
|
74
78
|
selectable: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Lays the row's content out on the `--cm-table-columns` grid (set it on the list), one child element per column,
|
|
81
|
+
* `space-20` apart: the same grid as a `cm-table-header` in the list's `header` slot, so cells sit under their headings.
|
|
82
|
+
*/
|
|
83
|
+
columns: boolean;
|
|
75
84
|
constructor();
|
|
76
85
|
connectedCallback(): void;
|
|
77
86
|
static styles: import("lit").CSSResult[];
|
|
@@ -86,9 +95,12 @@ export declare class CmResourceItem extends CmLocalizedElement {
|
|
|
86
95
|
* When `selectable`, a toolbar shows a select-all box with a menu (this page, all matching, none), bulk actions once something is selected,
|
|
87
96
|
* "2 products selected" and, when there are more results than rows, a button to select all of them.
|
|
88
97
|
* Put a `cm-table-header` in the `header` slot for column names and `cm-pagination` under the list.
|
|
98
|
+
* The list lines a slotted `cm-table-header` up with its rows (it sets the header's `resource-rows`): lay each row's
|
|
99
|
+
* content out as a grid with `grid-template-columns: var(--cm-table-columns)` and `column-gap: var(--cm-space-20)`,
|
|
100
|
+
* and set `--cm-table-columns` on the list.
|
|
89
101
|
* @element cm-resource-list
|
|
90
102
|
* @slot - `cm-resource-item` rows.
|
|
91
|
-
* @slot header - A `cm-table-header` (or anything) between the toolbar and the rows.
|
|
103
|
+
* @slot header - A `cm-table-header` (or anything) between the toolbar and the rows. A `cm-table-header` here is lined up with the rows, checkbox column included.
|
|
92
104
|
* @slot bulk-actions - Buttons that act on the selection, e.g. "Bulk orders". Shown once a row is selected.
|
|
93
105
|
* @slot actions - Buttons at the end of the toolbar, e.g. "Customise columns".
|
|
94
106
|
* @slot empty - Shown instead of the rows when there are none, e.g. a `cm-empty-state`.
|
|
@@ -3,7 +3,13 @@ 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
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _CmResourceItem_instances, _CmResourceItem_internals, _CmResourceItem_onRowClick, _CmResourceList_instances, _CmResourceList_id, _CmResourceList_headers, _CmResourceList_plural, _CmResourceList_syncHeaders, _CmResourceList_onHeaderSlot, _CmResourceList_sync, _CmResourceList_emit, _CmResourceList_menuSelect;
|
|
7
13
|
import { html, css, nothing } from 'lit';
|
|
8
14
|
import { base, define, nextId } from '../base.js';
|
|
9
15
|
import { CmLocalizedElement, defineStrings, pluralCategory } from '../localize.js';
|
|
@@ -49,7 +55,7 @@ const checkboxStyles = css `
|
|
|
49
55
|
* A row in a `cm-resource-list`: a checkbox when the list is selectable, an optional thumbnail and
|
|
50
56
|
* any content. With `href` the whole row is a link; otherwise clicking a selectable row ticks it.
|
|
51
57
|
* @element cm-resource-item
|
|
52
|
-
* @slot - Row content: name, details, badges.
|
|
58
|
+
* @slot - Row content: name, details, badges. To line up with a `cm-table-header`, set `columns` and give one element per column.
|
|
53
59
|
* @slot media - A 50px thumbnail (34px on phones): a `cm-thumbnail` (recommended; `alt=""` when the row names the product) or an `<img>`.
|
|
54
60
|
* @slot actions - Buttons at the end of the row. They do not toggle selection.
|
|
55
61
|
* @fires cm-resource-select - `detail: { value, selected }` when the merchant ticks or unticks the row. The list handles it.
|
|
@@ -70,6 +76,11 @@ export class CmResourceItem extends CmLocalizedElement {
|
|
|
70
76
|
this.label = '';
|
|
71
77
|
/** Shows the checkbox. Set by the parent list from its own `selectable`. */
|
|
72
78
|
this.selectable = false;
|
|
79
|
+
/**
|
|
80
|
+
* Lays the row's content out on the `--cm-table-columns` grid (set it on the list), one child element per column,
|
|
81
|
+
* `space-20` apart: the same grid as a `cm-table-header` in the list's `header` slot, so cells sit under their headings.
|
|
82
|
+
*/
|
|
83
|
+
this.columns = false;
|
|
73
84
|
_CmResourceItem_internals.set(this, this.attachInternals());
|
|
74
85
|
__classPrivateFieldGet(this, _CmResourceItem_internals, "f").role = 'listitem';
|
|
75
86
|
}
|
|
@@ -126,6 +137,7 @@ CmResourceItem.properties = {
|
|
|
126
137
|
href: {},
|
|
127
138
|
label: {},
|
|
128
139
|
selectable: { type: Boolean, reflect: true },
|
|
140
|
+
columns: { type: Boolean, reflect: true },
|
|
129
141
|
};
|
|
130
142
|
CmResourceItem.styles = [
|
|
131
143
|
base,
|
|
@@ -146,6 +158,10 @@ CmResourceItem.styles = [
|
|
|
146
158
|
}
|
|
147
159
|
::slotted(cm-thumbnail[slot='media']) { --cm-thumbnail-size: 50px; background: none; }
|
|
148
160
|
.content { flex: 1; min-width: 0; }
|
|
161
|
+
:host([columns]) .content {
|
|
162
|
+
display: grid; grid-template-columns: var(--cm-table-columns, minmax(0, 1fr)); column-gap: var(--cm-space-20); align-items: center;
|
|
163
|
+
}
|
|
164
|
+
:host([columns]) ::slotted(*) { min-width: 0; overflow-wrap: anywhere; }
|
|
149
165
|
a { position: absolute; inset: 0; z-index: 0; border-radius: var(--cm-radius-xs); }
|
|
150
166
|
a:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: -2px; }
|
|
151
167
|
.check, .actions { position: relative; z-index: 1; }
|
|
@@ -165,9 +181,12 @@ define('cm-resource-item', CmResourceItem);
|
|
|
165
181
|
* When `selectable`, a toolbar shows a select-all box with a menu (this page, all matching, none), bulk actions once something is selected,
|
|
166
182
|
* "2 products selected" and, when there are more results than rows, a button to select all of them.
|
|
167
183
|
* Put a `cm-table-header` in the `header` slot for column names and `cm-pagination` under the list.
|
|
184
|
+
* The list lines a slotted `cm-table-header` up with its rows (it sets the header's `resource-rows`): lay each row's
|
|
185
|
+
* content out as a grid with `grid-template-columns: var(--cm-table-columns)` and `column-gap: var(--cm-space-20)`,
|
|
186
|
+
* and set `--cm-table-columns` on the list.
|
|
168
187
|
* @element cm-resource-list
|
|
169
188
|
* @slot - `cm-resource-item` rows.
|
|
170
|
-
* @slot header - A `cm-table-header` (or anything) between the toolbar and the rows.
|
|
189
|
+
* @slot header - A `cm-table-header` (or anything) between the toolbar and the rows. A `cm-table-header` here is lined up with the rows, checkbox column included.
|
|
171
190
|
* @slot bulk-actions - Buttons that act on the selection, e.g. "Bulk orders". Shown once a row is selected.
|
|
172
191
|
* @slot actions - Buttons at the end of the toolbar, e.g. "Customise columns".
|
|
173
192
|
* @slot empty - Shown instead of the rows when there are none, e.g. a `cm-empty-state`.
|
|
@@ -194,6 +213,12 @@ export class CmResourceList extends CmLocalizedElement {
|
|
|
194
213
|
this._count = 0;
|
|
195
214
|
this._rows = 0;
|
|
196
215
|
_CmResourceList_id.set(this, nextId('cm-rl'));
|
|
216
|
+
_CmResourceList_headers.set(this, new Set());
|
|
217
|
+
_CmResourceList_onHeaderSlot.set(this, (e) => {
|
|
218
|
+
const slot = e.target;
|
|
219
|
+
slot.parentElement.classList.toggle('has', slot.assignedElements().length > 0);
|
|
220
|
+
__classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_syncHeaders).call(this, slot);
|
|
221
|
+
});
|
|
197
222
|
_CmResourceList_menuSelect.set(this, (e) => {
|
|
198
223
|
e.stopPropagation(); // the list's own menu: don't leak its cm-select to the page
|
|
199
224
|
const v = e.detail.value;
|
|
@@ -240,8 +265,10 @@ export class CmResourceList extends CmLocalizedElement {
|
|
|
240
265
|
/** Clears the selection. */
|
|
241
266
|
clearSelection() { this.selectPage(false); }
|
|
242
267
|
updated(changed) {
|
|
243
|
-
if (changed.has('selectable'))
|
|
268
|
+
if (changed.has('selectable')) {
|
|
244
269
|
__classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this);
|
|
270
|
+
__classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_syncHeaders).call(this);
|
|
271
|
+
}
|
|
245
272
|
}
|
|
246
273
|
render() {
|
|
247
274
|
const n = this._count;
|
|
@@ -279,7 +306,7 @@ export class CmResourceList extends CmLocalizedElement {
|
|
|
279
306
|
<span class="actions"><slot name="actions"></slot></span>
|
|
280
307
|
</div>`
|
|
281
308
|
: nothing}
|
|
282
|
-
<div class="header"><slot name="header" @slotchange=${(
|
|
309
|
+
<div class="header"><slot name="header" @slotchange=${__classPrivateFieldGet(this, _CmResourceList_onHeaderSlot, "f")}></slot></div>
|
|
283
310
|
<div class="body">
|
|
284
311
|
<div class="list" part="list" role="list" aria-label=${this.label || plural.replace(/^./, (c) => c.toUpperCase())} aria-busy=${this.loading ? 'true' : 'false'}>
|
|
285
312
|
<slot @slotchange=${() => __classPrivateFieldGet(this, _CmResourceList_instances, "m", _CmResourceList_sync).call(this)}></slot>
|
|
@@ -290,12 +317,27 @@ export class CmResourceList extends CmLocalizedElement {
|
|
|
290
317
|
`;
|
|
291
318
|
}
|
|
292
319
|
}
|
|
293
|
-
_CmResourceList_id = new WeakMap(), _CmResourceList_menuSelect = new WeakMap(), _CmResourceList_instances = new WeakSet(), _CmResourceList_plural = function _CmResourceList_plural() {
|
|
320
|
+
_CmResourceList_id = new WeakMap(), _CmResourceList_headers = new WeakMap(), _CmResourceList_onHeaderSlot = new WeakMap(), _CmResourceList_menuSelect = new WeakMap(), _CmResourceList_instances = new WeakSet(), _CmResourceList_plural = function _CmResourceList_plural() {
|
|
294
321
|
if (this.resourceNamePlural)
|
|
295
322
|
return this.resourceNamePlural;
|
|
296
323
|
const own = this.resourceName;
|
|
297
324
|
// A custom singular keeps the old rule (plus "s"); the built-in noun has its own plural.
|
|
298
325
|
return own !== this.t('resourceName') ? `${own}s` : this.t('resourceNamePlural');
|
|
326
|
+
}, _CmResourceList_syncHeaders = function _CmResourceList_syncHeaders(slot = this.renderRoot?.querySelector('slot[name="header"]')) {
|
|
327
|
+
if (!slot)
|
|
328
|
+
return;
|
|
329
|
+
const found = new Set();
|
|
330
|
+
for (const el of slot.assignedElements()) {
|
|
331
|
+
if (el.localName === 'cm-table-header')
|
|
332
|
+
found.add(el);
|
|
333
|
+
el.querySelectorAll('cm-table-header').forEach((h) => found.add(h));
|
|
334
|
+
}
|
|
335
|
+
for (const h of __classPrivateFieldGet(this, _CmResourceList_headers, "f"))
|
|
336
|
+
if (!found.has(h))
|
|
337
|
+
h.removeAttribute('resource-rows');
|
|
338
|
+
for (const h of found)
|
|
339
|
+
h.setAttribute('resource-rows', this.selectable ? 'selectable' : 'plain');
|
|
340
|
+
__classPrivateFieldSet(this, _CmResourceList_headers, found, "f");
|
|
299
341
|
}, _CmResourceList_sync = function _CmResourceList_sync() {
|
|
300
342
|
const items = this.items;
|
|
301
343
|
items.forEach((i) => (i.selectable = this.selectable));
|
|
@@ -3,6 +3,8 @@ import './icon.js';
|
|
|
3
3
|
declare const strings: {
|
|
4
4
|
/** Validation message when `required` and nothing is chosen. */
|
|
5
5
|
required: string;
|
|
6
|
+
/** The chosen option in the box with `show-group`: "Lead: Company". */
|
|
7
|
+
grouped: string;
|
|
6
8
|
};
|
|
7
9
|
declare module '../localize.js' {
|
|
8
10
|
interface CmStrings {
|
|
@@ -13,6 +15,11 @@ export interface SelectOption {
|
|
|
13
15
|
value: string;
|
|
14
16
|
label: string;
|
|
15
17
|
disabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Heading of the group the option belongs to ("Lead"), like a native `<optgroup label>`. Options of the same group
|
|
20
|
+
* are shown together under the heading, in the order the groups first appear. Since 1.3.
|
|
21
|
+
*/
|
|
22
|
+
group?: string;
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
18
25
|
* Dropdown field: a labelled box that opens a list of options and shows the chosen one.
|
|
@@ -20,8 +27,9 @@ export interface SelectOption {
|
|
|
20
27
|
* design; it keeps native-select keyboard behaviour. Participates in native forms.
|
|
21
28
|
*
|
|
22
29
|
* Options come from `<option>` children (easy in plain HTML, PHP and EJS) or the `options` property.
|
|
30
|
+
* Group them under headings with `<optgroup label="…">` or a `group` on each option (since 1.3).
|
|
23
31
|
* @element cm-select
|
|
24
|
-
* @slot - `<option value="…">Label</option>` elements
|
|
32
|
+
* @slot - `<option value="…">Label</option>` elements, optionally inside `<optgroup label="…">`. `disabled` (also on an optgroup) and `selected` are honoured.
|
|
25
33
|
* @fires change - When the merchant picks a different option.
|
|
26
34
|
* @fires input - Same moment as `change`.
|
|
27
35
|
*/
|
|
@@ -62,6 +70,10 @@ export declare class CmSelect extends CmLocalizedElement {
|
|
|
62
70
|
type: BooleanConstructor;
|
|
63
71
|
reflect: boolean;
|
|
64
72
|
};
|
|
73
|
+
showGroup: {
|
|
74
|
+
type: BooleanConstructor;
|
|
75
|
+
attribute: string;
|
|
76
|
+
};
|
|
65
77
|
_active: {
|
|
66
78
|
state: boolean;
|
|
67
79
|
};
|
|
@@ -81,7 +93,7 @@ export declare class CmSelect extends CmLocalizedElement {
|
|
|
81
93
|
value: string;
|
|
82
94
|
/** Shown while nothing is chosen, e.g. "Select customer". */
|
|
83
95
|
placeholder: string;
|
|
84
|
-
/** Options as strings or `{ value, label, disabled }`. Used instead of `<option>` children when set. */
|
|
96
|
+
/** Options as strings or `{ value, label, disabled, group }`. Used instead of `<option>` children when set. */
|
|
85
97
|
options: Array<string | SelectOption>;
|
|
86
98
|
/** The form will not submit until an option is chosen. */
|
|
87
99
|
required: boolean;
|
|
@@ -89,6 +101,11 @@ export declare class CmSelect extends CmLocalizedElement {
|
|
|
89
101
|
disabled: boolean;
|
|
90
102
|
/** Whether the list is showing. */
|
|
91
103
|
open: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Shows the chosen option's group before its label in the box ("Lead: Company"), for grouped lists where labels
|
|
106
|
+
* repeat across groups. The list itself always shows the bare label under its group heading. Since 1.3.
|
|
107
|
+
*/
|
|
108
|
+
showGroup: boolean;
|
|
92
109
|
_active: number;
|
|
93
110
|
_slotted: SelectOption[];
|
|
94
111
|
static styles: import("lit").CSSResult[];
|
|
@@ -102,7 +119,7 @@ export declare class CmSelect extends CmLocalizedElement {
|
|
|
102
119
|
formResetCallback(): void;
|
|
103
120
|
formDisabledCallback(d: boolean): void;
|
|
104
121
|
formStateRestoreCallback(state: string): void;
|
|
105
|
-
/** The options in use, normalised. */
|
|
122
|
+
/** The options in use, normalised, in the order shown (options of a group together). */
|
|
106
123
|
get items(): SelectOption[];
|
|
107
124
|
firstUpdated(): void;
|
|
108
125
|
updated(changed: Map<string, unknown>): void;
|
|
@@ -9,14 +9,17 @@ 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 _CmSelect_instances, _CmSelect_internals, _CmSelect_id, _CmSelect_defaultValue, _CmSelect_typed, _CmSelect_typedAt, _CmSelect_observer, _CmSelect_readChildren, _CmSelect_enabledIndexes, _CmSelect_show, _CmSelect_hide, _CmSelect_commit, _CmSelect_move, _CmSelect_typeahead, _CmSelect_onKeyDown, _CmSelect_onOutside, _CmSelect_onBoxClick, _CmSelect_focusBox;
|
|
12
|
+
var _CmSelect_instances, _CmSelect_internals, _CmSelect_id, _CmSelect_defaultValue, _CmSelect_typed, _CmSelect_typedAt, _CmSelect_observer, _CmSelect_readChildren, _CmSelect_enabledIndexes, _CmSelect_show, _CmSelect_hide, _CmSelect_commit, _CmSelect_move, _CmSelect_typeahead, _CmSelect_onKeyDown, _CmSelect_onOutside, _CmSelect_onBoxClick, _CmSelect_display, _CmSelect_focusBox;
|
|
13
13
|
import { LitElement, html, css, nothing } from 'lit';
|
|
14
14
|
import { base, define, nextId } from '../base.js';
|
|
15
15
|
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
16
|
+
import { groupStyles, sortByGroup, groupRuns } from '../popover.js';
|
|
16
17
|
import './icon.js';
|
|
17
18
|
const strings = defineStrings('select', {
|
|
18
19
|
/** Validation message when `required` and nothing is chosen. */
|
|
19
20
|
required: 'Please select an item in the list.',
|
|
21
|
+
/** The chosen option in the box with `show-group`: "Lead: Company". */
|
|
22
|
+
grouped: '{group}: {label}',
|
|
20
23
|
});
|
|
21
24
|
/**
|
|
22
25
|
* Dropdown field: a labelled box that opens a list of options and shows the chosen one.
|
|
@@ -24,8 +27,9 @@ const strings = defineStrings('select', {
|
|
|
24
27
|
* design; it keeps native-select keyboard behaviour. Participates in native forms.
|
|
25
28
|
*
|
|
26
29
|
* Options come from `<option>` children (easy in plain HTML, PHP and EJS) or the `options` property.
|
|
30
|
+
* Group them under headings with `<optgroup label="…">` or a `group` on each option (since 1.3).
|
|
27
31
|
* @element cm-select
|
|
28
|
-
* @slot - `<option value="…">Label</option>` elements
|
|
32
|
+
* @slot - `<option value="…">Label</option>` elements, optionally inside `<optgroup label="…">`. `disabled` (also on an optgroup) and `selected` are honoured.
|
|
29
33
|
* @fires change - When the merchant picks a different option.
|
|
30
34
|
* @fires input - Same moment as `change`.
|
|
31
35
|
*/
|
|
@@ -45,7 +49,7 @@ export class CmSelect extends CmLocalizedElement {
|
|
|
45
49
|
this.value = '';
|
|
46
50
|
/** Shown while nothing is chosen, e.g. "Select customer". */
|
|
47
51
|
this.placeholder = '';
|
|
48
|
-
/** Options as strings or `{ value, label, disabled }`. Used instead of `<option>` children when set. */
|
|
52
|
+
/** Options as strings or `{ value, label, disabled, group }`. Used instead of `<option>` children when set. */
|
|
49
53
|
this.options = [];
|
|
50
54
|
/** The form will not submit until an option is chosen. */
|
|
51
55
|
this.required = false;
|
|
@@ -53,6 +57,11 @@ export class CmSelect extends CmLocalizedElement {
|
|
|
53
57
|
this.disabled = false;
|
|
54
58
|
/** Whether the list is showing. */
|
|
55
59
|
this.open = false;
|
|
60
|
+
/**
|
|
61
|
+
* Shows the chosen option's group before its label in the box ("Lead: Company"), for grouped lists where labels
|
|
62
|
+
* repeat across groups. The list itself always shows the bare label under its group heading. Since 1.3.
|
|
63
|
+
*/
|
|
64
|
+
this.showGroup = false;
|
|
56
65
|
this._active = -1;
|
|
57
66
|
this._slotted = [];
|
|
58
67
|
_CmSelect_internals.set(this, this.attachInternals());
|
|
@@ -178,11 +187,11 @@ export class CmSelect extends CmLocalizedElement {
|
|
|
178
187
|
formDisabledCallback(d) { this.disabled = d; if (d)
|
|
179
188
|
this.open = false; }
|
|
180
189
|
formStateRestoreCallback(state) { this.value = state; }
|
|
181
|
-
/** The options in use, normalised. */
|
|
190
|
+
/** The options in use, normalised, in the order shown (options of a group together). */
|
|
182
191
|
get items() {
|
|
183
192
|
if (!this.options.length)
|
|
184
|
-
return this._slotted;
|
|
185
|
-
return this.options.map((o) => (typeof o === 'string' ? { value: o, label: o } : o));
|
|
193
|
+
return sortByGroup(this._slotted);
|
|
194
|
+
return sortByGroup(this.options.map((o) => (typeof o === 'string' ? { value: o, label: o } : o)));
|
|
186
195
|
}
|
|
187
196
|
firstUpdated() { __classPrivateFieldSet(this, _CmSelect_defaultValue, __classPrivateFieldGet(this, _CmSelect_defaultValue, "f") || this.value, "f"); }
|
|
188
197
|
updated(changed) {
|
|
@@ -203,6 +212,9 @@ export class CmSelect extends CmLocalizedElement {
|
|
|
203
212
|
const current = items.find((o) => o.value === this.value);
|
|
204
213
|
const described = [this.error && `${__classPrivateFieldGet(this, _CmSelect_id, "f")}-err`, this.helpText && `${__classPrivateFieldGet(this, _CmSelect_id, "f")}-help`].filter(Boolean).join(' ');
|
|
205
214
|
const hostLabel = this.getAttribute('aria-label');
|
|
215
|
+
const option = (o, i) => html `<li role="option" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-o${i}" class=${i === this._active ? 'active' : ''}
|
|
216
|
+
aria-selected=${o.value === this.value ? 'true' : 'false'} aria-disabled=${o.disabled ? 'true' : nothing}
|
|
217
|
+
@pointerenter=${() => !o.disabled && (this._active = i)} @click=${() => __classPrivateFieldGet(this, _CmSelect_instances, "m", _CmSelect_commit).call(this, i)}>${o.label}</li>`;
|
|
206
218
|
return html `<div class="field">
|
|
207
219
|
${this.label
|
|
208
220
|
? html `<span class="label" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-l" part="label" @click=${__classPrivateFieldGet(this, _CmSelect_focusBox, "f")}>${this.label}${this.required ? html `<span class="req" aria-hidden="true">*</span>` : nothing}</span>`
|
|
@@ -216,15 +228,16 @@ export class CmSelect extends CmLocalizedElement {
|
|
|
216
228
|
aria-required=${this.required ? 'true' : nothing} aria-invalid=${this.error ? 'true' : nothing}
|
|
217
229
|
aria-disabled=${this.disabled ? 'true' : nothing} aria-describedby=${described || nothing}
|
|
218
230
|
@click=${__classPrivateFieldGet(this, _CmSelect_onBoxClick, "f")} @keydown=${__classPrivateFieldGet(this, _CmSelect_onKeyDown, "f")} @blur=${() => __classPrivateFieldGet(this, _CmSelect_instances, "m", _CmSelect_hide).call(this)}>
|
|
219
|
-
<span class="text ${current ? '' : 'placeholder'}" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-v">${current ?
|
|
231
|
+
<span class="text ${current ? '' : 'placeholder'}" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-v">${current ? __classPrivateFieldGet(this, _CmSelect_instances, "m", _CmSelect_display).call(this, current) : this.placeholder}</span>
|
|
220
232
|
<cm-icon class="chev" name="chevron-down" size="16"></cm-icon>
|
|
221
233
|
</div>
|
|
222
234
|
<ul role="listbox" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-list" part="listbox" tabindex="-1" aria-labelledby=${this.label ? `${__classPrivateFieldGet(this, _CmSelect_id, "f")}-l` : nothing}
|
|
223
235
|
aria-label=${!this.label && hostLabel ? hostLabel : nothing} ?hidden=${!this.open}
|
|
224
236
|
@pointerdown=${(e) => e.preventDefault()}>
|
|
225
|
-
${items.map((
|
|
226
|
-
|
|
227
|
-
|
|
237
|
+
${groupRuns(items).map((run, gi) => run.group
|
|
238
|
+
? html `<li role="group" aria-labelledby="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-g${gi}"><div role="presentation" class="gh" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-g${gi}">${run.group}</div>
|
|
239
|
+
<ul role="none" class="gopts">${run.rows.map(({ row, index }) => option(row, index))}</ul></li>`
|
|
240
|
+
: run.rows.map(({ row, index }) => option(row, index)))}
|
|
228
241
|
</ul>
|
|
229
242
|
</div>
|
|
230
243
|
${this.error ? html `<p class="error" id="${__classPrivateFieldGet(this, _CmSelect_id, "f")}-err" role="alert">${this.error}</p>` : nothing}
|
|
@@ -235,7 +248,13 @@ export class CmSelect extends CmLocalizedElement {
|
|
|
235
248
|
}
|
|
236
249
|
_CmSelect_internals = new WeakMap(), _CmSelect_id = new WeakMap(), _CmSelect_defaultValue = new WeakMap(), _CmSelect_typed = new WeakMap(), _CmSelect_typedAt = new WeakMap(), _CmSelect_observer = new WeakMap(), _CmSelect_onKeyDown = new WeakMap(), _CmSelect_onOutside = new WeakMap(), _CmSelect_onBoxClick = new WeakMap(), _CmSelect_focusBox = new WeakMap(), _CmSelect_instances = new WeakSet(), _CmSelect_readChildren = function _CmSelect_readChildren() {
|
|
237
250
|
const opts = [...this.querySelectorAll('option')];
|
|
238
|
-
this._slotted = opts.map((o) =>
|
|
251
|
+
this._slotted = opts.map((o) => {
|
|
252
|
+
const g = o.parentElement?.localName === 'optgroup' ? o.parentElement : null;
|
|
253
|
+
const opt = { value: o.value, label: o.label || o.textContent.trim(), disabled: o.disabled || !!g?.disabled };
|
|
254
|
+
if (g?.label)
|
|
255
|
+
opt.group = g.label;
|
|
256
|
+
return opt;
|
|
257
|
+
});
|
|
239
258
|
if (!this.hasUpdated && !this.value) {
|
|
240
259
|
this.value = opts.find((o) => o.hasAttribute('selected'))?.value ?? '';
|
|
241
260
|
__classPrivateFieldSet(this, _CmSelect_defaultValue, this.value, "f");
|
|
@@ -282,6 +301,8 @@ _CmSelect_internals = new WeakMap(), _CmSelect_id = new WeakMap(), _CmSelect_def
|
|
|
282
301
|
return i;
|
|
283
302
|
}
|
|
284
303
|
return -1;
|
|
304
|
+
}, _CmSelect_display = function _CmSelect_display(o) {
|
|
305
|
+
return this.showGroup && o.group ? this.t('grouped', { group: o.group, label: o.label }) : o.label;
|
|
285
306
|
};
|
|
286
307
|
CmSelect.formAssociated = true;
|
|
287
308
|
CmSelect.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
@@ -296,11 +317,13 @@ CmSelect.properties = {
|
|
|
296
317
|
required: { type: Boolean, reflect: true },
|
|
297
318
|
disabled: { type: Boolean, reflect: true },
|
|
298
319
|
open: { type: Boolean, reflect: true },
|
|
320
|
+
showGroup: { type: Boolean, attribute: 'show-group' },
|
|
299
321
|
_active: { state: true },
|
|
300
322
|
_slotted: { state: true },
|
|
301
323
|
};
|
|
302
324
|
CmSelect.styles = [
|
|
303
325
|
base,
|
|
326
|
+
groupStyles,
|
|
304
327
|
css `
|
|
305
328
|
:host { display: block; position: relative; }
|
|
306
329
|
.field { display: flex; flex-direction: column; gap: var(--cm-space-10); }
|
|
@@ -333,6 +356,7 @@ CmSelect.styles = [
|
|
|
333
356
|
[role='option'][aria-selected='true'] { background: var(--cm-action-primary); color: var(--cm-action-primary-text); }
|
|
334
357
|
[role='option'][aria-selected='true'].active { background: var(--cm-action-primary-hover); }
|
|
335
358
|
[role='option'][aria-disabled='true'] { color: var(--cm-text-secondary); cursor: not-allowed; }
|
|
359
|
+
[role='group'] { display: block; }
|
|
336
360
|
.help, .error { margin: 0; font-size: 12px; color: var(--cm-text-tertiary); }
|
|
337
361
|
.error { color: var(--cm-text-critical); }
|
|
338
362
|
slot { display: none; }
|
|
@@ -31,6 +31,10 @@ export interface TableColumn {
|
|
|
31
31
|
* grid: set `--cm-table-columns` (a `grid-template-columns` value) on a shared parent.
|
|
32
32
|
* Inside an element with `role="table"` or `role="grid"` it renders a real header row
|
|
33
33
|
* (`row` and `columnheader` roles); elsewhere it is a plain bar whose sort buttons say their state.
|
|
34
|
+
*
|
|
35
|
+
* In the `header` slot of a `cm-resource-list`, the list sets `resource-rows` so the column names line up with the
|
|
36
|
+
* cells of its `cm-resource-item` rows (including the rows' checkbox column when the list is `selectable`). The
|
|
37
|
+
* list's toolbar has the select-all box there: don't also set `selectable` on the header.
|
|
34
38
|
* @element cm-table-header
|
|
35
39
|
* @slot - `<option value="key" sortable align="end">Label</option>` elements.
|
|
36
40
|
* @fires cm-sort - `detail: { key, direction }` when a sortable column is clicked. Set `sort` and `direction` yourself.
|
|
@@ -61,6 +65,10 @@ export declare class CmTableHeader extends CmLocalizedElement {
|
|
|
61
65
|
type: BooleanConstructor;
|
|
62
66
|
reflect: boolean;
|
|
63
67
|
};
|
|
68
|
+
resourceRows: {
|
|
69
|
+
attribute: string;
|
|
70
|
+
reflect: boolean;
|
|
71
|
+
};
|
|
64
72
|
_slotted: {
|
|
65
73
|
state: boolean;
|
|
66
74
|
};
|
|
@@ -80,6 +88,12 @@ export declare class CmTableHeader extends CmLocalizedElement {
|
|
|
80
88
|
checked: boolean;
|
|
81
89
|
/** Select-all box shows a dash: some rows are selected. */
|
|
82
90
|
indeterminate: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Lines the columns up with `cm-resource-item` rows: `plain` matches the rows' padding, `selectable` also leaves
|
|
93
|
+
* room for the rows' checkboxes. Set by `cm-resource-list` on a header in its `header` slot (from its own
|
|
94
|
+
* `selectable`); you don't need to set it. Unset (the default) is the standalone bar.
|
|
95
|
+
*/
|
|
96
|
+
resourceRows?: 'plain' | 'selectable';
|
|
83
97
|
_slotted: TableColumn[];
|
|
84
98
|
_inTable: boolean;
|
|
85
99
|
static styles: import("lit").CSSResult[];
|
|
@@ -23,6 +23,10 @@ const strings = defineStrings('tableHeader', {
|
|
|
23
23
|
* grid: set `--cm-table-columns` (a `grid-template-columns` value) on a shared parent.
|
|
24
24
|
* Inside an element with `role="table"` or `role="grid"` it renders a real header row
|
|
25
25
|
* (`row` and `columnheader` roles); elsewhere it is a plain bar whose sort buttons say their state.
|
|
26
|
+
*
|
|
27
|
+
* In the `header` slot of a `cm-resource-list`, the list sets `resource-rows` so the column names line up with the
|
|
28
|
+
* cells of its `cm-resource-item` rows (including the rows' checkbox column when the list is `selectable`). The
|
|
29
|
+
* list's toolbar has the select-all box there: don't also set `selectable` on the header.
|
|
26
30
|
* @element cm-table-header
|
|
27
31
|
* @slot - `<option value="key" sortable align="end">Label</option>` elements.
|
|
28
32
|
* @fires cm-sort - `detail: { key, direction }` when a sortable column is clicked. Set `sort` and `direction` yourself.
|
|
@@ -119,6 +123,7 @@ CmTableHeader.properties = {
|
|
|
119
123
|
selectable: { type: Boolean, reflect: true },
|
|
120
124
|
checked: { type: Boolean, reflect: true },
|
|
121
125
|
indeterminate: { type: Boolean, reflect: true },
|
|
126
|
+
resourceRows: { attribute: 'resource-rows', reflect: true },
|
|
122
127
|
_slotted: { state: true },
|
|
123
128
|
_inTable: { state: true },
|
|
124
129
|
};
|
|
@@ -154,6 +159,22 @@ CmTableHeader.styles = [
|
|
|
154
159
|
.dash { width: 10px; height: 2px; background: var(--cm-icon-selected); }
|
|
155
160
|
input:focus-visible + .box { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
156
161
|
slot { display: none; }
|
|
162
|
+
/* In a cm-resource-list (resource-rows): the bar's content box matches a row's content box, so the same
|
|
163
|
+
--cm-table-columns grid (with column-gap space-20) lands on the same x positions. Rows are padded space-10
|
|
164
|
+
inline, start with a 20px checkbox and a space-20 gap when selectable, and end with the gap before their
|
|
165
|
+
(possibly empty) actions; on phones: no padding, an 18px checkbox, space-10 gaps.
|
|
166
|
+
The bar reaches out to the list's edges; its border is drawn inside so it takes no room. */
|
|
167
|
+
:host([resource-rows]) .bar {
|
|
168
|
+
margin-inline: calc(-1 * var(--cm-space-10)); padding-inline: var(--cm-space-20) calc(2 * var(--cm-space-20));
|
|
169
|
+
border: 0; box-shadow: inset 0 0 0 var(--cm-border-1) var(--cm-border-subtle);
|
|
170
|
+
}
|
|
171
|
+
:host([resource-rows='selectable']) .bar:not(.sel) { padding-inline-start: calc(var(--cm-space-20) + 20px + var(--cm-space-20)); }
|
|
172
|
+
:host([resource-rows]) .bar.sel > .cell:first-child { overflow: visible; }
|
|
173
|
+
@media (max-width: 640px) {
|
|
174
|
+
:host([resource-rows]) .bar { padding-inline: var(--cm-space-10) calc(2 * var(--cm-space-10)); }
|
|
175
|
+
:host([resource-rows='selectable']) .bar:not(.sel) { padding-inline-start: calc(var(--cm-space-10) + 18px + var(--cm-space-10)); }
|
|
176
|
+
:host([resource-rows]) .bar.sel { grid-template-columns: calc(18px + var(--cm-space-10) - var(--cm-space-20)) var(--cm-table-columns, var(--_cols)); }
|
|
177
|
+
}
|
|
157
178
|
`,
|
|
158
179
|
];
|
|
159
180
|
define('cm-table-header', CmTableHeader);
|
|
@@ -2,6 +2,20 @@ import { CmLocalizedElement } from '../localize.js';
|
|
|
2
2
|
declare const strings: {
|
|
3
3
|
/** Validation message when `required` and empty. */
|
|
4
4
|
required: string;
|
|
5
|
+
/** Validation: a date or time before `min`. `{min}` is the min in the page language, e.g. "16 Nov 2026, 3:30 pm". */
|
|
6
|
+
rangeUnderflow: string;
|
|
7
|
+
/** Validation: a date or time after `max`. */
|
|
8
|
+
rangeOverflow: string;
|
|
9
|
+
/** Validation: a number below `min`. */
|
|
10
|
+
numberUnderflow: string;
|
|
11
|
+
/** Validation: a number above `max`. */
|
|
12
|
+
numberOverflow: string;
|
|
13
|
+
/** Validation: a value off the `step`. `{lower}` and `{upper}` are the nearest allowed values. */
|
|
14
|
+
stepMismatch: string;
|
|
15
|
+
/** Validation, `type="time"`: the time is only partly filled in. */
|
|
16
|
+
badTime: string;
|
|
17
|
+
/** Validation, `type="datetime-local"`: the date and time are only partly filled in. */
|
|
18
|
+
badDateTime: string;
|
|
5
19
|
};
|
|
6
20
|
declare module '../localize.js' {
|
|
7
21
|
interface CmStrings {
|
|
@@ -10,6 +24,8 @@ declare module '../localize.js' {
|
|
|
10
24
|
}
|
|
11
25
|
/**
|
|
12
26
|
* Labelled single- or multi-line input. Participates in native forms.
|
|
27
|
+
* `type="date"`, `"time"` and `"datetime-local"` use the browser's own picker; their values are ISO and local
|
|
28
|
+
* (`yyyy-mm-dd`, `hh:mm`, `yyyy-mm-ddThh:mm`), with no time zone.
|
|
13
29
|
* @element cm-text-field
|
|
14
30
|
* @fires input - On every keystroke (bubbles, composed).
|
|
15
31
|
* @fires change - When the value is committed.
|
|
@@ -60,6 +76,9 @@ export declare class CmTextField extends CmLocalizedElement {
|
|
|
60
76
|
size: {
|
|
61
77
|
reflect: boolean;
|
|
62
78
|
};
|
|
79
|
+
min: {};
|
|
80
|
+
max: {};
|
|
81
|
+
step: {};
|
|
63
82
|
};
|
|
64
83
|
/** Visible label above the box. Required for accessibility unless the field has an aria-label. */
|
|
65
84
|
label: string;
|
|
@@ -75,8 +94,11 @@ export declare class CmTextField extends CmLocalizedElement {
|
|
|
75
94
|
value: string;
|
|
76
95
|
/** Example input, shown in text-tertiary. Never a substitute for the label. */
|
|
77
96
|
placeholder: string;
|
|
78
|
-
/**
|
|
79
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Native input type. Ignored when `multiline`. `time` and `datetime-local` (since 1.2) give the browser's time and
|
|
99
|
+
* date-and-time pickers; their value is local time without a time zone, `hh:mm` and `yyyy-mm-ddThh:mm`.
|
|
100
|
+
*/
|
|
101
|
+
type: 'text' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'url' | 'date' | 'time' | 'datetime-local';
|
|
80
102
|
/** Renders a resizable textarea. */
|
|
81
103
|
multiline: boolean;
|
|
82
104
|
/** Visible rows when `multiline`. */
|
|
@@ -91,6 +113,18 @@ export declare class CmTextField extends CmLocalizedElement {
|
|
|
91
113
|
autocomplete?: string;
|
|
92
114
|
/** `small`: 12px label, 14px value (filter panels). */
|
|
93
115
|
size: 'default' | 'small';
|
|
116
|
+
/**
|
|
117
|
+
* Lowest allowed value for `number`, `date`, `time` and `datetime-local`, in the value's format (`2026-11-16T15:30`
|
|
118
|
+
* for `datetime-local`). The browser's picker doesn't offer earlier dates; an earlier value makes the field invalid.
|
|
119
|
+
*/
|
|
120
|
+
min?: string;
|
|
121
|
+
/** Highest allowed value for `number`, `date`, `time` and `datetime-local`, in the value's format. */
|
|
122
|
+
max?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Allowed steps from `min`, as on a native input: a number for `number`, days for `date`, seconds for `time` and
|
|
125
|
+
* `datetime-local` (`900` = 15 minutes; under 60 shows seconds). `any` allows every value.
|
|
126
|
+
*/
|
|
127
|
+
step?: string;
|
|
94
128
|
static styles: import("lit").CSSResult[];
|
|
95
129
|
connectedCallback(): void;
|
|
96
130
|
get form(): HTMLFormElement | null;
|