@commmerce/ui 0.0.0-stage → 1.0.0-rc.3

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.
Files changed (125) hide show
  1. package/LICENSE.md +17 -0
  2. package/README.md +41 -2
  3. package/dist/base.d.ts +7 -0
  4. package/dist/base.js +22 -0
  5. package/dist/cdn.js +1958 -0
  6. package/dist/components/accordion.d.ts +43 -0
  7. package/dist/components/accordion.js +83 -0
  8. package/dist/components/action-bar.d.ts +42 -0
  9. package/dist/components/action-bar.js +84 -0
  10. package/dist/components/action-menu.d.ts +89 -0
  11. package/dist/components/action-menu.js +283 -0
  12. package/dist/components/app-card.d.ts +57 -0
  13. package/dist/components/app-card.js +100 -0
  14. package/dist/components/avatar.d.ts +48 -0
  15. package/dist/components/avatar.js +82 -0
  16. package/dist/components/badge.d.ts +23 -0
  17. package/dist/components/badge.js +35 -0
  18. package/dist/components/banner.d.ts +36 -0
  19. package/dist/components/banner.js +88 -0
  20. package/dist/components/bottom-navigation.d.ts +48 -0
  21. package/dist/components/bottom-navigation.js +98 -0
  22. package/dist/components/bottom-sheet.d.ts +54 -0
  23. package/dist/components/bottom-sheet.js +133 -0
  24. package/dist/components/button.d.ts +53 -0
  25. package/dist/components/button.js +101 -0
  26. package/dist/components/card.d.ts +37 -0
  27. package/dist/components/card.js +58 -0
  28. package/dist/components/checkbox.d.ts +68 -0
  29. package/dist/components/checkbox.js +114 -0
  30. package/dist/components/comment.d.ts +76 -0
  31. package/dist/components/comment.js +170 -0
  32. package/dist/components/data-table.d.ts +132 -0
  33. package/dist/components/data-table.js +331 -0
  34. package/dist/components/empty-state.d.ts +49 -0
  35. package/dist/components/empty-state.js +94 -0
  36. package/dist/components/file-upload.d.ts +102 -0
  37. package/dist/components/file-upload.js +243 -0
  38. package/dist/components/filter-panel.d.ts +86 -0
  39. package/dist/components/filter-panel.js +128 -0
  40. package/dist/components/flash-offer-bar.d.ts +34 -0
  41. package/dist/components/flash-offer-bar.js +73 -0
  42. package/dist/components/grid.d.ts +39 -0
  43. package/dist/components/grid.js +42 -0
  44. package/dist/components/header-bar.d.ts +48 -0
  45. package/dist/components/header-bar.js +121 -0
  46. package/dist/components/icon.d.ts +30 -0
  47. package/dist/components/icon.js +36 -0
  48. package/dist/components/info-panel.d.ts +63 -0
  49. package/dist/components/info-panel.js +108 -0
  50. package/dist/components/layout.d.ts +45 -0
  51. package/dist/components/layout.js +67 -0
  52. package/dist/components/link-tabs.d.ts +40 -0
  53. package/dist/components/link-tabs.js +85 -0
  54. package/dist/components/menu-item.d.ts +68 -0
  55. package/dist/components/menu-item.js +64 -0
  56. package/dist/components/mobile-menu.d.ts +69 -0
  57. package/dist/components/mobile-menu.js +184 -0
  58. package/dist/components/modal.d.ts +46 -0
  59. package/dist/components/modal.js +59 -0
  60. package/dist/components/nav-item.d.ts +98 -0
  61. package/dist/components/nav-item.js +84 -0
  62. package/dist/components/nested-list.d.ts +105 -0
  63. package/dist/components/nested-list.js +279 -0
  64. package/dist/components/notification-panel.d.ts +121 -0
  65. package/dist/components/notification-panel.js +174 -0
  66. package/dist/components/option-group.d.ts +74 -0
  67. package/dist/components/option-group.js +172 -0
  68. package/dist/components/page-header.d.ts +58 -0
  69. package/dist/components/page-header.js +121 -0
  70. package/dist/components/page.d.ts +34 -0
  71. package/dist/components/page.js +41 -0
  72. package/dist/components/pagination.d.ts +64 -0
  73. package/dist/components/pagination.js +160 -0
  74. package/dist/components/progress-bar.d.ts +45 -0
  75. package/dist/components/progress-bar.js +81 -0
  76. package/dist/components/radio.d.ts +131 -0
  77. package/dist/components/radio.js +252 -0
  78. package/dist/components/report-tile.d.ts +65 -0
  79. package/dist/components/report-tile.js +112 -0
  80. package/dist/components/resource-list.d.ts +143 -0
  81. package/dist/components/resource-list.js +335 -0
  82. package/dist/components/save-bar.d.ts +58 -0
  83. package/dist/components/save-bar.js +128 -0
  84. package/dist/components/search.d.ts +78 -0
  85. package/dist/components/search.js +144 -0
  86. package/dist/components/select.d.ts +106 -0
  87. package/dist/components/select.js +338 -0
  88. package/dist/components/side-navigation.d.ts +51 -0
  89. package/dist/components/side-navigation.js +194 -0
  90. package/dist/components/side-panel.d.ts +50 -0
  91. package/dist/components/side-panel.js +73 -0
  92. package/dist/components/skeleton-display.d.ts +32 -0
  93. package/dist/components/skeleton-display.js +70 -0
  94. package/dist/components/skeleton.d.ts +41 -0
  95. package/dist/components/skeleton.js +59 -0
  96. package/dist/components/smart-tip.d.ts +62 -0
  97. package/dist/components/smart-tip.js +128 -0
  98. package/dist/components/spinner.d.ts +27 -0
  99. package/dist/components/spinner.js +48 -0
  100. package/dist/components/stack.d.ts +45 -0
  101. package/dist/components/stack.js +49 -0
  102. package/dist/components/status-tabs.d.ts +65 -0
  103. package/dist/components/status-tabs.js +158 -0
  104. package/dist/components/table-header.d.ts +84 -0
  105. package/dist/components/table-header.js +151 -0
  106. package/dist/components/tag.d.ts +39 -0
  107. package/dist/components/tag.js +68 -0
  108. package/dist/components/text-field.d.ts +101 -0
  109. package/dist/components/text-field.js +162 -0
  110. package/dist/components/thumbnail.d.ts +40 -0
  111. package/dist/components/thumbnail.js +61 -0
  112. package/dist/components/toast.d.ts +108 -0
  113. package/dist/components/toast.js +268 -0
  114. package/dist/components/toggle.d.ts +60 -0
  115. package/dist/components/toggle.js +108 -0
  116. package/dist/components/tooltip.d.ts +56 -0
  117. package/dist/components/tooltip.js +267 -0
  118. package/dist/custom-elements.json +13222 -0
  119. package/dist/index.d.ts +70 -0
  120. package/dist/index.js +56 -0
  121. package/dist/overlay.d.ts +57 -0
  122. package/dist/overlay.js +205 -0
  123. package/dist/spacing.d.ts +6 -0
  124. package/dist/spacing.js +7 -0
  125. package/package.json +59 -4
