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