@commmerce/ui 1.5.2 → 1.6.0
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.
- package/dist/calendar.js +2 -0
- package/dist/cdn.js +1004 -645
- package/dist/components/action-menu.d.ts +28 -1
- package/dist/components/action-menu.js +86 -17
- package/dist/components/badge.d.ts +3 -2
- package/dist/components/badge.js +4 -3
- package/dist/components/bottom-sheet.js +1 -1
- package/dist/components/button.d.ts +5 -1
- package/dist/components/button.js +18 -6
- package/dist/components/card.d.ts +38 -0
- package/dist/components/card.js +77 -12
- package/dist/components/checkbox.js +7 -2
- package/dist/components/color-field.js +2 -0
- package/dist/components/combobox.d.ts +27 -2
- package/dist/components/combobox.js +109 -15
- package/dist/components/data-table.d.ts +127 -9
- package/dist/components/data-table.js +577 -67
- package/dist/components/date-picker.d.ts +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-range-picker.d.ts +1 -1
- package/dist/components/date-range-picker.js +2 -2
- package/dist/components/empty-state.d.ts +8 -6
- package/dist/components/empty-state.js +26 -17
- package/dist/components/file-upload.d.ts +49 -4
- package/dist/components/file-upload.js +136 -29
- package/dist/components/layout.d.ts +2 -2
- package/dist/components/layout.js +5 -5
- package/dist/components/menu-item.d.ts +18 -0
- package/dist/components/menu-item.js +8 -0
- package/dist/components/page-header.d.ts +6 -0
- package/dist/components/page-header.js +22 -5
- package/dist/components/pagination.d.ts +3 -2
- package/dist/components/pagination.js +13 -10
- package/dist/components/radio.js +4 -2
- package/dist/components/resource-list.d.ts +28 -3
- package/dist/components/resource-list.js +47 -15
- package/dist/components/search.d.ts +2 -2
- package/dist/components/search.js +4 -2
- package/dist/components/segmented-control.js +1 -1
- package/dist/components/select.d.ts +11 -1
- package/dist/components/select.js +17 -4
- package/dist/components/side-navigation.d.ts +1 -1
- package/dist/components/side-navigation.js +5 -3
- package/dist/components/signature-field.js +2 -2
- package/dist/components/status-tabs.d.ts +24 -4
- package/dist/components/status-tabs.js +82 -9
- package/dist/components/table-header.d.ts +1 -1
- package/dist/components/table-header.js +3 -3
- package/dist/components/tag.d.ts +7 -0
- package/dist/components/tag.js +6 -3
- package/dist/components/text-field.d.ts +1 -1
- package/dist/components/text-field.js +3 -1
- package/dist/components/toggle.js +3 -1
- package/dist/components/tooltip.d.ts +5 -2
- package/dist/components/tooltip.js +14 -9
- package/dist/custom-elements.json +1594 -137
- package/dist/density.d.ts +21 -0
- package/dist/density.js +46 -0
- package/dist/field.d.ts +9 -5
- package/dist/field.js +16 -10
- package/dist/index.d.ts +1 -1
- package/dist/popover.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Row density for tables and lists (since 1.6): `comfortable` (the default) or `compact`.
|
|
3
|
+
*
|
|
4
|
+
* A screen switches every table and list inside it with `data-cm-density="compact"` on any ancestor (`<body>`, a
|
|
5
|
+
* page, a card). The rule below turns that attribute into custom properties, which inherit into the components'
|
|
6
|
+
* shadow roots; a component's own `density` attribute overrides it. Components read the properties with their
|
|
7
|
+
* comfortable value as the fallback, so a page that never sets a density gets comfortable rows.
|
|
8
|
+
*
|
|
9
|
+
* --cm-table-row-height data table body rows: 48px comfortable, 40px compact
|
|
10
|
+
* --cm-resource-row-height resource list rows: 56px comfortable, 40px compact
|
|
11
|
+
* --cm-resource-row-padding resource list rows' padding above and below: 8px / 4px
|
|
12
|
+
* --cm-resource-media-size resource list thumbnails: 40px / 32px
|
|
13
|
+
*
|
|
14
|
+
* On touch screens (pointer: coarse) rows stay at least 44px tall (`--cm-control-height-touch`) at either density.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DENSITY_CSS = "\n[data-cm-density=\"compact\"] { --cm-table-row-height: 40px; --cm-resource-row-height: 40px; --cm-resource-row-padding: 4px; --cm-resource-media-size: 32px; }\n[data-cm-density=\"comfortable\"] { --cm-table-row-height: 48px; --cm-resource-row-height: 56px; --cm-resource-row-padding: 8px; --cm-resource-media-size: 40px; }\n";
|
|
17
|
+
/**
|
|
18
|
+
* Adds the density rule to the document (or shadow root) the element lives in, once. Inside another component's
|
|
19
|
+
* shadow root the rule is added there too, so an ancestor in that tree can set `data-cm-density`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function adoptDensity(el: Element): void;
|
package/dist/density.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Row density for tables and lists (since 1.6): `comfortable` (the default) or `compact`.
|
|
3
|
+
*
|
|
4
|
+
* A screen switches every table and list inside it with `data-cm-density="compact"` on any ancestor (`<body>`, a
|
|
5
|
+
* page, a card). The rule below turns that attribute into custom properties, which inherit into the components'
|
|
6
|
+
* shadow roots; a component's own `density` attribute overrides it. Components read the properties with their
|
|
7
|
+
* comfortable value as the fallback, so a page that never sets a density gets comfortable rows.
|
|
8
|
+
*
|
|
9
|
+
* --cm-table-row-height data table body rows: 48px comfortable, 40px compact
|
|
10
|
+
* --cm-resource-row-height resource list rows: 56px comfortable, 40px compact
|
|
11
|
+
* --cm-resource-row-padding resource list rows' padding above and below: 8px / 4px
|
|
12
|
+
* --cm-resource-media-size resource list thumbnails: 40px / 32px
|
|
13
|
+
*
|
|
14
|
+
* On touch screens (pointer: coarse) rows stay at least 44px tall (`--cm-control-height-touch`) at either density.
|
|
15
|
+
*/
|
|
16
|
+
export const DENSITY_CSS = `
|
|
17
|
+
[data-cm-density="compact"] { --cm-table-row-height: 40px; --cm-resource-row-height: 40px; --cm-resource-row-padding: 4px; --cm-resource-media-size: 32px; }
|
|
18
|
+
[data-cm-density="comfortable"] { --cm-table-row-height: 48px; --cm-resource-row-height: 56px; --cm-resource-row-padding: 8px; --cm-resource-media-size: 40px; }
|
|
19
|
+
`;
|
|
20
|
+
let sheet = null;
|
|
21
|
+
const adopted = new WeakSet();
|
|
22
|
+
/**
|
|
23
|
+
* Adds the density rule to the document (or shadow root) the element lives in, once. Inside another component's
|
|
24
|
+
* shadow root the rule is added there too, so an ancestor in that tree can set `data-cm-density`.
|
|
25
|
+
*/
|
|
26
|
+
export function adoptDensity(el) {
|
|
27
|
+
if (typeof document === 'undefined' || typeof CSSStyleSheet === 'undefined')
|
|
28
|
+
return;
|
|
29
|
+
const roots = [document];
|
|
30
|
+
const root = el.getRootNode();
|
|
31
|
+
if (root instanceof ShadowRoot)
|
|
32
|
+
roots.push(root);
|
|
33
|
+
for (const r of roots) {
|
|
34
|
+
if (adopted.has(r))
|
|
35
|
+
continue;
|
|
36
|
+
adopted.add(r);
|
|
37
|
+
try {
|
|
38
|
+
if (!sheet) {
|
|
39
|
+
sheet = new CSSStyleSheet();
|
|
40
|
+
sheet.replaceSync(DENSITY_CSS);
|
|
41
|
+
}
|
|
42
|
+
r.adoptedStyleSheets = [...r.adoptedStyleSheets, sheet];
|
|
43
|
+
}
|
|
44
|
+
catch { /* very old browsers: compact density then comes only from the component's own attribute */ }
|
|
45
|
+
}
|
|
46
|
+
}
|
package/dist/field.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The field scale
|
|
3
|
-
* cm-date-picker, cm-date-range-picker and cm-color-field.
|
|
2
|
+
* The field scale, shared by every labelled form control: cm-text-field, cm-select, cm-combobox, cm-search,
|
|
3
|
+
* cm-date-picker, cm-date-range-picker and cm-color-field. Owner standard (1.6, issue #33; 1.5 drew 36px fields).
|
|
4
4
|
*
|
|
5
|
-
* - Box height `--_cm-field-h`:
|
|
5
|
+
* - Box height `--_cm-field-h`: 40px (`--cm-control-height-lg`), 32px with `size="small"` (toolbars and filter rows),
|
|
6
6
|
* 44px on touch screens (`pointer: coarse`) whatever the size, so every field stays easy to tap.
|
|
7
7
|
* - Value text 14px; 16px on touch screens, where smaller text makes iOS Safari zoom the page on focus.
|
|
8
|
-
* - Label
|
|
8
|
+
* - Label 13px medium (`type-label`), 8px above the box (4px when small); help and error text 12/16 under it.
|
|
9
9
|
*
|
|
10
10
|
* A component sets `height: var(--_cm-field-h)` and `font-size: var(--_cm-field-font)` on its box and uses the
|
|
11
11
|
* `.field`, `.label`, `.req`, `.hint`, `.help` and `.error` classes.
|
|
12
12
|
*/
|
|
13
13
|
export declare const fieldStyles: import("lit").CSSResult;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Options in a dropdown list (cm-select, cm-combobox), the same rows as cm-action-menu items (owner standard, 1.6):
|
|
16
|
+
* 36px rows of 14px text with 12px side padding (32px with `size="small"`), 44px on touch screens; group headings
|
|
17
|
+
* 12px (`groupStyles`). Hover and the keyboard-active row share `bg-hover`; pressed darkens it a little.
|
|
18
|
+
*/
|
|
15
19
|
export declare const optionStyles: import("lit").CSSResult;
|
package/dist/field.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
2
|
/**
|
|
3
|
-
* The field scale
|
|
4
|
-
* cm-date-picker, cm-date-range-picker and cm-color-field.
|
|
3
|
+
* The field scale, shared by every labelled form control: cm-text-field, cm-select, cm-combobox, cm-search,
|
|
4
|
+
* cm-date-picker, cm-date-range-picker and cm-color-field. Owner standard (1.6, issue #33; 1.5 drew 36px fields).
|
|
5
5
|
*
|
|
6
|
-
* - Box height `--_cm-field-h`:
|
|
6
|
+
* - Box height `--_cm-field-h`: 40px (`--cm-control-height-lg`), 32px with `size="small"` (toolbars and filter rows),
|
|
7
7
|
* 44px on touch screens (`pointer: coarse`) whatever the size, so every field stays easy to tap.
|
|
8
8
|
* - Value text 14px; 16px on touch screens, where smaller text makes iOS Safari zoom the page on focus.
|
|
9
|
-
* - Label
|
|
9
|
+
* - Label 13px medium (`type-label`), 8px above the box (4px when small); help and error text 12/16 under it.
|
|
10
10
|
*
|
|
11
11
|
* A component sets `height: var(--_cm-field-h)` and `font-size: var(--_cm-field-font)` on its box and uses the
|
|
12
12
|
* `.field`, `.label`, `.req`, `.hint`, `.help` and `.error` classes.
|
|
13
13
|
*/
|
|
14
14
|
export const fieldStyles = css `
|
|
15
15
|
:host {
|
|
16
|
-
--_cm-field-h: var(--cm-control-height-
|
|
16
|
+
--_cm-field-h: var(--cm-control-height-lg, 40px);
|
|
17
17
|
--_cm-field-font: var(--cm-font-size-14, 14px);
|
|
18
18
|
--_cm-field-pad: var(--cm-space-12, 12px);
|
|
19
19
|
}
|
|
@@ -27,21 +27,27 @@ export const fieldStyles = css `
|
|
|
27
27
|
color: var(--cm-text-default);
|
|
28
28
|
}
|
|
29
29
|
.req { color: var(--cm-text-critical); margin-inline-start: 2px; }
|
|
30
|
-
.hint { margin-inline-start: var(--cm-space-8); font-size: var(--cm-type-body-
|
|
31
|
-
.help, .error { margin: 0; font-size: var(--cm-type-body-
|
|
30
|
+
.hint { margin-inline-start: var(--cm-space-8); font-size: var(--cm-type-body-xs-size); font-weight: 400; color: var(--cm-text-tertiary); text-transform: lowercase; }
|
|
31
|
+
.help, .error { margin: 0; font-size: var(--cm-type-body-xs-size); line-height: var(--cm-type-body-xs-line-height); color: var(--cm-text-tertiary); }
|
|
32
32
|
.error { color: var(--cm-text-critical); }
|
|
33
33
|
:host([size='small']) .field { gap: var(--cm-space-4); }
|
|
34
34
|
:host([size='small']) .label { font-size: var(--cm-font-size-13); line-height: var(--cm-line-height-13); }
|
|
35
35
|
`;
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Options in a dropdown list (cm-select, cm-combobox), the same rows as cm-action-menu items (owner standard, 1.6):
|
|
38
|
+
* 36px rows of 14px text with 12px side padding (32px with `size="small"`), 44px on touch screens; group headings
|
|
39
|
+
* 12px (`groupStyles`). Hover and the keyboard-active row share `bg-hover`; pressed darkens it a little.
|
|
40
|
+
*/
|
|
37
41
|
export const optionStyles = css `
|
|
38
42
|
[role='listbox'] {
|
|
39
43
|
max-height: 264px; overflow-y: auto; margin: 0; padding: var(--cm-space-4); list-style: none;
|
|
40
44
|
}
|
|
41
45
|
[role='option'] {
|
|
42
|
-
display: flex; align-items: center; min-height: var(--cm-control-height-
|
|
46
|
+
display: flex; align-items: center; min-height: var(--cm-control-height-md, 36px); padding: var(--cm-space-4) var(--cm-space-12);
|
|
43
47
|
font-size: var(--cm-font-size-14); line-height: var(--cm-line-height-14); color: var(--cm-text-default);
|
|
44
48
|
border-radius: var(--cm-radius-sm); cursor: pointer;
|
|
45
49
|
}
|
|
46
|
-
|
|
50
|
+
[role='option']:not([aria-disabled='true']):not([aria-selected='true']):active { background: color-mix(in srgb, var(--cm-bg-hover), var(--cm-text-default) 8%); }
|
|
51
|
+
:host([size='small']) [role='option'] { min-height: var(--cm-control-height-sm, 32px); }
|
|
52
|
+
@media (pointer: coarse) { [role='option'], :host([size='small']) [role='option'] { min-height: var(--cm-control-height-touch, 44px); } }
|
|
47
53
|
`;
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export { CmStatusTabs } from './components/status-tabs.js';
|
|
|
37
37
|
export type { StatusTab } from './components/status-tabs.js';
|
|
38
38
|
export { CmTableHeader } from './components/table-header.js';
|
|
39
39
|
export { CmDataTable } from './components/data-table.js';
|
|
40
|
-
export type { DataTableColumn, DataTableRow, SortDirection } from './components/data-table.js';
|
|
40
|
+
export type { DataTableColumn, DataTableRow, DataTableAction, SortDirection } from './components/data-table.js';
|
|
41
41
|
export type { TableColumn } from './components/table-header.js';
|
|
42
42
|
export { CmResourceList, CmResourceItem } from './components/resource-list.js';
|
|
43
43
|
export { CmNestedList, CmNestedItem } from './components/nested-list.js';
|
package/dist/popover.js
CHANGED
|
@@ -33,7 +33,7 @@ export const groupStyles = css `
|
|
|
33
33
|
[role='group'] + [role='group'] { margin-block-start: var(--cm-space-4); padding-block-start: var(--cm-space-4); border-top: var(--cm-border-1) solid var(--cm-border-subtle); }
|
|
34
34
|
[role='option'] + [role='group'], [role='group'] + [role='option'] { margin-block-start: var(--cm-space-4); padding-block-start: var(--cm-space-4); border-top: var(--cm-border-1) solid var(--cm-border-subtle); }
|
|
35
35
|
.gh {
|
|
36
|
-
display: flex; align-items: baseline; gap: var(--cm-space-8); padding: var(--cm-space-8) var(--cm-space-
|
|
36
|
+
display: flex; align-items: baseline; gap: var(--cm-space-8); padding: var(--cm-space-8) var(--cm-space-12) var(--cm-space-4);
|
|
37
37
|
font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12); font-weight: 500; color: var(--cm-text-tertiary);
|
|
38
38
|
}
|
|
39
39
|
.gh .count { font-weight: 400; color: var(--cm-text-tertiary); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commmerce/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Commmerce UI web components: build apps that feel native to the Commmerce admin. Works in plain HTML, React, Vue and server-rendered pages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"test": "vitest run"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@commmerce/icons": "1.
|
|
54
|
-
"@commmerce/tokens": "1.
|
|
53
|
+
"@commmerce/icons": "1.6.0",
|
|
54
|
+
"@commmerce/tokens": "1.6.0",
|
|
55
55
|
"lit": "3.2.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|