@commmerce/ui 1.1.1 → 1.2.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 +677 -450
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +25 -0
- package/dist/components/card.d.ts +5 -0
- package/dist/components/card.js +44 -5
- 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/metric.d.ts +97 -0
- package/dist/components/metric.js +168 -0
- 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/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 +5102 -3386
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/package.json +3 -3
|
@@ -16,6 +16,7 @@ declare module '../localize.js' {
|
|
|
16
16
|
/**
|
|
17
17
|
* Black primary or outlined secondary action. With `icon-only` it is a square button that shows just an icon
|
|
18
18
|
* (bell, refresh, search, row actions) and is named by `label`. `count` adds a small counter ("3", "99+").
|
|
19
|
+
* `tone` colours a button by the outcome it records (`success`, `critical`); the label still carries the meaning.
|
|
19
20
|
* @element cm-button
|
|
20
21
|
* @slot - Label. Visually hidden when `icon-only` (it still names the button if `label` is empty).
|
|
21
22
|
* @slot icon - Optional leading icon. Overrides the `icon` attribute.
|
|
@@ -54,6 +55,9 @@ export declare class CmButton extends CmLocalizedElement {
|
|
|
54
55
|
count: {
|
|
55
56
|
type: NumberConstructor;
|
|
56
57
|
};
|
|
58
|
+
tone: {
|
|
59
|
+
reflect: boolean;
|
|
60
|
+
};
|
|
57
61
|
};
|
|
58
62
|
/** `primary` = black fill (one per group); `secondary` = light fill, black outline. */
|
|
59
63
|
variant: 'primary' | 'secondary';
|
|
@@ -77,6 +81,12 @@ export declare class CmButton extends CmLocalizedElement {
|
|
|
77
81
|
label: string;
|
|
78
82
|
/** Small counter on the button, e.g. unread notifications. Hidden at 0; over 99 shows "99+". Screen readers hear the exact number ("Notifications, 3 unread"). */
|
|
79
83
|
count: number;
|
|
84
|
+
/**
|
|
85
|
+
* Colours the button by meaning: `critical` (red: delete, "Not interested") or `success` (green: "Sale closed").
|
|
86
|
+
* Secondary: tone text, icon and outline on a white fill. Primary: filled in the tone. Leave unset for the
|
|
87
|
+
* standard black and white. Colour is never the only signal: the label must say what happens. Since 1.2.
|
|
88
|
+
*/
|
|
89
|
+
tone?: 'critical' | 'success';
|
|
80
90
|
static styles: import("lit").CSSResult[];
|
|
81
91
|
constructor();
|
|
82
92
|
updated(): void;
|
|
@@ -27,6 +27,7 @@ const strings = defineStrings('button', {
|
|
|
27
27
|
/**
|
|
28
28
|
* Black primary or outlined secondary action. With `icon-only` it is a square button that shows just an icon
|
|
29
29
|
* (bell, refresh, search, row actions) and is named by `label`. `count` adds a small counter ("3", "99+").
|
|
30
|
+
* `tone` colours a button by the outcome it records (`success`, `critical`); the label still carries the meaning.
|
|
30
31
|
* @element cm-button
|
|
31
32
|
* @slot - Label. Visually hidden when `icon-only` (it still names the button if `label` is empty).
|
|
32
33
|
* @slot icon - Optional leading icon. Overrides the `icon` attribute.
|
|
@@ -115,6 +116,7 @@ CmButton.properties = {
|
|
|
115
116
|
icon: {},
|
|
116
117
|
label: {},
|
|
117
118
|
count: { type: Number },
|
|
119
|
+
tone: { reflect: true },
|
|
118
120
|
};
|
|
119
121
|
CmButton.styles = [
|
|
120
122
|
base,
|
|
@@ -138,6 +140,29 @@ CmButton.styles = [
|
|
|
138
140
|
:host([disabled]) .btn, :host([loading]) .btn {
|
|
139
141
|
background: var(--cm-action-disabled); border-color: var(--cm-action-disabled); color: var(--cm-action-disabled-text); cursor: not-allowed;
|
|
140
142
|
}
|
|
143
|
+
/* Tones (1.2). Secondary sits on bg-surface, not bg-hover: text-critical on bg-hover is under 4.5:1 in dark.
|
|
144
|
+
Success has no border token: its outline is text-success (4.8:1 or more on every surface; icon-success is 2.9:1 on bg-page).
|
|
145
|
+
Primary fills with the tone's text colour and takes action-primary-text, like the black primary (5.1:1 or more).
|
|
146
|
+
Hover darkens it towards text-default, which only raises the label's contrast. Pairs: packages/tokens/scripts/contrast.mjs. */
|
|
147
|
+
:host([tone='critical']:not([variant='primary']):not([disabled]):not([loading])) .btn {
|
|
148
|
+
background: var(--cm-bg-surface); color: var(--cm-text-critical); border-color: var(--cm-border-critical);
|
|
149
|
+
}
|
|
150
|
+
:host([tone='critical']:not([variant='primary']):not([disabled]):not([loading])) .btn:hover { background: var(--cm-bg-critical); }
|
|
151
|
+
:host([tone='success']:not([variant='primary']):not([disabled]):not([loading])) .btn {
|
|
152
|
+
background: var(--cm-bg-surface); color: var(--cm-text-success); border-color: var(--cm-text-success);
|
|
153
|
+
}
|
|
154
|
+
:host([tone='success']:not([variant='primary']):not([disabled]):not([loading])) .btn:hover {
|
|
155
|
+
background: linear-gradient(var(--cm-bg-success-soft), var(--cm-bg-success-soft)) var(--cm-bg-surface);
|
|
156
|
+
}
|
|
157
|
+
:host([tone='critical'][variant='primary']:not([disabled]):not([loading])) .btn { --_tone: var(--cm-text-critical); }
|
|
158
|
+
:host([tone='success'][variant='primary']:not([disabled]):not([loading])) .btn { --_tone: var(--cm-text-success); }
|
|
159
|
+
:host([tone='critical'][variant='primary']:not([disabled]):not([loading])) .btn, :host([tone='success'][variant='primary']:not([disabled]):not([loading])) .btn {
|
|
160
|
+
background: var(--_tone); border-color: var(--_tone); color: var(--cm-action-primary-text);
|
|
161
|
+
}
|
|
162
|
+
:host([tone='critical'][variant='primary']:not([disabled]):not([loading])) .btn:hover, :host([tone='success'][variant='primary']:not([disabled]):not([loading])) .btn:hover {
|
|
163
|
+
background: color-mix(in srgb, var(--_tone) 80%, var(--cm-text-default));
|
|
164
|
+
border-color: color-mix(in srgb, var(--_tone) 80%, var(--cm-text-default));
|
|
165
|
+
}
|
|
141
166
|
.btn:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
142
167
|
.spinner {
|
|
143
168
|
width: 1em; height: 1em; border-radius: 50%;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
/**
|
|
3
3
|
* White section card with optional title, description and header actions.
|
|
4
|
+
*
|
|
5
|
+
* On narrow cards the header wraps instead of squeezing the heading: the title adornment moves under the heading
|
|
6
|
+
* when both don't fit on one line, and the actions move under the title when the title would be narrower than
|
|
7
|
+
* about 12 characters. Wide cards keep everything on one row.
|
|
4
8
|
* @element cm-card
|
|
5
9
|
* @slot - Body.
|
|
6
10
|
* @slot actions - Header actions (buttons, links), right-aligned.
|
|
7
11
|
* @slot title-adornment - Badge or icon next to the title.
|
|
8
12
|
*/
|
|
9
13
|
export declare class CmCard extends LitElement {
|
|
14
|
+
#private;
|
|
10
15
|
static properties: {
|
|
11
16
|
heading: {};
|
|
12
17
|
description: {};
|
package/dist/components/card.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
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 _CmCard_instances, _CmCard_adorned, _CmCard_onAdornment;
|
|
1
13
|
import { LitElement, html, css, nothing } from 'lit';
|
|
2
14
|
import { base, define } from '../base.js';
|
|
3
15
|
/**
|
|
4
16
|
* White section card with optional title, description and header actions.
|
|
17
|
+
*
|
|
18
|
+
* On narrow cards the header wraps instead of squeezing the heading: the title adornment moves under the heading
|
|
19
|
+
* when both don't fit on one line, and the actions move under the title when the title would be narrower than
|
|
20
|
+
* about 12 characters. Wide cards keep everything on one row.
|
|
5
21
|
* @element cm-card
|
|
6
22
|
* @slot - Body.
|
|
7
23
|
* @slot actions - Header actions (buttons, links), right-aligned.
|
|
@@ -10,6 +26,7 @@ import { base, define } from '../base.js';
|
|
|
10
26
|
export class CmCard extends LitElement {
|
|
11
27
|
constructor() {
|
|
12
28
|
super(...arguments);
|
|
29
|
+
_CmCard_instances.add(this);
|
|
13
30
|
/** Card title, rendered as a heading at `heading-level`. */
|
|
14
31
|
this.heading = '';
|
|
15
32
|
/** One sentence under the title in text-tertiary. */
|
|
@@ -18,21 +35,29 @@ export class CmCard extends LitElement {
|
|
|
18
35
|
this.flush = false;
|
|
19
36
|
/** Heading level for the title, so pages keep a correct outline. Default 2. */
|
|
20
37
|
this.headingLevel = 2;
|
|
38
|
+
_CmCard_adorned.set(this, false);
|
|
21
39
|
}
|
|
22
40
|
render() {
|
|
23
41
|
const level = Math.min(6, Math.max(2, this.headingLevel || 2));
|
|
24
42
|
const title = this.heading
|
|
25
|
-
? html `<div role="heading" aria-level=${level} class="title" part="title">${this.heading}
|
|
43
|
+
? html `<div role="heading" aria-level=${level} class="title" part="title"><span class="text">${this.heading}</span><span class="adornment" ?hidden=${!__classPrivateFieldGet(this, _CmCard_adorned, "f")}><slot name="title-adornment" @slotchange=${__classPrivateFieldGet(this, _CmCard_instances, "m", _CmCard_onAdornment)}></slot></span></div>`
|
|
26
44
|
: nothing;
|
|
27
45
|
return html `<section part="card" aria-label=${this.heading || nothing}>
|
|
28
46
|
${this.heading || this.description
|
|
29
|
-
? html `<header><div>${title}${this.description ? html `<p class="desc">${this.description}</p>` : nothing}</div>
|
|
47
|
+
? html `<header><div class="main">${this.heading ? html `<span class="strut" aria-hidden="true">${this.heading}</span>` : nothing}${title}${this.description ? html `<p class="desc">${this.description}</p>` : nothing}</div>
|
|
30
48
|
<div class="actions"><slot name="actions"></slot></div></header>`
|
|
31
49
|
: nothing}
|
|
32
50
|
<slot></slot>
|
|
33
51
|
</section>`;
|
|
34
52
|
}
|
|
35
53
|
}
|
|
54
|
+
_CmCard_adorned = new WeakMap(), _CmCard_instances = new WeakSet(), _CmCard_onAdornment = function _CmCard_onAdornment(e) {
|
|
55
|
+
const adorned = e.target.assignedNodes().some((n) => n.nodeType === Node.ELEMENT_NODE || n.textContent?.trim());
|
|
56
|
+
if (adorned !== __classPrivateFieldGet(this, _CmCard_adorned, "f")) {
|
|
57
|
+
__classPrivateFieldSet(this, _CmCard_adorned, adorned, "f");
|
|
58
|
+
this.requestUpdate();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
36
61
|
CmCard.properties = {
|
|
37
62
|
heading: {},
|
|
38
63
|
description: {},
|
|
@@ -48,11 +73,25 @@ CmCard.styles = [
|
|
|
48
73
|
border-radius: var(--cm-radius-md); padding: var(--cm-space-20);
|
|
49
74
|
}
|
|
50
75
|
:host([flush]) section { padding: 0; }
|
|
51
|
-
|
|
76
|
+
/* Wraps only on narrow cards. .main grows from a 0 basis (wide cards look exactly as before: its content stays
|
|
77
|
+
at the start), and its minimum width comes from .strut: the heading on one line, capped at 12 characters. So
|
|
78
|
+
the actions move under the title only when the heading would get less than that. */
|
|
79
|
+
header {
|
|
80
|
+
display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
|
|
81
|
+
gap: var(--cm-space-10) var(--cm-space-20); margin-bottom: var(--cm-space-20);
|
|
82
|
+
}
|
|
52
83
|
:host([flush]) header { padding: var(--cm-space-20) var(--cm-space-20) 0; }
|
|
53
|
-
.
|
|
84
|
+
.main { flex: 1 1 0%; max-inline-size: 100%; }
|
|
85
|
+
.strut {
|
|
86
|
+
display: block; block-size: 0; overflow: hidden; visibility: hidden; white-space: nowrap;
|
|
87
|
+
max-inline-size: 12ch; font-size: var(--cm-type-heading-sm-size); font-weight: 600;
|
|
88
|
+
}
|
|
89
|
+
.title { margin: 0; font-size: var(--cm-type-heading-sm-size); font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-10); }
|
|
90
|
+
/* Flex-wrap moves the badges under the heading before the heading itself would wrap. */
|
|
91
|
+
.adornment { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-10); }
|
|
92
|
+
.adornment[hidden] { display: none; }
|
|
54
93
|
.desc { margin: 6px 0 0; font-size: 16px; color: var(--cm-text-tertiary); }
|
|
55
|
-
.actions { display: flex; gap: var(--cm-space-20); align-items: center; }
|
|
94
|
+
.actions { display: flex; flex-wrap: wrap; gap: var(--cm-space-20); align-items: center; }
|
|
56
95
|
`,
|
|
57
96
|
];
|
|
58
97
|
define('cm-card', CmCard);
|
|
@@ -28,6 +28,22 @@ declare const strings: {
|
|
|
28
28
|
rangeOverflow: string;
|
|
29
29
|
/** Validation: a date in `disabled-dates` or refused by `isDateDisabled`. */
|
|
30
30
|
unavailable: string;
|
|
31
|
+
/** With `time`: accessible name of the time box. */
|
|
32
|
+
time: string;
|
|
33
|
+
/** With `time`: accessible name of the time box when the field has a label. */
|
|
34
|
+
timeFor: string;
|
|
35
|
+
/** With `time`: letters for hours and minutes in the time placeholder, e.g. hh:mm am. */
|
|
36
|
+
patternHour: string;
|
|
37
|
+
patternMinute: string;
|
|
38
|
+
/** With `time`, validation: the text in the time box is not a time. `{pattern}` is e.g. hh:mm am. */
|
|
39
|
+
badTime: string;
|
|
40
|
+
/** With `time`, validation: a date is set but no time. */
|
|
41
|
+
timeMissing: string;
|
|
42
|
+
/** With `time`, validation: a time off the `step`. `{count}` is the step in minutes. */
|
|
43
|
+
stepMismatch: {
|
|
44
|
+
one: string;
|
|
45
|
+
other: string;
|
|
46
|
+
};
|
|
31
47
|
};
|
|
32
48
|
declare module '../localize.js' {
|
|
33
49
|
interface CmStrings {
|
|
@@ -35,7 +51,8 @@ declare module '../localize.js' {
|
|
|
35
51
|
}
|
|
36
52
|
}
|
|
37
53
|
/**
|
|
38
|
-
* Date field: type a date or pick one from a calendar.
|
|
54
|
+
* Date field: type a date or pick one from a calendar. With `time`, a time box sits next to it and the value is a
|
|
55
|
+
* local date and time, `yyyy-mm-ddThh:mm`. Follows the WAI-ARIA APG "date picker dialog" pattern:
|
|
39
56
|
* the calendar button opens a month grid where arrows move by day and week, Page Up/Down by month, Shift+Page Up/Down
|
|
40
57
|
* by year, Home/End to the start and end of the week, Enter picks and Escape closes. Month and weekday names come
|
|
41
58
|
* from `Intl` in the page's language. Participates in native forms with an ISO `yyyy-mm-dd` value.
|
|
@@ -45,6 +62,8 @@ declare module '../localize.js' {
|
|
|
45
62
|
* @csspart box - The bordered box around the text input and calendar button.
|
|
46
63
|
* @csspart input - The text input.
|
|
47
64
|
* @csspart calendar - The month grid.
|
|
65
|
+
* @csspart time-box - With `time`: the bordered box around the time input.
|
|
66
|
+
* @csspart time-input - With `time`: the time input.
|
|
48
67
|
*/
|
|
49
68
|
export declare class CmDatePicker extends CmLocalizedElement {
|
|
50
69
|
#private;
|
|
@@ -102,6 +121,16 @@ export declare class CmDatePicker extends CmLocalizedElement {
|
|
|
102
121
|
size: {
|
|
103
122
|
reflect: boolean;
|
|
104
123
|
};
|
|
124
|
+
time: {
|
|
125
|
+
type: BooleanConstructor;
|
|
126
|
+
reflect: boolean;
|
|
127
|
+
};
|
|
128
|
+
step: {
|
|
129
|
+
type: NumberConstructor;
|
|
130
|
+
};
|
|
131
|
+
hourCycle: {
|
|
132
|
+
attribute: string;
|
|
133
|
+
};
|
|
105
134
|
_text: {
|
|
106
135
|
state: boolean;
|
|
107
136
|
};
|
|
@@ -117,11 +146,17 @@ export declare class CmDatePicker extends CmLocalizedElement {
|
|
|
117
146
|
error: string;
|
|
118
147
|
/** Form field name. */
|
|
119
148
|
name: string;
|
|
120
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* The date as ISO `yyyy-mm-dd`; empty when no date is set. With `time`: the local date and time
|
|
151
|
+
* `yyyy-mm-ddThh:mm` (no time zone or offset), empty until both a date and a time are set.
|
|
152
|
+
*/
|
|
121
153
|
value: string;
|
|
122
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Earliest date that can be chosen, ISO `yyyy-mm-dd`. With `time` it may include a time, `yyyy-mm-ddThh:mm`,
|
|
156
|
+
* or be `now` (the current minute, checked again whenever the field is validated).
|
|
157
|
+
*/
|
|
123
158
|
min: string;
|
|
124
|
-
/** Latest date that can be chosen, ISO `yyyy-mm-dd`. */
|
|
159
|
+
/** Latest date that can be chosen, ISO `yyyy-mm-dd`. With `time`, also `yyyy-mm-ddThh:mm` or `now`. */
|
|
125
160
|
max: string;
|
|
126
161
|
/** Shown in the empty box. Defaults to the locale's pattern, e.g. "dd/mm/yyyy". */
|
|
127
162
|
placeholder: string;
|
|
@@ -146,6 +181,15 @@ export declare class CmDatePicker extends CmLocalizedElement {
|
|
|
146
181
|
open: boolean;
|
|
147
182
|
/** `small`: 12px label, 14px value (filter panels). */
|
|
148
183
|
size: 'default' | 'small';
|
|
184
|
+
/**
|
|
185
|
+
* Adds a time box next to the date box, so the field holds a date and a time. Times are typed (`3:30 pm`, `15:30`)
|
|
186
|
+
* and shown in the locale's clock (12-hour with am/pm for `en-IN`); Up and Down change the time by `step`.
|
|
187
|
+
*/
|
|
188
|
+
time: boolean;
|
|
189
|
+
/** With `time`: minutes between allowed times, counted from midnight (15 allows :00, :15, :30, :45). Up and Down in the time box move by it. Default 1. */
|
|
190
|
+
step: number;
|
|
191
|
+
/** With `time`: `h12` or `h23` to force a 12- or 24-hour clock. Empty: the locale's clock. */
|
|
192
|
+
hourCycle: '' | 'h12' | 'h23';
|
|
149
193
|
_text: string;
|
|
150
194
|
_focus: Date;
|
|
151
195
|
static styles: import("lit").CSSResult[];
|
|
@@ -154,7 +198,7 @@ export declare class CmDatePicker extends CmLocalizedElement {
|
|
|
154
198
|
get form(): HTMLFormElement | null;
|
|
155
199
|
get validity(): ValidityState;
|
|
156
200
|
get validationMessage(): string;
|
|
157
|
-
/** The value as a local Date, or null. */
|
|
201
|
+
/** The value as a local Date (with `time`, at that time), or null. */
|
|
158
202
|
get valueAsDate(): Date | null;
|
|
159
203
|
checkValidity(): boolean;
|
|
160
204
|
reportValidity(): boolean;
|