@@ -0,0 +1,68 @@
1
+ import { LitElement } from 'lit';
2
+ import type { IconName } from '@commmerce/icons';
3
+ /** One choice in a `cm-action-menu` or `cm-bottom-sheet`. `{ divider: true }` draws a line between groups. */
4
+ export interface MenuItem {
5
+ /** Visible text. */
6
+ label?: string;
7
+ /** Identifies the choice in `cm-select`. Defaults to the label. */
8
+ value?: string;
9
+ /** Icon from @commmerce/icons, before the label. */
10
+ icon?: IconName | string;
11
+ /** Makes the choice a link. */
12
+ href?: string;
13
+ /** Can't be chosen right now. */
14
+ disabled?: boolean;
15
+ /** A destructive choice, e.g. "Delete store". Shown in the critical colour. */
16
+ critical?: boolean;
17
+ /** A separator line instead of a choice. */
18
+ divider?: boolean;
19
+ }
20
+ /**
21
+ * A choice described in markup, read by `cm-action-menu` and `cm-bottom-sheet`. It renders nothing itself.
22
+ * Its text is the label. An `<hr>` between items draws a separator.
23
+ * @element cm-menu-item
24
+ */
25
+ export declare class CmMenuItem extends LitElement {
26
+ static properties: {
27
+ value: {
28
+ reflect: boolean;
29
+ };
30
+ icon: {
31
+ reflect: boolean;
32
+ };
33
+ href: {
34
+ reflect: boolean;
35
+ };
36
+ disabled: {
37
+ type: BooleanConstructor;
38
+ reflect: boolean;
39
+ };
40
+ critical: {
41
+ type: BooleanConstructor;
42
+ reflect: boolean;
43
+ };
44
+ };
45
+ /** Identifies the choice in `cm-select`. Defaults to the text. */
46
+ value: string;
47
+ /** Icon from @commmerce/icons, before the label. */
48
+ icon: string;
49
+ /** Makes the choice a link. */
50
+ href: string;
51
+ /** Can't be chosen right now. */
52
+ disabled: boolean;
53
+ /** A destructive choice, shown in the critical colour. */
54
+ critical: boolean;
55
+ static styles: import("lit").CSSResult;
56
+ render(): null;
57
+ /** The item as data. */
58
+ toItem(): MenuItem;
59
+ }
60
+ /** Reads `cm-menu-item` and `hr` children of a host into data. */
61
+ export declare function readMenuItems(host: Element): MenuItem[];
62
+ /** Calls back when `cm-menu-item` children or their attributes and text change. */
63
+ export declare function watchMenuItems(host: Element, cb: () => void): MutationObserver;
64
+ declare global {
65
+ interface HTMLElementTagNameMap {
66
+ 'cm-menu-item': CmMenuItem;
67
+ }
68
+ }
@@ -0,0 +1,64 @@
1
+ import { LitElement, css } from 'lit';
2
+ import { define } from '../base.js';
3
+ /**
4
+ * A choice described in markup, read by `cm-action-menu` and `cm-bottom-sheet`. It renders nothing itself.
5
+ * Its text is the label. An `<hr>` between items draws a separator.
6
+ * @element cm-menu-item
7
+ */
8
+ export class CmMenuItem extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ /** Identifies the choice in `cm-select`. Defaults to the text. */
12
+ this.value = '';
13
+ /** Icon from @commmerce/icons, before the label. */
14
+ this.icon = '';
15
+ /** Makes the choice a link. */
16
+ this.href = '';
17
+ /** Can't be chosen right now. */
18
+ this.disabled = false;
19
+ /** A destructive choice, shown in the critical colour. */
20
+ this.critical = false;
21
+ }
22
+ render() { return null; }
23
+ /** The item as data. */
24
+ toItem() {
25
+ const label = (this.textContent ?? '').trim();
26
+ return {
27
+ label, value: this.value || label, icon: this.icon || undefined, href: this.href || undefined,
28
+ disabled: this.disabled || undefined, critical: this.critical || undefined,
29
+ };
30
+ }
31
+ }
32
+ CmMenuItem.properties = {
33
+ value: { reflect: true },
34
+ icon: { reflect: true },
35
+ href: { reflect: true },
36
+ disabled: { type: Boolean, reflect: true },
37
+ critical: { type: Boolean, reflect: true },
38
+ };
39
+ CmMenuItem.styles = css `:host { display: none; }`;
40
+ define('cm-menu-item', CmMenuItem);
41
+ /** Reads `cm-menu-item` and `hr` children of a host into data. */
42
+ export function readMenuItems(host) {
43
+ const out = [];
44
+ for (const c of Array.from(host.children)) {
45
+ // Attributes, not properties: children may not be upgraded yet when the parent first reads them.
46
+ if (c.localName === 'cm-menu-item') {
47
+ const label = (c.textContent ?? '').trim();
48
+ const a = (n) => c.getAttribute(n) || undefined;
49
+ out.push({
50
+ label, value: a('value') ?? label, icon: a('icon'), href: a('href'),
51
+ disabled: c.hasAttribute('disabled') || undefined, critical: c.hasAttribute('critical') || undefined,
52
+ });
53
+ }
54
+ else if (c.localName === 'hr')
55
+ out.push({ divider: true });
56
+ }
57
+ return out;
58
+ }
59
+ /** Calls back when `cm-menu-item` children or their attributes and text change. */
60
+ export function watchMenuItems(host, cb) {
61
+ const mo = new MutationObserver(cb);
62
+ mo.observe(host, { childList: true, subtree: true, attributes: true, characterData: true });
63
+ return mo;
64
+ }
@@ -0,0 +1,69 @@
1
+ import { LitElement } from 'lit';
2
+ import { type NavItem } from './nav-item.js';
3
+ import './icon.js';
4
+ /**
5
+ * The admin's full menu on phones, opened from "More" in the Bottom navigation. A grey page of white
6
+ * rounded cards: the store and the signed-in user first, then labelled sections of rows. Rows with
7
+ * sub-items open them on a second screen with a back button. For Commmerce products only, not for apps.
8
+ *
9
+ * Top-level `cm-nav-item`s are sections (their `label` is the heading; leave it empty for a card without
10
+ * one). Their children are rows. A child marked `primary` is the section's action, e.g. "Add channel".
11
+ * @element cm-mobile-menu
12
+ * @slot - `cm-nav-item` sections, each holding row items.
13
+ * @fires cm-navigate - When a row is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app.
14
+ * @fires cm-store-switch - When the store card is pressed.
15
+ * @fires cm-account - When the user row is pressed.
16
+ */
17
+ export declare class CmMobileMenu extends LitElement {
18
+ #private;
19
+ static properties: {
20
+ items: {
21
+ type: ArrayConstructor;
22
+ };
23
+ store: {};
24
+ userName: {
25
+ attribute: string;
26
+ };
27
+ userEmail: {
28
+ attribute: string;
29
+ };
30
+ avatarSrc: {
31
+ attribute: string;
32
+ };
33
+ label: {};
34
+ _slotted: {
35
+ state: boolean;
36
+ };
37
+ _page: {
38
+ state: boolean;
39
+ };
40
+ };
41
+ /** Sections as data: `[{ label: 'Panels', items: [{ label: 'Reports', icon: 'chart', href }] }]`. Used instead of children when set. */
42
+ items: NavItem[];
43
+ /** Store the merchant is signed in to. Empty hides the store row. */
44
+ store: string;
45
+ /** Signed-in user's name. Empty hides the user row. */
46
+ userName: string;
47
+ /** Signed-in user's email, under the name. */
48
+ userEmail: string;
49
+ /** Avatar image URL. Without it, the first letter of the name is shown. */
50
+ avatarSrc: string;
51
+ /** Accessible name of the navigation landmark. */
52
+ label: string;
53
+ _slotted: NavItem[];
54
+ /** Path of the open sub-page as [section, row], or null on the main page. */
55
+ _page: [number, number] | null;
56
+ static styles: import("lit").CSSResult[];
57
+ connectedCallback(): void;
58
+ disconnectedCallback(): void;
59
+ /** The sections in use. */
60
+ get sections(): NavItem[];
61
+ /** Returns to the main page from a sub-page. */
62
+ back(): void;
63
+ render(): import("lit-html").TemplateResult<1>;
64
+ }
65
+ declare global {
66
+ interface HTMLElementTagNameMap {
67
+ 'cm-mobile-menu': CmMobileMenu;
68
+ }
69
+ }
@@ -0,0 +1,184 @@
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 _CmMobileMenu_instances, _CmMobileMenu_observer, _CmMobileMenu_id, _CmMobileMenu_read, _CmMobileMenu_open, _CmMobileMenu_fire, _CmMobileMenu_row, _CmMobileMenu_profile;
13
+ import { LitElement, html, css, nothing } from 'lit';
14
+ import { base, define, nextId } from '../base.js';
15
+ import { readNavItems, watchNavItems, fireNavigate } from './nav-item.js';
16
+ import './icon.js';
17
+ /**
18
+ * The admin's full menu on phones, opened from "More" in the Bottom navigation. A grey page of white
19
+ * rounded cards: the store and the signed-in user first, then labelled sections of rows. Rows with
20
+ * sub-items open them on a second screen with a back button. For Commmerce products only, not for apps.
21
+ *
22
+ * Top-level `cm-nav-item`s are sections (their `label` is the heading; leave it empty for a card without
23
+ * one). Their children are rows. A child marked `primary` is the section's action, e.g. "Add channel".
24
+ * @element cm-mobile-menu
25
+ * @slot - `cm-nav-item` sections, each holding row items.
26
+ * @fires cm-navigate - When a row is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app.
27
+ * @fires cm-store-switch - When the store card is pressed.
28
+ * @fires cm-account - When the user row is pressed.
29
+ */
30
+ export class CmMobileMenu extends LitElement {
31
+ constructor() {
32
+ super(...arguments);
33
+ _CmMobileMenu_instances.add(this);
34
+ /** Sections as data: `[{ label: 'Panels', items: [{ label: 'Reports', icon: 'chart', href }] }]`. Used instead of children when set. */
35
+ this.items = [];
36
+ /** Store the merchant is signed in to. Empty hides the store row. */
37
+ this.store = '';
38
+ /** Signed-in user's name. Empty hides the user row. */
39
+ this.userName = '';
40
+ /** Signed-in user's email, under the name. */
41
+ this.userEmail = '';
42
+ /** Avatar image URL. Without it, the first letter of the name is shown. */
43
+ this.avatarSrc = '';
44
+ /** Accessible name of the navigation landmark. */
45
+ this.label = 'Menu';
46
+ this._slotted = [];
47
+ /** Path of the open sub-page as [section, row], or null on the main page. */
48
+ this._page = null;
49
+ _CmMobileMenu_observer.set(this, void 0);
50
+ _CmMobileMenu_id.set(this, nextId('cm-mmenu'));
51
+ }
52
+ connectedCallback() {
53
+ super.connectedCallback();
54
+ __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_read).call(this);
55
+ __classPrivateFieldSet(this, _CmMobileMenu_observer, watchNavItems(this, () => __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_read).call(this)), "f");
56
+ }
57
+ disconnectedCallback() {
58
+ super.disconnectedCallback();
59
+ __classPrivateFieldGet(this, _CmMobileMenu_observer, "f")?.disconnect();
60
+ }
61
+ /** The sections in use. */
62
+ get sections() { return this.items.length ? this.items : this._slotted; }
63
+ /** Returns to the main page from a sub-page. */
64
+ back() {
65
+ if (!this._page)
66
+ return;
67
+ const [s, r] = this._page;
68
+ this._page = null;
69
+ this.updateComplete.then(() => this.renderRoot.querySelector(`[data-row="${s}-${r}"]`)?.focus());
70
+ }
71
+ render() {
72
+ const secs = this.sections;
73
+ const page = this._page ? secs[this._page[0]]?.items?.[this._page[1]] : undefined;
74
+ if (page) {
75
+ return html `<nav part="nav" class="sub" aria-label=${this.label || 'Menu'} id="${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-sub"
76
+ @keydown=${(e) => { if (e.key === 'Escape') {
77
+ e.preventDefault();
78
+ this.back();
79
+ } }}>
80
+ <button type="button" class="back" part="back" @click=${() => this.back()}><cm-icon name="arrow-left" size="18"></cm-icon>${page.label}</button>
81
+ <ul class="card" aria-label=${page.label}>${page.items.map((it) => html `<li>${__classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_row).call(this, it, 0, 0, true)}</li>`)}</ul>
82
+ <slot hidden></slot>
83
+ </nav>`;
84
+ }
85
+ return html `<nav part="nav" aria-label=${this.label || 'Menu'}>
86
+ ${__classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_profile).call(this)}
87
+ ${secs.map((sec, s) => {
88
+ const hid = `${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-s${s}`;
89
+ return html `<section aria-labelledby=${sec.label ? hid : nothing}>
90
+ ${sec.label ? html `<h2 class="heading" id=${hid}>${sec.label}</h2>` : nothing}
91
+ <ul class="card">${(sec.items ?? []).map((it, r) => html `<li>${__classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_row).call(this, it, s, r)}</li>`)}</ul>
92
+ </section>`;
93
+ })}
94
+ <slot hidden></slot>
95
+ </nav>`;
96
+ }
97
+ }
98
+ _CmMobileMenu_observer = new WeakMap(), _CmMobileMenu_id = new WeakMap(), _CmMobileMenu_instances = new WeakSet(), _CmMobileMenu_read = function _CmMobileMenu_read() { this._slotted = readNavItems(this); }, _CmMobileMenu_open = function _CmMobileMenu_open(s, r) {
99
+ this._page = [s, r];
100
+ this.updateComplete.then(() => this.renderRoot.querySelector('.back')?.focus());
101
+ }, _CmMobileMenu_fire = function _CmMobileMenu_fire(name) { this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true })); }, _CmMobileMenu_row = function _CmMobileMenu_row(it, s, r, sub = false) {
102
+ const go = (e) => { if (!fireNavigate(this, it))
103
+ e.preventDefault(); };
104
+ if (it.primary && !sub)
105
+ return html `<button type="button" class="row action" part="row" @click=${go}>${it.label}</button>`;
106
+ const icon = it.icon && !sub ? html `<cm-icon class="icon" name=${it.icon} size="24"></cm-icon>` : nothing;
107
+ const badge = it.badge ? html `<span class="badge">${it.badge}</span>` : nothing;
108
+ if (it.items?.length && !sub) {
109
+ return html `<button type="button" class="row" part="row" data-row="${s}-${r}"
110
+ @click=${() => __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_open).call(this, s, r)}>${icon}<span class="label">${it.label}</span>${badge}<cm-icon class="chev" name="chevron-right" size="16"></cm-icon></button>`;
111
+ }
112
+ const inner = html `${icon}<span class="label">${it.label}</span>${badge}${it.href && !sub ? html `<cm-icon class="chev" name="chevron-right" size="16"></cm-icon>` : nothing}`;
113
+ return it.href
114
+ ? html `<a class="row" part="row" href=${it.href} aria-current=${it.current ? 'page' : nothing} @click=${go}>${inner}</a>`
115
+ : html `<button type="button" class="row" part="row" aria-current=${it.current ? 'page' : nothing} @click=${go}>${inner}</button>`;
116
+ }, _CmMobileMenu_profile = function _CmMobileMenu_profile() {
117
+ if (!this.store && !this.userName)
118
+ return nothing;
119
+ const initial = this.userName.trim().charAt(0).toUpperCase();
120
+ return html `<section aria-labelledby="${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-profile">
121
+ <h2 class="heading" id="${__classPrivateFieldGet(this, _CmMobileMenu_id, "f")}-profile">Profile</h2>
122
+ <ul class="card">
123
+ ${this.store ? html `<li><button type="button" class="row" part="row" @click=${() => __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_fire).call(this, 'cm-store-switch')}>
124
+ <span class="stack"><span class="eyebrow">Logged in to store</span><span>${this.store}</span></span>
125
+ <cm-icon class="chev" name="chevron-right" size="16"></cm-icon></button></li>` : nothing}
126
+ ${this.userName ? html `<li><button type="button" class="row" part="row" @click=${() => __classPrivateFieldGet(this, _CmMobileMenu_instances, "m", _CmMobileMenu_fire).call(this, 'cm-account')}>
127
+ <span class="avatar">${this.avatarSrc ? html `<img src=${this.avatarSrc} alt="">` : html `<span aria-hidden="true">${initial}</span>`}</span>
128
+ <span class="stack"><span>${this.userName}</span>${this.userEmail ? html `<span class="email">${this.userEmail}</span>` : nothing}</span>
129
+ <cm-icon class="chev" name="chevron-right" size="16"></cm-icon></button></li>` : nothing}
130
+ </ul>
131
+ </section>`;
132
+ };
133
+ CmMobileMenu.properties = {
134
+ items: { type: Array },
135
+ store: {},
136
+ userName: { attribute: 'user-name' },
137
+ userEmail: { attribute: 'user-email' },
138
+ avatarSrc: { attribute: 'avatar-src' },
139
+ label: {},
140
+ _slotted: { state: true },
141
+ _page: { state: true },
142
+ };
143
+ CmMobileMenu.styles = [
144
+ base,
145
+ css `
146
+ :host { display: block; background: var(--cm-bg-page); }
147
+ nav { padding: var(--cm-space-20); display: flex; flex-direction: column; gap: var(--cm-space-20); }
148
+ .heading {
149
+ margin: 0 0 8px; font-size: 12px; font-weight: 500; letter-spacing: var(--cm-tracking-caps); text-transform: uppercase;
150
+ color: var(--cm-text-default);
151
+ }
152
+ .card { list-style: none; margin: 0; padding: 0 15px; background: var(--cm-bg-surface); border-radius: 12px; }
153
+ .card > li + li { border-top: var(--cm-border-1) solid var(--cm-border-default); }
154
+ .row {
155
+ display: flex; align-items: center; gap: var(--cm-space-15); width: 100%; min-height: 51px; padding: 8px 4px 8px 6px;
156
+ font: inherit; font-size: 18px; font-weight: 500; color: var(--cm-text-default); text-align: start; text-decoration: none;
157
+ background: none; border: 0; cursor: pointer;
158
+ }
159
+ .row:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: -2px; border-radius: var(--cm-radius-sm); }
160
+ .row .icon { color: var(--cm-icon-responsive-menu); }
161
+ .label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
162
+ .chev { color: var(--cm-icon-selected); }
163
+ .badge {
164
+ flex: none; padding: 5px 10px; border-radius: var(--cm-radius-full); font-size: 10px; font-weight: 500;
165
+ letter-spacing: var(--cm-tracking-caps); text-transform: uppercase; color: var(--cm-text-on-dark); background: var(--cm-nav-badge);
166
+ }
167
+ .action { justify-content: center; min-height: 40px; font-size: 12px; letter-spacing: var(--cm-tracking-caps); text-transform: uppercase; }
168
+ .eyebrow { display: block; font-size: 12px; letter-spacing: var(--cm-tracking-caps); text-transform: uppercase; color: var(--cm-text-tertiary); }
169
+ .stack { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
170
+ .email { font-size: 12px; font-weight: 400; }
171
+ .avatar {
172
+ display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
173
+ font-size: 12px; background: var(--cm-avatar-bg); border: var(--cm-border-1) solid var(--cm-border-strong); color: var(--cm-text-default);
174
+ }
175
+ .avatar img { width: 100%; height: 100%; object-fit: cover; }
176
+ .back {
177
+ display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; padding: 6px 4px; font: inherit; font-size: 16px; font-weight: 500;
178
+ color: var(--cm-text-default); background: none; border: 0; cursor: pointer; border-radius: var(--cm-radius-sm);
179
+ }
180
+ .back:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
181
+ .sub .row { font-size: 16px; min-height: 48px; }
182
+ `,
183
+ ];
184
+ define('cm-mobile-menu', CmMobileMenu);
@@ -0,0 +1,46 @@
1
+ import { CmOverlay } from '../overlay.js';
2
+ /**
3
+ * A dialog over the page for a short task or a decision that must be made before going on: confirming a
4
+ * deletion, editing one field, picking from a short list. A black header with the title and a close button,
5
+ * the content, and the actions in a footer.
6
+ *
7
+ * Built on the native `<dialog>`: the page behind is inert (focus stays in the modal), Esc and a click on the
8
+ * backdrop ask to close through `cm-close`, page scrolling is locked, and focus returns to the opener.
9
+ * @element cm-modal
10
+ * @slot - The content.
11
+ * @slot footer - Actions, right-aligned: the main action last. Usually `cm-button`s.
12
+ * @fires cm-open - After the modal opens.
13
+ * @fires cm-close - Before it closes from Esc, the backdrop or the close button. `detail: { reason }`. Cancelable: call `preventDefault()` to keep it open (e.g. unsaved changes).
14
+ * @fires cm-closed - After it has closed and focus has gone back.
15
+ */
16
+ export declare class CmModal extends CmOverlay {
17
+ #private;
18
+ static properties: {
19
+ size: {
20
+ reflect: boolean;
21
+ };
22
+ _hasFooter: {
23
+ state: boolean;
24
+ };
25
+ open: {
26
+ type: BooleanConstructor;
27
+ reflect: boolean;
28
+ };
29
+ heading: {};
30
+ label: {};
31
+ closeLabel: {
32
+ attribute: string;
33
+ };
34
+ };
35
+ /** Width: `small` (400px, confirmations), `medium` (620px, default) or `large` (900px, lists and tables). Never wider than the screen. */
36
+ size: 'small' | 'medium' | 'large';
37
+ _hasFooter: boolean;
38
+ connectedCallback(): void;
39
+ static styles: import("lit").CSSResult[];
40
+ render(): import("lit-html").TemplateResult<1>;
41
+ }
42
+ declare global {
43
+ interface HTMLElementTagNameMap {
44
+ 'cm-modal': CmModal;
45
+ }
46
+ }
@@ -0,0 +1,59 @@
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 _CmModal_instances, _CmModal_slot;
7
+ import { html, css } from 'lit';
8
+ import { define } from '../base.js';
9
+ import { CmOverlay } from '../overlay.js';
10
+ /**
11
+ * A dialog over the page for a short task or a decision that must be made before going on: confirming a
12
+ * deletion, editing one field, picking from a short list. A black header with the title and a close button,
13
+ * the content, and the actions in a footer.
14
+ *
15
+ * Built on the native `<dialog>`: the page behind is inert (focus stays in the modal), Esc and a click on the
16
+ * backdrop ask to close through `cm-close`, page scrolling is locked, and focus returns to the opener.
17
+ * @element cm-modal
18
+ * @slot - The content.
19
+ * @slot footer - Actions, right-aligned: the main action last. Usually `cm-button`s.
20
+ * @fires cm-open - After the modal opens.
21
+ * @fires cm-close - Before it closes from Esc, the backdrop or the close button. `detail: { reason }`. Cancelable: call `preventDefault()` to keep it open (e.g. unsaved changes).
22
+ * @fires cm-closed - After it has closed and focus has gone back.
23
+ */
24
+ export class CmModal extends CmOverlay {
25
+ constructor() {
26
+ super(...arguments);
27
+ _CmModal_instances.add(this);
28
+ /** Width: `small` (400px, confirmations), `medium` (620px, default) or `large` (900px, lists and tables). Never wider than the screen. */
29
+ this.size = 'medium';
30
+ this._hasFooter = false;
31
+ }
32
+ connectedCallback() {
33
+ super.connectedCallback();
34
+ this._hasFooter = !!this.querySelector(':scope > [slot="footer"]');
35
+ }
36
+ render() {
37
+ return this.renderDialog(html `<div class="panel" part="panel" tabindex="-1">
38
+ ${this.renderHeader()}
39
+ <div class="body" part="body"><slot></slot></div>
40
+ <footer class="foot" part="footer" ?hidden=${!this._hasFooter}><slot name="footer" @slotchange=${__classPrivateFieldGet(this, _CmModal_instances, "m", _CmModal_slot)}></slot></footer>
41
+ </div>`);
42
+ }
43
+ }
44
+ _CmModal_instances = new WeakSet(), _CmModal_slot = function _CmModal_slot(e) { this._hasFooter = e.target.assignedElements().length > 0; };
45
+ CmModal.properties = {
46
+ ...CmOverlay.properties,
47
+ size: { reflect: true },
48
+ _hasFooter: { state: true },
49
+ };
50
+ CmModal.styles = [
51
+ ...CmOverlay.overlayStyles,
52
+ css `
53
+ dialog { position: fixed; inset: 0; margin: auto; width: min(var(--cm-modal-width, 620px), calc(100vw - 32px)); }
54
+ :host([size='small']) dialog { --cm-modal-width: 400px; }
55
+ :host([size='large']) dialog { --cm-modal-width: 900px; }
56
+ .panel { max-height: calc(100dvh - 64px); border-radius: var(--cm-radius-sm); box-shadow: var(--cm-shadow-100); }
57
+ `,
58
+ ];
59
+ define('cm-modal', CmModal);
@@ -0,0 +1,98 @@
1
+ import { LitElement } from 'lit';
2
+ import type { IconName } from '@commmerce/icons';
3
+ /** One navigation destination, used by `cm-side-navigation`, `cm-mobile-menu` and `cm-bottom-navigation`. */
4
+ export interface NavItem {
5
+ /** Visible text. */
6
+ label: string;
7
+ /** Icon from @commmerce/icons, shown before the label. */
8
+ icon?: IconName | string;
9
+ /** Where the item goes. Items with children and no `href` are buttons that show and hide the children. */
10
+ href?: string;
11
+ /** Identifies the item in `cm-navigate` handlers. Defaults to the `href`, then the label. */
12
+ value?: string;
13
+ /** Marks the page the merchant is on (`aria-current="page"`). */
14
+ current?: boolean;
15
+ /** Short text after the label, e.g. "New". */
16
+ badge?: string;
17
+ /** Children start open. A parent of the current item opens on its own. */
18
+ expanded?: boolean;
19
+ /** Bottom navigation only: draws the icon as a black square, for the one main action (Quick add). */
20
+ primary?: boolean;
21
+ /** Sub-items. Side navigation shows one level; deeper levels are flattened into it. */
22
+ items?: NavItem[];
23
+ }
24
+ /**
25
+ * A navigation destination described in markup. It renders nothing itself: the navigation that contains it
26
+ * reads its attributes and children. Nest `cm-nav-item`s to make sub-items.
27
+ * @element cm-nav-item
28
+ * @slot - Child `cm-nav-item`s (sub-items).
29
+ */
30
+ export declare class CmNavItem extends LitElement {
31
+ static properties: {
32
+ label: {
33
+ reflect: boolean;
34
+ };
35
+ icon: {
36
+ reflect: boolean;
37
+ };
38
+ href: {
39
+ reflect: boolean;
40
+ };
41
+ value: {
42
+ reflect: boolean;
43
+ };
44
+ current: {
45
+ type: BooleanConstructor;
46
+ reflect: boolean;
47
+ };
48
+ badge: {
49
+ reflect: boolean;
50
+ };
51
+ expanded: {
52
+ type: BooleanConstructor;
53
+ reflect: boolean;
54
+ };
55
+ primary: {
56
+ type: BooleanConstructor;
57
+ reflect: boolean;
58
+ };
59
+ };
60
+ /** Visible text. */
61
+ label: string;
62
+ /** Icon from @commmerce/icons. */
63
+ icon: string;
64
+ /** Where the item goes. Leave empty on a parent that only opens its sub-items. */
65
+ href: string;
66
+ /** Identifies the item in `cm-navigate` handlers. */
67
+ value: string;
68
+ /** The page the merchant is on. */
69
+ current: boolean;
70
+ /** Short text after the label, e.g. "New". */
71
+ badge: string;
72
+ /** Sub-items start open. */
73
+ expanded: boolean;
74
+ /** Bottom navigation only: the one main action, drawn as a black square (Quick add). */
75
+ primary: boolean;
76
+ static styles: import("lit").CSSResult;
77
+ render(): null;
78
+ /** This item and its sub-items as plain data. */
79
+ toItem(): NavItem;
80
+ }
81
+ /** Reads the direct `cm-nav-item` children of `host` as data. */
82
+ export declare const readNavItems: (host: Element) => NavItem[];
83
+ /** The value a `cm-navigate` handler sees for an item. */
84
+ export declare const navValue: (it: NavItem) => string;
85
+ /** True when the item or any descendant is current. */
86
+ export declare const hasCurrent: (it: NavItem) => boolean;
87
+ /** Watches `cm-nav-item` children (attributes and structure) and calls `cb` when they change. */
88
+ export declare const watchNavItems: (host: Element, cb: () => void) => MutationObserver;
89
+ /**
90
+ * Fires the cancelable `cm-navigate` event. Returns false when a handler called `preventDefault()`
91
+ * (the app routes itself), so the caller can stop the link.
92
+ */
93
+ export declare const fireNavigate: (host: Element, item: NavItem) => boolean;
94
+ declare global {
95
+ interface HTMLElementTagNameMap {
96
+ 'cm-nav-item': CmNavItem;
97
+ }
98
+ }