@devschile/chucao 1.7.0 → 2.0.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 +14 -12
- package/dist/chucao/chucao.css +1 -1
- package/dist/chucao/chucao.esm.js +1 -1
- package/dist/chucao/index.esm.js +1 -1
- package/dist/chucao/index.esm.js.map +1 -1
- package/dist/chucao/p-10658dc9.entry.js +2 -0
- package/dist/chucao/p-10658dc9.entry.js.map +1 -0
- package/dist/chucao/p-19dde4f9.entry.js +2 -0
- package/dist/chucao/p-19dde4f9.entry.js.map +1 -0
- package/dist/chucao/p-2e20c7a1.entry.js +2 -0
- package/dist/chucao/p-2e20c7a1.entry.js.map +1 -0
- package/dist/chucao/p-66dce533.entry.js +2 -0
- package/dist/chucao/p-66dce533.entry.js.map +1 -0
- package/dist/chucao/p-75184fe1.entry.js +2 -0
- package/dist/chucao/p-75184fe1.entry.js.map +1 -0
- package/dist/chucao/p-96c852f5.entry.js +2 -0
- package/dist/chucao/p-96c852f5.entry.js.map +1 -0
- package/dist/chucao/p-BaKXvAYc.js +3 -0
- package/dist/chucao/p-BaKXvAYc.js.map +1 -0
- package/dist/chucao/{p-fe8e9537.entry.js → p-a0ec231a.entry.js} +2 -2
- package/dist/chucao/{p-488c7838.entry.js → p-e48912c7.entry.js} +2 -2
- package/dist/chucao/{p-20492b73.entry.js → p-f04d2f75.entry.js} +2 -2
- package/dist/chucao/{p-053d58a4.entry.js → p-f62e1da2.entry.js} +2 -2
- package/dist/cjs/ch-accordion.cjs.entry.js +1 -1
- package/dist/cjs/ch-alert_8.cjs.entry.js +185 -8
- 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-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 +62 -3
- package/dist/cjs/ch-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/ch-tabs.cjs.entry.js +1 -1
- 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 +82 -0
- package/dist/cjs/ch-tooltip.cjs.entry.js.map +1 -0
- package/dist/cjs/chucao.cjs.js +2 -2
- package/dist/cjs/{index-ls4U227d.js → index-C9Abf0td.js} +204 -9
- package/dist/cjs/index-C9Abf0td.js.map +1 -0
- package/dist/cjs/index.cjs.js +5 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -0
- 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-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.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.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-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-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.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 +4 -0
- 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.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-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.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-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.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-DL-bL54o.js +2 -0
- package/dist/components/p-DL-bL54o.js.map +1 -0
- package/dist/esm/ch-accordion.entry.js +1 -1
- package/dist/esm/ch-alert_8.entry.js +185 -8
- 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-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 +62 -3
- package/dist/esm/ch-radio.entry.js.map +1 -1
- package/dist/esm/ch-tabs.entry.js +1 -1
- 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 +80 -0
- package/dist/esm/ch-tooltip.entry.js.map +1 -0
- package/dist/esm/chucao.js +3 -3
- package/dist/esm/{index-pfWAsOzE.js → index-BaKXvAYc.js} +204 -10
- package/dist/esm/index-BaKXvAYc.js.map +1 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/ch-checkbox/ch-checkbox.d.ts +9 -0
- package/dist/types/components/ch-input/ch-input.d.ts +9 -0
- package/dist/types/components/ch-modal/ch-modal.d.ts +67 -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/ch-tooltip/ch-tooltip.d.ts +47 -0
- package/dist/types/components.d.ts +240 -0
- package/dist/types/tokens/tokens.d.ts +4 -0
- package/dist/types/tokens/types.d.ts +1 -1
- package/dist-react/components.d.ts +10 -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 +15 -0
- package/dist-vue/index.ts +19 -0
- package/hydrate/index.js +836 -61
- package/hydrate/index.mjs +836 -61
- package/package.json +4 -1
- package/dist/chucao/p-0305f2eb.entry.js +0 -2
- package/dist/chucao/p-0305f2eb.entry.js.map +0 -1
- package/dist/chucao/p-9a614e82.entry.js +0 -2
- package/dist/chucao/p-9a614e82.entry.js.map +0 -1
- package/dist/chucao/p-ad3206a2.entry.js +0 -2
- package/dist/chucao/p-ad3206a2.entry.js.map +0 -1
- package/dist/chucao/p-c598f978.entry.js +0 -2
- package/dist/chucao/p-c598f978.entry.js.map +0 -1
- package/dist/chucao/p-pfWAsOzE.js +0 -3
- package/dist/chucao/p-pfWAsOzE.js.map +0 -1
- package/dist/cjs/index-ls4U227d.js.map +0 -1
- package/dist/components/p-ONE3uKkF.js +0 -2
- package/dist/components/p-ONE3uKkF.js.map +0 -1
- package/dist/esm/index-pfWAsOzE.js.map +0 -1
- /package/dist/chucao/{p-fe8e9537.entry.js.map → p-a0ec231a.entry.js.map} +0 -0
- /package/dist/chucao/{p-488c7838.entry.js.map → p-e48912c7.entry.js.map} +0 -0
- /package/dist/chucao/{p-20492b73.entry.js.map → p-f04d2f75.entry.js.map} +0 -0
- /package/dist/chucao/{p-053d58a4.entry.js.map → p-f62e1da2.entry.js.map} +0 -0
package/hydrate/index.mjs
CHANGED
|
@@ -130,7 +130,7 @@ function hydrateFactory($stencilWindow, $stencilHydrateOpts, $stencilHydrateResu
|
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
const NAMESPACE = 'chucao';
|
|
133
|
-
const BUILD = /* chucao */ { hotModuleReplacement: false,
|
|
133
|
+
const BUILD = /* chucao */ { hotModuleReplacement: false, slotRelocation: true, state: true, updatable: true};
|
|
134
134
|
|
|
135
135
|
/*
|
|
136
136
|
Stencil Hydrate Platform v4.44.0 | MIT Licensed | https://stenciljs.com
|
|
@@ -1635,6 +1635,31 @@ var scopeCss = (cssText, scopeId2, commentOriginalSelector) => {
|
|
|
1635
1635
|
return cssText;
|
|
1636
1636
|
};
|
|
1637
1637
|
|
|
1638
|
+
// src/runtime/normalize-watchers.ts
|
|
1639
|
+
var normalizeWatchers = (raw) => {
|
|
1640
|
+
if (!raw) return void 0;
|
|
1641
|
+
const keys = Object.keys(raw);
|
|
1642
|
+
if (keys.length === 0) return void 0;
|
|
1643
|
+
let hasLegacy = false;
|
|
1644
|
+
for (const propName of keys) {
|
|
1645
|
+
if (hasLegacy) break;
|
|
1646
|
+
for (const h2 of raw[propName]) {
|
|
1647
|
+
if (typeof h2 === "string") {
|
|
1648
|
+
hasLegacy = true;
|
|
1649
|
+
break;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
if (!hasLegacy) return raw;
|
|
1654
|
+
const out = {};
|
|
1655
|
+
for (const propName of keys) {
|
|
1656
|
+
out[propName] = raw[propName].map(
|
|
1657
|
+
(h2) => typeof h2 === "string" ? { [h2]: 0 } : h2
|
|
1658
|
+
);
|
|
1659
|
+
}
|
|
1660
|
+
return out;
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1638
1663
|
// src/utils/remote-value.ts
|
|
1639
1664
|
var RemoteValue = class _RemoteValue {
|
|
1640
1665
|
/**
|
|
@@ -1754,7 +1779,9 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
1754
1779
|
}
|
|
1755
1780
|
if (propValue != null && !isComplexType(propValue)) {
|
|
1756
1781
|
if (propType & 4 /* Boolean */) {
|
|
1757
|
-
{
|
|
1782
|
+
if (isFormAssociated && typeof propValue === "string") {
|
|
1783
|
+
return propValue === "" || !!propValue;
|
|
1784
|
+
} else {
|
|
1758
1785
|
return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
1759
1786
|
}
|
|
1760
1787
|
}
|
|
@@ -2389,6 +2416,14 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2389
2416
|
const isHostElement = isHost(renderFnResults);
|
|
2390
2417
|
const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
|
|
2391
2418
|
hostTagName = hostElm.tagName;
|
|
2419
|
+
if (cmpMeta.$attrsToReflect$) {
|
|
2420
|
+
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
|
2421
|
+
cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => {
|
|
2422
|
+
{
|
|
2423
|
+
rootVnode.$attrs$[attribute] = hostElm[propName];
|
|
2424
|
+
}
|
|
2425
|
+
});
|
|
2426
|
+
}
|
|
2392
2427
|
if (isInitialLoad && rootVnode.$attrs$) {
|
|
2393
2428
|
for (const key of Object.keys(rootVnode.$attrs$)) {
|
|
2394
2429
|
if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
|
|
@@ -2549,6 +2584,13 @@ var dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
2549
2584
|
hostRef.$deferredConnectedCallback$ = false;
|
|
2550
2585
|
safeCall(instance, "connectedCallback", void 0, elm);
|
|
2551
2586
|
}
|
|
2587
|
+
{
|
|
2588
|
+
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
2589
|
+
if (hostRef.$queuedListeners$) {
|
|
2590
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
|
|
2591
|
+
hostRef.$queuedListeners$ = void 0;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2552
2594
|
if (hostRef.$fetchedCbList$.length) {
|
|
2553
2595
|
hostRef.$fetchedCbList$.forEach((cb) => cb(elm));
|
|
2554
2596
|
}
|
|
@@ -2710,16 +2752,40 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
2710
2752
|
`Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`
|
|
2711
2753
|
);
|
|
2712
2754
|
}
|
|
2755
|
+
const elm = hostRef.$hostElement$ ;
|
|
2713
2756
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
2714
2757
|
const flags = hostRef.$flags$;
|
|
2715
2758
|
const instance = hostRef.$lazyInstance$ ;
|
|
2716
2759
|
newVal = parsePropertyValue(
|
|
2717
2760
|
newVal,
|
|
2718
|
-
cmpMeta.$members$[propName][0]
|
|
2761
|
+
cmpMeta.$members$[propName][0],
|
|
2762
|
+
!!(cmpMeta.$flags$ & 64 /* formAssociated */)
|
|
2763
|
+
);
|
|
2719
2764
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
2720
2765
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
2721
2766
|
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
|
|
2722
2767
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
2768
|
+
if (cmpMeta.$watchers$) {
|
|
2769
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
2770
|
+
if (watchMethods) {
|
|
2771
|
+
watchMethods.map((watcher) => {
|
|
2772
|
+
try {
|
|
2773
|
+
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
2774
|
+
if (flags & 128 /* isWatchReady */ || watcherFlags & 1 /* Immediate */) {
|
|
2775
|
+
if (!instance) {
|
|
2776
|
+
hostRef.$fetchedCbList$.push(() => {
|
|
2777
|
+
hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
|
|
2778
|
+
});
|
|
2779
|
+
} else {
|
|
2780
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
} catch (e) {
|
|
2784
|
+
consoleError(e, elm);
|
|
2785
|
+
}
|
|
2786
|
+
});
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2723
2789
|
if (flags & 2 /* hasRendered */) {
|
|
2724
2790
|
if (instance.componentShouldUpdate) {
|
|
2725
2791
|
const shouldUpdate = instance.componentShouldUpdate(newVal, oldVal, propName);
|
|
@@ -2738,7 +2804,18 @@ var setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
2738
2804
|
var proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
2739
2805
|
var _a2;
|
|
2740
2806
|
const prototype = Cstr.prototype;
|
|
2741
|
-
|
|
2807
|
+
{
|
|
2808
|
+
{
|
|
2809
|
+
if (Cstr.watchers && !cmpMeta.$watchers$) {
|
|
2810
|
+
cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
|
|
2811
|
+
}
|
|
2812
|
+
if (Cstr.deserializers && !cmpMeta.$deserializers$) {
|
|
2813
|
+
cmpMeta.$deserializers$ = Cstr.deserializers;
|
|
2814
|
+
}
|
|
2815
|
+
if (Cstr.serializers && !cmpMeta.$serializers$) {
|
|
2816
|
+
cmpMeta.$serializers$ = Cstr.serializers;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2742
2819
|
const members = Object.entries((_a2 = cmpMeta.$members$) != null ? _a2 : {});
|
|
2743
2820
|
members.map(([memberName, [memberFlags]]) => {
|
|
2744
2821
|
if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
|
|
@@ -2776,7 +2853,9 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
2776
2853
|
origSetter.apply(this, [
|
|
2777
2854
|
parsePropertyValue(
|
|
2778
2855
|
newValue,
|
|
2779
|
-
memberFlags
|
|
2856
|
+
memberFlags,
|
|
2857
|
+
!!(cmpMeta.$flags$ & 64 /* formAssociated */)
|
|
2858
|
+
)
|
|
2780
2859
|
]);
|
|
2781
2860
|
newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
|
|
2782
2861
|
setValue(this, memberName, newValue, cmpMeta);
|
|
@@ -2823,6 +2902,11 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
2823
2902
|
throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
2824
2903
|
}
|
|
2825
2904
|
if (!Cstr.isProxied) {
|
|
2905
|
+
{
|
|
2906
|
+
cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
|
|
2907
|
+
cmpMeta.$serializers$ = Cstr.serializers;
|
|
2908
|
+
cmpMeta.$deserializers$ = Cstr.deserializers;
|
|
2909
|
+
}
|
|
2826
2910
|
proxyComponent(Cstr, cmpMeta);
|
|
2827
2911
|
Cstr.isProxied = true;
|
|
2828
2912
|
}
|
|
@@ -2838,6 +2922,9 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
2838
2922
|
{
|
|
2839
2923
|
hostRef.$flags$ &= -9 /* isConstructingInstance */;
|
|
2840
2924
|
}
|
|
2925
|
+
{
|
|
2926
|
+
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
2927
|
+
}
|
|
2841
2928
|
endNewInstance();
|
|
2842
2929
|
const needsDeferredCallback = cmpMeta.$flags$ & 4 /* hasSlotRelocation */;
|
|
2843
2930
|
if (!needsDeferredCallback) {
|
|
@@ -2936,6 +3023,7 @@ var connectedCallback = (elm) => {
|
|
|
2936
3023
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
2937
3024
|
}
|
|
2938
3025
|
} else {
|
|
3026
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
2939
3027
|
if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
|
|
2940
3028
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
2941
3029
|
} else if (hostRef.$flags$ & 1024 /* hasFailedLoad */) {
|
|
@@ -2957,6 +3045,38 @@ var setContentReference = (elm) => {
|
|
|
2957
3045
|
contentRefElm["s-cn"] = true;
|
|
2958
3046
|
insertBefore(elm, contentRefElm, elm.firstChild);
|
|
2959
3047
|
};
|
|
3048
|
+
var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
3049
|
+
if (listeners && win.document) {
|
|
3050
|
+
listeners.map(([flags, name, method]) => {
|
|
3051
|
+
const target = getHostListenerTarget(win.document, elm, flags) ;
|
|
3052
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
3053
|
+
const opts = hostListenerOpts(flags);
|
|
3054
|
+
plt.ael(target, name, handler, opts);
|
|
3055
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
3056
|
+
});
|
|
3057
|
+
}
|
|
3058
|
+
};
|
|
3059
|
+
var hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
3060
|
+
var _a2;
|
|
3061
|
+
try {
|
|
3062
|
+
{
|
|
3063
|
+
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
3064
|
+
(_a2 = hostRef.$lazyInstance$) == null ? void 0 : _a2[methodName](ev);
|
|
3065
|
+
} else {
|
|
3066
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
} catch (e) {
|
|
3070
|
+
consoleError(e, hostRef.$hostElement$);
|
|
3071
|
+
}
|
|
3072
|
+
};
|
|
3073
|
+
var getHostListenerTarget = (doc, elm, flags) => {
|
|
3074
|
+
if (flags & 4 /* TargetDocument */) {
|
|
3075
|
+
return doc;
|
|
3076
|
+
}
|
|
3077
|
+
return elm;
|
|
3078
|
+
};
|
|
3079
|
+
var hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
2960
3080
|
function transformTag(tag) {
|
|
2961
3081
|
return tag;
|
|
2962
3082
|
}
|
|
@@ -4766,7 +4886,7 @@ function proxyHostElement(elm, cstr) {
|
|
|
4766
4886
|
attrPropVal = cstr.prototype[methodName](attrValue, memberName);
|
|
4767
4887
|
}
|
|
4768
4888
|
} else {
|
|
4769
|
-
attrPropVal = parsePropertyValue(attrValue, memberFlags);
|
|
4889
|
+
attrPropVal = parsePropertyValue(attrValue, memberFlags, !!(cmpMeta.$flags$ & 64 /* formAssociated */));
|
|
4770
4890
|
}
|
|
4771
4891
|
}
|
|
4772
4892
|
if (propValue !== void 0) {
|
|
@@ -4947,6 +5067,7 @@ async function hydrateComponent(win2, results, tagName, elm, waitingElements) {
|
|
|
4947
5067
|
if (!hostRef) {
|
|
4948
5068
|
return;
|
|
4949
5069
|
}
|
|
5070
|
+
addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
|
|
4950
5071
|
try {
|
|
4951
5072
|
connectedCallback(elm);
|
|
4952
5073
|
await elm.componentOnReady();
|
|
@@ -5176,7 +5297,7 @@ var registerInstance = (lazyInstance, hostRef) => {
|
|
|
5176
5297
|
if (!hostRef) return void 0;
|
|
5177
5298
|
lazyInstance.__stencil__getHostRef = () => hostRef;
|
|
5178
5299
|
hostRef.$lazyInstance$ = lazyInstance;
|
|
5179
|
-
if (hostRef.$cmpMeta$.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.
|
|
5300
|
+
if (hostRef.$cmpMeta$.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.state)) {
|
|
5180
5301
|
reWireGetterSetter(lazyInstance, hostRef);
|
|
5181
5302
|
}
|
|
5182
5303
|
return hostRef;
|
|
@@ -5391,7 +5512,7 @@ class ChCard {
|
|
|
5391
5512
|
registerInstance(this, hostRef);
|
|
5392
5513
|
}
|
|
5393
5514
|
render() {
|
|
5394
|
-
return (hAsync(Host, { key: '
|
|
5515
|
+
return (hAsync(Host, { key: '1541ba4361c996716356fb87cdcc73b1260d4c6a' }, hAsync("div", { key: '924070eeb79f6c8f8e6362772bbab0dcc1c6f315', class: "card" }, hAsync("slot", { key: '2fde36426395a519cb1ebe265ba0eef3aaf6ff38' }))));
|
|
5395
5516
|
}
|
|
5396
5517
|
static get style() { return chCardCss(); }
|
|
5397
5518
|
static get cmpMeta() { return {
|
|
@@ -5404,17 +5525,28 @@ class ChCard {
|
|
|
5404
5525
|
}; }
|
|
5405
5526
|
}
|
|
5406
5527
|
|
|
5407
|
-
const chCheckboxCss = () => `:host{display:inline-block}.control{display:inline-flex;align-items:center;gap:var(--spacing-lg);cursor:pointer}.control--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.input{appearance:none;-webkit-appearance:none;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;width:var(--spacing-4xl);height:var(--spacing-4xl);margin:0;flex-shrink:0;border:var(--border-width) solid var(--border);border-radius:var(--radius-sm);background:var(--surface);cursor:pointer;transition:border-color var(--duration-normal) var(--easing-default), background-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.input:focus-visible{outline:var(--focus-outline-width) solid var(--accent);outline-offset:var(--focus-outline-offset)}.input:checked{border-color:var(--accent);background:var(--accent)}.input:checked::before{content:'';width:var(--spacing-xs);height:var(--spacing-lg);border:solid var(--color-accent-text);border-width:0 var(--spacing-shift) var(--spacing-shift) 0;transform:rotate(45deg);margin-top:calc(-1 * var(--spacing-2xs))}.input--invalid{border-color:var(--color-status-warning)}.input--invalid:focus-visible{outline-color:var(--color-status-warning)}.label-text{color:var(--text)}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
5528
|
+
const chCheckboxCss = () => `:host{display:inline-block}.control{display:inline-flex;align-items:center;gap:var(--spacing-lg);cursor:pointer}.control--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.input{appearance:none;-webkit-appearance:none;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;width:var(--spacing-4xl);height:var(--spacing-4xl);margin:0;flex-shrink:0;border:var(--border-width) solid var(--border);border-radius:var(--radius-sm);background:var(--surface);cursor:pointer;transition:border-color var(--duration-normal) var(--easing-default), background-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.input:focus-visible{outline:var(--focus-outline-width) solid var(--accent);outline-offset:var(--focus-outline-offset)}.input:checked{border-color:var(--accent);background:var(--accent)}.input:checked::before{content:'';width:var(--spacing-xs);height:var(--spacing-lg);border:solid var(--color-accent-text);border-width:0 var(--spacing-shift) var(--spacing-shift) 0;transform:rotate(45deg);margin-top:calc(-1 * var(--spacing-2xs))}.input--invalid{border-color:var(--color-status-warning)}.input--invalid:focus-visible{outline-color:var(--color-status-warning)}:host([data-touched]:invalid) .input,:host(:user-invalid) .input{border-color:var(--color-status-warning)}:host([data-touched]:invalid) .input:focus-visible,:host(:user-invalid) .input:focus-visible{outline-color:var(--color-status-warning)}.label-text{color:var(--text)}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
5408
5529
|
|
|
5409
5530
|
let checkboxIds = 0;
|
|
5410
5531
|
class ChCheckbox {
|
|
5411
5532
|
constructor(hostRef) {
|
|
5412
5533
|
registerInstance(this, hostRef);
|
|
5413
5534
|
this.chChange = createEvent(this, "chChange");
|
|
5535
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
5536
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
5537
|
+
}
|
|
5538
|
+
else {
|
|
5539
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
5540
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
5541
|
+
}
|
|
5414
5542
|
}
|
|
5415
5543
|
checkboxId = `ch-checkbox-${++checkboxIds}`;
|
|
5416
5544
|
hintId = `${this.checkboxId}-hint`;
|
|
5417
5545
|
errorId = `${this.checkboxId}-error`;
|
|
5546
|
+
initialChecked = false;
|
|
5547
|
+
internals;
|
|
5548
|
+
formDisabled = false;
|
|
5549
|
+
get host() { return getElement(this); }
|
|
5418
5550
|
/**
|
|
5419
5551
|
* Visible label rendered next to the checkbox, associated with it via
|
|
5420
5552
|
* `for`/`id`, so assistive technology announces the checkbox's purpose.
|
|
@@ -5461,6 +5593,39 @@ class ChCheckbox {
|
|
|
5461
5593
|
this.checked = ev.target.checked;
|
|
5462
5594
|
this.chChange.emit(this.checked);
|
|
5463
5595
|
};
|
|
5596
|
+
syncForm() {
|
|
5597
|
+
const internals = this.internals;
|
|
5598
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
5599
|
+
return;
|
|
5600
|
+
}
|
|
5601
|
+
internals.setFormValue(this.checked ? this.value : null);
|
|
5602
|
+
const flags = {};
|
|
5603
|
+
let message;
|
|
5604
|
+
if (this.required && !this.checked) {
|
|
5605
|
+
flags.valueMissing = true;
|
|
5606
|
+
}
|
|
5607
|
+
if (this.invalid && this.errorMessage) {
|
|
5608
|
+
flags.customError = true;
|
|
5609
|
+
}
|
|
5610
|
+
message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);
|
|
5611
|
+
internals.setValidity(flags, message);
|
|
5612
|
+
}
|
|
5613
|
+
componentDidLoad() {
|
|
5614
|
+
this.initialChecked = this.checked;
|
|
5615
|
+
this.syncForm();
|
|
5616
|
+
this.host.addEventListener('change', this.markTouched);
|
|
5617
|
+
this.host.addEventListener('focusout', this.markTouched);
|
|
5618
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
5619
|
+
}
|
|
5620
|
+
markTouched = () => {
|
|
5621
|
+
this.host.setAttribute('data-touched', '');
|
|
5622
|
+
};
|
|
5623
|
+
formResetCallback() {
|
|
5624
|
+
this.checked = this.initialChecked;
|
|
5625
|
+
}
|
|
5626
|
+
formDisabledCallback(isDisabled) {
|
|
5627
|
+
this.formDisabled = isDisabled;
|
|
5628
|
+
}
|
|
5464
5629
|
get describedBy() {
|
|
5465
5630
|
if (this.invalid && this.errorMessage) {
|
|
5466
5631
|
return this.errorId;
|
|
@@ -5471,26 +5636,42 @@ class ChCheckbox {
|
|
|
5471
5636
|
return undefined;
|
|
5472
5637
|
}
|
|
5473
5638
|
render() {
|
|
5474
|
-
return (hAsync(Host, { key: '
|
|
5475
|
-
}
|
|
5639
|
+
return (hAsync(Host, { key: 'ca6c6f1297434052eeee68fd76cf21d6a7b99aae' }, hAsync("label", { key: '1f3538da6eb2ce91a75cf73044e2103ba472d4ed', class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled }, htmlFor: this.checkboxId }, hAsync("input", { key: '7ed674616bc70af42b025a2b945378192ce48a58', 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 && hAsync("span", { key: '4f5ccc7b28d95d012aa5cd87ec2411be34672d9e', class: "label-text" }, this.label)), this.hint && !(this.invalid && this.errorMessage) && (hAsync("p", { key: 'b7d2b09c54ed61907e4e7110af867b2a0592924c', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (hAsync("p", { key: '2340791705a5fce22b810a3a32377a7b1ccef852', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
5640
|
+
}
|
|
5641
|
+
static get formAssociated() { return true; }
|
|
5642
|
+
static get watchers() { return {
|
|
5643
|
+
"checked": [{
|
|
5644
|
+
"syncForm": 0
|
|
5645
|
+
}],
|
|
5646
|
+
"required": [{
|
|
5647
|
+
"syncForm": 0
|
|
5648
|
+
}],
|
|
5649
|
+
"invalid": [{
|
|
5650
|
+
"syncForm": 0
|
|
5651
|
+
}],
|
|
5652
|
+
"errorMessage": [{
|
|
5653
|
+
"syncForm": 0
|
|
5654
|
+
}]
|
|
5655
|
+
}; }
|
|
5476
5656
|
static get style() { return chCheckboxCss(); }
|
|
5477
5657
|
static get cmpMeta() { return {
|
|
5478
|
-
"$flags$":
|
|
5658
|
+
"$flags$": 585,
|
|
5479
5659
|
"$tagName$": "ch-checkbox",
|
|
5480
5660
|
"$members$": {
|
|
5481
5661
|
"label": [1],
|
|
5482
|
-
"name": [
|
|
5662
|
+
"name": [513],
|
|
5483
5663
|
"value": [1],
|
|
5484
5664
|
"checked": [1028],
|
|
5485
|
-
"disabled": [
|
|
5486
|
-
"required": [
|
|
5665
|
+
"disabled": [516],
|
|
5666
|
+
"required": [516],
|
|
5487
5667
|
"hint": [1],
|
|
5488
5668
|
"errorMessage": [1, "error-message"],
|
|
5489
|
-
"invalid": [4]
|
|
5669
|
+
"invalid": [4],
|
|
5670
|
+
"formDisabled": [32]
|
|
5490
5671
|
},
|
|
5491
5672
|
"$listeners$": undefined,
|
|
5492
5673
|
"$lazyBundleId$": "-",
|
|
5493
|
-
"$attrsToReflect$": []
|
|
5674
|
+
"$attrsToReflect$": [["name", "name"], ["disabled", "disabled"], ["required", "required"]]
|
|
5494
5675
|
}; }
|
|
5495
5676
|
}
|
|
5496
5677
|
|
|
@@ -5520,7 +5701,7 @@ class ChDivider {
|
|
|
5520
5701
|
}; }
|
|
5521
5702
|
}
|
|
5522
5703
|
|
|
5523
|
-
const chInputCss = () => `:host{display:inline-block;width:100%}.label{display:block;margin-bottom:var(--spacing-sm);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);color:var(--text)}.input{box-sizing:border-box;width:100%;padding:var(--spacing-xl) var(--spacing-3xl);border-radius:var(--radius);border:var(--border-width) solid var(--border);background:var(--surface);color:var(--text);backdrop-filter:blur(var(--effect-blur));font-family:inherit;font-size:inherit;transition:border-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.input::placeholder{color:var(--text-muted)}.input:focus{border-color:var(--accent);box-shadow:var(--shadow-focus-ring);outline:none}.input--invalid{border-color:var(--color-status-warning)}.input--invalid:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}.input:disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
5704
|
+
const chInputCss = () => `:host{display:inline-block;width:100%}.label{display:block;margin-bottom:var(--spacing-sm);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);color:var(--text)}.input{box-sizing:border-box;width:100%;padding:var(--spacing-xl) var(--spacing-3xl);border-radius:var(--radius);border:var(--border-width) solid var(--border);background:var(--surface);color:var(--text);backdrop-filter:blur(var(--effect-blur));font-family:inherit;font-size:inherit;transition:border-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.input::placeholder{color:var(--text-muted)}.input:focus{border-color:var(--accent);box-shadow:var(--shadow-focus-ring);outline:none}.input--invalid{border-color:var(--color-status-warning)}.input--invalid:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}:host([data-touched]:invalid) .input,:host(:user-invalid) .input{border-color:var(--color-status-warning)}:host([data-touched]:invalid) .input:focus,:host(:user-invalid) .input:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}.input:disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
5524
5705
|
|
|
5525
5706
|
let inputIds = 0;
|
|
5526
5707
|
class ChInput {
|
|
@@ -5528,10 +5709,21 @@ class ChInput {
|
|
|
5528
5709
|
registerInstance(this, hostRef);
|
|
5529
5710
|
this.chInput = createEvent(this, "chInput");
|
|
5530
5711
|
this.chChange = createEvent(this, "chChange");
|
|
5712
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
5713
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
5714
|
+
}
|
|
5715
|
+
else {
|
|
5716
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
5717
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
5718
|
+
}
|
|
5531
5719
|
}
|
|
5532
5720
|
inputId = `ch-input-${++inputIds}`;
|
|
5533
5721
|
hintId = `${this.inputId}-hint`;
|
|
5534
5722
|
errorId = `${this.inputId}-error`;
|
|
5723
|
+
initialValue = '';
|
|
5724
|
+
internals;
|
|
5725
|
+
formDisabled = false;
|
|
5726
|
+
get host() { return getElement(this); }
|
|
5535
5727
|
/**
|
|
5536
5728
|
* Visible label rendered above the input and associated with it via
|
|
5537
5729
|
* `for`/`id`, so assistive technology announces the input's purpose.
|
|
@@ -5590,6 +5782,39 @@ class ChInput {
|
|
|
5590
5782
|
this.value = ev.target.value;
|
|
5591
5783
|
this.chChange.emit(this.value);
|
|
5592
5784
|
};
|
|
5785
|
+
syncForm() {
|
|
5786
|
+
const internals = this.internals;
|
|
5787
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
5788
|
+
return;
|
|
5789
|
+
}
|
|
5790
|
+
internals.setFormValue(this.value);
|
|
5791
|
+
const flags = {};
|
|
5792
|
+
let message;
|
|
5793
|
+
if (this.required && this.value === '') {
|
|
5794
|
+
flags.valueMissing = true;
|
|
5795
|
+
}
|
|
5796
|
+
if (this.invalid && this.errorMessage) {
|
|
5797
|
+
flags.customError = true;
|
|
5798
|
+
}
|
|
5799
|
+
message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);
|
|
5800
|
+
internals.setValidity(flags, message);
|
|
5801
|
+
}
|
|
5802
|
+
componentDidLoad() {
|
|
5803
|
+
this.initialValue = this.value;
|
|
5804
|
+
this.syncForm();
|
|
5805
|
+
this.host.addEventListener('change', this.markTouched);
|
|
5806
|
+
this.host.addEventListener('focusout', this.markTouched);
|
|
5807
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
5808
|
+
}
|
|
5809
|
+
markTouched = () => {
|
|
5810
|
+
this.host.setAttribute('data-touched', '');
|
|
5811
|
+
};
|
|
5812
|
+
formResetCallback() {
|
|
5813
|
+
this.value = this.initialValue;
|
|
5814
|
+
}
|
|
5815
|
+
formDisabledCallback(isDisabled) {
|
|
5816
|
+
this.formDisabled = isDisabled;
|
|
5817
|
+
}
|
|
5593
5818
|
get describedBy() {
|
|
5594
5819
|
if (this.invalid && this.errorMessage) {
|
|
5595
5820
|
return this.errorId;
|
|
@@ -5600,27 +5825,43 @@ class ChInput {
|
|
|
5600
5825
|
return undefined;
|
|
5601
5826
|
}
|
|
5602
5827
|
render() {
|
|
5603
|
-
return (hAsync(Host, { key: '
|
|
5604
|
-
}
|
|
5828
|
+
return (hAsync(Host, { key: '8ac09d33deda0e98464108b77ef5e79ca1696e3f' }, this.label && (hAsync("label", { key: 'e66ab373c5234c2fdacf6bbb796b42ed212c3fd8', class: "label", htmlFor: this.inputId }, this.label)), hAsync("input", { key: 'ae23f4e30970287927f418aebd3b1f83be6d7738', 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) && (hAsync("p", { key: '8a6ff789e40a0b3595a34c1e94c3d779d4169bf0', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (hAsync("p", { key: 'aa4c0d89748ad91d91f6483fcf9b3641b44ee864', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
5829
|
+
}
|
|
5830
|
+
static get formAssociated() { return true; }
|
|
5831
|
+
static get watchers() { return {
|
|
5832
|
+
"value": [{
|
|
5833
|
+
"syncForm": 0
|
|
5834
|
+
}],
|
|
5835
|
+
"required": [{
|
|
5836
|
+
"syncForm": 0
|
|
5837
|
+
}],
|
|
5838
|
+
"invalid": [{
|
|
5839
|
+
"syncForm": 0
|
|
5840
|
+
}],
|
|
5841
|
+
"errorMessage": [{
|
|
5842
|
+
"syncForm": 0
|
|
5843
|
+
}]
|
|
5844
|
+
}; }
|
|
5605
5845
|
static get style() { return chInputCss(); }
|
|
5606
5846
|
static get cmpMeta() { return {
|
|
5607
|
-
"$flags$":
|
|
5847
|
+
"$flags$": 585,
|
|
5608
5848
|
"$tagName$": "ch-input",
|
|
5609
5849
|
"$members$": {
|
|
5610
5850
|
"label": [1],
|
|
5611
5851
|
"type": [1],
|
|
5612
5852
|
"value": [1025],
|
|
5613
5853
|
"placeholder": [1],
|
|
5614
|
-
"name": [
|
|
5615
|
-
"disabled": [
|
|
5616
|
-
"required": [
|
|
5854
|
+
"name": [513],
|
|
5855
|
+
"disabled": [516],
|
|
5856
|
+
"required": [516],
|
|
5617
5857
|
"hint": [1],
|
|
5618
5858
|
"errorMessage": [1, "error-message"],
|
|
5619
|
-
"invalid": [4]
|
|
5859
|
+
"invalid": [4],
|
|
5860
|
+
"formDisabled": [32]
|
|
5620
5861
|
},
|
|
5621
5862
|
"$listeners$": undefined,
|
|
5622
5863
|
"$lazyBundleId$": "-",
|
|
5623
|
-
"$attrsToReflect$": []
|
|
5864
|
+
"$attrsToReflect$": [["name", "name"], ["disabled", "disabled"], ["required", "required"]]
|
|
5624
5865
|
}; }
|
|
5625
5866
|
}
|
|
5626
5867
|
|
|
@@ -5678,18 +5919,218 @@ class ChLink {
|
|
|
5678
5919
|
}; }
|
|
5679
5920
|
}
|
|
5680
5921
|
|
|
5681
|
-
const
|
|
5922
|
+
const chModalCss = () => `.modal{box-sizing:border-box;max-width:min(32rem, calc(100vw - var(--spacing-6xl)));max-height:calc(100vh - var(--spacing-6xl));padding:var(--spacing-5xl);border:var(--border-width) solid var(--border);border-radius:var(--radius);background:var(--color-background-base);color:var(--text);font-family:var(--font-body);font-size:var(--typography-size-md)}.modal::backdrop{background:var(--color-scrim-default);backdrop-filter:blur(var(--effect-blur))}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--spacing-2xl);margin-bottom:var(--spacing-2xl)}.modal-body{overflow-y:auto}.modal-close{display:inline-flex;align-items:center;justify-content:center;flex:none;padding:var(--spacing-2xs) var(--spacing-md);border:0;border-radius:var(--radius);background:none;color:var(--text-muted);cursor:pointer;font-family:var(--font-heading);font-size:var(--typography-size-lg);line-height:1;transition:background-color var(--duration-normal) var(--easing-default)}.modal-close:hover{background:var(--surface-hover);color:var(--text)}.modal-close:focus-visible{outline:var(--focus-outline-width) solid var(--accent);outline-offset:var(--focus-outline-offset)}@media (pointer: coarse){.modal-close{min-width:44px;min-height:44px}}@media (prefers-reduced-motion: reduce){.modal-close{transition:none}}`;
|
|
5923
|
+
|
|
5924
|
+
let openModals = 0;
|
|
5925
|
+
let previousOverflow = '';
|
|
5926
|
+
let previousPaddingRight = '';
|
|
5927
|
+
/**
|
|
5928
|
+
* Modal dialog, built on the native `<dialog>` element and opened with
|
|
5929
|
+
* `showModal()`.
|
|
5930
|
+
*
|
|
5931
|
+
* The browser therefore supplies the parts that are easy to get wrong: moving
|
|
5932
|
+
* focus into the dialog and returning it afterwards, marking the rest of the
|
|
5933
|
+
* document inert, `Escape` to close, the top layer, `::backdrop`, and the
|
|
5934
|
+
* implicit `dialog` role with `aria-modal="true"`. Notably it does not trap
|
|
5935
|
+
* focus, which is deliberate — the W3C APA group concluded a modal should let
|
|
5936
|
+
* keyboard users reach browser UI, so a hand-rolled trap would be less
|
|
5937
|
+
* correct, not more.
|
|
5938
|
+
*
|
|
5939
|
+
* What the platform does not cover, and this component adds: locking the page
|
|
5940
|
+
* behind the dialog so it cannot scroll, and closing when the backdrop is
|
|
5941
|
+
* clicked. The latter is `closedby="any"` in the platform, which Safari does
|
|
5942
|
+
* not support yet, so it is implemented here for every browser alike rather
|
|
5943
|
+
* than only for some.
|
|
5944
|
+
*/
|
|
5945
|
+
class ChModal {
|
|
5946
|
+
constructor(hostRef) {
|
|
5947
|
+
registerInstance(this, hostRef);
|
|
5948
|
+
this.chOpen = createEvent(this, "chOpen");
|
|
5949
|
+
this.chClose = createEvent(this, "chClose");
|
|
5950
|
+
}
|
|
5951
|
+
/**
|
|
5952
|
+
* Whether the dialog is open. Kept in sync when the user closes it with
|
|
5953
|
+
* `Escape`, the close button or a click outside.
|
|
5954
|
+
*/
|
|
5955
|
+
open = false;
|
|
5956
|
+
/**
|
|
5957
|
+
* Accessible name for the dialog, set as `aria-label`. A slotted heading
|
|
5958
|
+
* cannot be referenced with `aria-labelledby` across the shadow boundary, so
|
|
5959
|
+
* the name comes through this prop — and a modal dialog needs one, so pass
|
|
5960
|
+
* the same text as the heading.
|
|
5961
|
+
*/
|
|
5962
|
+
label;
|
|
5963
|
+
/**
|
|
5964
|
+
* Accessible label for the close button, set as `aria-label`. Setting it is
|
|
5965
|
+
* what adds the button: its only content is a decorative glyph, so without a
|
|
5966
|
+
* label it would have no accessible name.
|
|
5967
|
+
*/
|
|
5968
|
+
closeLabel;
|
|
5969
|
+
/**
|
|
5970
|
+
* Emitted after the dialog opens.
|
|
5971
|
+
*/
|
|
5972
|
+
chOpen;
|
|
5973
|
+
/**
|
|
5974
|
+
* Emitted after the dialog closes, however it was closed.
|
|
5975
|
+
*/
|
|
5976
|
+
chClose;
|
|
5977
|
+
dialog;
|
|
5978
|
+
scrollLocked = false;
|
|
5979
|
+
pointerDownedOutside = false;
|
|
5980
|
+
componentDidLoad() {
|
|
5981
|
+
// Wired here rather than in JSX because Stencil derives a listener's event
|
|
5982
|
+
// name from whether `on<name>` exists on `window`, which differs between
|
|
5983
|
+
// the browser and the test environment for pointer events.
|
|
5984
|
+
this.dialog?.addEventListener('close', this.handleNativeClose);
|
|
5985
|
+
this.dialog?.addEventListener('pointerdown', this.handlePointerDown);
|
|
5986
|
+
this.dialog?.addEventListener('click', this.handleClick);
|
|
5987
|
+
if (this.open) {
|
|
5988
|
+
this.showDialog();
|
|
5989
|
+
}
|
|
5990
|
+
}
|
|
5991
|
+
disconnectedCallback() {
|
|
5992
|
+
this.dialog?.removeEventListener('close', this.handleNativeClose);
|
|
5993
|
+
this.dialog?.removeEventListener('pointerdown', this.handlePointerDown);
|
|
5994
|
+
this.dialog?.removeEventListener('click', this.handleClick);
|
|
5995
|
+
this.unlockScroll();
|
|
5996
|
+
}
|
|
5997
|
+
handleOpenChange(open) {
|
|
5998
|
+
if (open) {
|
|
5999
|
+
this.showDialog();
|
|
6000
|
+
}
|
|
6001
|
+
else {
|
|
6002
|
+
this.closeDialog();
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
showDialog() {
|
|
6006
|
+
if (typeof this.dialog?.showModal !== 'function') {
|
|
6007
|
+
return;
|
|
6008
|
+
}
|
|
6009
|
+
this.lockScroll();
|
|
6010
|
+
this.dialog.showModal();
|
|
6011
|
+
this.chOpen.emit();
|
|
6012
|
+
}
|
|
6013
|
+
closeDialog() {
|
|
6014
|
+
if (typeof this.dialog?.close === 'function' && this.dialog.open) {
|
|
6015
|
+
this.dialog.close();
|
|
6016
|
+
}
|
|
6017
|
+
}
|
|
6018
|
+
lockScroll() {
|
|
6019
|
+
if (this.scrollLocked) {
|
|
6020
|
+
return;
|
|
6021
|
+
}
|
|
6022
|
+
this.scrollLocked = true;
|
|
6023
|
+
openModals += 1;
|
|
6024
|
+
if (openModals > 1) {
|
|
6025
|
+
return;
|
|
6026
|
+
}
|
|
6027
|
+
const root = document.documentElement;
|
|
6028
|
+
const scrollbar = window.innerWidth - root.clientWidth;
|
|
6029
|
+
previousOverflow = root.style.overflow;
|
|
6030
|
+
previousPaddingRight = root.style.paddingRight;
|
|
6031
|
+
root.style.overflow = 'hidden';
|
|
6032
|
+
if (scrollbar > 0) {
|
|
6033
|
+
root.style.paddingRight = `${scrollbar}px`;
|
|
6034
|
+
}
|
|
6035
|
+
}
|
|
6036
|
+
unlockScroll() {
|
|
6037
|
+
if (!this.scrollLocked) {
|
|
6038
|
+
return;
|
|
6039
|
+
}
|
|
6040
|
+
this.scrollLocked = false;
|
|
6041
|
+
openModals -= 1;
|
|
6042
|
+
if (openModals > 0) {
|
|
6043
|
+
return;
|
|
6044
|
+
}
|
|
6045
|
+
const root = document.documentElement;
|
|
6046
|
+
root.style.overflow = previousOverflow;
|
|
6047
|
+
root.style.paddingRight = previousPaddingRight;
|
|
6048
|
+
}
|
|
6049
|
+
/**
|
|
6050
|
+
* True for a pointer event on the backdrop: the `<dialog>` is the event
|
|
6051
|
+
* target for its own box only, and the coordinates fall outside that box.
|
|
6052
|
+
*/
|
|
6053
|
+
isOnBackdrop(event) {
|
|
6054
|
+
if (!this.dialog || event.target !== this.dialog) {
|
|
6055
|
+
return false;
|
|
6056
|
+
}
|
|
6057
|
+
const box = this.dialog.getBoundingClientRect();
|
|
6058
|
+
return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
|
|
6059
|
+
}
|
|
6060
|
+
handlePointerDown = (event) => {
|
|
6061
|
+
this.pointerDownedOutside = this.isOnBackdrop(event);
|
|
6062
|
+
};
|
|
6063
|
+
handleClick = (event) => {
|
|
6064
|
+
// Requiring the press to have started on the backdrop too keeps a
|
|
6065
|
+
// selection dragged out of the dialog, and a keyboard-synthesised click
|
|
6066
|
+
// (which reports coordinates of 0), from closing it.
|
|
6067
|
+
const dismiss = this.pointerDownedOutside && this.isOnBackdrop(event);
|
|
6068
|
+
this.pointerDownedOutside = false;
|
|
6069
|
+
if (dismiss) {
|
|
6070
|
+
this.closeDialog();
|
|
6071
|
+
}
|
|
6072
|
+
};
|
|
6073
|
+
handleNativeClose = () => {
|
|
6074
|
+
this.unlockScroll();
|
|
6075
|
+
if (this.open) {
|
|
6076
|
+
this.open = false;
|
|
6077
|
+
}
|
|
6078
|
+
this.chClose.emit();
|
|
6079
|
+
};
|
|
6080
|
+
handleCloseClick = () => {
|
|
6081
|
+
if (typeof this.dialog?.close === 'function' && this.dialog.open) {
|
|
6082
|
+
this.dialog.close();
|
|
6083
|
+
return;
|
|
6084
|
+
}
|
|
6085
|
+
this.open = false;
|
|
6086
|
+
this.chClose.emit();
|
|
6087
|
+
};
|
|
6088
|
+
render() {
|
|
6089
|
+
return (hAsync(Host, { key: '92edf16d3ff079f72a4785ec9852e3e25218fd35' }, hAsync("dialog", { key: '546fc72a098e1e2d8c05fafa2f11eac19ff83fd3', class: "modal", "aria-label": this.label, ref: el => (this.dialog = el) }, hAsync("div", { key: '5a67aa39b6687db89d97533eb54d3a3b663bed56', class: "modal-head" }, hAsync("slot", { key: '2e44b59a7c5e6af4a110a7f86362964ddd30d215', name: "heading" }), this.closeLabel && (hAsync("button", { key: 'ce70baaa876c9f7b82865f0547e8e8cef5d5dfde', class: "modal-close", type: "button", "aria-label": this.closeLabel, onClick: this.handleCloseClick }, hAsync("span", { key: 'df4536a8851a1ca9d3d2c46d15d18856660a54f6', "aria-hidden": "true" }, "\u00D7")))), hAsync("div", { key: '5de77062134ccd90643df17d7b0d0ddb161f6a5f', class: "modal-body" }, hAsync("slot", { key: '3b64493e9236b311a4b2f5250c5027f866bce8fd' })))));
|
|
6090
|
+
}
|
|
6091
|
+
static get watchers() { return {
|
|
6092
|
+
"open": [{
|
|
6093
|
+
"handleOpenChange": 0
|
|
6094
|
+
}]
|
|
6095
|
+
}; }
|
|
6096
|
+
static get style() { return chModalCss(); }
|
|
6097
|
+
static get cmpMeta() { return {
|
|
6098
|
+
"$flags$": 777,
|
|
6099
|
+
"$tagName$": "ch-modal",
|
|
6100
|
+
"$members$": {
|
|
6101
|
+
"open": [1028],
|
|
6102
|
+
"label": [1],
|
|
6103
|
+
"closeLabel": [1, "close-label"]
|
|
6104
|
+
},
|
|
6105
|
+
"$listeners$": undefined,
|
|
6106
|
+
"$lazyBundleId$": "-",
|
|
6107
|
+
"$attrsToReflect$": []
|
|
6108
|
+
}; }
|
|
6109
|
+
}
|
|
6110
|
+
|
|
6111
|
+
const chRadioCss = () => `:host{display:inline-block}.group-label{display:block;margin-bottom:var(--spacing-sm);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);color:var(--text)}.radio-group{display:flex;flex-direction:column;gap:var(--spacing-lg)}.control{display:inline-flex;align-items:center;gap:var(--spacing-lg);cursor:pointer}.control--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.input{appearance:none;-webkit-appearance:none;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;width:var(--spacing-4xl);height:var(--spacing-4xl);margin:0;flex-shrink:0;border:var(--border-width) solid var(--border);border-radius:50%;background:var(--surface);cursor:pointer;transition:border-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.input:focus-visible{outline:var(--focus-outline-width) solid var(--accent);outline-offset:var(--focus-outline-offset)}.input:checked{border-color:var(--accent)}.input:checked::before{content:'';width:var(--spacing-md);height:var(--spacing-md);border-radius:50%;background:var(--accent)}.input--invalid{border-color:var(--color-status-warning)}.input--invalid:focus-visible{outline-color:var(--color-status-warning)}:host([data-touched]:invalid) .input,:host(:user-invalid) .input{border-color:var(--color-status-warning)}:host([data-touched]:invalid) .input:focus-visible,:host(:user-invalid) .input:focus-visible{outline-color:var(--color-status-warning)}.label-text{color:var(--text)}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
5682
6112
|
|
|
5683
6113
|
let radioIds = 0;
|
|
5684
6114
|
class ChRadio {
|
|
5685
6115
|
constructor(hostRef) {
|
|
5686
6116
|
registerInstance(this, hostRef);
|
|
5687
6117
|
this.chChange = createEvent(this, "chChange");
|
|
6118
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
6119
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
6120
|
+
}
|
|
6121
|
+
else {
|
|
6122
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
6123
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
6124
|
+
}
|
|
5688
6125
|
}
|
|
5689
6126
|
groupId = `ch-radio-${++radioIds}`;
|
|
5690
6127
|
labelId = `${this.groupId}-label`;
|
|
5691
6128
|
hintId = `${this.groupId}-hint`;
|
|
5692
6129
|
errorId = `${this.groupId}-error`;
|
|
6130
|
+
initialValue;
|
|
6131
|
+
internals;
|
|
6132
|
+
formDisabled = false;
|
|
6133
|
+
get host() { return getElement(this); }
|
|
5693
6134
|
/**
|
|
5694
6135
|
* Visible label describing the radio group, associated with it via
|
|
5695
6136
|
* `aria-labelledby`.
|
|
@@ -5737,6 +6178,39 @@ class ChRadio {
|
|
|
5737
6178
|
this.value = ev.target.value;
|
|
5738
6179
|
this.chChange.emit(this.value);
|
|
5739
6180
|
};
|
|
6181
|
+
syncForm() {
|
|
6182
|
+
const internals = this.internals;
|
|
6183
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
6184
|
+
return;
|
|
6185
|
+
}
|
|
6186
|
+
internals.setFormValue(this.value ?? null);
|
|
6187
|
+
const flags = {};
|
|
6188
|
+
let message;
|
|
6189
|
+
if (this.required && !this.value) {
|
|
6190
|
+
flags.valueMissing = true;
|
|
6191
|
+
}
|
|
6192
|
+
if (this.invalid && this.errorMessage) {
|
|
6193
|
+
flags.customError = true;
|
|
6194
|
+
}
|
|
6195
|
+
message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);
|
|
6196
|
+
internals.setValidity(flags, message);
|
|
6197
|
+
}
|
|
6198
|
+
componentDidLoad() {
|
|
6199
|
+
this.initialValue = this.value;
|
|
6200
|
+
this.syncForm();
|
|
6201
|
+
this.host.addEventListener('change', this.markTouched);
|
|
6202
|
+
this.host.addEventListener('focusout', this.markTouched);
|
|
6203
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
6204
|
+
}
|
|
6205
|
+
markTouched = () => {
|
|
6206
|
+
this.host.setAttribute('data-touched', '');
|
|
6207
|
+
};
|
|
6208
|
+
formResetCallback() {
|
|
6209
|
+
this.value = this.initialValue;
|
|
6210
|
+
}
|
|
6211
|
+
formDisabledCallback(isDisabled) {
|
|
6212
|
+
this.formDisabled = isDisabled;
|
|
6213
|
+
}
|
|
5740
6214
|
get describedBy() {
|
|
5741
6215
|
if (this.invalid && this.errorMessage) {
|
|
5742
6216
|
return this.errorId;
|
|
@@ -5748,40 +6222,67 @@ class ChRadio {
|
|
|
5748
6222
|
}
|
|
5749
6223
|
render() {
|
|
5750
6224
|
const groupName = this.name || `${this.groupId}-group`;
|
|
5751
|
-
return (hAsync(Host, { key: '
|
|
5752
|
-
}
|
|
6225
|
+
return (hAsync(Host, { key: '1a2562301b8daf00c557764c7f4cdfd54e6e11ef' }, this.label && (hAsync("span", { key: '873958acd3422069572031d59be22c06e3e705a6', class: "group-label", id: this.labelId }, this.label)), hAsync("div", { key: '860c71f128b6fb84dce3c14d2086fd77cc1a4a1e', class: "radio-group", role: "radiogroup", "aria-labelledby": this.label ? this.labelId : undefined }, this.options.map(option => (hAsync("label", { class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled || option.disabled } }, hAsync("input", { class: { 'input': true, 'input--invalid': this.invalid }, type: "radio", name: groupName, value: option.value, checked: option.value === this.value, disabled: this.disabled || this.formDisabled || option.disabled, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), hAsync("span", { class: "mark" }), hAsync("span", { class: "label-text" }, option.label))))), this.hint && !(this.invalid && this.errorMessage) && (hAsync("p", { key: '2b358f659d1ef21b1e90ecb67c41d6a0054806e3', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (hAsync("p", { key: '4e60f0303e42668c4532f076143a47daa216dff8', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
6226
|
+
}
|
|
6227
|
+
static get formAssociated() { return true; }
|
|
6228
|
+
static get watchers() { return {
|
|
6229
|
+
"value": [{
|
|
6230
|
+
"syncForm": 0
|
|
6231
|
+
}],
|
|
6232
|
+
"required": [{
|
|
6233
|
+
"syncForm": 0
|
|
6234
|
+
}],
|
|
6235
|
+
"invalid": [{
|
|
6236
|
+
"syncForm": 0
|
|
6237
|
+
}],
|
|
6238
|
+
"errorMessage": [{
|
|
6239
|
+
"syncForm": 0
|
|
6240
|
+
}]
|
|
6241
|
+
}; }
|
|
5753
6242
|
static get style() { return chRadioCss(); }
|
|
5754
6243
|
static get cmpMeta() { return {
|
|
5755
|
-
"$flags$":
|
|
6244
|
+
"$flags$": 585,
|
|
5756
6245
|
"$tagName$": "ch-radio",
|
|
5757
6246
|
"$members$": {
|
|
5758
6247
|
"label": [1],
|
|
5759
6248
|
"options": [16],
|
|
5760
6249
|
"value": [1025],
|
|
5761
|
-
"name": [
|
|
5762
|
-
"disabled": [
|
|
5763
|
-
"required": [
|
|
6250
|
+
"name": [513],
|
|
6251
|
+
"disabled": [516],
|
|
6252
|
+
"required": [516],
|
|
5764
6253
|
"hint": [1],
|
|
5765
6254
|
"errorMessage": [1, "error-message"],
|
|
5766
|
-
"invalid": [4]
|
|
6255
|
+
"invalid": [4],
|
|
6256
|
+
"formDisabled": [32]
|
|
5767
6257
|
},
|
|
5768
6258
|
"$listeners$": undefined,
|
|
5769
6259
|
"$lazyBundleId$": "-",
|
|
5770
|
-
"$attrsToReflect$": []
|
|
6260
|
+
"$attrsToReflect$": [["name", "name"], ["disabled", "disabled"], ["required", "required"]]
|
|
5771
6261
|
}; }
|
|
5772
6262
|
}
|
|
5773
6263
|
|
|
5774
|
-
const chSelectCss = () => `:host{display:inline-block;width:100%}.label{display:block;margin-bottom:var(--spacing-sm);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);color:var(--text)}.select{box-sizing:border-box;width:100%;padding:var(--spacing-xl) var(--spacing-3xl);border-radius:var(--radius);border:var(--border-width) solid var(--border);background:var(--surface);color:var(--text);backdrop-filter:blur(var(--effect-blur));font-family:inherit;font-size:inherit;cursor:pointer;transition:border-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.select:focus{border-color:var(--accent);box-shadow:var(--shadow-focus-ring);outline:none}.select--invalid{border-color:var(--color-status-warning)}.select--invalid:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}.select:disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.select option{background:var(--bg);color:var(--text)}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
6264
|
+
const chSelectCss = () => `:host{display:inline-block;width:100%}.label{display:block;margin-bottom:var(--spacing-sm);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);color:var(--text)}.select{box-sizing:border-box;width:100%;padding:var(--spacing-xl) var(--spacing-3xl);border-radius:var(--radius);border:var(--border-width) solid var(--border);background:var(--surface);color:var(--text);backdrop-filter:blur(var(--effect-blur));font-family:inherit;font-size:inherit;cursor:pointer;transition:border-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.select:focus{border-color:var(--accent);box-shadow:var(--shadow-focus-ring);outline:none}.select--invalid{border-color:var(--color-status-warning)}.select--invalid:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}:host([data-touched]:invalid) .select,:host(:user-invalid) .select{border-color:var(--color-status-warning)}:host([data-touched]:invalid) .select:focus,:host(:user-invalid) .select:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}.select:disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.select option{background:var(--bg);color:var(--text)}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
5775
6265
|
|
|
5776
6266
|
let selectIds = 0;
|
|
5777
6267
|
class ChSelect {
|
|
5778
6268
|
constructor(hostRef) {
|
|
5779
6269
|
registerInstance(this, hostRef);
|
|
5780
6270
|
this.chChange = createEvent(this, "chChange");
|
|
6271
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
6272
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
6273
|
+
}
|
|
6274
|
+
else {
|
|
6275
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
6276
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
6277
|
+
}
|
|
5781
6278
|
}
|
|
5782
6279
|
selectId = `ch-select-${++selectIds}`;
|
|
5783
6280
|
hintId = `${this.selectId}-hint`;
|
|
5784
6281
|
errorId = `${this.selectId}-error`;
|
|
6282
|
+
initialValue;
|
|
6283
|
+
internals;
|
|
6284
|
+
formDisabled = false;
|
|
6285
|
+
get host() { return getElement(this); }
|
|
5785
6286
|
/**
|
|
5786
6287
|
* Visible label rendered above the select and associated with it via
|
|
5787
6288
|
* `for`/`id`, so assistive technology announces the select's purpose.
|
|
@@ -5832,6 +6333,39 @@ class ChSelect {
|
|
|
5832
6333
|
this.value = ev.target.value;
|
|
5833
6334
|
this.chChange.emit(this.value);
|
|
5834
6335
|
};
|
|
6336
|
+
syncForm() {
|
|
6337
|
+
const internals = this.internals;
|
|
6338
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
6339
|
+
return;
|
|
6340
|
+
}
|
|
6341
|
+
internals.setFormValue(this.value ?? '');
|
|
6342
|
+
const flags = {};
|
|
6343
|
+
let message;
|
|
6344
|
+
if (this.required && !this.value) {
|
|
6345
|
+
flags.valueMissing = true;
|
|
6346
|
+
}
|
|
6347
|
+
if (this.invalid && this.errorMessage) {
|
|
6348
|
+
flags.customError = true;
|
|
6349
|
+
}
|
|
6350
|
+
message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);
|
|
6351
|
+
internals.setValidity(flags, message);
|
|
6352
|
+
}
|
|
6353
|
+
componentDidLoad() {
|
|
6354
|
+
this.initialValue = this.value;
|
|
6355
|
+
this.syncForm();
|
|
6356
|
+
this.host.addEventListener('change', this.markTouched);
|
|
6357
|
+
this.host.addEventListener('focusout', this.markTouched);
|
|
6358
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
6359
|
+
}
|
|
6360
|
+
markTouched = () => {
|
|
6361
|
+
this.host.setAttribute('data-touched', '');
|
|
6362
|
+
};
|
|
6363
|
+
formResetCallback() {
|
|
6364
|
+
this.value = this.initialValue;
|
|
6365
|
+
}
|
|
6366
|
+
formDisabledCallback(isDisabled) {
|
|
6367
|
+
this.formDisabled = isDisabled;
|
|
6368
|
+
}
|
|
5835
6369
|
get describedBy() {
|
|
5836
6370
|
if (this.invalid && this.errorMessage) {
|
|
5837
6371
|
return this.errorId;
|
|
@@ -5842,27 +6376,43 @@ class ChSelect {
|
|
|
5842
6376
|
return undefined;
|
|
5843
6377
|
}
|
|
5844
6378
|
render() {
|
|
5845
|
-
return (hAsync(Host, { key: '
|
|
5846
|
-
}
|
|
6379
|
+
return (hAsync(Host, { key: 'b3336d43945543f23e903df41eaefef23fde6ff4' }, this.label && (hAsync("label", { key: '1928d359fce76001c24c969ccc59c5bc7c67e676', class: "label", htmlFor: this.selectId }, this.label)), hAsync("select", { key: '7896282971021ef35d9bd3926335e02bc0efc804', id: this.label ? this.selectId : undefined, class: { 'select': true, 'select--invalid': this.invalid }, name: this.name, disabled: this.disabled || this.formDisabled, required: this.required, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }, this.placeholder && (hAsync("option", { key: '4acfff84e5616092c6a8d0741cdf6bf959a4cfee', value: "", disabled: true, hidden: true, selected: !this.value }, this.placeholder)), this.options.map(option => (hAsync("option", { value: option.value, disabled: option.disabled, selected: option.value === this.value }, option.label)))), this.hint && !(this.invalid && this.errorMessage) && (hAsync("p", { key: 'cb079b5ed1a64e53b6bc3ba07f63dee0baa0f78f', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (hAsync("p", { key: '87e730d857a4a8c44378c98759ac8ecc7cfde366', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
6380
|
+
}
|
|
6381
|
+
static get formAssociated() { return true; }
|
|
6382
|
+
static get watchers() { return {
|
|
6383
|
+
"value": [{
|
|
6384
|
+
"syncForm": 0
|
|
6385
|
+
}],
|
|
6386
|
+
"required": [{
|
|
6387
|
+
"syncForm": 0
|
|
6388
|
+
}],
|
|
6389
|
+
"invalid": [{
|
|
6390
|
+
"syncForm": 0
|
|
6391
|
+
}],
|
|
6392
|
+
"errorMessage": [{
|
|
6393
|
+
"syncForm": 0
|
|
6394
|
+
}]
|
|
6395
|
+
}; }
|
|
5847
6396
|
static get style() { return chSelectCss(); }
|
|
5848
6397
|
static get cmpMeta() { return {
|
|
5849
|
-
"$flags$":
|
|
6398
|
+
"$flags$": 585,
|
|
5850
6399
|
"$tagName$": "ch-select",
|
|
5851
6400
|
"$members$": {
|
|
5852
6401
|
"label": [1],
|
|
5853
6402
|
"options": [16],
|
|
5854
6403
|
"value": [1025],
|
|
5855
6404
|
"placeholder": [1],
|
|
5856
|
-
"name": [
|
|
5857
|
-
"disabled": [
|
|
5858
|
-
"required": [
|
|
6405
|
+
"name": [513],
|
|
6406
|
+
"disabled": [516],
|
|
6407
|
+
"required": [516],
|
|
5859
6408
|
"hint": [1],
|
|
5860
6409
|
"errorMessage": [1, "error-message"],
|
|
5861
|
-
"invalid": [4]
|
|
6410
|
+
"invalid": [4],
|
|
6411
|
+
"formDisabled": [32]
|
|
5862
6412
|
},
|
|
5863
6413
|
"$listeners$": undefined,
|
|
5864
6414
|
"$lazyBundleId$": "-",
|
|
5865
|
-
"$attrsToReflect$": []
|
|
6415
|
+
"$attrsToReflect$": [["name", "name"], ["disabled", "disabled"], ["required", "required"]]
|
|
5866
6416
|
}; }
|
|
5867
6417
|
}
|
|
5868
6418
|
|
|
@@ -5911,17 +6461,28 @@ class ChSpinner {
|
|
|
5911
6461
|
}; }
|
|
5912
6462
|
}
|
|
5913
6463
|
|
|
5914
|
-
const chSwitchCss = () => `:host{display:inline-block}.control{position:relative;display:inline-flex;align-items:center;gap:var(--spacing-lg);cursor:pointer}.control--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}.input:focus-visible~.track{outline:var(--focus-outline-width) solid var(--accent);outline-offset:var(--focus-outline-offset)}.track{position:relative;box-sizing:border-box;width:var(--spacing-6xl);height:var(--spacing-5xl);flex-shrink:0;border:var(--border-width) solid var(--border);border-radius:var(--radius-pill);background:var(--surface);transition:border-color var(--duration-normal) var(--easing-default), background-color var(--duration-normal) var(--easing-default)}.thumb{position:absolute;top:50%;left:var(--spacing-2xs);width:var(--spacing-2xl);height:var(--spacing-2xl);border-radius:50%;background:var(--text-muted);transform:translateY(-50%);transition:left var(--duration-normal) var(--easing-default), background-color var(--duration-normal) var(--easing-default)}.input:checked~.track{border-color:var(--accent);background:var(--accent)}.input:checked~.track .thumb{left:calc(100% - var(--spacing-2xl) - var(--spacing-2xs));background:var(--color-accent-text)}.input--invalid~.track{border-color:var(--color-status-warning)}.input--invalid:focus-visible~.track{outline-color:var(--color-status-warning)}.label-text{color:var(--text)}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
6464
|
+
const chSwitchCss = () => `:host{display:inline-block}.control{position:relative;display:inline-flex;align-items:center;gap:var(--spacing-lg);cursor:pointer}.control--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}.input:focus-visible~.track{outline:var(--focus-outline-width) solid var(--accent);outline-offset:var(--focus-outline-offset)}.track{position:relative;box-sizing:border-box;width:var(--spacing-6xl);height:var(--spacing-5xl);flex-shrink:0;border:var(--border-width) solid var(--border);border-radius:var(--radius-pill);background:var(--surface);transition:border-color var(--duration-normal) var(--easing-default), background-color var(--duration-normal) var(--easing-default)}.thumb{position:absolute;top:50%;left:var(--spacing-2xs);width:var(--spacing-2xl);height:var(--spacing-2xl);border-radius:50%;background:var(--text-muted);transform:translateY(-50%);transition:left var(--duration-normal) var(--easing-default), background-color var(--duration-normal) var(--easing-default)}.input:checked~.track{border-color:var(--accent);background:var(--accent)}.input:checked~.track .thumb{left:calc(100% - var(--spacing-2xl) - var(--spacing-2xs));background:var(--color-accent-text)}.input--invalid~.track{border-color:var(--color-status-warning)}.input--invalid:focus-visible~.track{outline-color:var(--color-status-warning)}:host([data-touched]:invalid) .track,:host(:user-invalid) .track{border-color:var(--color-status-warning)}:host([data-touched]:invalid) .input:focus-visible~.track,:host(:user-invalid) .input:focus-visible~.track{outline-color:var(--color-status-warning)}.label-text{color:var(--text)}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
5915
6465
|
|
|
5916
6466
|
let switchIds = 0;
|
|
5917
6467
|
class ChSwitch {
|
|
5918
6468
|
constructor(hostRef) {
|
|
5919
6469
|
registerInstance(this, hostRef);
|
|
5920
6470
|
this.chChange = createEvent(this, "chChange");
|
|
6471
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
6472
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
6473
|
+
}
|
|
6474
|
+
else {
|
|
6475
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
6476
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
6477
|
+
}
|
|
5921
6478
|
}
|
|
5922
6479
|
switchId = `ch-switch-${++switchIds}`;
|
|
5923
6480
|
hintId = `${this.switchId}-hint`;
|
|
5924
6481
|
errorId = `${this.switchId}-error`;
|
|
6482
|
+
initialChecked = false;
|
|
6483
|
+
internals;
|
|
6484
|
+
formDisabled = false;
|
|
6485
|
+
get host() { return getElement(this); }
|
|
5925
6486
|
/**
|
|
5926
6487
|
* Visible label rendered next to the switch, associated with it via
|
|
5927
6488
|
* `for`/`id`, so assistive technology announces the switch's purpose.
|
|
@@ -5968,6 +6529,39 @@ class ChSwitch {
|
|
|
5968
6529
|
this.checked = ev.target.checked;
|
|
5969
6530
|
this.chChange.emit(this.checked);
|
|
5970
6531
|
};
|
|
6532
|
+
syncForm() {
|
|
6533
|
+
const internals = this.internals;
|
|
6534
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
6535
|
+
return;
|
|
6536
|
+
}
|
|
6537
|
+
internals.setFormValue(this.checked ? this.value : null);
|
|
6538
|
+
const flags = {};
|
|
6539
|
+
let message;
|
|
6540
|
+
if (this.required && !this.checked) {
|
|
6541
|
+
flags.valueMissing = true;
|
|
6542
|
+
}
|
|
6543
|
+
if (this.invalid && this.errorMessage) {
|
|
6544
|
+
flags.customError = true;
|
|
6545
|
+
}
|
|
6546
|
+
message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);
|
|
6547
|
+
internals.setValidity(flags, message);
|
|
6548
|
+
}
|
|
6549
|
+
componentDidLoad() {
|
|
6550
|
+
this.initialChecked = this.checked;
|
|
6551
|
+
this.syncForm();
|
|
6552
|
+
this.host.addEventListener('change', this.markTouched);
|
|
6553
|
+
this.host.addEventListener('focusout', this.markTouched);
|
|
6554
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
6555
|
+
}
|
|
6556
|
+
markTouched = () => {
|
|
6557
|
+
this.host.setAttribute('data-touched', '');
|
|
6558
|
+
};
|
|
6559
|
+
formResetCallback() {
|
|
6560
|
+
this.checked = this.initialChecked;
|
|
6561
|
+
}
|
|
6562
|
+
formDisabledCallback(isDisabled) {
|
|
6563
|
+
this.formDisabled = isDisabled;
|
|
6564
|
+
}
|
|
5971
6565
|
get describedBy() {
|
|
5972
6566
|
if (this.invalid && this.errorMessage) {
|
|
5973
6567
|
return this.errorId;
|
|
@@ -5978,26 +6572,42 @@ class ChSwitch {
|
|
|
5978
6572
|
return undefined;
|
|
5979
6573
|
}
|
|
5980
6574
|
render() {
|
|
5981
|
-
return (hAsync(Host, { key: '
|
|
5982
|
-
}
|
|
6575
|
+
return (hAsync(Host, { key: '1f868bf2f0a95e5eb0b0013de2a1414034a0af78' }, hAsync("label", { key: 'bfa3ff8ca66a9c367882808718b882bb1679d5fd', class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled }, htmlFor: this.switchId }, hAsync("input", { key: '49d10196b6df781b1e76d0b33118cc21294136f4', 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 }), hAsync("span", { key: '79948dc41567e2c52023e1c0ddd17888b4a04335', class: "track" }, hAsync("span", { key: 'd07b297ff5edd963954e4ab2b7e678176a1823f6', class: "thumb" })), this.label && hAsync("span", { key: '33695230dab7fc68c0dc1b06cc21b7f8bf7bb1ec', class: "label-text" }, this.label)), this.hint && !(this.invalid && this.errorMessage) && (hAsync("p", { key: '3be08bad4526e8c1adde62a154654079b17d6910', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (hAsync("p", { key: '623cff85e039ecb640238d9e41fd3aa82c671ddd', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
6576
|
+
}
|
|
6577
|
+
static get formAssociated() { return true; }
|
|
6578
|
+
static get watchers() { return {
|
|
6579
|
+
"checked": [{
|
|
6580
|
+
"syncForm": 0
|
|
6581
|
+
}],
|
|
6582
|
+
"required": [{
|
|
6583
|
+
"syncForm": 0
|
|
6584
|
+
}],
|
|
6585
|
+
"invalid": [{
|
|
6586
|
+
"syncForm": 0
|
|
6587
|
+
}],
|
|
6588
|
+
"errorMessage": [{
|
|
6589
|
+
"syncForm": 0
|
|
6590
|
+
}]
|
|
6591
|
+
}; }
|
|
5983
6592
|
static get style() { return chSwitchCss(); }
|
|
5984
6593
|
static get cmpMeta() { return {
|
|
5985
|
-
"$flags$":
|
|
6594
|
+
"$flags$": 585,
|
|
5986
6595
|
"$tagName$": "ch-switch",
|
|
5987
6596
|
"$members$": {
|
|
5988
6597
|
"label": [1],
|
|
5989
|
-
"name": [
|
|
6598
|
+
"name": [513],
|
|
5990
6599
|
"value": [1],
|
|
5991
6600
|
"checked": [1028],
|
|
5992
|
-
"disabled": [
|
|
5993
|
-
"required": [
|
|
6601
|
+
"disabled": [516],
|
|
6602
|
+
"required": [516],
|
|
5994
6603
|
"hint": [1],
|
|
5995
6604
|
"errorMessage": [1, "error-message"],
|
|
5996
|
-
"invalid": [4]
|
|
6605
|
+
"invalid": [4],
|
|
6606
|
+
"formDisabled": [32]
|
|
5997
6607
|
},
|
|
5998
6608
|
"$listeners$": undefined,
|
|
5999
6609
|
"$lazyBundleId$": "-",
|
|
6000
|
-
"$attrsToReflect$": []
|
|
6610
|
+
"$attrsToReflect$": [["name", "name"], ["disabled", "disabled"], ["required", "required"]]
|
|
6001
6611
|
}; }
|
|
6002
6612
|
}
|
|
6003
6613
|
|
|
@@ -6105,7 +6715,7 @@ class ChTabs {
|
|
|
6105
6715
|
}; }
|
|
6106
6716
|
}
|
|
6107
6717
|
|
|
6108
|
-
const chTextareaCss = () => `:host{display:inline-block;width:100%}.label{display:block;margin-bottom:var(--spacing-sm);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);color:var(--text)}.textarea{box-sizing:border-box;width:100%;min-height:var(--spacing-6xl);padding:var(--spacing-xl) var(--spacing-3xl);border-radius:var(--radius);border:var(--border-width) solid var(--border);background:var(--surface);color:var(--text);backdrop-filter:blur(var(--effect-blur));font-family:inherit;font-size:inherit;line-height:var(--spacing-5xl);resize:vertical;transition:border-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.textarea::placeholder{color:var(--text-muted)}.textarea:focus{border-color:var(--accent);box-shadow:var(--shadow-focus-ring);outline:none}.textarea--invalid{border-color:var(--color-status-warning)}.textarea--invalid:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}.textarea:disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
6718
|
+
const chTextareaCss = () => `:host{display:inline-block;width:100%}.label{display:block;margin-bottom:var(--spacing-sm);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);color:var(--text)}.textarea{box-sizing:border-box;width:100%;min-height:var(--spacing-6xl);padding:var(--spacing-xl) var(--spacing-3xl);border-radius:var(--radius);border:var(--border-width) solid var(--border);background:var(--surface);color:var(--text);backdrop-filter:blur(var(--effect-blur));font-family:inherit;font-size:inherit;line-height:var(--spacing-5xl);resize:vertical;transition:border-color var(--duration-normal) var(--easing-default), box-shadow var(--duration-normal) var(--easing-default)}.textarea::placeholder{color:var(--text-muted)}.textarea:focus{border-color:var(--accent);box-shadow:var(--shadow-focus-ring);outline:none}.textarea--invalid{border-color:var(--color-status-warning)}.textarea--invalid:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}:host([data-touched]:invalid) .textarea,:host(:user-invalid) .textarea{border-color:var(--color-status-warning)}:host([data-touched]:invalid) .textarea:focus,:host(:user-invalid) .textarea:focus{border-color:var(--color-status-warning);box-shadow:0 0 0 3px var(--color-status-warning-background)}.textarea:disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--text-muted)}.error{color:var(--color-status-warning)}`;
|
|
6109
6719
|
|
|
6110
6720
|
let textareaIds = 0;
|
|
6111
6721
|
const DEFAULT_ROWS = 4;
|
|
@@ -6114,10 +6724,21 @@ class ChTextarea {
|
|
|
6114
6724
|
registerInstance(this, hostRef);
|
|
6115
6725
|
this.chInput = createEvent(this, "chInput");
|
|
6116
6726
|
this.chChange = createEvent(this, "chChange");
|
|
6727
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
6728
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
6729
|
+
}
|
|
6730
|
+
else {
|
|
6731
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
6732
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
6733
|
+
}
|
|
6117
6734
|
}
|
|
6118
6735
|
textareaId = `ch-textarea-${++textareaIds}`;
|
|
6119
6736
|
hintId = `${this.textareaId}-hint`;
|
|
6120
6737
|
errorId = `${this.textareaId}-error`;
|
|
6738
|
+
initialValue = '';
|
|
6739
|
+
internals;
|
|
6740
|
+
formDisabled = false;
|
|
6741
|
+
get host() { return getElement(this); }
|
|
6121
6742
|
/**
|
|
6122
6743
|
* Visible label rendered above the textarea and associated with it via
|
|
6123
6744
|
* `for`/`id`, so assistive technology announces the textarea's purpose.
|
|
@@ -6176,6 +6797,39 @@ class ChTextarea {
|
|
|
6176
6797
|
this.value = ev.target.value;
|
|
6177
6798
|
this.chChange.emit(this.value);
|
|
6178
6799
|
};
|
|
6800
|
+
syncForm() {
|
|
6801
|
+
const internals = this.internals;
|
|
6802
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
6803
|
+
return;
|
|
6804
|
+
}
|
|
6805
|
+
internals.setFormValue(this.value);
|
|
6806
|
+
const flags = {};
|
|
6807
|
+
let message;
|
|
6808
|
+
if (this.required && this.value === '') {
|
|
6809
|
+
flags.valueMissing = true;
|
|
6810
|
+
}
|
|
6811
|
+
if (this.invalid && this.errorMessage) {
|
|
6812
|
+
flags.customError = true;
|
|
6813
|
+
}
|
|
6814
|
+
message = this.errorMessage ?? (flags.valueMissing ? 'Please fill out this field.' : undefined);
|
|
6815
|
+
internals.setValidity(flags, message);
|
|
6816
|
+
}
|
|
6817
|
+
componentDidLoad() {
|
|
6818
|
+
this.initialValue = this.value;
|
|
6819
|
+
this.syncForm();
|
|
6820
|
+
this.host.addEventListener('change', this.markTouched);
|
|
6821
|
+
this.host.addEventListener('focusout', this.markTouched);
|
|
6822
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
6823
|
+
}
|
|
6824
|
+
markTouched = () => {
|
|
6825
|
+
this.host.setAttribute('data-touched', '');
|
|
6826
|
+
};
|
|
6827
|
+
formResetCallback() {
|
|
6828
|
+
this.value = this.initialValue;
|
|
6829
|
+
}
|
|
6830
|
+
formDisabledCallback(isDisabled) {
|
|
6831
|
+
this.formDisabled = isDisabled;
|
|
6832
|
+
}
|
|
6179
6833
|
get describedBy() {
|
|
6180
6834
|
if (this.invalid && this.errorMessage) {
|
|
6181
6835
|
return this.errorId;
|
|
@@ -6186,26 +6840,145 @@ class ChTextarea {
|
|
|
6186
6840
|
return undefined;
|
|
6187
6841
|
}
|
|
6188
6842
|
render() {
|
|
6189
|
-
return (hAsync(Host, { key: '
|
|
6190
|
-
}
|
|
6843
|
+
return (hAsync(Host, { key: 'de54ff9593c43939689cfbe2e13de538fcc7c022' }, this.label && (hAsync("label", { key: 'bfab3a6e82c1dbb03bd8f3477e6def631eca2e26', class: "label", htmlFor: this.textareaId }, this.label)), hAsync("textarea", { key: 'a2de483052ac7849f9f7ff61b4052d068cf7fcf6', 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) && (hAsync("p", { key: '80e2a1a36274eaff1609b60882dee02c34138687', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (hAsync("p", { key: 'b086d35f6579c56debdb8445aefa79ae953c8734', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
6844
|
+
}
|
|
6845
|
+
static get formAssociated() { return true; }
|
|
6846
|
+
static get watchers() { return {
|
|
6847
|
+
"value": [{
|
|
6848
|
+
"syncForm": 0
|
|
6849
|
+
}],
|
|
6850
|
+
"required": [{
|
|
6851
|
+
"syncForm": 0
|
|
6852
|
+
}],
|
|
6853
|
+
"invalid": [{
|
|
6854
|
+
"syncForm": 0
|
|
6855
|
+
}],
|
|
6856
|
+
"errorMessage": [{
|
|
6857
|
+
"syncForm": 0
|
|
6858
|
+
}]
|
|
6859
|
+
}; }
|
|
6191
6860
|
static get style() { return chTextareaCss(); }
|
|
6192
6861
|
static get cmpMeta() { return {
|
|
6193
|
-
"$flags$":
|
|
6862
|
+
"$flags$": 585,
|
|
6194
6863
|
"$tagName$": "ch-textarea",
|
|
6195
6864
|
"$members$": {
|
|
6196
6865
|
"label": [1],
|
|
6197
6866
|
"value": [1025],
|
|
6198
6867
|
"placeholder": [1],
|
|
6199
6868
|
"rows": [2],
|
|
6200
|
-
"name": [
|
|
6201
|
-
"disabled": [
|
|
6202
|
-
"required": [
|
|
6869
|
+
"name": [513],
|
|
6870
|
+
"disabled": [516],
|
|
6871
|
+
"required": [516],
|
|
6203
6872
|
"hint": [1],
|
|
6204
6873
|
"errorMessage": [1, "error-message"],
|
|
6205
|
-
"invalid": [4]
|
|
6874
|
+
"invalid": [4],
|
|
6875
|
+
"formDisabled": [32]
|
|
6206
6876
|
},
|
|
6207
6877
|
"$listeners$": undefined,
|
|
6208
6878
|
"$lazyBundleId$": "-",
|
|
6879
|
+
"$attrsToReflect$": [["name", "name"], ["disabled", "disabled"], ["required", "required"]]
|
|
6880
|
+
}; }
|
|
6881
|
+
}
|
|
6882
|
+
|
|
6883
|
+
const chTooltipCss = () => `:host{display:inline-block}.anchor{position:relative;display:inline-flex}.bubble{position:absolute;z-index:var(--z-index-dropdown);width:max-content;max-width:16rem;padding:var(--spacing-md) var(--spacing-2xl);border:var(--border-width) solid var(--border);border-radius:var(--radius-sm);background:var(--color-background-base);color:var(--text);font-family:var(--font-body);font-size:var(--typography-size-sm);line-height:1.4;opacity:0;visibility:hidden;transition:opacity var(--duration-fast) var(--easing-default), visibility var(--duration-fast) var(--easing-default)}.bubble--visible{opacity:1;visibility:visible}.bubble::before{content:'';position:absolute}.bubble--top{bottom:100%;left:50%;transform:translateX(-50%);margin-bottom:var(--spacing-md)}.bubble--top::before{top:100%;left:0;right:0;height:var(--spacing-md)}.bubble--bottom{top:100%;left:50%;transform:translateX(-50%);margin-top:var(--spacing-md)}.bubble--bottom::before{bottom:100%;left:0;right:0;height:var(--spacing-md)}.bubble--left{right:100%;top:50%;transform:translateY(-50%);margin-right:var(--spacing-md)}.bubble--left::before{left:100%;top:0;bottom:0;width:var(--spacing-md)}.bubble--right{left:100%;top:50%;transform:translateY(-50%);margin-left:var(--spacing-md)}.bubble--right::before{right:100%;top:0;bottom:0;width:var(--spacing-md)}@media (prefers-reduced-motion: reduce){.bubble{transition:none}}`;
|
|
6884
|
+
|
|
6885
|
+
let tooltipIds = 0;
|
|
6886
|
+
/**
|
|
6887
|
+
* Short help text shown on hover and on focus.
|
|
6888
|
+
*
|
|
6889
|
+
* Both the trigger and the text come from the consumer's light DOM through
|
|
6890
|
+
* named slots. That is what makes the accessible association work: an
|
|
6891
|
+
* `aria-describedby` IDREF only resolves within a single tree, and slotted
|
|
6892
|
+
* nodes stay in the document tree even though they render inside the shadow
|
|
6893
|
+
* root. Keeping the text in the shadow root instead would need a reference
|
|
6894
|
+
* pointing into a shadow tree, which the platform does not allow — element
|
|
6895
|
+
* reflection only points outwards, and `referenceTarget` is not available yet.
|
|
6896
|
+
*
|
|
6897
|
+
* The trigger has to be a natively focusable element (`<button>`, `<a>`,
|
|
6898
|
+
* `<input>`). A chucao component such as `ch-button` will not be described,
|
|
6899
|
+
* because `aria-*` set on a custom element host does not reach the native
|
|
6900
|
+
* element inside it — see the discussion in issue #47.
|
|
6901
|
+
*/
|
|
6902
|
+
class ChTooltip {
|
|
6903
|
+
constructor(hostRef) {
|
|
6904
|
+
registerInstance(this, hostRef);
|
|
6905
|
+
}
|
|
6906
|
+
get el() { return getElement(this); }
|
|
6907
|
+
fallbackId = `ch-tooltip-${++tooltipIds}`;
|
|
6908
|
+
/**
|
|
6909
|
+
* Which side of the trigger the bubble is placed on.
|
|
6910
|
+
*/
|
|
6911
|
+
placement = 'top';
|
|
6912
|
+
// Hover and focus are tracked apart so that neither cancels the other: a
|
|
6913
|
+
// pointer passing over and away must not hide a tooltip whose trigger still
|
|
6914
|
+
// holds keyboard focus.
|
|
6915
|
+
hovered = false;
|
|
6916
|
+
focused = false;
|
|
6917
|
+
dismissed = false;
|
|
6918
|
+
get visible() {
|
|
6919
|
+
return (this.hovered || this.focused) && !this.dismissed;
|
|
6920
|
+
}
|
|
6921
|
+
componentDidLoad() {
|
|
6922
|
+
this.associate();
|
|
6923
|
+
}
|
|
6924
|
+
handleMouseEnter() {
|
|
6925
|
+
this.hovered = true;
|
|
6926
|
+
this.dismissed = false;
|
|
6927
|
+
}
|
|
6928
|
+
handleMouseLeave() {
|
|
6929
|
+
this.hovered = false;
|
|
6930
|
+
}
|
|
6931
|
+
handleFocusIn() {
|
|
6932
|
+
this.focused = true;
|
|
6933
|
+
this.dismissed = false;
|
|
6934
|
+
}
|
|
6935
|
+
handleFocusOut() {
|
|
6936
|
+
this.focused = false;
|
|
6937
|
+
}
|
|
6938
|
+
/**
|
|
6939
|
+
* Listens on the document because a tooltip opened by hovering leaves focus
|
|
6940
|
+
* wherever it was, so a host-scoped handler would never see the key.
|
|
6941
|
+
*/
|
|
6942
|
+
handleKeyDown(event) {
|
|
6943
|
+
if (event.key === 'Escape' && this.visible) {
|
|
6944
|
+
this.dismissed = true;
|
|
6945
|
+
}
|
|
6946
|
+
}
|
|
6947
|
+
slotted(name) {
|
|
6948
|
+
return Array.from(this.el.children).find(child => child.getAttribute('slot') === name);
|
|
6949
|
+
}
|
|
6950
|
+
/**
|
|
6951
|
+
* Points the trigger at the text with `aria-describedby`. Re-run on
|
|
6952
|
+
* `slotchange` because a framework re-render can replace the slotted nodes
|
|
6953
|
+
* and take the attributes with them.
|
|
6954
|
+
*/
|
|
6955
|
+
associate = () => {
|
|
6956
|
+
const trigger = this.slotted('trigger');
|
|
6957
|
+
const content = this.slotted('content');
|
|
6958
|
+
if (!trigger || !content) {
|
|
6959
|
+
return;
|
|
6960
|
+
}
|
|
6961
|
+
if (!content.id) {
|
|
6962
|
+
content.id = this.fallbackId;
|
|
6963
|
+
}
|
|
6964
|
+
content.setAttribute('role', 'tooltip');
|
|
6965
|
+
trigger.setAttribute('aria-describedby', content.id);
|
|
6966
|
+
};
|
|
6967
|
+
render() {
|
|
6968
|
+
return (hAsync(Host, { key: '654d4a12f84c94e014691e911e7c63c6c45b8755' }, hAsync("span", { key: '726269e02fedc37efc39f1561d8b9baf83d6a4cc', class: "anchor" }, hAsync("slot", { key: '876cb19249032d6d1c66f22bd2c255683b6a7f66', name: "trigger", onSlotchange: this.associate }), hAsync("span", { key: '7436eb75b40b33d0b6c8ce194245d4a08a29facb', class: { 'bubble': true, [`bubble--${this.placement}`]: true, 'bubble--visible': this.visible } }, hAsync("slot", { key: '24648cc6078d61803793df011058da9515b466b5', name: "content", onSlotchange: this.associate })))));
|
|
6969
|
+
}
|
|
6970
|
+
static get style() { return chTooltipCss(); }
|
|
6971
|
+
static get cmpMeta() { return {
|
|
6972
|
+
"$flags$": 777,
|
|
6973
|
+
"$tagName$": "ch-tooltip",
|
|
6974
|
+
"$members$": {
|
|
6975
|
+
"placement": [1],
|
|
6976
|
+
"hovered": [32],
|
|
6977
|
+
"focused": [32],
|
|
6978
|
+
"dismissed": [32]
|
|
6979
|
+
},
|
|
6980
|
+
"$listeners$": [[1, "mouseenter", "handleMouseEnter"], [1, "mouseleave", "handleMouseLeave"], [0, "focusin", "handleFocusIn"], [0, "focusout", "handleFocusOut"], [4, "keydown", "handleKeyDown"]],
|
|
6981
|
+
"$lazyBundleId$": "-",
|
|
6209
6982
|
"$attrsToReflect$": []
|
|
6210
6983
|
}; }
|
|
6211
6984
|
}
|
|
@@ -6220,12 +6993,14 @@ registerComponents([
|
|
|
6220
6993
|
ChDivider,
|
|
6221
6994
|
ChInput,
|
|
6222
6995
|
ChLink,
|
|
6996
|
+
ChModal,
|
|
6223
6997
|
ChRadio,
|
|
6224
6998
|
ChSelect,
|
|
6225
6999
|
ChSpinner,
|
|
6226
7000
|
ChSwitch,
|
|
6227
7001
|
ChTabs,
|
|
6228
7002
|
ChTextarea,
|
|
7003
|
+
ChTooltip,
|
|
6229
7004
|
]);
|
|
6230
7005
|
|
|
6231
7006
|
exports.hydrateApp = hydrateApp;
|