@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,54 @@
1
+ import { CmOverlay } from '../overlay.js';
2
+ import { type MenuItem } from './menu-item.js';
3
+ import './icon.js';
4
+ /**
5
+ * A sheet that rises from the bottom of a phone screen with a few actions ("Mark as paid", "Generate invoice")
6
+ * or shortcuts ("Orders", "Add orders"). White with 20px top corners, a round black close button on its top
7
+ * edge, and rows split by thin lines. Rows without icons are centred; rows with icons line up left and end in a
8
+ * chevron. Use `cm-menu-item` children (or `items`); anything else in the sheet is shown as it is.
9
+ *
10
+ * A native modal `<dialog>`: the page behind is inert, Esc and the backdrop ask to close through `cm-close`,
11
+ * scrolling is locked, and focus returns to the opener.
12
+ * @element cm-bottom-sheet
13
+ * @slot - `cm-menu-item`s, or your own content.
14
+ * @fires cm-select - When a row is chosen. `detail: { value, item }`. Cancelable: `preventDefault()` keeps the sheet open (and stops a link).
15
+ * @fires cm-open - After the sheet opens.
16
+ * @fires cm-close - Before it closes from Esc, the backdrop or the close button. `detail: { reason }`. Cancelable.
17
+ * @fires cm-closed - After it has closed.
18
+ */
19
+ export declare class CmBottomSheet extends CmOverlay {
20
+ #private;
21
+ static properties: {
22
+ items: {
23
+ type: ArrayConstructor;
24
+ };
25
+ _slotted: {
26
+ state: boolean;
27
+ };
28
+ open: {
29
+ type: BooleanConstructor;
30
+ reflect: boolean;
31
+ };
32
+ heading: {};
33
+ label: {};
34
+ closeLabel: {
35
+ attribute: string;
36
+ };
37
+ };
38
+ /** Hidden title that names the sheet for screen readers, e.g. "Order actions". Set it (or `label`). */
39
+ heading: string;
40
+ /** Rows as data, used instead of `cm-menu-item` children when set. */
41
+ items: MenuItem[];
42
+ _slotted: MenuItem[];
43
+ static styles: import("lit").CSSResult[];
44
+ /** The rows in use. */
45
+ get sheetItems(): MenuItem[];
46
+ connectedCallback(): void;
47
+ disconnectedCallback(): void;
48
+ render(): import("lit-html").TemplateResult<1>;
49
+ }
50
+ declare global {
51
+ interface HTMLElementTagNameMap {
52
+ 'cm-bottom-sheet': CmBottomSheet;
53
+ }
54
+ }
@@ -0,0 +1,133 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _CmBottomSheet_instances, _CmBottomSheet_observer, _CmBottomSheet_choose, _CmBottomSheet_row;
13
+ import { html, css, nothing } from 'lit';
14
+ import { define } from '../base.js';
15
+ import { CmOverlay } from '../overlay.js';
16
+ import { readMenuItems, watchMenuItems } from './menu-item.js';
17
+ import './icon.js';
18
+ /**
19
+ * A sheet that rises from the bottom of a phone screen with a few actions ("Mark as paid", "Generate invoice")
20
+ * or shortcuts ("Orders", "Add orders"). White with 20px top corners, a round black close button on its top
21
+ * edge, and rows split by thin lines. Rows without icons are centred; rows with icons line up left and end in a
22
+ * chevron. Use `cm-menu-item` children (or `items`); anything else in the sheet is shown as it is.
23
+ *
24
+ * A native modal `<dialog>`: the page behind is inert, Esc and the backdrop ask to close through `cm-close`,
25
+ * scrolling is locked, and focus returns to the opener.
26
+ * @element cm-bottom-sheet
27
+ * @slot - `cm-menu-item`s, or your own content.
28
+ * @fires cm-select - When a row is chosen. `detail: { value, item }`. Cancelable: `preventDefault()` keeps the sheet open (and stops a link).
29
+ * @fires cm-open - After the sheet opens.
30
+ * @fires cm-close - Before it closes from Esc, the backdrop or the close button. `detail: { reason }`. Cancelable.
31
+ * @fires cm-closed - After it has closed.
32
+ */
33
+ export class CmBottomSheet extends CmOverlay {
34
+ constructor() {
35
+ super(...arguments);
36
+ _CmBottomSheet_instances.add(this);
37
+ /** Hidden title that names the sheet for screen readers, e.g. "Order actions". Set it (or `label`). */
38
+ this.heading = '';
39
+ /** Rows as data, used instead of `cm-menu-item` children when set. */
40
+ this.items = [];
41
+ this._slotted = [];
42
+ _CmBottomSheet_observer.set(this, void 0);
43
+ }
44
+ /** The rows in use. */
45
+ get sheetItems() { return this.items.length ? this.items : this._slotted; }
46
+ connectedCallback() {
47
+ super.connectedCallback();
48
+ this._slotted = readMenuItems(this);
49
+ __classPrivateFieldSet(this, _CmBottomSheet_observer, watchMenuItems(this, () => { this._slotted = readMenuItems(this); }), "f");
50
+ }
51
+ disconnectedCallback() {
52
+ super.disconnectedCallback();
53
+ __classPrivateFieldGet(this, _CmBottomSheet_observer, "f")?.disconnect();
54
+ }
55
+ render() {
56
+ const items = this.sheetItems.filter((it) => !it.divider);
57
+ const icons = items.some((it) => it.icon);
58
+ return this.renderDialog(html `<div class="panel" part="panel" tabindex="-1">
59
+ <button type="button" class="x" part="close" aria-label=${this.closeLabel || 'Close'} @click=${() => this.requestClose('close-button')}>
60
+ <cm-icon name="close" size="16"></cm-icon></button>
61
+ ${this.heading ? html `<h2 class="vh" id="${this.uid}-h">${this.heading}</h2>` : nothing}
62
+ <div class="content">
63
+ ${items.length ? html `<ul class=${icons ? 'icons' : ''} part="list">${items.map((it) => html `<li>${__classPrivateFieldGet(this, _CmBottomSheet_instances, "m", _CmBottomSheet_row).call(this, it)}</li>`)}</ul>` : nothing}
64
+ <slot ?hidden=${this._slotted.length > 0}></slot>
65
+ </div>
66
+ </div>`);
67
+ }
68
+ }
69
+ _CmBottomSheet_observer = new WeakMap(), _CmBottomSheet_instances = new WeakSet(), _CmBottomSheet_choose = function _CmBottomSheet_choose(e, it) {
70
+ if (it.disabled) {
71
+ e.preventDefault();
72
+ return;
73
+ }
74
+ const ok = this.dispatchEvent(new CustomEvent('cm-select', {
75
+ detail: { value: it.value ?? it.label, item: it }, bubbles: true, composed: true, cancelable: true,
76
+ }));
77
+ if (!ok) {
78
+ e.preventDefault();
79
+ return;
80
+ }
81
+ this.requestClose('action');
82
+ }, _CmBottomSheet_row = function _CmBottomSheet_row(it) {
83
+ const cls = `row${it.critical ? ' critical' : ''}`;
84
+ const inner = html `${it.icon ? html `<cm-icon class="lead" name=${it.icon} size="18"></cm-icon>` : nothing}<span class="label">${it.label}</span>${it.icon ? html `<cm-icon name="chevron-right" size="16"></cm-icon>` : nothing}`;
85
+ return it.href && !it.disabled
86
+ ? html `<a class=${cls} part="row" href=${it.href} @click=${(e) => __classPrivateFieldGet(this, _CmBottomSheet_instances, "m", _CmBottomSheet_choose).call(this, e, it)}>${inner}</a>`
87
+ : html `<button type="button" class=${cls} part="row" aria-disabled=${it.disabled ? 'true' : nothing}
88
+ @click=${(e) => __classPrivateFieldGet(this, _CmBottomSheet_instances, "m", _CmBottomSheet_choose).call(this, e, it)}>${inner}</button>`;
89
+ };
90
+ CmBottomSheet.properties = {
91
+ ...CmOverlay.properties,
92
+ items: { type: Array },
93
+ _slotted: { state: true },
94
+ };
95
+ CmBottomSheet.styles = [
96
+ ...CmOverlay.overlayStyles,
97
+ css `
98
+ dialog {
99
+ position: fixed; inset: auto 0 0 0; margin: 0 auto; width: min(600px, 100vw); padding-top: 22px;
100
+ }
101
+ .panel {
102
+ position: relative; overflow: visible; max-height: calc(100dvh - 80px); padding: 18px var(--cm-space-20) max(var(--cm-space-20), env(safe-area-inset-bottom));
103
+ border-radius: 20px 20px 0 0; box-shadow: var(--cm-shadow-100);
104
+ }
105
+ .x {
106
+ position: absolute; top: -18px; left: 50%; transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%;
107
+ background: var(--cm-bg-panel-header); color: var(--cm-text-on-dark);
108
+ }
109
+ .x:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
110
+ .content { overflow: auto; min-height: 0; }
111
+ ul { list-style: none; margin: 0; padding: 0; }
112
+ li + li { border-top: var(--cm-border-1) solid var(--cm-border-default); }
113
+ .row {
114
+ display: flex; align-items: center; justify-content: center; gap: var(--cm-space-10); width: 100%; min-height: 44px; padding: 8px 4px;
115
+ font: inherit; font-size: 14px; color: var(--cm-text-default); text-decoration: none; background: none; border: 0; cursor: pointer;
116
+ }
117
+ .icons .row { justify-content: flex-start; }
118
+ .row .label { overflow-wrap: anywhere; }
119
+ .icons .row .label { flex: 1; text-align: start; }
120
+ .row.critical { color: var(--cm-text-critical); }
121
+ .row[aria-disabled='true'] { color: var(--cm-text-secondary); cursor: default; }
122
+ .row:hover:not([aria-disabled='true']):not(.critical) { background: var(--cm-bg-hover); }
123
+ .row.critical:hover { text-decoration: underline; } /* text-critical on bg-hover is under 4.5:1 in dark */
124
+ .row:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: -2px; border-radius: var(--cm-radius-sm); }
125
+ .lead { color: var(--cm-icon-default); }
126
+ @media (prefers-reduced-motion: no-preference) {
127
+ dialog[open] .panel { animation: cm-sheet-in 200ms ease-out; }
128
+ }
129
+ @keyframes cm-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
130
+ .vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
131
+ `,
132
+ ];
133
+ define('cm-bottom-sheet', CmBottomSheet);
@@ -0,0 +1,53 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Black primary or outlined secondary action.
4
+ * @element cm-button
5
+ * @slot - Label.
6
+ * @slot icon - Optional leading icon.
7
+ * @fires click - Native click; suppressed while disabled or loading.
8
+ */
9
+ export declare class CmButton extends LitElement {
10
+ #private;
11
+ static formAssociated: boolean;
12
+ static properties: {
13
+ variant: {
14
+ reflect: boolean;
15
+ };
16
+ size: {
17
+ reflect: boolean;
18
+ };
19
+ type: {};
20
+ disabled: {
21
+ type: BooleanConstructor;
22
+ reflect: boolean;
23
+ };
24
+ loading: {
25
+ type: BooleanConstructor;
26
+ reflect: boolean;
27
+ };
28
+ href: {};
29
+ target: {};
30
+ };
31
+ /** `primary` = black fill (one per group); `secondary` = light fill, black outline. */
32
+ variant: 'primary' | 'secondary';
33
+ /** `large` 46px (save bars), `medium` 32px, `slim` 24px. */
34
+ size: 'large' | 'medium' | 'slim';
35
+ /** Form behaviour when inside a `<form>`: `submit` submits it, `reset` resets it. */
36
+ type: 'button' | 'submit' | 'reset';
37
+ /** Blocks clicks and dims the button. Prefer explaining why nearby. */
38
+ disabled: boolean;
39
+ /** Shows a spinner and blocks clicks while an action runs. */
40
+ loading: boolean;
41
+ /** Renders a link styled as a button. */
42
+ href?: string;
43
+ /** Link target when `href` is set. `_blank` adds `rel="noopener noreferrer"`. */
44
+ target?: string;
45
+ static styles: import("lit").CSSResult[];
46
+ constructor();
47
+ render(): import("lit-html").TemplateResult<1>;
48
+ }
49
+ declare global {
50
+ interface HTMLElementTagNameMap {
51
+ 'cm-button': CmButton;
52
+ }
53
+ }
@@ -0,0 +1,101 @@
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 _CmButton_internals, _CmButton_onClick;
7
+ import { LitElement, html, css, nothing } from 'lit';
8
+ import { base, define } from '../base.js';
9
+ /**
10
+ * Black primary or outlined secondary action.
11
+ * @element cm-button
12
+ * @slot - Label.
13
+ * @slot icon - Optional leading icon.
14
+ * @fires click - Native click; suppressed while disabled or loading.
15
+ */
16
+ export class CmButton extends LitElement {
17
+ constructor() {
18
+ super();
19
+ /** `primary` = black fill (one per group); `secondary` = light fill, black outline. */
20
+ this.variant = 'secondary';
21
+ /** `large` 46px (save bars), `medium` 32px, `slim` 24px. */
22
+ this.size = 'medium';
23
+ /** Form behaviour when inside a `<form>`: `submit` submits it, `reset` resets it. */
24
+ this.type = 'button';
25
+ /** Blocks clicks and dims the button. Prefer explaining why nearby. */
26
+ this.disabled = false;
27
+ /** Shows a spinner and blocks clicks while an action runs. */
28
+ this.loading = false;
29
+ _CmButton_internals.set(this, this.attachInternals());
30
+ _CmButton_onClick.set(this, (e) => {
31
+ if (this.disabled || this.loading) {
32
+ e.preventDefault();
33
+ e.stopImmediatePropagation();
34
+ return;
35
+ }
36
+ const form = __classPrivateFieldGet(this, _CmButton_internals, "f").form;
37
+ if (!form || this.href)
38
+ return;
39
+ if (this.type === 'submit')
40
+ form.requestSubmit();
41
+ else if (this.type === 'reset')
42
+ form.reset();
43
+ });
44
+ this.addEventListener('click', __classPrivateFieldGet(this, _CmButton_onClick, "f"), { capture: true });
45
+ }
46
+ render() {
47
+ const inner = html `${this.loading ? html `<span class="spinner" aria-hidden="true"></span>` : html `<slot name="icon"></slot>`}<slot></slot>`;
48
+ if (this.href && !this.disabled) {
49
+ return html `<a class="btn" part="control" href=${this.href} target=${this.target ?? nothing}
50
+ rel=${this.target === '_blank' ? 'noopener noreferrer' : nothing}>${inner}</a>`;
51
+ }
52
+ return html `<button class="btn" part="control" type="button"
53
+ ?disabled=${this.disabled} aria-disabled=${this.loading ? 'true' : nothing}
54
+ aria-busy=${this.loading ? 'true' : nothing}>${inner}</button>`;
55
+ }
56
+ }
57
+ _CmButton_internals = new WeakMap(), _CmButton_onClick = new WeakMap();
58
+ CmButton.formAssociated = true;
59
+ CmButton.properties = {
60
+ variant: { reflect: true },
61
+ size: { reflect: true },
62
+ type: {},
63
+ disabled: { type: Boolean, reflect: true },
64
+ loading: { type: Boolean, reflect: true },
65
+ href: {},
66
+ target: {},
67
+ };
68
+ CmButton.styles = [
69
+ base,
70
+ css `
71
+ :host { display: inline-flex; vertical-align: middle; }
72
+ .btn {
73
+ display: inline-flex; align-items: center; justify-content: center; gap: 6px;
74
+ width: 100%; font: inherit; font-weight: 500; line-height: 1; white-space: nowrap;
75
+ border-radius: var(--cm-radius-sm); border: var(--cm-border-1) solid transparent;
76
+ cursor: pointer; text-decoration: none;
77
+ }
78
+ :host([size='large']) .btn { height: 46px; padding: 0 var(--cm-space-20); font-size: 16px; }
79
+ .btn, :host([size='medium']) .btn { height: 32px; padding: 0 var(--cm-space-15); font-size: 12px; }
80
+ :host([size='slim']) .btn { height: 24px; padding: 0 var(--cm-space-10); font-size: 10px; }
81
+ :host([variant='primary']) .btn { background: var(--cm-action-primary); color: var(--cm-action-primary-text); border-color: var(--cm-action-primary); }
82
+ :host([variant='primary']) .btn:hover { background: var(--cm-action-primary-hover); border-color: var(--cm-action-primary-hover); }
83
+ .btn, :host([variant='secondary']) .btn {
84
+ background: var(--cm-bg-hover); color: var(--cm-text-default); border-color: var(--cm-border-strong);
85
+ }
86
+ :host([variant='secondary']) .btn:hover { background: var(--cm-bg-surface); }
87
+ :host([disabled]) .btn, :host([loading]) .btn {
88
+ background: var(--cm-action-disabled); border-color: var(--cm-action-disabled); color: var(--cm-action-disabled-text); cursor: not-allowed;
89
+ }
90
+ .btn:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
91
+ .spinner {
92
+ width: 1em; height: 1em; border-radius: 50%;
93
+ border: 2px solid currentColor; border-right-color: transparent;
94
+ animation: spin .7s linear infinite;
95
+ }
96
+ @keyframes spin { to { transform: rotate(360deg); } }
97
+ @media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
98
+ ::slotted([slot='icon']) { display: inline-flex; }
99
+ `,
100
+ ];
101
+ define('cm-button', CmButton);
@@ -0,0 +1,37 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * White section card with optional title, description and header actions.
4
+ * @element cm-card
5
+ * @slot - Body.
6
+ * @slot actions - Header actions (buttons, links), right-aligned.
7
+ * @slot title-adornment - Badge or icon next to the title.
8
+ */
9
+ export declare class CmCard extends LitElement {
10
+ static properties: {
11
+ heading: {};
12
+ description: {};
13
+ flush: {
14
+ type: BooleanConstructor;
15
+ reflect: boolean;
16
+ };
17
+ headingLevel: {
18
+ type: NumberConstructor;
19
+ attribute: string;
20
+ };
21
+ };
22
+ /** Card title, rendered as a heading at `heading-level`. */
23
+ heading: string;
24
+ /** One sentence under the title in text-tertiary. */
25
+ description: string;
26
+ /** Removes body padding, for lists and tables that run edge to edge. */
27
+ flush: boolean;
28
+ /** Heading level for the title, so pages keep a correct outline. Default 2. */
29
+ headingLevel: 2 | 3 | 4 | 5 | 6;
30
+ static styles: import("lit").CSSResult[];
31
+ render(): import("lit-html").TemplateResult<1>;
32
+ }
33
+ declare global {
34
+ interface HTMLElementTagNameMap {
35
+ 'cm-card': CmCard;
36
+ }
37
+ }
@@ -0,0 +1,58 @@
1
+ import { LitElement, html, css, nothing } from 'lit';
2
+ import { base, define } from '../base.js';
3
+ /**
4
+ * White section card with optional title, description and header actions.
5
+ * @element cm-card
6
+ * @slot - Body.
7
+ * @slot actions - Header actions (buttons, links), right-aligned.
8
+ * @slot title-adornment - Badge or icon next to the title.
9
+ */
10
+ export class CmCard extends LitElement {
11
+ constructor() {
12
+ super(...arguments);
13
+ /** Card title, rendered as a heading at `heading-level`. */
14
+ this.heading = '';
15
+ /** One sentence under the title in text-tertiary. */
16
+ this.description = '';
17
+ /** Removes body padding, for lists and tables that run edge to edge. */
18
+ this.flush = false;
19
+ /** Heading level for the title, so pages keep a correct outline. Default 2. */
20
+ this.headingLevel = 2;
21
+ }
22
+ render() {
23
+ const level = Math.min(6, Math.max(2, this.headingLevel || 2));
24
+ const title = this.heading
25
+ ? html `<div role="heading" aria-level=${level} class="title" part="title">${this.heading}<slot name="title-adornment"></slot></div>`
26
+ : nothing;
27
+ return html `<section part="card" aria-label=${this.heading || nothing}>
28
+ ${this.heading || this.description
29
+ ? html `<header><div>${title}${this.description ? html `<p class="desc">${this.description}</p>` : nothing}</div>
30
+ <div class="actions"><slot name="actions"></slot></div></header>`
31
+ : nothing}
32
+ <slot></slot>
33
+ </section>`;
34
+ }
35
+ }
36
+ CmCard.properties = {
37
+ heading: {},
38
+ description: {},
39
+ flush: { type: Boolean, reflect: true },
40
+ headingLevel: { type: Number, attribute: 'heading-level' },
41
+ };
42
+ CmCard.styles = [
43
+ base,
44
+ css `
45
+ :host { display: block; }
46
+ section {
47
+ background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-card);
48
+ border-radius: var(--cm-radius-md); padding: var(--cm-space-20);
49
+ }
50
+ :host([flush]) section { padding: 0; }
51
+ header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--cm-space-20); margin-bottom: var(--cm-space-20); }
52
+ :host([flush]) header { padding: var(--cm-space-20) var(--cm-space-20) 0; }
53
+ .title { margin: 0; font-size: var(--cm-type-heading-sm-size); font-weight: 600; display: flex; align-items: center; gap: var(--cm-space-10); }
54
+ .desc { margin: 6px 0 0; font-size: 16px; color: var(--cm-text-tertiary); }
55
+ .actions { display: flex; gap: var(--cm-space-20); align-items: center; }
56
+ `,
57
+ ];
58
+ define('cm-card', CmCard);
@@ -0,0 +1,68 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Checkbox with label and optional description. Participates in native forms.
4
+ * @element cm-checkbox
5
+ * @slot - Rich label content, used instead of `label`.
6
+ * @fires change - When toggled by the user.
7
+ */
8
+ export declare class CmCheckbox extends LitElement {
9
+ #private;
10
+ static formAssociated: boolean;
11
+ static shadowRootOptions: {
12
+ delegatesFocus: boolean;
13
+ mode: ShadowRootMode;
14
+ serializable?: boolean;
15
+ slotAssignment?: SlotAssignmentMode;
16
+ };
17
+ static properties: {
18
+ label: {};
19
+ description: {};
20
+ name: {
21
+ reflect: boolean;
22
+ };
23
+ value: {};
24
+ checked: {
25
+ type: BooleanConstructor;
26
+ reflect: boolean;
27
+ };
28
+ indeterminate: {
29
+ type: BooleanConstructor;
30
+ };
31
+ disabled: {
32
+ type: BooleanConstructor;
33
+ reflect: boolean;
34
+ };
35
+ required: {
36
+ type: BooleanConstructor;
37
+ };
38
+ };
39
+ /** Visible label. Capitalised automatically in the original design; write it in sentence case. */
40
+ label: string;
41
+ /** Help text under the label, linked for screen readers. */
42
+ description: string;
43
+ /** Form field name. */
44
+ name: string;
45
+ /** Submitted value when checked. */
46
+ value: string;
47
+ /** Whether the box is ticked. Reflects to the attribute. */
48
+ checked: boolean;
49
+ /** Mixed state, for a "select all" box when only some rows are selected. */
50
+ indeterminate: boolean;
51
+ /** Blocks interaction. Also set by a disabled `<fieldset>`. */
52
+ disabled: boolean;
53
+ /** Form will not submit until ticked. */
54
+ required: boolean;
55
+ static styles: import("lit").CSSResult[];
56
+ connectedCallback(): void;
57
+ get form(): HTMLFormElement | null;
58
+ checkValidity(): boolean;
59
+ formResetCallback(): void;
60
+ formDisabledCallback(d: boolean): void;
61
+ updated(): void;
62
+ render(): import("lit-html").TemplateResult<1>;
63
+ }
64
+ declare global {
65
+ interface HTMLElementTagNameMap {
66
+ 'cm-checkbox': CmCheckbox;
67
+ }
68
+ }
@@ -0,0 +1,114 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _CmCheckbox_instances, _CmCheckbox_internals, _CmCheckbox_id, _CmCheckbox_defaultChecked, _CmCheckbox_onChange;
13
+ import { LitElement, html, css, nothing } from 'lit';
14
+ import { base, define, nextId } from '../base.js';
15
+ /**
16
+ * Checkbox with label and optional description. Participates in native forms.
17
+ * @element cm-checkbox
18
+ * @slot - Rich label content, used instead of `label`.
19
+ * @fires change - When toggled by the user.
20
+ */
21
+ export class CmCheckbox extends LitElement {
22
+ constructor() {
23
+ super(...arguments);
24
+ _CmCheckbox_instances.add(this);
25
+ /** Visible label. Capitalised automatically in the original design; write it in sentence case. */
26
+ this.label = '';
27
+ /** Help text under the label, linked for screen readers. */
28
+ this.description = '';
29
+ /** Form field name. */
30
+ this.name = '';
31
+ /** Submitted value when checked. */
32
+ this.value = 'on';
33
+ /** Whether the box is ticked. Reflects to the attribute. */
34
+ this.checked = false;
35
+ /** Mixed state, for a "select all" box when only some rows are selected. */
36
+ this.indeterminate = false;
37
+ /** Blocks interaction. Also set by a disabled `<fieldset>`. */
38
+ this.disabled = false;
39
+ /** Form will not submit until ticked. */
40
+ this.required = false;
41
+ _CmCheckbox_internals.set(this, this.attachInternals());
42
+ _CmCheckbox_id.set(this, nextId('cm-cb'));
43
+ _CmCheckbox_defaultChecked.set(this, false);
44
+ }
45
+ connectedCallback() {
46
+ super.connectedCallback();
47
+ __classPrivateFieldSet(this, _CmCheckbox_defaultChecked, this.checked, "f");
48
+ }
49
+ get form() { return __classPrivateFieldGet(this, _CmCheckbox_internals, "f").form; }
50
+ checkValidity() { return __classPrivateFieldGet(this, _CmCheckbox_internals, "f").checkValidity(); }
51
+ formResetCallback() { this.checked = __classPrivateFieldGet(this, _CmCheckbox_defaultChecked, "f"); }
52
+ formDisabledCallback(d) { this.disabled = d; }
53
+ updated() {
54
+ __classPrivateFieldGet(this, _CmCheckbox_internals, "f").setFormValue(this.checked ? this.value : null);
55
+ if (this.required && !this.checked)
56
+ __classPrivateFieldGet(this, _CmCheckbox_internals, "f").setValidity({ valueMissing: true }, 'Please tick this box.');
57
+ else
58
+ __classPrivateFieldGet(this, _CmCheckbox_internals, "f").setValidity({});
59
+ }
60
+ render() {
61
+ const mark = this.indeterminate
62
+ ? html `<svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true"><path d="M2 6h8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`
63
+ : html `<svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true"><path d="M2 6.2 4.8 9 10 3" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
64
+ return html `<label for=${__classPrivateFieldGet(this, _CmCheckbox_id, "f")}>
65
+ <input type="checkbox" id=${__classPrivateFieldGet(this, _CmCheckbox_id, "f")} .checked=${this.checked} .indeterminate=${this.indeterminate}
66
+ ?disabled=${this.disabled} ?required=${this.required}
67
+ aria-describedby=${this.description ? `${__classPrivateFieldGet(this, _CmCheckbox_id, "f")}-d` : nothing} @change=${__classPrivateFieldGet(this, _CmCheckbox_instances, "m", _CmCheckbox_onChange)} />
68
+ <span class="box" part="box">${mark}</span>
69
+ ${this.label || this.description
70
+ ? html `<span class="text"><span class="label">${this.label}<slot></slot></span>${this.description ? html `<span class="desc" id="${__classPrivateFieldGet(this, _CmCheckbox_id, "f")}-d">${this.description}</span>` : nothing}</span>`
71
+ : html `<slot></slot>`}
72
+ </label>`;
73
+ }
74
+ }
75
+ _CmCheckbox_internals = new WeakMap(), _CmCheckbox_id = new WeakMap(), _CmCheckbox_defaultChecked = new WeakMap(), _CmCheckbox_instances = new WeakSet(), _CmCheckbox_onChange = function _CmCheckbox_onChange(e) {
76
+ const input = e.target;
77
+ this.checked = input.checked;
78
+ this.indeterminate = false;
79
+ this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
80
+ };
81
+ CmCheckbox.formAssociated = true;
82
+ CmCheckbox.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
83
+ CmCheckbox.properties = {
84
+ label: {},
85
+ description: {},
86
+ name: { reflect: true },
87
+ value: {},
88
+ checked: { type: Boolean, reflect: true },
89
+ indeterminate: { type: Boolean },
90
+ disabled: { type: Boolean, reflect: true },
91
+ required: { type: Boolean },
92
+ };
93
+ CmCheckbox.styles = [
94
+ base,
95
+ css `
96
+ :host { display: inline-flex; }
97
+ label { position: relative; display: inline-flex; align-items: flex-start; gap: var(--cm-space-10); cursor: pointer; }
98
+ input { position: absolute; opacity: 0; width: 20px; height: 20px; margin: 0; cursor: inherit; }
99
+ .box {
100
+ flex: none; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
101
+ border: var(--cm-border-1) solid var(--cm-border-strong); border-radius: var(--cm-radius-xs);
102
+ background: var(--cm-bg-surface); color: transparent;
103
+ }
104
+ input:checked + .box, input:indeterminate + .box { color: var(--cm-text-default); }
105
+ input:focus-visible + .box { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
106
+ .text { display: flex; flex-direction: column; gap: 6px; padding-top: 1px; }
107
+ .label { font-size: 16px; }
108
+ .desc { font-size: 12px; color: var(--cm-text-tertiary); }
109
+ :host([disabled]) label { cursor: not-allowed; }
110
+ :host([disabled]) .box { background: var(--cm-bg-input-filled); border-color: var(--cm-border-default); }
111
+ :host([disabled]) .label { color: var(--cm-text-secondary); }
112
+ `,
113
+ ];
114
+ define('cm-checkbox', CmCheckbox);