@swisspost/design-system-components 1.5.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/check-non-empty-ae713942.js +13 -0
- package/dist/cjs/check-non-empty-ae713942.js.map +1 -0
- package/dist/cjs/{check-one-of-4c2e8b2e.js → check-one-of-27ad3154.js} +1 -1
- package/dist/cjs/check-one-of-27ad3154.js.map +1 -0
- package/dist/cjs/constants-238701d3.js +7 -0
- package/dist/cjs/constants-238701d3.js.map +1 -0
- package/dist/cjs/fade-35a3633a.js +12 -0
- package/dist/cjs/fade-35a3633a.js.map +1 -0
- package/dist/cjs/index-b38a23e0.js +41 -0
- package/dist/cjs/index-b38a23e0.js.map +1 -0
- package/dist/cjs/{index-12cc37c9.js → index-b619e205.js} +245 -41
- package/dist/cjs/index-b619e205.js.map +1 -0
- package/dist/cjs/loader.cjs.js +3 -12
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/package-bd70f73c.js +7 -0
- package/dist/cjs/package-bd70f73c.js.map +1 -0
- package/dist/cjs/post-accordion.cjs.entry.js +89 -0
- package/dist/cjs/post-accordion.cjs.entry.js.map +1 -0
- package/dist/cjs/post-alert.cjs.entry.js +10 -10
- package/dist/cjs/post-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/post-collapsible.cjs.entry.js +49 -80
- package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
- package/dist/cjs/post-components.cjs.js +3 -6
- package/dist/cjs/post-components.cjs.js.map +1 -1
- package/dist/cjs/post-icon.cjs.entry.js +7 -7
- package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tab-header.cjs.entry.js +5 -4
- package/dist/cjs/post-tab-header.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tab-panel.cjs.entry.js +2 -2
- package/dist/cjs/post-tab-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tabs.cjs.entry.js +3 -3
- package/dist/cjs/post-tabs.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/post-tooltip.cjs.entry.js.map +1 -1
- package/dist/collection/animations/collapse.js +13 -0
- package/dist/collection/animations/collapse.js.map +1 -0
- package/dist/collection/animations/fade.js +4 -4
- package/dist/collection/animations/fade.js.map +1 -1
- package/dist/collection/collection-manifest.json +10 -9
- package/dist/collection/components/post-accordion/post-accordion.css +1 -0
- package/dist/collection/components/post-accordion/post-accordion.js +178 -0
- package/dist/collection/components/post-accordion/post-accordion.js.map +1 -0
- package/dist/collection/components/post-alert/post-alert.css +1 -1
- package/dist/collection/components/post-alert/post-alert.js +9 -7
- package/dist/collection/components/post-alert/post-alert.js.map +1 -1
- package/dist/collection/components/post-collapsible/heading-levels.js +2 -0
- package/dist/collection/components/post-collapsible/heading-levels.js.map +1 -0
- package/dist/collection/components/post-collapsible/post-collapsible.css +1 -29
- package/dist/collection/components/post-collapsible/post-collapsible.js +65 -63
- package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -1
- package/dist/collection/components/post-icon/post-icon.js +5 -4
- package/dist/collection/components/post-icon/post-icon.js.map +1 -1
- package/dist/collection/components/post-tab-header/post-tab-header.css +1 -1
- package/dist/collection/components/post-tab-header/post-tab-header.js +5 -4
- package/dist/collection/components/post-tab-header/post-tab-header.js.map +1 -1
- package/dist/collection/components/post-tab-panel/post-tab-panel.js +2 -2
- package/dist/collection/components/post-tabs/post-tabs.js +11 -7
- package/dist/collection/components/post-tabs/post-tabs.js.map +1 -1
- package/dist/collection/components/post-tooltip/post-tooltip.js +22 -15
- package/dist/collection/components/post-tooltip/post-tooltip.js.map +1 -1
- package/dist/collection/utils/index.js +1 -3
- package/dist/collection/utils/index.js.map +1 -1
- package/dist/collection/utils/is-motion-reduced.js +4 -0
- package/dist/collection/utils/is-motion-reduced.js.map +1 -0
- package/dist/collection/utils/property-checkers/check-non-empty.js +1 -1
- package/dist/collection/utils/property-checkers/empty-or.js +1 -1
- package/dist/collection/utils/property-checkers/index.js +4 -4
- package/dist/components/check-non-empty.js +2 -2
- package/dist/components/check-non-empty.js.map +1 -1
- package/dist/components/check-one-of.js.map +1 -1
- package/dist/components/constants.js +5 -0
- package/dist/components/constants.js.map +1 -0
- package/dist/components/fade.js +4 -4
- package/dist/components/fade.js.map +1 -1
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +36 -0
- package/dist/components/index2.js.map +1 -0
- package/dist/components/package.js +1 -1
- package/dist/components/post-accordion.d.ts +11 -0
- package/dist/components/post-accordion.js +108 -0
- package/dist/components/post-accordion.js.map +1 -0
- package/dist/components/post-alert.js +9 -3
- package/dist/components/post-alert.js.map +1 -1
- package/dist/components/post-collapsible.js +51 -84
- package/dist/components/post-collapsible.js.map +1 -1
- package/dist/components/post-icon2.js +11 -21
- package/dist/components/post-icon2.js.map +1 -1
- package/dist/components/post-tab-header.js +3 -1
- package/dist/components/post-tab-header.js.map +1 -1
- package/dist/components/post-tab-panel.js.map +1 -1
- package/dist/components/post-tabs.js.map +1 -1
- package/dist/components/post-tooltip.js +2 -0
- package/dist/components/post-tooltip.js.map +1 -1
- package/dist/docs.d.ts +334 -235
- package/dist/docs.json +458 -14
- package/dist/esm/check-non-empty-09c39561.js +11 -0
- package/dist/esm/check-non-empty-09c39561.js.map +1 -0
- package/dist/esm/{check-one-of-ded5e15e.js → check-one-of-74750af9.js} +1 -1
- package/dist/esm/check-one-of-74750af9.js.map +1 -0
- package/dist/esm/constants-8d548297.js +5 -0
- package/dist/esm/constants-8d548297.js.map +1 -0
- package/dist/esm/fade-7fd71785.js +9 -0
- package/dist/esm/fade-7fd71785.js.map +1 -0
- package/dist/esm/index-35921354.js +36 -0
- package/dist/esm/index-35921354.js.map +1 -0
- package/dist/esm/{index-5611074b.js → index-4eff5fc5.js} +245 -41
- package/dist/esm/index-4eff5fc5.js.map +1 -0
- package/dist/esm/loader.js +4 -13
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/package-f3f12016.js +5 -0
- package/dist/esm/package-f3f12016.js.map +1 -0
- package/dist/esm/post-accordion.entry.js +85 -0
- package/dist/esm/post-accordion.entry.js.map +1 -0
- package/dist/esm/post-alert.entry.js +8 -8
- package/dist/esm/post-alert.entry.js.map +1 -1
- package/dist/esm/post-collapsible.entry.js +49 -80
- package/dist/esm/post-collapsible.entry.js.map +1 -1
- package/dist/esm/post-components.js +4 -7
- package/dist/esm/post-components.js.map +1 -1
- package/dist/esm/post-icon.entry.js +6 -6
- package/dist/esm/post-icon.entry.js.map +1 -1
- package/dist/esm/post-tab-header.entry.js +5 -4
- package/dist/esm/post-tab-header.entry.js.map +1 -1
- package/dist/esm/post-tab-panel.entry.js +2 -2
- package/dist/esm/post-tab-panel.entry.js.map +1 -1
- package/dist/esm/post-tabs.entry.js +3 -3
- package/dist/esm/post-tabs.entry.js.map +1 -1
- package/dist/esm/post-tooltip.entry.js +3 -3
- package/dist/esm/post-tooltip.entry.js.map +1 -1
- package/dist/post-components/p-08d942a0.entry.js +2 -0
- package/dist/post-components/p-08d942a0.entry.js.map +1 -0
- package/dist/post-components/{p-7240ae7b.entry.js → p-10c47e0a.entry.js} +2 -2
- package/dist/post-components/p-10c47e0a.entry.js.map +1 -0
- package/dist/post-components/{p-bcc705f1.js → p-1339f8cd.js} +1 -1
- package/dist/post-components/p-1339f8cd.js.map +1 -0
- package/dist/post-components/{p-e5306504.js → p-2737eaf5.js} +1 -1
- package/dist/post-components/p-2737eaf5.js.map +1 -0
- package/dist/post-components/{p-123bb6fb.entry.js → p-2755ba2e.entry.js} +2 -2
- package/dist/post-components/p-2755ba2e.entry.js.map +1 -0
- package/dist/post-components/p-440193f4.js +2 -0
- package/dist/post-components/p-440193f4.js.map +1 -0
- package/dist/post-components/p-4aae941f.js +2 -0
- package/dist/post-components/p-6a0a1ce4.entry.js +2 -0
- package/dist/post-components/p-6a0a1ce4.entry.js.map +1 -0
- package/dist/post-components/p-7d91397a.entry.js +2 -0
- package/dist/post-components/p-7d91397a.entry.js.map +1 -0
- package/dist/post-components/p-871ade93.entry.js +2 -0
- package/dist/post-components/p-871ade93.entry.js.map +1 -0
- package/dist/post-components/p-a18e1d1c.entry.js +2 -0
- package/dist/post-components/p-a18e1d1c.entry.js.map +1 -0
- package/dist/post-components/p-a7649277.js +3 -0
- package/dist/post-components/p-a7649277.js.map +1 -0
- package/dist/post-components/{p-8c386036.entry.js → p-b4b7e30c.entry.js} +2 -2
- package/dist/post-components/p-b4b7e30c.entry.js.map +1 -0
- package/dist/post-components/p-b531475e.js +2 -0
- package/dist/post-components/p-b531475e.js.map +1 -0
- package/dist/post-components/p-dfe29f7f.js +2 -0
- package/dist/post-components/p-dfe29f7f.js.map +1 -0
- package/dist/post-components/post-components.esm.js +1 -1
- package/dist/post-components/post-components.esm.js.map +1 -1
- package/dist/types/animations/collapse.d.ts +2 -0
- package/dist/types/components/post-accordion/post-accordion.d.ts +28 -0
- package/dist/types/components/post-alert/post-alert.d.ts +1 -1
- package/dist/types/components/post-collapsible/heading-levels.d.ts +2 -0
- package/dist/types/components/post-collapsible/post-collapsible.d.ts +16 -12
- package/dist/types/components.d.ts +79 -3
- package/dist/types/stencil-public-runtime.d.ts +38 -5
- package/dist/types/utils/index.d.ts +1 -3
- package/dist/types/utils/is-motion-reduced.d.ts +1 -0
- package/loader/index.d.ts +1 -1
- package/package.json +5 -5
- package/dist/cjs/check-non-empty-35b4d0b5.js +0 -14
- package/dist/cjs/check-non-empty-35b4d0b5.js.map +0 -1
- package/dist/cjs/check-one-of-4c2e8b2e.js.map +0 -1
- package/dist/cjs/check-type-508a21a5.js +0 -18
- package/dist/cjs/check-type-508a21a5.js.map +0 -1
- package/dist/cjs/fade-8c6d4fa7.js +0 -12
- package/dist/cjs/fade-8c6d4fa7.js.map +0 -1
- package/dist/cjs/index-12cc37c9.js.map +0 -1
- package/dist/cjs/index-f8f6f146.js +0 -28
- package/dist/cjs/index-f8f6f146.js.map +0 -1
- package/dist/cjs/package-112e1698.js +0 -7
- package/dist/cjs/package-112e1698.js.map +0 -1
- package/dist/collection/utils/get-element-height.js +0 -12
- package/dist/collection/utils/get-element-height.js.map +0 -1
- package/dist/collection/utils/on-transition-end.js +0 -15
- package/dist/collection/utils/on-transition-end.js.map +0 -1
- package/dist/collection/utils/should-reduce-motion.js +0 -4
- package/dist/collection/utils/should-reduce-motion.js.map +0 -1
- package/dist/components/check-type.js +0 -16
- package/dist/components/check-type.js.map +0 -1
- package/dist/esm/check-non-empty-554bdf88.js +0 -11
- package/dist/esm/check-non-empty-554bdf88.js.map +0 -1
- package/dist/esm/check-one-of-ded5e15e.js.map +0 -1
- package/dist/esm/check-type-18ebb4e7.js +0 -16
- package/dist/esm/check-type-18ebb4e7.js.map +0 -1
- package/dist/esm/fade-671f1489.js +0 -9
- package/dist/esm/fade-671f1489.js.map +0 -1
- package/dist/esm/index-5611074b.js.map +0 -1
- package/dist/esm/index-7f723686.js +0 -24
- package/dist/esm/index-7f723686.js.map +0 -1
- package/dist/esm/package-331628f1.js +0 -5
- package/dist/esm/package-331628f1.js.map +0 -1
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/post-components/p-0d37fe44.entry.js +0 -2
- package/dist/post-components/p-0d37fe44.entry.js.map +0 -1
- package/dist/post-components/p-123bb6fb.entry.js.map +0 -1
- package/dist/post-components/p-15fc087f.js +0 -2
- package/dist/post-components/p-15fc087f.js.map +0 -1
- package/dist/post-components/p-65a9d1c2.entry.js +0 -2
- package/dist/post-components/p-65a9d1c2.entry.js.map +0 -1
- package/dist/post-components/p-7240ae7b.entry.js.map +0 -1
- package/dist/post-components/p-75a7b352.js +0 -2
- package/dist/post-components/p-75a7b352.js.map +0 -1
- package/dist/post-components/p-8c386036.entry.js.map +0 -1
- package/dist/post-components/p-97a064da.entry.js +0 -2
- package/dist/post-components/p-97a064da.entry.js.map +0 -1
- package/dist/post-components/p-bcc705f1.js.map +0 -1
- package/dist/post-components/p-c8efe0ae.js +0 -2
- package/dist/post-components/p-c8efe0ae.js.map +0 -1
- package/dist/post-components/p-ccae1c68.entry.js +0 -2
- package/dist/post-components/p-ccae1c68.entry.js.map +0 -1
- package/dist/post-components/p-d94db268.js +0 -3
- package/dist/post-components/p-d94db268.js.map +0 -1
- package/dist/post-components/p-e5306504.js.map +0 -1
- package/dist/post-components/p-eb3ff4dc.js +0 -2
- package/dist/types/utils/get-element-height.d.ts +0 -3
- package/dist/types/utils/on-transition-end.d.ts +0 -1
- package/dist/types/utils/should-reduce-motion.d.ts +0 -1
- /package/dist/post-components/{p-eb3ff4dc.js.map → p-4aae941f.js.map} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { E as EMPTY_VALUES } from './constants-8d548297.js';
|
|
2
|
+
|
|
3
|
+
function checkNonEmpty(value, error) {
|
|
4
|
+
if (EMPTY_VALUES.some(v => v === value)) {
|
|
5
|
+
throw new Error(error);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { checkNonEmpty as c };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=check-non-empty-09c39561.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"check-non-empty-09c39561.js","mappings":";;SAEgB,aAAa,CAAC,KAAc,EAAE,KAAa;EACzD,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE;IACvC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GACxB;AACH;;;;","names":[],"sources":["src/utils/property-checkers/check-non-empty.ts"],"sourcesContent":["import { EMPTY_VALUES } from './constants';\n\nexport function checkNonEmpty(value: unknown, error: string) {\n if (EMPTY_VALUES.some(v => v === value)) {\n throw new Error(error);\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"check-one-of-74750af9.js","mappings":"SAAgB,UAAU,CAAI,KAAQ,EAAE,cAA4B,EAAE,KAAa;EACjF,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D;;;;","names":[],"sources":["src/utils/property-checkers/check-one-of.ts"],"sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: readonly T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n"],"version":3}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"constants-8d548297.js","mappings":"MAAa,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE;;;;","names":[],"sources":["src/utils/property-checkers/constants.ts"],"sourcesContent":["export const EMPTY_VALUES = [undefined, null, ''];\n"],"version":3}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const fadeDuration = 200;
|
|
2
|
+
const fadedOutKeyframe = { opacity: '0' };
|
|
3
|
+
const fadedInKeyframe = { opacity: '1' };
|
|
4
|
+
const fadeIn = (el) => el.animate([fadedOutKeyframe, fadedInKeyframe], { duration: fadeDuration });
|
|
5
|
+
const fadeOut = (el) => el.animate([fadedInKeyframe, fadedOutKeyframe], { duration: fadeDuration });
|
|
6
|
+
|
|
7
|
+
export { fadeIn as a, fadeOut as f };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=fade-7fd71785.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"fade-7fd71785.js","mappings":"AAAA,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,gBAAgB,GAAa,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC;AAClD,MAAM,eAAe,GAAa,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC;MAEpC,MAAM,GAAG,CAAC,EAAW,KAAgB,EAAE,CAAC,OAAO,CAC1D,CAAE,gBAAgB,EAAE,eAAe,CAAE,EACrC,EAAE,QAAQ,EAAE,YAAY,EAAE,EAC1B;MAEW,OAAO,GAAG,CAAC,EAAW,KAAgB,EAAE,CAAC,OAAO,CAC3D,CAAE,eAAe,EAAE,gBAAgB,CAAE,EACrC,EAAE,QAAQ,EAAE,YAAY,EAAE;;;;","names":[],"sources":["src/animations/fade.ts"],"sourcesContent":["const fadeDuration = 200;\nconst fadedOutKeyframe: Keyframe = {opacity: '0'};\nconst fadedInKeyframe: Keyframe = {opacity: '1'};\n\nexport const fadeIn = (el: Element): Animation => el.animate(\n [ fadedOutKeyframe, fadedInKeyframe ],\n { duration: fadeDuration }\n);\n\nexport const fadeOut = (el: Element): Animation => el.animate(\n [ fadedInKeyframe, fadedOutKeyframe ],\n { duration: fadeDuration }\n);\n"],"version":3}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { E as EMPTY_VALUES } from './constants-8d548297.js';
|
|
2
|
+
import { c as checkOneOf } from './check-one-of-74750af9.js';
|
|
3
|
+
|
|
4
|
+
function emptyOr(check) {
|
|
5
|
+
return (...args) => {
|
|
6
|
+
const value = args[0];
|
|
7
|
+
if (!EMPTY_VALUES.some(v => v === value))
|
|
8
|
+
check(...args);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function checkPattern(value, pattern, errorMessage) {
|
|
13
|
+
if (typeof value !== 'string' || !pattern.test(value))
|
|
14
|
+
throw new Error(errorMessage);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function checkType(value, type, error) {
|
|
18
|
+
const typeIsArray = type === 'array';
|
|
19
|
+
const valueIsArray = Array.isArray(value);
|
|
20
|
+
if (typeIsArray || valueIsArray) {
|
|
21
|
+
if (valueIsArray !== typeIsArray)
|
|
22
|
+
throw new Error(error);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (typeof value !== type)
|
|
26
|
+
throw new Error(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const checkEmptyOrOneOf = emptyOr(checkOneOf);
|
|
31
|
+
const checkEmptyOrPattern = emptyOr(checkPattern);
|
|
32
|
+
const checkEmptyOrType = emptyOr(checkType);
|
|
33
|
+
|
|
34
|
+
export { checkEmptyOrPattern as a, checkEmptyOrOneOf as b, checkType as c, checkEmptyOrType as d };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=index-35921354.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"index-35921354.js","mappings":";;;SAEgB,OAAO,CAAsB,KAA2B;EACtE,OAAO,CAAC,GAAG,IAAO;IAChB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;MAAE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;GAC1D,CAAC;AACJ;;SCPgB,YAAY,CAAC,KAAc,EAAE,OAAe,EAAE,YAAoB;EAChF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACvF;;SCMgB,SAAS,CAAC,KAAc,EAAE,IAAkB,EAAE,KAAa;EACzE,MAAM,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC;EACrC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,YAAY,KAAK,WAAW;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GAC1D;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,IAAI;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GACnD;AACH;;MCZa,iBAAiB,GAAG,OAAO,CAAC,UAAU,EAAE;MACxC,mBAAmB,GAAG,OAAO,CAAC,YAAY,EAAE;MAC5C,gBAAgB,GAAG,OAAO,CAAC,SAAS;;;;","names":[],"sources":["src/utils/property-checkers/empty-or.ts","src/utils/property-checkers/check-pattern.ts","src/utils/property-checkers/check-type.ts","src/utils/property-checkers/index.ts"],"sourcesContent":["import { EMPTY_VALUES } from './constants';\n\nexport function emptyOr<T extends unknown[]>(check: (...args: T) => void) {\n return (...args: T) => {\n const value = args[0];\n if (!EMPTY_VALUES.some(v => v === value)) check(...args);\n };\n}\n","export function checkPattern(value: unknown, pattern: RegExp, errorMessage: string) {\n if (typeof value !== 'string' || !pattern.test(value)) throw new Error(errorMessage);\n}\n","export type PropertyType =\n | 'boolean'\n | 'number'\n | 'string'\n | 'array'\n | 'object'\n | 'function';\n\nexport function checkType(value: unknown, type: PropertyType, error: string) {\n const typeIsArray = type === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if (valueIsArray !== typeIsArray) throw new Error(error);\n } else {\n if (typeof value !== type) throw new Error(error);\n }\n}\n","import { emptyOr } from './empty-or';\nimport { checkOneOf } from './check-one-of';\nimport { checkPattern } from './check-pattern';\nimport { checkType } from './check-type';\n\nexport const checkEmptyOrOneOf = emptyOr(checkOneOf);\nexport const checkEmptyOrPattern = emptyOr(checkPattern);\nexport const checkEmptyOrType = emptyOr(checkType);\n\nexport * from './check-non-empty';\nexport * from './check-one-of';\nexport * from './check-pattern';\nexport * from './check-type';\n"],"version":3}
|
|
@@ -105,10 +105,10 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
105
105
|
};
|
|
106
106
|
walk(children);
|
|
107
107
|
if (vnodeData) {
|
|
108
|
-
// normalize class / classname attributes
|
|
109
108
|
if (vnodeData.key) {
|
|
110
109
|
key = vnodeData.key;
|
|
111
110
|
}
|
|
111
|
+
// normalize class / className attributes
|
|
112
112
|
{
|
|
113
113
|
const classData = vnodeData.className || vnodeData.class;
|
|
114
114
|
if (classData) {
|
|
@@ -310,9 +310,9 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
310
310
|
}
|
|
311
311
|
styles.set(scopeId, style);
|
|
312
312
|
};
|
|
313
|
-
const addStyle = (styleContainerNode, cmpMeta, mode
|
|
313
|
+
const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
314
314
|
var _a;
|
|
315
|
-
|
|
315
|
+
const scopeId = getScopeId(cmpMeta);
|
|
316
316
|
const style = styles.get(scopeId);
|
|
317
317
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
318
318
|
// so the fallback is to always use the document for the root node in those cases
|
|
@@ -327,11 +327,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
327
327
|
}
|
|
328
328
|
if (!appliedStyles.has(scopeId)) {
|
|
329
329
|
{
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
styleElm = doc.createElement('style');
|
|
333
|
-
styleElm.innerHTML = style;
|
|
334
|
-
}
|
|
330
|
+
styleElm = doc.createElement('style');
|
|
331
|
+
styleElm.innerHTML = style;
|
|
335
332
|
// Apply CSP nonce to the style tag if it exists
|
|
336
333
|
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
337
334
|
if (nonce != null) {
|
|
@@ -356,7 +353,6 @@ const attachStyles = (hostRef) => {
|
|
|
356
353
|
const flags = cmpMeta.$flags$;
|
|
357
354
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
358
355
|
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
359
|
-
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
360
356
|
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
361
357
|
// only required when we're NOT using native shadow dom (slot)
|
|
362
358
|
// or this browser doesn't support native shadow dom
|
|
@@ -379,6 +375,21 @@ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
|
379
375
|
*
|
|
380
376
|
* Modified for Stencil's compiler and vdom
|
|
381
377
|
*/
|
|
378
|
+
/**
|
|
379
|
+
* When running a VDom render set properties present on a VDom node onto the
|
|
380
|
+
* corresponding HTML element.
|
|
381
|
+
*
|
|
382
|
+
* Note that this function has special functionality for the `class`,
|
|
383
|
+
* `style`, `key`, and `ref` attributes, as well as event handlers (like
|
|
384
|
+
* `onClick`, etc). All others are just passed through as-is.
|
|
385
|
+
*
|
|
386
|
+
* @param elm the HTMLElement onto which attributes should be set
|
|
387
|
+
* @param memberName the name of the attribute to set
|
|
388
|
+
* @param oldValue the old value for the attribute
|
|
389
|
+
* @param newValue the new value for the attribute
|
|
390
|
+
* @param isSvg whether we're in an svg context or not
|
|
391
|
+
* @param flags bitflags for Vdom variables
|
|
392
|
+
*/
|
|
382
393
|
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
383
394
|
if (oldValue !== newValue) {
|
|
384
395
|
let isProp = isMemberInElement(elm, memberName);
|
|
@@ -937,9 +948,9 @@ const patch = (oldVNode, newVNode) => {
|
|
|
937
948
|
}
|
|
938
949
|
};
|
|
939
950
|
/**
|
|
940
|
-
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by
|
|
941
|
-
*
|
|
942
|
-
*
|
|
951
|
+
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
|
|
952
|
+
* them with `null`. This signals that the DOM element corresponding to the VDom
|
|
953
|
+
* node has been removed from the DOM.
|
|
943
954
|
*
|
|
944
955
|
* @param vNode a virtual DOM node
|
|
945
956
|
*/
|
|
@@ -960,12 +971,39 @@ const nullifyVNodeRefs = (vNode) => {
|
|
|
960
971
|
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
961
972
|
* the DOM node into which it should be rendered.
|
|
962
973
|
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
974
|
+
* @param isInitialLoad whether or not this is the first call after page load
|
|
963
975
|
*/
|
|
964
|
-
const renderVdom = (hostRef, renderFnResults) => {
|
|
976
|
+
const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
965
977
|
const hostElm = hostRef.$hostElement$;
|
|
966
978
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
979
|
+
// if `renderFnResults` is a Host node then we can use it directly. If not,
|
|
980
|
+
// we need to call `h` again to wrap the children of our component in a
|
|
981
|
+
// 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
|
|
982
|
+
// implicitly that the top-level vdom node is 1) an only child and 2)
|
|
983
|
+
// contains attrs that need to be set on the host element.
|
|
967
984
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
968
985
|
hostTagName = hostElm.tagName;
|
|
986
|
+
// On the first render and *only* on the first render we want to check for
|
|
987
|
+
// any attributes set on the host element which are also set on the vdom
|
|
988
|
+
// node. If we find them, we override the value on the VDom node attrs with
|
|
989
|
+
// the value from the host element, which allows developers building apps
|
|
990
|
+
// with Stencil components to override e.g. the `role` attribute on a
|
|
991
|
+
// component even if it's already set on the `Host`.
|
|
992
|
+
if (isInitialLoad && rootVnode.$attrs$) {
|
|
993
|
+
for (const key of Object.keys(rootVnode.$attrs$)) {
|
|
994
|
+
// We have a special implementation in `setAccessor` for `style` and
|
|
995
|
+
// `class` which reconciles values coming from the VDom with values
|
|
996
|
+
// already present on the DOM element, so we don't want to override those
|
|
997
|
+
// attributes on the VDom tree with values from the host element if they
|
|
998
|
+
// are present.
|
|
999
|
+
//
|
|
1000
|
+
// Likewise, `ref` and `key` are special internal values for the Stencil
|
|
1001
|
+
// runtime and we don't want to override those either.
|
|
1002
|
+
if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
|
|
1003
|
+
rootVnode.$attrs$[key] = hostElm[key];
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
969
1007
|
rootVnode.$tag$ = null;
|
|
970
1008
|
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
971
1009
|
hostRef.$vnode$ = rootVnode;
|
|
@@ -1023,6 +1061,13 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1023
1061
|
// called in order after `dispatchHooks` exits.
|
|
1024
1062
|
let maybePromise;
|
|
1025
1063
|
if (isInitialLoad) {
|
|
1064
|
+
{
|
|
1065
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1066
|
+
if (hostRef.$queuedListeners$) {
|
|
1067
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1068
|
+
hostRef.$queuedListeners$ = undefined;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1026
1071
|
{
|
|
1027
1072
|
// If `componentWillLoad` returns a `Promise` then we want to wait on
|
|
1028
1073
|
// whatever's going on in that `Promise` before we launch into
|
|
@@ -1067,6 +1112,16 @@ const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.th
|
|
|
1067
1112
|
*/
|
|
1068
1113
|
const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
|
|
1069
1114
|
(maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
|
|
1115
|
+
/**
|
|
1116
|
+
* Update a component given reference to its host elements and so on.
|
|
1117
|
+
*
|
|
1118
|
+
* @param hostRef an object containing references to the element's host node,
|
|
1119
|
+
* VDom nodes, and other metadata
|
|
1120
|
+
* @param instance a reference to the underlying host element where it will be
|
|
1121
|
+
* rendered
|
|
1122
|
+
* @param isInitialLoad whether or not this function is being called as part of
|
|
1123
|
+
* the first render cycle
|
|
1124
|
+
*/
|
|
1070
1125
|
const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
1071
1126
|
var _a;
|
|
1072
1127
|
const elm = hostRef.$hostElement$;
|
|
@@ -1078,7 +1133,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1078
1133
|
}
|
|
1079
1134
|
const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
|
1080
1135
|
{
|
|
1081
|
-
callRender(hostRef, instance);
|
|
1136
|
+
callRender(hostRef, instance, elm, isInitialLoad);
|
|
1082
1137
|
}
|
|
1083
1138
|
if (rc) {
|
|
1084
1139
|
// ok, so turns out there are some child host elements
|
|
@@ -1102,8 +1157,24 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1102
1157
|
}
|
|
1103
1158
|
}
|
|
1104
1159
|
};
|
|
1105
|
-
|
|
1160
|
+
/**
|
|
1161
|
+
* Handle making the call to the VDom renderer with the proper context given
|
|
1162
|
+
* various build variables
|
|
1163
|
+
*
|
|
1164
|
+
* @param hostRef an object containing references to the element's host node,
|
|
1165
|
+
* VDom nodes, and other metadata
|
|
1166
|
+
* @param instance a reference to the underlying host element where it will be
|
|
1167
|
+
* rendered
|
|
1168
|
+
* @param elm the Host element for the component
|
|
1169
|
+
* @param isInitialLoad whether or not this function is being called as part of
|
|
1170
|
+
* @returns an empty promise
|
|
1171
|
+
*/
|
|
1172
|
+
const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
1106
1173
|
try {
|
|
1174
|
+
/**
|
|
1175
|
+
* minification optimization: `allRenderFn` is `true` if all components have a `render`
|
|
1176
|
+
* method, so we can call the method immediately. If not, check before calling it.
|
|
1177
|
+
*/
|
|
1107
1178
|
instance = instance.render() ;
|
|
1108
1179
|
{
|
|
1109
1180
|
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
@@ -1117,7 +1188,7 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
1117
1188
|
// or we need to update the css class/attrs on the host element
|
|
1118
1189
|
// DOM WRITE!
|
|
1119
1190
|
{
|
|
1120
|
-
renderVdom(hostRef, instance);
|
|
1191
|
+
renderVdom(hostRef, instance, isInitialLoad);
|
|
1121
1192
|
}
|
|
1122
1193
|
}
|
|
1123
1194
|
}
|
|
@@ -1180,6 +1251,16 @@ const appDidLoad = (who) => {
|
|
|
1180
1251
|
}
|
|
1181
1252
|
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
1182
1253
|
};
|
|
1254
|
+
/**
|
|
1255
|
+
* Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
|
|
1256
|
+
* e.g. custom element node. If a build figures out that e.g. no component
|
|
1257
|
+
* has a `componentDidLoad` method, the instance method gets removed from the
|
|
1258
|
+
* output bundle and this function returns `undefined`.
|
|
1259
|
+
* @param instance any object that may or may not contain methods
|
|
1260
|
+
* @param method method name
|
|
1261
|
+
* @param arg single arbitrary argument
|
|
1262
|
+
* @returns result of method call if it exists, otherwise `undefined`
|
|
1263
|
+
*/
|
|
1183
1264
|
const safeCall = (instance, method, arg) => {
|
|
1184
1265
|
if (instance && instance[method]) {
|
|
1185
1266
|
try {
|
|
@@ -1247,6 +1328,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1247
1328
|
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1248
1329
|
*/
|
|
1249
1330
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1331
|
+
var _a;
|
|
1250
1332
|
if (cmpMeta.$members$) {
|
|
1251
1333
|
if (Cstr.watchers) {
|
|
1252
1334
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
@@ -1284,7 +1366,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1284
1366
|
});
|
|
1285
1367
|
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1286
1368
|
const attrNameToPropName = new Map();
|
|
1287
|
-
prototype.attributeChangedCallback = function (attrName,
|
|
1369
|
+
prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
|
|
1288
1370
|
plt.jmp(() => {
|
|
1289
1371
|
const propName = attrNameToPropName.get(attrName);
|
|
1290
1372
|
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
@@ -1307,12 +1389,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1307
1389
|
// customElements.define('my-component', MyComponent);
|
|
1308
1390
|
// </script>
|
|
1309
1391
|
// ```
|
|
1310
|
-
// In this case if we do not
|
|
1392
|
+
// In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
|
|
1311
1393
|
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
1312
1394
|
// to the value that was set inline i.e. "some-value" from above example. When
|
|
1313
|
-
// the connectedCallback attempts to
|
|
1395
|
+
// the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
|
|
1314
1396
|
//
|
|
1315
|
-
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/
|
|
1397
|
+
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
|
|
1316
1398
|
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
1317
1399
|
//
|
|
1318
1400
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
@@ -1332,23 +1414,62 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1332
1414
|
// `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
|
|
1333
1415
|
return;
|
|
1334
1416
|
}
|
|
1417
|
+
else if (propName == null) {
|
|
1418
|
+
// At this point we should know this is not a "member", so we can treat it like watching an attribute
|
|
1419
|
+
// on a vanilla web component
|
|
1420
|
+
const hostRef = getHostRef(this);
|
|
1421
|
+
const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
|
|
1422
|
+
// We only want to trigger the callback(s) if:
|
|
1423
|
+
// 1. The instance is ready
|
|
1424
|
+
// 2. The watchers are ready
|
|
1425
|
+
// 3. The value has changed
|
|
1426
|
+
if (!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
|
|
1427
|
+
flags & 128 /* HOST_FLAGS.isWatchReady */ &&
|
|
1428
|
+
newValue !== oldValue) {
|
|
1429
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1430
|
+
const entry = cmpMeta.$watchers$[attrName];
|
|
1431
|
+
entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
|
|
1432
|
+
if (instance[callbackName] != null) {
|
|
1433
|
+
instance[callbackName].call(instance, newValue, oldValue, attrName);
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1335
1439
|
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
|
1336
1440
|
});
|
|
1337
1441
|
};
|
|
1338
|
-
//
|
|
1339
|
-
//
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1442
|
+
// Create an array of attributes to observe
|
|
1443
|
+
// This list in comprised of all strings used within a `@Watch()` decorator
|
|
1444
|
+
// on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
|
|
1445
|
+
// As such, there is no way to guarantee type-safety here that a user hasn't entered
|
|
1446
|
+
// an invalid attribute.
|
|
1447
|
+
Cstr.observedAttributes = Array.from(new Set([
|
|
1448
|
+
...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
|
|
1449
|
+
...members
|
|
1450
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
|
|
1451
|
+
.map(([propName, m]) => {
|
|
1452
|
+
const attrName = m[1] || propName;
|
|
1453
|
+
attrNameToPropName.set(attrName, propName);
|
|
1454
|
+
return attrName;
|
|
1455
|
+
}),
|
|
1456
|
+
]));
|
|
1347
1457
|
}
|
|
1348
1458
|
}
|
|
1349
1459
|
return Cstr;
|
|
1350
1460
|
};
|
|
1351
|
-
|
|
1461
|
+
/**
|
|
1462
|
+
* Initialize a Stencil component given a reference to its host element, its
|
|
1463
|
+
* runtime bookkeeping data structure, runtime metadata about the component,
|
|
1464
|
+
* and (optionally) an HMR version ID.
|
|
1465
|
+
*
|
|
1466
|
+
* @param elm a host element
|
|
1467
|
+
* @param hostRef the element's runtime bookkeeping object
|
|
1468
|
+
* @param cmpMeta runtime metadata for the Stencil component
|
|
1469
|
+
* @param hmrVersionId an (optional) HMR version ID
|
|
1470
|
+
*/
|
|
1471
|
+
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
1472
|
+
let Cstr;
|
|
1352
1473
|
// initializeComponent
|
|
1353
1474
|
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1354
1475
|
// Let the runtime know that the component has been initialized
|
|
@@ -1471,18 +1592,40 @@ const connectedCallback = (elm) => {
|
|
|
1471
1592
|
}
|
|
1472
1593
|
}
|
|
1473
1594
|
else {
|
|
1595
|
+
// not the first time this has connected
|
|
1596
|
+
// reattach any event listeners to the host
|
|
1597
|
+
// since they would have been removed when disconnected
|
|
1598
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1474
1599
|
// fire off connectedCallback() on component instance
|
|
1475
|
-
|
|
1600
|
+
if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
|
|
1601
|
+
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
1602
|
+
}
|
|
1603
|
+
else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
|
|
1604
|
+
hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
|
|
1605
|
+
}
|
|
1476
1606
|
}
|
|
1477
1607
|
endConnected();
|
|
1478
1608
|
}
|
|
1479
1609
|
};
|
|
1480
|
-
const
|
|
1610
|
+
const disconnectInstance = (instance) => {
|
|
1611
|
+
{
|
|
1612
|
+
safeCall(instance, 'disconnectedCallback');
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
const disconnectedCallback = async (elm) => {
|
|
1481
1616
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1482
1617
|
const hostRef = getHostRef(elm);
|
|
1483
|
-
const instance = hostRef.$lazyInstance$ ;
|
|
1484
1618
|
{
|
|
1485
|
-
|
|
1619
|
+
if (hostRef.$rmListeners$) {
|
|
1620
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1621
|
+
hostRef.$rmListeners$ = undefined;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
|
|
1625
|
+
disconnectInstance(hostRef.$lazyInstance$);
|
|
1626
|
+
}
|
|
1627
|
+
else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
|
|
1628
|
+
hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
|
|
1486
1629
|
}
|
|
1487
1630
|
}
|
|
1488
1631
|
};
|
|
@@ -1502,6 +1645,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1502
1645
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1503
1646
|
lazyBundles.map((lazyBundle) => {
|
|
1504
1647
|
lazyBundle[1].map((compactMeta) => {
|
|
1648
|
+
var _a;
|
|
1505
1649
|
const cmpMeta = {
|
|
1506
1650
|
$flags$: compactMeta[0],
|
|
1507
1651
|
$tagName$: compactMeta[1],
|
|
@@ -1512,7 +1656,10 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1512
1656
|
cmpMeta.$members$ = compactMeta[2];
|
|
1513
1657
|
}
|
|
1514
1658
|
{
|
|
1515
|
-
cmpMeta.$
|
|
1659
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1660
|
+
}
|
|
1661
|
+
{
|
|
1662
|
+
cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
|
|
1516
1663
|
}
|
|
1517
1664
|
const tagName = cmpMeta.$tagName$;
|
|
1518
1665
|
const HostElement = class extends HTMLElement {
|
|
@@ -1584,6 +1731,35 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1584
1731
|
// Fallback appLoad event
|
|
1585
1732
|
endBootstrap();
|
|
1586
1733
|
};
|
|
1734
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1735
|
+
if (listeners) {
|
|
1736
|
+
listeners.map(([flags, name, method]) => {
|
|
1737
|
+
const target = elm;
|
|
1738
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1739
|
+
const opts = hostListenerOpts(flags);
|
|
1740
|
+
plt.ael(target, name, handler, opts);
|
|
1741
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1746
|
+
try {
|
|
1747
|
+
{
|
|
1748
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1749
|
+
// instance is ready, let's call it's member method for this event
|
|
1750
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1751
|
+
}
|
|
1752
|
+
else {
|
|
1753
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
catch (e) {
|
|
1758
|
+
consoleError(e);
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
// prettier-ignore
|
|
1762
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1587
1763
|
/**
|
|
1588
1764
|
* Assigns the given value to the nonce property on the runtime platform object.
|
|
1589
1765
|
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
@@ -1591,13 +1767,40 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1591
1767
|
* @returns void
|
|
1592
1768
|
*/
|
|
1593
1769
|
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1770
|
+
/**
|
|
1771
|
+
* A WeakMap mapping runtime component references to their corresponding host reference
|
|
1772
|
+
* instances.
|
|
1773
|
+
*/
|
|
1594
1774
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1775
|
+
/**
|
|
1776
|
+
* Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
|
|
1777
|
+
*
|
|
1778
|
+
* @param ref the runtime ref of interest
|
|
1779
|
+
* @returns the Host reference (if found) or undefined
|
|
1780
|
+
*/
|
|
1595
1781
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1782
|
+
/**
|
|
1783
|
+
* Register a lazy instance with the {@link hostRefs} object so it's
|
|
1784
|
+
* corresponding {@link d.HostRef} can be retrieved later.
|
|
1785
|
+
*
|
|
1786
|
+
* @param lazyInstance the lazy instance of interest
|
|
1787
|
+
* @param hostRef that instances `HostRef` object
|
|
1788
|
+
* @returns a reference to the host ref WeakMap
|
|
1789
|
+
*/
|
|
1596
1790
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1597
|
-
|
|
1791
|
+
/**
|
|
1792
|
+
* Register a host element for a Stencil component, setting up various metadata
|
|
1793
|
+
* and callbacks based on {@link BUILD} flags as well as the component's runtime
|
|
1794
|
+
* metadata.
|
|
1795
|
+
*
|
|
1796
|
+
* @param hostElement the host element to register
|
|
1797
|
+
* @param cmpMeta runtime metadata for that component
|
|
1798
|
+
* @returns a reference to the host ref WeakMap
|
|
1799
|
+
*/
|
|
1800
|
+
const registerHost = (hostElement, cmpMeta) => {
|
|
1598
1801
|
const hostRef = {
|
|
1599
1802
|
$flags$: 0,
|
|
1600
|
-
$hostElement$:
|
|
1803
|
+
$hostElement$: hostElement,
|
|
1601
1804
|
$cmpMeta$: cmpMeta,
|
|
1602
1805
|
$instanceValues$: new Map(),
|
|
1603
1806
|
};
|
|
@@ -1606,10 +1809,11 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1606
1809
|
}
|
|
1607
1810
|
{
|
|
1608
1811
|
hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
|
|
1609
|
-
|
|
1610
|
-
|
|
1812
|
+
hostElement['s-p'] = [];
|
|
1813
|
+
hostElement['s-rc'] = [];
|
|
1611
1814
|
}
|
|
1612
|
-
|
|
1815
|
+
addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
|
|
1816
|
+
return hostRefs.set(hostElement, hostRef);
|
|
1613
1817
|
};
|
|
1614
1818
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
1615
1819
|
const consoleError = (e, el) => (0, console.error)(e, el);
|
|
@@ -1702,4 +1906,4 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
|
1702
1906
|
|
|
1703
1907
|
export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|
|
1704
1908
|
|
|
1705
|
-
//# sourceMappingURL=index-
|
|
1909
|
+
//# sourceMappingURL=index-4eff5fc5.js.map
|