@commmerce/ui 1.6.0 → 1.7.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.
@@ -3,6 +3,11 @@ import { base, define } from '../base.js';
3
3
  /**
4
4
  * Side card on detail pages that lists facts as label/value pairs (order details, SKU, tags).
5
5
  * Put `cm-info-item` elements inside. The Figma file calls this the "Additional Info Card".
6
+ * Labels are 13/18 in text-tertiary, values 14/20 medium (owner standard).
7
+ *
8
+ * On record pages (since 1.7) use `variant="compact"` (the padding of a compact `cm-card`: 16px, 12px under the title)
9
+ * and `layout="rows"`: each fact on one row, the label on the start side and the value beside it, the way a CRM's
10
+ * Details card reads. Rows fit the 320px aside of a record layout.
6
11
  * @element cm-info-panel
7
12
  * @slot - `cm-info-item` elements.
8
13
  * @fires cm-action - When the header text action (for example REMOVE) is pressed.
@@ -18,6 +23,13 @@ export class CmInfoPanel extends LitElement {
18
23
  this.actionLabel = '';
19
24
  /** Heading level for the title. Default 2. */
20
25
  this.headingLevel = 2;
26
+ /** `default` (24px padding, like a standard `cm-card`; 16px on phones; 20px before 1.7.1) or `compact` (16px padding and 12px under the title, like a compact `cm-card`). Since 1.7. */
27
+ this.variant = 'default';
28
+ /**
29
+ * `stacked` (default: each label over its value; `half` items share a line) or `rows` (each label beside its value,
30
+ * two fifths of the width for the label; `half` is ignored). Since 1.7.
31
+ */
32
+ this.layout = 'stacked';
21
33
  /** The items area is a list only while it holds just `cm-info-item`s (not, say, a loading skeleton). */
22
34
  this._list = true;
23
35
  }
@@ -44,6 +56,8 @@ CmInfoPanel.properties = {
44
56
  action: {},
45
57
  actionLabel: { attribute: 'action-label' },
46
58
  headingLevel: { type: Number, attribute: 'heading-level' },
59
+ variant: { reflect: true },
60
+ layout: { reflect: true },
47
61
  _list: { state: true },
48
62
  };
49
63
  CmInfoPanel.styles = [
@@ -52,7 +66,7 @@ CmInfoPanel.styles = [
52
66
  :host { display: block; }
53
67
  section {
54
68
  background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-subtle);
55
- border-radius: var(--cm-radius-md); padding: var(--cm-space-20);
69
+ border-radius: var(--cm-radius-md); padding: var(--cm-space-24);
56
70
  }
57
71
  header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--cm-space-16); margin-bottom: var(--cm-space-16); }
58
72
  .title { margin: 0; font-size: var(--cm-type-heading-sm-size); line-height: var(--cm-type-heading-sm-line-height); font-weight: 600; }
