@commmerce/ui 1.9.2 → 1.10.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/cdn.js +463 -449
- package/dist/components/account-menu.d.ts +1 -1
- package/dist/components/account-menu.js +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/sparkline.d.ts +68 -0
- package/dist/components/sparkline.js +134 -0
- package/dist/custom-elements.json +267 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -3
|
@@ -18,7 +18,7 @@ declare module '../localize.js' {
|
|
|
18
18
|
* to the avatar's end edge. Put it in `cm-header-bar`'s `account` slot, so it is always last in the bar.
|
|
19
19
|
* For Commmerce products only, not for apps.
|
|
20
20
|
* @element cm-account-menu
|
|
21
|
-
* @slot - `cm-menu-item` elements (
|
|
21
|
+
* @slot - `cm-menu-item` elements, with `<hr>` between groups (as in `cm-action-menu`).
|
|
22
22
|
* @slot org-logo - The business's logo (an `<img>`, 40px round). Without it, a store icon on the brand tone is shown.
|
|
23
23
|
* @fires cm-select - When a choice is picked (as on `cm-action-menu`).
|
|
24
24
|
* @csspart trigger - The avatar button.
|
|
@@ -16,7 +16,7 @@ const strings = defineStrings('accountMenu', {
|
|
|
16
16
|
* to the avatar's end edge. Put it in `cm-header-bar`'s `account` slot, so it is always last in the bar.
|
|
17
17
|
* For Commmerce products only, not for apps.
|
|
18
18
|
* @element cm-account-menu
|
|
19
|
-
* @slot - `cm-menu-item` elements (
|
|
19
|
+
* @slot - `cm-menu-item` elements, with `<hr>` between groups (as in `cm-action-menu`).
|
|
20
20
|
* @slot org-logo - The business's logo (an `<img>`, 40px round). Without it, a store icon on the brand tone is shown.
|
|
21
21
|
* @fires cm-select - When a choice is picked (as on `cm-action-menu`).
|
|
22
22
|
* @csspart trigger - The avatar button.
|
|
@@ -126,7 +126,7 @@ CmButton.styles = [
|
|
|
126
126
|
css `
|
|
127
127
|
:host { display: inline-flex; vertical-align: middle; max-width: 100%; }
|
|
128
128
|
/* A label longer than the room (a button in a narrow card) ends with an ellipsis instead of spilling out (1.8.1). */
|
|
129
|
-
.text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
129
|
+
.text { min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: var(--cm-line-height-14, 20px); } /* a full line box, so overflow: hidden doesn't cut g, p and y (1.9.3) */
|
|
130
130
|
.btn {
|
|
131
131
|
position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--cm-space-8);
|
|
132
132
|
width: 100%; min-width: 0; font: inherit; font-weight: 500; line-height: 1; white-space: nowrap;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
2
|
+
declare const strings: {
|
|
3
|
+
/** Accessible summary. {label} names the series, {total} its sum, {peak} the largest value, {latest} the last one. */
|
|
4
|
+
summary: string;
|
|
5
|
+
/** Accessible summary when `labels` names the points: {when} is the label of the peak. */
|
|
6
|
+
summaryAt: string;
|
|
7
|
+
/** Accessible summary with no values. */
|
|
8
|
+
empty: string;
|
|
9
|
+
};
|
|
10
|
+
declare module '../localize.js' {
|
|
11
|
+
interface CmStrings {
|
|
12
|
+
sparkline: typeof strings;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export type SparklineType = 'bars' | 'line';
|
|
16
|
+
export type SparklineTone = 'neutral' | 'information' | 'success';
|
|
17
|
+
/**
|
|
18
|
+
* A word-sized chart of one series over time, for a summary card: "Visits, last 30 days" beside the facts it sums
|
|
19
|
+
* up (since 1.10.0). Bars (the default) for counts per day or week, a line for a level that moves (a balance, a
|
|
20
|
+
* score). It has no axes or numbers of its own: put the figure it explains next to it, for example in `cm-metric`
|
|
21
|
+
* or a `cm-info-item`. Time runs left to right in every language. Screen readers hear one sentence: the total, the
|
|
22
|
+
* peak (and when, with `labels`) and the latest value; with `labels`, pointing at a bar shows its label and value.
|
|
23
|
+
* @element cm-sparkline
|
|
24
|
+
* @cssprop --cm-sparkline-height - Height (default 32px). The width follows the container (default 100%, at most `--cm-sparkline-width`).
|
|
25
|
+
* @cssprop --cm-sparkline-width - Largest width (default none).
|
|
26
|
+
* @csspart chart - The `<svg>`.
|
|
27
|
+
*/
|
|
28
|
+
export declare class CmSparkline extends CmLocalizedElement {
|
|
29
|
+
static properties: {
|
|
30
|
+
values: {
|
|
31
|
+
converter: {
|
|
32
|
+
fromAttribute: (v: string | null) => number[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
labels: {
|
|
36
|
+
converter: {
|
|
37
|
+
fromAttribute: (v: string | null) => string[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
label: {};
|
|
41
|
+
type: {
|
|
42
|
+
reflect: boolean;
|
|
43
|
+
};
|
|
44
|
+
tone: {
|
|
45
|
+
reflect: boolean;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/** The points, oldest first. In HTML: `values="[0,2,1,4]"` or `values="0,2,1,4"`. */
|
|
49
|
+
values: number[];
|
|
50
|
+
/** Optional name of each point, oldest first ("12 Nov"), for the summary and the hover text. */
|
|
51
|
+
labels: string[];
|
|
52
|
+
/** What the series is, e.g. "Visits, last 30 days". Used in the accessible summary. */
|
|
53
|
+
label: string;
|
|
54
|
+
/** `bars` (default) for counts; `line` for a level. */
|
|
55
|
+
type: SparklineType;
|
|
56
|
+
/** Colour: `neutral` (default, the text colour at 60%), `information` or `success`. */
|
|
57
|
+
tone: SparklineTone;
|
|
58
|
+
static styles: import("lit").CSSResult[];
|
|
59
|
+
/** The sentence screen readers hear. */
|
|
60
|
+
get summary(): string;
|
|
61
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
62
|
+
}
|
|
63
|
+
declare global {
|
|
64
|
+
interface HTMLElementTagNameMap {
|
|
65
|
+
'cm-sparkline': CmSparkline;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { html, svg, css, nothing } from 'lit';
|
|
2
|
+
import { base, define } from '../base.js';
|
|
3
|
+
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
4
|
+
const strings = defineStrings('sparkline', {
|
|
5
|
+
/** Accessible summary. {label} names the series, {total} its sum, {peak} the largest value, {latest} the last one. */
|
|
6
|
+
summary: '{label}: {total} in all, peak {peak}, latest {latest}',
|
|
7
|
+
/** Accessible summary when `labels` names the points: {when} is the label of the peak. */
|
|
8
|
+
summaryAt: '{label}: {total} in all, peak {peak} on {when}, latest {latest}',
|
|
9
|
+
/** Accessible summary with no values. */
|
|
10
|
+
empty: '{label}: no data',
|
|
11
|
+
});
|
|
12
|
+
/** "[1,0,3]" (JSON) or "1, 0, 3" (comma-separated) to numbers; anything else that isn't a number counts as 0. */
|
|
13
|
+
const toNumbers = (v) => {
|
|
14
|
+
if (!v)
|
|
15
|
+
return [];
|
|
16
|
+
const t = v.trim();
|
|
17
|
+
let raw = [];
|
|
18
|
+
if (t.startsWith('[')) {
|
|
19
|
+
try {
|
|
20
|
+
raw = JSON.parse(t);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
raw = [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
raw = t.split(',');
|
|
28
|
+
return raw.map((x) => { const n = Number(x); return Number.isFinite(n) ? n : 0; });
|
|
29
|
+
};
|
|
30
|
+
const toLabels = (v) => {
|
|
31
|
+
if (!v)
|
|
32
|
+
return [];
|
|
33
|
+
const t = v.trim();
|
|
34
|
+
if (t.startsWith('[')) {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(t).map(String);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return t.split(',').map((s) => s.trim());
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* A word-sized chart of one series over time, for a summary card: "Visits, last 30 days" beside the facts it sums
|
|
46
|
+
* up (since 1.10.0). Bars (the default) for counts per day or week, a line for a level that moves (a balance, a
|
|
47
|
+
* score). It has no axes or numbers of its own: put the figure it explains next to it, for example in `cm-metric`
|
|
48
|
+
* or a `cm-info-item`. Time runs left to right in every language. Screen readers hear one sentence: the total, the
|
|
49
|
+
* peak (and when, with `labels`) and the latest value; with `labels`, pointing at a bar shows its label and value.
|
|
50
|
+
* @element cm-sparkline
|
|
51
|
+
* @cssprop --cm-sparkline-height - Height (default 32px). The width follows the container (default 100%, at most `--cm-sparkline-width`).
|
|
52
|
+
* @cssprop --cm-sparkline-width - Largest width (default none).
|
|
53
|
+
* @csspart chart - The `<svg>`.
|
|
54
|
+
*/
|
|
55
|
+
export class CmSparkline extends CmLocalizedElement {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
/** The points, oldest first. In HTML: `values="[0,2,1,4]"` or `values="0,2,1,4"`. */
|
|
59
|
+
this.values = [];
|
|
60
|
+
/** Optional name of each point, oldest first ("12 Nov"), for the summary and the hover text. */
|
|
61
|
+
this.labels = [];
|
|
62
|
+
/** What the series is, e.g. "Visits, last 30 days". Used in the accessible summary. */
|
|
63
|
+
this.label = '';
|
|
64
|
+
/** `bars` (default) for counts; `line` for a level. */
|
|
65
|
+
this.type = 'bars';
|
|
66
|
+
/** Colour: `neutral` (default, the text colour at 60%), `information` or `success`. */
|
|
67
|
+
this.tone = 'neutral';
|
|
68
|
+
}
|
|
69
|
+
/** The sentence screen readers hear. */
|
|
70
|
+
get summary() {
|
|
71
|
+
const v = this.values ?? [];
|
|
72
|
+
const label = this.label || '';
|
|
73
|
+
if (!v.length)
|
|
74
|
+
return this.t('empty', { label });
|
|
75
|
+
const total = v.reduce((a, b) => a + b, 0);
|
|
76
|
+
const peak = Math.max(...v);
|
|
77
|
+
const at = v.indexOf(peak);
|
|
78
|
+
const vars = { label, total: this.formatNumber(total), peak: this.formatNumber(peak), latest: this.formatNumber(v[v.length - 1]) };
|
|
79
|
+
const when = this.labels?.[at];
|
|
80
|
+
return when ? this.t('summaryAt', { ...vars, when }) : this.t('summary', vars);
|
|
81
|
+
}
|
|
82
|
+
render() {
|
|
83
|
+
const v = this.values ?? [];
|
|
84
|
+
const n = v.length;
|
|
85
|
+
// A 100 x 32 box stretched to the element; the stroke widths stay put (non-scaling-stroke).
|
|
86
|
+
const W = 100, H = 32, top = 2;
|
|
87
|
+
const max = Math.max(1, ...v.map((x) => Math.max(0, x)));
|
|
88
|
+
const y = (x) => H - (Math.max(0, x) / max) * (H - top);
|
|
89
|
+
const tip = (i) => (this.labels?.[i] ? `${this.labels[i]}: ${this.formatNumber(v[i])}` : '');
|
|
90
|
+
let marks = nothing;
|
|
91
|
+
if (n && this.type === 'line') {
|
|
92
|
+
const step = n > 1 ? W / (n - 1) : 0;
|
|
93
|
+
const pts = v.map((x, i) => `${(n > 1 ? i * step : W / 2).toFixed(2)},${y(x).toFixed(2)}`).join(' ');
|
|
94
|
+
const last = pts.split(' ').pop().split(',');
|
|
95
|
+
// The dot is a zero-length round-capped line: with non-scaling-stroke it stays round however the chart stretches.
|
|
96
|
+
marks = svg `<polyline class="line" points=${pts}></polyline><line class="dot" x1=${last[0]} y1=${last[1]} x2=${last[0]} y2=${last[1]}></line>`;
|
|
97
|
+
}
|
|
98
|
+
else if (n) {
|
|
99
|
+
const slot = W / n, gap = n > 1 ? Math.min(slot * 0.25, 2) : 0, bw = slot - gap;
|
|
100
|
+
marks = v.map((x, i) => {
|
|
101
|
+
const h = Math.max(x > 0 ? 1.5 : 0, H - y(x));
|
|
102
|
+
const t = tip(i);
|
|
103
|
+
return svg `<rect class=${i === n - 1 ? 'bar last' : 'bar'} x=${(i * slot + gap / 2).toFixed(2)} y=${(H - h).toFixed(2)} width=${bw.toFixed(2)} height=${h.toFixed(2)} rx="0.6">${t ? svg `<title>${t}</title>` : nothing}</rect>`;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return html `<svg part="chart" role="img" aria-label=${this.summary} viewBox="0 0 ${W} ${H}" preserveAspectRatio="none">
|
|
107
|
+
<line class="base" x1="0" y1=${H} x2=${W} y2=${H}></line>${marks}</svg>`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
CmSparkline.properties = {
|
|
111
|
+
values: { converter: { fromAttribute: toNumbers } },
|
|
112
|
+
labels: { converter: { fromAttribute: toLabels } },
|
|
113
|
+
label: {},
|
|
114
|
+
type: { reflect: true },
|
|
115
|
+
tone: { reflect: true },
|
|
116
|
+
};
|
|
117
|
+
CmSparkline.styles = [
|
|
118
|
+
base,
|
|
119
|
+
css `
|
|
120
|
+
:host { display: block; width: 100%; max-width: var(--cm-sparkline-width, none); height: var(--cm-sparkline-height, 32px); color: var(--cm-icon-default); }
|
|
121
|
+
:host([tone='information']) { color: var(--cm-text-information); }
|
|
122
|
+
:host([tone='success']) { color: var(--cm-text-success); }
|
|
123
|
+
svg { display: block; width: 100%; height: 100%; overflow: visible; direction: ltr; }
|
|
124
|
+
.base { stroke: var(--cm-border-subtle); stroke-width: 1; vector-effect: non-scaling-stroke; }
|
|
125
|
+
.bar { fill: currentColor; }
|
|
126
|
+
.bar.last { fill: var(--cm-text-default); }
|
|
127
|
+
:host([tone='information']) .bar.last, :host([tone='success']) .bar.last { fill: currentColor; opacity: 1; }
|
|
128
|
+
:host([tone='information']) .bar:not(.last), :host([tone='success']) .bar:not(.last) { opacity: 0.55; }
|
|
129
|
+
.line { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
|
|
130
|
+
.dot { stroke: var(--cm-text-default); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
|
|
131
|
+
:host([tone='information']) .dot, :host([tone='success']) .dot { stroke: currentColor; }
|
|
132
|
+
`,
|
|
133
|
+
];
|
|
134
|
+
define('cm-sparkline', CmSparkline);
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
],
|
|
201
201
|
"slots": [
|
|
202
202
|
{
|
|
203
|
-
"description": "`cm-menu-item` elements (
|
|
203
|
+
"description": "`cm-menu-item` elements, with `<hr>` between groups (as in `cm-action-menu`).",
|
|
204
204
|
"name": "",
|
|
205
205
|
"inheritedFrom": {
|
|
206
206
|
"name": "CmActionMenu",
|
|
@@ -32351,6 +32351,272 @@
|
|
|
32351
32351
|
}
|
|
32352
32352
|
]
|
|
32353
32353
|
},
|
|
32354
|
+
{
|
|
32355
|
+
"kind": "javascript-module",
|
|
32356
|
+
"path": "src/components/sparkline.ts",
|
|
32357
|
+
"declarations": [
|
|
32358
|
+
{
|
|
32359
|
+
"kind": "class",
|
|
32360
|
+
"description": "A word-sized chart of one series over time, for a summary card: \"Visits, last 30 days\" beside the facts it sums\nup (since 1.10.0). Bars (the default) for counts per day or week, a line for a level that moves (a balance, a\nscore). It has no axes or numbers of its own: put the figure it explains next to it, for example in `cm-metric`\nor a `cm-info-item`. Time runs left to right in every language. Screen readers hear one sentence: the total, the\npeak (and when, with `labels`) and the latest value; with `labels`, pointing at a bar shows its label and value.",
|
|
32361
|
+
"name": "CmSparkline",
|
|
32362
|
+
"cssProperties": [
|
|
32363
|
+
{
|
|
32364
|
+
"description": "Height (default 32px). The width follows the container (default 100%, at most `--cm-sparkline-width`).",
|
|
32365
|
+
"name": "--cm-sparkline-height"
|
|
32366
|
+
},
|
|
32367
|
+
{
|
|
32368
|
+
"description": "Largest width (default none).",
|
|
32369
|
+
"name": "--cm-sparkline-width"
|
|
32370
|
+
}
|
|
32371
|
+
],
|
|
32372
|
+
"cssParts": [
|
|
32373
|
+
{
|
|
32374
|
+
"description": "The `<svg>`.",
|
|
32375
|
+
"name": "chart"
|
|
32376
|
+
}
|
|
32377
|
+
],
|
|
32378
|
+
"members": [
|
|
32379
|
+
{
|
|
32380
|
+
"kind": "field",
|
|
32381
|
+
"name": "values",
|
|
32382
|
+
"privacy": "public",
|
|
32383
|
+
"type": {
|
|
32384
|
+
"text": "number[]"
|
|
32385
|
+
},
|
|
32386
|
+
"default": "[]",
|
|
32387
|
+
"description": "The points, oldest first. In HTML: `values=\"[0,2,1,4]\"` or `values=\"0,2,1,4\"`.",
|
|
32388
|
+
"attribute": "values"
|
|
32389
|
+
},
|
|
32390
|
+
{
|
|
32391
|
+
"kind": "field",
|
|
32392
|
+
"name": "labels",
|
|
32393
|
+
"privacy": "public",
|
|
32394
|
+
"type": {
|
|
32395
|
+
"text": "string[]"
|
|
32396
|
+
},
|
|
32397
|
+
"default": "[]",
|
|
32398
|
+
"description": "Optional name of each point, oldest first (\"12 Nov\"), for the summary and the hover text.",
|
|
32399
|
+
"attribute": "labels"
|
|
32400
|
+
},
|
|
32401
|
+
{
|
|
32402
|
+
"kind": "field",
|
|
32403
|
+
"name": "label",
|
|
32404
|
+
"privacy": "public",
|
|
32405
|
+
"type": {
|
|
32406
|
+
"text": "string"
|
|
32407
|
+
},
|
|
32408
|
+
"default": "''",
|
|
32409
|
+
"description": "What the series is, e.g. \"Visits, last 30 days\". Used in the accessible summary.",
|
|
32410
|
+
"attribute": "label"
|
|
32411
|
+
},
|
|
32412
|
+
{
|
|
32413
|
+
"kind": "field",
|
|
32414
|
+
"name": "type",
|
|
32415
|
+
"privacy": "public",
|
|
32416
|
+
"type": {
|
|
32417
|
+
"text": "SparklineType"
|
|
32418
|
+
},
|
|
32419
|
+
"default": "'bars'",
|
|
32420
|
+
"description": "`bars` (default) for counts; `line` for a level.",
|
|
32421
|
+
"attribute": "type",
|
|
32422
|
+
"reflects": true
|
|
32423
|
+
},
|
|
32424
|
+
{
|
|
32425
|
+
"kind": "field",
|
|
32426
|
+
"name": "tone",
|
|
32427
|
+
"privacy": "public",
|
|
32428
|
+
"type": {
|
|
32429
|
+
"text": "SparklineTone"
|
|
32430
|
+
},
|
|
32431
|
+
"default": "'neutral'",
|
|
32432
|
+
"description": "Colour: `neutral` (default, the text colour at 60%), `information` or `success`.",
|
|
32433
|
+
"attribute": "tone",
|
|
32434
|
+
"reflects": true
|
|
32435
|
+
},
|
|
32436
|
+
{
|
|
32437
|
+
"kind": "field",
|
|
32438
|
+
"name": "summary",
|
|
32439
|
+
"type": {
|
|
32440
|
+
"text": "string"
|
|
32441
|
+
},
|
|
32442
|
+
"description": "The sentence screen readers hear.",
|
|
32443
|
+
"readonly": true
|
|
32444
|
+
},
|
|
32445
|
+
{
|
|
32446
|
+
"kind": "method",
|
|
32447
|
+
"name": "finalize",
|
|
32448
|
+
"static": true,
|
|
32449
|
+
"description": "A property declared with `string: 'key'` (e.g. `saveLabel: { attribute: 'save-label', string: 'save' }`) reads\nas that built-in string until it is set, so `el.saveLabel` is \"Save\" in English and the translation elsewhere.\nSetting it overrides the string for this element; setting `undefined` goes back to the built-in one.",
|
|
32450
|
+
"inheritedFrom": {
|
|
32451
|
+
"name": "CmLocalizedElement",
|
|
32452
|
+
"module": "src/localize.ts"
|
|
32453
|
+
}
|
|
32454
|
+
},
|
|
32455
|
+
{
|
|
32456
|
+
"kind": "field",
|
|
32457
|
+
"name": "strings",
|
|
32458
|
+
"privacy": "public",
|
|
32459
|
+
"type": {
|
|
32460
|
+
"text": "Record<string, Message> | null | undefined"
|
|
32461
|
+
},
|
|
32462
|
+
"description": "Replaces this component's built-in text (labels, accessible names, messages), key by key. In HTML pass JSON:\n`strings='{\"close\":\"Fermer\"}'`. Keys and English defaults are listed under \"Built-in text\" on the component's\npage; set text for every component at once with `configure()` or `setStrings()` (see Localisation).",
|
|
32463
|
+
"attribute": "strings",
|
|
32464
|
+
"inheritedFrom": {
|
|
32465
|
+
"name": "CmLocalizedElement",
|
|
32466
|
+
"module": "src/localize.ts"
|
|
32467
|
+
}
|
|
32468
|
+
},
|
|
32469
|
+
{
|
|
32470
|
+
"kind": "field",
|
|
32471
|
+
"name": "stringsNamespace",
|
|
32472
|
+
"privacy": "protected",
|
|
32473
|
+
"description": "The string namespace: the tag name without `cm-`, in camelCase.",
|
|
32474
|
+
"readonly": true,
|
|
32475
|
+
"inheritedFrom": {
|
|
32476
|
+
"name": "CmLocalizedElement",
|
|
32477
|
+
"module": "src/localize.ts"
|
|
32478
|
+
}
|
|
32479
|
+
},
|
|
32480
|
+
{
|
|
32481
|
+
"kind": "method",
|
|
32482
|
+
"name": "t",
|
|
32483
|
+
"privacy": "protected",
|
|
32484
|
+
"parameters": [
|
|
32485
|
+
{
|
|
32486
|
+
"name": "key",
|
|
32487
|
+
"type": {
|
|
32488
|
+
"text": "string"
|
|
32489
|
+
}
|
|
32490
|
+
},
|
|
32491
|
+
{
|
|
32492
|
+
"name": "vars",
|
|
32493
|
+
"optional": true,
|
|
32494
|
+
"type": {
|
|
32495
|
+
"text": "MessageVars"
|
|
32496
|
+
}
|
|
32497
|
+
}
|
|
32498
|
+
],
|
|
32499
|
+
"description": "The component's text for `key`, in its language, with `{placeholders}` filled from `vars`.",
|
|
32500
|
+
"inheritedFrom": {
|
|
32501
|
+
"name": "CmLocalizedElement",
|
|
32502
|
+
"module": "src/localize.ts"
|
|
32503
|
+
}
|
|
32504
|
+
},
|
|
32505
|
+
{
|
|
32506
|
+
"kind": "field",
|
|
32507
|
+
"name": "locale",
|
|
32508
|
+
"privacy": "protected",
|
|
32509
|
+
"description": "The locale used for numbers, dates and plurals.",
|
|
32510
|
+
"readonly": true,
|
|
32511
|
+
"inheritedFrom": {
|
|
32512
|
+
"name": "CmLocalizedElement",
|
|
32513
|
+
"module": "src/localize.ts"
|
|
32514
|
+
}
|
|
32515
|
+
},
|
|
32516
|
+
{
|
|
32517
|
+
"kind": "method",
|
|
32518
|
+
"name": "formatNumber",
|
|
32519
|
+
"privacy": "protected",
|
|
32520
|
+
"parameters": [
|
|
32521
|
+
{
|
|
32522
|
+
"name": "n",
|
|
32523
|
+
"type": {
|
|
32524
|
+
"text": "number"
|
|
32525
|
+
}
|
|
32526
|
+
},
|
|
32527
|
+
{
|
|
32528
|
+
"name": "options",
|
|
32529
|
+
"optional": true,
|
|
32530
|
+
"type": {
|
|
32531
|
+
"text": "Intl.NumberFormatOptions"
|
|
32532
|
+
}
|
|
32533
|
+
}
|
|
32534
|
+
],
|
|
32535
|
+
"description": "A number formatted for the component's locale.",
|
|
32536
|
+
"inheritedFrom": {
|
|
32537
|
+
"name": "CmLocalizedElement",
|
|
32538
|
+
"module": "src/localize.ts"
|
|
32539
|
+
}
|
|
32540
|
+
}
|
|
32541
|
+
],
|
|
32542
|
+
"attributes": [
|
|
32543
|
+
{
|
|
32544
|
+
"name": "values",
|
|
32545
|
+
"type": {
|
|
32546
|
+
"text": "number[]"
|
|
32547
|
+
},
|
|
32548
|
+
"default": "[]",
|
|
32549
|
+
"description": "The points, oldest first. In HTML: `values=\"[0,2,1,4]\"` or `values=\"0,2,1,4\"`.",
|
|
32550
|
+
"fieldName": "values"
|
|
32551
|
+
},
|
|
32552
|
+
{
|
|
32553
|
+
"name": "labels",
|
|
32554
|
+
"type": {
|
|
32555
|
+
"text": "string[]"
|
|
32556
|
+
},
|
|
32557
|
+
"default": "[]",
|
|
32558
|
+
"description": "Optional name of each point, oldest first (\"12 Nov\"), for the summary and the hover text.",
|
|
32559
|
+
"fieldName": "labels"
|
|
32560
|
+
},
|
|
32561
|
+
{
|
|
32562
|
+
"name": "label",
|
|
32563
|
+
"type": {
|
|
32564
|
+
"text": "string"
|
|
32565
|
+
},
|
|
32566
|
+
"default": "''",
|
|
32567
|
+
"description": "What the series is, e.g. \"Visits, last 30 days\". Used in the accessible summary.",
|
|
32568
|
+
"fieldName": "label"
|
|
32569
|
+
},
|
|
32570
|
+
{
|
|
32571
|
+
"name": "type",
|
|
32572
|
+
"type": {
|
|
32573
|
+
"text": "SparklineType"
|
|
32574
|
+
},
|
|
32575
|
+
"default": "'bars'",
|
|
32576
|
+
"description": "`bars` (default) for counts; `line` for a level.",
|
|
32577
|
+
"fieldName": "type"
|
|
32578
|
+
},
|
|
32579
|
+
{
|
|
32580
|
+
"name": "tone",
|
|
32581
|
+
"type": {
|
|
32582
|
+
"text": "SparklineTone"
|
|
32583
|
+
},
|
|
32584
|
+
"default": "'neutral'",
|
|
32585
|
+
"description": "Colour: `neutral` (default, the text colour at 60%), `information` or `success`.",
|
|
32586
|
+
"fieldName": "tone"
|
|
32587
|
+
},
|
|
32588
|
+
{
|
|
32589
|
+
"name": "strings",
|
|
32590
|
+
"type": {
|
|
32591
|
+
"text": "Record<string, Message> | null | undefined"
|
|
32592
|
+
},
|
|
32593
|
+
"description": "Replaces this component's built-in text (labels, accessible names, messages), key by key. In HTML pass JSON:\n`strings='{\"close\":\"Fermer\"}'`. Keys and English defaults are listed under \"Built-in text\" on the component's\npage; set text for every component at once with `configure()` or `setStrings()` (see Localisation).",
|
|
32594
|
+
"fieldName": "strings",
|
|
32595
|
+
"inheritedFrom": {
|
|
32596
|
+
"name": "CmLocalizedElement",
|
|
32597
|
+
"module": "src/localize.ts"
|
|
32598
|
+
}
|
|
32599
|
+
}
|
|
32600
|
+
],
|
|
32601
|
+
"superclass": {
|
|
32602
|
+
"name": "CmLocalizedElement",
|
|
32603
|
+
"module": "/src/localize.js"
|
|
32604
|
+
},
|
|
32605
|
+
"tagName": "cm-sparkline",
|
|
32606
|
+
"customElement": true
|
|
32607
|
+
}
|
|
32608
|
+
],
|
|
32609
|
+
"exports": [
|
|
32610
|
+
{
|
|
32611
|
+
"kind": "js",
|
|
32612
|
+
"name": "CmSparkline",
|
|
32613
|
+
"declaration": {
|
|
32614
|
+
"name": "CmSparkline",
|
|
32615
|
+
"module": "src/components/sparkline.ts"
|
|
32616
|
+
}
|
|
32617
|
+
}
|
|
32618
|
+
]
|
|
32619
|
+
},
|
|
32354
32620
|
{
|
|
32355
32621
|
"kind": "javascript-module",
|
|
32356
32622
|
"path": "src/components/spinner.ts",
|
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export { CmMenuItem } from './components/menu-item.js';
|
|
|
71
71
|
export type { MenuItem } from './components/menu-item.js';
|
|
72
72
|
export { CmActionMenu } from './components/action-menu.js';
|
|
73
73
|
export { CmAccountMenu } from './components/account-menu.js';
|
|
74
|
+
export { CmSparkline } from './components/sparkline.js';
|
|
74
75
|
export { CmBottomSheet } from './components/bottom-sheet.js';
|
|
75
76
|
export { CmNotificationPanel, CmNotificationItem } from './components/notification-panel.js';
|
|
76
77
|
export type { NotificationItem } from './components/notification-panel.js';
|
package/dist/index.js
CHANGED
|
@@ -54,6 +54,7 @@ export { CmFilterPanel } from './components/filter-panel.js';
|
|
|
54
54
|
export { CmMenuItem } from './components/menu-item.js';
|
|
55
55
|
export { CmActionMenu } from './components/action-menu.js';
|
|
56
56
|
export { CmAccountMenu } from './components/account-menu.js';
|
|
57
|
+
export { CmSparkline } from './components/sparkline.js';
|
|
57
58
|
export { CmBottomSheet } from './components/bottom-sheet.js';
|
|
58
59
|
export { CmNotificationPanel, CmNotificationItem } from './components/notification-panel.js';
|
|
59
60
|
export { CmToast, CmToastRegion, showToast, undoable } from './components/toast.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commmerce/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Commmerce UI web components: build apps that feel native to the Commmerce admin. Works in plain HTML, React, Vue and server-rendered pages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"test": "vitest run"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@commmerce/icons": "1.
|
|
54
|
-
"@commmerce/tokens": "1.
|
|
53
|
+
"@commmerce/icons": "1.10.0",
|
|
54
|
+
"@commmerce/tokens": "1.10.0",
|
|
55
55
|
"lit": "3.2.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|