@swisspost/design-system-components 1.3.1 → 1.3.2
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-type-f24cf91d.js +24 -0
- package/dist/cjs/check-type-f24cf91d.js.map +1 -0
- package/dist/cjs/{index-8880977f.js → index-a8b23f1b.js} +1 -1
- package/dist/cjs/{index-8880977f.js.map → index-a8b23f1b.js.map} +1 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/post-collapsible.cjs.entry.js +11 -19
- package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
- package/dist/cjs/post-components.cjs.js +3 -3
- package/dist/cjs/post-components.cjs.js.map +1 -1
- package/dist/cjs/post-icon.cjs.entry.js +39 -29
- package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/post-collapsible/post-collapsible.css +1251 -3863
- package/dist/collection/components/post-collapsible/post-collapsible.js +12 -10
- package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -1
- package/dist/collection/components/post-icon/post-icon.js +41 -46
- package/dist/collection/components/post-icon/post-icon.js.map +1 -1
- package/dist/collection/utils/get-element-height.js +0 -3
- package/dist/collection/utils/get-element-height.js.map +1 -1
- package/dist/collection/utils/index.js +0 -3
- package/dist/collection/utils/index.js.map +1 -1
- package/dist/collection/utils/on-transition-end.js +0 -3
- package/dist/collection/utils/on-transition-end.js.map +1 -1
- package/dist/collection/utils/property-checkers/check-one-of.js +5 -0
- package/dist/collection/utils/property-checkers/check-one-of.js.map +1 -0
- package/dist/collection/utils/property-checkers/check-type.js +13 -0
- package/dist/collection/utils/property-checkers/check-type.js.map +1 -0
- package/dist/collection/utils/property-checkers/empty-or.js +9 -0
- package/dist/collection/utils/property-checkers/empty-or.js.map +1 -0
- package/dist/collection/utils/property-checkers/index.js +8 -0
- package/dist/collection/utils/property-checkers/index.js.map +1 -0
- package/dist/collection/utils/should-reduce-motion.js +0 -3
- package/dist/collection/utils/should-reduce-motion.js.map +1 -1
- package/dist/components/check-type.js +21 -0
- package/dist/components/check-type.js.map +1 -0
- package/dist/components/post-collapsible.js +12 -19
- package/dist/components/post-collapsible.js.map +1 -1
- package/dist/components/post-icon.js +37 -30
- package/dist/components/post-icon.js.map +1 -1
- package/dist/docs.json +2 -2
- package/dist/esm/check-type-67411ed3.js +21 -0
- package/dist/esm/check-type-67411ed3.js.map +1 -0
- package/dist/esm/{index-6d5a72fa.js → index-401f2d6a.js} +1 -1
- package/dist/esm/{index-6d5a72fa.js.map → index-401f2d6a.js.map} +1 -1
- package/dist/esm/loader.js +4 -4
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/post-collapsible.entry.js +10 -18
- package/dist/esm/post-collapsible.entry.js.map +1 -1
- package/dist/esm/post-components.js +4 -4
- package/dist/esm/post-components.js.map +1 -1
- package/dist/esm/post-icon.entry.js +35 -25
- package/dist/esm/post-icon.entry.js.map +1 -1
- package/dist/post-components/{p-d1bc7b0b.entry.js → p-07a51673.entry.js} +2 -2
- package/dist/post-components/p-07a51673.entry.js.map +1 -0
- package/dist/post-components/p-416f1e74.entry.js +2 -0
- package/dist/post-components/p-416f1e74.entry.js.map +1 -0
- package/dist/post-components/{p-a93114b9.js → p-f214c52a.js} +1 -1
- package/dist/post-components/{p-a93114b9.js.map → p-f214c52a.js.map} +1 -1
- package/dist/post-components/p-f549b3fc.js +2 -0
- package/dist/post-components/p-f549b3fc.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/components/post-collapsible/post-collapsible.d.ts +14 -13
- package/dist/types/components/post-icon/post-icon.d.ts +22 -22
- package/dist/types/utils/property-checkers/check-one-of.d.ts +1 -0
- package/dist/types/utils/property-checkers/check-type.d.ts +2 -0
- package/dist/types/utils/property-checkers/empty-or.d.ts +1 -0
- package/dist/types/utils/property-checkers/index.d.ts +4 -0
- package/package.json +17 -11
- package/dist/cjs/property-checkers-586ad9d4.js +0 -40
- package/dist/cjs/property-checkers-586ad9d4.js.map +0 -1
- package/dist/collection/utils/property-checkers.js +0 -31
- package/dist/collection/utils/property-checkers.js.map +0 -1
- package/dist/components/property-checkers.js +0 -34
- package/dist/components/property-checkers.js.map +0 -1
- package/dist/esm/property-checkers-484ca671.js +0 -34
- package/dist/esm/property-checkers-484ca671.js.map +0 -1
- package/dist/post-components/p-7cd9c1ad.js +0 -2
- package/dist/post-components/p-7cd9c1ad.js.map +0 -1
- package/dist/post-components/p-b07185a3.entry.js +0 -2
- package/dist/post-components/p-b07185a3.entry.js.map +0 -1
- package/dist/post-components/p-d1bc7b0b.entry.js.map +0 -1
- package/dist/types/utils/property-checkers.d.ts +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["checkOneOf","value","possibleValues","error","includes","Error","checkType","type","typeIsArray","valueIsArray","Array","isArray"],"sources":["./src/utils/property-checkers/check-one-of.ts","./src/utils/property-checkers/check-type.ts"],"sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\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"],"mappings":"SAAgBA,EAAcC,EAAUC,EAAqBC,GAC3D,IAAKD,EAAeE,SAASH,GAAQ,MAAM,IAAII,MAAMF,EACvD,C,SCMgBG,EAAUL,EAAgBM,EAAoBJ,GAC5D,MAAMK,EAAcD,IAAS,QAC7B,MAAME,EAAeC,MAAMC,QAAQV,GAEnC,GAAIO,GAAeC,EAAc,CAC/B,GAAIA,IAAiBD,EAAa,MAAM,IAAIH,MAAMF,E,KAC7C,CACL,UAAWF,IAAUM,EAAM,MAAM,IAAIF,MAAMF,E,CAE/C,Q"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as e,b as a}from"./p-
|
|
1
|
+
import{p as e,b as a}from"./p-f214c52a.js";export{s as setNonce}from"./p-f214c52a.js";const o=()=>{const s=import.meta.url;const a={};if(s!==""){a.resourcesUrl=new URL(".",s).href}return e(a)};o().then((e=>a([["p-07a51673",[[1,"post-collapsible",{collapsed:[4],headingLevel:[2,"heading-level"],collapseClasses:[32],collapseHeight:[32],collapsibleId:[32],hasHeader:[32],headingTag:[32],isOpen:[32],onAccordionButtonClick:[32],toggle:[64]}]]],["p-416f1e74",[[1,"post-icon",{animation:[1],base:[1],flipH:[4,"flip-h"],flipV:[4,"flip-v"],name:[1],rotate:[2],scale:[2],svgOutput:[32]}]]]],e)));
|
|
2
2
|
//# sourceMappingURL=post-components.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["patchBrowser","importMeta","import","meta","url","opts","resourcesUrl","URL","href","promiseResolve","then","options","bootstrapLazy","collapsed","headingLevel","
|
|
1
|
+
{"version":3,"names":["patchBrowser","importMeta","import","meta","url","opts","resourcesUrl","URL","href","promiseResolve","then","options","bootstrapLazy","collapsed","headingLevel","collapseClasses","collapseHeight","collapsibleId","hasHeader","headingTag","isOpen","onAccordionButtonClick","toggle","animation","base","flipH","flipV","name","rotate","scale","svgOutput"],"sources":["../../node_modules/.pnpm/@stencil+core@3.1.0/node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"sourcesContent":["/*\n Stencil Client Patch Browser v3.1.0 | MIT Licensed | https://stenciljs.com\n */\nimport { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';\nimport { consoleDevInfo, plt, win, doc, promiseResolve, H } from '@stencil/core';\n/**\n * Helper method for querying a `meta` tag that contains a nonce value\n * out of a DOM's head.\n *\n * @param doc The DOM containing the `head` to query against\n * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag\n * exists or the tag has no content.\n */\nfunction queryNonceMetaTagContent(doc) {\n var _a, _b, _c;\n return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name=\"csp-nonce\"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;\n}\n// TODO(STENCIL-661): Remove code related to the dynamic import shim\nconst getDynamicImportFunction = (namespace) => `__sc_import_${namespace.replace(/\\s|-/g, '_')}`;\nconst patchBrowser = () => {\n // NOTE!! This fn cannot use async/await!\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo('Running in development mode.');\n }\n // TODO(STENCIL-659): Remove code implementing the CSS variable shim\n if (BUILD.cssVarShim) {\n // shim css vars\n // TODO(STENCIL-659): Remove code implementing the CSS variable shim\n plt.$cssShim$ = win.__cssshim;\n }\n if (BUILD.cloneNodeFix) {\n // opted-in to polyfill cloneNode() for slot polyfilled components\n patchCloneNodeFix(H.prototype);\n }\n if (BUILD.profile && !performance.mark) {\n // not all browsers support performance.mark/measure (Safari 10)\n // because the mark/measure APIs are designed to write entries to a buffer in the browser that does not exist,\n // simply stub the implementations out.\n // TODO(STENCIL-323): Remove this patch when support for older browsers is removed (breaking)\n // @ts-ignore\n performance.mark = performance.measure = () => {\n /*noop*/\n };\n performance.getEntriesByName = () => [];\n }\n // @ts-ignore\n const scriptElm = \n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n BUILD.scriptDataOpts || BUILD.safari10 || BUILD.dynamicImportShim\n ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\\/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) ||\n s.getAttribute('data-stencil-namespace') === NAMESPACE)\n : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? (scriptElm || {})['data-opts'] || {} : {};\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) {\n // Safari < v11 support: This IF is true if it's Safari below v11.\n // This fn cannot use async/await since Safari didn't support it until v11,\n // however, Safari 10 did support modules. Safari 10 also didn't support \"nomodule\",\n // so both the ESM file and nomodule file would get downloaded. Only Safari\n // has 'onbeforeload' in the script, and \"history.scrollRestoration\" was added\n // to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue.\n // IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds.\n return {\n then() {\n /* promise noop */\n },\n };\n }\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n if (!BUILD.safari10 && importMeta !== '') {\n opts.resourcesUrl = new URL('.', importMeta).href;\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n // TODO(STENCIL-663): Remove code related to deprecated `safari10` field.\n }\n else if (BUILD.dynamicImportShim || BUILD.safari10) {\n opts.resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)).href;\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n if (BUILD.dynamicImportShim) {\n patchDynamicImport(opts.resourcesUrl, scriptElm);\n }\n // TODO(STENCIL-661): Remove code related to the dynamic import shim\n if (BUILD.dynamicImportShim && !win.customElements) {\n // module support, but no custom elements support (Old Edge)\n // @ts-ignore\n return import(/* webpackChunkName: \"polyfills-dom\" */ './dom.js').then(() => opts);\n }\n }\n return promiseResolve(opts);\n};\n// TODO(STENCIL-661): Remove code related to the dynamic import shim\nconst patchDynamicImport = (base, orgScriptElm) => {\n const importFunctionName = getDynamicImportFunction(NAMESPACE);\n try {\n // test if this browser supports dynamic imports\n // There is a caching issue in V8, that breaks using import() in Function\n // By generating a random string, we can workaround it\n // Check https://bugs.chromium.org/p/chromium/issues/detail?id=990810 for more info\n win[importFunctionName] = new Function('w', `return import(w);//${Math.random()}`);\n }\n catch (e) {\n // this shim is specifically for browsers that do support \"esm\" imports\n // however, they do NOT support \"dynamic\" imports\n // basically this code is for old Edge, v18 and below\n const moduleMap = new Map();\n win[importFunctionName] = (src) => {\n var _a;\n const url = new URL(src, base).href;\n let mod = moduleMap.get(url);\n if (!mod) {\n const script = doc.createElement('script');\n script.type = 'module';\n script.crossOrigin = orgScriptElm.crossOrigin;\n script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], {\n type: 'application/javascript',\n }));\n // Apply CSP nonce to the script tag if it exists\n const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);\n if (nonce != null) {\n script.setAttribute('nonce', nonce);\n }\n mod = new Promise((resolve) => {\n script.onload = () => {\n resolve(win[importFunctionName].m);\n script.remove();\n };\n });\n moduleMap.set(url, mod);\n doc.head.appendChild(script);\n }\n return mod;\n };\n }\n};\nconst patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function (deep) {\n if (this.nodeName === 'TEMPLATE') {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n // Node.ATTRIBUTE_NODE === 2, and checking because IE11\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport { patchBrowser };\n","export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(options => {\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"],"mappings":"sFAmBA,MAAMA,EAAe,KAkCjB,MAAMC,EAAaC,OAAOC,KAAKC,IAC/B,MAAMC,EAAqE,GAiB3E,GAAuBJ,IAAe,GAAI,CACtCI,EAAKC,aAAe,IAAIC,IAAI,IAAKN,GAAYO,IAGrD,CAcI,OAAOC,EAAeJ,EAAK,ECrF/BL,IAAeU,MAAKC,GAEXC,EAAc,sCAAsC,CAACC,UAAA,IAAAC,aAAA,oBAAAC,gBAAA,KAAAC,eAAA,KAAAC,cAAA,KAAAC,UAAA,KAAAC,WAAA,KAAAC,OAAA,KAAAC,uBAAA,KAAAC,OAAA,wCAAAC,UAAA,IAAAC,KAAA,IAAAC,MAAA,aAAAC,MAAA,aAAAC,KAAA,IAAAC,OAAA,IAAAC,MAAA,IAAAC,UAAA,UAAAnB"}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
export declare class PostCollapsible {
|
|
2
|
+
private collapsibleElement;
|
|
3
|
+
private isLoaded;
|
|
4
|
+
host: HTMLPostCollapsibleElement;
|
|
5
|
+
collapseClasses: string;
|
|
6
|
+
collapseHeight: string | null;
|
|
7
|
+
collapsibleId: string;
|
|
8
|
+
hasHeader: boolean;
|
|
9
|
+
headingTag: string | undefined;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
onAccordionButtonClick: () => Promise<boolean>;
|
|
2
12
|
/**
|
|
3
13
|
* If `true`, the element is initially collapsed otherwise it is displayed.
|
|
4
14
|
*/
|
|
5
|
-
collapsed?: boolean;
|
|
15
|
+
readonly collapsed?: boolean;
|
|
16
|
+
validateCollapsed(newValue?: boolean): void;
|
|
6
17
|
/**
|
|
7
18
|
* Defines the hierarchical level of the collapsible header within the headings structure.
|
|
8
19
|
*/
|
|
9
|
-
headingLevel?: number;
|
|
10
|
-
isOpen: boolean;
|
|
11
|
-
collapseClasses: string;
|
|
12
|
-
collapseHeight: string | null;
|
|
13
|
-
headingTag: string | undefined;
|
|
14
|
-
collapsibleId: string;
|
|
15
|
-
hasHeader: boolean;
|
|
16
|
-
host: HTMLElement;
|
|
17
|
-
isLoaded: boolean;
|
|
18
|
-
collapsibleElement: HTMLElement;
|
|
19
|
-
validateCollapsed(newValue?: boolean): void;
|
|
20
|
+
readonly headingLevel?: number;
|
|
20
21
|
validateHeadingLevel(newValue?: number): void;
|
|
21
22
|
componentWillLoad(): void;
|
|
22
23
|
componentDidLoad(): void;
|
|
@@ -24,7 +25,7 @@ export declare class PostCollapsible {
|
|
|
24
25
|
* Triggers the collapse programmatically.
|
|
25
26
|
*/
|
|
26
27
|
toggle(open?: boolean): Promise<boolean>;
|
|
27
|
-
startTransition
|
|
28
|
+
private startTransition;
|
|
28
29
|
private getCollapseClasses;
|
|
29
30
|
render(): any;
|
|
30
31
|
}
|
|
@@ -2,49 +2,49 @@
|
|
|
2
2
|
* @class PostIcon - representing a stencil component
|
|
3
3
|
*/
|
|
4
4
|
export declare class PostIcon {
|
|
5
|
+
private initialPath;
|
|
6
|
+
private path;
|
|
7
|
+
private svgSource;
|
|
8
|
+
svgOutput: string;
|
|
5
9
|
/**
|
|
6
|
-
* The name
|
|
10
|
+
* The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`).
|
|
7
11
|
*/
|
|
8
|
-
|
|
12
|
+
readonly animation?: string;
|
|
13
|
+
validateAnimation(newValue?: string): void;
|
|
9
14
|
/**
|
|
10
15
|
* The base path, where the icons are located (must be a public url).
|
|
11
16
|
*/
|
|
12
|
-
base?: string;
|
|
17
|
+
readonly base?: string;
|
|
18
|
+
validateBase(newValue?: string): void;
|
|
13
19
|
/**
|
|
14
20
|
* When set to `true`, the icon will be flipped horizontally.
|
|
15
21
|
*/
|
|
16
|
-
flipH?: boolean;
|
|
22
|
+
readonly flipH?: boolean;
|
|
23
|
+
validateFlipH(newValue?: boolean): void;
|
|
17
24
|
/**
|
|
18
25
|
* When set to `true`, the icon will be flipped vertically.
|
|
19
26
|
*/
|
|
20
|
-
flipV?: boolean;
|
|
27
|
+
readonly flipV?: boolean;
|
|
28
|
+
validateFlipV(newValue?: boolean): void;
|
|
21
29
|
/**
|
|
22
|
-
* The
|
|
30
|
+
* The name/id of the icon (e.g. 1000, 1001, ...).
|
|
23
31
|
*/
|
|
24
|
-
|
|
32
|
+
readonly name: string;
|
|
33
|
+
validateName(newValue?: string): void;
|
|
25
34
|
/**
|
|
26
35
|
* The `number` of degree for the css `rotate` transformation.
|
|
27
36
|
*/
|
|
28
|
-
rotate?: number;
|
|
37
|
+
readonly rotate?: number;
|
|
38
|
+
validateRotate(newValue?: number): void;
|
|
29
39
|
/**
|
|
30
|
-
* The
|
|
40
|
+
* The `number` for the css `scale` transformation.
|
|
31
41
|
*/
|
|
32
|
-
|
|
33
|
-
initialPath: string;
|
|
34
|
-
path: string;
|
|
35
|
-
svgSource: string;
|
|
36
|
-
svgOutput: string;
|
|
37
|
-
validateName(newValue?: string): void;
|
|
38
|
-
validateBase(newValue?: string): void;
|
|
39
|
-
validateFlipH(newValue?: boolean): void;
|
|
40
|
-
validateFlipV(newValue?: boolean): void;
|
|
42
|
+
readonly scale?: number;
|
|
41
43
|
validateScale(newValue?: number): void;
|
|
42
|
-
validateRotate(newValue?: number): void;
|
|
43
|
-
validateAnimation(newValue?: string): void;
|
|
44
44
|
connectedCallback(): void;
|
|
45
45
|
componentWillLoad(): void;
|
|
46
46
|
componentWillRender(): void;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
private fetchSVG;
|
|
48
|
+
private getPath;
|
|
49
49
|
render(): any;
|
|
50
50
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function checkOneOf<T>(value: T, possibleValues: T[], error: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function emptyOr<T extends unknown[]>(check: (...args: T) => void): (...args: T) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const checkEmptyOrOneOf: <T>(value: T, possibleValues: T[], error: string) => void;
|
|
2
|
+
export declare const checkEmptyOrType: (value: unknown, type: import("./check-type").PropertyType, error: string) => void;
|
|
3
|
+
export * from './check-one-of';
|
|
4
|
+
export * from './check-type';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swisspost/design-system-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "A collection of web components built with Stencil JS for the Swiss Post Design System.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -26,24 +26,29 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@popperjs/core": "2.11.6",
|
|
29
|
-
"@stencil/
|
|
29
|
+
"@stencil-community/eslint-plugin": "^0.5.0",
|
|
30
|
+
"@stencil/core": "3.1.0",
|
|
30
31
|
"@stencil/react-output-target": "0.4.0",
|
|
31
|
-
"@stencil/sass": "
|
|
32
|
-
"@swisspost/design-system-styles": "
|
|
33
|
-
"bootstrap": "5.
|
|
34
|
-
"
|
|
35
|
-
"
|
|
32
|
+
"@stencil/sass": "3.0.0",
|
|
33
|
+
"@swisspost/design-system-styles": "6.0.0",
|
|
34
|
+
"bootstrap": "5.2.3",
|
|
35
|
+
"eslint-plugin-react": "7.32.2",
|
|
36
|
+
"puppeteer": "19.7.4",
|
|
37
|
+
"sass": "1.59.2"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
|
-
"@percy/cli": "1.20.
|
|
40
|
+
"@percy/cli": "1.20.3",
|
|
39
41
|
"@percy/cypress": "3.1.2",
|
|
40
42
|
"@types/jest": "27.5.2",
|
|
41
|
-
"
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "5.54.1",
|
|
44
|
+
"@typescript-eslint/parser": "5.54.1",
|
|
45
|
+
"cypress": "12.7.0",
|
|
42
46
|
"cypress-storybook": "0.5.1",
|
|
47
|
+
"eslint": "8.36.0",
|
|
43
48
|
"jest": "27.5.1",
|
|
44
49
|
"jest-cli": "27.5.1",
|
|
45
50
|
"npm-run-all": "4.1.5",
|
|
46
|
-
"typescript": "4.
|
|
51
|
+
"typescript": "4.9.5"
|
|
47
52
|
},
|
|
48
53
|
"scripts": {
|
|
49
54
|
"start": "stencil build --watch --docs-readme",
|
|
@@ -54,6 +59,7 @@
|
|
|
54
59
|
"e2e": "cypress run",
|
|
55
60
|
"e2e:watch": "cypress open",
|
|
56
61
|
"snapshots": "percy exec -- cypress run --config-file ./cypress.snapshot.config.js",
|
|
57
|
-
"generate": "stencil generate"
|
|
62
|
+
"generate": "stencil generate",
|
|
63
|
+
"lint": "eslint src/**/*{.ts,.tsx}"
|
|
58
64
|
}
|
|
59
65
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const EMPTY_VALUES = [undefined, null, ''];
|
|
4
|
-
function checkType(value, type, errorMessage) {
|
|
5
|
-
const lowerCaseType = type.toLowerCase();
|
|
6
|
-
const typeIsArray = lowerCaseType === 'array';
|
|
7
|
-
const valueIsArray = Array.isArray(value);
|
|
8
|
-
if (typeIsArray || valueIsArray) {
|
|
9
|
-
if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))
|
|
10
|
-
throw new Error(errorMessage);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
if (typeof value !== lowerCaseType)
|
|
14
|
-
throw new Error(errorMessage);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function checkEmptyOrType(value, type, errorMessage) {
|
|
18
|
-
if (!EMPTY_VALUES.some(v => v === value))
|
|
19
|
-
checkType(value, type, errorMessage);
|
|
20
|
-
}
|
|
21
|
-
function checkOneOf(value, possibleValues, errorMessage) {
|
|
22
|
-
if (!possibleValues.includes(value))
|
|
23
|
-
throw new Error(errorMessage);
|
|
24
|
-
}
|
|
25
|
-
function checkEmptyOrOneOf(value, possibleValues, errorMessage) {
|
|
26
|
-
if (!EMPTY_VALUES.some(v => v === value))
|
|
27
|
-
checkOneOf(value, possibleValues, errorMessage);
|
|
28
|
-
}
|
|
29
|
-
function checkBoolean(value, errorMessage) {
|
|
30
|
-
if (typeof value !== 'boolean')
|
|
31
|
-
throw new Error(errorMessage);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
exports.checkBoolean = checkBoolean;
|
|
35
|
-
exports.checkEmptyOrOneOf = checkEmptyOrOneOf;
|
|
36
|
-
exports.checkEmptyOrType = checkEmptyOrType;
|
|
37
|
-
exports.checkOneOf = checkOneOf;
|
|
38
|
-
exports.checkType = checkType;
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=property-checkers-586ad9d4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"property-checkers-586ad9d4.js","mappings":";;AAAA,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;SAE3B,SAAS,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EAC1E,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;EACzC,MAAM,WAAW,GAAG,aAAa,KAAK,OAAO,CAAC;EAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,MAAM,CAAC,WAAW,IAAI,YAAY,CAAC;MAClE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACjC;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,aAAa;MAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACnE;AACH,CAAC;SAEe,gBAAgB,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EACjF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IAAE,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;AACjF,CAAC;SAEe,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC;SAEe,iBAAiB,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EACtF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IAAE,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AAC5F,CAAC;SAEe,YAAY,CAAC,KAAc,EAAE,YAAoB;EAC/D,IAAI,OAAO,KAAK,KAAK,SAAS;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChE;;;;;;;;","names":[],"sources":["./src/utils/property-checkers.ts"],"sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\n\nexport function checkType(value: unknown, type: string, errorMessage: string) {\n const lowerCaseType = type.toLowerCase();\n const typeIsArray = lowerCaseType === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))\n throw new Error(errorMessage);\n } else {\n if (typeof value !== lowerCaseType) throw new Error(errorMessage);\n }\n}\n\nexport function checkEmptyOrType(value: unknown, type: string, errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkType(value, type, errorMessage);\n}\n\nexport function checkOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!possibleValues.includes(value)) throw new Error(errorMessage);\n}\n\nexport function checkEmptyOrOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkOneOf(value, possibleValues, errorMessage);\n}\n\nexport function checkBoolean(value: unknown, errorMessage: string) {\n if (typeof value !== 'boolean') throw new Error(errorMessage);\n}\n"],"version":3}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const EMPTY_VALUES = [undefined, null, ''];
|
|
2
|
-
export function checkType(value, type, errorMessage) {
|
|
3
|
-
const lowerCaseType = type.toLowerCase();
|
|
4
|
-
const typeIsArray = lowerCaseType === 'array';
|
|
5
|
-
const valueIsArray = Array.isArray(value);
|
|
6
|
-
if (typeIsArray || valueIsArray) {
|
|
7
|
-
if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))
|
|
8
|
-
throw new Error(errorMessage);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
if (typeof value !== lowerCaseType)
|
|
12
|
-
throw new Error(errorMessage);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function checkEmptyOrType(value, type, errorMessage) {
|
|
16
|
-
if (!EMPTY_VALUES.some(v => v === value))
|
|
17
|
-
checkType(value, type, errorMessage);
|
|
18
|
-
}
|
|
19
|
-
export function checkOneOf(value, possibleValues, errorMessage) {
|
|
20
|
-
if (!possibleValues.includes(value))
|
|
21
|
-
throw new Error(errorMessage);
|
|
22
|
-
}
|
|
23
|
-
export function checkEmptyOrOneOf(value, possibleValues, errorMessage) {
|
|
24
|
-
if (!EMPTY_VALUES.some(v => v === value))
|
|
25
|
-
checkOneOf(value, possibleValues, errorMessage);
|
|
26
|
-
}
|
|
27
|
-
export function checkBoolean(value, errorMessage) {
|
|
28
|
-
if (typeof value !== 'boolean')
|
|
29
|
-
throw new Error(errorMessage);
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=property-checkers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"property-checkers.js","sourceRoot":"","sources":["../../src/utils/property-checkers.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AAE3C,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EAC1E,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;EACzC,MAAM,WAAW,GAAG,aAAa,KAAK,OAAO,CAAC;EAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW,IAAI,YAAY,CAAC;MAClE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACjC;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,aAAa;MAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACnE;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EACjF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC;IAAE,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EACtF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC;IAAE,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,YAAoB;EAC/D,IAAI,OAAO,KAAK,KAAK,SAAS;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChE,CAAC","sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\n\nexport function checkType(value: unknown, type: string, errorMessage: string) {\n const lowerCaseType = type.toLowerCase();\n const typeIsArray = lowerCaseType === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))\n throw new Error(errorMessage);\n } else {\n if (typeof value !== lowerCaseType) throw new Error(errorMessage);\n }\n}\n\nexport function checkEmptyOrType(value: unknown, type: string, errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkType(value, type, errorMessage);\n}\n\nexport function checkOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!possibleValues.includes(value)) throw new Error(errorMessage);\n}\n\nexport function checkEmptyOrOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkOneOf(value, possibleValues, errorMessage);\n}\n\nexport function checkBoolean(value: unknown, errorMessage: string) {\n if (typeof value !== 'boolean') throw new Error(errorMessage);\n}\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const EMPTY_VALUES = [undefined, null, ''];
|
|
2
|
-
function checkType(value, type, errorMessage) {
|
|
3
|
-
const lowerCaseType = type.toLowerCase();
|
|
4
|
-
const typeIsArray = lowerCaseType === 'array';
|
|
5
|
-
const valueIsArray = Array.isArray(value);
|
|
6
|
-
if (typeIsArray || valueIsArray) {
|
|
7
|
-
if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))
|
|
8
|
-
throw new Error(errorMessage);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
if (typeof value !== lowerCaseType)
|
|
12
|
-
throw new Error(errorMessage);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function checkEmptyOrType(value, type, errorMessage) {
|
|
16
|
-
if (!EMPTY_VALUES.some(v => v === value))
|
|
17
|
-
checkType(value, type, errorMessage);
|
|
18
|
-
}
|
|
19
|
-
function checkOneOf(value, possibleValues, errorMessage) {
|
|
20
|
-
if (!possibleValues.includes(value))
|
|
21
|
-
throw new Error(errorMessage);
|
|
22
|
-
}
|
|
23
|
-
function checkEmptyOrOneOf(value, possibleValues, errorMessage) {
|
|
24
|
-
if (!EMPTY_VALUES.some(v => v === value))
|
|
25
|
-
checkOneOf(value, possibleValues, errorMessage);
|
|
26
|
-
}
|
|
27
|
-
function checkBoolean(value, errorMessage) {
|
|
28
|
-
if (typeof value !== 'boolean')
|
|
29
|
-
throw new Error(errorMessage);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { checkOneOf as a, checkType as b, checkBoolean as c, checkEmptyOrType as d, checkEmptyOrOneOf as e };
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=property-checkers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"property-checkers.js","mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;SAE3B,SAAS,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EAC1E,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;EACzC,MAAM,WAAW,GAAG,aAAa,KAAK,OAAO,CAAC;EAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,MAAM,CAAC,WAAW,IAAI,YAAY,CAAC;MAClE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACjC;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,aAAa;MAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACnE;AACH,CAAC;SAEe,gBAAgB,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EACjF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IAAE,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;AACjF,CAAC;SAEe,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC;SAEe,iBAAiB,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EACtF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IAAE,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AAC5F,CAAC;SAEe,YAAY,CAAC,KAAc,EAAE,YAAoB;EAC/D,IAAI,OAAO,KAAK,KAAK,SAAS;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChE;;;;","names":[],"sources":["./src/utils/property-checkers.ts"],"sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\n\nexport function checkType(value: unknown, type: string, errorMessage: string) {\n const lowerCaseType = type.toLowerCase();\n const typeIsArray = lowerCaseType === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))\n throw new Error(errorMessage);\n } else {\n if (typeof value !== lowerCaseType) throw new Error(errorMessage);\n }\n}\n\nexport function checkEmptyOrType(value: unknown, type: string, errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkType(value, type, errorMessage);\n}\n\nexport function checkOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!possibleValues.includes(value)) throw new Error(errorMessage);\n}\n\nexport function checkEmptyOrOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkOneOf(value, possibleValues, errorMessage);\n}\n\nexport function checkBoolean(value: unknown, errorMessage: string) {\n if (typeof value !== 'boolean') throw new Error(errorMessage);\n}\n"],"version":3}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const EMPTY_VALUES = [undefined, null, ''];
|
|
2
|
-
function checkType(value, type, errorMessage) {
|
|
3
|
-
const lowerCaseType = type.toLowerCase();
|
|
4
|
-
const typeIsArray = lowerCaseType === 'array';
|
|
5
|
-
const valueIsArray = Array.isArray(value);
|
|
6
|
-
if (typeIsArray || valueIsArray) {
|
|
7
|
-
if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))
|
|
8
|
-
throw new Error(errorMessage);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
if (typeof value !== lowerCaseType)
|
|
12
|
-
throw new Error(errorMessage);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function checkEmptyOrType(value, type, errorMessage) {
|
|
16
|
-
if (!EMPTY_VALUES.some(v => v === value))
|
|
17
|
-
checkType(value, type, errorMessage);
|
|
18
|
-
}
|
|
19
|
-
function checkOneOf(value, possibleValues, errorMessage) {
|
|
20
|
-
if (!possibleValues.includes(value))
|
|
21
|
-
throw new Error(errorMessage);
|
|
22
|
-
}
|
|
23
|
-
function checkEmptyOrOneOf(value, possibleValues, errorMessage) {
|
|
24
|
-
if (!EMPTY_VALUES.some(v => v === value))
|
|
25
|
-
checkOneOf(value, possibleValues, errorMessage);
|
|
26
|
-
}
|
|
27
|
-
function checkBoolean(value, errorMessage) {
|
|
28
|
-
if (typeof value !== 'boolean')
|
|
29
|
-
throw new Error(errorMessage);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { checkOneOf as a, checkType as b, checkBoolean as c, checkEmptyOrType as d, checkEmptyOrOneOf as e };
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=property-checkers-484ca671.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"property-checkers-484ca671.js","mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;SAE3B,SAAS,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EAC1E,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;EACzC,MAAM,WAAW,GAAG,aAAa,KAAK,OAAO,CAAC;EAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,MAAM,CAAC,WAAW,IAAI,YAAY,CAAC;MAClE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACjC;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,aAAa;MAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACnE;AACH,CAAC;SAEe,gBAAgB,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EACjF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IAAE,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;AACjF,CAAC;SAEe,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC;SAEe,iBAAiB,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EACtF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IAAE,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AAC5F,CAAC;SAEe,YAAY,CAAC,KAAc,EAAE,YAAoB;EAC/D,IAAI,OAAO,KAAK,KAAK,SAAS;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChE;;;;","names":[],"sources":["./src/utils/property-checkers.ts"],"sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\n\nexport function checkType(value: unknown, type: string, errorMessage: string) {\n const lowerCaseType = type.toLowerCase();\n const typeIsArray = lowerCaseType === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))\n throw new Error(errorMessage);\n } else {\n if (typeof value !== lowerCaseType) throw new Error(errorMessage);\n }\n}\n\nexport function checkEmptyOrType(value: unknown, type: string, errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkType(value, type, errorMessage);\n}\n\nexport function checkOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!possibleValues.includes(value)) throw new Error(errorMessage);\n}\n\nexport function checkEmptyOrOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkOneOf(value, possibleValues, errorMessage);\n}\n\nexport function checkBoolean(value: unknown, errorMessage: string) {\n if (typeof value !== 'boolean') throw new Error(errorMessage);\n}\n"],"version":3}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const n=[undefined,null,""];function o(n,o,r){const t=o.toLowerCase();const f=t==="array";const e=Array.isArray(n);if(f||e){if(f&&!e||!f&&e)throw new Error(r)}else{if(typeof n!==t)throw new Error(r)}}function r(r,t,f){if(!n.some((n=>n===r)))o(r,t,f)}function t(n,o,r){if(!o.includes(n))throw new Error(r)}function f(o,r,f){if(!n.some((n=>n===o)))t(o,r,f)}function e(n,o){if(typeof n!=="boolean")throw new Error(o)}export{t as a,o as b,e as c,r as d,f as e};
|
|
2
|
-
//# sourceMappingURL=p-7cd9c1ad.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["EMPTY_VALUES","undefined","checkType","value","type","errorMessage","lowerCaseType","toLowerCase","typeIsArray","valueIsArray","Array","isArray","Error","checkEmptyOrType","some","v","checkOneOf","possibleValues","includes","checkEmptyOrOneOf","checkBoolean"],"sources":["./src/utils/property-checkers.ts"],"sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\n\nexport function checkType(value: unknown, type: string, errorMessage: string) {\n const lowerCaseType = type.toLowerCase();\n const typeIsArray = lowerCaseType === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))\n throw new Error(errorMessage);\n } else {\n if (typeof value !== lowerCaseType) throw new Error(errorMessage);\n }\n}\n\nexport function checkEmptyOrType(value: unknown, type: string, errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkType(value, type, errorMessage);\n}\n\nexport function checkOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!possibleValues.includes(value)) throw new Error(errorMessage);\n}\n\nexport function checkEmptyOrOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkOneOf(value, possibleValues, errorMessage);\n}\n\nexport function checkBoolean(value: unknown, errorMessage: string) {\n if (typeof value !== 'boolean') throw new Error(errorMessage);\n}\n"],"mappings":"AAAA,MAAMA,EAAe,CAACC,UAAW,KAAM,I,SAEvBC,EAAUC,EAAgBC,EAAcC,GACtD,MAAMC,EAAgBF,EAAKG,cAC3B,MAAMC,EAAcF,IAAkB,QACtC,MAAMG,EAAeC,MAAMC,QAAQR,GAEnC,GAAIK,GAAeC,EAAc,CAC/B,GAAKD,IAAgBC,IAAmBD,GAAeC,EACrD,MAAM,IAAIG,MAAMP,E,KACb,CACL,UAAWF,IAAUG,EAAe,MAAM,IAAIM,MAAMP,E,CAExD,C,SAEgBQ,EAAiBV,EAAgBC,EAAcC,GAC7D,IAAKL,EAAac,MAAKC,GAAKA,IAAMZ,IAAQD,EAAUC,EAAOC,EAAMC,EACnE,C,SAEgBW,EAAcb,EAAUc,EAAqBZ,GAC3D,IAAKY,EAAeC,SAASf,GAAQ,MAAM,IAAIS,MAAMP,EACvD,C,SAEgBc,EAAqBhB,EAAUc,EAAqBZ,GAClE,IAAKL,EAAac,MAAKC,GAAKA,IAAMZ,IAAQa,EAAWb,EAAOc,EAAgBZ,EAC9E,C,SAEgBe,EAAajB,EAAgBE,GAC3C,UAAWF,IAAU,UAAW,MAAM,IAAIS,MAAMP,EAClD,Q"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as i,h as t,H as n}from"./p-a93114b9.js";import{b as s,d as e,e as o}from"./p-7cd9c1ad.js";const a=":host{display:inline-block;width:1em;vertical-align:-0.15em}svg{display:block;width:100%;fill:currentColor}:host([flip-h]) svg{scale:-1 1}:host([flip-v]) svg{scale:1 -1}:host([flip-h][flip-v]) svg{scale:-1}:host([animation]) svg{transform-origin:center}:host([animation=cylon]) svg{animation:icon-animation-cylon 0.75s ease-in-out infinite alternate}:host([animation=cylon-vertical]) svg{animation:icon-animation-cylon-vertical 0.75s ease-in-out infinite alternate}:host([animation=spin]) svg{animation:icon-animation-spin 2s linear infinite normal}:host([animation=spin-reverse]) svg{animation:icon-animation-spin 2s linear infinite reverse}:host([animation=fade]) svg{animation:icon-animation-fade 0.75s ease-in-out infinite alternate}:host([animation=throb]) svg{animation:icon-animation-throb 0.75s ease-in-out infinite alternate}@keyframes icon-animation-cylon{from{transform:translateX(-25%)}to{transform:translateX(25%)}}@keyframes icon-animation-cylon-vertical{from{transform:translateY(25%)}to{transform:translateY(-25%)}}@keyframes icon-animation-fade{from{opacity:0.1}to{opacity:1}}@keyframes icon-animation-spin{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes icon-animation-throb{from{opacity:0.5;transform:scale(0.5)}to{opacity:1;transform:scale(1)}}";const l="https://unpkg.com/@swisspost/design-system-icons/public/post-icons";const r=["cylon","cylon-vertical","spin","spin-reverse","fade","throb"];const h=class{constructor(t){i(this,t);this.name=undefined;this.base=undefined;this.flipH=undefined;this.flipV=undefined;this.scale=undefined;this.rotate=undefined;this.animation=undefined;this.initialPath=undefined;this.path=undefined;this.svgSource='<svg viewBox="0 0 16 16"></svg>';this.svgOutput=undefined}validateName(i=this.name){s(i,"string",'The post-icon "name" prop should be a string.')}validateBase(i=this.base){e(i,"string",'The post-icon "base" prop should be a string.')}validateFlipH(i=this.flipH){e(i,"boolean",'The post-icon "flipH" prop should be a boolean.')}validateFlipV(i=this.flipV){e(i,"boolean",'The post-icon "flipV" prop should be a boolean.')}validateScale(i=this.scale){e(i,"number",'The post-icon "scale" prop should be a number.')}validateRotate(i=this.rotate){e(i,"number",'The post-icon "rotate" prop should be a number.')}validateAnimation(i=this.animation){if(i!==undefined)o(i,r,`The post-icon "animation" prop requires one of the following values: ${r.join(", ")}.`)}connectedCallback(){var i;let t;const n=document.head.querySelector('meta[name="design-system-settings"][data-post-icon-base]');if(this.base){t=this.base}else if(n){t=n.getAttribute("data-post-icon-base")}else{t=l}this.path=this.getPath(t);this.svgSource=(i=window.localStorage.getItem(`post-icon-${this.name}`))!==null&&i!==void 0?i:this.svgSource}componentWillLoad(){this.validateName();this.validateBase();this.validateFlipH();this.validateFlipV();this.validateScale();this.validateRotate();this.validateAnimation();this.fetchSVG()}componentWillRender(){const i=Object.entries({scale:this.scale&&!isNaN(Number(this.scale))?`${this.scale}`:null,rotate:this.rotate&&!isNaN(Number(this.rotate))?`${this.rotate}deg`:null}).filter((([i,t])=>t!==null)).map((([i,t])=>`${i}: ${t}`)).join(";");const t=document.createElement("div");t.innerHTML=this.svgSource;const n=t.querySelector("svg");n.setAttribute("style",i);this.svgOutput=t.innerHTML}getPath(i){return new URL([...i.split("/"),`${this.name}.svg#icon`].join("/"),window.location.origin).toString()}fetchSVG(){fetch(this.path).then((i=>i.text())).then((i=>{const t=i.match(/^<svg\b([\s\S]*)><\/svg>/);if(t!==null){this.svgSource=t[0];window.localStorage.setItem(`post-icon-${this.name}`,this.svgSource)}else{this.initialPath=this.path;this.path=this.getPath(l);if(this.initialPath!==this.path){console.warn(`Warning in <post-icon/>: The content on the path "${this.path}" seems to be no svg-only content. We'll gonna try to load the icon from the cdn.`);this.fetchSVG()}else{console.error(`Error in <post-icon/>: Could not load the svg on the path "${this.initialPath}"!`)}}})).catch((i=>{console.log(i)}))}render(){return t(n,null,t("div",{innerHTML:this.svgOutput}))}static get watchers(){return{name:["validateName"],base:["validateBase"],flipH:["validateFlipH"],flipV:["validateFlipV"],scale:["validateScale"],rotate:["validateRotate"],animation:["validateAnimation"]}}};h.style=a;export{h as post_icon};
|
|
2
|
-
//# sourceMappingURL=p-b07185a3.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["postIconCss","CDN_URL","ANIMATION_KEYS","PostIcon","validateName","newValue","this","name","checkType","validateBase","base","checkEmptyOrType","validateFlipH","flipH","validateFlipV","flipV","validateScale","scale","validateRotate","rotate","validateAnimation","animation","undefined","checkEmptyOrOneOf","join","connectedCallback","basePath","metaBase","document","head","querySelector","getAttribute","path","getPath","svgSource","_a","window","localStorage","getItem","componentWillLoad","fetchSVG","componentWillRender","svgStyles","Object","entries","isNaN","Number","filter","_key","value","map","key","helperElement","createElement","innerHTML","svgElement","setAttribute","svgOutput","URL","split","location","origin","toString","fetch","then","response","text","textResponse","match","setItem","initialPath","console","warn","error","catch","log","render","h","Host"],"sources":["./src/components/post-icon/post-icon.scss?tag=post-icon&encapsulation=shadow","./src/components/post-icon/post-icon.tsx"],"sourcesContent":["@use 'sass:map';\n\n$post-icon-animations: (\n 'cylon': icon-animation-cylon .75s ease-in-out infinite alternate,\n 'cylon-vertical': icon-animation-cylon-vertical .75s ease-in-out infinite alternate,\n 'spin': icon-animation-spin 2s linear infinite normal,\n 'spin-reverse': icon-animation-spin 2s linear infinite reverse,\n 'fade': icon-animation-fade .75s ease-in-out infinite alternate,\n 'throb': icon-animation-throb .75s ease-in-out infinite alternate\n);\n\n:host {\n display: inline-block;\n width: 1em;\n vertical-align: -0.15em;\n}\n\nsvg {\n display: block;\n width: 100%;\n fill: currentColor;\n}\n\n// flip\n\n:host([flip-h]) {\n svg { scale: -1 1; }\n}\n\n:host([flip-v]) {\n svg { scale: 1 -1; }\n}\n\n:host([flip-h][flip-v]) {\n svg { scale: -1; }\n}\n\n// scale\n// done with inline styling\n\n// rotate\n// done with inline styling\n\n// animation\n\n:host([animation]) {\n svg {\n transform-origin: center;\n }\n}\n\n@each $key, $value in $post-icon-animations {\n :host([animation=\"#{$key}\"]) {\n svg {\n animation: $value;\n }\n }\n}\n\n@keyframes icon-animation-cylon {\n from { transform: translateX(-25%) }\n to { transform: translateX(25%) }\n}\n\n@keyframes icon-animation-cylon-vertical {\n from { transform: translateY(25%); }\n to { transform: translateY(-25%); }\n}\n\n@keyframes icon-animation-fade {\n from { opacity: .1; }\n to { opacity: 1; }\n}\n\n@keyframes icon-animation-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(359deg); }\n}\n\n@keyframes icon-animation-throb {\n from {\n opacity: .5;\n transform: scale(0.5);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n","import { Component, Host, h, Prop, State, Watch } from '@stencil/core';\nimport { checkType, checkEmptyOrType, checkEmptyOrOneOf } from '../../utils';\n\nconst CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';\nconst ANIMATION_KEYS = [\n 'cylon',\n 'cylon-vertical',\n 'spin',\n 'spin-reverse',\n 'fade',\n 'throb'\n];\n\n/**\n * @class PostIcon - representing a stencil component\n */\n@Component({\n tag: 'post-icon',\n styleUrl: 'post-icon.scss',\n shadow: true,\n})\nexport class PostIcon {\n /**\n * The name/id of the icon (e.g. 1000, 1001, ...).\n */\n @Prop() name: string;\n\n /**\n * The base path, where the icons are located (must be a public url).\n */\n @Prop() base?: string;\n\n /**\n * When set to `true`, the icon will be flipped horizontally.\n */\n @Prop() flipH?: boolean;\n\n /**\n * When set to `true`, the icon will be flipped vertically.\n */\n @Prop() flipV?: boolean;\n\n /**\n * The `number` for the css `scale` transformation.\n */\n @Prop() scale?: number;\n\n /**\n * The `number` of degree for the css `rotate` transformation.\n */\n @Prop() rotate?: number;\n\n /**\n * The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`).\n */\n @Prop() animation?: string;\n @State() initialPath: string;\n @State() path: string;\n @State() svgSource: string = '<svg viewBox=\"0 0 16 16\"></svg>';\n @State() svgOutput: string;\n\n @Watch('name')\n validateName(newValue = this.name) {\n checkType(newValue, 'string', 'The post-icon \"name\" prop should be a string.');\n }\n\n @Watch('base')\n validateBase(newValue = this.base) {\n checkEmptyOrType(newValue, 'string', 'The post-icon \"base\" prop should be a string.');\n }\n\n @Watch('flipH')\n validateFlipH(newValue = this.flipH) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipH\" prop should be a boolean.');\n }\n\n @Watch('flipV')\n validateFlipV(newValue = this.flipV) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipV\" prop should be a boolean.');\n }\n\n @Watch('scale')\n validateScale(newValue = this.scale) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"scale\" prop should be a number.');\n }\n\n @Watch('rotate')\n validateRotate(newValue = this.rotate) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"rotate\" prop should be a number.');\n }\n\n @Watch('animation')\n validateAnimation(newValue = this.animation) {\n if (newValue !== undefined) checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon \"animation\" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);\n }\n\n connectedCallback() {\n // Construct icon path from different possible sources\n let basePath: string;\n const metaBase = document.head.querySelector(\n 'meta[name=\"design-system-settings\"][data-post-icon-base]',\n );\n\n if (this.base) {\n basePath = this.base;\n } else if (metaBase) {\n basePath = metaBase.getAttribute('data-post-icon-base');\n } else {\n basePath = CDN_URL;\n }\n\n this.path = this.getPath(basePath);\n this.svgSource = window.localStorage.getItem(`post-icon-${this.name}`) ?? this.svgSource;\n }\n\n componentWillLoad() {\n this.validateName();\n this.validateBase();\n this.validateFlipH();\n this.validateFlipV();\n this.validateScale();\n this.validateRotate();\n this.validateAnimation();\n\n this.fetchSVG();\n }\n\n componentWillRender() {\n const svgStyles = Object.entries({\n scale: this.scale && !isNaN(Number(this.scale)) ? `${this.scale}` : null,\n rotate: this.rotate && !isNaN(Number(this.rotate)) ? `${this.rotate}deg` : null,\n })\n .filter(([_key, value]) => value !== null)\n .map(([key, value]) => `${key}: ${value}`)\n .join(';');\n\n const helperElement = document.createElement('div');\n helperElement.innerHTML = this.svgSource;\n\n const svgElement = helperElement.querySelector('svg');\n svgElement.setAttribute('style', svgStyles);\n\n this.svgOutput = helperElement.innerHTML;\n }\n\n getPath(basePath: string) {\n return new URL(\n [...basePath.split('/'), `${this.name}.svg#icon`].join('/'),\n window.location.origin,\n ).toString();\n }\n\n fetchSVG() {\n fetch(this.path)\n .then(response => response.text())\n .then(textResponse => {\n const match = textResponse.match(/^<svg\\b([\\s\\S]*)><\\/svg>/);\n\n if (match !== null) {\n this.svgSource = match[0];\n window.localStorage.setItem(`post-icon-${this.name}`, this.svgSource);\n } else {\n this.initialPath = this.path;\n this.path = this.getPath(CDN_URL);\n\n if (this.initialPath !== this.path) {\n console.warn(\n `Warning in <post-icon/>: The content on the path \"${this.path}\" seems to be no svg-only content. We'll gonna try to load the icon from the cdn.`,\n );\n this.fetchSVG();\n } else {\n console.error(\n `Error in <post-icon/>: Could not load the svg on the path \"${this.initialPath}\"!`,\n );\n }\n }\n })\n .catch(error => {\n console.log(error);\n });\n }\n\n render() {\n return (\n <Host>\n <div innerHTML={this.svgOutput} />\n </Host>\n );\n }\n}\n"],"mappings":"oGAAA,MAAMA,EAAc,uwCCGpB,MAAMC,EAAU,qEAChB,MAAMC,EAAiB,CACrB,QACA,iBACA,OACA,eACA,OACA,S,MAWWC,EAAQ,M,6OAqCU,kC,yBAI7BC,aAAaC,EAAWC,KAAKC,MAC3BC,EAAUH,EAAU,SAAU,gD,CAIhCI,aAAaJ,EAAWC,KAAKI,MAC3BC,EAAiBN,EAAU,SAAU,gD,CAIvCO,cAAcP,EAAWC,KAAKO,OAC5BF,EAAiBN,EAAU,UAAW,kD,CAIxCS,cAAcT,EAAWC,KAAKS,OAC5BJ,EAAiBN,EAAU,UAAW,kD,CAIxCW,cAAcX,EAAWC,KAAKW,OAC5BN,EAAiBN,EAAU,SAAU,iD,CAIvCa,eAAeb,EAAWC,KAAKa,QAC7BR,EAAiBN,EAAU,SAAU,kD,CAIvCe,kBAAkBf,EAAWC,KAAKe,WAChC,GAAIhB,IAAaiB,UAAWC,EAAkBlB,EAAUH,EAAgB,wEAAwEA,EAAesB,KAAK,S,CAGtKC,oB,MAEE,IAAIC,EACJ,MAAMC,EAAWC,SAASC,KAAKC,cAC7B,4DAGF,GAAIxB,KAAKI,KAAM,CACbgB,EAAWpB,KAAKI,I,MACX,GAAIiB,EAAU,CACnBD,EAAWC,EAASI,aAAa,sB,KAC5B,CACLL,EAAWzB,C,CAGbK,KAAK0B,KAAO1B,KAAK2B,QAAQP,GACzBpB,KAAK4B,WAAYC,EAAAC,OAAOC,aAAaC,QAAQ,aAAahC,KAAKC,WAAO,MAAA4B,SAAA,EAAAA,EAAI7B,KAAK4B,S,CAGjFK,oBACEjC,KAAKF,eACLE,KAAKG,eACLH,KAAKM,gBACLN,KAAKQ,gBACLR,KAAKU,gBACLV,KAAKY,iBACLZ,KAAKc,oBAELd,KAAKkC,U,CAGPC,sBACE,MAAMC,EAAYC,OAAOC,QAAQ,CAC/B3B,MAAOX,KAAKW,QAAU4B,MAAMC,OAAOxC,KAAKW,QAAU,GAAGX,KAAKW,QAAU,KACpEE,OAAQb,KAAKa,SAAW0B,MAAMC,OAAOxC,KAAKa,SAAW,GAAGb,KAAKa,YAAc,OAE1E4B,QAAO,EAAEC,EAAMC,KAAWA,IAAU,OACpCC,KAAI,EAAEC,EAAKF,KAAW,GAAGE,MAAQF,MACjCzB,KAAK,KAER,MAAM4B,EAAgBxB,SAASyB,cAAc,OAC7CD,EAAcE,UAAYhD,KAAK4B,UAE/B,MAAMqB,EAAaH,EAActB,cAAc,OAC/CyB,EAAWC,aAAa,QAASd,GAEjCpC,KAAKmD,UAAYL,EAAcE,S,CAGjCrB,QAAQP,GACN,OAAO,IAAIgC,IACT,IAAIhC,EAASiC,MAAM,KAAM,GAAGrD,KAAKC,iBAAiBiB,KAAK,KACvDY,OAAOwB,SAASC,QAChBC,U,CAGJtB,WACEuB,MAAMzD,KAAK0B,MACRgC,MAAKC,GAAYA,EAASC,SAC1BF,MAAKG,IACJ,MAAMC,EAAQD,EAAaC,MAAM,4BAEjC,GAAIA,IAAU,KAAM,CAClB9D,KAAK4B,UAAYkC,EAAM,GACvBhC,OAAOC,aAAagC,QAAQ,aAAa/D,KAAKC,OAAQD,KAAK4B,U,KACtD,CACL5B,KAAKgE,YAAchE,KAAK0B,KACxB1B,KAAK0B,KAAO1B,KAAK2B,QAAQhC,GAEzB,GAAIK,KAAKgE,cAAgBhE,KAAK0B,KAAM,CAClCuC,QAAQC,KACN,qDAAqDlE,KAAK0B,yFAE5D1B,KAAKkC,U,KACA,CACL+B,QAAQE,MACN,8DAA8DnE,KAAKgE,gB,MAK1EI,OAAMD,IACLF,QAAQI,IAAIF,EAAM,G,CAIxBG,SACE,OACEC,EAACC,EAAI,KACHD,EAAA,OAAKvB,UAAWhD,KAAKmD,Y"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getElementHeight","el","classesWhenShown","Array","isArray","classesToAdd","filter","klass","classList","contains","length","add","scrollHeight","remove","shouldReduceMotion","window","matchMedia","matches","async","onTransitionEnd","Promise","resolve","ontransitionend","postCollapsibleCss","nextId","PostCollapsible","this","isLoaded","validateCollapsed","newValue","collapsed","checkBoolean","isOpen","collapseClasses","getCollapseClasses","setTimeout","toggle","validateHeadingLevel","headingLevel","checkOneOf","headingTag","componentWillLoad","hasHeader","host","querySelectorAll","console","warn","collapsibleId","id","componentDidLoad","collapsibleElement","shadowRoot","querySelector","open","startTransition","then","collapseHeight","expandedHeight","render","h","class","style","height","type","onClick","name"],"sources":["./src/utils/get-element-height.ts","./src/utils/should-reduce-motion.ts","./src/utils/on-transition-end.ts","./src/components/post-collapsible/post-collapsible.scss?tag=post-collapsible&encapsulation=shadow","./src/components/post-collapsible/post-collapsible.tsx"],"sourcesContent":["/*\n * Copyright 2022 by Swiss Post, Information Technology\n */\n\nexport function getElementHeight(el: HTMLElement): number;\nexport function getElementHeight(el: HTMLElement, classWhenShown: string): number;\nexport function getElementHeight(el: HTMLElement, classesWhenShown: string[]): number;\nexport function getElementHeight(el: HTMLElement, classesWhenShown: any = []): number {\n if (!Array.isArray(classesWhenShown)) classesWhenShown = [classesWhenShown];\n\n const classesToAdd = classesWhenShown.filter(klass => !el.classList.contains(klass));\n if (classesToAdd.length) el.classList.add(...classesToAdd);\n\n const scrollHeight = el.scrollHeight;\n\n if (classesToAdd.length) el.classList.remove(...classesToAdd);\n\n return scrollHeight;\n}\n","/*\n * Copyright 2022 by Swiss Post, Information Technology\n */\n\nexport function shouldReduceMotion(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n","/*\n * Copyright 2022 by Swiss Post, Information Technology\n */\n\nimport { shouldReduceMotion } from './should-reduce-motion';\n\nexport async function onTransitionEnd(el: HTMLElement): Promise<void> {\n return new Promise(resolve => {\n if (shouldReduceMotion()) {\n resolve();\n } else {\n el.ontransitionend = () => {\n resolve();\n el.ontransitionend = null;\n };\n }\n });\n}\n","@use '@swisspost/design-system-styles/basics';\n@use '@swisspost/design-system-styles/components/accordion';\n@use '@swisspost/design-system-styles/components/transitions';\n\n:host {\n display: block;\n}\n","import { Component, Element, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { checkBoolean, checkOneOf, getElementHeight, onTransitionEnd } from '../../utils';\n\nlet nextId = 0;\n\n@Component({\n tag: 'post-collapsible',\n styleUrl: 'post-collapsible.scss',\n shadow: true,\n})\nexport class PostCollapsible {\n /**\n * If `true`, the element is initially collapsed otherwise it is displayed.\n */\n @Prop() collapsed?: boolean = false;\n\n /**\n * Defines the hierarchical level of the collapsible header within the headings structure.\n */\n @Prop() headingLevel?: number = 2;\n\n @State() isOpen = true;\n @State() collapseClasses: string;\n @State() collapseHeight: string | null = null;\n @State() headingTag: string | undefined;\n @State() collapsibleId: string;\n @State() hasHeader: boolean;\n\n @Element() host: HTMLElement;\n\n isLoaded = false;\n collapsibleElement: HTMLElement;\n\n @Watch('collapsed')\n validateCollapsed(newValue = this.collapsed) {\n checkBoolean(newValue, 'The post-collapsible \"collapsed\" prop should be a boolean.');\n\n if (!this.isLoaded) {\n this.isOpen = !newValue;\n this.collapseClasses = this.getCollapseClasses();\n } else {\n setTimeout(() => {\n this.toggle(!newValue);\n });\n }\n }\n\n @Watch('headingLevel')\n validateHeadingLevel(newValue = this.headingLevel) {\n checkOneOf(\n newValue,\n [ 1, 2, 3, 4, 5, 6 ],\n 'The post-collapsible element requires a heading level between 1 and 6.',\n );\n\n this.headingTag = `h${newValue}`;\n }\n\n componentWillLoad() {\n this.validateCollapsed();\n this.validateHeadingLevel();\n\n this.hasHeader = this.host.querySelectorAll('[slot=\"header\"]').length > 0;\n if (!this.hasHeader) {\n console.warn('Be sure to bind the post-collapsible to its control using aria-controls and aria-expanded attributes. More information here: https://getbootstrap.com/docs/5.2/components/collapse/#accessibility');\n }\n\n this.collapsibleId = this.host.id || `post-collapsible-${nextId++}`;\n this.collapseClasses = this.getCollapseClasses();\n }\n\n componentDidLoad() {\n this.isLoaded = true;\n this.collapsibleElement = this.host.shadowRoot.querySelector(`#${this.collapsibleId}--collapse`);\n }\n\n /**\n * Triggers the collapse programmatically.\n */\n @Method()\n async toggle(open: boolean = !this.isOpen): Promise<boolean> {\n if (open !== this.isOpen) {\n this.isOpen = !this.isOpen;\n\n this.startTransition();\n\n await onTransitionEnd(this.collapsibleElement).then(() => {\n this.collapseHeight = null;\n this.collapseClasses = this.getCollapseClasses();\n });\n\n return this.isOpen;\n }\n }\n\n startTransition() {\n const expandedHeight = getElementHeight(this.collapsibleElement, 'show');\n\n this.collapseHeight = `${this.isOpen ? 0 : expandedHeight}px`;\n this.collapseClasses = 'collapsing';\n\n setTimeout(() => {\n this.collapseHeight = `${this.isOpen ? expandedHeight : 0}px`;\n }, 50);\n }\n\n private getCollapseClasses() {\n return this.isOpen ? 'collapse show' : 'collapse';\n }\n\n render() {\n if (!this.hasHeader) {\n return (\n <div\n id={`${this.collapsibleId}--collapse`}\n class={this.collapseClasses}\n style={{ height: this.collapseHeight }}\n >\n <slot/>\n </div>\n );\n }\n\n return (\n <div class=\"accordion-item\">\n <this.headingTag class=\"accordion-header\" id={`${this.collapsibleId}--header`}>\n <button\n class={`accordion-button ${this.isOpen ? '' : 'collapsed'}`}\n type=\"button\"\n aria-expanded={`${this.isOpen}`}\n aria-controls={`${this.collapsibleId}--collapse`}\n onClick={() => this.toggle()}\n >\n <slot name=\"header\"/>\n </button>\n </this.headingTag>\n <div\n id={`${this.collapsibleId}--collapse`}\n class={`accordion-collapse ${this.collapseClasses}`}\n style={{ height: this.collapseHeight }}\n aria-labelledby={`${this.collapsibleId}--header`}\n >\n <div class=\"accordion-body\">\n <slot/>\n </div>\n </div>\n </div>\n );\n }\n}\n"],"mappings":"iGAOgBA,EAAiBC,EAAiBC,EAAwB,IACxE,IAAKC,MAAMC,QAAQF,GAAmBA,EAAmB,CAACA,GAE1D,MAAMG,EAAeH,EAAiBI,QAAOC,IAAUN,EAAGO,UAAUC,SAASF,KAC7E,GAAIF,EAAaK,OAAQT,EAAGO,UAAUG,OAAON,GAE7C,MAAMO,EAAeX,EAAGW,aAExB,GAAIP,EAAaK,OAAQT,EAAGO,UAAUK,UAAUR,GAEhD,OAAOO,CACT,C,SCdgBE,IACd,OAAOC,OAAOC,WAAW,oCAAoCC,OAC/D,CCAOC,eAAeC,EAAgBlB,GACpC,OAAO,IAAImB,SAAQC,IACjB,GAAIP,IAAsB,CACxBO,G,KACK,CACLpB,EAAGqB,gBAAkB,KACnBD,IACApB,EAAGqB,gBAAkB,IAAI,C,IAIjC,CCjBA,MAAMC,EAAqB,wl3LCG3B,IAAIC,EAAS,E,MAOAC,EAAe,M,yBAoB1BC,KAAAC,SAAW,M,eAhBmB,M,kBAKE,E,YAEd,K,mDAEuB,K,gFAWzCC,kBAAkBC,EAAWH,KAAKI,WAChCC,EAAaF,EAAU,8DAEvB,IAAKH,KAAKC,SAAU,CAClBD,KAAKM,QAAUH,EACfH,KAAKO,gBAAkBP,KAAKQ,oB,KACvB,CACLC,YAAW,KACTT,KAAKU,QAAQP,EAAS,G,EAM5BQ,qBAAqBR,EAAWH,KAAKY,cACnCC,EACEV,EACA,CAAE,EAAG,EAAG,EAAG,EAAG,EAAG,GACjB,0EAGFH,KAAKc,WAAa,IAAIX,G,CAGxBY,oBACEf,KAAKE,oBACLF,KAAKW,uBAELX,KAAKgB,UAAYhB,KAAKiB,KAAKC,iBAAiB,mBAAmBlC,OAAS,EACxE,IAAKgB,KAAKgB,UAAW,CACnBG,QAAQC,KAAK,oM,CAGfpB,KAAKqB,cAAgBrB,KAAKiB,KAAKK,IAAM,oBAAoBxB,MACzDE,KAAKO,gBAAkBP,KAAKQ,oB,CAG9Be,mBACEvB,KAAKC,SAAW,KAChBD,KAAKwB,mBAAqBxB,KAAKiB,KAAKQ,WAAWC,cAAc,IAAI1B,KAAKqB,0B,CAOxE7B,aAAamC,GAAiB3B,KAAKM,QACjC,GAAIqB,IAAS3B,KAAKM,OAAQ,CACxBN,KAAKM,QAAUN,KAAKM,OAEpBN,KAAK4B,wBAECnC,EAAgBO,KAAKwB,oBAAoBK,MAAK,KAClD7B,KAAK8B,eAAiB,KACtB9B,KAAKO,gBAAkBP,KAAKQ,oBAAoB,IAGlD,OAAOR,KAAKM,M,EAIhBsB,kBACE,MAAMG,EAAiBzD,EAAiB0B,KAAKwB,mBAAoB,QAEjExB,KAAK8B,eAAiB,GAAG9B,KAAKM,OAAS,EAAIyB,MAC3C/B,KAAKO,gBAAkB,aAEvBE,YAAW,KACTT,KAAK8B,eAAiB,GAAG9B,KAAKM,OAASyB,EAAiB,KAAK,GAC5D,G,CAGGvB,qBACN,OAAOR,KAAKM,OAAS,gBAAkB,U,CAGzC0B,SACE,IAAKhC,KAAKgB,UAAW,CACnB,OACEiB,EAAA,OACEX,GAAI,GAAGtB,KAAKqB,0BACZa,MAAOlC,KAAKO,gBACZ4B,MAAO,CAAEC,OAAQpC,KAAK8B,iBAEtBG,EAAA,a,CAKN,OACEA,EAAA,OAAKC,MAAM,kBACTD,EAACjC,KAAKc,WAAU,CAACoB,MAAM,mBAAmBZ,GAAI,GAAGtB,KAAKqB,yBACpDY,EAAA,UACEC,MAAO,oBAAoBlC,KAAKM,OAAS,GAAK,cAC9C+B,KAAK,SAAQ,gBACE,GAAGrC,KAAKM,SAAQ,gBAChB,GAAGN,KAAKqB,0BACvBiB,QAAS,IAAMtC,KAAKU,UAEpBuB,EAAA,QAAMM,KAAK,aAGfN,EAAA,OACEX,GAAI,GAAGtB,KAAKqB,0BACZa,MAAO,sBAAsBlC,KAAKO,kBAClC4B,MAAO,CAAEC,OAAQpC,KAAK8B,gBAAgB,kBACrB,GAAG9B,KAAKqB,yBAEzBY,EAAA,OAAKC,MAAM,kBACTD,EAAA,e"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function checkType(value: unknown, type: string, errorMessage: string): void;
|
|
2
|
-
export declare function checkEmptyOrType(value: unknown, type: string, errorMessage: string): void;
|
|
3
|
-
export declare function checkOneOf<T>(value: T, possibleValues: T[], errorMessage: string): void;
|
|
4
|
-
export declare function checkEmptyOrOneOf<T>(value: T, possibleValues: T[], errorMessage: string): void;
|
|
5
|
-
export declare function checkBoolean(value: unknown, errorMessage: string): void;
|