@@ -64,11 +78,20 @@ CmInfoPanel.styles = [
64
78
  .action:hover { text-decoration-thickness: 2px; }
65
79
  .action:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
66
80
  .items { display: grid; grid-template-columns: 1fr 1fr; gap: var(--cm-space-12) var(--cm-space-20); }
81
+ :host([variant='compact']) section { padding: var(--cm-space-16); }
82
+ @media (max-width: 640px) { section { padding: var(--cm-space-16); } }
83
+ :host([variant='compact']) header { margin-bottom: var(--cm-space-12); }
84
+ /* Rows (1.7): the item's label and value become two columns of its own grid. */
85
+ :host([layout='rows']) .items { grid-template-columns: minmax(0, 1fr); }
86
+ :host([layout='rows']) ::slotted(cm-info-item) {
87
+ display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: baseline;
88
+ column-gap: var(--cm-space-12); grid-column: 1 / -1; --_cm-info-value-gap: 0px;
89
+ }
67
90
  `,
68
91
  ];
69
92
  define('cm-info-panel', CmInfoPanel);
70
93
  /**
71
- * One fact in an info panel: a label and its value (text, a badge or tags).
94
+ * One fact in an info panel: a label (13px) and its value (14px): text, a link, a badge or tags.
72
95
  * @element cm-info-item
73
96
  * @slot - The value.
74
97
  */
@@ -101,7 +124,7 @@ CmInfoItem.styles = [
101
124
  .label { font-size: var(--cm-font-size-13); line-height: var(--cm-line-height-13); color: var(--cm-text-tertiary); }
102
125
  .value {
103
126
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-8);
104
- margin-top: var(--cm-space-4); font-size: var(--cm-font-size-14); line-height: var(--cm-line-height-14); font-weight: 500; overflow-wrap: anywhere;
127
+ margin-top: var(--_cm-info-value-gap, var(--cm-space-4)); font-size: var(--cm-font-size-14); line-height: var(--cm-line-height-14); font-weight: 500; overflow-wrap: anywhere;
105
128
 
106
129
  }
107
130
  `,
@@ -4,22 +4,67 @@ import { type SpaceStep } from '../spacing.js';
4
4
  * The body of an admin page: sections side by side, for example the main column and side column of a detail page.
5
5
  * Sections stack into one column, in source order, when the layout is narrower than 768px (a container query, so
6
6
  * it follows the space the layout gets, not the window). Put the main section first.
7
+ *
8
+ * `variant="record"` (since 1.7) is the standard record page: a lead, contact, deal, account or ticket, an order or a
9
+ * product. Put in one main `cm-layout-section` and one `cm-layout-section variant="aside"`. From 880px of the layout's
10
+ * own width the aside is a 320px column on the end side (on the left in right-to-left pages) and the main column takes
11
+ * the rest, `space-24` apart. Narrower, they stack: the aside goes above the main content (the key facts first) or
12
+ * below it with `aside-position="below"`, and the gap is `space-16` once the layout is 640px wide or less. The aside
13
+ * is placed by its variant, not by where it is in the source. Cards in a record layout's sections are as far apart as
14
+ * the columns.
7
15
  * @element cm-layout
8
16
  * @slot - `cm-layout-section` elements.
17
+ * @cssprop --cm-layout-sticky-top - With `sticky-aside`: how far from the top of the window the aside stops. Default
18
+ * `space-24` below the `cm-app-frame` header (just `space-24` outside an app frame). Since 1.7.
9
19
  */
10
20
  export declare class CmLayout extends LitElement {
21
+ #private;
11
22
  static properties: {
12
23
  gap: {
13
24
  reflect: boolean;
14
25
  };
26
+ variant: {
27
+ reflect: boolean;
28
+ };
29
+ asidePosition: {
30
+ attribute: string;
31
+ reflect: boolean;
32
+ };
33
+ stickyAside: {
34
+ type: BooleanConstructor;
35
+ attribute: string;
36
+ reflect: boolean;
37
+ };
15
38
  };
16
- /** Space between sections, across and down: a spacing step on the 4px grid (`0`, `4`, `8`, `12`, `16`, `20`, `24`, `32`, `40`, `48`, `64`; the pre-1.5 steps `10`, `15`, `22` and `30` still work and draw as 8, 16, 24 and 32). Default `24` (owner standard, 1.6: 24px between page sections; was 20). */
39
+ /**
40
+ * Space between sections, across and down: a spacing step on the 4px grid (`0`, `4`, `8`, `12`, `16`, `20`, `24`, `32`, `40`, `48`, `64`; the pre-1.5 steps `10`, `15`, `22` and `30` still work and draw as 8, 16, 24 and 32). Default `24` (owner standard, 1.6: 24px between page sections; was 20).
41
+ * In a record layout the default `24` becomes `16` once the layout is 640px wide or less.
42
+ */
17
43
  gap: SpaceStep;
44
+ /**
45
+ * `default`: a six-track grid for `full`, `one-half`, `one-third` and `two-thirds` sections.
46
+ * `record` (since 1.7): a main column and a 320px `aside` section on the end side from 880px (a 1280px laptop window with the side navigation gives about 950px); see the element description.
47
+ */
48
+ variant: 'default' | 'record';
49
+ /** Record layout: where the aside goes once the columns stack (below 880px), `above` the main content (default) or `below` it. Since 1.7. */
50
+ asidePosition: 'above' | 'below';
51
+ /**
52
+ * Record layout: the aside stays in view below the header while the main column scrolls, as long as the whole aside
53
+ * fits in the window (a taller aside scrolls with the page, so nothing in it is out of reach). Only while the
54
+ * columns are side by side. Since 1.7.
55
+ */
56
+ stickyAside: boolean;
18
57
  static styles: import("lit").CSSResult[];
58
+ disconnectedCallback(): void;
59
+ connectedCallback(): void;
60
+ updated(changed: Map<string, unknown>): void;
61
+ /** Whether the aside currently sticks (`sticky-aside` is on and the whole aside fits in the window). For tests and debugging. */
62
+ get asideSticks(): boolean;
19
63
  render(): import("lit-html").TemplateResult<1>;
20
64
  }
21
65
  /**
22
66
  * One column of a `cm-layout`. Its children are stacked `space-24` apart (cards on the page; since 1.6, was `space-20`).
67
+ * In a record layout they are as far apart as the columns (`space-16` once the layout is 640px wide or less).
23
68
  * @element cm-layout-section
24
69
  * @slot - The section's content, usually cards.
25
70
  */
@@ -32,8 +77,9 @@ export declare class CmLayoutSection extends LitElement {
32
77
  /**
33
78
  * Width on wide layouts: `full` (default), `one-half`, `one-third` or `two-thirds`. A detail page is a
34
79
  * `two-thirds` main section and a `one-third` side section. Every section is full width once the layout stacks.
80
+ * `aside` (since 1.7) is the 320px side column of a `cm-layout variant="record"`; in other layouts it is `one-third`.
35
81
  */
36
- variant: 'full' | 'one-half' | 'one-third' | 'two-thirds';
82
+ variant: 'full' | 'one-half' | 'one-third' | 'two-thirds' | 'aside';
37
83
  static styles: import("lit").CSSResult[];
38
84
  render(): import("lit-html").TemplateResult<1>;
39
85
  }
@@ -1,3 +1,15 @@
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 _CmLayout_instances, _CmLayout_internals, _CmLayout_observer, _CmLayout_observed, _CmLayout_onResize, _CmLayout_asides, _CmLayout_unwatch, _CmLayout_watch, _CmLayout_measure, _CmLayout_setFits;
1
13
  import { LitElement, html, css } from 'lit';
2
14
  import { base, define } from '../base.js';
3
15
  import { spaceRules } from '../spacing.js';
@@ -5,20 +17,115 @@ import { spaceRules } from '../spacing.js';
5
17
  * The body of an admin page: sections side by side, for example the main column and side column of a detail page.
6
18
  * Sections stack into one column, in source order, when the layout is narrower than 768px (a container query, so
7
19
  * it follows the space the layout gets, not the window). Put the main section first.
20
+ *
21
+ * `variant="record"` (since 1.7) is the standard record page: a lead, contact, deal, account or ticket, an order or a
22
+ * product. Put in one main `cm-layout-section` and one `cm-layout-section variant="aside"`. From 880px of the layout's
23
+ * own width the aside is a 320px column on the end side (on the left in right-to-left pages) and the main column takes
24
+ * the rest, `space-24` apart. Narrower, they stack: the aside goes above the main content (the key facts first) or
25
+ * below it with `aside-position="below"`, and the gap is `space-16` once the layout is 640px wide or less. The aside
26
+ * is placed by its variant, not by where it is in the source. Cards in a record layout's sections are as far apart as
27
+ * the columns.
8
28
  * @element cm-layout
9
29
  * @slot - `cm-layout-section` elements.
30
+ * @cssprop --cm-layout-sticky-top - With `sticky-aside`: how far from the top of the window the aside stops. Default
31
+ * `space-24` below the `cm-app-frame` header (just `space-24` outside an app frame). Since 1.7.
10
32
  */
11
33
  export class CmLayout extends LitElement {
12
34
  constructor() {
13
35
  super(...arguments);
14
- /** Space between sections, across and down: a spacing step on the 4px grid (`0`, `4`, `8`, `12`, `16`, `20`, `24`, `32`, `40`, `48`, `64`; the pre-1.5 steps `10`, `15`, `22` and `30` still work and draw as 8, 16, 24 and 32). Default `24` (owner standard, 1.6: 24px between page sections; was 20). */
36
+ _CmLayout_instances.add(this);
37
+ /**
38
+ * Space between sections, across and down: a spacing step on the 4px grid (`0`, `4`, `8`, `12`, `16`, `20`, `24`, `32`, `40`, `48`, `64`; the pre-1.5 steps `10`, `15`, `22` and `30` still work and draw as 8, 16, 24 and 32). Default `24` (owner standard, 1.6: 24px between page sections; was 20).
39
+ * In a record layout the default `24` becomes `16` once the layout is 640px wide or less.
40
+ */
15
41
  this.gap = '24';
42
+ /**
43
+ * `default`: a six-track grid for `full`, `one-half`, `one-third` and `two-thirds` sections.
44
+ * `record` (since 1.7): a main column and a 320px `aside` section on the end side from 880px (a 1280px laptop window with the side navigation gives about 950px); see the element description.
45
+ */
46
+ this.variant = 'default';
47
+ /** Record layout: where the aside goes once the columns stack (below 880px), `above` the main content (default) or `below` it. Since 1.7. */
48
+ this.asidePosition = 'above';
49
+ /**
50
+ * Record layout: the aside stays in view below the header while the main column scrolls, as long as the whole aside
51
+ * fits in the window (a taller aside scrolls with the page, so nothing in it is out of reach). Only while the
52
+ * columns are side by side. Since 1.7.
53
+ */
54
+ this.stickyAside = false;
55
+ _CmLayout_internals.set(this, this.attachInternals());
56
+ _CmLayout_observer.set(this, void 0);
57
+ _CmLayout_observed.set(this, []);
58
+ _CmLayout_onResize.set(this, () => __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_measure).call(this));
59
+ }
60
+ disconnectedCallback() {
61
+ super.disconnectedCallback();
62
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_unwatch).call(this);
63
+ }
64
+ connectedCallback() {
65
+ super.connectedCallback();
66
+ if (this.hasUpdated)
67
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_watch).call(this);
68
+ }
69
+ updated(changed) {
70
+ if (changed.has('stickyAside') || changed.has('variant'))
71
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_watch).call(this);
72
+ }
73
+ /** Whether the aside currently sticks (`sticky-aside` is on and the whole aside fits in the window). For tests and debugging. */
74
+ get asideSticks() {
75
+ const a = __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_asides).call(this)[0];
76
+ return !!a && getComputedStyle(a).position === 'sticky';
16
77
  }
