@devschile/chucao 2.6.0 → 2.7.1
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/chucao/chucao.esm.js +1 -1
- package/dist/chucao/{p-ffaf1a31.entry.js → p-01b6c7bf.entry.js} +2 -2
- package/dist/chucao/{p-2c1bc8bd.entry.js → p-0c7f6f8d.entry.js} +2 -2
- package/dist/chucao/p-10f6801e.entry.js +2 -0
- package/dist/chucao/p-10f6801e.entry.js.map +1 -0
- package/dist/chucao/{p-0409c063.entry.js → p-15d27bb7.entry.js} +2 -2
- package/dist/chucao/{p-e6f959f4.entry.js → p-1b70e3f1.entry.js} +2 -2
- package/dist/chucao/{p-66ae9e2c.entry.js → p-1e4cd3aa.entry.js} +2 -2
- package/dist/chucao/{p-c1b35f1b.entry.js → p-2e37c61b.entry.js} +2 -2
- package/dist/chucao/{p-f7305552.entry.js → p-42028c97.entry.js} +2 -2
- package/dist/chucao/{p-090d26f1.entry.js → p-472ec451.entry.js} +2 -2
- package/dist/chucao/{p-81b6622f.entry.js → p-5240f5ac.entry.js} +2 -2
- package/dist/chucao/p-60e1c1df.entry.js +2 -0
- package/dist/chucao/{p-b56f4a29.entry.js.map → p-60e1c1df.entry.js.map} +1 -1
- package/dist/chucao/{p-b9b47942.entry.js → p-7cdc71cc.entry.js} +2 -2
- package/dist/chucao/{p-50cbea7f.entry.js → p-8ae680a4.entry.js} +2 -2
- package/dist/chucao/{p-20ea1b18.entry.js → p-90284ebe.entry.js} +2 -2
- package/dist/chucao/p-9db118d9.entry.js +2 -0
- package/dist/chucao/p-9ebcc7be.entry.js +2 -0
- package/dist/chucao/p-9ebcc7be.entry.js.map +1 -0
- package/dist/chucao/{p-207648f9.entry.js → p-a7c674b7.entry.js} +2 -2
- package/dist/chucao/{p-79f20bfd.entry.js → p-c4b2bd1f.entry.js} +2 -2
- package/dist/chucao/{p-7d4336bd.entry.js → p-c90da3c0.entry.js} +2 -2
- package/dist/chucao/p-d8b71751.entry.js +2 -0
- package/dist/chucao/p-d8b71751.entry.js.map +1 -0
- package/dist/chucao/{p-925af6b8.entry.js → p-deb2571b.entry.js} +2 -2
- package/dist/chucao/{p-9794a3fa.entry.js → p-e77d35c3.entry.js} +2 -2
- package/dist/chucao/{p-21ca2235.entry.js → p-f6ab0a11.entry.js} +2 -2
- package/dist/chucao/p-f917d34f.entry.js +2 -0
- package/dist/chucao/{p-e2f725bd.entry.js.map → p-f917d34f.entry.js.map} +1 -1
- package/dist/chucao/{p-f0aea6ed.entry.js → p-ffecdf25.entry.js} +2 -2
- package/dist/cjs/ch-accordion.cjs.entry.js +1 -1
- package/dist/cjs/ch-alert_8.cjs.entry.js +7 -7
- package/dist/cjs/ch-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/ch-cluster.cjs.entry.js +2 -2
- package/dist/cjs/ch-description-list.cjs.entry.js +1 -1
- package/dist/cjs/ch-divider.cjs.entry.js +1 -1
- package/dist/cjs/ch-drawer.cjs.entry.js +1 -1
- package/dist/cjs/ch-emoji.cjs.entry.js +1 -1
- package/dist/cjs/ch-empty-state.cjs.entry.js +1 -1
- package/dist/cjs/ch-grid.cjs.entry.js +1 -1
- package/dist/cjs/ch-icon-button.cjs.entry.js +1 -1
- package/dist/cjs/ch-icon.cjs.entry.js +1 -1
- package/dist/cjs/ch-modal.cjs.entry.js +1 -1
- package/dist/cjs/ch-number-input.cjs.entry.js +237 -0
- package/dist/cjs/ch-number-input.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-page-header.cjs.entry.js +1 -1
- package/dist/cjs/ch-radio.cjs.entry.js +1 -1
- package/dist/cjs/ch-segmented-control.cjs.entry.js +1 -1
- package/dist/cjs/ch-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/ch-stack.cjs.entry.js +1 -1
- package/dist/cjs/ch-stat.cjs.entry.js +2 -2
- package/dist/cjs/ch-table.cjs.entry.js +145 -0
- package/dist/cjs/ch-table.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-tabs.cjs.entry.js +1 -1
- package/dist/cjs/ch-textarea.cjs.entry.js +1 -1
- package/dist/cjs/ch-timeline.cjs.entry.js +1 -1
- package/dist/cjs/ch-tooltip.cjs.entry.js +24 -7
- package/dist/cjs/ch-tooltip.cjs.entry.js.map +1 -1
- package/dist/cjs/chucao.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/ch-accordion/ch-accordion.js +1 -1
- package/dist/collection/components/ch-alert/ch-alert.js +1 -1
- package/dist/collection/components/ch-badge/ch-badge.js +1 -1
- package/dist/collection/components/ch-card/ch-card.js +1 -1
- package/dist/collection/components/ch-checkbox/ch-checkbox.js +1 -1
- package/dist/collection/components/ch-cluster/ch-cluster.js +2 -2
- package/dist/collection/components/ch-description-list/ch-description-list.js +1 -1
- package/dist/collection/components/ch-divider/ch-divider.js +1 -1
- package/dist/collection/components/ch-drawer/ch-drawer.js +1 -1
- package/dist/collection/components/ch-emoji/ch-emoji.js +1 -1
- package/dist/collection/components/ch-empty-state/ch-empty-state.js +1 -1
- package/dist/collection/components/ch-grid/ch-grid.js +1 -1
- package/dist/collection/components/ch-icon/ch-icon.js +1 -1
- package/dist/collection/components/ch-icon-button/ch-icon-button.js +1 -1
- package/dist/collection/components/ch-input/ch-input.js +1 -1
- package/dist/collection/components/ch-modal/ch-modal.js +1 -1
- package/dist/collection/components/ch-number-input/ch-number-input.css +74 -0
- package/dist/collection/components/ch-number-input/ch-number-input.js +555 -0
- package/dist/collection/components/ch-number-input/ch-number-input.js.map +1 -0
- package/dist/collection/components/ch-page-header/ch-page-header.js +1 -1
- package/dist/collection/components/ch-radio/ch-radio.js +1 -1
- package/dist/collection/components/ch-segmented-control/ch-segmented-control.js +1 -1
- package/dist/collection/components/ch-select/ch-select.js +1 -1
- package/dist/collection/components/ch-skeleton/ch-skeleton.js +1 -1
- package/dist/collection/components/ch-spinner/ch-spinner.js +1 -1
- package/dist/collection/components/ch-stack/ch-stack.js +1 -1
- package/dist/collection/components/ch-stat/ch-stat.js +2 -2
- package/dist/collection/components/ch-switch/ch-switch.js +1 -1
- package/dist/collection/components/ch-table/ch-table.css +107 -0
- package/dist/collection/components/ch-table/ch-table.js +347 -0
- package/dist/collection/components/ch-table/ch-table.js.map +1 -0
- package/dist/collection/components/ch-tabs/ch-tabs.js +1 -1
- package/dist/collection/components/ch-textarea/ch-textarea.js +1 -1
- package/dist/collection/components/ch-timeline/ch-timeline.js +1 -1
- package/dist/collection/components/ch-tooltip/ch-tooltip.css +11 -0
- package/dist/collection/components/ch-tooltip/ch-tooltip.js +23 -6
- package/dist/collection/components/ch-tooltip/ch-tooltip.js.map +1 -1
- package/dist/collection/utils/overlay.js.map +1 -1
- package/dist/components/ch-accordion.js +1 -1
- package/dist/components/ch-alert.js +1 -1
- package/dist/components/ch-badge.js +1 -1
- package/dist/components/ch-button.js +1 -1
- package/dist/components/ch-card.js +1 -1
- package/dist/components/ch-card.js.map +1 -1
- package/dist/components/ch-checkbox.js +1 -1
- package/dist/components/ch-cluster.js +1 -1
- package/dist/components/ch-description-list.js +1 -1
- package/dist/components/ch-divider.js +1 -1
- package/dist/components/ch-drawer.js +1 -1
- package/dist/components/ch-emoji.js +1 -1
- package/dist/components/ch-empty-state.js +1 -1
- package/dist/components/ch-grid.js +1 -1
- package/dist/components/ch-icon-button.js +1 -1
- package/dist/components/ch-icon.js +1 -1
- package/dist/components/ch-input.js +1 -1
- package/dist/components/ch-modal.js +1 -1
- package/dist/components/ch-number-input.d.ts +11 -0
- package/dist/components/ch-number-input.js +2 -0
- package/dist/components/ch-number-input.js.map +1 -0
- package/dist/components/ch-page-header.js +1 -1
- package/dist/components/ch-radio.js +1 -1
- package/dist/components/ch-segmented-control.js +1 -1
- package/dist/components/ch-select.js +1 -1
- package/dist/components/ch-skeleton.js +1 -1
- package/dist/components/ch-spinner.js +1 -1
- package/dist/components/ch-stack.js +1 -1
- package/dist/components/ch-stat.js +1 -1
- package/dist/components/ch-switch.js +1 -1
- package/dist/components/ch-table.d.ts +11 -0
- package/dist/components/ch-table.js +2 -0
- package/dist/components/ch-table.js.map +1 -0
- package/dist/components/ch-tabs.js +1 -1
- package/dist/components/ch-textarea.js +1 -1
- package/dist/components/ch-timeline.js +1 -1
- package/dist/components/ch-tooltip.js +1 -1
- package/dist/components/ch-tooltip.js.map +1 -1
- package/dist/components/{p-Cw0b4OGc.js → p-DiUN1WGc.js} +2 -2
- package/dist/esm/ch-accordion.entry.js +1 -1
- package/dist/esm/ch-alert_8.entry.js +7 -7
- package/dist/esm/ch-checkbox.entry.js +1 -1
- package/dist/esm/ch-cluster.entry.js +2 -2
- package/dist/esm/ch-description-list.entry.js +1 -1
- package/dist/esm/ch-divider.entry.js +1 -1
- package/dist/esm/ch-drawer.entry.js +1 -1
- package/dist/esm/ch-emoji.entry.js +1 -1
- package/dist/esm/ch-empty-state.entry.js +1 -1
- package/dist/esm/ch-grid.entry.js +1 -1
- package/dist/esm/ch-icon-button.entry.js +1 -1
- package/dist/esm/ch-icon.entry.js +1 -1
- package/dist/esm/ch-modal.entry.js +1 -1
- package/dist/esm/ch-number-input.entry.js +235 -0
- package/dist/esm/ch-number-input.entry.js.map +1 -0
- package/dist/esm/ch-page-header.entry.js +1 -1
- package/dist/esm/ch-radio.entry.js +1 -1
- package/dist/esm/ch-segmented-control.entry.js +1 -1
- package/dist/esm/ch-skeleton.entry.js +1 -1
- package/dist/esm/ch-stack.entry.js +1 -1
- package/dist/esm/ch-stat.entry.js +2 -2
- package/dist/esm/ch-table.entry.js +143 -0
- package/dist/esm/ch-table.entry.js.map +1 -0
- package/dist/esm/ch-tabs.entry.js +1 -1
- package/dist/esm/ch-textarea.entry.js +1 -1
- package/dist/esm/ch-timeline.entry.js +1 -1
- package/dist/esm/ch-tooltip.entry.js +24 -7
- package/dist/esm/ch-tooltip.entry.js.map +1 -1
- package/dist/esm/chucao.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ch-number-input/ch-number-input.d.ts +105 -0
- package/dist/types/components/ch-table/ch-table.d.ts +106 -0
- package/dist/types/components/ch-tooltip/ch-tooltip.d.ts +7 -0
- package/dist/types/components.d.ts +459 -0
- package/dist/types/utils/overlay.d.ts +1 -1
- package/dist-react/components.d.ts +15 -1
- package/dist-react/components.js +21 -0
- package/dist-react/components.ts +31 -1
- package/dist-vue/index.d.ts +2 -0
- package/dist-vue/index.js +33 -0
- package/dist-vue/index.ts +37 -0
- package/hydrate/index.js +519 -37
- package/hydrate/index.mjs +519 -37
- package/package.json +9 -1
- package/dist/chucao/p-370d9629.entry.js +0 -2
- package/dist/chucao/p-370d9629.entry.js.map +0 -1
- package/dist/chucao/p-95061461.entry.js +0 -2
- package/dist/chucao/p-b56f4a29.entry.js +0 -2
- package/dist/chucao/p-e2f725bd.entry.js +0 -2
- /package/dist/chucao/{p-ffaf1a31.entry.js.map → p-01b6c7bf.entry.js.map} +0 -0
- /package/dist/chucao/{p-2c1bc8bd.entry.js.map → p-0c7f6f8d.entry.js.map} +0 -0
- /package/dist/chucao/{p-0409c063.entry.js.map → p-15d27bb7.entry.js.map} +0 -0
- /package/dist/chucao/{p-e6f959f4.entry.js.map → p-1b70e3f1.entry.js.map} +0 -0
- /package/dist/chucao/{p-66ae9e2c.entry.js.map → p-1e4cd3aa.entry.js.map} +0 -0
- /package/dist/chucao/{p-c1b35f1b.entry.js.map → p-2e37c61b.entry.js.map} +0 -0
- /package/dist/chucao/{p-f7305552.entry.js.map → p-42028c97.entry.js.map} +0 -0
- /package/dist/chucao/{p-090d26f1.entry.js.map → p-472ec451.entry.js.map} +0 -0
- /package/dist/chucao/{p-81b6622f.entry.js.map → p-5240f5ac.entry.js.map} +0 -0
- /package/dist/chucao/{p-b9b47942.entry.js.map → p-7cdc71cc.entry.js.map} +0 -0
- /package/dist/chucao/{p-50cbea7f.entry.js.map → p-8ae680a4.entry.js.map} +0 -0
- /package/dist/chucao/{p-20ea1b18.entry.js.map → p-90284ebe.entry.js.map} +0 -0
- /package/dist/chucao/{p-95061461.entry.js.map → p-9db118d9.entry.js.map} +0 -0
- /package/dist/chucao/{p-207648f9.entry.js.map → p-a7c674b7.entry.js.map} +0 -0
- /package/dist/chucao/{p-79f20bfd.entry.js.map → p-c4b2bd1f.entry.js.map} +0 -0
- /package/dist/chucao/{p-7d4336bd.entry.js.map → p-c90da3c0.entry.js.map} +0 -0
- /package/dist/chucao/{p-925af6b8.entry.js.map → p-deb2571b.entry.js.map} +0 -0
- /package/dist/chucao/{p-9794a3fa.entry.js.map → p-e77d35c3.entry.js.map} +0 -0
- /package/dist/chucao/{p-21ca2235.entry.js.map → p-f6ab0a11.entry.js.map} +0 -0
- /package/dist/chucao/{p-f0aea6ed.entry.js.map → p-ffecdf25.entry.js.map} +0 -0
- /package/dist/components/{p-Cw0b4OGc.js.map → p-DiUN1WGc.js.map} +0 -0
|
@@ -23,7 +23,7 @@ export class ChSpinner {
|
|
|
23
23
|
label;
|
|
24
24
|
render() {
|
|
25
25
|
const labelled = Boolean(this.label);
|
|
26
|
-
return (h(Host, { key: '
|
|
26
|
+
return (h(Host, { key: '1d8ef18f03d7a52d61854cc84fb39994ee8ce0a9' }, h("span", { key: '28ec4657d1a0de9181f9d31742fc6bd26b284b14', class: { spinner: true, [`spinner--${this.size}`]: true }, role: labelled ? 'status' : undefined, "aria-label": labelled ? this.label : undefined, "aria-hidden": labelled ? undefined : 'true' })));
|
|
27
27
|
}
|
|
28
28
|
static get is() { return "ch-spinner"; }
|
|
29
29
|
static get encapsulation() { return "shadow"; }
|
|
@@ -24,7 +24,7 @@ export class ChStack {
|
|
|
24
24
|
return GAPS.has(this.gap) ? this.gap : 'md';
|
|
25
25
|
}
|
|
26
26
|
render() {
|
|
27
|
-
return (h(Host, { key: '
|
|
27
|
+
return (h(Host, { key: '1c70344ce291ba78a533f99ac6c4c135296251e1', class: { stack: true, [`stack--gap-${this.gapStep}`]: true, [`stack--align-${this.align}`]: true, [`stack--justify-${this.justify}`]: true } }, h("slot", { key: 'f4167e47a2fdee42f97611fba5907d79f8d0448d' })));
|
|
28
28
|
}
|
|
29
29
|
static get is() { return "ch-stack"; }
|
|
30
30
|
static get encapsulation() { return "shadow"; }
|
|
@@ -43,10 +43,10 @@ export class ChStat {
|
|
|
43
43
|
}
|
|
44
44
|
render() {
|
|
45
45
|
const cue = this.toneClass === 'positive' ? '+' : this.toneClass === 'negative' ? '−' : null;
|
|
46
|
-
return (h(Host, { key: '
|
|
46
|
+
return (h(Host, { key: '76d71c964efeb4e5a07aabff0b895f1ded21b345', class: "stat" }, h("div", { key: '103db766f21c91c8406e8d3368049f4e4a018007', class: "stat__inner" }, h("span", { key: '74e45654072a92ba4f894aee5366852561f8f352', class: "stat__label" }, this.label), h("span", { key: 'deb8d0d20c70d7fbab392641fd9d0e617ab8daf5', class: {
|
|
47
47
|
stat__value: true,
|
|
48
48
|
[`stat__value--${this.toneClass}`]: this.toneClass !== 'default',
|
|
49
|
-
} }, cue && (h("span", { key: '
|
|
49
|
+
} }, cue && (h("span", { key: '82b83cb7182f10ceca5172fc790aad01882645cc', class: "stat__cue", "aria-hidden": "true" }, cue)), h("slot", { key: 'e9c3095eca4ed3907fc0e95395f3cc62bfd4158a', name: "value" }, this.value)), this.hint && h("span", { key: '4b892b35299def40a62c386e6af7c5f19aebe44b', class: "stat__hint" }, this.hint), h("div", { key: '0535d9fb62ddf5ed1ee2b5993689cb080f753ff9', class: "stat__footer" }, h("slot", { key: '1d8e09fa8db2d4a6e188f8deaa93631df9cc2a36', name: "footer" })))));
|
|
50
50
|
}
|
|
51
51
|
static get is() { return "ch-stat"; }
|
|
52
52
|
static get encapsulation() { return "shadow"; }
|
|
@@ -95,7 +95,7 @@ export class ChSwitch {
|
|
|
95
95
|
return undefined;
|
|
96
96
|
}
|
|
97
97
|
render() {
|
|
98
|
-
return (h(Host, { key: '
|
|
98
|
+
return (h(Host, { key: '8bafcbe9b03858f278f0884d43b9ce579a98c84e' }, h("label", { key: '8783c0e8ce0bb9c03a3772a08afb383e338b5be4', class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled }, htmlFor: this.switchId }, h("input", { key: '4093d398ed167ede08749050b6a9c9d5b25f2470', id: this.switchId, class: { 'input': true, 'input--invalid': this.invalid }, type: "checkbox", role: "switch", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled || this.formDisabled, required: this.required, "aria-checked": this.checked ? 'true' : 'false', "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), h("span", { key: 'eea728ebbf6c6fefd761415bf8cb00765e5c2e76', class: "track" }, h("span", { key: '4d18d8c9ed871bbf6e537b93bcce14c0f00f00e9', class: "thumb" })), this.label && h("span", { key: '048657735d8fdf9a03a89b83cf3f3d65a466d886', class: "label-text" }, this.label)), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '869a40f9ce8bd2f93d918426f119c637039ac5e9', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '08d947e2909706290b7efbb3e8af6999ad249dea', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
99
99
|
}
|
|
100
100
|
static get is() { return "ch-switch"; }
|
|
101
101
|
static get encapsulation() { return "shadow"; }
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
font-family: var(--typography-body);
|
|
4
|
+
color: var(--color-text-primary);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:host([hidden]) {
|
|
8
|
+
display: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* The scroll box owns the horizontal overflow so a wide table never widens the
|
|
13
|
+
* page. It is focusable so a keyboard user can scroll it without a mouse.
|
|
14
|
+
*/
|
|
15
|
+
.table__scroll {
|
|
16
|
+
overflow-x: auto;
|
|
17
|
+
/* Without this the table shrinks to the box and never overflows. */
|
|
18
|
+
min-width: 0;
|
|
19
|
+
border: var(--border-width) solid var(--color-border-default);
|
|
20
|
+
border-radius: var(--radius-md);
|
|
21
|
+
background: var(--color-surface-default);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.table__scroll:focus-visible {
|
|
25
|
+
outline: 2px solid var(--color-accent-default);
|
|
26
|
+
outline-offset: 2px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.table {
|
|
30
|
+
/*
|
|
31
|
+
* `width: max-content` with a `min-width: 100%` floor: on a wide viewport the
|
|
32
|
+
* table fills the box, on a narrow one it keeps the width its cells need and
|
|
33
|
+
* the scroll box absorbs the overflow. `width: 100%` would instead squeeze the
|
|
34
|
+
* columns until the text wrapped, which is not scrolling.
|
|
35
|
+
*/
|
|
36
|
+
width: 100%;
|
|
37
|
+
border-collapse: collapse;
|
|
38
|
+
font-size: var(--typography-size-sm);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* A cell never collapses below a readable width, which is what makes the table
|
|
42
|
+
* wider than a narrow scroll box and produces the horizontal scroll. */
|
|
43
|
+
.cell {
|
|
44
|
+
min-width: 8rem;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.caption {
|
|
48
|
+
position: absolute;
|
|
49
|
+
width: 1px;
|
|
50
|
+
height: 1px;
|
|
51
|
+
padding: 0;
|
|
52
|
+
margin: -1px;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
clip-path: inset(50%);
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
border: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.cell {
|
|
60
|
+
padding: var(--spacing-md) var(--spacing-lg);
|
|
61
|
+
text-align: left;
|
|
62
|
+
vertical-align: top;
|
|
63
|
+
border-bottom: var(--border-width) solid var(--color-border-default);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.cell--header {
|
|
67
|
+
font-weight: var(--typography-weight-semibold);
|
|
68
|
+
color: var(--color-text-secondary);
|
|
69
|
+
white-space: nowrap;
|
|
70
|
+
background: var(--color-surface-hover);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* The last body row loses its rule; the scroll box border closes the table. */
|
|
74
|
+
tbody tr:last-child td {
|
|
75
|
+
border-bottom: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.sort {
|
|
79
|
+
all: unset;
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: var(--spacing-xs);
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
border-radius: var(--radius-sm);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.sort:focus-visible {
|
|
88
|
+
outline: 2px solid var(--color-accent-default);
|
|
89
|
+
outline-offset: 2px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Direction is carried by the glyph, not by colour alone. */
|
|
93
|
+
.sort__cue {
|
|
94
|
+
font-size: var(--typography-size-xs);
|
|
95
|
+
color: var(--color-text-secondary);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.table__empty {
|
|
99
|
+
padding: var(--spacing-2xl) var(--spacing-lg);
|
|
100
|
+
text-align: center;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.table__empty-message {
|
|
104
|
+
margin: 0;
|
|
105
|
+
font-size: var(--typography-size-sm);
|
|
106
|
+
color: var(--color-text-secondary);
|
|
107
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
let tableIds = 0;
|
|
3
|
+
/**
|
|
4
|
+
* Presentation-only data grid over a native `<table>`.
|
|
5
|
+
*
|
|
6
|
+
* The component renders the table skeleton and the header row; the consumer
|
|
7
|
+
* slots the body as **native** `<tr>` elements. It does not hold the rows, sort
|
|
8
|
+
* them, paginate them or fetch anything — it reports intent and the consumer
|
|
9
|
+
* decides. Sorting is controlled: the table reflects the `sortKey` and
|
|
10
|
+
* `sortDirection` it is given, so a consumer that ignores `chSort` leaves the
|
|
11
|
+
* `aria-sort` that matches its own data.
|
|
12
|
+
*
|
|
13
|
+
* ```html
|
|
14
|
+
* <ch-table sortable sort-key="name" sort-direction="ascending">
|
|
15
|
+
* <tr><td>Aurora SpA</td><td>En despacho</td></tr>
|
|
16
|
+
* <tr><td>Bosque Ltda</td><td>Pendiente</td></tr>
|
|
17
|
+
* </ch-table>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* ```js
|
|
21
|
+
* table.columns = [
|
|
22
|
+
* { key: 'name', label: 'Cliente' },
|
|
23
|
+
* { key: 'status', label: 'Estado' },
|
|
24
|
+
* ];
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Columns come from the `columns` prop, like `ch-select`'s `options` — there is
|
|
28
|
+
* no `ch-table-column` element, and an unknown element inside a component is
|
|
29
|
+
* never rendered.
|
|
30
|
+
*
|
|
31
|
+
* Rows must be real `<tr>` elements created as DOM nodes, not written as
|
|
32
|
+
* HTML inside the tag: the parser rejects a `<tr>` outside a `<table>`, so
|
|
33
|
+
* `<ch-table><tr>…</tr></ch-table>` in an HTML string parses to a text node
|
|
34
|
+
* and the table correctly reports itself empty. Framework templates and
|
|
35
|
+
* `createElement` are unaffected.
|
|
36
|
+
*
|
|
37
|
+
* The shape is the one approved on #77: `table`/`thead`/`tbody` live in the
|
|
38
|
+
* shadow DOM and the consumer slots native rows. Custom row and cell elements
|
|
39
|
+
* are not possible — the HTML parser foster-parents them out of a native
|
|
40
|
+
* table, which the spike in `tests/browser/semantic-shapes.browser.spec.ts`
|
|
41
|
+
* measured in real Chromium.
|
|
42
|
+
*/
|
|
43
|
+
export class ChTable {
|
|
44
|
+
captionId = `ch-table-${++tableIds}-caption`;
|
|
45
|
+
emptyId = `${this.captionId}-empty`;
|
|
46
|
+
host;
|
|
47
|
+
/** Columns, in display order. Rendered as the header row. */
|
|
48
|
+
columns = [];
|
|
49
|
+
/** Whether the header offers sorting. Individual columns can opt out. */
|
|
50
|
+
sortable = false;
|
|
51
|
+
/** Key of the column currently used for sorting. Controlled by the consumer. */
|
|
52
|
+
sortKey;
|
|
53
|
+
/** Direction of the current sort. Defaults to `ascending`. */
|
|
54
|
+
sortDirection = 'ascending';
|
|
55
|
+
/**
|
|
56
|
+
* Accessible name for the table. Always rendered as a caption, visually
|
|
57
|
+
* hidden, because a data table without a name is announced as a bare grid.
|
|
58
|
+
*/
|
|
59
|
+
label;
|
|
60
|
+
/**
|
|
61
|
+
* Shown in place of the rows when the body is empty. `filtered` distinguishes
|
|
62
|
+
* "nothing matched your filters" from "there is nothing yet", which are
|
|
63
|
+
* different messages and different next actions.
|
|
64
|
+
*/
|
|
65
|
+
empty = 'unmeasured';
|
|
66
|
+
/**
|
|
67
|
+
* Marks the body as empty *because of filtering* rather than because there is
|
|
68
|
+
* no data at all. Both look like zero rows, and they need different messages
|
|
69
|
+
* and different next actions.
|
|
70
|
+
*/
|
|
71
|
+
filtered = false;
|
|
72
|
+
/** Emitted when a sortable header is activated. The consumer applies the sort. */
|
|
73
|
+
chSort;
|
|
74
|
+
onFiltered() {
|
|
75
|
+
this.measure();
|
|
76
|
+
}
|
|
77
|
+
rerenderHeaders() {
|
|
78
|
+
// Header attributes are derived from controlled props, so a prop change
|
|
79
|
+
// has to repaint them; `columns` and the slot repaint on their own.
|
|
80
|
+
this.rerender = !this.rerender;
|
|
81
|
+
}
|
|
82
|
+
rerender = false;
|
|
83
|
+
observer;
|
|
84
|
+
componentDidLoad() {
|
|
85
|
+
this.measure();
|
|
86
|
+
// `slotchange` does not fire for native `<tr>` children, and it only fires
|
|
87
|
+
// at all once the element is upgraded, so a row added later would leave the
|
|
88
|
+
// table stuck on its first measurement. Observing the host covers both
|
|
89
|
+
// orders plus a consumer that swaps rows on refresh. `MutationObserver` is
|
|
90
|
+
// absent in the mock-doc test environment, where the slot behaviour is
|
|
91
|
+
// exercised through an explicit `slotchange` instead.
|
|
92
|
+
if (typeof MutationObserver === 'function') {
|
|
93
|
+
this.observer = new MutationObserver(this.measure);
|
|
94
|
+
this.observer.observe(this.host, { childList: true });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
disconnectedCallback() {
|
|
98
|
+
this.observer?.disconnect();
|
|
99
|
+
this.observer = undefined;
|
|
100
|
+
}
|
|
101
|
+
measure = () => {
|
|
102
|
+
const rows = Array.from(this.host.children).filter(child => child.tagName === 'TR');
|
|
103
|
+
this.empty = rows.length === 0 ? 'true' : 'none';
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* A filtered-empty body and a truly empty one both have zero rows; only the
|
|
107
|
+
* consumer knows which, since `filtered` is a prop it controls.
|
|
108
|
+
*/
|
|
109
|
+
get emptyState() {
|
|
110
|
+
if (this.filtered) {
|
|
111
|
+
return 'filtered';
|
|
112
|
+
}
|
|
113
|
+
return this.empty;
|
|
114
|
+
}
|
|
115
|
+
/** Direction glyph. Not colour: the arrow is the cue in greyscale. */
|
|
116
|
+
sortCue(active) {
|
|
117
|
+
if (!active) {
|
|
118
|
+
return '⇅';
|
|
119
|
+
}
|
|
120
|
+
return this.sortDirection === 'ascending' ? '▲' : '▼';
|
|
121
|
+
}
|
|
122
|
+
emptyMessage(state) {
|
|
123
|
+
return state === 'filtered' ? 'No results for these filters.' : 'Nothing here yet.';
|
|
124
|
+
}
|
|
125
|
+
nextDirection(key) {
|
|
126
|
+
if (this.sortKey !== key) {
|
|
127
|
+
return 'ascending';
|
|
128
|
+
}
|
|
129
|
+
return this.sortDirection === 'ascending' ? 'descending' : 'ascending';
|
|
130
|
+
}
|
|
131
|
+
handleSort = (key) => {
|
|
132
|
+
this.chSort.emit({ key, direction: this.nextDirection(key) });
|
|
133
|
+
};
|
|
134
|
+
handleHeaderKeydown = (ev, key) => {
|
|
135
|
+
if (ev.key !== 'Enter' && ev.key !== ' ') {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
ev.preventDefault();
|
|
139
|
+
this.handleSort(key);
|
|
140
|
+
};
|
|
141
|
+
renderHeaderCell(column) {
|
|
142
|
+
const sortable = this.sortable && column.sortable !== false;
|
|
143
|
+
if (!sortable) {
|
|
144
|
+
return (h("th", { scope: "col", class: "cell cell--header" }, column.label));
|
|
145
|
+
}
|
|
146
|
+
const active = this.sortKey === column.key;
|
|
147
|
+
const direction = active ? this.sortDirection : 'none';
|
|
148
|
+
return (h("th", { scope: "col", class: "cell cell--header", "aria-sort": direction }, h("button", { type: "button", class: "sort", onClick: () => this.handleSort(column.key), onKeyDown: ev => this.handleHeaderKeydown(ev, column.key) }, h("span", null, column.label), h("span", { class: "sort__cue", "aria-hidden": "true" }, this.sortCue(active)))));
|
|
149
|
+
}
|
|
150
|
+
render() {
|
|
151
|
+
const empty = this.emptyState;
|
|
152
|
+
// Before the first measurement the table is rendered as non-empty, so a
|
|
153
|
+
// consumer never sees the empty message flash over real rows.
|
|
154
|
+
return (h(Host, { key: 'f4511d753b9140b08eee0e50041ba4e7408930ec', class: { 'table': true, 'table--empty': empty === 'true' || empty === 'filtered' } }, h("div", { key: '8cc987803f5d000d7efbbc6b605561d2c6ca1c46', class: "table__scroll", tabIndex: 0, role: "group", "aria-labelledby": this.captionId }, h("table", { key: '9eff6abfe0fecfd3559bfe397db3957fa60e288a' }, h("caption", { key: '35d88e56267aff1ae9753326ffc807cf6e04bfba', id: this.captionId, class: "caption" }, this.label), h("thead", { key: '0b01e865f3c0f40e9e86634f701b77886713e2e3' }, h("tr", { key: '92ded28a12867b8a2a372a9b04e8fd251870a5c7' }, this.columns.map(column => this.renderHeaderCell(column)))), h("tbody", { key: '68d7a49aa51cf1e958f1af7ebc36cdb5f6acfdd0' }, h("slot", { key: '79e296699379971e93b8a91b7823987be835ce8e' })))), (empty === 'true' || empty === 'filtered') && (h("div", { key: 'b7b2734f3d83ced393377fbe6f2911d2466ce714', class: "table__empty", id: this.emptyId }, h("slot", { key: '926191c01eef1f1898ad7fc800824021a697da35', name: "empty" }, h("p", { key: '6302a52795029b3d31200ae3c1c4ff53af3ab81c', class: "table__empty-message" }, this.emptyMessage(empty)))))));
|
|
155
|
+
}
|
|
156
|
+
static get is() { return "ch-table"; }
|
|
157
|
+
static get encapsulation() { return "shadow"; }
|
|
158
|
+
static get originalStyleUrls() {
|
|
159
|
+
return {
|
|
160
|
+
"$": ["ch-table.css"]
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
static get styleUrls() {
|
|
164
|
+
return {
|
|
165
|
+
"$": ["ch-table.css"]
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
static get properties() {
|
|
169
|
+
return {
|
|
170
|
+
"columns": {
|
|
171
|
+
"type": "unknown",
|
|
172
|
+
"mutable": false,
|
|
173
|
+
"complexType": {
|
|
174
|
+
"original": "ChTableSortColumn[]",
|
|
175
|
+
"resolved": "ChTableSortColumn[]",
|
|
176
|
+
"references": {
|
|
177
|
+
"ChTableSortColumn": {
|
|
178
|
+
"location": "local",
|
|
179
|
+
"path": "/home/runner/work/chucao/chucao/src/components/ch-table/ch-table.tsx",
|
|
180
|
+
"id": "src/components/ch-table/ch-table.tsx::ChTableSortColumn"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": false,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "Columns, in display order. Rendered as the header row."
|
|
189
|
+
},
|
|
190
|
+
"getter": false,
|
|
191
|
+
"setter": false,
|
|
192
|
+
"defaultValue": "[]"
|
|
193
|
+
},
|
|
194
|
+
"sortable": {
|
|
195
|
+
"type": "boolean",
|
|
196
|
+
"mutable": false,
|
|
197
|
+
"complexType": {
|
|
198
|
+
"original": "boolean",
|
|
199
|
+
"resolved": "boolean",
|
|
200
|
+
"references": {}
|
|
201
|
+
},
|
|
202
|
+
"required": false,
|
|
203
|
+
"optional": false,
|
|
204
|
+
"docs": {
|
|
205
|
+
"tags": [],
|
|
206
|
+
"text": "Whether the header offers sorting. Individual columns can opt out."
|
|
207
|
+
},
|
|
208
|
+
"getter": false,
|
|
209
|
+
"setter": false,
|
|
210
|
+
"reflect": true,
|
|
211
|
+
"attribute": "sortable",
|
|
212
|
+
"defaultValue": "false"
|
|
213
|
+
},
|
|
214
|
+
"sortKey": {
|
|
215
|
+
"type": "string",
|
|
216
|
+
"mutable": false,
|
|
217
|
+
"complexType": {
|
|
218
|
+
"original": "string",
|
|
219
|
+
"resolved": "string",
|
|
220
|
+
"references": {}
|
|
221
|
+
},
|
|
222
|
+
"required": false,
|
|
223
|
+
"optional": true,
|
|
224
|
+
"docs": {
|
|
225
|
+
"tags": [],
|
|
226
|
+
"text": "Key of the column currently used for sorting. Controlled by the consumer."
|
|
227
|
+
},
|
|
228
|
+
"getter": false,
|
|
229
|
+
"setter": false,
|
|
230
|
+
"reflect": false,
|
|
231
|
+
"attribute": "sort-key"
|
|
232
|
+
},
|
|
233
|
+
"sortDirection": {
|
|
234
|
+
"type": "string",
|
|
235
|
+
"mutable": false,
|
|
236
|
+
"complexType": {
|
|
237
|
+
"original": "ChTableSortDirection",
|
|
238
|
+
"resolved": "\"ascending\" | \"descending\"",
|
|
239
|
+
"references": {
|
|
240
|
+
"ChTableSortDirection": {
|
|
241
|
+
"location": "local",
|
|
242
|
+
"path": "/home/runner/work/chucao/chucao/src/components/ch-table/ch-table.tsx",
|
|
243
|
+
"id": "src/components/ch-table/ch-table.tsx::ChTableSortDirection"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
"required": false,
|
|
248
|
+
"optional": false,
|
|
249
|
+
"docs": {
|
|
250
|
+
"tags": [],
|
|
251
|
+
"text": "Direction of the current sort. Defaults to `ascending`."
|
|
252
|
+
},
|
|
253
|
+
"getter": false,
|
|
254
|
+
"setter": false,
|
|
255
|
+
"reflect": false,
|
|
256
|
+
"attribute": "sort-direction",
|
|
257
|
+
"defaultValue": "'ascending'"
|
|
258
|
+
},
|
|
259
|
+
"label": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"mutable": false,
|
|
262
|
+
"complexType": {
|
|
263
|
+
"original": "string",
|
|
264
|
+
"resolved": "string",
|
|
265
|
+
"references": {}
|
|
266
|
+
},
|
|
267
|
+
"required": true,
|
|
268
|
+
"optional": false,
|
|
269
|
+
"docs": {
|
|
270
|
+
"tags": [],
|
|
271
|
+
"text": "Accessible name for the table. Always rendered as a caption, visually\nhidden, because a data table without a name is announced as a bare grid."
|
|
272
|
+
},
|
|
273
|
+
"getter": false,
|
|
274
|
+
"setter": false,
|
|
275
|
+
"reflect": false,
|
|
276
|
+
"attribute": "label"
|
|
277
|
+
},
|
|
278
|
+
"filtered": {
|
|
279
|
+
"type": "boolean",
|
|
280
|
+
"mutable": false,
|
|
281
|
+
"complexType": {
|
|
282
|
+
"original": "boolean",
|
|
283
|
+
"resolved": "boolean",
|
|
284
|
+
"references": {}
|
|
285
|
+
},
|
|
286
|
+
"required": false,
|
|
287
|
+
"optional": false,
|
|
288
|
+
"docs": {
|
|
289
|
+
"tags": [],
|
|
290
|
+
"text": "Marks the body as empty *because of filtering* rather than because there is\nno data at all. Both look like zero rows, and they need different messages\nand different next actions."
|
|
291
|
+
},
|
|
292
|
+
"getter": false,
|
|
293
|
+
"setter": false,
|
|
294
|
+
"reflect": true,
|
|
295
|
+
"attribute": "filtered",
|
|
296
|
+
"defaultValue": "false"
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
static get states() {
|
|
301
|
+
return {
|
|
302
|
+
"empty": {},
|
|
303
|
+
"rerender": {}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
static get events() {
|
|
307
|
+
return [{
|
|
308
|
+
"method": "chSort",
|
|
309
|
+
"name": "chSort",
|
|
310
|
+
"bubbles": true,
|
|
311
|
+
"cancelable": true,
|
|
312
|
+
"composed": true,
|
|
313
|
+
"docs": {
|
|
314
|
+
"tags": [],
|
|
315
|
+
"text": "Emitted when a sortable header is activated. The consumer applies the sort."
|
|
316
|
+
},
|
|
317
|
+
"complexType": {
|
|
318
|
+
"original": "{ key: string; direction: ChTableSortDirection }",
|
|
319
|
+
"resolved": "{ key: string; direction: ChTableSortDirection; }",
|
|
320
|
+
"references": {
|
|
321
|
+
"ChTableSortDirection": {
|
|
322
|
+
"location": "local",
|
|
323
|
+
"path": "/home/runner/work/chucao/chucao/src/components/ch-table/ch-table.tsx",
|
|
324
|
+
"id": "src/components/ch-table/ch-table.tsx::ChTableSortDirection"
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}];
|
|
329
|
+
}
|
|
330
|
+
static get elementRef() { return "host"; }
|
|
331
|
+
static get watchers() {
|
|
332
|
+
return [{
|
|
333
|
+
"propName": "filtered",
|
|
334
|
+
"methodName": "onFiltered"
|
|
335
|
+
}, {
|
|
336
|
+
"propName": "sortKey",
|
|
337
|
+
"methodName": "rerenderHeaders"
|
|
338
|
+
}, {
|
|
339
|
+
"propName": "sortDirection",
|
|
340
|
+
"methodName": "rerenderHeaders"
|
|
341
|
+
}, {
|
|
342
|
+
"propName": "sortable",
|
|
343
|
+
"methodName": "rerenderHeaders"
|
|
344
|
+
}];
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
//# sourceMappingURL=ch-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ch-table.js","sourceRoot":"","sources":["../../../../src/components/ch-table/ch-table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAqB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAc1G,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,MAAM,OAAO,OAAO;IACD,SAAS,GAAG,YAAY,EAAE,QAAQ,UAAU,CAAC;IAC7C,OAAO,GAAG,GAAG,IAAI,CAAC,SAAS,QAAQ,CAAC;IAElC,IAAI,CAAe;IAEtC,6DAA6D;IACrD,OAAO,GA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AK,KAAK,MAAM,IAAI,KAAK,KAAK,UAAU,EAAE;YACtF,4DAAK,KAAK,EAAC,eAAe,EAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAC,OAAO,qBAAkB,IAAI,CAAC,SAAS;gBAClF;oBACE,gEAAS,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAC,SAAS,IACzC,IAAI,CAAC,KAAK,CACH;oBACV;wBACE,6DAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAM,CAC9D;oBACR;wBACE,8DAAa,CACP,CACF,CACJ;YACL,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,UAAU,CAAC,IAAI,CAC7C,4DAAK,KAAK,EAAC,cAAc,EAAC,EAAE,EAAE,IAAI,CAAC,OAAO;gBACxC,6DAAM,IAAI,EAAC,OAAO;oBAChB,0DAAG,KAAK,EAAC,sBAAsB,IAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAK,CACzD,CACH,CACP,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, type EventEmitter, Host, Prop, State, Watch, h } from '@stencil/core';\n\nexport type ChTableSortDirection = 'ascending' | 'descending';\n\n/** A column the table can sort by, in display order. */\nexport interface ChTableSortColumn {\n /** Identifies the column in `chSort` events. */\n key: string;\n /** Visible header text. */\n label: string;\n /** Whether the header offers sorting. Defaults to `true` when the table is sortable. */\n sortable?: boolean;\n}\n\nlet tableIds = 0;\n\n/**\n * Presentation-only data grid over a native `<table>`.\n *\n * The component renders the table skeleton and the header row; the consumer\n * slots the body as **native** `<tr>` elements. It does not hold the rows, sort\n * them, paginate them or fetch anything — it reports intent and the consumer\n * decides. Sorting is controlled: the table reflects the `sortKey` and\n * `sortDirection` it is given, so a consumer that ignores `chSort` leaves the\n * `aria-sort` that matches its own data.\n *\n * ```html\n * <ch-table sortable sort-key=\"name\" sort-direction=\"ascending\">\n * <tr><td>Aurora SpA</td><td>En despacho</td></tr>\n * <tr><td>Bosque Ltda</td><td>Pendiente</td></tr>\n * </ch-table>\n * ```\n *\n * ```js\n * table.columns = [\n * { key: 'name', label: 'Cliente' },\n * { key: 'status', label: 'Estado' },\n * ];\n * ```\n *\n * Columns come from the `columns` prop, like `ch-select`'s `options` — there is\n * no `ch-table-column` element, and an unknown element inside a component is\n * never rendered.\n *\n * Rows must be real `<tr>` elements created as DOM nodes, not written as\n * HTML inside the tag: the parser rejects a `<tr>` outside a `<table>`, so\n * `<ch-table><tr>…</tr></ch-table>` in an HTML string parses to a text node\n * and the table correctly reports itself empty. Framework templates and\n * `createElement` are unaffected.\n *\n * The shape is the one approved on #77: `table`/`thead`/`tbody` live in the\n * shadow DOM and the consumer slots native rows. Custom row and cell elements\n * are not possible — the HTML parser foster-parents them out of a native\n * table, which the spike in `tests/browser/semantic-shapes.browser.spec.ts`\n * measured in real Chromium.\n */\n@Component({\n tag: 'ch-table',\n styleUrl: 'ch-table.css',\n shadow: true,\n})\nexport class ChTable {\n private readonly captionId = `ch-table-${++tableIds}-caption`;\n private readonly emptyId = `${this.captionId}-empty`;\n\n @Element() private host!: HTMLElement;\n\n /** Columns, in display order. Rendered as the header row. */\n @Prop() columns: ChTableSortColumn[] = [];\n\n /** Whether the header offers sorting. Individual columns can opt out. */\n @Prop({ reflect: true }) sortable = false;\n\n /** Key of the column currently used for sorting. Controlled by the consumer. */\n @Prop() sortKey?: string;\n\n /** Direction of the current sort. Defaults to `ascending`. */\n @Prop() sortDirection: ChTableSortDirection = 'ascending';\n\n /**\n * Accessible name for the table. Always rendered as a caption, visually\n * hidden, because a data table without a name is announced as a bare grid.\n */\n @Prop() label!: string;\n\n /**\n * Shown in place of the rows when the body is empty. `filtered` distinguishes\n * \"nothing matched your filters\" from \"there is nothing yet\", which are\n * different messages and different next actions.\n */\n @State() empty: 'unmeasured' | 'none' | 'true' = 'unmeasured';\n\n /**\n * Marks the body as empty *because of filtering* rather than because there is\n * no data at all. Both look like zero rows, and they need different messages\n * and different next actions.\n */\n @Prop({ reflect: true }) filtered = false;\n\n /** Emitted when a sortable header is activated. The consumer applies the sort. */\n @Event() chSort: EventEmitter<{ key: string; direction: ChTableSortDirection }>;\n\n @Watch('filtered')\n protected onFiltered(): void {\n this.measure();\n }\n\n @Watch('sortKey')\n @Watch('sortDirection')\n @Watch('sortable')\n protected rerenderHeaders(): void {\n // Header attributes are derived from controlled props, so a prop change\n // has to repaint them; `columns` and the slot repaint on their own.\n this.rerender = !this.rerender;\n }\n\n @State() private rerender = false;\n\n private observer?: MutationObserver;\n\n componentDidLoad() {\n this.measure();\n // `slotchange` does not fire for native `<tr>` children, and it only fires\n // at all once the element is upgraded, so a row added later would leave the\n // table stuck on its first measurement. Observing the host covers both\n // orders plus a consumer that swaps rows on refresh. `MutationObserver` is\n // absent in the mock-doc test environment, where the slot behaviour is\n // exercised through an explicit `slotchange` instead.\n if (typeof MutationObserver === 'function') {\n this.observer = new MutationObserver(this.measure);\n this.observer.observe(this.host, { childList: true });\n }\n }\n\n disconnectedCallback() {\n this.observer?.disconnect();\n this.observer = undefined;\n }\n\n private measure = (): void => {\n const rows = Array.from(this.host.children).filter(child => child.tagName === 'TR');\n this.empty = rows.length === 0 ? 'true' : 'none';\n };\n\n /**\n * A filtered-empty body and a truly empty one both have zero rows; only the\n * consumer knows which, since `filtered` is a prop it controls.\n */\n private get emptyState(): 'none' | 'true' | 'filtered' | 'unmeasured' {\n if (this.filtered) {\n return 'filtered';\n }\n return this.empty;\n }\n\n /** Direction glyph. Not colour: the arrow is the cue in greyscale. */\n private sortCue(active: boolean): string {\n if (!active) {\n return '⇅';\n }\n return this.sortDirection === 'ascending' ? '▲' : '▼';\n }\n\n private emptyMessage(state: 'none' | 'true' | 'filtered' | 'unmeasured'): string {\n return state === 'filtered' ? 'No results for these filters.' : 'Nothing here yet.';\n }\n\n private nextDirection(key: string): ChTableSortDirection {\n if (this.sortKey !== key) {\n return 'ascending';\n }\n return this.sortDirection === 'ascending' ? 'descending' : 'ascending';\n }\n\n private handleSort = (key: string) => {\n this.chSort.emit({ key, direction: this.nextDirection(key) });\n };\n\n private handleHeaderKeydown = (ev: KeyboardEvent, key: string) => {\n if (ev.key !== 'Enter' && ev.key !== ' ') {\n return;\n }\n ev.preventDefault();\n this.handleSort(key);\n };\n\n private renderHeaderCell(column: ChTableSortColumn) {\n const sortable = this.sortable && column.sortable !== false;\n if (!sortable) {\n return (\n <th scope=\"col\" class=\"cell cell--header\">\n {column.label}\n </th>\n );\n }\n\n const active = this.sortKey === column.key;\n const direction = active ? this.sortDirection : 'none';\n return (\n <th scope=\"col\" class=\"cell cell--header\" aria-sort={direction}>\n <button type=\"button\" class=\"sort\" onClick={() => this.handleSort(column.key)} onKeyDown={ev => this.handleHeaderKeydown(ev, column.key)}>\n <span>{column.label}</span>\n <span class=\"sort__cue\" aria-hidden=\"true\">\n {this.sortCue(active)}\n </span>\n </button>\n </th>\n );\n }\n\n render() {\n const empty = this.emptyState;\n // Before the first measurement the table is rendered as non-empty, so a\n // consumer never sees the empty message flash over real rows.\n return (\n <Host class={{ 'table': true, 'table--empty': empty === 'true' || empty === 'filtered' }}>\n <div class=\"table__scroll\" tabIndex={0} role=\"group\" aria-labelledby={this.captionId}>\n <table>\n <caption id={this.captionId} class=\"caption\">\n {this.label}\n </caption>\n <thead>\n <tr>{this.columns.map(column => this.renderHeaderCell(column))}</tr>\n </thead>\n <tbody>\n <slot></slot>\n </tbody>\n </table>\n </div>\n {(empty === 'true' || empty === 'filtered') && (\n <div class=\"table__empty\" id={this.emptyId}>\n <slot name=\"empty\">\n <p class=\"table__empty-message\">{this.emptyMessage(empty)}</p>\n </slot>\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -77,7 +77,7 @@ export class ChTabs {
|
|
|
77
77
|
}
|
|
78
78
|
render() {
|
|
79
79
|
const active = this.activeValue;
|
|
80
|
-
return (h(Host, { key: '
|
|
80
|
+
return (h(Host, { key: '5fd5208bb1b9b75f13b9d3830d042f623aaca651' }, h("div", { key: '8d602a604a8315db01f3e4d28a39e866efabdb48', class: "tablist", role: "tablist", "aria-label": this.label, onKeyDown: this.handleKeyDown, ref: el => (this.tablistEl = el) }, this.tabs.map(tab => {
|
|
81
81
|
const selected = tab.value === active;
|
|
82
82
|
return (h("button", { key: tab.value, type: "button", class: { 'tab': true, 'tab--active': selected, 'tab--disabled': Boolean(tab.disabled) }, role: "tab", id: this.tabId(tab.value), "data-value": tab.value, "aria-selected": selected ? 'true' : 'false', "aria-controls": this.panelId(tab.value), tabIndex: selected ? FIRST_TAB_INDEX : LAST_TAB_INDEX, disabled: tab.disabled, onClick: () => this.select(tab.value) }, tab.label));
|
|
83
83
|
})), this.tabs.map(tab => (h("div", { key: `${tab.value}-panel`, class: "tabpanel", id: this.panelId(tab.value), role: "tabpanel", "aria-labelledby": this.tabId(tab.value), tabIndex: FIRST_TAB_INDEX, hidden: tab.value !== active }, h("slot", { name: `panel-${tab.value}` }))))));
|
|
@@ -108,7 +108,7 @@ export class ChTextarea {
|
|
|
108
108
|
return undefined;
|
|
109
109
|
}
|
|
110
110
|
render() {
|
|
111
|
-
return (h(Host, { key: '
|
|
111
|
+
return (h(Host, { key: '0f2b76444b3bff5d37d069bf1fe307781c5e59d1' }, this.label && (h("label", { key: '08b83be70f33dc2c9b93a6d748564aad4eb63d76', class: "label", htmlFor: this.textareaId }, this.label)), h("textarea", { key: '749876530342e5ff9d70ab7039dded1a4f0faa5a', id: this.label ? this.textareaId : undefined, class: { 'textarea': true, 'textarea--invalid': this.invalid }, rows: this.rows, name: this.name, placeholder: this.placeholder, disabled: this.disabled || this.formDisabled, required: this.required, value: this.value, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onInput: this.handleInput, onChange: this.handleChange }), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '36e41249852346df559bd278256cc89a79371a88', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '90bda1f377da78e07eae82ee13069813c7ed1e8b', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
112
112
|
}
|
|
113
113
|
static get is() { return "ch-textarea"; }
|
|
114
114
|
static get encapsulation() { return "shadow"; }
|
|
@@ -25,7 +25,7 @@ import { Host, h } from "@stencil/core";
|
|
|
25
25
|
*/
|
|
26
26
|
export class ChTimeline {
|
|
27
27
|
render() {
|
|
28
|
-
return (h(Host, { key: '
|
|
28
|
+
return (h(Host, { key: '50b3a225915e4223fa3eaf560cb1e15898026ec0', class: "timeline" }, h("ol", { key: '5b5e218a419f63990deca2d1a7e0f8f36f63cc09', class: "list" }, h("slot", { key: '69ff4592e898cdecb078437b6633e5e24c626e61' }))));
|
|
29
29
|
}
|
|
30
30
|
static get is() { return "ch-timeline"; }
|
|
31
31
|
static get encapsulation() { return "shadow"; }
|
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
display: inline-flex;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/* Fixed at the origin of the same containing block the bubble uses. */
|
|
11
|
+
.probe {
|
|
12
|
+
position: fixed;
|
|
13
|
+
top: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
width: 1px;
|
|
16
|
+
height: 1px;
|
|
17
|
+
visibility: hidden;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
.bubble {
|
|
11
22
|
position: absolute;
|
|
12
23
|
z-index: var(--z-index-dropdown);
|