@devschile/chucao 1.8.0 → 2.1.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 +3 -0
- package/dist/chucao/chucao.esm.js +1 -1
- package/dist/chucao/chucao.esm.js.map +1 -1
- package/dist/chucao/{p-e8fe65bb.entry.js → p-04dbcfa0.entry.js} +2 -2
- package/dist/chucao/p-11083711.entry.js +2 -0
- package/dist/chucao/p-11083711.entry.js.map +1 -0
- package/dist/chucao/{p-cfb6db53.entry.js → p-121fbfc8.entry.js} +2 -2
- package/dist/chucao/p-1b1e56cd.entry.js +2 -0
- package/dist/chucao/p-1b1e56cd.entry.js.map +1 -0
- package/dist/chucao/{p-df73f786.entry.js → p-2ab4a6a8.entry.js} +2 -2
- package/dist/chucao/p-4bc8e098.entry.js +2 -0
- package/dist/chucao/p-4bc8e098.entry.js.map +1 -0
- package/dist/chucao/p-5fe8bfff.entry.js +2 -0
- package/dist/chucao/p-5fe8bfff.entry.js.map +1 -0
- package/dist/chucao/p-9bb81a65.entry.js +2 -0
- package/dist/chucao/p-9bb81a65.entry.js.map +1 -0
- package/dist/chucao/p-DWC12BJ-.js +3 -0
- package/dist/chucao/p-DWC12BJ-.js.map +1 -0
- package/dist/chucao/{p-2d7e81b2.entry.js → p-a955eebf.entry.js} +2 -2
- package/dist/chucao/{p-cbb2b478.entry.js → p-d5a9e340.entry.js} +2 -2
- package/dist/chucao/{p-1cc7042e.entry.js → p-ff5f5c1f.entry.js} +2 -2
- package/dist/cjs/ch-accordion.cjs.entry.js +1 -1
- package/dist/cjs/ch-alert_8.cjs.entry.js +186 -9
- package/dist/cjs/ch-alert_8.cjs.entry.js.map +1 -1
- package/dist/cjs/ch-checkbox.cjs.entry.js +62 -3
- package/dist/cjs/ch-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/ch-divider.cjs.entry.js +1 -1
- package/dist/cjs/ch-emoji.cjs.entry.js +104 -0
- package/dist/cjs/ch-emoji.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-link.cjs.entry.js +1 -1
- package/dist/cjs/ch-modal.cjs.entry.js +2 -2
- package/dist/cjs/ch-radio.cjs.entry.js +62 -3
- package/dist/cjs/ch-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/ch-tabs.cjs.entry.js +2 -2
- package/dist/cjs/ch-textarea.cjs.entry.js +62 -3
- package/dist/cjs/ch-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/ch-tooltip.cjs.entry.js +2 -2
- package/dist/cjs/chucao.cjs.js +3 -3
- package/dist/cjs/chucao.cjs.js.map +1 -1
- package/dist/cjs/{index-DMeDkSQU.js → index-C9cpLteP.js} +71 -12
- package/dist/cjs/index-C9cpLteP.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/ch-card/ch-card.js +1 -1
- package/dist/collection/components/ch-checkbox/ch-checkbox.css +10 -0
- package/dist/collection/components/ch-checkbox/ch-checkbox.js +64 -4
- package/dist/collection/components/ch-checkbox/ch-checkbox.js.map +1 -1
- package/dist/collection/components/ch-emoji/ch-emoji.css +33 -0
- package/dist/collection/components/ch-emoji/ch-emoji.js +151 -0
- package/dist/collection/components/ch-emoji/ch-emoji.js.map +1 -0
- package/dist/collection/components/ch-input/ch-input.css +11 -0
- package/dist/collection/components/ch-input/ch-input.js +64 -4
- package/dist/collection/components/ch-input/ch-input.js.map +1 -1
- package/dist/collection/components/ch-modal/ch-modal.js +1 -1
- package/dist/collection/components/ch-radio/ch-radio.css +10 -0
- package/dist/collection/components/ch-radio/ch-radio.js +64 -4
- package/dist/collection/components/ch-radio/ch-radio.js.map +1 -1
- package/dist/collection/components/ch-select/ch-select.css +11 -0
- package/dist/collection/components/ch-select/ch-select.js +64 -4
- package/dist/collection/components/ch-select/ch-select.js.map +1 -1
- package/dist/collection/components/ch-spinner/ch-spinner.js +1 -1
- package/dist/collection/components/ch-switch/ch-switch.css +10 -0
- package/dist/collection/components/ch-switch/ch-switch.js +64 -4
- package/dist/collection/components/ch-switch/ch-switch.js.map +1 -1
- package/dist/collection/components/ch-tabs/ch-tabs.js +1 -1
- package/dist/collection/components/ch-textarea/ch-textarea.css +11 -0
- package/dist/collection/components/ch-textarea/ch-textarea.js +64 -4
- package/dist/collection/components/ch-textarea/ch-textarea.js.map +1 -1
- package/dist/collection/components/ch-tooltip/ch-tooltip.js +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-checkbox.js +1 -1
- package/dist/components/ch-checkbox.js.map +1 -1
- package/dist/components/ch-divider.js +1 -1
- package/dist/components/ch-emoji.d.ts +11 -0
- package/dist/components/ch-emoji.js +2 -0
- package/dist/components/ch-emoji.js.map +1 -0
- package/dist/components/ch-input.js +1 -1
- package/dist/components/ch-input.js.map +1 -1
- package/dist/components/ch-link.js +1 -1
- package/dist/components/ch-modal.js +1 -1
- package/dist/components/ch-radio.js +1 -1
- package/dist/components/ch-radio.js.map +1 -1
- package/dist/components/ch-select.js +1 -1
- package/dist/components/ch-select.js.map +1 -1
- package/dist/components/ch-spinner.js +1 -1
- package/dist/components/ch-switch.js +1 -1
- package/dist/components/ch-switch.js.map +1 -1
- package/dist/components/ch-tabs.js +1 -1
- package/dist/components/ch-textarea.js +1 -1
- package/dist/components/ch-textarea.js.map +1 -1
- package/dist/components/ch-tooltip.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/p-BhAZrOxf.js +2 -0
- package/dist/components/p-BhAZrOxf.js.map +1 -0
- package/dist/esm/ch-accordion.entry.js +1 -1
- package/dist/esm/ch-alert_8.entry.js +186 -9
- package/dist/esm/ch-alert_8.entry.js.map +1 -1
- package/dist/esm/ch-checkbox.entry.js +62 -3
- package/dist/esm/ch-checkbox.entry.js.map +1 -1
- package/dist/esm/ch-divider.entry.js +1 -1
- package/dist/esm/ch-emoji.entry.js +102 -0
- package/dist/esm/ch-emoji.entry.js.map +1 -0
- package/dist/esm/ch-link.entry.js +1 -1
- package/dist/esm/ch-modal.entry.js +2 -2
- package/dist/esm/ch-radio.entry.js +62 -3
- package/dist/esm/ch-radio.entry.js.map +1 -1
- package/dist/esm/ch-tabs.entry.js +2 -2
- package/dist/esm/ch-textarea.entry.js +62 -3
- package/dist/esm/ch-textarea.entry.js.map +1 -1
- package/dist/esm/ch-tooltip.entry.js +2 -2
- package/dist/esm/chucao.js +4 -4
- package/dist/esm/chucao.js.map +1 -1
- package/dist/esm/{index-Bvah_WQV.js → index-DWC12BJ-.js} +71 -12
- package/dist/esm/index-DWC12BJ-.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/ch-checkbox/ch-checkbox.d.ts +9 -0
- package/dist/types/components/ch-emoji/ch-emoji.d.ts +32 -0
- package/dist/types/components/ch-input/ch-input.d.ts +9 -0
- package/dist/types/components/ch-radio/ch-radio.d.ts +9 -0
- package/dist/types/components/ch-select/ch-select.d.ts +9 -0
- package/dist/types/components/ch-switch/ch-switch.d.ts +9 -0
- package/dist/types/components/ch-textarea/ch-textarea.d.ts +9 -0
- package/dist/types/components.d.ts +96 -0
- package/dist/types/stencil-public-runtime.d.ts +1 -0
- package/dist-react/components.d.ts +3 -0
- package/dist-react/components.js +9 -0
- package/dist-react/components.ts +12 -0
- package/dist-vue/index.d.ts +1 -0
- package/dist-vue/index.js +6 -0
- package/dist-vue/index.ts +8 -0
- package/hydrate/index.js +555 -63
- package/hydrate/index.mjs +555 -63
- package/loader/index.d.ts +1 -1
- package/package.json +5 -1
- package/dist/chucao/p-13ab5f9a.entry.js +0 -2
- package/dist/chucao/p-13ab5f9a.entry.js.map +0 -1
- package/dist/chucao/p-23c5220b.entry.js +0 -2
- package/dist/chucao/p-23c5220b.entry.js.map +0 -1
- package/dist/chucao/p-421cda05.entry.js +0 -2
- package/dist/chucao/p-421cda05.entry.js.map +0 -1
- package/dist/chucao/p-Bvah_WQV.js +0 -3
- package/dist/chucao/p-Bvah_WQV.js.map +0 -1
- package/dist/chucao/p-c16b18b7.entry.js +0 -2
- package/dist/chucao/p-c16b18b7.entry.js.map +0 -1
- package/dist/cjs/index-DMeDkSQU.js.map +0 -1
- package/dist/components/p-hyy-cLgi.js +0 -2
- package/dist/components/p-hyy-cLgi.js.map +0 -1
- package/dist/esm/index-Bvah_WQV.js.map +0 -1
- /package/dist/chucao/{p-e8fe65bb.entry.js.map → p-04dbcfa0.entry.js.map} +0 -0
- /package/dist/chucao/{p-cfb6db53.entry.js.map → p-121fbfc8.entry.js.map} +0 -0
- /package/dist/chucao/{p-df73f786.entry.js.map → p-2ab4a6a8.entry.js.map} +0 -0
- /package/dist/chucao/{p-2d7e81b2.entry.js.map → p-a955eebf.entry.js.map} +0 -0
- /package/dist/chucao/{p-cbb2b478.entry.js.map → p-d5a9e340.entry.js.map} +0 -0
- /package/dist/chucao/{p-1cc7042e.entry.js.map → p-ff5f5c1f.entry.js.map} +0 -0
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-C9cpLteP.js');
|
|
4
4
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await index.globalScripts();
|
|
8
|
-
return index.bootstrapLazy([["ch-alert_8.cjs",[[769,"ch-alert",{"variant":[1],"dismissLabel":[1,"dismiss-label"]}],[769,"ch-badge",{"variant":[1]}],[769,"ch-button",{"variant":[1],"disabled":[4],"label":[1]}],[257,"ch-card"],[
|
|
8
|
+
return index.bootstrapLazy([["ch-alert_8.cjs",[[769,"ch-alert",{"variant":[1],"dismissLabel":[1,"dismiss-label"]}],[769,"ch-badge",{"variant":[1]}],[769,"ch-button",{"variant":[1],"disabled":[4],"label":[1]}],[257,"ch-card"],[577,"ch-input",{"label":[1],"type":[1],"value":[1025],"placeholder":[1],"name":[513],"disabled":[516],"required":[516],"hint":[1],"errorMessage":[1,"error-message"],"invalid":[4],"formDisabled":[32]},null,{"value":[{"syncForm":0}],"required":[{"syncForm":0}],"invalid":[{"syncForm":0}],"errorMessage":[{"syncForm":0}]}],[577,"ch-select",{"label":[1],"options":[16],"value":[1025],"placeholder":[1],"name":[513],"disabled":[516],"required":[516],"hint":[1],"errorMessage":[1,"error-message"],"invalid":[4],"formDisabled":[32]},null,{"value":[{"syncForm":0}],"required":[{"syncForm":0}],"invalid":[{"syncForm":0}],"errorMessage":[{"syncForm":0}]}],[513,"ch-spinner",{"size":[1],"label":[1]}],[577,"ch-switch",{"label":[1],"name":[513],"value":[1],"checked":[1028],"disabled":[516],"required":[516],"hint":[1],"errorMessage":[1,"error-message"],"invalid":[4],"formDisabled":[32]},null,{"checked":[{"syncForm":0}],"required":[{"syncForm":0}],"invalid":[{"syncForm":0}],"errorMessage":[{"syncForm":0}]}]]],["ch-accordion.cjs",[[769,"ch-accordion",{"items":[16],"value":[1025]}]]],["ch-checkbox.cjs",[[577,"ch-checkbox",{"label":[1],"name":[513],"value":[1],"checked":[1028],"disabled":[516],"required":[516],"hint":[1],"errorMessage":[1,"error-message"],"invalid":[4],"formDisabled":[32]},null,{"checked":[{"syncForm":0}],"required":[{"syncForm":0}],"invalid":[{"syncForm":0}],"errorMessage":[{"syncForm":0}]}]]],["ch-divider.cjs",[[513,"ch-divider",{"orientation":[1]}]]],["ch-emoji.cjs",[[513,"ch-emoji",{"name":[1],"alt":[1],"size":[1],"extIndex":[32],"loaded":[32]},null,{"name":[{"handleNameChange":0}]}]]],["ch-link.cjs",[[769,"ch-link",{"href":[1],"target":[1],"variant":[1],"disabled":[4]}]]],["ch-modal.cjs",[[769,"ch-modal",{"open":[1028],"label":[1],"closeLabel":[1,"close-label"]},null,{"open":[{"handleOpenChange":0}]}]]],["ch-radio.cjs",[[577,"ch-radio",{"label":[1],"options":[16],"value":[1025],"name":[513],"disabled":[516],"required":[516],"hint":[1],"errorMessage":[1,"error-message"],"invalid":[4],"formDisabled":[32]},null,{"value":[{"syncForm":0}],"required":[{"syncForm":0}],"invalid":[{"syncForm":0}],"errorMessage":[{"syncForm":0}]}]]],["ch-tabs.cjs",[[769,"ch-tabs",{"tabs":[16],"value":[1025],"label":[1]}]]],["ch-textarea.cjs",[[577,"ch-textarea",{"label":[1],"value":[1025],"placeholder":[1],"rows":[2],"name":[513],"disabled":[516],"required":[516],"hint":[1],"errorMessage":[1,"error-message"],"invalid":[4],"formDisabled":[32]},null,{"value":[{"syncForm":0}],"required":[{"syncForm":0}],"invalid":[{"syncForm":0}],"errorMessage":[{"syncForm":0}]}]]],["ch-tooltip.cjs",[[769,"ch-tooltip",{"placement":[1],"hovered":[32],"focused":[32],"dismissed":[32]},[[1,"mouseenter","handleMouseEnter"],[1,"mouseleave","handleMouseLeave"],[0,"focusin","handleFocusIn"],[0,"focusout","handleFocusOut"],[4,"keydown","handleKeyDown"]]]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
exports.setNonce = index.setNonce;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"components/ch-badge/ch-badge.js",
|
|
6
6
|
"components/ch-button/ch-button.js",
|
|
7
7
|
"components/ch-divider/ch-divider.js",
|
|
8
|
+
"components/ch-emoji/ch-emoji.js",
|
|
8
9
|
"components/ch-link/ch-link.js",
|
|
9
10
|
"components/ch-radio/ch-radio.js",
|
|
10
11
|
"components/ch-select/ch-select.js",
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"mixins": [],
|
|
22
23
|
"compiler": {
|
|
23
24
|
"name": "@stencil/core",
|
|
24
|
-
"version": "4.44.
|
|
25
|
+
"version": "4.44.2",
|
|
25
26
|
"typescriptVersion": "5.8.3"
|
|
26
27
|
},
|
|
27
28
|
"collections": [],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
export class ChCard {
|
|
3
3
|
render() {
|
|
4
|
-
return (h(Host, { key: '
|
|
4
|
+
return (h(Host, { key: 'de570a460eff697eb242ef56fcedd5b400d6b03f' }, h("div", { key: '3350619356a929c5d922948d52d6635420dc8547', class: "card" }, h("slot", { key: 'b50679202b5fea142702de0babf62587186d4dc8' }))));
|
|
5
5
|
}
|
|
6
6
|
static get is() { return "ch-card"; }
|
|
7
7
|
static get encapsulation() { return "shadow"; }
|
|
@@ -63,6 +63,16 @@
|
|
|
63
63
|
outline-color: var(--color-status-warning);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
:host([data-touched]:invalid) .input,
|
|
67
|
+
:host(:user-invalid) .input {
|
|
68
|
+
border-color: var(--color-status-warning);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([data-touched]:invalid) .input:focus-visible,
|
|
72
|
+
:host(:user-invalid) .input:focus-visible {
|
|
73
|
+
outline-color: var(--color-status-warning);
|
|
74
|
+
}
|
|
75
|
+
|
|
66
76
|
.label-text {
|
|
67
77
|
color: var(--text);
|
|
68
78
|
}
|
|
@@ -4,6 +4,10 @@ export class ChCheckbox {
|
|
|
4
4
|
checkboxId = `ch-checkbox-${++checkboxIds}`;
|
|
5
5
|
hintId = `${this.checkboxId}-hint`;
|
|
6
6
|
errorId = `${this.checkboxId}-error`;
|
|
7
|
+
initialChecked = false;
|
|
8
|
+
internals;
|
|
9
|
+
formDisabled = false;
|
|
10
|
+
host;
|
|
7
11
|
/**
|
|
8
12
|
* Visible label rendered next to the checkbox, associated with it via
|
|
9
13
|
* `for`/`id`, so assistive technology announces the checkbox's purpose.
|
|
@@ -50,6 +54,39 @@ export class ChCheckbox {
|
|
|
50
54
|
this.checked = ev.target.checked;
|
|
51
55
|
this.chChange.emit(this.checked);
|
|
52
56
|
};
|
|
57
|
+
syncForm() {
|
|
58
|
+
const internals = this.internals;
|
|
59
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
internals.setFormValue(this.checked ? this.value : null);
|
|
63
|
+
const flags = {};
|
|
64
|
+
let message;
|
|
65
|
+
if (this.required && !this.checked) {
|
|
66
|
+
flags.valueMissing = true;
|
|
67
|
+
}
|
|
68
|
+
if (this.invalid && this.errorMessage) {
|
|
69
|
+
flags.customError = true;
|
|
70
|
+
}
|
|
71
|
+
message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);
|
|
72
|
+
internals.setValidity(flags, message);
|
|
73
|
+
}
|
|
74
|
+
componentDidLoad() {
|
|
75
|
+
this.initialChecked = this.checked;
|
|
76
|
+
this.syncForm();
|
|
77
|
+
this.host.addEventListener('change', this.markTouched);
|
|
78
|
+
this.host.addEventListener('focusout', this.markTouched);
|
|
79
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
80
|
+
}
|
|
81
|
+
markTouched = () => {
|
|
82
|
+
this.host.setAttribute('data-touched', '');
|
|
83
|
+
};
|
|
84
|
+
formResetCallback() {
|
|
85
|
+
this.checked = this.initialChecked;
|
|
86
|
+
}
|
|
87
|
+
formDisabledCallback(isDisabled) {
|
|
88
|
+
this.formDisabled = isDisabled;
|
|
89
|
+
}
|
|
53
90
|
get describedBy() {
|
|
54
91
|
if (this.invalid && this.errorMessage) {
|
|
55
92
|
return this.errorId;
|
|
@@ -60,10 +97,11 @@ export class ChCheckbox {
|
|
|
60
97
|
return undefined;
|
|
61
98
|
}
|
|
62
99
|
render() {
|
|
63
|
-
return (h(Host, { key: '
|
|
100
|
+
return (h(Host, { key: 'ad83b999d4dbafbd7b6f2369bae8fbce8e068cad' }, h("label", { key: 'e5927ad9d76db7cd9418debe8e635767b597e27a', class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled }, htmlFor: this.checkboxId }, h("input", { key: '93c49822bf5a470d67a7077354adcd9144643843', id: this.checkboxId, class: { 'input': true, 'input--invalid': this.invalid }, type: "checkbox", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled || this.formDisabled, required: this.required, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), this.label && h("span", { key: 'da90747e3339879a744569c98befed94507bebdd', class: "label-text" }, this.label)), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '3c10c9e29a943bc12983d4ef6b9fa00d95293c80', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '76e4a8debadd36dae475bd2439410c0f2a82cb62', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
64
101
|
}
|
|
65
102
|
static get is() { return "ch-checkbox"; }
|
|
66
103
|
static get encapsulation() { return "shadow"; }
|
|
104
|
+
static get formAssociated() { return true; }
|
|
67
105
|
static get originalStyleUrls() {
|
|
68
106
|
return {
|
|
69
107
|
"$": ["ch-checkbox.css"]
|
|
@@ -111,7 +149,7 @@ export class ChCheckbox {
|
|
|
111
149
|
},
|
|
112
150
|
"getter": false,
|
|
113
151
|
"setter": false,
|
|
114
|
-
"reflect":
|
|
152
|
+
"reflect": true,
|
|
115
153
|
"attribute": "name"
|
|
116
154
|
},
|
|
117
155
|
"value": {
|
|
@@ -170,7 +208,7 @@ export class ChCheckbox {
|
|
|
170
208
|
},
|
|
171
209
|
"getter": false,
|
|
172
210
|
"setter": false,
|
|
173
|
-
"reflect":
|
|
211
|
+
"reflect": true,
|
|
174
212
|
"attribute": "disabled",
|
|
175
213
|
"defaultValue": "false"
|
|
176
214
|
},
|
|
@@ -190,7 +228,7 @@ export class ChCheckbox {
|
|
|
190
228
|
},
|
|
191
229
|
"getter": false,
|
|
192
230
|
"setter": false,
|
|
193
|
-
"reflect":
|
|
231
|
+
"reflect": true,
|
|
194
232
|
"attribute": "required",
|
|
195
233
|
"defaultValue": "false"
|
|
196
234
|
},
|
|
@@ -254,6 +292,11 @@ export class ChCheckbox {
|
|
|
254
292
|
}
|
|
255
293
|
};
|
|
256
294
|
}
|
|
295
|
+
static get states() {
|
|
296
|
+
return {
|
|
297
|
+
"formDisabled": {}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
257
300
|
static get events() {
|
|
258
301
|
return [{
|
|
259
302
|
"method": "chChange",
|
|
@@ -272,5 +315,22 @@ export class ChCheckbox {
|
|
|
272
315
|
}
|
|
273
316
|
}];
|
|
274
317
|
}
|
|
318
|
+
static get elementRef() { return "host"; }
|
|
319
|
+
static get watchers() {
|
|
320
|
+
return [{
|
|
321
|
+
"propName": "checked",
|
|
322
|
+
"methodName": "syncForm"
|
|
323
|
+
}, {
|
|
324
|
+
"propName": "required",
|
|
325
|
+
"methodName": "syncForm"
|
|
326
|
+
}, {
|
|
327
|
+
"propName": "invalid",
|
|
328
|
+
"methodName": "syncForm"
|
|
329
|
+
}, {
|
|
330
|
+
"propName": "errorMessage",
|
|
331
|
+
"methodName": "syncForm"
|
|
332
|
+
}];
|
|
333
|
+
}
|
|
334
|
+
static get attachInternalsMemberName() { return "internals"; }
|
|
275
335
|
}
|
|
276
336
|
//# sourceMappingURL=ch-checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ch-checkbox.js","sourceRoot":"","sources":["../../../../src/components/ch-checkbox/ch-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAqB,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ch-checkbox.js","sourceRoot":"","sources":["../../../../src/components/ch-checkbox/ch-checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAqB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE3H,IAAI,WAAW,GAAG,CAAC,CAAC;AAQpB,MAAM,OAAO,UAAU;IACJ,UAAU,GAAG,eAAe,EAAE,WAAW,EAAE,CAAC;IAC5C,MAAM,GAAG,GAAG,IAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { AttachInternals, Component, Element, Event, type EventEmitter, Host, Prop, State, Watch, h } from '@stencil/core';\n\nlet checkboxIds = 0;\n\n@Component({\n tag: 'ch-checkbox',\n styleUrl: 'ch-checkbox.css',\n shadow: true,\n formAssociated: true,\n})\nexport class ChCheckbox {\n private readonly checkboxId = `ch-checkbox-${++checkboxIds}`;\n private readonly hintId = `${this.checkboxId}-hint`;\n private readonly errorId = `${this.checkboxId}-error`;\n private initialChecked = false;\n\n @AttachInternals() internals!: ElementInternals;\n @State() formDisabled = false;\n @Element() private host!: HTMLElement;\n\n /**\n * Visible label rendered next to the checkbox, associated with it via\n * `for`/`id`, so assistive technology announces the checkbox's purpose.\n */\n @Prop() label?: string;\n\n /**\n * The name of the checkbox, submitted with form data.\n */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * The value of the checkbox, submitted with form data.\n */\n @Prop() value = 'on';\n\n /**\n * Whether the checkbox is checked.\n */\n @Prop({ mutable: true }) checked = false;\n\n /**\n * Whether the checkbox is disabled.\n */\n @Prop({ reflect: true }) disabled = false;\n\n /**\n * Whether the checkbox is required.\n */\n @Prop({ reflect: true }) required = false;\n\n /**\n * Helper text rendered below the checkbox, associated via `aria-describedby`.\n * Replaced by `errorMessage` when the checkbox is invalid.\n */\n @Prop() hint?: string;\n\n /**\n * Error message rendered below the checkbox when it is invalid.\n */\n @Prop() errorMessage?: string;\n\n /**\n * Whether the checkbox is in an invalid state; toggles `aria-invalid` and error styling.\n */\n @Prop() invalid = false;\n\n /**\n * Emitted when the checked state changes, with the new checked value.\n */\n @Event() chChange: EventEmitter<boolean>;\n\n private handleChange = (ev: Event) => {\n this.checked = (ev.target as HTMLInputElement).checked;\n this.chChange.emit(this.checked);\n };\n\n @Watch('checked')\n @Watch('required')\n @Watch('invalid')\n @Watch('errorMessage')\n protected syncForm(): void {\n const internals = this.internals;\n if (typeof internals?.setFormValue !== 'function') {\n return;\n }\n internals.setFormValue(this.checked ? this.value : null);\n const flags: ValidityStateFlags = {};\n let message: string | undefined;\n if (this.required && !this.checked) {\n flags.valueMissing = true;\n }\n if (this.invalid && this.errorMessage) {\n flags.customError = true;\n }\n message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);\n internals.setValidity(flags, message);\n }\n\n componentDidLoad() {\n this.initialChecked = this.checked;\n this.syncForm();\n this.host.addEventListener('change', this.markTouched);\n this.host.addEventListener('focusout', this.markTouched);\n this.host.addEventListener('invalid', this.markTouched);\n }\n\n private markTouched = (): void => {\n this.host.setAttribute('data-touched', '');\n };\n\n formResetCallback(): void {\n this.checked = this.initialChecked;\n }\n\n formDisabledCallback(isDisabled: boolean): void {\n this.formDisabled = isDisabled;\n }\n\n private get describedBy(): string | undefined {\n if (this.invalid && this.errorMessage) {\n return this.errorId;\n }\n if (this.hint) {\n return this.hintId;\n }\n return undefined;\n }\n\n render() {\n return (\n <Host>\n <label class={{ 'control': true, 'control--disabled': this.disabled || this.formDisabled }} htmlFor={this.checkboxId}>\n <input\n id={this.checkboxId}\n class={{ 'input': true, 'input--invalid': this.invalid }}\n type=\"checkbox\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n disabled={this.disabled || this.formDisabled}\n required={this.required}\n aria-invalid={this.invalid ? 'true' : undefined}\n aria-describedby={this.describedBy}\n onChange={this.handleChange}\n />\n {this.label && <span class=\"label-text\">{this.label}</span>}\n </label>\n {this.hint && !(this.invalid && this.errorMessage) && (\n <p class=\"hint\" id={this.hintId}>\n {this.hint}\n </p>\n )}\n {this.invalid && this.errorMessage && (\n <p class=\"error\" id={this.errorId} role=\"alert\">\n {this.errorMessage}\n </p>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
vertical-align: middle;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.emoji {
|
|
7
|
+
display: block;
|
|
8
|
+
object-fit: contain;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.emoji--sm {
|
|
12
|
+
width: 16px;
|
|
13
|
+
height: 16px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.emoji--md {
|
|
17
|
+
width: 24px;
|
|
18
|
+
height: 24px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.emoji--lg {
|
|
22
|
+
width: 32px;
|
|
23
|
+
height: 32px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.emoji--xl {
|
|
27
|
+
width: 48px;
|
|
28
|
+
height: 48px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.emoji--hidden {
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import emojiMap from "./emoji-map.json";
|
|
3
|
+
const CDN_BASE = 'https://static.devschile.cl/emoji';
|
|
4
|
+
const EXTENSIONS = ['png', 'gif', 'jpg', 'svg'];
|
|
5
|
+
/**
|
|
6
|
+
* Inline emoji from the devsChile CDN.
|
|
7
|
+
*
|
|
8
|
+
* Given a name (or alias from the emoji map), the component resolves the
|
|
9
|
+
* asset URL and tries each possible file extension until one loads.
|
|
10
|
+
* Size is controlled via the `size` prop.
|
|
11
|
+
*/
|
|
12
|
+
export class ChEmoji {
|
|
13
|
+
extIndex = 0;
|
|
14
|
+
loaded = false;
|
|
15
|
+
/**
|
|
16
|
+
* The emoji name or alias, e.g. `"huemul-love"` or `"heart"`.
|
|
17
|
+
*/
|
|
18
|
+
name;
|
|
19
|
+
/**
|
|
20
|
+
* Accessible alt text for the image. Defaults to the `name` prop.
|
|
21
|
+
*/
|
|
22
|
+
alt;
|
|
23
|
+
/**
|
|
24
|
+
* Size of the emoji. Either `sm`, `md`, `lg`, or `xl`.
|
|
25
|
+
*/
|
|
26
|
+
size = 'md';
|
|
27
|
+
componentWillLoad() {
|
|
28
|
+
this.resolveAsset();
|
|
29
|
+
}
|
|
30
|
+
handleNameChange() {
|
|
31
|
+
this.resolveAsset();
|
|
32
|
+
}
|
|
33
|
+
resolveAsset() {
|
|
34
|
+
this.extIndex = 0;
|
|
35
|
+
this.loaded = false;
|
|
36
|
+
}
|
|
37
|
+
get assetName() {
|
|
38
|
+
return emojiMap[this.name] ?? this.name;
|
|
39
|
+
}
|
|
40
|
+
get currentSrc() {
|
|
41
|
+
return `${CDN_BASE}/${this.assetName}.${EXTENSIONS[this.extIndex]}`;
|
|
42
|
+
}
|
|
43
|
+
handleError = () => {
|
|
44
|
+
if (this.extIndex < EXTENSIONS.length - 1) {
|
|
45
|
+
this.extIndex++;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
handleLoad = () => {
|
|
49
|
+
this.loaded = true;
|
|
50
|
+
};
|
|
51
|
+
render() {
|
|
52
|
+
return (h(Host, { key: 'bfc646f047dae03aa8079825012305d7beb1fa6d' }, h("img", { key: 'c397cc1f928c6871df10adc1f43874738e1cbf33', class: {
|
|
53
|
+
'emoji': true,
|
|
54
|
+
[`emoji--${this.size}`]: true,
|
|
55
|
+
'emoji--hidden': !this.loaded,
|
|
56
|
+
}, src: this.currentSrc, alt: this.alt ?? this.name, onError: this.handleError, onLoad: this.handleLoad })));
|
|
57
|
+
}
|
|
58
|
+
static get is() { return "ch-emoji"; }
|
|
59
|
+
static get encapsulation() { return "shadow"; }
|
|
60
|
+
static get originalStyleUrls() {
|
|
61
|
+
return {
|
|
62
|
+
"$": ["ch-emoji.css"]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
static get styleUrls() {
|
|
66
|
+
return {
|
|
67
|
+
"$": ["ch-emoji.css"]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
static get properties() {
|
|
71
|
+
return {
|
|
72
|
+
"name": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"mutable": false,
|
|
75
|
+
"complexType": {
|
|
76
|
+
"original": "string",
|
|
77
|
+
"resolved": "string",
|
|
78
|
+
"references": {}
|
|
79
|
+
},
|
|
80
|
+
"required": true,
|
|
81
|
+
"optional": false,
|
|
82
|
+
"docs": {
|
|
83
|
+
"tags": [],
|
|
84
|
+
"text": "The emoji name or alias, e.g. `\"huemul-love\"` or `\"heart\"`."
|
|
85
|
+
},
|
|
86
|
+
"getter": false,
|
|
87
|
+
"setter": false,
|
|
88
|
+
"reflect": false,
|
|
89
|
+
"attribute": "name"
|
|
90
|
+
},
|
|
91
|
+
"alt": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"mutable": false,
|
|
94
|
+
"complexType": {
|
|
95
|
+
"original": "string",
|
|
96
|
+
"resolved": "string",
|
|
97
|
+
"references": {}
|
|
98
|
+
},
|
|
99
|
+
"required": false,
|
|
100
|
+
"optional": true,
|
|
101
|
+
"docs": {
|
|
102
|
+
"tags": [],
|
|
103
|
+
"text": "Accessible alt text for the image. Defaults to the `name` prop."
|
|
104
|
+
},
|
|
105
|
+
"getter": false,
|
|
106
|
+
"setter": false,
|
|
107
|
+
"reflect": false,
|
|
108
|
+
"attribute": "alt"
|
|
109
|
+
},
|
|
110
|
+
"size": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"mutable": false,
|
|
113
|
+
"complexType": {
|
|
114
|
+
"original": "ChEmojiSize",
|
|
115
|
+
"resolved": "\"lg\" | \"md\" | \"sm\" | \"xl\"",
|
|
116
|
+
"references": {
|
|
117
|
+
"ChEmojiSize": {
|
|
118
|
+
"location": "local",
|
|
119
|
+
"path": "/home/runner/work/chucao/chucao/src/components/ch-emoji/ch-emoji.tsx",
|
|
120
|
+
"id": "src/components/ch-emoji/ch-emoji.tsx::ChEmojiSize"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"required": false,
|
|
125
|
+
"optional": false,
|
|
126
|
+
"docs": {
|
|
127
|
+
"tags": [],
|
|
128
|
+
"text": "Size of the emoji. Either `sm`, `md`, `lg`, or `xl`."
|
|
129
|
+
},
|
|
130
|
+
"getter": false,
|
|
131
|
+
"setter": false,
|
|
132
|
+
"reflect": false,
|
|
133
|
+
"attribute": "size",
|
|
134
|
+
"defaultValue": "'md'"
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
static get states() {
|
|
139
|
+
return {
|
|
140
|
+
"extIndex": {},
|
|
141
|
+
"loaded": {}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
static get watchers() {
|
|
145
|
+
return [{
|
|
146
|
+
"propName": "name",
|
|
147
|
+
"methodName": "handleNameChange"
|
|
148
|
+
}];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=ch-emoji.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ch-emoji.js","sourceRoot":"","sources":["../../../../src/components/ch-emoji/ch-emoji.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAIxC,MAAM,QAAQ,GAAG,mCAAmC,CAAC;AACrD,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEhD;;;;;;GAMG;AAMH,MAAM,OAAO,OAAO;IACD,QAAQ,GAAG,CAAC,CAAC;IACb,MAAM,GAAG,KAAK,CAAC;IAEhC;;OAEG;IACK,IAAI,CAAU;IAEtB;;OAEG;IACK,GAAG,CAAU;IAErB;;OAEG;IACK,IAAI,GAAgB,IAAI,CAAC;IAEjC,iBAA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;;;CACF","sourcesContent":["import { Component, Host, Prop, State, Watch, h } from '@stencil/core';\n\nimport emojiMap from './emoji-map.json';\n\nexport type ChEmojiSize = 'sm' | 'md' | 'lg' | 'xl';\n\nconst CDN_BASE = 'https://static.devschile.cl/emoji';\nconst EXTENSIONS = ['png', 'gif', 'jpg', 'svg'];\n\n/**\n * Inline emoji from the devsChile CDN.\n *\n * Given a name (or alias from the emoji map), the component resolves the\n * asset URL and tries each possible file extension until one loads.\n * Size is controlled via the `size` prop.\n */\n@Component({\n tag: 'ch-emoji',\n styleUrl: 'ch-emoji.css',\n shadow: true,\n})\nexport class ChEmoji {\n @State() private extIndex = 0;\n @State() private loaded = false;\n\n /**\n * The emoji name or alias, e.g. `\"huemul-love\"` or `\"heart\"`.\n */\n @Prop() name!: string;\n\n /**\n * Accessible alt text for the image. Defaults to the `name` prop.\n */\n @Prop() alt?: string;\n\n /**\n * Size of the emoji. Either `sm`, `md`, `lg`, or `xl`.\n */\n @Prop() size: ChEmojiSize = 'md';\n\n componentWillLoad(): void {\n this.resolveAsset();\n }\n\n @Watch('name')\n handleNameChange(): void {\n this.resolveAsset();\n }\n\n private resolveAsset(): void {\n this.extIndex = 0;\n this.loaded = false;\n }\n\n private get assetName(): string {\n return (emojiMap as Record<string, string>)[this.name] ?? this.name;\n }\n\n private get currentSrc(): string {\n return `${CDN_BASE}/${this.assetName}.${EXTENSIONS[this.extIndex]}`;\n }\n\n private handleError = (): void => {\n if (this.extIndex < EXTENSIONS.length - 1) {\n this.extIndex++;\n }\n };\n\n private handleLoad = (): void => {\n this.loaded = true;\n };\n\n render() {\n return (\n <Host>\n <img\n class={{\n 'emoji': true,\n [`emoji--${this.size}`]: true,\n 'emoji--hidden': !this.loaded,\n }}\n src={this.currentSrc}\n alt={this.alt ?? this.name}\n onError={this.handleError}\n onLoad={this.handleLoad}\n />\n </Host>\n );\n }\n}\n"]}
|
|
@@ -46,6 +46,17 @@
|
|
|
46
46
|
box-shadow: 0 0 0 3px var(--color-status-warning-background);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
:host([data-touched]:invalid) .input,
|
|
50
|
+
:host(:user-invalid) .input {
|
|
51
|
+
border-color: var(--color-status-warning);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:host([data-touched]:invalid) .input:focus,
|
|
55
|
+
:host(:user-invalid) .input:focus {
|
|
56
|
+
border-color: var(--color-status-warning);
|
|
57
|
+
box-shadow: 0 0 0 3px var(--color-status-warning-background);
|
|
58
|
+
}
|
|
59
|
+
|
|
49
60
|
.input:disabled {
|
|
50
61
|
opacity: var(--opacity-disabled);
|
|
51
62
|
cursor: not-allowed;
|
|
@@ -4,6 +4,10 @@ export class ChInput {
|
|
|
4
4
|
inputId = `ch-input-${++inputIds}`;
|
|
5
5
|
hintId = `${this.inputId}-hint`;
|
|
6
6
|
errorId = `${this.inputId}-error`;
|
|
7
|
+
initialValue = '';
|
|
8
|
+
internals;
|
|
9
|
+
formDisabled = false;
|
|
10
|
+
host;
|
|
7
11
|
/**
|
|
8
12
|
* Visible label rendered above the input and associated with it via
|
|
9
13
|
* `for`/`id`, so assistive technology announces the input's purpose.
|
|
@@ -62,6 +66,39 @@ export class ChInput {
|
|
|
62
66
|
this.value = ev.target.value;
|
|
63
67
|
this.chChange.emit(this.value);
|
|
64
68
|
};
|
|
69
|
+
syncForm() {
|
|
70
|
+
const internals = this.internals;
|
|
71
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
internals.setFormValue(this.value);
|
|
75
|
+
const flags = {};
|
|
76
|
+
let message;
|
|
77
|
+
if (this.required && this.value === '') {
|
|
78
|
+
flags.valueMissing = true;
|
|
79
|
+
}
|
|
80
|
+
if (this.invalid && this.errorMessage) {
|
|
81
|
+
flags.customError = true;
|
|
82
|
+
}
|
|
83
|
+
message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);
|
|
84
|
+
internals.setValidity(flags, message);
|
|
85
|
+
}
|
|
86
|
+
componentDidLoad() {
|
|
87
|
+
this.initialValue = this.value;
|
|
88
|
+
this.syncForm();
|
|
89
|
+
this.host.addEventListener('change', this.markTouched);
|
|
90
|
+
this.host.addEventListener('focusout', this.markTouched);
|
|
91
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
92
|
+
}
|
|
93
|
+
markTouched = () => {
|
|
94
|
+
this.host.setAttribute('data-touched', '');
|
|
95
|
+
};
|
|
96
|
+
formResetCallback() {
|
|
97
|
+
this.value = this.initialValue;
|
|
98
|
+
}
|
|
99
|
+
formDisabledCallback(isDisabled) {
|
|
100
|
+
this.formDisabled = isDisabled;
|
|
101
|
+
}
|
|
65
102
|
get describedBy() {
|
|
66
103
|
if (this.invalid && this.errorMessage) {
|
|
67
104
|
return this.errorId;
|
|
@@ -72,10 +109,11 @@ export class ChInput {
|
|
|
72
109
|
return undefined;
|
|
73
110
|
}
|
|
74
111
|
render() {
|
|
75
|
-
return (h(Host, { key: '
|
|
112
|
+
return (h(Host, { key: '8a4b7cf5b80097afb849e2de9620fdd205774923' }, this.label && (h("label", { key: '7400206e6c27d61e7b9afadeba8a2131059af59a', class: "label", htmlFor: this.inputId }, this.label)), h("input", { key: '2c4fd9215d5b21f28d57a1c49eeaa64224e21e05', id: this.label ? this.inputId : undefined, class: { 'input': true, 'input--invalid': this.invalid }, type: this.type, 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: '6e6a381f81442622784afc480eb79327ae8a8525', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '743215633ca399d801c813194b054d40631b7be6', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
76
113
|
}
|
|
77
114
|
static get is() { return "ch-input"; }
|
|
78
115
|
static get encapsulation() { return "shadow"; }
|
|
116
|
+
static get formAssociated() { return true; }
|
|
79
117
|
static get originalStyleUrls() {
|
|
80
118
|
return {
|
|
81
119
|
"$": ["ch-input.css"]
|
|
@@ -182,7 +220,7 @@ export class ChInput {
|
|
|
182
220
|
},
|
|
183
221
|
"getter": false,
|
|
184
222
|
"setter": false,
|
|
185
|
-
"reflect":
|
|
223
|
+
"reflect": true,
|
|
186
224
|
"attribute": "name"
|
|
187
225
|
},
|
|
188
226
|
"disabled": {
|
|
@@ -201,7 +239,7 @@ export class ChInput {
|
|
|
201
239
|
},
|
|
202
240
|
"getter": false,
|
|
203
241
|
"setter": false,
|
|
204
|
-
"reflect":
|
|
242
|
+
"reflect": true,
|
|
205
243
|
"attribute": "disabled",
|
|
206
244
|
"defaultValue": "false"
|
|
207
245
|
},
|
|
@@ -221,7 +259,7 @@ export class ChInput {
|
|
|
221
259
|
},
|
|
222
260
|
"getter": false,
|
|
223
261
|
"setter": false,
|
|
224
|
-
"reflect":
|
|
262
|
+
"reflect": true,
|
|
225
263
|
"attribute": "required",
|
|
226
264
|
"defaultValue": "false"
|
|
227
265
|
},
|
|
@@ -285,6 +323,11 @@ export class ChInput {
|
|
|
285
323
|
}
|
|
286
324
|
};
|
|
287
325
|
}
|
|
326
|
+
static get states() {
|
|
327
|
+
return {
|
|
328
|
+
"formDisabled": {}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
288
331
|
static get events() {
|
|
289
332
|
return [{
|
|
290
333
|
"method": "chInput",
|
|
@@ -318,5 +361,22 @@ export class ChInput {
|
|
|
318
361
|
}
|
|
319
362
|
}];
|
|
320
363
|
}
|
|
364
|
+
static get elementRef() { return "host"; }
|
|
365
|
+
static get watchers() {
|
|
366
|
+
return [{
|
|
367
|
+
"propName": "value",
|
|
368
|
+
"methodName": "syncForm"
|
|
369
|
+
}, {
|
|
370
|
+
"propName": "required",
|
|
371
|
+
"methodName": "syncForm"
|
|
372
|
+
}, {
|
|
373
|
+
"propName": "invalid",
|
|
374
|
+
"methodName": "syncForm"
|
|
375
|
+
}, {
|
|
376
|
+
"propName": "errorMessage",
|
|
377
|
+
"methodName": "syncForm"
|
|
378
|
+
}];
|
|
379
|
+
}
|
|
380
|
+
static get attachInternalsMemberName() { return "internals"; }
|
|
321
381
|
}
|
|
322
382
|
//# sourceMappingURL=ch-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ch-input.js","sourceRoot":"","sources":["../../../../src/components/ch-input/ch-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAqB,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ch-input.js","sourceRoot":"","sources":["../../../../src/components/ch-input/ch-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAqB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE3H,IAAI,QAAQ,GAAG,CAAC,CAAC;AAQjB,MAAM,OAAO,OAAO;IACD,OAAO,GAAG,YAAY,EAAE,QAAQ,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,OAAO,CAAC;IAChC,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,QAAQ,CAAC;IAC3C,YAAY,GAAG,EAAE,CAAC;IAEP,SAAS,CAAoB;IACvC,YAAY,GAAG,KAAK,CAAC;IACX,IAAI,CAAe;IAEtC;;;OAGG;IACK,KAAK,CAAU;IAEvB;;OAEG;IACK,IAAI,GAAG,MAAM,CAAC;IAEtB;;OAEG;IACsB,KAAK,GAAG,EAAE,CAAC;IAEpC;;OAEG;IACK,WAAW,CAAU;IAE7B;;OAEG;IACsB,IAAI,CAAU;IAEvC;;OAEG;IACsB,QAAQ,GAAG,KAAK,CAAC;IAE1C;;OAEG;IACsB,QAAQ,GAAG,KAAK,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;;;;;;;;;;;;CACF","sourcesContent":["import { AttachInternals, Component, Element, Event, type EventEmitter, Host, Prop, State, Watch, h } from '@stencil/core';\n\nlet inputIds = 0;\n\n@Component({\n tag: 'ch-input',\n styleUrl: 'ch-input.css',\n shadow: true,\n formAssociated: true,\n})\nexport class ChInput {\n private readonly inputId = `ch-input-${++inputIds}`;\n private readonly hintId = `${this.inputId}-hint`;\n private readonly errorId = `${this.inputId}-error`;\n private initialValue = '';\n\n @AttachInternals() internals!: ElementInternals;\n @State() formDisabled = false;\n @Element() private host!: HTMLElement;\n\n /**\n * Visible label rendered above the input and associated with it via\n * `for`/`id`, so assistive technology announces the input's purpose.\n */\n @Prop() label?: string;\n\n /**\n * The type of the input, mirroring the native `<input type>` attribute.\n */\n @Prop() type = 'text';\n\n /**\n * The value of the input.\n */\n @Prop({ mutable: true }) value = '';\n\n /**\n * Placeholder text shown when the input is empty.\n */\n @Prop() placeholder?: string;\n\n /**\n * The name of the input, submitted with form data.\n */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * Whether the input is disabled.\n */\n @Prop({ reflect: true }) disabled = false;\n\n /**\n * Whether the input is required.\n */\n @Prop({ reflect: true }) required = false;\n\n /**\n * Helper text rendered below the input, associated via `aria-describedby`.\n * Replaced by `errorMessage` when the input is invalid.\n */\n @Prop() hint?: string;\n\n /**\n * Error message rendered below the input when it is invalid.\n */\n @Prop() errorMessage?: string;\n\n /**\n * Whether the input is in an invalid state; toggles `aria-invalid` and error styling.\n */\n @Prop() invalid = false;\n\n /**\n * Emitted on every keystroke, with the current input value.\n */\n @Event() chInput: EventEmitter<string>;\n\n /**\n * Emitted when the input value is committed (on native `change`).\n */\n @Event() chChange: EventEmitter<string>;\n\n private handleInput = (ev: InputEvent) => {\n this.value = (ev.target as HTMLInputElement).value;\n this.chInput.emit(this.value);\n };\n\n private handleChange = (ev: Event) => {\n this.value = (ev.target as HTMLInputElement).value;\n this.chChange.emit(this.value);\n };\n\n @Watch('value')\n @Watch('required')\n @Watch('invalid')\n @Watch('errorMessage')\n protected syncForm(): void {\n const internals = this.internals;\n if (typeof internals?.setFormValue !== 'function') {\n return;\n }\n internals.setFormValue(this.value);\n const flags: ValidityStateFlags = {};\n let message: string | undefined;\n if (this.required && this.value === '') {\n flags.valueMissing = true;\n }\n if (this.invalid && this.errorMessage) {\n flags.customError = true;\n }\n message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);\n internals.setValidity(flags, message);\n }\n\n componentDidLoad() {\n this.initialValue = this.value;\n this.syncForm();\n this.host.addEventListener('change', this.markTouched);\n this.host.addEventListener('focusout', this.markTouched);\n this.host.addEventListener('invalid', this.markTouched);\n }\n\n private markTouched = (): void => {\n this.host.setAttribute('data-touched', '');\n };\n\n formResetCallback(): void {\n this.value = this.initialValue;\n }\n\n formDisabledCallback(isDisabled: boolean): void {\n this.formDisabled = isDisabled;\n }\n\n private get describedBy(): string | undefined {\n if (this.invalid && this.errorMessage) {\n return this.errorId;\n }\n if (this.hint) {\n return this.hintId;\n }\n return undefined;\n }\n\n render() {\n return (\n <Host>\n {this.label && (\n <label class=\"label\" htmlFor={this.inputId}>\n {this.label}\n </label>\n )}\n <input\n id={this.label ? this.inputId : undefined}\n class={{ 'input': true, 'input--invalid': this.invalid }}\n type={this.type}\n name={this.name}\n placeholder={this.placeholder}\n disabled={this.disabled || this.formDisabled}\n required={this.required}\n value={this.value}\n aria-invalid={this.invalid ? 'true' : undefined}\n aria-describedby={this.describedBy}\n onInput={this.handleInput}\n onChange={this.handleChange}\n />\n {this.hint && !(this.invalid && this.errorMessage) && (\n <p class=\"hint\" id={this.hintId}>\n {this.hint}\n </p>\n )}\n {this.invalid && this.errorMessage && (\n <p class=\"error\" id={this.errorId} role=\"alert\">\n {this.errorMessage}\n </p>\n )}\n </Host>\n );\n }\n}\n"]}
|
|
@@ -159,7 +159,7 @@ export class ChModal {
|
|
|
159
159
|
this.chClose.emit();
|
|
160
160
|
};
|
|
161
161
|
render() {
|
|
162
|
-
return (h(Host, { key: '
|
|
162
|
+
return (h(Host, { key: '8f5f8c340291feb4385076bfdefc02a849e08efe' }, h("dialog", { key: 'e435367c1e3dc5c7e8102f6ac76792394f5097fa', class: "modal", "aria-label": this.label, ref: el => (this.dialog = el) }, h("div", { key: '05a0d306dc7e3f917c47de28ed6359280c0472b8', class: "modal-head" }, h("slot", { key: '79e25ed41f98a5ceee2dca9afc200d8980d9f284', name: "heading" }), this.closeLabel && (h("button", { key: '0620b914cb51cae7ab74f2ccccb25e9fc324811f', class: "modal-close", type: "button", "aria-label": this.closeLabel, onClick: this.handleCloseClick }, h("span", { key: 'e2a1e0ec6c1d1cbdb2de684bfe4c7e0ed07ceaee', "aria-hidden": "true" }, "\u00D7")))), h("div", { key: 'af254d18e1538ea5dac06c421ba03d897ddf057d', class: "modal-body" }, h("slot", { key: '645876d63f275108a2a9d27f563bb6918dcb9deb' })))));
|
|
163
163
|
}
|
|
164
164
|
static get is() { return "ch-modal"; }
|
|
165
165
|
static get encapsulation() { return "shadow"; }
|
|
@@ -73,6 +73,16 @@
|
|
|
73
73
|
outline-color: var(--color-status-warning);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
:host([data-touched]:invalid) .input,
|
|
77
|
+
:host(:user-invalid) .input {
|
|
78
|
+
border-color: var(--color-status-warning);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
:host([data-touched]:invalid) .input:focus-visible,
|
|
82
|
+
:host(:user-invalid) .input:focus-visible {
|
|
83
|
+
outline-color: var(--color-status-warning);
|
|
84
|
+
}
|
|
85
|
+
|
|
76
86
|
.label-text {
|
|
77
87
|
color: var(--text);
|
|
78
88
|
}
|