@commmerce/ui 1.9.3 → 1.10.1

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.
@@ -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 (and `cm-menu-item divider`).",
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",
@@ -728,58 +728,11 @@
728
728
  "module": "src/components/action-menu.ts"
729
729
  }
730
730
  },
731
- {
732
- "kind": "method",
733
- "name": "#place",
734
- "privacy": "private",
735
- "parameters": [
736
- {
737
- "name": "pop",
738
- "type": {
739
- "text": "HTMLElement"
740
- }
741
- }
742
- ],
743
- "description": "Puts the top-layer menu under the trigger (above it when there's no room below), aligned to its start or end edge.",
744
- "inheritedFrom": {
745
- "name": "CmActionMenu",
746
- "module": "src/components/action-menu.ts"
747
- }
748
- },
749
731
  {
750
732
  "kind": "field",
751
- "name": "#onMove",
733
+ "name": "#layer",
752
734
  "privacy": "private",
753
- "inheritedFrom": {
754
- "name": "CmActionMenu",
755
- "module": "src/components/action-menu.ts"
756
- }
757
- },
758
- {
759
- "kind": "field",
760
- "name": "#following",
761
- "privacy": "private",
762
- "type": {
763
- "text": "boolean"
764
- },
765
- "default": "false",
766
- "inheritedFrom": {
767
- "name": "CmActionMenu",
768
- "module": "src/components/action-menu.ts"
769
- }
770
- },
771
- {
772
- "kind": "method",
773
- "name": "#follow",
774
- "privacy": "private",
775
- "parameters": [
776
- {
777
- "name": "on",
778
- "type": {
779
- "text": "boolean"
780
- }
781
- }
782
- ],
735
+ "default": "new TopLayer()",
783
736
  "inheritedFrom": {
784
737
  "name": "CmActionMenu",
785
738
  "module": "src/components/action-menu.ts"
@@ -1884,46 +1837,11 @@
1884
1837
  "privacy": "private",
1885
1838
  "description": "Opens toward the other side when the menu would run off the screen (1.8.1: a More menu at the end of a page header)."
1886
1839
  },
1887
- {
1888
- "kind": "method",
1889
- "name": "#place",
1890
- "privacy": "private",
1891
- "parameters": [
1892
- {
1893
- "name": "pop",
1894
- "type": {
1895
- "text": "HTMLElement"
1896
- }
1897
- }
1898
- ],
1899
- "description": "Puts the top-layer menu under the trigger (above it when there's no room below), aligned to its start or end edge."
1900
- },
1901
- {
1902
- "kind": "field",
1903
- "name": "#onMove",
1904
- "privacy": "private"
1905
- },
1906
1840
  {
1907
1841
  "kind": "field",
1908
- "name": "#following",
1842
+ "name": "#layer",
1909
1843
  "privacy": "private",
1910
- "type": {
1911
- "text": "boolean"
1912
- },
1913
- "default": "false"
1914
- },
1915
- {
1916
- "kind": "method",
1917
- "name": "#follow",
1918
- "privacy": "private",
1919
- "parameters": [
1920
- {
1921
- "name": "on",
1922
- "type": {
1923
- "text": "boolean"
1924
- }
1925
- }
1926
- ]
1844
+ "default": "new TopLayer()"
1927
1845
  },
1928
1846
  {
1929
1847
  "kind": "field",
@@ -10889,6 +10807,12 @@
10889
10807
  },
10890
10808
  "description": "Rows in the list: the matching options, then the \"Add …\" row if offered."
10891
10809
  },
10810
+ {
10811
+ "kind": "field",
10812
+ "name": "#layer",
10813
+ "privacy": "private",
10814
+ "default": "new TopLayer()"
10815
+ },
10892
10816
  {
10893
10817
  "kind": "method",
10894
10818
  "name": "#emit",
@@ -13635,6 +13559,12 @@
13635
13559
  }
13636
13560
  ]
13637
13561
  },
13562
+ {
13563
+ "kind": "field",
13564
+ "name": "#layer",
13565
+ "privacy": "private",
13566
+ "default": "new TopLayer()"
13567
+ },
13638
13568
  {
13639
13569
  "kind": "method",
13640
13570
  "name": "#togglePicker",
@@ -14758,6 +14688,12 @@
14758
14688
  ],
