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

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,48 @@
1
+ import { LitElement } from 'lit';
2
+ import './icon.js';
3
+ import './avatar.js';
4
+ /**
5
+ * The white bar across the top of the admin: logo, store switcher, then account actions, the wallet
6
+ * balance and the signed-in user on the right. For Commmerce products only, not for apps.
7
+ *
8
+ * The bar adapts to its own width: under 900px the actions hide; under 640px the balance hides too and the user pill shrinks to the avatar; put those
9
+ * destinations in the Mobile menu instead.
10
+ * @element cm-header-bar
11
+ * @slot logo - The product logo (an `<img>` or `<svg>`), linked to the dashboard if you wrap it in `<a>`.
12
+ * @slot actions - Buttons such as "Hire an Expert" (secondary) and "My Subscription" (primary).
13
+ * @slot end - Anything after the user pill, e.g. a notifications button.
14
+ * @fires cm-store-switch - When the store switcher is pressed. Open your store list in response.
15
+ * @fires cm-wallet - When the wallet balance is pressed.
16
+ * @fires cm-account - When the user pill is pressed. Open the account menu in response.
17
+ */
18
+ export declare class CmHeaderBar extends LitElement {
19
+ #private;
20
+ static properties: {
21
+ store: {};
22
+ balance: {};
23
+ userName: {
24
+ attribute: string;
25
+ };
26
+ avatarSrc: {
27
+ attribute: string;
28
+ };
29
+ label: {};
30
+ };
31
+ /** Current store's address or name, shown as the store switcher ("preprod.commmerce.com"). Empty hides it. */
32
+ store: string;
33
+ /** Wallet balance, already formatted ("₹ 2,312"). Empty hides the pill. */
34
+ balance: string;
35
+ /** Signed-in user's name. Empty hides the user pill. */
36
+ userName: string;
37
+ /** Avatar image URL. Without it, the initials of `user-name` are shown. */
38
+ avatarSrc: string;
39
+ /** Accessible name of the header's toolbar region. */
40
+ label: string;
41
+ static styles: import("lit").CSSResult[];
42
+ render(): import("lit-html").TemplateResult<1>;
43
+ }
44
+ declare global {
45
+ interface HTMLElementTagNameMap {
46
+ 'cm-header-bar': CmHeaderBar;
47
+ }
48
+ }
@@ -0,0 +1,121 @@
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 _CmHeaderBar_instances, _CmHeaderBar_fire;
7
+ import { LitElement, html, css, nothing } from 'lit';
8
+ import { base, define } from '../base.js';
9
+ import './icon.js';
10
+ import './avatar.js';
11
+ /**
12
+ * The white bar across the top of the admin: logo, store switcher, then account actions, the wallet
13
+ * balance and the signed-in user on the right. For Commmerce products only, not for apps.
14
+ *
15
+ * The bar adapts to its own width: under 900px the actions hide; under 640px the balance hides too and the user pill shrinks to the avatar; put those
16
+ * destinations in the Mobile menu instead.
17
+ * @element cm-header-bar
18
+ * @slot logo - The product logo (an `<img>` or `<svg>`), linked to the dashboard if you wrap it in `<a>`.
19
+ * @slot actions - Buttons such as "Hire an Expert" (secondary) and "My Subscription" (primary).
20
+ * @slot end - Anything after the user pill, e.g. a notifications button.
21
+ * @fires cm-store-switch - When the store switcher is pressed. Open your store list in response.
22
+ * @fires cm-wallet - When the wallet balance is pressed.
23
+ * @fires cm-account - When the user pill is pressed. Open the account menu in response.
24
+ */
25
+ export class CmHeaderBar extends LitElement {
26
+ constructor() {
27
+ super(...arguments);
28
+ _CmHeaderBar_instances.add(this);
29
+ /** Current store's address or name, shown as the store switcher ("preprod.commmerce.com"). Empty hides it. */
30
+ this.store = '';
31
+ /** Wallet balance, already formatted ("₹ 2,312"). Empty hides the pill. */
32
+ this.balance = '';
33
+ /** Signed-in user's name. Empty hides the user pill. */
34
+ this.userName = '';
35
+ /** Avatar image URL. Without it, the initials of `user-name` are shown. */
36
+ this.avatarSrc = '';
37
+ /** Accessible name of the header's toolbar region. */
38
+ this.label = 'Admin';
39
+ }
40
+ render() {
41
+ return html `
42
+ <header part="bar" role="banner" aria-label=${this.label || nothing}>
43
+ <div class="logo"><slot name="logo"></slot></div>
44
+ ${this.store ? html `<button type="button" class="store" part="store" aria-haspopup="true" aria-label=${`Store: ${this.store}. Switch store`}
45
+ @click=${() => __classPrivateFieldGet(this, _CmHeaderBar_instances, "m", _CmHeaderBar_fire).call(this, 'cm-store-switch')}><span>${this.store}</span><cm-icon name="chevron-down" size="20"></cm-icon></button>` : nothing}
46
+ <span class="grow"></span>
47
+ <div class="end">
48
+ <div class="actions"><slot name="actions"></slot></div>
49
+ ${this.balance ? html `<button type="button" class="pill" part="balance" aria-label=${`Wallet balance ${this.balance}`}
50
+ @click=${() => __classPrivateFieldGet(this, _CmHeaderBar_instances, "m", _CmHeaderBar_fire).call(this, 'cm-wallet')}>${this.balance}</button>` : nothing}
51
+ ${this.userName ? html `<button type="button" class="user" part="user" aria-haspopup="true" aria-label=${`Account: ${this.userName}`}
52
+ @click=${() => __classPrivateFieldGet(this, _CmHeaderBar_instances, "m", _CmHeaderBar_fire).call(this, 'cm-account')}><span class="name">${this.userName}</span>
53
+ <cm-avatar class="avatar" name=${this.userName} src=${this.avatarSrc} decorative></cm-avatar></button>` : nothing}
54
+ <slot name="end"></slot>
55
+ </div>
56
+ </header>
57
+ `;
58
+ }
59
+ }
60
+ _CmHeaderBar_instances = new WeakSet(), _CmHeaderBar_fire = function _CmHeaderBar_fire(name) {
61
+ this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true }));
62
+ };
63
+ CmHeaderBar.properties = {
64
+ store: {},
65
+ balance: {},
66
+ userName: { attribute: 'user-name' },
67
+ avatarSrc: { attribute: 'avatar-src' },
68
+ label: {},
69
+ };
70
+ CmHeaderBar.styles = [
71
+ base,
72
+ css `
73
+ :host { display: block; background: var(--cm-bg-surface); container-type: inline-size; }
74
+ header {
75
+ display: flex; align-items: center; gap: var(--cm-space-20); min-height: 70px; padding: 10px var(--cm-space-20) 10px 27px;
76
+ }
77
+ .logo { display: flex; align-items: center; flex: none; }
78
+ ::slotted([slot='logo']) { display: block; max-height: 24px; width: auto; }
79
+ .store, .pill, .user {
80
+ display: inline-flex; align-items: center; gap: 8px; font: inherit; color: var(--cm-text-default);
81
+ background: none; cursor: pointer;
82
+ }
83
+ .store {
84
+ margin-left: 60px; padding: 6px 8px; border: 0; border-radius: var(--cm-radius-sm); font-size: 18px; min-width: 0; flex: 0 1 auto;
85
+ }
86
+ .store span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
87
+ .store:hover { background: var(--cm-bg-hover); }
88
+ .grow { flex: 1; }
89
+ .end { display: flex; align-items: center; gap: var(--cm-space-20); flex: none; white-space: nowrap; }
90
+ .actions { display: flex; align-items: center; gap: var(--cm-space-20); }
91
+ .pill {
92
+ min-height: 44px; padding: 0 var(--cm-space-20); font-size: 14px; font-weight: 500;
93
+ border: var(--cm-border-1) solid var(--cm-border-strong); border-radius: var(--cm-radius-sm);
94
+ }
95
+ .pill:hover, .user:hover { background: var(--cm-bg-hover); }
96
+ .user {
97
+ min-height: 50px; padding: 4px 6px 4px 20px; gap: var(--cm-space-20); font-size: 18px;
98
+ border: var(--cm-border-1) solid var(--cm-border-strong); border-radius: var(--cm-radius-full);
99
+ }
100
+ .avatar { --cm-avatar-size: 36px; }
101
+ button:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
102
+ @container (max-width: 1300px) {
103
+ .store { margin-left: var(--cm-space-20); }
104
+ }
105
+ @container (max-width: 1100px) {
106
+ .store { font-size: 16px; }
107
+ }
108
+ @container (max-width: 900px) {
109
+ .actions { display: none; }
110
+ }
111
+ @container (max-width: 640px) {
112
+ header { min-height: 56px; gap: var(--cm-space-10); padding: 8px var(--cm-space-15); }
113
+ .actions, .pill { display: none; }
114
+ .store { margin-left: 0; font-size: 14px; }
115
+ .user { padding: 2px; min-height: 0; border-color: transparent; }
116
+ .user .name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
117
+ .avatar { --cm-avatar-size: 32px; }
118
+ }
119
+ `,
120
+ ];
121
+ define('cm-header-bar', CmHeaderBar);
@@ -0,0 +1,30 @@
1
+ import { LitElement } from 'lit';
2
+ import { type IconName } from '@commmerce/icons';
3
+ /**
4
+ * Line icon from @commmerce/icons. Decorative unless `label` is set.
5
+ * @element cm-icon
6
+ */
7
+ export declare class CmIcon extends LitElement {
8
+ static properties: {
9
+ name: {
10
+ reflect: boolean;
11
+ };
12
+ size: {
13
+ type: NumberConstructor;
14
+ };
15
+ label: {};
16
+ };
17
+ /** Icon from @commmerce/icons. See the Icons page for all names. */
18
+ name: IconName;
19
+ /** Pixel size. Header icons are 18, buttons 16. */
20
+ size: number;
21
+ /** Accessible name. Leave empty when the icon sits next to text that says the same thing. */
22
+ label: string;
23
+ static styles: import("lit").CSSResult;
24
+ render(): import("lit-html").TemplateResult<2>;
25
+ }
26
+ declare global {
27
+ interface HTMLElementTagNameMap {
28
+ 'cm-icon': CmIcon;
29
+ }
30
+ }
@@ -0,0 +1,36 @@
1
+ import { LitElement, svg, css, nothing } from 'lit';
2
+ import { icons, dotted } from '@commmerce/icons';
3
+ import { define } from '../base.js';
4
+ /**
5
+ * Line icon from @commmerce/icons. Decorative unless `label` is set.
6
+ * @element cm-icon
7
+ */
8
+ export class CmIcon extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ /** Icon from @commmerce/icons. See the Icons page for all names. */
12
+ this.name = 'more';
13
+ /** Pixel size. Header icons are 18, buttons 16. */
14
+ this.size = 18;
15
+ /** Accessible name. Leave empty when the icon sits next to text that says the same thing. */
16
+ this.label = '';
17
+ }
18
+ render() {
19
+ const d = icons[this.name] ?? icons.more;
20
+ const sw = dotted.includes(this.name) ? 3 : 1.6;
21
+ return svg `<svg width=${this.size} height=${this.size} viewBox="0 0 24 24" fill="none" stroke="currentColor"
22
+ stroke-width=${sw} stroke-linecap="round" stroke-linejoin="round"
23
+ role=${this.label ? 'img' : nothing} aria-label=${this.label || nothing} aria-hidden=${this.label ? nothing : 'true'}
24
+ part="svg"><path d=${d}></path></svg>`;
25
+ }
26
+ }
27
+ CmIcon.properties = {
28
+ name: { reflect: true },
29
+ size: { type: Number },
30
+ label: {},
31
+ };
32
+ CmIcon.styles = css `
33
+ :host { display: inline-flex; flex: none; color: inherit; line-height: 0; }
34
+ svg { display: block; }
35
+ `;
36
+ define('cm-icon', CmIcon);
@@ -0,0 +1,63 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Side card on detail pages that lists facts as label/value pairs (order details, SKU, tags).
4
+ * Put `cm-info-item` elements inside. The Figma file calls this the "Additional Info Card".
5
+ * @element cm-info-panel
6
+ * @slot - `cm-info-item` elements.
7
+ * @fires cm-action - When the header text action (for example REMOVE) is pressed.
8
+ */
9
+ export declare class CmInfoPanel extends LitElement {
10
+ static properties: {
11
+ heading: {};
12
+ action: {};
13
+ actionLabel: {
14
+ attribute: string;
15
+ };
16
+ headingLevel: {
17
+ type: NumberConstructor;
18
+ attribute: string;
19
+ };
20
+ _list: {
21
+ state: boolean;
22
+ };
23
+ };
24
+ /** Panel title. */
25
+ heading: string;
26
+ /** Text of the header action, shown uppercase ("Remove", "Edit"). Leave empty for none. */
27
+ action: string;
28
+ /** Accessible name of the header action when the text alone is unclear, e.g. "Remove order details". */
29
+ actionLabel: string;
30
+ /** Heading level for the title. Default 2. */
31
+ headingLevel: 2 | 3 | 4 | 5 | 6;
32
+ /** The items area is a list only while it holds just `cm-info-item`s (not, say, a loading skeleton). */
33
+ _list: boolean;
34
+ static styles: import("lit").CSSResult[];
35
+ render(): import("lit-html").TemplateResult<1>;
36
+ }
37
+ /**
38
+ * One fact in an info panel: a label and its value (text, a badge or tags).
39
+ * @element cm-info-item
40
+ * @slot - The value.
41
+ */
42
+ export declare class CmInfoItem extends LitElement {
43
+ static properties: {
44
+ label: {};
45
+ half: {
46
+ type: BooleanConstructor;
47
+ reflect: boolean;
48
+ };
49
+ };
50
+ /** What the value is ("Ordered on", "SKU"). */
51
+ label: string;
52
+ /** Takes half the width, so two short facts share a line. */
53
+ half: boolean;
54
+ static styles: import("lit").CSSResult[];
55
+ connectedCallback(): void;
56
+ render(): import("lit-html").TemplateResult<1>;
57
+ }
58
+ declare global {
59
+ interface HTMLElementTagNameMap {
60
+ 'cm-info-panel': CmInfoPanel;
61
+ 'cm-info-item': CmInfoItem;
62
+ }
63
+ }
@@ -0,0 +1,108 @@
1
+ import { LitElement, html, css, nothing } from 'lit';
2
+ import { base, define } from '../base.js';
3
+ /**
4
+ * Side card on detail pages that lists facts as label/value pairs (order details, SKU, tags).
5
+ * Put `cm-info-item` elements inside. The Figma file calls this the "Additional Info Card".
6
+ * @element cm-info-panel
7
+ * @slot - `cm-info-item` elements.
8
+ * @fires cm-action - When the header text action (for example REMOVE) is pressed.
9
+ */
10
+ export class CmInfoPanel extends LitElement {
11
+ constructor() {
12
+ super(...arguments);
13
+ /** Panel title. */
14
+ this.heading = '';
15
+ /** Text of the header action, shown uppercase ("Remove", "Edit"). Leave empty for none. */
16
+ this.action = '';
17
+ /** Accessible name of the header action when the text alone is unclear, e.g. "Remove order details". */
18
+ this.actionLabel = '';
19
+ /** Heading level for the title. Default 2. */
20
+ this.headingLevel = 2;
21
+ /** The items area is a list only while it holds just `cm-info-item`s (not, say, a loading skeleton). */
22
+ this._list = true;
23
+ }
24
+ render() {
25
+ const level = Math.min(6, Math.max(2, this.headingLevel || 2));
26
+ return html `<section part="panel" aria-label=${this.heading || nothing}>
27
+ ${this.heading || this.action
28
+ ? html `<header>
29
+ <div class="title" role="heading" aria-level=${level} part="title">${this.heading}</div>
30
+ ${this.action
31
+ ? html `<button class="action" type="button" part="action" aria-label=${this.actionLabel || nothing}
32
+ @click=${() => this.dispatchEvent(new CustomEvent('cm-action', { bubbles: true, composed: true }))}>${this.action}</button>`
33
+ : nothing}
34
+ </header>`
35
+ : nothing}
36
+ <div class="items" role=${this._list ? 'list' : nothing}><slot @slotchange=${(e) => {
37
+ this._list = e.target.assignedElements().every((el) => el.localName === 'cm-info-item');
38
+ }}></slot></div>
39
+ </section>`;
40
+ }
41
+ }
42
+ CmInfoPanel.properties = {
43
+ heading: {},
44
+ action: {},
45
+ actionLabel: { attribute: 'action-label' },
46
+ headingLevel: { type: Number, attribute: 'heading-level' },
47
+ _list: { state: true },
48
+ };
49
+ CmInfoPanel.styles = [
50
+ base,
51
+ css `
52
+ :host { display: block; }
53
+ section {
54
+ background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-card);
55
+ border-radius: var(--cm-radius-md); padding: var(--cm-space-20);
56
+ }
57
+ header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--cm-space-20); margin-bottom: var(--cm-space-20); }
58
+ .title { margin: 0; font-size: 20px; font-weight: 600; }
59
+ .action {
60
+ padding: 2px 4px; margin: -2px -4px; border: 0; background: none; color: var(--cm-text-default); cursor: pointer;
61
+ font: inherit; font-size: 14px; font-weight: 500; letter-spacing: var(--cm-tracking-caps); text-transform: uppercase;
62
+ border-radius: var(--cm-radius-xs);
63
+ }
64
+ .action:hover { text-decoration: underline; }
65
+ .action:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
66
+ .items { display: grid; grid-template-columns: 1fr 1fr; gap: var(--cm-space-15) var(--cm-space-20); }
67
+ `,
68
+ ];
69
+ define('cm-info-panel', CmInfoPanel);
70
+ /**
71
+ * One fact in an info panel: a label and its value (text, a badge or tags).
72
+ * @element cm-info-item
73
+ * @slot - The value.
74
+ */
75
+ export class CmInfoItem extends LitElement {
76
+ constructor() {
77
+ super(...arguments);
78
+ /** What the value is ("Ordered on", "SKU"). */
79
+ this.label = '';
80
+ /** Takes half the width, so two short facts share a line. */
81
+ this.half = false;
82
+ }
83
+ connectedCallback() {
84
+ super.connectedCallback();
85
+ if (!this.hasAttribute('role'))
86
+ this.setAttribute('role', 'listitem');
87
+ }
88
+ render() {
89
+ return html `<div class="label" part="label">${this.label}</div><div class="value" part="value"><slot></slot></div>`;
90
+ }
91
+ }
92
+ CmInfoItem.properties = {
93
+ label: {},
94
+ half: { type: Boolean, reflect: true },
95
+ };
96
+ CmInfoItem.styles = [
97
+ base,
98
+ css `
99
+ :host { display: block; grid-column: 1 / -1; min-width: 0; }
100
+ :host([half]) { grid-column: auto; }
101
+ .label { font-size: 16px; }
102
+ .value {
103
+ display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-10);
104
+ margin-top: 6px; font-size: 16px; font-weight: 500; overflow-wrap: anywhere;
105
+ }
106
+ `,
107
+ ];
108
+ define('cm-info-item', CmInfoItem);
@@ -0,0 +1,45 @@
1
+ import { LitElement } from 'lit';
2
+ import { type SpaceStep } from '../spacing.js';
3
+ /**
4
+ * The body of an admin page: sections side by side, for example the main column and side column of a detail page.
5
+ * Sections stack into one column, in source order, when the layout is narrower than 768px (a container query, so
6
+ * it follows the space the layout gets, not the window). Put the main section first.
7
+ * @element cm-layout
8
+ * @slot - `cm-layout-section` elements.
9
+ */
10
+ export declare class CmLayout extends LitElement {
11
+ static properties: {
12
+ gap: {
13
+ reflect: boolean;
14
+ };
15
+ };
16
+ /** Space between sections, across and down: a spacing step (`0`, `10`, `12`, `15`, `20`, `22`, `30`). Default `20`. */
17
+ gap: SpaceStep;
18
+ static styles: import("lit").CSSResult[];
19
+ render(): import("lit-html").TemplateResult<1>;
20
+ }
21
+ /**
22
+ * One column of a `cm-layout`. Its children are stacked `space-20` apart (cards on the page).
23
+ * @element cm-layout-section
24
+ * @slot - The section's content, usually cards.
25
+ */
26
+ export declare class CmLayoutSection extends LitElement {
27
+ static properties: {
28
+ variant: {
29
+ reflect: boolean;
30
+ };
31
+ };
32
+ /**
33
+ * Width on wide layouts: `full` (default), `one-half`, `one-third` or `two-thirds`. A detail page is a
34
+ * `two-thirds` main section and a `one-third` side section. Every section is full width once the layout stacks.
35
+ */
36
+ variant: 'full' | 'one-half' | 'one-third' | 'two-thirds';
37
+ static styles: import("lit").CSSResult[];
38
+ render(): import("lit-html").TemplateResult<1>;
39
+ }
40
+ declare global {
41
+ interface HTMLElementTagNameMap {
42
+ 'cm-layout': CmLayout;
43
+ 'cm-layout-section': CmLayoutSection;
44
+ }
45
+ }
@@ -0,0 +1,67 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { base, define } from '../base.js';
3
+ import { spaceRules } from '../spacing.js';
4
+ /**
5
+ * The body of an admin page: sections side by side, for example the main column and side column of a detail page.
6
+ * Sections stack into one column, in source order, when the layout is narrower than 768px (a container query, so
7
+ * it follows the space the layout gets, not the window). Put the main section first.
8
+ * @element cm-layout
9
+ * @slot - `cm-layout-section` elements.
10
+ */
11
+ export class CmLayout extends LitElement {
12
+ constructor() {
13
+ super(...arguments);
14
+ /** Space between sections, across and down: a spacing step (`0`, `10`, `12`, `15`, `20`, `22`, `30`). Default `20`. */
15
+ this.gap = '20';
16
+ }
17
+ render() {
18
+ return html `<div class="layout" part="layout"><slot></slot></div>`;
19
+ }
20
+ }
21
+ CmLayout.properties = { gap: { reflect: true } };
22
+ CmLayout.styles = [
23
+ base,
24
+ css `
25
+ :host { display: block; container: cm-layout / inline-size; --_gap: var(--cm-space-20); }
26
+ .layout { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--_gap); align-items: start; }
27
+ @container cm-layout (max-width: 767px) {
28
+ .layout { grid-template-columns: minmax(0, 1fr); }
29
+ }
30
+ /* Section widths live here, not in cm-layout-section: a container name only reaches queries in its own
31
+ shadow tree in current browsers, and rules on ::slotted from this scope win over the section's :host. */
32
+ ::slotted(*) { grid-column: 1 / -1; min-inline-size: 0; }
33
+ @container cm-layout (min-width: 768px) {
34
+ ::slotted([variant='one-half']) { grid-column: span 3; }
35
+ ::slotted([variant='one-third']) { grid-column: span 2; }
36
+ ::slotted([variant='two-thirds']) { grid-column: span 4; }
37
+ }
38
+ `,
39
+ spaceRules('gap', '--_gap'),
40
+ ];
41
+ /**
42
+ * One column of a `cm-layout`. Its children are stacked `space-20` apart (cards on the page).
43
+ * @element cm-layout-section
44
+ * @slot - The section's content, usually cards.
45
+ */
46
+ export class CmLayoutSection extends LitElement {
47
+ constructor() {
48
+ super(...arguments);
49
+ /**
50
+ * Width on wide layouts: `full` (default), `one-half`, `one-third` or `two-thirds`. A detail page is a
51
+ * `two-thirds` main section and a `one-third` side section. Every section is full width once the layout stacks.
52
+ */
53
+ this.variant = 'full';
54
+ }
55
+ render() {
56
+ return html `<slot></slot>`;
57
+ }
58
+ }
59
+ CmLayoutSection.properties = { variant: { reflect: true } };
60
+ CmLayoutSection.styles = [
61
+ base,
62
+ css `
63
+ :host { display: flex; flex-direction: column; gap: var(--cm-space-20); min-inline-size: 0; }
64
+ `,
65
+ ];
66
+ define('cm-layout', CmLayout);
67
+ define('cm-layout-section', CmLayoutSection);
@@ -0,0 +1,40 @@
1
+ import { LitElement } from 'lit';
2
+ import { type NavItem } from './nav-item.js';
3
+ /**
4
+ * A row of links between sibling pages, such as the sections of Settings or the parts of a product
5
+ * (Details, Variants, Inventory). It looks like Status tabs but each tab is a link to its own page:
6
+ * the current page is black and underlined. Too many tabs for the width scroll sideways.
7
+ *
8
+ * To filter one list without leaving the page, use Status tabs instead.
9
+ * @element cm-link-tabs
10
+ * @slot - `cm-nav-item` elements with `href`; mark the page you are on `current`.
11
+ * @fires cm-navigate - When a tab is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app.
12
+ */
13
+ export declare class CmLinkTabs extends LitElement {
14
+ #private;
15
+ static properties: {
16
+ items: {
17
+ type: ArrayConstructor;
18
+ };
19
+ label: {};
20
+ _slotted: {
21
+ state: boolean;
22
+ };
23
+ };
24
+ /** Tabs as data (`{ label, href, current }`). Used instead of `cm-nav-item` children when set. */
25
+ items: NavItem[];
26
+ /** Accessible name of the navigation, e.g. "Settings sections". */
27
+ label: string;
28
+ _slotted: NavItem[];
29
+ static styles: import("lit").CSSResult[];
30
+ connectedCallback(): void;
31
+ disconnectedCallback(): void;
32
+ /** The tabs in use. */
33
+ get tabs(): NavItem[];
34
+ render(): import("lit-html").TemplateResult<1>;
35
+ }
36
+ declare global {
37
+ interface HTMLElementTagNameMap {
38
+ 'cm-link-tabs': CmLinkTabs;
39
+ }
40
+ }
@@ -0,0 +1,85 @@
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 _CmLinkTabs_instances, _CmLinkTabs_observer, _CmLinkTabs_read;
13
+ import { LitElement, html, css, nothing } from 'lit';
14
+ import { base, define } from '../base.js';
15
+ import { readNavItems, watchNavItems, fireNavigate } from './nav-item.js';
16
+ /**
17
+ * A row of links between sibling pages, such as the sections of Settings or the parts of a product
18
+ * (Details, Variants, Inventory). It looks like Status tabs but each tab is a link to its own page:
19
+ * the current page is black and underlined. Too many tabs for the width scroll sideways.
20
+ *
21
+ * To filter one list without leaving the page, use Status tabs instead.
22
+ * @element cm-link-tabs
23
+ * @slot - `cm-nav-item` elements with `href`; mark the page you are on `current`.
24
+ * @fires cm-navigate - When a tab is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app.
25
+ */
26
+ export class CmLinkTabs extends LitElement {
27
+ constructor() {
28
+ super(...arguments);
29
+ _CmLinkTabs_instances.add(this);
30
+ /** Tabs as data (`{ label, href, current }`). Used instead of `cm-nav-item` children when set. */
31
+ this.items = [];
32
+ /** Accessible name of the navigation, e.g. "Settings sections". */
33
+ this.label = 'Sections';
34
+ this._slotted = [];
35
+ _CmLinkTabs_observer.set(this, void 0);
36
+ }
37
+ connectedCallback() {
38
+ super.connectedCallback();
39
+ __classPrivateFieldGet(this, _CmLinkTabs_instances, "m", _CmLinkTabs_read).call(this);
40
+ __classPrivateFieldSet(this, _CmLinkTabs_observer, watchNavItems(this, () => __classPrivateFieldGet(this, _CmLinkTabs_instances, "m", _CmLinkTabs_read).call(this)), "f");
41
+ }
42
+ disconnectedCallback() {
43
+ super.disconnectedCallback();
44
+ __classPrivateFieldGet(this, _CmLinkTabs_observer, "f")?.disconnect();
45
+ }
46
+ /** The tabs in use. */
47
+ get tabs() { return this.items.length ? this.items : this._slotted; }
48
+ render() {
49
+ return html `<nav part="nav" aria-label=${this.label || 'Sections'}>
50
+ <ul part="tabs">${this.tabs.map((t) => html `<li><a part="tab" href=${t.href || '#'} aria-current=${t.current ? 'page' : nothing}
51
+ @click=${(e) => { if (!fireNavigate(this, t))
52
+ e.preventDefault(); }}>${t.label}${t.badge ? html `<span class="badge">(${t.badge})</span>` : nothing}</a></li>`)}</ul>
53
+ <slot hidden></slot>
54
+ </nav>`;
55
+ }
56
+ }
57
+ _CmLinkTabs_observer = new WeakMap(), _CmLinkTabs_instances = new WeakSet(), _CmLinkTabs_read = function _CmLinkTabs_read() { this._slotted = readNavItems(this); };
58
+ CmLinkTabs.properties = {
59
+ items: { type: Array },
60
+ label: {},
61
+ _slotted: { state: true },
62
+ };
63
+ CmLinkTabs.styles = [
64
+ base,
65
+ css `
66
+ :host { display: block; }
67
+ ul {
68
+ display: flex; gap: 28px; margin: 0; padding: 2px 2px 0; list-style: none; overflow-x: auto; scrollbar-width: thin;
69
+ border-bottom: var(--cm-border-1) solid var(--cm-border-default); white-space: nowrap;
70
+ }
71
+ li { flex: none; display: flex; }
72
+ a {
73
+ position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0 14px;
74
+ font-size: 16px; font-weight: 500; color: var(--cm-text-tertiary); text-decoration: none;
75
+ }
76
+ a::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 1px; background: transparent; }
77
+ a:hover { color: var(--cm-text-default); }
78
+ a[aria-current='page'] { color: var(--cm-text-default); }
79
+ a[aria-current='page']::after { background: var(--cm-border-strong); }
80
+ a:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; border-radius: var(--cm-radius-xs); }
81
+ .badge { font-size: 12px; color: var(--cm-text-tertiary); }
82
+ @media (max-width: 640px) { ul { gap: 18px; } a { font-size: 14px; } }
83
+ `,
84
+ ];
85
+ define('cm-link-tabs', CmLinkTabs);