@commmerce/ui 1.3.0 → 1.5.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/THIRD_PARTY_NOTICES.txt +101 -0
- package/dist/calendar.js +15 -19
- package/dist/cdn.js +1669 -1193
- package/dist/components/accordion.js +9 -8
- package/dist/components/action-bar.js +15 -15
- package/dist/components/action-menu.js +10 -9
- package/dist/components/app-card.js +15 -14
- package/dist/components/app-frame.d.ts +15 -0
- package/dist/components/app-frame.js +22 -2
- package/dist/components/badge.d.ts +2 -1
- package/dist/components/badge.js +4 -3
- package/dist/components/banner.js +6 -5
- package/dist/components/board.js +18 -18
- package/dist/components/bottom-navigation.d.ts +1 -1
- package/dist/components/bottom-navigation.js +9 -7
- package/dist/components/bottom-sheet.d.ts +1 -1
- package/dist/components/bottom-sheet.js +9 -8
- package/dist/components/button.d.ts +3 -3
- package/dist/components/button.js +22 -19
- package/dist/components/calendar.d.ts +380 -0
- package/dist/components/calendar.js +1480 -0
- package/dist/components/card.d.ts +1 -1
- package/dist/components/card.js +18 -12
- package/dist/components/checkbox.js +8 -7
- package/dist/components/color-field.js +9 -13
- package/dist/components/combobox.d.ts +8 -0
- package/dist/components/combobox.js +18 -18
- package/dist/components/comment.d.ts +1 -1
- package/dist/components/comment.js +12 -13
- package/dist/components/data-table.js +12 -11
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-range-picker.js +7 -7
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/empty-state.js +16 -16
- package/dist/components/file-upload.js +18 -16
- package/dist/components/filter-panel.js +1 -1
- package/dist/components/flash-offer-bar.js +8 -7
- package/dist/components/global-search.d.ts +1 -1
- package/dist/components/global-search.js +12 -9
- package/dist/components/grid.d.ts +1 -1
- package/dist/components/grid.js +1 -1
- package/dist/components/header-bar.js +38 -31
- package/dist/components/info-panel.d.ts +1 -1
- package/dist/components/info-panel.js +11 -10
- package/dist/components/layout.d.ts +1 -1
- package/dist/components/layout.js +1 -1
- package/dist/components/link-tabs.js +8 -7
- package/dist/components/metric.js +4 -4
- package/dist/components/mobile-menu.js +16 -15
- package/dist/components/modal.js +2 -1
- package/dist/components/nested-list.d.ts +2 -2
- package/dist/components/nested-list.js +21 -22
- package/dist/components/notification-panel.js +12 -11
- package/dist/components/option-group.js +10 -11
- package/dist/components/page-header.js +16 -15
- package/dist/components/page.d.ts +18 -4
- package/dist/components/page.js +22 -7
- package/dist/components/pagination.d.ts +1 -1
- package/dist/components/pagination.js +16 -9
- package/dist/components/progress-bar.js +4 -3
- package/dist/components/radio.js +12 -12
- package/dist/components/report-tile.d.ts +2 -2
- package/dist/components/report-tile.js +18 -18
- package/dist/components/resource-list.d.ts +22 -6
- package/dist/components/resource-list.js +92 -52
- package/dist/components/save-bar.js +8 -8
- package/dist/components/search.d.ts +5 -2
- package/dist/components/search.js +20 -14
- package/dist/components/segmented-control.d.ts +67 -0
- package/dist/components/segmented-control.js +76 -0
- package/dist/components/select.d.ts +8 -0
- package/dist/components/select.js +18 -18
- package/dist/components/side-navigation.js +20 -17
- package/dist/components/side-panel.js +4 -3
- package/dist/components/signature-field.d.ts +153 -0
- package/dist/components/signature-field.js +728 -0
- package/dist/components/skeleton-display.js +4 -4
- package/dist/components/skeleton.d.ts +1 -1
- package/dist/components/skeleton.js +2 -2
- package/dist/components/smart-tip.d.ts +1 -1
- package/dist/components/smart-tip.js +16 -16
- package/dist/components/spinner.js +1 -1
- package/dist/components/stack.d.ts +1 -1
- package/dist/components/stack.js +1 -1
- package/dist/components/status-tabs.d.ts +4 -3
- package/dist/components/status-tabs.js +26 -12
- package/dist/components/table-header.d.ts +4 -3
- package/dist/components/table-header.js +22 -15
- package/dist/components/tag.js +3 -4
- package/dist/components/text-field.d.ts +1 -1
- package/dist/components/text-field.js +8 -15
- package/dist/components/thumbnail.js +1 -1
- package/dist/components/timeline.js +12 -11
- package/dist/components/toast.js +6 -6
- package/dist/components/toggle.js +12 -11
- package/dist/components/tooltip.js +4 -3
- package/dist/custom-elements.json +13655 -9770
- package/dist/field.d.ts +15 -0
- package/dist/field.js +47 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/overlay.js +5 -4
- package/dist/popover.js +8 -8
- package/dist/spacing.d.ts +14 -4
- package/dist/spacing.js +13 -4
- package/package.json +3 -3
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { base, define } from '../base.js';
|
|
3
|
+
import { defineStrings } from '../localize.js';
|
|
4
|
+
import { CmOptionGroup } from './option-group.js';
|
|
5
|
+
const strings = defineStrings('segmentedControl', {
|
|
6
|
+
/** Validation message when `required` and nothing is chosen. */
|
|
7
|
+
required: 'Please select one of these options.',
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* A compact switch between two to four views or filters of the same content ("Open / Done", "Board / List"): the
|
|
11
|
+
* options sit side by side in one track and exactly one is selected. Since 1.5.
|
|
12
|
+
*
|
|
13
|
+
* It is an option group with a different look, so it behaves exactly like `cm-option-group`: a radio group with one
|
|
14
|
+
* tab stop, arrow keys (mirrored in right-to-left text), Home and End move and select, `change` fires on every new
|
|
15
|
+
* choice, and inside a form it submits its `value`. Options come from `<option>` children or the `options` property.
|
|
16
|
+
* Option `tone`s are not shown: a view switch has no good or bad answer.
|
|
17
|
+
*
|
|
18
|
+
* Use it to change what a page or card shows, right away. To pick a setting that is saved with a form, use
|
|
19
|
+
* `cm-option-group` (bigger, separate buttons); for five or more choices, `cm-select`; for page sections, tabs.
|
|
20
|
+
* @element cm-segmented-control
|
|
21
|
+
* @slot - `<option value="…">Label</option>` elements. `disabled` and `selected` are honoured.
|
|
22
|
+
* @csspart options - The track (`role="radiogroup"`).
|
|
23
|
+
* @csspart option - Each option (`role="radio"`).
|
|
24
|
+
* @csspart label - The visible label, when `label` is set.
|
|
25
|
+
* @fires change - When the merchant picks a different option.
|
|
26
|
+
* @fires input - Same moment as `change`.
|
|
27
|
+
*/
|
|
28
|
+
export class CmSegmentedControl extends CmOptionGroup {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
/**
|
|
32
|
+
* `default`: a 36px track, the height of buttons and fields beside it. `small`: 32px, for toolbars, filter rows and
|
|
33
|
+
* card headers next to small fields and slim buttons. On touch screens both are 44px tall.
|
|
34
|
+
*/
|
|
35
|
+
this.size = 'default';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
CmSegmentedControl.properties = {
|
|
39
|
+
...CmOptionGroup.properties,
|
|
40
|
+
size: { reflect: true },
|
|
41
|
+
};
|
|
42
|
+
CmSegmentedControl.styles = [
|
|
43
|
+
base,
|
|
44
|
+
css `
|
|
45
|
+
:host { display: inline-block; vertical-align: middle; max-width: 100%; --_h: var(--cm-control-height-md, 36px); }
|
|
46
|
+
:host([size='small']) { --_h: var(--cm-control-height-sm, 32px); }
|
|
47
|
+
@media (pointer: coarse) { :host, :host([size='small']) { --_h: var(--cm-control-height-touch, 44px); } }
|
|
48
|
+
.label {
|
|
49
|
+
display: block; margin-bottom: var(--cm-space-8);
|
|
50
|
+
font-size: var(--cm-type-label-size); line-height: var(--cm-type-label-line-height); font-weight: var(--cm-type-label-weight);
|
|
51
|
+
}
|
|
52
|
+
.req { color: var(--cm-text-critical); margin-inline-start: 2px; }
|
|
53
|
+
.options {
|
|
54
|
+
display: inline-flex; max-width: 100%; height: var(--_h); padding: 2px; gap: 2px;
|
|
55
|
+
background: var(--cm-bg-hover); border: var(--cm-border-1) solid var(--cm-border-subtle); border-radius: var(--cm-radius-sm);
|
|
56
|
+
}
|
|
57
|
+
button {
|
|
58
|
+
flex: 1 1 auto; min-width: 0; height: 100%; padding: 0 var(--cm-space-12);
|
|
59
|
+
font: inherit; font-size: var(--cm-font-size-14); line-height: var(--cm-line-height-14); font-weight: 500; white-space: nowrap;
|
|
60
|
+
overflow: hidden; text-overflow: ellipsis;
|
|
61
|
+
color: var(--cm-text-tertiary); background: none; cursor: pointer;
|
|
62
|
+
border: var(--cm-border-1) solid transparent; border-radius: var(--cm-radius-xs);
|
|
63
|
+
}
|
|
64
|
+
:host([size='small']) button { padding: 0 var(--cm-space-8); font-size: var(--cm-font-size-13); }
|
|
65
|
+
button:hover:not(:disabled) { color: var(--cm-text-default); }
|
|
66
|
+
/* Selected: a white segment with the control outline (border-input, 3:1 or more) and dark text, so the choice
|
|
67
|
+
doesn't rest on colour alone. */
|
|
68
|
+
button[aria-checked='true'] { color: var(--cm-text-default); background: var(--cm-bg-surface); border-color: var(--cm-border-input); }
|
|
69
|
+
button:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 1px; }
|
|
70
|
+
button:disabled { color: var(--cm-text-secondary); cursor: not-allowed; }
|
|
71
|
+
button[aria-checked='true']:disabled { background: var(--cm-bg-input-filled); border-color: var(--cm-border-subtle); }
|
|
72
|
+
:host([disabled]) .options { background: var(--cm-bg-input-filled); }
|
|
73
|
+
slot { display: none; }
|
|
74
|
+
`,
|
|
75
|
+
];
|
|
76
|
+
define('cm-segmented-control', CmSegmentedControl);
|
|
@@ -74,6 +74,9 @@ export declare class CmSelect extends CmLocalizedElement {
|
|
|
74
74
|
type: BooleanConstructor;
|
|
75
75
|
attribute: string;
|
|
76
76
|
};
|
|
77
|
+
size: {
|
|
78
|
+
reflect: boolean;
|
|
79
|
+
};
|
|
77
80
|
_active: {
|
|
78
81
|
state: boolean;
|
|
79
82
|
};
|
|
@@ -106,6 +109,11 @@ export declare class CmSelect extends CmLocalizedElement {
|
|
|
106
109
|
* repeat across groups. The list itself always shows the bare label under its group heading. Since 1.3.
|
|
107
110
|
*/
|
|
108
111
|
showGroup: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* `small`: a 32px box with a 13px label, for toolbars, filter rows and filter panels. Default: a 36px box. On touch
|
|
114
|
+
* screens both are 44px. Since 1.5.
|
|
115
|
+
*/
|
|
116
|
+
size: 'default' | 'small';
|
|
109
117
|
_active: number;
|
|
110
118
|
_slotted: SelectOption[];
|
|
111
119
|
static styles: import("lit").CSSResult[];
|
|
@@ -14,6 +14,7 @@ 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
16
|
import { groupStyles, sortByGroup, groupRuns } from '../popover.js';
|
|
17
|
+
import { fieldStyles, optionStyles } from '../field.js';
|
|
17
18
|
import './icon.js';
|
|
18
19
|
const strings = defineStrings('select', {
|
|
19
20
|
/** Validation message when `required` and nothing is chosen. */
|
|
@@ -62,6 +63,11 @@ export class CmSelect extends CmLocalizedElement {
|
|
|
62
63
|
* repeat across groups. The list itself always shows the bare label under its group heading. Since 1.3.
|
|
63
64
|
*/
|
|
64
65
|
this.showGroup = false;
|
|
66
|
+
/**
|
|
67
|
+
* `small`: a 32px box with a 13px label, for toolbars, filter rows and filter panels. Default: a 36px box. On touch
|
|
68
|
+
* screens both are 44px. Since 1.5.
|
|
69
|
+
*/
|
|
70
|
+
this.size = 'default';
|
|
65
71
|
this._active = -1;
|
|
66
72
|
this._slotted = [];
|
|
67
73
|
_CmSelect_internals.set(this, this.attachInternals());
|
|
@@ -318,49 +324,43 @@ CmSelect.properties = {
|
|
|
318
324
|
disabled: { type: Boolean, reflect: true },
|
|
319
325
|
open: { type: Boolean, reflect: true },
|
|
320
326
|
showGroup: { type: Boolean, attribute: 'show-group' },
|
|
327
|
+
size: { reflect: true },
|
|
321
328
|
_active: { state: true },
|
|
322
329
|
_slotted: { state: true },
|
|
323
330
|
};
|
|
324
331
|
CmSelect.styles = [
|
|
325
332
|
base,
|
|
333
|
+
fieldStyles,
|
|
334
|
+
optionStyles,
|
|
326
335
|
groupStyles,
|
|
327
336
|
css `
|
|
328
337
|
:host { display: block; position: relative; }
|
|
329
|
-
.
|
|
330
|
-
.label { font-size: var(--cm-type-label-size); color: var(--cm-text-default); cursor: default; }
|
|
331
|
-
.req { color: var(--cm-text-critical); margin-inline-start: 2px; }
|
|
338
|
+
.label { cursor: default; }
|
|
332
339
|
.wrap { position: relative; }
|
|
333
340
|
.box {
|
|
334
|
-
display: flex; align-items: center; gap: var(--cm-space-
|
|
335
|
-
|
|
341
|
+
display: flex; align-items: center; gap: var(--cm-space-8); width: 100%; height: var(--_cm-field-h);
|
|
342
|
+
padding-block: 0; padding-inline: var(--_cm-field-pad) var(--cm-space-8);
|
|
343
|
+
font-size: var(--_cm-field-font); line-height: var(--cm-line-height-14); color: var(--cm-text-default); background: var(--cm-bg-surface); cursor: pointer;
|
|
336
344
|
border: var(--cm-border-1) solid var(--cm-border-input); border-radius: var(--cm-radius-sm); outline: none; user-select: none;
|
|
337
345
|
}
|
|
338
346
|
.box:focus-visible, :host([open]) .box { border-color: var(--cm-border-strong); box-shadow: 0 0 0 1px var(--cm-border-strong); }
|
|
339
347
|
.text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
340
348
|
.placeholder { color: var(--cm-text-tertiary); }
|
|
341
|
-
.chev { flex: none; color: var(--cm-icon-selected); transition: transform
|
|
349
|
+
.chev { flex: none; color: var(--cm-icon-selected); transition: transform var(--cm-duration-fast) var(--cm-easing-standard); }
|
|
342
350
|
:host([open]) .chev { transform: rotate(180deg); }
|
|
343
351
|
:host([error]:not([error=''])) .box { border-color: var(--cm-border-critical); }
|
|
344
|
-
:host([disabled]) .box { background: var(--cm-bg-input-filled); color: var(--cm-text-secondary); border-color: var(--cm-border-
|
|
352
|
+
:host([disabled]) .box { background: var(--cm-bg-input-filled); color: var(--cm-text-secondary); border-color: var(--cm-border-subtle); cursor: not-allowed; }
|
|
345
353
|
[role='listbox'] {
|
|
346
|
-
position: absolute; z-index: 20; top: calc(100% + var(--cm-space-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
border-radius: var(--cm-radius-md); box-shadow: var(--cm-shadow-100);
|
|
350
|
-
}
|
|
351
|
-
[role='option'] {
|
|
352
|
-
display: flex; align-items: center; min-height: 40px; padding: 6px var(--cm-space-20);
|
|
353
|
-
font-size: 16px; color: var(--cm-text-default); cursor: pointer;
|
|
354
|
+
position: absolute; z-index: 20; top: calc(100% + var(--cm-space-4)); inset-inline: 0; min-width: max-content;
|
|
355
|
+
background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-subtle);
|
|
356
|
+
border-radius: var(--cm-radius-md); box-shadow: var(--cm-shadow-md);
|
|
354
357
|
}
|
|
355
358
|
[role='option'].active { background: var(--cm-bg-hover); }
|
|
356
359
|
[role='option'][aria-selected='true'] { background: var(--cm-action-primary); color: var(--cm-action-primary-text); }
|
|
357
360
|
[role='option'][aria-selected='true'].active { background: var(--cm-action-primary-hover); }
|
|
358
361
|
[role='option'][aria-disabled='true'] { color: var(--cm-text-secondary); cursor: not-allowed; }
|
|
359
362
|
[role='group'] { display: block; }
|
|
360
|
-
.help, .error { margin: 0; font-size: 12px; color: var(--cm-text-tertiary); }
|
|
361
|
-
.error { color: var(--cm-text-critical); }
|
|
362
363
|
slot { display: none; }
|
|
363
|
-
@media (max-width: 640px) { [role='option'] { font-size: 14px; min-height: 30px; padding-inline: var(--cm-space-15); } }
|
|
364
364
|
@media (prefers-reduced-motion: reduce) { .chev { transition: none; } }
|
|
365
365
|
`,
|
|
366
366
|
];
|
|
@@ -112,7 +112,7 @@ export class CmSideNavigation extends CmLocalizedElement {
|
|
|
112
112
|
${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_tip).call(this, it, html `<button type="button" class="item parent ${hasCurrent(it) ? 'has-current' : ''}" part="item" data-index=${i}
|
|
113
113
|
aria-expanded=${open ? 'true' : 'false'} aria-controls=${sub} @click=${() => (rail ? __classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_openFromRail).call(this, i) : this.toggle(i))}>
|
|
114
114
|
${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_icon).call(this, it)}${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_text).call(this, it)}
|
|
115
|
-
${rail ? nothing : html `<cm-icon class="chev" name="chevron-down" size="
|
|
115
|
+
${rail ? nothing : html `<cm-icon class="chev" name="chevron-down" size="16"></cm-icon>`}
|
|
116
116
|
</button>`)}
|
|
117
117
|
<ul class="sub" id=${sub} ?hidden=${!open} aria-label=${it.label}>
|
|
118
118
|
${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_flatten).call(this, it.items).map(([s, d]) => html `<li>${__classPrivateFieldGet(this, _CmSideNavigation_instances, "m", _CmSideNavigation_link).call(this, { ...s, icon: undefined }, d ? 'deep' : '', { parent: i })}</li>`)}
|
|
@@ -188,7 +188,7 @@ _CmSideNavigation_seen = new WeakMap(), _CmSideNavigation_observer = new WeakMap
|
|
|
188
188
|
}, _CmSideNavigation_icon = function _CmSideNavigation_icon(it) {
|
|
189
189
|
if (it.icon)
|
|
190
190
|
return html `<cm-icon name=${it.icon} size="20"></cm-icon>`;
|
|
191
|
-
return this.collapsed ? html `<span class="initial" aria-hidden="true">${[...it.label.trim()][0] ?? ''}</span>` : nothing;
|
|
191
|
+
return this.collapsed ? html `<span class="initial" aria-hidden="true">${([...it.label.trim()][0] ?? '').toLocaleUpperCase(this.locale)}</span>` : nothing;
|
|
192
192
|
}, _CmSideNavigation_text = function _CmSideNavigation_text(it) {
|
|
193
193
|
if (!this.collapsed)
|
|
194
194
|
return html `<span class="label">${it.label}</span>${it.badge ? html `<span class="badge">${it.badge}</span>` : nothing}`;
|
|
@@ -225,43 +225,46 @@ CmSideNavigation.styles = [
|
|
|
225
225
|
css `
|
|
226
226
|
:host { display: block; width: var(--cm-side-navigation-width, 250px); }
|
|
227
227
|
nav {
|
|
228
|
-
background: var(--cm-bg-dashboard); color: var(--cm-text-on-dark-secondary); border-radius:
|
|
229
|
-
padding:
|
|
228
|
+
background: var(--cm-bg-dashboard); color: var(--cm-text-on-dark-secondary); border-radius: var(--cm-radius-lg);
|
|
229
|
+
padding: var(--cm-space-12) 0; font-size: var(--cm-font-size-14); line-height: var(--cm-line-height-14);
|
|
230
230
|
}
|
|
231
231
|
ul { list-style: none; margin: 0; padding: 0; }
|
|
232
232
|
.item {
|
|
233
|
-
display: flex; align-items: center; gap:
|
|
234
|
-
|
|
233
|
+
display: flex; align-items: center; gap: var(--cm-space-8); box-sizing: border-box; width: calc(100% - 2 * var(--cm-space-8));
|
|
234
|
+
min-height: var(--cm-control-height-md); margin: 0 var(--cm-space-8); padding-block: 0; padding-inline: var(--cm-space-12) var(--cm-space-8);
|
|
235
|
+
font: inherit; color: inherit; text-align: start; text-decoration: none; background: none; border: 0; border-radius: var(--cm-radius-sm); cursor: pointer;
|
|
235
236
|
}
|
|
236
237
|
.item:hover { color: var(--cm-text-on-dark); background: var(--cm-nav-active); }
|
|
237
238
|
.item:focus-visible { outline: 2px solid var(--cm-text-on-dark); outline-offset: -2px; color: var(--cm-text-on-dark); }
|
|
238
239
|
.item[aria-current='page'] { color: var(--cm-text-on-dark); font-weight: 600; }
|
|
239
240
|
.parent.has-current { color: var(--cm-text-on-dark); }
|
|
240
241
|
.label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
241
|
-
.chev { transition: transform
|
|
242
|
+
.chev { transition: transform var(--cm-duration-fast) var(--cm-easing-standard); }
|
|
242
243
|
[aria-expanded='true'] .chev { transform: rotate(180deg); }
|
|
243
244
|
.badge {
|
|
244
|
-
flex: none;
|
|
245
|
-
|
|
245
|
+
flex: none; box-sizing: border-box; min-inline-size: var(--cm-space-20); padding: 0 var(--cm-space-4); text-align: center;
|
|
246
|
+
border-radius: var(--cm-radius-full); font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12); font-weight: 500;
|
|
247
|
+
font-variant-numeric: tabular-nums; color: var(--cm-text-on-dark); background: var(--cm-nav-badge);
|
|
246
248
|
}
|
|
247
|
-
.sub { padding:
|
|
248
|
-
.sub .item { min-height:
|
|
249
|
-
.sub .item.deep { padding-inline-start:
|
|
249
|
+
.sub { padding: 0 0 var(--cm-space-4); }
|
|
250
|
+
.sub .item { min-height: var(--cm-control-height-sm); padding-inline-start: calc(var(--cm-space-12) + var(--cm-icon-size-md) + var(--cm-space-8)); }
|
|
251
|
+
.sub .item.deep { padding-inline-start: calc(var(--cm-space-12) + var(--cm-icon-size-md) + var(--cm-space-8) + var(--cm-space-16)); }
|
|
250
252
|
@media (prefers-reduced-motion: reduce) { .chev { transition: none; } }
|
|
253
|
+
/* Touch screens: rows at least 44px tall. */
|
|
254
|
+
@media (pointer: coarse) { .item, .sub .item, :host([collapsed]) .item { min-height: var(--cm-control-height-touch); } }
|
|
251
255
|
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
|
|
252
|
-
.toggle { margin-block-start:
|
|
253
|
-
.toggle .label { font-size: 14px; }
|
|
256
|
+
.toggle { margin-block-start: var(--cm-space-8); color: var(--cm-text-on-dark-secondary); }
|
|
254
257
|
/* Collapsed: an icon rail. */
|
|
255
258
|
:host([collapsed]) { width: var(--cm-side-navigation-collapsed-width, 72px); }
|
|
256
259
|
:host([collapsed]) cm-tooltip { display: block; color: inherit; }
|
|
257
|
-
:host([collapsed]) .item { position: relative; justify-content: center; min-height:
|
|
260
|
+
:host([collapsed]) .item { position: relative; justify-content: center; min-height: var(--cm-control-height-lg); padding: 0; }
|
|
258
261
|
:host([collapsed]) .item[aria-current='page'], :host([collapsed]) .parent.has-current { background: var(--cm-nav-active); }
|
|
259
|
-
.initial { display: grid; place-items: center; width:
|
|
262
|
+
.initial { display: grid; place-items: center; width: var(--cm-icon-size-md); height: var(--cm-icon-size-md); font-size: var(--cm-font-size-14); font-weight: 600; }
|
|
260
263
|
.dot {
|
|
261
264
|
position: absolute; inset-block-start: 6px; inset-inline-start: calc(50% + 4px); min-width: 8px; height: 8px; border-radius: var(--cm-radius-full);
|
|
262
265
|
background: var(--cm-nav-badge); box-shadow: 0 0 0 2px var(--cm-bg-dashboard);
|
|
263
266
|
}
|
|
264
|
-
.dot.count { inset-block-start:
|
|
267
|
+
.dot.count { inset-block-start: 2px; height: 16px; padding: 0 var(--cm-space-4); font-size: var(--cm-font-size-12); font-weight: 600; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums; color: var(--cm-text-on-dark); }
|
|
265
268
|
`,
|
|
266
269
|
];
|
|
267
270
|
define('cm-side-navigation', CmSideNavigation);
|
|
@@ -59,16 +59,17 @@ CmSidePanel.styles = [
|
|
|
59
59
|
}
|
|
60
60
|
:host([size='small']) dialog { --cm-side-panel-width: 380px; }
|
|
61
61
|
:host([size='large']) dialog { --cm-side-panel-width: 720px; }
|
|
62
|
-
.panel { height: 100%; box-shadow: var(--cm-shadow-
|
|
62
|
+
.panel { height: 100%; box-shadow: var(--cm-shadow-lg); }
|
|
63
63
|
@media (prefers-reduced-motion: no-preference) {
|
|
64
|
-
dialog[open] .panel { animation: cm-side-in
|
|
64
|
+
dialog[open] .panel { animation: cm-side-in var(--cm-duration-base) var(--cm-easing-standard); }
|
|
65
65
|
}
|
|
66
66
|
/* Slides in from the end edge: from the right, or from the left in right-to-left pages. */
|
|
67
67
|
dialog:dir(rtl) { --_cm-side-from: -24px; }
|
|
68
68
|
@keyframes cm-side-in { from { transform: translateX(var(--_cm-side-from, 24px)); opacity: 0; } to { transform: none; opacity: 1; } }
|
|
69
69
|
@media (max-width: 599px) {
|
|
70
70
|
dialog { inset: 16px; width: auto; height: auto; }
|
|
71
|
-
.panel { border-radius: var(--cm-radius-
|
|
71
|
+
.panel { border-radius: var(--cm-radius-lg); }
|
|
72
|
+
|
|
72
73
|
}
|
|
73
74
|
`,
|
|
74
75
|
];
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
2
|
+
declare const strings: {
|
|
3
|
+
/** Name of the Draw / Type tab list when the field has no label. */
|
|
4
|
+
modes: string;
|
|
5
|
+
/** The two tabs. */
|
|
6
|
+
draw: string;
|
|
7
|
+
type: string;
|
|
8
|
+
/** Accessible name of the drawing area, and the same once something is drawn. */
|
|
9
|
+
pad: string;
|
|
10
|
+
padSigned: string;
|
|
11
|
+
/** Read with the drawing area: how to draw, and the keyboard alternative. */
|
|
12
|
+
instructions: string;
|
|
13
|
+
/** Hint above the line while nothing is drawn. */
|
|
14
|
+
signHere: string;
|
|
15
|
+
/** Accessible name and placeholder of the box in Type mode. */
|
|
16
|
+
typeLabel: string;
|
|
17
|
+
typePlaceholder: string;
|
|
18
|
+
/** Undo and Clear buttons: visible text and accessible names. */
|
|
19
|
+
undo: string;
|
|
20
|
+
undoLabel: string;
|
|
21
|
+
clear: string;
|
|
22
|
+
clearLabel: string;
|
|
23
|
+
/** Announced after Clear and Undo. */
|
|
24
|
+
cleared: string;
|
|
25
|
+
undone: string;
|
|
26
|
+
/** Validation message when `required` and nothing is signed. */
|
|
27
|
+
required: string;
|
|
28
|
+
};
|
|
29
|
+
declare module '../localize.js' {
|
|
30
|
+
interface CmStrings {
|
|
31
|
+
signatureField: typeof strings;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Signature field: sign by drawing with a mouse, finger or pen, or by typing a name that is shown in a handwriting
|
|
36
|
+
* font. Gives a PNG of the signature, cropped to the ink, as a data URL (`value`, `toDataURL()`) or a Blob
|
|
37
|
+
* (`toBlob()`). Participates in native forms: submits the data URL under `name`; `required` blocks submission
|
|
38
|
+
* until something is signed. For e-sign screens ("Sign now") and signing pages.
|
|
39
|
+
*
|
|
40
|
+
* Load `@commmerce/tokens/fonts.css` (the hosted build's fonts.css) for the typed signature's font, Dancing Script;
|
|
41
|
+
* without it, typed signatures use the system's cursive font.
|
|
42
|
+
* @element cm-signature-field
|
|
43
|
+
* @fires cm-change - After a stroke is finished, Undo, Clear, a switch between Draw and Type, or typing stops for 400ms. `detail`: `{ value, empty, mode }`. A plain `change` event (no detail) follows it, for code that treats every form field alike.
|
|
44
|
+
* @csspart label - The label.
|
|
45
|
+
* @csspart tabs - The Draw / Type tab list.
|
|
46
|
+
* @csspart pad - The signing area (both modes).
|
|
47
|
+
* @csspart canvas - The drawing canvas.
|
|
48
|
+
* @csspart input - The text box in Type mode.
|
|
49
|
+
* @csspart undo - The Undo button (Draw mode).
|
|
50
|
+
* @csspart clear - The Clear button.
|
|
51
|
+
* @cssprop --cm-signature-font - Font of typed signatures. Default: Dancing Script, then cursive system fonts.
|
|
52
|
+
*/
|
|
53
|
+
export declare class CmSignatureField extends CmLocalizedElement {
|
|
54
|
+
#private;
|
|
55
|
+
static formAssociated: boolean;
|
|
56
|
+
static shadowRootOptions: {
|
|
57
|
+
delegatesFocus: boolean;
|
|
58
|
+
mode: ShadowRootMode;
|
|
59
|
+
serializable?: boolean;
|
|
60
|
+
slotAssignment?: SlotAssignmentMode;
|
|
61
|
+
};
|
|
62
|
+
static properties: {
|
|
63
|
+
label: {};
|
|
64
|
+
hint: {};
|
|
65
|
+
helpText: {
|
|
66
|
+
attribute: string;
|
|
67
|
+
};
|
|
68
|
+
error: {
|
|
69
|
+
reflect: boolean;
|
|
70
|
+
};
|
|
71
|
+
name: {
|
|
72
|
+
reflect: boolean;
|
|
73
|
+
};
|
|
74
|
+
value: {};
|
|
75
|
+
mode: {
|
|
76
|
+
reflect: boolean;
|
|
77
|
+
};
|
|
78
|
+
typedName: {
|
|
79
|
+
attribute: string;
|
|
80
|
+
};
|
|
81
|
+
required: {
|
|
82
|
+
type: BooleanConstructor;
|
|
83
|
+
reflect: boolean;
|
|
84
|
+
};
|
|
85
|
+
disabled: {
|
|
86
|
+
type: BooleanConstructor;
|
|
87
|
+
reflect: boolean;
|
|
88
|
+
};
|
|
89
|
+
_announce: {
|
|
90
|
+
state: boolean;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/** Visible label above the field, e.g. "Your signature". Without one, give the element an `aria-label`. */
|
|
94
|
+
label: string;
|
|
95
|
+
/** Lowercase bracketed note after the label. */
|
|
96
|
+
hint: string;
|
|
97
|
+
/** One sentence under the field in text-tertiary, e.g. what the signer agrees to. */
|
|
98
|
+
helpText: string;
|
|
99
|
+
/** Error message from your own validation; turns the pad's border critical and is announced. */
|
|
100
|
+
error: string;
|
|
101
|
+
/** Form field name. */
|
|
102
|
+
name: string;
|
|
103
|
+
/**
|
|
104
|
+
* The signature as a PNG data URL (`data:image/png;base64,…`), cropped to the ink, or empty when nothing is
|
|
105
|
+
* signed. Updated after every stroke and keystroke. Set it to a PNG or SVG data URL (or any image URL the page
|
|
106
|
+
* may read) to show a saved signature in Draw mode; set it to `''` to clear both modes.
|
|
107
|
+
*/
|
|
108
|
+
value: string;
|
|
109
|
+
/** The selected tab: `draw` (pointer, touch, pen) or `type` (keyboard). Each keeps its own signature. */
|
|
110
|
+
mode: 'draw' | 'type';
|
|
111
|
+
/** The name typed in Type mode. Set it to prefill the box with the signer's name. */
|
|
112
|
+
typedName: string;
|
|
113
|
+
/** Shows a red asterisk and blocks form submission until something is signed. */
|
|
114
|
+
required: boolean;
|
|
115
|
+
/** Blocks interaction. Also set by a disabled `<fieldset>`. */
|
|
116
|
+
disabled: boolean;
|
|
117
|
+
/** @internal Text in the polite status region. */
|
|
118
|
+
_announce: string;
|
|
119
|
+
static styles: import("lit").CSSResult[];
|
|
120
|
+
connectedCallback(): void;
|
|
121
|
+
disconnectedCallback(): void;
|
|
122
|
+
get form(): HTMLFormElement | null;
|
|
123
|
+
get validity(): ValidityState;
|
|
124
|
+
get validationMessage(): string;
|
|
125
|
+
checkValidity(): boolean;
|
|
126
|
+
reportValidity(): boolean;
|
|
127
|
+
formResetCallback(): void;
|
|
128
|
+
formDisabledCallback(d: boolean): void;
|
|
129
|
+
formStateRestoreCallback(state: string): void;
|
|
130
|
+
/** True when the current mode has nothing signed: no strokes (or saved image) in Draw, no text in Type. */
|
|
131
|
+
get empty(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The signature as a PNG data URL: black ink on transparent at 2x the pad's size, cropped to the ink with 8px
|
|
134
|
+
* (16 image pixels) around it. Empty string when nothing is signed.
|
|
135
|
+
*/
|
|
136
|
+
toDataURL(): string;
|
|
137
|
+
/** The same PNG as `toDataURL()` as a Blob, for uploading. `null` when nothing is signed. */
|
|
138
|
+
toBlob(): Promise<Blob | null>;
|
|
139
|
+
/** Removes the current mode's signature (Draw: every stroke and any saved image; Type: the text). */
|
|
140
|
+
clear(): void;
|
|
141
|
+
/** Removes the last stroke in Draw mode (then the saved image, if one was loaded). */
|
|
142
|
+
undo(): void;
|
|
143
|
+
willUpdate(changed: Map<string, unknown>): void;
|
|
144
|
+
firstUpdated(): void;
|
|
145
|
+
updated(changed: Map<string, unknown>): void;
|
|
146
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
147
|
+
}
|
|
148
|
+
declare global {
|
|
149
|
+
interface HTMLElementTagNameMap {
|
|
150
|
+
'cm-signature-field': CmSignatureField;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export {};
|