14759
14689
  "description": "Time mode checks, after the custom error and a bad typed date."
14760
14690
  },
14691
+ {
14692
+ "kind": "field",
14693
+ "name": "#layer",
14694
+ "privacy": "private",
14695
+ "default": "new TopLayer()"
14696
+ },
14761
14697
  {
14762
14698
  "kind": "method",
14763
14699
  "name": "#setValue",
@@ -15730,6 +15666,12 @@
15730
15666
  }
15731
15667
  ]
15732
15668
  },
15669
+ {
15670
+ "kind": "field",
15671
+ "name": "#layer",
15672
+ "privacy": "private",
15673
+ "default": "new TopLayer()"
15674
+ },
15733
15675
  {
15734
15676
  "kind": "method",
15735
15677
  "name": "#emit",
@@ -18434,6 +18376,12 @@
18434
18376
  "privacy": "private",
18435
18377
  "readonly": true
18436
18378
  },
18379
+ {
18380
+ "kind": "field",
18381
+ "name": "#layer",
18382
+ "privacy": "private",
18383
+ "default": "new TopLayer()"
18384
+ },
18437
18385
  {
18438
18386
  "kind": "method",
18439
18387
  "name": "#hide",
@@ -29223,6 +29171,12 @@
29223
29171
  "name": "#readChildren",
29224
29172
  "privacy": "private"
29225
29173
  },
29174
+ {
29175
+ "kind": "field",
29176
+ "name": "#layer",
29177
+ "privacy": "private",
29178
+ "default": "new TopLayer()"
29179
+ },
29226
29180
  {
29227
29181
  "kind": "method",
29228
29182
  "name": "#enabledIndexes",
@@ -32351,6 +32305,272 @@
32351
32305
  }
32352
32306
  ]
32353
32307
  },
