@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,57 @@
1
+ import { LitElement } from 'lit';
2
+ import './icon.js';
3
+ /**
4
+ * A card for one app in the Commmerce app marketplace: logo tile, name, developer, rating, pricing,
5
+ * an optional offer, and actions (Sign Up, Contact, View Details).
6
+ * @element cm-app-card
7
+ * @slot logo - The app's logo, an `<img>` with `alt` set to the app name. Shown in a 130×54 tile.
8
+ * @slot actions - Buttons, e.g. `<cm-button variant="primary">Sign Up</cm-button>` and `<cm-button>Contact</cm-button>`.
9
+ * @slot status - Top-right corner, e.g. a `cm-toggle` that turns an installed app on and off.
10
+ */
11
+ export declare class CmAppCard extends LitElement {
12
+ static properties: {
13
+ name: {};
14
+ developer: {};
15
+ rating: {
16
+ type: NumberConstructor;
17
+ };
18
+ reviews: {
19
+ type: NumberConstructor;
20
+ };
21
+ reviewsHref: {
22
+ attribute: string;
23
+ };
24
+ pricing: {};
25
+ offer: {};
26
+ href: {};
27
+ headingLevel: {
28
+ type: NumberConstructor;
29
+ attribute: string;
30
+ };
31
+ };
32
+ /** App name, the card's heading. */
33
+ name: string;
34
+ /** Who made the app, shown as "By …". */
35
+ developer: string;
36
+ /** Average rating out of 5. Leave unset for apps without reviews. */
37
+ rating?: number;
38
+ /** Number of reviews. */
39
+ reviews?: number;
40
+ /** Link for the reviews count. */
41
+ reviewsHref: string;
42
+ /** Pricing summary: "Free plan available. 7-day free trial." */
43
+ pricing: string;
44
+ /** Optional offer, shown on a pale blue line with a percent icon. */
45
+ offer: string;
46
+ /** App details page. Shows a "View Details" link. */
47
+ href: string;
48
+ /** Heading level of the app name (2–6), to fit the page outline. */
49
+ headingLevel: number;
50
+ static styles: import("lit").CSSResult[];
51
+ render(): import("lit-html").TemplateResult<1>;
52
+ }
53
+ declare global {
54
+ interface HTMLElementTagNameMap {
55
+ 'cm-app-card': CmAppCard;
56
+ }
57
+ }
@@ -0,0 +1,100 @@
1
+ import { LitElement, html, css, nothing } from 'lit';
2
+ import { base, define } from '../base.js';
3
+ import './icon.js';
4
+ /**
5
+ * A card for one app in the Commmerce app marketplace: logo tile, name, developer, rating, pricing,
6
+ * an optional offer, and actions (Sign Up, Contact, View Details).
7
+ * @element cm-app-card
8
+ * @slot logo - The app's logo, an `<img>` with `alt` set to the app name. Shown in a 130×54 tile.
9
+ * @slot actions - Buttons, e.g. `<cm-button variant="primary">Sign Up</cm-button>` and `<cm-button>Contact</cm-button>`.
10
+ * @slot status - Top-right corner, e.g. a `cm-toggle` that turns an installed app on and off.
11
+ */
12
+ export class CmAppCard extends LitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ /** App name, the card's heading. */
16
+ this.name = '';
17
+ /** Who made the app, shown as "By …". */
18
+ this.developer = '';
19
+ /** Link for the reviews count. */
20
+ this.reviewsHref = '';
21
+ /** Pricing summary: "Free plan available. 7-day free trial." */
22
+ this.pricing = '';
23
+ /** Optional offer, shown on a pale blue line with a percent icon. */
24
+ this.offer = '';
25
+ /** App details page. Shows a "View Details" link. */
26
+ this.href = '';
27
+ /** Heading level of the app name (2–6), to fit the page outline. */
28
+ this.headingLevel = 3;
29
+ }
30
+ render() {
31
+ const lvl = Math.min(6, Math.max(2, Math.round(this.headingLevel) || 3));
32
+ const hasRating = typeof this.rating === 'number' && !Number.isNaN(this.rating);
33
+ const reviews = typeof this.reviews === 'number' ? `${this.reviews.toLocaleString()} ${this.reviews === 1 ? 'Review' : 'Reviews'}` : '';
34
+ return html `<article part="card" aria-labelledby="name">
35
+ <div class="logo" part="logo"><slot name="logo"></slot></div>
36
+ <div class="status"><slot name="status"></slot></div>
37
+ <div class="name" id="name" role="heading" aria-level=${lvl}>${this.name}</div>
38
+ ${this.developer ? html `<p class="by">By ${this.developer}</p>` : nothing}
39
+ ${hasRating ? html `<p class="rating"><cm-icon class="star" name="star" size="12"></cm-icon>
40
+ <span aria-hidden="true">${this.rating.toFixed(1)}</span><span class="sr">Rated ${this.rating.toFixed(1)} out of 5</span>
41
+ ${reviews ? (this.reviewsHref ? html `<a href=${this.reviewsHref}>${reviews}</a>` : html `<span>${reviews}</span>`) : nothing}</p>` : nothing}
42
+ ${this.pricing ? html `<p class="pricing">${this.pricing}</p>` : nothing}
43
+ ${this.offer ? html `<p class="offer"><cm-icon name="percent" size="12"></cm-icon><span><span class="sr">Offer: </span>${this.offer}</span></p>` : nothing}
44
+ <div class="actions"><slot name="actions"></slot>${this.href ? html `<a class="details" part="details" href=${this.href}
45
+ aria-label=${`View details of ${this.name}`}>View Details</a>` : nothing}</div>
46
+ </article>`;
47
+ }
48
+ }
49
+ CmAppCard.properties = {
50
+ name: {},
51
+ developer: {},
52
+ rating: { type: Number },
53
+ reviews: { type: Number },
54
+ reviewsHref: { attribute: 'reviews-href' },
55
+ pricing: {},
56
+ offer: {},
57
+ href: {},
58
+ headingLevel: { type: Number, attribute: 'heading-level' },
59
+ };
60
+ CmAppCard.styles = [
61
+ base,
62
+ css `
63
+ :host { display: block; container-type: inline-size; }
64
+ article {
65
+ position: relative; display: flex; flex-direction: column; gap: 10px; height: 100%; padding: var(--cm-space-20);
66
+ background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-default); border-radius: var(--cm-radius-md);
67
+ font-size: 12px;
68
+ }
69
+ .logo {
70
+ display: grid; place-items: center; width: 130px; height: 54px; margin-bottom: 10px; padding: 8px; overflow: hidden;
71
+ background: var(--cm-bg-inset); border-radius: var(--cm-radius-xs);
72
+ }
73
+ ::slotted([slot='logo']) { max-width: 100%; max-height: 100%; object-fit: contain; }
74
+ .status { position: absolute; top: var(--cm-space-20); right: var(--cm-space-20); }
75
+ .name { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
76
+ .by { margin: -6px 0 0; }
77
+ .rating { display: flex; align-items: center; gap: 5px; margin: 0; }
78
+ .star { color: var(--cm-icon-rating); }
79
+ .star::part(svg) { fill: currentColor; }
80
+ .rating a, .details { color: var(--cm-text-default); text-decoration: underline; text-underline-offset: 2px; }
81
+ .rating a:focus-visible, .details:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; border-radius: 2px; }
82
+ .pricing { margin: 4px 0 0; }
83
+ .offer {
84
+ display: flex; align-items: center; gap: 5px; margin: 0; padding: 4px 6px; font-size: 11px; line-height: 1.3;
85
+ background: var(--cm-bg-offer-card); border-radius: var(--cm-radius-xs);
86
+ }
87
+ .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-20); margin-top: auto; padding-top: 6px; }
88
+ .actions slot { display: contents; }
89
+ .details { font-weight: 500; }
90
+ .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
91
+ @container (max-width: 380px) {
92
+ article { padding: var(--cm-space-10); }
93
+ .logo { width: 100px; height: 40px; padding: 6px; }
94
+ .status { top: var(--cm-space-10); right: var(--cm-space-10); }
95
+ .actions { gap: var(--cm-space-10); }
96
+ .details { margin-left: auto; }
97
+ }
98
+ `,
99
+ ];
100
+ define('cm-app-card', CmAppCard);
@@ -0,0 +1,48 @@
1
+ import { LitElement } from 'lit';
2
+ import './icon.js';
3
+ /** "Asha Rao" → "AR", "preprod.commmerce.com" → "P". At most two letters. */
4
+ export declare function initials(name: string): string;
5
+ /**
6
+ * A person or a store, as a photo or their initials.
7
+ * Round for people, square for stores. Without a photo (or when it fails to load) it shows the initials of
8
+ * `name`, and without a name a person or store icon.
9
+ * @element cm-avatar
10
+ */
11
+ export declare class CmAvatar extends LitElement {
12
+ static properties: {
13
+ name: {};
14
+ src: {};
15
+ size: {
16
+ reflect: boolean;
17
+ };
18
+ shape: {
19
+ reflect: boolean;
20
+ };
21
+ decorative: {
22
+ type: BooleanConstructor;
23
+ reflect: boolean;
24
+ };
25
+ _failed: {
26
+ state: boolean;
27
+ };
28
+ };
29
+ /** Who or what it shows. Used for the initials and as the accessible name. */
30
+ name: string;
31
+ /** Photo or logo URL. Shown cropped to fill the avatar. */
32
+ src: string;
33
+ /** `small` 24px, `medium` 36px, `large` 48px. Set `--cm-avatar-size` for any other size. */
34
+ size: 'small' | 'medium' | 'large';
35
+ /** `round` for people, `square` for stores and businesses. */
36
+ shape: 'round' | 'square';
37
+ /** Hides it from screen readers. Use when the name is written right next to the avatar. */
38
+ decorative: boolean;
39
+ _failed: boolean;
40
+ static styles: import("lit").CSSResult[];
41
+ willUpdate(changed: Map<string, unknown>): void;
42
+ render(): import("lit-html").TemplateResult<1>;
43
+ }
44
+ declare global {
45
+ interface HTMLElementTagNameMap {
46
+ 'cm-avatar': CmAvatar;
47
+ }
48
+ }
@@ -0,0 +1,82 @@
1
+ import { LitElement, html, css, nothing } from 'lit';
2
+ import { base, define } from '../base.js';
3
+ import './icon.js';
4
+ /** "Asha Rao" → "AR", "preprod.commmerce.com" → "P". At most two letters. */
5
+ export function initials(name) {
6
+ const words = name.trim().split(/[\s._@-]+/).filter(Boolean);
7
+ if (!words.length)
8
+ return '';
9
+ const first = [...words[0]][0] ?? '';
10
+ const last = words.length > 1 && !/[.@]/.test(name) ? [...words[words.length - 1]][0] ?? '' : '';
11
+ return (first + last).toLocaleUpperCase();
12
+ }
13
+ /**
14
+ * A person or a store, as a photo or their initials.
15
+ * Round for people, square for stores. Without a photo (or when it fails to load) it shows the initials of
16
+ * `name`, and without a name a person or store icon.
17
+ * @element cm-avatar
18
+ */
19
+ export class CmAvatar extends LitElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ /** Who or what it shows. Used for the initials and as the accessible name. */
23
+ this.name = '';
24
+ /** Photo or logo URL. Shown cropped to fill the avatar. */
25
+ this.src = '';
26
+ /** `small` 24px, `medium` 36px, `large` 48px. Set `--cm-avatar-size` for any other size. */
27
+ this.size = 'medium';
28
+ /** `round` for people, `square` for stores and businesses. */
29
+ this.shape = 'round';
30
+ /** Hides it from screen readers. Use when the name is written right next to the avatar. */
31
+ this.decorative = false;
32
+ this._failed = false;
33
+ }
34
+ willUpdate(changed) {
35
+ if (changed.has('src'))
36
+ this._failed = false;
37
+ }
38
+ render() {
39
+ const letters = initials(this.name);
40
+ const label = this.decorative || !this.name ? nothing : this.name;
41
+ const hidden = this.decorative || !this.name ? 'true' : nothing;
42
+ let inner;
43
+ let cls = 'avatar';
44
+ if (this.src && !this._failed) {
45
+ inner = html `<img src=${this.src} alt="" @error=${() => { this._failed = true; }}>`;
46
+ }
47
+ else if (letters) {
48
+ inner = html `<span aria-hidden="true">${letters}</span>`;
49
+ }
50
+ else {
51
+ cls += ' icon';
52
+ inner = html `<cm-icon name=${this.shape === 'square' ? 'store' : 'user'} size="18"></cm-icon>`;
53
+ }
54
+ return html `<span class=${cls} part="avatar" role=${label === nothing ? nothing : 'img'} aria-label=${label} aria-hidden=${hidden}>${inner}</span>`;
55
+ }
56
+ }
57
+ CmAvatar.properties = {
58
+ name: {},
59
+ src: {},
60
+ size: { reflect: true },
61
+ shape: { reflect: true },
62
+ decorative: { type: Boolean, reflect: true },
63
+ _failed: { state: true },
64
+ };
65
+ CmAvatar.styles = [
66
+ base,
67
+ css `
68
+ :host { --_size: var(--cm-avatar-size, 36px); display: inline-flex; vertical-align: middle; flex: none; }
69
+ :host([size='small']) { --_size: var(--cm-avatar-size, 24px); }
70
+ :host([size='large']) { --_size: var(--cm-avatar-size, 48px); }
71
+ .avatar {
72
+ display: grid; place-items: center; overflow: hidden; inline-size: var(--_size); block-size: var(--_size);
73
+ border-radius: 50%; background: var(--cm-avatar-bg); color: var(--cm-text-default);
74
+ font-size: calc(var(--_size) * 0.4); font-weight: 500; line-height: 1; user-select: none;
75
+ }
76
+ :host([shape='square']) .avatar { border-radius: var(--cm-radius-sm); }
77
+ .icon { background: var(--cm-bg-input-filled); color: var(--cm-icon-selected); }
78
+ img { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; }
79
+ @media (forced-colors: active) { .avatar { border: 1px solid CanvasText; } }
80
+ `,
81
+ ];
82
+ define('cm-avatar', CmAvatar);
@@ -0,0 +1,23 @@
1
+ import { LitElement } from 'lit';
2
+ import { type Tone } from '../base.js';
3
+ /**
4
+ * Uppercase status pill ("ORDER PLACED", "ACCEPTED").
5
+ * @element cm-badge
6
+ * @slot - Status text.
7
+ */
8
+ export declare class CmBadge extends LitElement {
9
+ static properties: {
10
+ tone: {
11
+ reflect: boolean;
12
+ };
13
+ };
14
+ /** Colour and meaning. `neutral` for drafts and other states with no status. */
15
+ tone: Tone | 'neutral';
16
+ static styles: import("lit").CSSResult[];
17
+ render(): import("lit-html").TemplateResult<1>;
18
+ }
19
+ declare global {
20
+ interface HTMLElementTagNameMap {
21
+ 'cm-badge': CmBadge;
22
+ }
23
+ }
@@ -0,0 +1,35 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { base, define } from '../base.js';
3
+ /**
4
+ * Uppercase status pill ("ORDER PLACED", "ACCEPTED").
5
+ * @element cm-badge
6
+ * @slot - Status text.
7
+ */
8
+ export class CmBadge extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ /** Colour and meaning. `neutral` for drafts and other states with no status. */
12
+ this.tone = 'neutral';
13
+ }
14
+ render() {
15
+ return html `<span part="badge"><slot></slot></span>`;
16
+ }
17
+ }
18
+ CmBadge.properties = { tone: { reflect: true } };
19
+ CmBadge.styles = [
20
+ base,
21
+ css `
22
+ :host { display: inline-flex; vertical-align: middle; }
23
+ span {
24
+ display: inline-flex; align-items: center; height: 28px; padding: 0 var(--cm-space-10);
25
+ font-size: 10px; font-weight: 500; letter-spacing: var(--cm-tracking-caps); text-transform: uppercase;
26
+ border-radius: var(--cm-radius-full); background: var(--cm-bg-tag); color: var(--cm-text-default);
27
+ }
28
+ /* Tinted tones are laid over the surface colour, so the text keeps AA contrast on any page background. */
29
+ :host([tone='information']) span { background: linear-gradient(var(--cm-bg-information-soft), var(--cm-bg-information-soft)), var(--cm-bg-surface); color: var(--cm-text-information); }
30
+ :host([tone='success']) span { background: linear-gradient(var(--cm-bg-success-soft), var(--cm-bg-success-soft)), var(--cm-bg-surface); color: var(--cm-text-success); }
31
+ :host([tone='critical']) span { background: linear-gradient(var(--cm-bg-critical), var(--cm-bg-critical)), var(--cm-bg-surface); color: var(--cm-text-critical); }
32
+ :host([tone='attention']) span { background: linear-gradient(var(--cm-bg-attention), var(--cm-bg-attention)), var(--cm-bg-surface); color: var(--cm-text-attention); }
33
+ `,
34
+ ];
35
+ define('cm-badge', CmBadge);
@@ -0,0 +1,36 @@
1
+ import { LitElement } from 'lit';
2
+ import { type Tone } from '../base.js';
3
+ /**
4
+ * Full-width message about the page or a task. Critical banners are announced immediately.
5
+ * @element cm-banner
6
+ * @slot - Message body.
7
+ * @slot actions - Buttons or links under the message.
8
+ * @fires cm-dismiss - When the close button is pressed (cancelable; default hides the banner).
9
+ */
10
+ export declare class CmBanner extends LitElement {
11
+ #private;
12
+ static properties: {
13
+ tone: {
14
+ reflect: boolean;
15
+ };
16
+ heading: {};
17
+ dismissible: {
18
+ type: BooleanConstructor;
19
+ };
20
+ };
21
+ /** attention = blue, information = orange, success = green, critical = red. */
22
+ tone: Tone;
23
+ /** Bold first line. Leave empty for one-line banners. */
24
+ heading: string;
25
+ /** Shows a close button. Use for messages the merchant can act on later. */
26
+ dismissible: boolean;
27
+ static styles: import("lit").CSSResult[];
28
+ /** @internal */
29
+ hasActions: boolean;
30
+ render(): import("lit-html").TemplateResult<1>;
31
+ }
32
+ declare global {
33
+ interface HTMLElementTagNameMap {
34
+ 'cm-banner': CmBanner;
35
+ }
36
+ }
@@ -0,0 +1,88 @@
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 _CmBanner_instances, _CmBanner_onSlot, _CmBanner_dismiss;
7
+ import { LitElement, html, svg, css, nothing } from 'lit';
8
+ import { base, define } from '../base.js';
9
+ /**
10
+ * Full-width message about the page or a task. Critical banners are announced immediately.
11
+ * @element cm-banner
12
+ * @slot - Message body.
13
+ * @slot actions - Buttons or links under the message.
14
+ * @fires cm-dismiss - When the close button is pressed (cancelable; default hides the banner).
15
+ */
16
+ export class CmBanner extends LitElement {
17
+ constructor() {
18
+ super(...arguments);
19
+ _CmBanner_instances.add(this);
20
+ /** attention = blue, information = orange, success = green, critical = red. */
21
+ this.tone = 'attention';
22
+ /** Bold first line. Leave empty for one-line banners. */
23
+ this.heading = '';
24
+ /** Shows a close button. Use for messages the merchant can act on later. */
25
+ this.dismissible = false;
26
+ /** @internal */
27
+ this.hasActions = false;
28
+ }
29
+ render() {
30
+ const role = this.tone === 'critical' ? 'alert' : 'status';
31
+ const icon = this.tone === 'success'
32
+ ? svg `<path d="m5 10.5 3 3 7-7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`
33
+ : svg `<circle cx="10" cy="10" r="7.5" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M10 6v5M10 13.6v.2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>`;
34
+ return html `<div class="banner" part="banner" role=${role}>
35
+ <svg class="icon" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true">${icon}</svg>
36
+ <div class="body">
37
+ ${this.heading ? html `<p class="title">${this.heading}</p>` : nothing}
38
+ <div><slot></slot></div>
39
+ <div class="actions" ?hidden=${!this.hasActions}><slot name="actions" @slotchange=${__classPrivateFieldGet(this, _CmBanner_instances, "m", _CmBanner_onSlot)}></slot></div>
40
+ </div>
41
+ ${this.dismissible
42
+ ? html `<button class="close" aria-label="Dismiss" @click=${__classPrivateFieldGet(this, _CmBanner_instances, "m", _CmBanner_dismiss)}>
43
+ <svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg></button>`
44
+ : nothing}
45
+ </div>`;
46
+ }
47
+ }
48
+ _CmBanner_instances = new WeakSet(), _CmBanner_onSlot = function _CmBanner_onSlot(e) {
49
+ this.hasActions = e.target.assignedElements().length > 0;
50
+ this.requestUpdate();
51
+ }, _CmBanner_dismiss = function _CmBanner_dismiss() {
52
+ const ev = new CustomEvent('cm-dismiss', { bubbles: true, composed: true, cancelable: true });
53
+ if (this.dispatchEvent(ev))
54
+ this.hidden = true;
55
+ };
56
+ CmBanner.properties = {
57
+ tone: { reflect: true },
58
+ heading: {},
59
+ dismissible: { type: Boolean },
60
+ };
61
+ CmBanner.styles = [
62
+ base,
63
+ css `
64
+ :host { display: block; }
65
+ .banner {
66
+ display: flex; gap: var(--cm-space-15); align-items: flex-start;
67
+ padding: var(--cm-space-15) var(--cm-space-20); border-radius: var(--cm-radius-md);
68
+ background: var(--cm-bg-attention); color: var(--cm-text-default); font-size: 14px;
69
+ }
70
+ :host([tone='information']) .banner { background: var(--cm-bg-information); }
71
+ :host([tone='success']) .banner { background: var(--cm-bg-success); }
72
+ :host([tone='critical']) .banner { background: var(--cm-bg-critical); }
73
+ .icon { flex: none; margin-top: 2px; color: var(--cm-text-attention); }
74
+ :host([tone='critical']) .icon { color: var(--cm-icon-critical); }
75
+ :host([tone='information']) .icon, :host([tone='success']) .icon { color: var(--cm-text-default); }
76
+ .body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
77
+ .title { margin: 0; font-size: 16px; font-weight: 600; }
78
+ :host([tone='critical']) .title { color: var(--cm-text-critical); }
79
+ .actions { display: flex; gap: var(--cm-space-10); margin-top: var(--cm-space-10); }
80
+ .actions[hidden] { display: none; }
81
+ .close {
82
+ flex: none; display: inline-flex; padding: 4px; margin: -4px; background: none; border: 0;
83
+ border-radius: var(--cm-radius-sm); color: inherit; cursor: pointer;
84
+ }
85
+ .close:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
86
+ `,
87
+ ];
88
+ define('cm-banner', CmBanner);
@@ -0,0 +1,48 @@
1
+ import { LitElement } from 'lit';
2
+ import { type NavItem } from './nav-item.js';
3
+ import './icon.js';
4
+ /**
5
+ * The admin's tab bar on phones and small tablets: up to five destinations with an icon over an uppercase
6
+ * label, in a white bar with rounded top corners. The last item ("More") usually opens the Mobile menu.
7
+ * For Commmerce products only, not for apps.
8
+ *
9
+ * Items come from `cm-nav-item` children or the `items` property. Mark the main action `primary`
10
+ * (Quick add) to draw its icon as a black square.
11
+ * @element cm-bottom-navigation
12
+ * @slot - `cm-nav-item` elements (no nesting).
13
+ * @fires cm-navigate - When an item is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app. Items without `href` only fire this event (e.g. "More" opens the Mobile menu).
14
+ */
15
+ export declare class CmBottomNavigation extends LitElement {
16
+ #private;
17
+ static properties: {
18
+ items: {
19
+ type: ArrayConstructor;
20
+ };
21
+ label: {};
22
+ fixed: {
23
+ type: BooleanConstructor;
24
+ reflect: boolean;
25
+ };
26
+ _slotted: {
27
+ state: boolean;
28
+ };
29
+ };
30
+ /** Items as data. Used instead of `cm-nav-item` children when set. */
31
+ items: NavItem[];
32
+ /** Accessible name of the navigation landmark. */
33
+ label: string;
34
+ /** Pins the bar to the bottom of the viewport, above the device's home indicator. */
35
+ fixed: boolean;
36
+ _slotted: NavItem[];
37
+ static styles: import("lit").CSSResult[];
38
+ connectedCallback(): void;
39
+ disconnectedCallback(): void;
40
+ /** The items in use. */
41
+ get navItems(): NavItem[];
42
+ render(): import("lit-html").TemplateResult<1>;
43
+ }
44
+ declare global {
45
+ interface HTMLElementTagNameMap {
46
+ 'cm-bottom-navigation': CmBottomNavigation;
47
+ }
48
+ }
@@ -0,0 +1,98 @@
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 _CmBottomNavigation_instances, _CmBottomNavigation_observer, _CmBottomNavigation_read, _CmBottomNavigation_item;
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
+ import './icon.js';
17
+ /**
18
+ * The admin's tab bar on phones and small tablets: up to five destinations with an icon over an uppercase
19
+ * label, in a white bar with rounded top corners. The last item ("More") usually opens the Mobile menu.
20
+ * For Commmerce products only, not for apps.
21
+ *
22
+ * Items come from `cm-nav-item` children or the `items` property. Mark the main action `primary`
23
+ * (Quick add) to draw its icon as a black square.
24
+ * @element cm-bottom-navigation
25
+ * @slot - `cm-nav-item` elements (no nesting).
26
+ * @fires cm-navigate - When an item is chosen. `detail: { item, value, href }`. Cancelable: call `preventDefault()` to route in your app. Items without `href` only fire this event (e.g. "More" opens the Mobile menu).
27
+ */
28
+ export class CmBottomNavigation extends LitElement {
29
+ constructor() {
30
+ super(...arguments);
31
+ _CmBottomNavigation_instances.add(this);
32
+ /** Items as data. Used instead of `cm-nav-item` children when set. */
33
+ this.items = [];
34
+ /** Accessible name of the navigation landmark. */
35
+ this.label = 'Main';
36
+ /** Pins the bar to the bottom of the viewport, above the device's home indicator. */
37
+ this.fixed = false;
38
+ this._slotted = [];
39
+ _CmBottomNavigation_observer.set(this, void 0);
40
+ }
41
+ connectedCallback() {
42
+ super.connectedCallback();
43
+ __classPrivateFieldGet(this, _CmBottomNavigation_instances, "m", _CmBottomNavigation_read).call(this);
44
+ __classPrivateFieldSet(this, _CmBottomNavigation_observer, watchNavItems(this, () => __classPrivateFieldGet(this, _CmBottomNavigation_instances, "m", _CmBottomNavigation_read).call(this)), "f");
45
+ }
46
+ disconnectedCallback() {
47
+ super.disconnectedCallback();
48
+ __classPrivateFieldGet(this, _CmBottomNavigation_observer, "f")?.disconnect();
49
+ }
50
+ /** The items in use. */
51
+ get navItems() { return this.items.length ? this.items : this._slotted; }
52
+ render() {
53
+ return html `<nav part="nav" aria-label=${this.label || 'Main'}>
54
+ <ul>${this.navItems.slice(0, 5).map((it) => html `<li>${__classPrivateFieldGet(this, _CmBottomNavigation_instances, "m", _CmBottomNavigation_item).call(this, it)}</li>`)}</ul>
55
+ <slot hidden></slot>
56
+ </nav>`;
57
+ }
58
+ }
59
+ _CmBottomNavigation_observer = new WeakMap(), _CmBottomNavigation_instances = new WeakSet(), _CmBottomNavigation_read = function _CmBottomNavigation_read() { this._slotted = readNavItems(this); }, _CmBottomNavigation_item = function _CmBottomNavigation_item(it) {
60
+ const cls = `item ${it.primary ? 'primary' : ''}`;
61
+ const inner = html `<span class="icon">${it.icon ? html `<cm-icon name=${it.icon} size=${it.primary ? 16 : 24}></cm-icon>` : nothing}</span><span class="label">${it.label}</span>`;
62
+ const go = (e) => { if (!fireNavigate(this, it))
63
+ e.preventDefault(); };
64
+ return it.href
65
+ ? html `<a class=${cls} part="item" href=${it.href} aria-current=${it.current ? 'page' : nothing} @click=${go}>${inner}</a>`
66
+ : html `<button type="button" class=${cls} part="item" aria-current=${it.current ? 'page' : nothing} @click=${go}>${inner}</button>`;
67
+ };
68
+ CmBottomNavigation.properties = {
69
+ items: { type: Array },
70
+ label: {},
71
+ fixed: { type: Boolean, reflect: true },
72
+ _slotted: { state: true },
73
+ };
74
+ CmBottomNavigation.styles = [
75
+ base,
76
+ css `
77
+ :host { display: block; }
78
+ :host([fixed]) { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; }
79
+ nav {
80
+ background: var(--cm-bg-surface); border-radius: 16px 16px 0 0; box-shadow: var(--cm-shadow-100);
81
+ padding: 10px 6px calc(8px + env(safe-area-inset-bottom, 0px));
82
+ }
83
+ ul { display: flex; list-style: none; margin: 0; padding: 0; }
84
+ li { flex: 1; min-width: 0; display: flex; }
85
+ .item {
86
+ flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 48px; padding: 2px 2px 0;
87
+ font: inherit; font-size: 10px; font-weight: 500; letter-spacing: var(--cm-tracking-caps); text-transform: uppercase;
88
+ color: var(--cm-text-tertiary); text-decoration: none; background: none; border: 0; border-radius: var(--cm-radius-sm); cursor: pointer;
89
+ }
90
+ .item:hover, .item[aria-current='page'] { color: var(--cm-text-default); }
91
+ .item[aria-current='page'] .icon { color: var(--cm-icon-selected); }
92
+ .item:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 0; }
93
+ .icon { display: grid; place-items: center; width: 26px; height: 26px; }
94
+ .primary .icon { color: var(--cm-action-primary-text); background: var(--cm-action-primary); border-radius: var(--cm-radius-xs); }
95
+ .label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
96
+ `,
97
+ ];
98
+ define('cm-bottom-navigation', CmBottomNavigation);