17
78
  render() {
18
- return html `<div class="layout" part="layout"><slot></slot></div>`;
79
+ return html `<div class="layout" part="layout"><slot @slotchange=${() => { if (this.stickyAside)
80
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_watch).call(this); }}></slot></div>`;
19
81
  }
20
82
  }
21
- CmLayout.properties = { gap: { reflect: true } };
83
+ _CmLayout_internals = new WeakMap(), _CmLayout_observer = new WeakMap(), _CmLayout_observed = new WeakMap(), _CmLayout_onResize = new WeakMap(), _CmLayout_instances = new WeakSet(), _CmLayout_asides = function _CmLayout_asides() {
84
+ return [...this.children].filter((c) => c.getAttribute('variant') === 'aside');
85
+ }, _CmLayout_unwatch = function _CmLayout_unwatch() {
86
+ __classPrivateFieldGet(this, _CmLayout_observer, "f")?.disconnect();
87
+ __classPrivateFieldSet(this, _CmLayout_observer, undefined, "f");
88
+ __classPrivateFieldSet(this, _CmLayout_observed, [], "f");
89
+ window.removeEventListener('resize', __classPrivateFieldGet(this, _CmLayout_onResize, "f"));
90
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_setFits).call(this, false);
91
+ }, _CmLayout_watch = function _CmLayout_watch() {
92
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_unwatch).call(this);
93
+ if (!this.stickyAside || this.variant !== 'record' || !this.isConnected)
94
+ return;
95
+ __classPrivateFieldSet(this, _CmLayout_observer, new ResizeObserver(() => __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_measure).call(this)), "f");
96
+ __classPrivateFieldSet(this, _CmLayout_observed, [this, ...__classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_asides).call(this)], "f");
97
+ __classPrivateFieldGet(this, _CmLayout_observed, "f").forEach((el) => __classPrivateFieldGet(this, _CmLayout_observer, "f").observe(el));
98
+ window.addEventListener('resize', __classPrivateFieldGet(this, _CmLayout_onResize, "f"));
99
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_measure).call(this);
100
+ }, _CmLayout_measure = function _CmLayout_measure() {
101
+ const asides = __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_asides).call(this);
102
+ if (asides.some((a) => !__classPrivateFieldGet(this, _CmLayout_observed, "f").includes(a))) {
103
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_watch).call(this);
104
+ return;
105
+ }
106
+ const fits = asides.length > 0 && asides.every((a) => {
107
+ const top = parseFloat(getComputedStyle(a).insetBlockStart) || 0;
108
+ return a.getBoundingClientRect().height + top <= window.innerHeight;
109
+ });
110
+ __classPrivateFieldGet(this, _CmLayout_instances, "m", _CmLayout_setFits).call(this, fits);
111
+ }, _CmLayout_setFits = function _CmLayout_setFits(on) {
112
+ const states = __classPrivateFieldGet(this, _CmLayout_internals, "f").states;
113
+ if (!states)
114
+ return;
115
+ try {
116
+ if (on)
117
+ states.add('aside-fits');
118
+ else
119
+ states.delete('aside-fits');
120
+ }
121
+ catch { /* browsers without custom states: the aside scrolls with the page */ }
122
+ };
123
+ CmLayout.properties = {
124
+ gap: { reflect: true },
125
+ variant: { reflect: true },
126
+ asidePosition: { attribute: 'aside-position', reflect: true },
127
+ stickyAside: { type: Boolean, attribute: 'sticky-aside', reflect: true },
128
+ };
22
129
  CmLayout.styles = [
23
130
  base,
24
131
  css `
@@ -32,14 +139,35 @@ CmLayout.styles = [
32
139
  ::slotted(*) { grid-column: 1 / -1; min-inline-size: 0; }
33
140
  @container cm-layout (min-width: 768px) {
34
141
  ::slotted([variant='one-half']) { grid-column: span 3; }
35
- ::slotted([variant='one-third']) { grid-column: span 2; }
142
+ ::slotted([variant='one-third']), ::slotted([variant='aside']) { grid-column: span 2; }
36
143
  ::slotted([variant='two-thirds']) { grid-column: span 4; }
37
144
  }
145
+
146
+ /* Record layout (1.7). The phone gap is set on .layout, so it also reaches the sections (inherited). */
147
+ :host([variant='record']) .layout { grid-template-columns: minmax(0, 1fr); }
148
+ :host([variant='record']) ::slotted(*) { grid-column: 1 / -1; order: 0; --_cm-section-gap: var(--_gap); }
149
+ :host([variant='record']) ::slotted([variant='aside']) { order: -1; }
150
+ :host([variant='record'][aside-position='below']) ::slotted([variant='aside']) { order: 1; }
151
+ @container cm-layout (max-width: 640px) {
152
+ :host([variant='record'][gap='24']) .layout { --_gap: var(--cm-space-16); }
153
+ }
154
+ @container cm-layout (min-width: 880px) {
155
+ /* Dense placement puts the aside beside the main section whichever comes first in the source. */
156
+ :host([variant='record']) .layout { grid-template-columns: minmax(0, 1fr) 320px; grid-auto-flow: dense; } /* scale-exempt: the record aside is a fixed 320px column */
157
+ :host([variant='record']) ::slotted(*) { grid-column: 1; order: 0; }
158
+ :host([variant='record']) ::slotted([variant='aside']) { grid-column: 2; }
159
+ :host([variant='record'][sticky-aside]:state(aside-fits)) ::slotted([variant='aside']) { position: sticky; }
160
+ }
161
+ :host([variant='record'][sticky-aside]) ::slotted([variant='aside']) {
162
+ /* Read back by #measure(); only takes effect once the aside is sticky. --_header: cm-app-frame's header height. */
163
+ inset-block-start: var(--cm-layout-sticky-top, calc(var(--_header, 0px) + var(--cm-space-24)));
164
+ }
38
165
  `,
39
166
  spaceRules('gap', '--_gap'),
40
167
  ];
