@devschile/chucao 1.6.0 → 1.8.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/README.md +15 -12
- package/dist/chucao/chucao.css +1 -1
- package/dist/chucao/chucao.esm.js +1 -1
- package/dist/chucao/chucao.esm.js.map +1 -1
- package/dist/chucao/index.esm.js +1 -1
- package/dist/chucao/index.esm.js.map +1 -1
- package/dist/chucao/{p-175aee94.entry.js → p-13ab5f9a.entry.js} +2 -2
- package/dist/chucao/{p-dde82d7d.entry.js → p-1cc7042e.entry.js} +2 -2
- package/dist/chucao/p-23c5220b.entry.js +2 -0
- package/dist/chucao/p-23c5220b.entry.js.map +1 -0
- package/dist/chucao/p-2d7e81b2.entry.js +2 -0
- package/dist/chucao/p-2d7e81b2.entry.js.map +1 -0
- package/dist/chucao/{p-af2c57b5.entry.js → p-421cda05.entry.js} +2 -2
- package/dist/chucao/p-Bvah_WQV.js +3 -0
- package/dist/chucao/p-Bvah_WQV.js.map +1 -0
- package/dist/chucao/{p-d75eeeea.entry.js → p-c16b18b7.entry.js} +2 -2
- package/dist/chucao/p-cbb2b478.entry.js +2 -0
- package/dist/chucao/p-cbb2b478.entry.js.map +1 -0
- package/dist/chucao/{p-fcc70c8d.entry.js → p-cfb6db53.entry.js} +2 -2
- package/dist/chucao/p-df73f786.entry.js +2 -0
- package/dist/chucao/{p-85a49fd7.entry.js → p-e8fe65bb.entry.js} +2 -2
- package/dist/cjs/ch-accordion.cjs.entry.js +1 -1
- package/dist/cjs/{ch-badge_6.cjs.entry.js → ch-alert_8.cjs.entry.js} +73 -9
- package/dist/cjs/ch-alert_8.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-checkbox.cjs.entry.js +2 -2
- package/dist/cjs/ch-divider.cjs.entry.js +2 -2
- package/dist/cjs/ch-link.cjs.entry.js +1 -1
- package/dist/cjs/ch-modal.cjs.entry.js +167 -0
- package/dist/cjs/ch-modal.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-radio.cjs.entry.js +2 -2
- package/dist/cjs/ch-tabs.cjs.entry.js +2 -2
- package/dist/cjs/ch-textarea.cjs.entry.js +2 -2
- package/dist/cjs/ch-tooltip.cjs.entry.js +82 -0
- package/dist/cjs/ch-tooltip.cjs.entry.js.map +1 -0
- package/dist/cjs/chucao.cjs.js +3 -3
- package/dist/cjs/chucao.cjs.js.map +1 -1
- package/dist/cjs/{index-CiYvuUBV.js → index-DMeDkSQU.js} +183 -11
- package/dist/cjs/index-DMeDkSQU.js.map +1 -0
- package/dist/cjs/index.cjs.js +12 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +5 -1
- package/dist/collection/components/ch-alert/ch-alert.css +77 -0
- package/dist/collection/components/ch-alert/ch-alert.js +118 -0
- package/dist/collection/components/ch-alert/ch-alert.js.map +1 -0
- package/dist/collection/components/ch-badge/ch-badge.js +1 -1
- package/dist/collection/components/ch-button/ch-button.js +1 -1
- package/dist/collection/components/ch-button/ch-button.js.map +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-divider/ch-divider.js +1 -1
- package/dist/collection/components/ch-input/ch-input.js +1 -1
- package/dist/collection/components/ch-modal/ch-modal.css +69 -0
- package/dist/collection/components/ch-modal/ch-modal.js +278 -0
- package/dist/collection/components/ch-modal/ch-modal.js.map +1 -0
- package/dist/collection/components/ch-radio/ch-radio.js +1 -1
- package/dist/collection/components/ch-select/ch-select.js +1 -1
- package/dist/collection/components/ch-spinner/ch-spinner.css +39 -0
- package/dist/collection/components/ch-spinner/ch-spinner.js +90 -0
- package/dist/collection/components/ch-spinner/ch-spinner.js.map +1 -0
- package/dist/collection/components/ch-switch/ch-switch.js +1 -1
- 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-tooltip/ch-tooltip.css +100 -0
- package/dist/collection/components/ch-tooltip/ch-tooltip.js +168 -0
- package/dist/collection/components/ch-tooltip/ch-tooltip.js.map +1 -0
- package/dist/collection/tokens/tokens.js +9 -1
- package/dist/collection/tokens/tokens.js.map +1 -1
- package/dist/collection/tokens/types.js.map +1 -1
- package/dist/components/ch-accordion.js +1 -1
- package/dist/components/ch-alert.d.ts +11 -0
- package/dist/components/ch-alert.js +2 -0
- package/dist/components/ch-alert.js.map +1 -0
- package/dist/components/ch-badge.js +1 -1
- package/dist/components/ch-button.js +1 -1
- package/dist/components/ch-button.js.map +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-divider.js +1 -1
- package/dist/components/ch-input.js +1 -1
- package/dist/components/ch-link.js +1 -1
- package/dist/components/ch-modal.d.ts +11 -0
- package/dist/components/ch-modal.js +2 -0
- package/dist/components/ch-modal.js.map +1 -0
- package/dist/components/ch-radio.js +1 -1
- package/dist/components/ch-select.js +1 -1
- package/dist/components/ch-spinner.d.ts +11 -0
- package/dist/components/ch-spinner.js +2 -0
- package/dist/components/ch-spinner.js.map +1 -0
- package/dist/components/ch-switch.js +1 -1
- package/dist/components/ch-tabs.js +1 -1
- package/dist/components/ch-textarea.js +1 -1
- package/dist/components/ch-tooltip.d.ts +11 -0
- package/dist/components/ch-tooltip.js +2 -0
- package/dist/components/ch-tooltip.js.map +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-hyy-cLgi.js +2 -0
- package/dist/components/p-hyy-cLgi.js.map +1 -0
- package/dist/esm/ch-accordion.entry.js +1 -1
- package/dist/esm/{ch-badge_6.entry.js → ch-alert_8.entry.js} +72 -10
- package/dist/esm/ch-alert_8.entry.js.map +1 -0
- package/dist/esm/ch-checkbox.entry.js +2 -2
- package/dist/esm/ch-divider.entry.js +2 -2
- package/dist/esm/ch-link.entry.js +1 -1
- package/dist/esm/ch-modal.entry.js +165 -0
- package/dist/esm/ch-modal.entry.js.map +1 -0
- package/dist/esm/ch-radio.entry.js +2 -2
- package/dist/esm/ch-tabs.entry.js +2 -2
- package/dist/esm/ch-textarea.entry.js +2 -2
- package/dist/esm/ch-tooltip.entry.js +80 -0
- package/dist/esm/ch-tooltip.entry.js.map +1 -0
- package/dist/esm/chucao.js +4 -4
- package/dist/esm/chucao.js.map +1 -1
- package/dist/esm/{index-ImsAHlk9.js → index-Bvah_WQV.js} +183 -12
- package/dist/esm/index-Bvah_WQV.js.map +1 -0
- package/dist/esm/index.js +10 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/ch-alert/ch-alert.d.ts +34 -0
- package/dist/types/components/ch-modal/ch-modal.d.ts +67 -0
- package/dist/types/components/ch-spinner/ch-spinner.d.ts +25 -0
- package/dist/types/components/ch-tooltip/ch-tooltip.d.ts +47 -0
- package/dist/types/components.d.ts +369 -0
- package/dist/types/stencil-public-runtime.d.ts +11 -0
- package/dist/types/tokens/tokens.d.ts +8 -0
- package/dist/types/tokens/types.d.ts +3 -3
- package/dist-react/components.d.ts +18 -1
- package/dist-react/components.js +39 -0
- package/dist-react/components.ts +55 -1
- package/dist-vue/index.d.ts +4 -0
- package/dist-vue/index.js +28 -0
- package/dist-vue/index.ts +36 -0
- package/hydrate/index.js +542 -19
- package/hydrate/index.mjs +542 -19
- package/package.json +6 -2
- package/dist/chucao/p-ImsAHlk9.js +0 -3
- package/dist/chucao/p-ImsAHlk9.js.map +0 -1
- package/dist/chucao/p-b4520f1c.entry.js +0 -2
- package/dist/chucao/p-b4520f1c.entry.js.map +0 -1
- package/dist/chucao/p-fe0c9320.entry.js +0 -2
- package/dist/cjs/ch-badge_6.cjs.entry.js.map +0 -1
- package/dist/cjs/index-CiYvuUBV.js.map +0 -1
- package/dist/components/p-x4aZoujY.js +0 -2
- package/dist/components/p-x4aZoujY.js.map +0 -1
- package/dist/esm/ch-badge_6.entry.js.map +0 -1
- package/dist/esm/index-ImsAHlk9.js.map +0 -1
- /package/dist/chucao/{p-175aee94.entry.js.map → p-13ab5f9a.entry.js.map} +0 -0
- /package/dist/chucao/{p-dde82d7d.entry.js.map → p-1cc7042e.entry.js.map} +0 -0
- /package/dist/chucao/{p-af2c57b5.entry.js.map → p-421cda05.entry.js.map} +0 -0
- /package/dist/chucao/{p-d75eeeea.entry.js.map → p-c16b18b7.entry.js.map} +0 -0
- /package/dist/chucao/{p-fcc70c8d.entry.js.map → p-cfb6db53.entry.js.map} +0 -0
- /package/dist/chucao/{p-fe0c9320.entry.js.map → p-df73f786.entry.js.map} +0 -0
- /package/dist/chucao/{p-85a49fd7.entry.js.map → p-e8fe65bb.entry.js.map} +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
let openModals = 0;
|
|
3
|
+
let previousOverflow = '';
|
|
4
|
+
let previousPaddingRight = '';
|
|
5
|
+
/**
|
|
6
|
+
* Modal dialog, built on the native `<dialog>` element and opened with
|
|
7
|
+
* `showModal()`.
|
|
8
|
+
*
|
|
9
|
+
* The browser therefore supplies the parts that are easy to get wrong: moving
|
|
10
|
+
* focus into the dialog and returning it afterwards, marking the rest of the
|
|
11
|
+
* document inert, `Escape` to close, the top layer, `::backdrop`, and the
|
|
12
|
+
* implicit `dialog` role with `aria-modal="true"`. Notably it does not trap
|
|
13
|
+
* focus, which is deliberate — the W3C APA group concluded a modal should let
|
|
14
|
+
* keyboard users reach browser UI, so a hand-rolled trap would be less
|
|
15
|
+
* correct, not more.
|
|
16
|
+
*
|
|
17
|
+
* What the platform does not cover, and this component adds: locking the page
|
|
18
|
+
* behind the dialog so it cannot scroll, and closing when the backdrop is
|
|
19
|
+
* clicked. The latter is `closedby="any"` in the platform, which Safari does
|
|
20
|
+
* not support yet, so it is implemented here for every browser alike rather
|
|
21
|
+
* than only for some.
|
|
22
|
+
*/
|
|
23
|
+
export class ChModal {
|
|
24
|
+
/**
|
|
25
|
+
* Whether the dialog is open. Kept in sync when the user closes it with
|
|
26
|
+
* `Escape`, the close button or a click outside.
|
|
27
|
+
*/
|
|
28
|
+
open = false;
|
|
29
|
+
/**
|
|
30
|
+
* Accessible name for the dialog, set as `aria-label`. A slotted heading
|
|
31
|
+
* cannot be referenced with `aria-labelledby` across the shadow boundary, so
|
|
32
|
+
* the name comes through this prop — and a modal dialog needs one, so pass
|
|
33
|
+
* the same text as the heading.
|
|
34
|
+
*/
|
|
35
|
+
label;
|
|
36
|
+
/**
|
|
37
|
+
* Accessible label for the close button, set as `aria-label`. Setting it is
|
|
38
|
+
* what adds the button: its only content is a decorative glyph, so without a
|
|
39
|
+
* label it would have no accessible name.
|
|
40
|
+
*/
|
|
41
|
+
closeLabel;
|
|
42
|
+
/**
|
|
43
|
+
* Emitted after the dialog opens.
|
|
44
|
+
*/
|
|
45
|
+
chOpen;
|
|
46
|
+
/**
|
|
47
|
+
* Emitted after the dialog closes, however it was closed.
|
|
48
|
+
*/
|
|
49
|
+
chClose;
|
|
50
|
+
dialog;
|
|
51
|
+
scrollLocked = false;
|
|
52
|
+
pointerDownedOutside = false;
|
|
53
|
+
componentDidLoad() {
|
|
54
|
+
// Wired here rather than in JSX because Stencil derives a listener's event
|
|
55
|
+
// name from whether `on<name>` exists on `window`, which differs between
|
|
56
|
+
// the browser and the test environment for pointer events.
|
|
57
|
+
this.dialog?.addEventListener('close', this.handleNativeClose);
|
|
58
|
+
this.dialog?.addEventListener('pointerdown', this.handlePointerDown);
|
|
59
|
+
this.dialog?.addEventListener('click', this.handleClick);
|
|
60
|
+
if (this.open) {
|
|
61
|
+
this.showDialog();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
disconnectedCallback() {
|
|
65
|
+
this.dialog?.removeEventListener('close', this.handleNativeClose);
|
|
66
|
+
this.dialog?.removeEventListener('pointerdown', this.handlePointerDown);
|
|
67
|
+
this.dialog?.removeEventListener('click', this.handleClick);
|
|
68
|
+
this.unlockScroll();
|
|
69
|
+
}
|
|
70
|
+
handleOpenChange(open) {
|
|
71
|
+
if (open) {
|
|
72
|
+
this.showDialog();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this.closeDialog();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
showDialog() {
|
|
79
|
+
if (typeof this.dialog?.showModal !== 'function') {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.lockScroll();
|
|
83
|
+
this.dialog.showModal();
|
|
84
|
+
this.chOpen.emit();
|
|
85
|
+
}
|
|
86
|
+
closeDialog() {
|
|
87
|
+
if (typeof this.dialog?.close === 'function' && this.dialog.open) {
|
|
88
|
+
this.dialog.close();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
lockScroll() {
|
|
92
|
+
if (this.scrollLocked) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.scrollLocked = true;
|
|
96
|
+
openModals += 1;
|
|
97
|
+
if (openModals > 1) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const root = document.documentElement;
|
|
101
|
+
const scrollbar = window.innerWidth - root.clientWidth;
|
|
102
|
+
previousOverflow = root.style.overflow;
|
|
103
|
+
previousPaddingRight = root.style.paddingRight;
|
|
104
|
+
root.style.overflow = 'hidden';
|
|
105
|
+
if (scrollbar > 0) {
|
|
106
|
+
root.style.paddingRight = `${scrollbar}px`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
unlockScroll() {
|
|
110
|
+
if (!this.scrollLocked) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.scrollLocked = false;
|
|
114
|
+
openModals -= 1;
|
|
115
|
+
if (openModals > 0) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const root = document.documentElement;
|
|
119
|
+
root.style.overflow = previousOverflow;
|
|
120
|
+
root.style.paddingRight = previousPaddingRight;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* True for a pointer event on the backdrop: the `<dialog>` is the event
|
|
124
|
+
* target for its own box only, and the coordinates fall outside that box.
|
|
125
|
+
*/
|
|
126
|
+
isOnBackdrop(event) {
|
|
127
|
+
if (!this.dialog || event.target !== this.dialog) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
const box = this.dialog.getBoundingClientRect();
|
|
131
|
+
return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
|
|
132
|
+
}
|
|
133
|
+
handlePointerDown = (event) => {
|
|
134
|
+
this.pointerDownedOutside = this.isOnBackdrop(event);
|
|
135
|
+
};
|
|
136
|
+
handleClick = (event) => {
|
|
137
|
+
// Requiring the press to have started on the backdrop too keeps a
|
|
138
|
+
// selection dragged out of the dialog, and a keyboard-synthesised click
|
|
139
|
+
// (which reports coordinates of 0), from closing it.
|
|
140
|
+
const dismiss = this.pointerDownedOutside && this.isOnBackdrop(event);
|
|
141
|
+
this.pointerDownedOutside = false;
|
|
142
|
+
if (dismiss) {
|
|
143
|
+
this.closeDialog();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
handleNativeClose = () => {
|
|
147
|
+
this.unlockScroll();
|
|
148
|
+
if (this.open) {
|
|
149
|
+
this.open = false;
|
|
150
|
+
}
|
|
151
|
+
this.chClose.emit();
|
|
152
|
+
};
|
|
153
|
+
handleCloseClick = () => {
|
|
154
|
+
if (typeof this.dialog?.close === 'function' && this.dialog.open) {
|
|
155
|
+
this.dialog.close();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
this.open = false;
|
|
159
|
+
this.chClose.emit();
|
|
160
|
+
};
|
|
161
|
+
render() {
|
|
162
|
+
return (h(Host, { key: '92edf16d3ff079f72a4785ec9852e3e25218fd35' }, h("dialog", { key: '546fc72a098e1e2d8c05fafa2f11eac19ff83fd3', class: "modal", "aria-label": this.label, ref: el => (this.dialog = el) }, h("div", { key: '5a67aa39b6687db89d97533eb54d3a3b663bed56', class: "modal-head" }, h("slot", { key: '2e44b59a7c5e6af4a110a7f86362964ddd30d215', name: "heading" }), this.closeLabel && (h("button", { key: 'ce70baaa876c9f7b82865f0547e8e8cef5d5dfde', class: "modal-close", type: "button", "aria-label": this.closeLabel, onClick: this.handleCloseClick }, h("span", { key: 'df4536a8851a1ca9d3d2c46d15d18856660a54f6', "aria-hidden": "true" }, "\u00D7")))), h("div", { key: '5de77062134ccd90643df17d7b0d0ddb161f6a5f', class: "modal-body" }, h("slot", { key: '3b64493e9236b311a4b2f5250c5027f866bce8fd' })))));
|
|
163
|
+
}
|
|
164
|
+
static get is() { return "ch-modal"; }
|
|
165
|
+
static get encapsulation() { return "shadow"; }
|
|
166
|
+
static get originalStyleUrls() {
|
|
167
|
+
return {
|
|
168
|
+
"$": ["ch-modal.css"]
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
static get styleUrls() {
|
|
172
|
+
return {
|
|
173
|
+
"$": ["ch-modal.css"]
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
static get properties() {
|
|
177
|
+
return {
|
|
178
|
+
"open": {
|
|
179
|
+
"type": "boolean",
|
|
180
|
+
"mutable": true,
|
|
181
|
+
"complexType": {
|
|
182
|
+
"original": "boolean",
|
|
183
|
+
"resolved": "boolean",
|
|
184
|
+
"references": {}
|
|
185
|
+
},
|
|
186
|
+
"required": false,
|
|
187
|
+
"optional": false,
|
|
188
|
+
"docs": {
|
|
189
|
+
"tags": [],
|
|
190
|
+
"text": "Whether the dialog is open. Kept in sync when the user closes it with\n`Escape`, the close button or a click outside."
|
|
191
|
+
},
|
|
192
|
+
"getter": false,
|
|
193
|
+
"setter": false,
|
|
194
|
+
"reflect": false,
|
|
195
|
+
"attribute": "open",
|
|
196
|
+
"defaultValue": "false"
|
|
197
|
+
},
|
|
198
|
+
"label": {
|
|
199
|
+
"type": "string",
|
|
200
|
+
"mutable": false,
|
|
201
|
+
"complexType": {
|
|
202
|
+
"original": "string",
|
|
203
|
+
"resolved": "string",
|
|
204
|
+
"references": {}
|
|
205
|
+
},
|
|
206
|
+
"required": false,
|
|
207
|
+
"optional": true,
|
|
208
|
+
"docs": {
|
|
209
|
+
"tags": [],
|
|
210
|
+
"text": "Accessible name for the dialog, set as `aria-label`. A slotted heading\ncannot be referenced with `aria-labelledby` across the shadow boundary, so\nthe name comes through this prop \u2014 and a modal dialog needs one, so pass\nthe same text as the heading."
|
|
211
|
+
},
|
|
212
|
+
"getter": false,
|
|
213
|
+
"setter": false,
|
|
214
|
+
"reflect": false,
|
|
215
|
+
"attribute": "label"
|
|
216
|
+
},
|
|
217
|
+
"closeLabel": {
|
|
218
|
+
"type": "string",
|
|
219
|
+
"mutable": false,
|
|
220
|
+
"complexType": {
|
|
221
|
+
"original": "string",
|
|
222
|
+
"resolved": "string",
|
|
223
|
+
"references": {}
|
|
224
|
+
},
|
|
225
|
+
"required": false,
|
|
226
|
+
"optional": true,
|
|
227
|
+
"docs": {
|
|
228
|
+
"tags": [],
|
|
229
|
+
"text": "Accessible label for the close button, set as `aria-label`. Setting it is\nwhat adds the button: its only content is a decorative glyph, so without a\nlabel it would have no accessible name."
|
|
230
|
+
},
|
|
231
|
+
"getter": false,
|
|
232
|
+
"setter": false,
|
|
233
|
+
"reflect": false,
|
|
234
|
+
"attribute": "close-label"
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
static get events() {
|
|
239
|
+
return [{
|
|
240
|
+
"method": "chOpen",
|
|
241
|
+
"name": "chOpen",
|
|
242
|
+
"bubbles": true,
|
|
243
|
+
"cancelable": true,
|
|
244
|
+
"composed": true,
|
|
245
|
+
"docs": {
|
|
246
|
+
"tags": [],
|
|
247
|
+
"text": "Emitted after the dialog opens."
|
|
248
|
+
},
|
|
249
|
+
"complexType": {
|
|
250
|
+
"original": "void",
|
|
251
|
+
"resolved": "void",
|
|
252
|
+
"references": {}
|
|
253
|
+
}
|
|
254
|
+
}, {
|
|
255
|
+
"method": "chClose",
|
|
256
|
+
"name": "chClose",
|
|
257
|
+
"bubbles": true,
|
|
258
|
+
"cancelable": true,
|
|
259
|
+
"composed": true,
|
|
260
|
+
"docs": {
|
|
261
|
+
"tags": [],
|
|
262
|
+
"text": "Emitted after the dialog closes, however it was closed."
|
|
263
|
+
},
|
|
264
|
+
"complexType": {
|
|
265
|
+
"original": "void",
|
|
266
|
+
"resolved": "void",
|
|
267
|
+
"references": {}
|
|
268
|
+
}
|
|
269
|
+
}];
|
|
270
|
+
}
|
|
271
|
+
static get watchers() {
|
|
272
|
+
return [{
|
|
273
|
+
"propName": "open",
|
|
274
|
+
"methodName": "handleOpenChange"
|
|
275
|
+
}];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=ch-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ch-modal.js","sourceRoot":"","sources":["../../../../src/components/ch-modal/ch-modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAqB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE1F,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,IAAI,gBAAgB,GAAG,EAAE,CAAC;AAC1B,IAAI,oBAAoB,GAAG,EAAE,CAAC;AAE9B;;;;;;;;;;;;;;;;;GAiBG;AAMH,MAAM,OAAO,OAAO;IAClB;;;OAGG;IACsB,IAAI,GAAG,KAAK,CAAC;IAEtC;;;;;OAKG;IACK,KAAK,CAAU;IAEvB;;;;OAIG;IACK,UAAU,CAAU;IAE5B;;OAEG;IACM,MAAM,CAAqB;IAEpC;;OAEG;IACM,OAAO,CAAqB;IAE7B,MAAM,CAAqB;IAC3B,YAAY,GAAG,KAAK,CAAC;IACrB,oBAAoB,GAAG,KAAK,CAAC;IAErC,gBAAgB;QACd,2EAA2E;QAC3E,yEAAyE;QACzE,2DAA2D;QAC3D,IAAI,CAAC,MAAM,EAA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,KAAK,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM;QACJ,OAAO,CACL,EAAC,IAAI;YACH,+DAAQ,KAAK,EAAC,OAAO,gBAAa,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,EAAuB,CAAC;gBAC9F,4DAAK,KAAK,EAAC,YAAY;oBACrB,6DAAM,IAAI,EAAC,SAAS,GAAQ;oBAC3B,IAAI,CAAC,UAAU,IAAI,CAClB,+DAAQ,KAAK,EAAC,aAAa,EAAC,IAAI,EAAC,QAAQ,gBAAa,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB;wBACnG,4EAAkB,MAAM,aAAS,CAC1B,CACV,CACG;gBACN,4DAAK,KAAK,EAAC,YAAY;oBACrB,8DAAa,CACT,CACC,CACJ,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, type EventEmitter, Host, Prop, Watch, h } from '@stencil/core';\n\nlet openModals = 0;\nlet previousOverflow = '';\nlet previousPaddingRight = '';\n\n/**\n * Modal dialog, built on the native `<dialog>` element and opened with\n * `showModal()`.\n *\n * The browser therefore supplies the parts that are easy to get wrong: moving\n * focus into the dialog and returning it afterwards, marking the rest of the\n * document inert, `Escape` to close, the top layer, `::backdrop`, and the\n * implicit `dialog` role with `aria-modal=\"true\"`. Notably it does not trap\n * focus, which is deliberate — the W3C APA group concluded a modal should let\n * keyboard users reach browser UI, so a hand-rolled trap would be less\n * correct, not more.\n *\n * What the platform does not cover, and this component adds: locking the page\n * behind the dialog so it cannot scroll, and closing when the backdrop is\n * clicked. The latter is `closedby=\"any\"` in the platform, which Safari does\n * not support yet, so it is implemented here for every browser alike rather\n * than only for some.\n */\n@Component({\n tag: 'ch-modal',\n styleUrl: 'ch-modal.css',\n shadow: true,\n})\nexport class ChModal {\n /**\n * Whether the dialog is open. Kept in sync when the user closes it with\n * `Escape`, the close button or a click outside.\n */\n @Prop({ mutable: true }) open = false;\n\n /**\n * Accessible name for the dialog, set as `aria-label`. A slotted heading\n * cannot be referenced with `aria-labelledby` across the shadow boundary, so\n * the name comes through this prop — and a modal dialog needs one, so pass\n * the same text as the heading.\n */\n @Prop() label?: string;\n\n /**\n * Accessible label for the close button, set as `aria-label`. Setting it is\n * what adds the button: its only content is a decorative glyph, so without a\n * label it would have no accessible name.\n */\n @Prop() closeLabel?: string;\n\n /**\n * Emitted after the dialog opens.\n */\n @Event() chOpen: EventEmitter<void>;\n\n /**\n * Emitted after the dialog closes, however it was closed.\n */\n @Event() chClose: EventEmitter<void>;\n\n private dialog?: HTMLDialogElement;\n private scrollLocked = false;\n private pointerDownedOutside = false;\n\n componentDidLoad() {\n // Wired here rather than in JSX because Stencil derives a listener's event\n // name from whether `on<name>` exists on `window`, which differs between\n // the browser and the test environment for pointer events.\n this.dialog?.addEventListener('close', this.handleNativeClose);\n this.dialog?.addEventListener('pointerdown', this.handlePointerDown);\n this.dialog?.addEventListener('click', this.handleClick);\n if (this.open) {\n this.showDialog();\n }\n }\n\n disconnectedCallback() {\n this.dialog?.removeEventListener('close', this.handleNativeClose);\n this.dialog?.removeEventListener('pointerdown', this.handlePointerDown);\n this.dialog?.removeEventListener('click', this.handleClick);\n this.unlockScroll();\n }\n\n @Watch('open')\n handleOpenChange(open: boolean) {\n if (open) {\n this.showDialog();\n } else {\n this.closeDialog();\n }\n }\n\n private showDialog() {\n if (typeof this.dialog?.showModal !== 'function') {\n return;\n }\n this.lockScroll();\n this.dialog.showModal();\n this.chOpen.emit();\n }\n\n private closeDialog() {\n if (typeof this.dialog?.close === 'function' && this.dialog.open) {\n this.dialog.close();\n }\n }\n\n private lockScroll() {\n if (this.scrollLocked) {\n return;\n }\n this.scrollLocked = true;\n openModals += 1;\n if (openModals > 1) {\n return;\n }\n const root = document.documentElement;\n const scrollbar = window.innerWidth - root.clientWidth;\n previousOverflow = root.style.overflow;\n previousPaddingRight = root.style.paddingRight;\n root.style.overflow = 'hidden';\n if (scrollbar > 0) {\n root.style.paddingRight = `${scrollbar}px`;\n }\n }\n\n private unlockScroll() {\n if (!this.scrollLocked) {\n return;\n }\n this.scrollLocked = false;\n openModals -= 1;\n if (openModals > 0) {\n return;\n }\n const root = document.documentElement;\n root.style.overflow = previousOverflow;\n root.style.paddingRight = previousPaddingRight;\n }\n\n /**\n * True for a pointer event on the backdrop: the `<dialog>` is the event\n * target for its own box only, and the coordinates fall outside that box.\n */\n private isOnBackdrop(event: MouseEvent) {\n if (!this.dialog || event.target !== this.dialog) {\n return false;\n }\n const box = this.dialog.getBoundingClientRect();\n return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;\n }\n\n private handlePointerDown = (event: Event) => {\n this.pointerDownedOutside = this.isOnBackdrop(event as MouseEvent);\n };\n\n private handleClick = (event: Event) => {\n // Requiring the press to have started on the backdrop too keeps a\n // selection dragged out of the dialog, and a keyboard-synthesised click\n // (which reports coordinates of 0), from closing it.\n const dismiss = this.pointerDownedOutside && this.isOnBackdrop(event as MouseEvent);\n this.pointerDownedOutside = false;\n if (dismiss) {\n this.closeDialog();\n }\n };\n\n private handleNativeClose = () => {\n this.unlockScroll();\n if (this.open) {\n this.open = false;\n }\n this.chClose.emit();\n };\n\n private handleCloseClick = () => {\n if (typeof this.dialog?.close === 'function' && this.dialog.open) {\n this.dialog.close();\n return;\n }\n this.open = false;\n this.chClose.emit();\n };\n\n render() {\n return (\n <Host>\n <dialog class=\"modal\" aria-label={this.label} ref={el => (this.dialog = el as HTMLDialogElement)}>\n <div class=\"modal-head\">\n <slot name=\"heading\"></slot>\n {this.closeLabel && (\n <button class=\"modal-close\" type=\"button\" aria-label={this.closeLabel} onClick={this.handleCloseClick}>\n <span aria-hidden=\"true\">×</span>\n </button>\n )}\n </div>\n <div class=\"modal-body\">\n <slot></slot>\n </div>\n </dialog>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -63,7 +63,7 @@ export class ChRadio {
|
|
|
63
63
|
}
|
|
64
64
|
render() {
|
|
65
65
|
const groupName = this.name || `${this.groupId}-group`;
|
|
66
|
-
return (h(Host, { key: '
|
|
66
|
+
return (h(Host, { key: '68ce563b4a03669b76ff3822705b1ff92c4c02f2' }, this.label && (h("span", { key: '1887f5b70a5bf9f049495d76588458181d3f7735', class: "group-label", id: this.labelId }, this.label)), h("div", { key: 'c38ee340f9527e16c5587f2309f91ea463bb7cad', class: "radio-group", role: "radiogroup", "aria-labelledby": this.label ? this.labelId : undefined }, this.options.map(option => (h("label", { class: { 'control': true, 'control--disabled': this.disabled || option.disabled } }, h("input", { class: { 'input': true, 'input--invalid': this.invalid }, type: "radio", name: groupName, value: option.value, checked: option.value === this.value, disabled: this.disabled || option.disabled, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), h("span", { class: "mark" }), h("span", { class: "label-text" }, option.label))))), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: 'ad60ce772279809ee334fc30182be1d0350d5586', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '316c911f9e1a29d17cc2d6b0e60ed35755420ae2', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
67
67
|
}
|
|
68
68
|
static get is() { return "ch-radio"; }
|
|
69
69
|
static get encapsulation() { return "shadow"; }
|
|
@@ -64,7 +64,7 @@ export class ChSelect {
|
|
|
64
64
|
return undefined;
|
|
65
65
|
}
|
|
66
66
|
render() {
|
|
67
|
-
return (h(Host, { key: '
|
|
67
|
+
return (h(Host, { key: '90aaf1fa70da54071539de8a22ebe9373f2ae90a' }, this.label && (h("label", { key: '8b14b4deb611c4f1eb496c6f0d3fa58b7c4342b6', class: "label", htmlFor: this.selectId }, this.label)), h("select", { key: 'c93b4ba079e9e61ef5bb2392256545af73263665', id: this.label ? this.selectId : undefined, class: { 'select': true, 'select--invalid': this.invalid }, name: this.name, disabled: this.disabled, required: this.required, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }, this.placeholder && (h("option", { key: 'df8e97bdb0bd3e5426558027d34c1eb63ee76f1e', value: "", disabled: true, hidden: true, selected: !this.value }, this.placeholder)), this.options.map(option => (h("option", { value: option.value, disabled: option.disabled, selected: option.value === this.value }, option.label)))), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '6b6078e31a1a2f183951f5ada63a5e7e7f582f96', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: 'f7791b37b8660441a43a6b45d99472b2df7df0ab', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
68
68
|
}
|
|
69
69
|
static get is() { return "ch-select"; }
|
|
70
70
|
static get encapsulation() { return "shadow"; }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
vertical-align: middle;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.spinner {
|
|
7
|
+
display: block;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
width: 1em;
|
|
10
|
+
height: 1em;
|
|
11
|
+
border: 0.125em solid currentColor;
|
|
12
|
+
border-top-color: transparent;
|
|
13
|
+
border-radius: 50%;
|
|
14
|
+
animation: ch-spinner-rotate var(--duration-spin) var(--easing-linear) infinite;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.spinner--sm {
|
|
18
|
+
font-size: var(--typography-size-sm);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.spinner--md {
|
|
22
|
+
font-size: var(--typography-size-lg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.spinner--lg {
|
|
26
|
+
font-size: var(--typography-size-xl);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@keyframes ch-spinner-rotate {
|
|
30
|
+
to {
|
|
31
|
+
transform: rotate(360deg);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@media (prefers-reduced-motion: reduce) {
|
|
36
|
+
.spinner {
|
|
37
|
+
animation-duration: calc(var(--duration-spin) * 4);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
/**
|
|
3
|
+
* Loading indicator.
|
|
4
|
+
*
|
|
5
|
+
* The spinner is drawn in `currentColor`, so it takes the surrounding text
|
|
6
|
+
* colour and stays legible on any surface — inside a primary `ch-button` it
|
|
7
|
+
* picks up the button's own text colour instead of the accent, which would be
|
|
8
|
+
* invisible there. Set `color` on or above the element to change it.
|
|
9
|
+
*/
|
|
10
|
+
export class ChSpinner {
|
|
11
|
+
/**
|
|
12
|
+
* The size of the spinner. Either `sm`, `md`, or `lg`. Each size sets a
|
|
13
|
+
* font-size and the spinner is drawn in `em`, so it also scales with an
|
|
14
|
+
* inherited font-size.
|
|
15
|
+
*/
|
|
16
|
+
size = 'md';
|
|
17
|
+
/**
|
|
18
|
+
* Accessible label announced while the spinner is visible, e.g. `Cargando
|
|
19
|
+
* resultados`. When omitted the spinner is treated as decorative and hidden
|
|
20
|
+
* from assistive technology — the right behaviour next to visible loading
|
|
21
|
+
* text, which would otherwise be announced twice.
|
|
22
|
+
*/
|
|
23
|
+
label;
|
|
24
|
+
render() {
|
|
25
|
+
const labelled = Boolean(this.label);
|
|
26
|
+
return (h(Host, { key: 'dc7c7e19f6a6878680555b0d7dbd84f5dc5774c8' }, h("span", { key: 'd29d5f3344ae578d2a28382b13b45b901d41e52b', class: { spinner: true, [`spinner--${this.size}`]: true }, role: labelled ? 'status' : undefined, "aria-label": labelled ? this.label : undefined, "aria-hidden": labelled ? undefined : 'true' })));
|
|
27
|
+
}
|
|
28
|
+
static get is() { return "ch-spinner"; }
|
|
29
|
+
static get encapsulation() { return "shadow"; }
|
|
30
|
+
static get originalStyleUrls() {
|
|
31
|
+
return {
|
|
32
|
+
"$": ["ch-spinner.css"]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
static get styleUrls() {
|
|
36
|
+
return {
|
|
37
|
+
"$": ["ch-spinner.css"]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
static get properties() {
|
|
41
|
+
return {
|
|
42
|
+
"size": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"mutable": false,
|
|
45
|
+
"complexType": {
|
|
46
|
+
"original": "ChSpinnerSize",
|
|
47
|
+
"resolved": "\"lg\" | \"md\" | \"sm\"",
|
|
48
|
+
"references": {
|
|
49
|
+
"ChSpinnerSize": {
|
|
50
|
+
"location": "local",
|
|
51
|
+
"path": "/home/runner/work/chucao/chucao/src/components/ch-spinner/ch-spinner.tsx",
|
|
52
|
+
"id": "src/components/ch-spinner/ch-spinner.tsx::ChSpinnerSize"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": false,
|
|
57
|
+
"optional": false,
|
|
58
|
+
"docs": {
|
|
59
|
+
"tags": [],
|
|
60
|
+
"text": "The size of the spinner. Either `sm`, `md`, or `lg`. Each size sets a\nfont-size and the spinner is drawn in `em`, so it also scales with an\ninherited font-size."
|
|
61
|
+
},
|
|
62
|
+
"getter": false,
|
|
63
|
+
"setter": false,
|
|
64
|
+
"reflect": false,
|
|
65
|
+
"attribute": "size",
|
|
66
|
+
"defaultValue": "'md'"
|
|
67
|
+
},
|
|
68
|
+
"label": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"mutable": false,
|
|
71
|
+
"complexType": {
|
|
72
|
+
"original": "string",
|
|
73
|
+
"resolved": "string",
|
|
74
|
+
"references": {}
|
|
75
|
+
},
|
|
76
|
+
"required": false,
|
|
77
|
+
"optional": true,
|
|
78
|
+
"docs": {
|
|
79
|
+
"tags": [],
|
|
80
|
+
"text": "Accessible label announced while the spinner is visible, e.g. `Cargando\nresultados`. When omitted the spinner is treated as decorative and hidden\nfrom assistive technology \u2014 the right behaviour next to visible loading\ntext, which would otherwise be announced twice."
|
|
81
|
+
},
|
|
82
|
+
"getter": false,
|
|
83
|
+
"setter": false,
|
|
84
|
+
"reflect": false,
|
|
85
|
+
"attribute": "label"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=ch-spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ch-spinner.js","sourceRoot":"","sources":["../../../../src/components/ch-spinner/ch-spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAIzD;;;;;;;GAOG;AAMH,MAAM,OAAO,SAAS;IACpB;;;;OAIG;IACK,IAAI,GAAkB,IAAI,CAAC;IAEnC;;;;;OAKG;IACK,KAAK,CAAU;IAEvB,MAAM;QACJ,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAErC,OAAO,CACL,EAAC,IAAI;YACH,6DACE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,YAAY,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EACzD,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,gBACzB,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,iBAChC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,GACpC,CACH,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, h } from '@stencil/core';\n\nexport type ChSpinnerSize = 'sm' | 'md' | 'lg';\n\n/**\n * Loading indicator.\n *\n * The spinner is drawn in `currentColor`, so it takes the surrounding text\n * colour and stays legible on any surface — inside a primary `ch-button` it\n * picks up the button's own text colour instead of the accent, which would be\n * invisible there. Set `color` on or above the element to change it.\n */\n@Component({\n tag: 'ch-spinner',\n styleUrl: 'ch-spinner.css',\n shadow: true,\n})\nexport class ChSpinner {\n /**\n * The size of the spinner. Either `sm`, `md`, or `lg`. Each size sets a\n * font-size and the spinner is drawn in `em`, so it also scales with an\n * inherited font-size.\n */\n @Prop() size: ChSpinnerSize = 'md';\n\n /**\n * Accessible label announced while the spinner is visible, e.g. `Cargando\n * resultados`. When omitted the spinner is treated as decorative and hidden\n * from assistive technology — the right behaviour next to visible loading\n * text, which would otherwise be announced twice.\n */\n @Prop() label?: string;\n\n render() {\n const labelled = Boolean(this.label);\n\n return (\n <Host>\n <span\n class={{ spinner: true, [`spinner--${this.size}`]: true }}\n role={labelled ? 'status' : undefined}\n aria-label={labelled ? this.label : undefined}\n aria-hidden={labelled ? undefined : 'true'}\n ></span>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -60,7 +60,7 @@ export class ChSwitch {
|
|
|
60
60
|
return undefined;
|
|
61
61
|
}
|
|
62
62
|
render() {
|
|
63
|
-
return (h(Host, { key: '
|
|
63
|
+
return (h(Host, { key: 'f95f9b724e37771ea3949ff569881dc1eff370a1' }, h("label", { key: '878c3c47e380356a3b79e79fdd135df627ce37a6', class: { 'control': true, 'control--disabled': this.disabled }, htmlFor: this.switchId }, h("input", { key: '14ee6041b8aeb4115db1f7ca9c542314651f34ea', 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, 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: '0d58863f220b6e9f04babd6231a35dea039a41a2', class: "track" }, h("span", { key: '588617f6bb1c61168b860c4b2863892828fd5df5', class: "thumb" })), this.label && h("span", { key: '530e64cc85761e91a019431f977bb9d2d8e86e27', class: "label-text" }, this.label)), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '71ffd6b56a753673f9d5663054a217e250363ce1', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '63f9965c30d8cd2820554de31ac7edc364aee22b', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
64
64
|
}
|
|
65
65
|
static get is() { return "ch-switch"; }
|
|
66
66
|
static get encapsulation() { return "shadow"; }
|
|
@@ -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: '0467e7ea24884d4c19c33b736a07303569dfaa3b' }, h("div", { key: '8ad451816ef31809c82486f3c9dd36b6e89e77e5', 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}` }))))));
|
|
@@ -73,7 +73,7 @@ export class ChTextarea {
|
|
|
73
73
|
return undefined;
|
|
74
74
|
}
|
|
75
75
|
render() {
|
|
76
|
-
return (h(Host, { key: '
|
|
76
|
+
return (h(Host, { key: '1e5846687f73807b36da2328106aec84bdecb7cb' }, this.label && (h("label", { key: '9a8d410d07bb6b9cc9a5329088786de6365af507', class: "label", htmlFor: this.textareaId }, this.label)), h("textarea", { key: '7353cc267072e7df111d94ad0466588d0b7e77d8', 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, 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: '5b953e2c568b151c502404fccc4a79d6d6e516f9', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: 'bc500a5bd32ac35cf4de723b02cb42f459614c39', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
77
77
|
}
|
|
78
78
|
static get is() { return "ch-textarea"; }
|
|
79
79
|
static get encapsulation() { return "shadow"; }
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.anchor {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.bubble {
|
|
11
|
+
position: absolute;
|
|
12
|
+
z-index: var(--z-index-dropdown);
|
|
13
|
+
width: max-content;
|
|
14
|
+
max-width: 16rem;
|
|
15
|
+
padding: var(--spacing-md) var(--spacing-2xl);
|
|
16
|
+
border: var(--border-width) solid var(--border);
|
|
17
|
+
border-radius: var(--radius-sm);
|
|
18
|
+
background: var(--color-background-base);
|
|
19
|
+
color: var(--text);
|
|
20
|
+
font-family: var(--font-body);
|
|
21
|
+
font-size: var(--typography-size-sm);
|
|
22
|
+
line-height: 1.4;
|
|
23
|
+
opacity: 0;
|
|
24
|
+
visibility: hidden;
|
|
25
|
+
transition:
|
|
26
|
+
opacity var(--duration-fast) var(--easing-default),
|
|
27
|
+
visibility var(--duration-fast) var(--easing-default);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.bubble--visible {
|
|
31
|
+
opacity: 1;
|
|
32
|
+
visibility: visible;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.bubble::before {
|
|
36
|
+
content: '';
|
|
37
|
+
position: absolute;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.bubble--top {
|
|
41
|
+
bottom: 100%;
|
|
42
|
+
left: 50%;
|
|
43
|
+
transform: translateX(-50%);
|
|
44
|
+
margin-bottom: var(--spacing-md);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.bubble--top::before {
|
|
48
|
+
top: 100%;
|
|
49
|
+
left: 0;
|
|
50
|
+
right: 0;
|
|
51
|
+
height: var(--spacing-md);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.bubble--bottom {
|
|
55
|
+
top: 100%;
|
|
56
|
+
left: 50%;
|
|
57
|
+
transform: translateX(-50%);
|
|
58
|
+
margin-top: var(--spacing-md);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.bubble--bottom::before {
|
|
62
|
+
bottom: 100%;
|
|
63
|
+
left: 0;
|
|
64
|
+
right: 0;
|
|
65
|
+
height: var(--spacing-md);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.bubble--left {
|
|
69
|
+
right: 100%;
|
|
70
|
+
top: 50%;
|
|
71
|
+
transform: translateY(-50%);
|
|
72
|
+
margin-right: var(--spacing-md);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.bubble--left::before {
|
|
76
|
+
left: 100%;
|
|
77
|
+
top: 0;
|
|
78
|
+
bottom: 0;
|
|
79
|
+
width: var(--spacing-md);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.bubble--right {
|
|
83
|
+
left: 100%;
|
|
84
|
+
top: 50%;
|
|
85
|
+
transform: translateY(-50%);
|
|
86
|
+
margin-left: var(--spacing-md);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.bubble--right::before {
|
|
90
|
+
right: 100%;
|
|
91
|
+
top: 0;
|
|
92
|
+
bottom: 0;
|
|
93
|
+
width: var(--spacing-md);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@media (prefers-reduced-motion: reduce) {
|
|
97
|
+
.bubble {
|
|
98
|
+
transition: none;
|
|
99
|
+
}
|
|
100
|
+
}
|