32308
+ {
32309
+ "kind": "javascript-module",
32310
+ "path": "src/components/sparkline.ts",
32311
+ "declarations": [
32312
+ {
32313
+ "kind": "class",
32314
+ "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.",
32315
+ "name": "CmSparkline",
32316
+ "cssProperties": [
32317
+ {
32318
+ "description": "Height (default 32px). The width follows the container (default 100%, at most `--cm-sparkline-width`).",
32319
+ "name": "--cm-sparkline-height"
32320
+ },
32321
+ {
32322
+ "description": "Largest width (default none).",
32323
+ "name": "--cm-sparkline-width"
32324
+ }
32325
+ ],
32326
+ "cssParts": [
32327
+ {
32328
+ "description": "The `<svg>`.",
32329
+ "name": "chart"
32330
+ }
32331
+ ],
32332
+ "members": [
32333
+ {
32334
+ "kind": "field",
32335
+ "name": "values",
32336
+ "privacy": "public",
32337
+ "type": {
32338
+ "text": "number[]"
32339
+ },
32340
+ "default": "[]",
32341
+ "description": "The points, oldest first. In HTML: `values=\"[0,2,1,4]\"` or `values=\"0,2,1,4\"`.",
32342
+ "attribute": "values"
32343
+ },
32344
+ {
32345
+ "kind": "field",
32346
+ "name": "labels",
32347
+ "privacy": "public",
32348
+ "type": {
32349
+ "text": "string[]"
32350
+ },
32351
+ "default": "[]",
32352
+ "description": "Optional name of each point, oldest first (\"12 Nov\"), for the summary and the hover text.",
32353
+ "attribute": "labels"
32354
+ },
32355
+ {
32356
+ "kind": "field",
32357
+ "name": "label",
32358
+ "privacy": "public",
32359
+ "type": {
32360
+ "text": "string"
32361
+ },
32362
+ "default": "''",
32363
+ "description": "What the series is, e.g. \"Visits, last 30 days\". Used in the accessible summary.",
32364
+ "attribute": "label"
32365
+ },
32366
+ {
32367
+ "kind": "field",
32368
+ "name": "type",
32369
+ "privacy": "public",
32370
+ "type": {
32371
+ "text": "SparklineType"
32372
+ },
32373
+ "default": "'bars'",
32374
+ "description": "`bars` (default) for counts; `line` for a level.",
32375
+ "attribute": "type",
32376
+ "reflects": true
32377
+ },
32378
+ {
32379
+ "kind": "field",
32380
+ "name": "tone",
32381
+ "privacy": "public",
32382
+ "type": {
32383
+ "text": "SparklineTone"
32384
+ },
32385
+ "default": "'neutral'",
32386
+ "description": "Colour: `neutral` (default, the text colour at 60%), `information` or `success`.",
32387
+ "attribute": "tone",
32388
+ "reflects": true
32389
+ },
32390
+ {
32391
+ "kind": "field",
32392
+ "name": "summary",
32393
+ "type": {
32394
+ "text": "string"
32395
+ },
32396
+ "description": "The sentence screen readers hear.",
32397
+ "readonly": true
32398
+ },
32399
+ {
32400
+ "kind": "method",
32401
+ "name": "finalize",
32402
+ "static": true,
32403
+ "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.",
32404
+ "inheritedFrom": {
32405
+ "name": "CmLocalizedElement",
32406
+ "module": "src/localize.ts"
32407
+ }
32408
+ },
32409
+ {
32410
+ "kind": "field",
32411
+ "name": "strings",
32412
+ "privacy": "public",
32413
+ "type": {
32414
+ "text": "Record<string, Message> | null | undefined"
32415
+ },
32416
+ "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).",
32417
+ "attribute": "strings",
32418
+ "inheritedFrom": {
32419
+ "name": "CmLocalizedElement",
32420
+ "module": "src/localize.ts"
32421
+ }
32422
+ },
32423
+ {
32424
+ "kind": "field",
32425
+ "name": "stringsNamespace",
32426
+ "privacy": "protected",
32427
+ "description": "The string namespace: the tag name without `cm-`, in camelCase.",
32428
+ "readonly": true,
32429
+ "inheritedFrom": {
32430
+ "name": "CmLocalizedElement",
32431
+ "module": "src/localize.ts"
32432
+ }
32433
+ },
32434
+ {
32435
+ "kind": "method",
32436
+ "name": "t",
32437
+ "privacy": "protected",
32438
+ "parameters": [
32439
+ {
32440
+ "name": "key",
32441
+ "type": {
32442
+ "text": "string"
32443
+ }
32444
+ },
32445
+ {
32446
+ "name": "vars",
32447
+ "optional": true,
32448
+ "type": {
32449
+ "text": "MessageVars"
32450
+ }
32451
+ }
32452
+ ],
32453
+ "description": "The component's text for `key`, in its language, with `{placeholders}` filled from `vars`.",
32454
+ "inheritedFrom": {
32455
+ "name": "CmLocalizedElement",
32456
+ "module": "src/localize.ts"
32457
+ }
32458
+ },
32459
+ {
32460
+ "kind": "field",
32461
+ "name": "locale",
32462
+ "privacy": "protected",
32463
+ "description": "The locale used for numbers, dates and plurals.",
32464
+ "readonly": true,
32465
+ "inheritedFrom": {
32466
+ "name": "CmLocalizedElement",
32467
+ "module": "src/localize.ts"
32468
+ }
32469
+ },
32470
+ {
32471
+ "kind": "method",
32472
+ "name": "formatNumber",
32473
+ "privacy": "protected",
32474
+ "parameters": [
32475
+ {
32476
+ "name": "n",
32477
+ "type": {
32478
+ "text": "number"
32479
+ }
32480
+ },
32481
+ {
32482
+ "name": "options",
32483
+ "optional": true,
32484
+ "type": {
32485
+ "text": "Intl.NumberFormatOptions"
32486
+ }
32487
+ }
32488
+ ],
32489
+ "description": "A number formatted for the component's locale.",
32490
+ "inheritedFrom": {
32491
+ "name": "CmLocalizedElement",
32492
+ "module": "src/localize.ts"
32493
+ }
32494
+ }
32495
+ ],
32496
+ "attributes": [
32497
+ {
32498
+ "name": "values",
32499
+ "type": {
32500
+ "text": "number[]"
32501
+ },
32502
+ "default": "[]",
32503
+ "description": "The points, oldest first. In HTML: `values=\"[0,2,1,4]\"` or `values=\"0,2,1,4\"`.",
32504
+ "fieldName": "values"
32505
+ },
32506
+ {
32507
+ "name": "labels",
32508
+ "type": {
32509
+ "text": "string[]"
32510
+ },
32511
+ "default": "[]",
32512
+ "description": "Optional name of each point, oldest first (\"12 Nov\"), for the summary and the hover text.",
32513
+ "fieldName": "labels"
32514
+ },
32515
+ {
32516
+ "name": "label",
32517
+ "type": {
32518
+ "text": "string"
32519
+ },
32520
+ "default": "''",
32521
+ "description": "What the series is, e.g. \"Visits, last 30 days\". Used in the accessible summary.",
32522
+ "fieldName": "label"
32523
+ },
32524
+ {
32525
+ "name": "type",
32526
+ "type": {
32527
+ "text": "SparklineType"
32528
+ },
32529
+ "default": "'bars'",
32530
+ "description": "`bars` (default) for counts; `line` for a level.",
32531
+ "fieldName": "type"
32532
+ },
32533
+ {
32534
+ "name": "tone",
32535
+ "type": {
32536
+ "text": "SparklineTone"
32537
+ },
32538
+ "default": "'neutral'",
32539
+ "description": "Colour: `neutral` (default, the text colour at 60%), `information` or `success`.",
32540
+ "fieldName": "tone"
32541
+ },
32542
+ {
32543
+ "name": "strings",
32544
+ "type": {
32545
+ "text": "Record<string, Message> | null | undefined"
32546
+ },
32547
+ "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).",
32548
+ "fieldName": "strings",
32549
+ "inheritedFrom": {
32550
+ "name": "CmLocalizedElement",
32551
+ "module": "src/localize.ts"
32552
+ }
32553
+ }
32554
+ ],
32555
+ "superclass": {
32556
+ "name": "CmLocalizedElement",
32557
+ "module": "/src/localize.js"
32558
+ },
32559
+ "tagName": "cm-sparkline",
32560
+ "customElement": true
32561
+ }
32562
+ ],
32563
+ "exports": [
32564
+ {
32565
+ "kind": "js",
32566
+ "name": "CmSparkline",
32567
+ "declaration": {
32568
+ "name": "CmSparkline",
32569
+ "module": "src/components/sparkline.ts"
32570
+ }
32571
+ }
32572
+ ]
32573
+ },
32354
32574
  {
32355
32575
  "kind": "javascript-module",
32356
32576
  "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';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Floating lists and menus in the top layer (since 1.10.1, issue #35). A dropdown drawn with `position: absolute`
3
+ * inside a component is covered by later rows that make their own stacking context (a `cm-resource-item`'s actions)
4
+ * and clipped by any ancestor with `overflow: hidden` / `auto` (a card, a board column, a table's scroll area). In
5
+ * the top layer nothing can cover or clip it. `TopLayer` shows the element as a manual popover, puts it beside its
6
+ * anchor (below, or above when there is more room there), keeps it inside the window and follows scrolling and
7
+ * resizing while it is open. Browsers without popovers, or a list styled `position: static` (the header bar's
8
+ * full-screen search), keep the in-place layout.
9
+ */
10
+ /** Neutralises the browser's own popover styles (border, padding, colours) so each component's styles apply as before. */
11
+ export declare const topLayerStyles: import("lit").CSSResult;
12
+ export interface TopLayerOptions {
13
+ /** `start` / `end`: aligned to the anchor's start or end edge. `stretch`: at least as wide as the anchor. */
14
+ align?: 'start' | 'end' | 'stretch';
15
+ /** Space between anchor and list (default 4). */
16
+ gap?: number;
17
+ }
18
+ export declare class TopLayer {
19
+ #private;
20
+ /** Whether the list is currently shown in the top layer. */
21
+ get active(): boolean;
22
+ /**
23
+ * Shows `pop` in the top layer beside `anchor`. Returns false (and leaves the in-place layout) when the browser
24
+ * has no popovers or the list is laid out statically.
25
+ */
26
+ open(pop: HTMLElement | null | undefined, anchor: HTMLElement | null | undefined, opts?: TopLayerOptions): boolean;
27
+ /** Puts the list beside its anchor again (call after its content changes size). */
28
+ place(): void;
29
+ /** Hides the list and puts back its in-place styles. */
30
+ close(): void;
31
+ }