41
168
  /**
42
169
  * One column of a `cm-layout`. Its children are stacked `space-24` apart (cards on the page; since 1.6, was `space-20`).
170
+ * In a record layout they are as far apart as the columns (`space-16` once the layout is 640px wide or less).
43
171
  * @element cm-layout-section
44
172
  * @slot - The section's content, usually cards.
45
173
  */
@@ -49,6 +177,7 @@ export class CmLayoutSection extends LitElement {
49
177
  /**
50
178
  * Width on wide layouts: `full` (default), `one-half`, `one-third` or `two-thirds`. A detail page is a
51
179
  * `two-thirds` main section and a `one-third` side section. Every section is full width once the layout stacks.
180
+ * `aside` (since 1.7) is the 320px side column of a `cm-layout variant="record"`; in other layouts it is `one-third`.
52
181
  */
53
182
  this.variant = 'full';
54
183
  }
@@ -60,7 +189,7 @@ CmLayoutSection.properties = { variant: { reflect: true } };
60
189
  CmLayoutSection.styles = [
61
190
  base,
62
191
  css `
63
- :host { display: flex; flex-direction: column; gap: var(--cm-space-24); min-inline-size: 0; }
192
+ :host { display: flex; flex-direction: column; gap: var(--_cm-section-gap, var(--cm-space-24)); min-inline-size: 0; }
64
193
  `,
65
194
  ];
66
195
  define('cm-layout', CmLayout);
@@ -3,6 +3,8 @@ import './icon.js';
3
3
  declare const strings: {
4
4
  /** Accessible name of the back link on narrow screens. */
5
5
  back: string;
6
+ /** Accessible name of the back link (`back-href`) when no `back-label` is given. */
7
+ backOnly: string;
6
8
  /** Accessible name of the breadcrumb navigation. */
7
9
  breadcrumbs: string;
8
10
  /** Accessible names of the record arrows and their group. */
@@ -23,7 +25,8 @@ export interface Breadcrumb {
23
25
  /**
24
26
  * Top of an admin page: breadcrumbs, the page title and the page's main actions.
25
27
  * The Figma file calls this the "Save Bar" (80px desktop, 50px mobile).
26
- * On narrow screens the breadcrumbs collapse to a back link to the parent page.
28
+ * On narrow screens the breadcrumbs collapse to a back link to the parent page. `back-href` (since 1.7) shows that
29
+ * back link at every width instead, before the title: use it on record pages opened from a list (a lead, an order).
27
30
  * Type (owner standard, 1.6): title 24/32 semibold (20/28 on phones), description 13/18, breadcrumbs 13/18.
28
31
  * A badge in `title-adornment` sits beside the title and wraps under it only when the title runs out of room.
29
32
  * @element cm-page-header
@@ -41,6 +44,12 @@ export declare class CmPageHeader extends CmLocalizedElement {
41
44
  breadcrumbs: {
42
45
  type: ArrayConstructor;
43
46
  };
47
+ backHref: {
48
+ attribute: string;
49
+ };
50
+ backLabel: {
51
+ attribute: string;
52
+ };
44
53
  pagination: {
45
54
  type: BooleanConstructor;
46
55
  reflect: boolean;
@@ -56,13 +65,24 @@ export declare class CmPageHeader extends CmLocalizedElement {
56
65
  };
57
66
  /** Page title, rendered as the page's `<h1>` and as the last (current) breadcrumb. */
58
67
  heading: string;
59
- /** One line under the title saying what the page is for, 13px in text-tertiary (owner standard: page description 13). Since 1.6. */
68
+ /**
69
+ * One line under the title saying what the page is for, 13px in text-tertiary (owner standard: page description 13). Since 1.6.
70
+ * On a record page, the record's facts at a glance: "Owner Asha Rao · Created 12 Nov 2026 · Source Website form".
71
+ */
60
72
  description: string;
61
73
  /**
62
74
  * Parent pages, outermost first, as `{label, href}`. Don't include the current page.
63
75
  * In HTML pass JSON: `breadcrumbs='[{"label":"Products","href":"/products"}]'`.
64
76
  */
65
77
  breadcrumbs: Breadcrumb[];
78
+ /**
79
+ * Address of the page this one was opened from (the list of leads, of orders). Shows a back arrow before the title
80
+ * at every width, named "Back to {back-label}". Without it the arrow appears only on narrow screens, for the last
81
+ * breadcrumb with an `href`. Since 1.7.
82
+ */
83
+ backHref: string;
84
+ /** Name of the page `back-href` leads to ("Leads"), for the back arrow's accessible name. Since 1.7. */
85
+ backLabel: string;
66
86
  /** Shows previous/next arrows for stepping through records (orders, products). */
67
87
  pagination: boolean;
68
88
  /** Enables the previous arrow. */
@@ -11,6 +11,8 @@ import './icon.js';
11
11
  const strings = defineStrings('pageHeader', {
12
12
  /** Accessible name of the back link on narrow screens. */
13
13
  back: 'Back to {label}',
14
+ /** Accessible name of the back link (`back-href`) when no `back-label` is given. */
15
+ backOnly: 'Back',
14
16
  /** Accessible name of the breadcrumb navigation. */
15
17
  breadcrumbs: 'Breadcrumb',
16
18
  /** Accessible names of the record arrows and their group. */
@@ -21,7 +23,8 @@ const strings = defineStrings('pageHeader', {
21
23
  /**
22
24
  * Top of an admin page: breadcrumbs, the page title and the page's main actions.
23
25
  * The Figma file calls this the "Save Bar" (80px desktop, 50px mobile).
24
- * On narrow screens the breadcrumbs collapse to a back link to the parent page.
26
+ * On narrow screens the breadcrumbs collapse to a back link to the parent page. `back-href` (since 1.7) shows that
27
+ * back link at every width instead, before the title: use it on record pages opened from a list (a lead, an order).
25
28
  * Type (owner standard, 1.6): title 24/32 semibold (20/28 on phones), description 13/18, breadcrumbs 13/18.
26
29
  * A badge in `title-adornment` sits beside the title and wraps under it only when the title runs out of room.
27
30
  * @element cm-page-header
@@ -37,13 +40,24 @@ export class CmPageHeader extends CmLocalizedElement {
37
40
  _CmPageHeader_instances.add(this);
38
41
  /** Page title, rendered as the page's `<h1>` and as the last (current) breadcrumb. */
39
42
  this.heading = '';
40
- /** One line under the title saying what the page is for, 13px in text-tertiary (owner standard: page description 13). Since 1.6. */
43
+ /**
44
+ * One line under the title saying what the page is for, 13px in text-tertiary (owner standard: page description 13). Since 1.6.
45
+ * On a record page, the record's facts at a glance: "Owner Asha Rao · Created 12 Nov 2026 · Source Website form".
46
+ */
41
47
  this.description = '';
42
48
  /**
43
49
  * Parent pages, outermost first, as `{label, href}`. Don't include the current page.
44
50
  * In HTML pass JSON: `breadcrumbs='[{"label":"Products","href":"/products"}]'`.
45
51
  */
46
52
  this.breadcrumbs = [];
53
+ /**
54
+ * Address of the page this one was opened from (the list of leads, of orders). Shows a back arrow before the title
55
+ * at every width, named "Back to {back-label}". Without it the arrow appears only on narrow screens, for the last
56
+ * breadcrumb with an `href`. Since 1.7.
57
+ */
58
+ this.backHref = '';
59
+ /** Name of the page `back-href` leads to ("Leads"), for the back arrow's accessible name. Since 1.7. */
60
+ this.backLabel = '';
47
61
  /** Shows previous/next arrows for stepping through records (orders, products). */
48
62
  this.pagination = false;
49
63
  /** Enables the previous arrow. */
@@ -53,11 +67,11 @@ export class CmPageHeader extends CmLocalizedElement {
53
67
  }
54
68
  render() {
55
69
  const crumbs = Array.isArray(this.breadcrumbs) ? this.breadcrumbs : [];
56
- const parent = [...crumbs].reverse().find((c) => c.href);
70
+ const parent = this.backHref ? { href: this.backHref, label: this.backLabel } : [...crumbs].reverse().find((c) => c.href);
57
71
  return html `<header part="header">
58
- <div class="lead">
72
+ <div class=${this.description ? 'lead described' : 'lead'}>
59
73
  ${parent
60
- ? html `<a class="back" part="back" href=${parent.href} aria-label=${this.t('back', { label: parent.label })}><cm-icon name="chevron-left" size="20"></cm-icon></a>`
74
+ ? html `<a class=${this.backHref ? 'back always' : 'back'} part="back" href=${parent.href} aria-label=${parent.label ? this.t('back', { label: parent.label }) : this.t('backOnly')}><cm-icon name="chevron-left" size="20"></cm-icon></a>`
61
75
  : nothing}
62
76
  <div class="titles">
63
77
  ${crumbs.length
@@ -89,6 +103,8 @@ CmPageHeader.properties = {
89
103
  heading: {},
90
104
  description: {},
91
105
  breadcrumbs: { type: Array },
106
+ backHref: { attribute: 'back-href' },
107
+ backLabel: { attribute: 'back-label' },
92
108
  pagination: { type: Boolean, reflect: true },
93
109
  hasPrevious: { type: Boolean, attribute: 'has-previous' },
94
110
  hasNext: { type: Boolean, attribute: 'has-next' },
@@ -133,6 +149,7 @@ CmPageHeader.styles = [
133
149
  .arrow:active:not(:disabled), .back:active { background: color-mix(in srgb, var(--cm-bg-hover), var(--cm-text-default) 8%); }
134
150
  .arrow:disabled { color: var(--cm-text-secondary); border-color: var(--cm-border-subtle); cursor: not-allowed; }
135
151
  .back { display: none; border: 0; flex: none; text-decoration: none; }
152
+ .back.always { display: inline-flex; }
136
153
  /* Icon buttons (1.6): 36 x 36, 40 x 40 on touch screens with a 44px hit area. */
137
154
  @media (pointer: coarse) {
138
155
  .arrow, .back { width: var(--cm-control-height-lg, 40px); height: var(--cm-control-height-lg, 40px); }
@@ -142,6 +159,9 @@ CmPageHeader.styles = [
142
159
  /* Title and actions share one row while they fit; otherwise the actions wrap below, so nothing spills sideways. */
143
160
  header { min-height: 48px; padding: var(--cm-space-8) var(--cm-space-16); gap: var(--cm-space-8); }
144
161
  .lead { flex: 1 1 160px; }
162
+ /* With a description (a record's meta line) the title block takes the whole row and the actions go under it,
163
+ so the meta line is not squeezed into a narrow column beside the buttons. Since 1.7. */
164
+ .lead.described { flex-basis: 100%; }
145
165
  .actions { flex: 0 1 auto; min-width: 0; max-width: 100%; justify-content: flex-end; }
146
166
  nav { display: none; }
147
167
  .back { display: inline-flex; }
@@ -70,6 +70,7 @@ export class CmStatusTabs extends CmLocalizedElement {
70
70
  const row = this.renderRoot.querySelector('.tabs');
71
71
  __classPrivateFieldGet(this, _CmStatusTabs_resize, "f").observe(row);
72
72
  row.addEventListener('scroll', () => __classPrivateFieldGet(this, _CmStatusTabs_instances, "m", _CmStatusTabs_measure).call(this), { passive: true });
73
+ document.fonts?.ready.then(() => __classPrivateFieldGet(this, _CmStatusTabs_instances, "m", _CmStatusTabs_measure).call(this));
73
74
  }
74
75
  /** The tabs in use, normalised. */
75
76
  get items() {
@@ -86,8 +87,12 @@ export class CmStatusTabs extends CmLocalizedElement {
86
87
  this.renderRoot.querySelector('button[tabindex="0"]')?.focus(options);
87
88
  }
88
89
  updated(changed) {
89
- if (changed.has('tabs') || changed.has('_slotted') || changed.has('size'))
90
- __classPrivateFieldGet(this, _CmStatusTabs_instances, "m", _CmStatusTabs_measure).call(this);
90
+ // Measure after every render, and watch each tab: counts that arrive later, or the web font finishing loading,
91
+ // widen the tabs without resizing the row, so the row's own resize alone would miss them (issue seen in CRM /v4).
92
+ void changed;
93
+ __classPrivateFieldGet(this, _CmStatusTabs_instances, "m", _CmStatusTabs_measure).call(this);
94
+ for (const b of this.renderRoot.querySelectorAll('.tabs > *'))
95
+ __classPrivateFieldGet(this, _CmStatusTabs_resize, "f").observe(b);
91
96
  if (!('ariaControlsElements' in Element.prototype))
92
97
  return;
93
98
  const root = this.getRootNode();
@@ -2,19 +2,29 @@ import { CmLocalizedElement } from '../localize.js';
2
2
  import './icon.js';
3
3
  export type ToastTone = 'default' | 'critical';
4
4
  export type ToastDismissReason = 'timeout' | 'close' | 'action';
5
+ /** How a toast closed, as `closed` resolves: a dismiss reason, or `removed` when it left the page while open. */
6
+ export type ToastCloseReason = ToastDismissReason | 'removed';
5
7
  declare const regionStrings: {
6
8
  /** Accessible name of the toast region (a live region). */
7
9
  label: string;
8
10
  };
11
+ declare const toastStrings: {
12
+ /** Label of the action that `undoable()` adds. */
13
+ undo: string;
14
+ /** Read after a toast that has an action, in a toast region: how to reach it from the keyboard. Empty: not read. */
15
+ shortcut: string;
16
+ };
9
17
  declare module '../localize.js' {
10
18
  interface CmStrings {
11
19
  toastRegion: typeof regionStrings;
20
+ toast: typeof toastStrings;
12
21
  }
13
22
  }
14
23
  /**
15
24
  * A short confirmation that appears at the bottom of the screen and goes away on its own ("Product saved").
16
25
  * Usually shown with `showToast()`, which puts it in the page's toast region so screen readers announce it.
17
- * Hovering or focusing it pauses the timer.
26
+ * Hovering or focusing it pauses the timer. In a toast region, F6 moves focus to the newest toast's action and back.
27
+ * `closed` resolves with how it closed, so code can wait for an Undo (or for the toast to go).
18
28
  * @element cm-toast
19
29
  * @slot - The message, if not given with `message`.
20
30
  * @fires cm-action - The action button was pressed (cancelable; by default the toast then closes).
@@ -58,6 +68,11 @@ export declare class CmToast extends CmLocalizedElement {
58
68
  _inRegion: boolean;
59
69
  /** Alone, the toast's live region must exist before its text, or screen readers skip the first message. */
60
70
  _primed: boolean;
71
+ /**
72
+ * Resolves when the toast closes (this time it is shown), with the reason: `action` (its action was pressed),
73
+ * `close` (Dismiss, Esc or `open = false`), `timeout`, or `removed` (taken off the page while open, e.g. pushed out by newer toasts).
74
+ */
75
+ get closed(): Promise<ToastCloseReason>;
61
76
  static styles: import("lit").CSSResult[];
62
77
  /** The time the toast stays, clamped to 2000–10000 ms. */
63
78
  get effectiveDuration(): number;
@@ -73,6 +88,8 @@ export declare class CmToast extends CmLocalizedElement {
73
88
  /**
74
89
  * The page's toast area: bottom centre, above everything, a polite live region so new toasts are announced.
75
90
  * `showToast()` creates one when needed; add it yourself only to change where toasts appear.
91
+ * Keyboard: F6 (or Shift+F6) moves focus to the newest toast with an action (else the newest toast) and, pressed
92
+ * again, back to where it was; Esc closes the focused toast. When a focused toast closes, focus goes back too.
76
93
  * @element cm-toast-region
77
94
  * @slot - `cm-toast` elements. Closed toasts are removed.
78
95
  */
@@ -89,6 +106,11 @@ export declare class CmToastRegion extends CmLocalizedElement {
89
106
  connectedCallback(): void;
90
107
  disconnectedCallback(): void;
91
108
  updated(): void;
109
+ /**
110
+ * Moves focus to the newest open toast with an action (else the newest toast): its action, or its Dismiss button.
111
+ * F6 does this; call it to offer another shortcut. Returns false when there is no toast to focus.
112
+ */
113
+ focusToast(): boolean;
92
114
  /** Adds a toast, removing the oldest ones above `max`. */
93
115
  add(toast: CmToast): CmToast;
94
116
  render(): import("lit-html").TemplateResult<1>;
@@ -107,9 +129,24 @@ export interface ShowToastOptions {
107
129
  }
108
130
  /**
109
131
  * Shows a toast in the page's toast region (created on first use) and returns it. The message is text, never HTML.
132
+ * The returned toast is the handle: `toast.dismiss()` closes it, and `await toast.closed` gives how it closed
133
+ * (`action`, `timeout`, `close` or `removed`).
110
134
  * @example showToast('Product saved'); showToast('Order archived', { action: { label: 'Undo', onAction: undo } });
111
135
  */
112
136
  export declare function showToast(message: string, options?: ShowToastOptions): CmToast;
137
+ export interface UndoableOptions extends Omit<ShowToastOptions, 'action'> {
138
+ /** What just happened, in the past tense: "Lead archived". */
139
+ message: string;
140
+ /** Label of the action. Default: the built-in string `toast.undo` ("Undo"). */
141
+ undoLabel?: string;
142
+ }
143
+ /**
144
+ * Undo instead of confirm: runs `doIt` at once, then shows `message` in a toast with Undo, and runs `undoIt` if Undo
145
+ * is pressed. Resolves with how the toast closed once that is known (`action` only after `undoIt` has finished), so
146
+ * a caller can, say, really delete a record only on `timeout`. If `doIt` throws, no toast is shown and the promise rejects.
147
+ * @example await undoable(() => api.archive(lead), () => api.unarchive(lead), { message: 'Lead archived' });
148
+ */
149
+ export declare function undoable(doIt: () => unknown, undoIt: () => unknown, options: UndoableOptions): Promise<ToastCloseReason>;
113
150
  declare global {
114
151
  interface HTMLElementTagNameMap {
115
152
  'cm-toast': CmToast;