@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
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import {
|
|
2
|
+
import { checkOneOf, checkType, getElementHeight, onTransitionEnd } from '../../utils';
|
|
3
3
|
let nextId = 0;
|
|
4
4
|
export class PostCollapsible {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.isLoaded = false;
|
|
7
|
-
this.collapsed = false;
|
|
8
|
-
this.headingLevel = 2;
|
|
9
|
-
this.isOpen = true;
|
|
10
7
|
this.collapseClasses = undefined;
|
|
11
8
|
this.collapseHeight = null;
|
|
12
|
-
this.headingTag = undefined;
|
|
13
9
|
this.collapsibleId = undefined;
|
|
14
10
|
this.hasHeader = undefined;
|
|
11
|
+
this.headingTag = undefined;
|
|
12
|
+
this.isOpen = true;
|
|
13
|
+
this.onAccordionButtonClick = () => this.toggle();
|
|
14
|
+
this.collapsed = false;
|
|
15
|
+
this.headingLevel = 2;
|
|
15
16
|
}
|
|
16
17
|
validateCollapsed(newValue = this.collapsed) {
|
|
17
|
-
|
|
18
|
+
checkType(newValue, 'boolean', 'The post-collapsible "collapsed" prop should be a boolean.');
|
|
18
19
|
if (!this.isLoaded) {
|
|
19
20
|
this.isOpen = !newValue;
|
|
20
21
|
this.collapseClasses = this.getCollapseClasses();
|
|
@@ -72,7 +73,7 @@ export class PostCollapsible {
|
|
|
72
73
|
if (!this.hasHeader) {
|
|
73
74
|
return (h("div", { id: `${this.collapsibleId}--collapse`, class: this.collapseClasses, style: { height: this.collapseHeight } }, h("slot", null)));
|
|
74
75
|
}
|
|
75
|
-
return (h("div", { class: "accordion-item" }, h(this.headingTag, { class: "accordion-header", id: `${this.collapsibleId}--header` }, h("button", { class: `accordion-button ${this.isOpen ? '' : 'collapsed'}`, type: "button", "aria-expanded": `${this.isOpen}`, "aria-controls": `${this.collapsibleId}--collapse`, onClick:
|
|
76
|
+
return (h("div", { class: "accordion-item" }, h(this.headingTag, { class: "accordion-header", id: `${this.collapsibleId}--header` }, h("button", { class: `accordion-button ${this.isOpen ? '' : 'collapsed'}`, type: "button", "aria-expanded": `${this.isOpen}`, "aria-controls": `${this.collapsibleId}--collapse`, onClick: this.onAccordionButtonClick }, h("slot", { name: "header" }))), h("div", { id: `${this.collapsibleId}--collapse`, class: `accordion-collapse ${this.collapseClasses}`, style: { height: this.collapseHeight }, "aria-labelledby": `${this.collapsibleId}--header` }, h("div", { class: "accordion-body" }, h("slot", null)))));
|
|
76
77
|
}
|
|
77
78
|
static get is() { return "post-collapsible"; }
|
|
78
79
|
static get encapsulation() { return "shadow"; }
|
|
@@ -128,12 +129,13 @@ export class PostCollapsible {
|
|
|
128
129
|
}
|
|
129
130
|
static get states() {
|
|
130
131
|
return {
|
|
131
|
-
"isOpen": {},
|
|
132
132
|
"collapseClasses": {},
|
|
133
133
|
"collapseHeight": {},
|
|
134
|
-
"headingTag": {},
|
|
135
134
|
"collapsibleId": {},
|
|
136
|
-
"hasHeader": {}
|
|
135
|
+
"hasHeader": {},
|
|
136
|
+
"headingTag": {},
|
|
137
|
+
"isOpen": {},
|
|
138
|
+
"onAccordionButtonClick": {}
|
|
137
139
|
};
|
|
138
140
|
}
|
|
139
141
|
static get methods() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-collapsible.js","sourceRoot":"","sources":["../../../src/components/post-collapsible/post-collapsible.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"post-collapsible.js","sourceRoot":"","sources":["../../../src/components/post-collapsible/post-collapsible.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEvF,IAAI,MAAM,GAAG,CAAC,CAAC;AAOf,MAAM,OAAO,eAAe;;IAElB,aAAQ,GAAG,KAAK,CAAC;;0BAKgB,IAAI;;;;kBAI3B,IAAI;kCACY,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE;qBAKd,KAAK;wBAmBH,CAAC;;EAhB1C,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS;IACzC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,4DAA4D,CAAC,CAAC;IAE7F,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAClB,IAAI,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC;MACxB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAClD;SAAM;MACL,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;MACzB,CAAC,CAAC,CAAC;KACJ;EACH,CAAC;EAQD,oBAAoB,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY;IAC/C,UAAU,CAC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B,GAAG,IAAI,CAAC,aAAa,YAAY,EAChD,OAAO,EAAE,IAAI,CAAC,sBAAsB;UAEpC,YAAM,IAAI,EAAC,QAAQ,GAAE,CACd,CACO;MAClB,WACE,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa,YAAY,EACrC,KAAK,EAAE,sBAAsB,IAAI,CAAC,eAAe,EAAE,EACnD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,qBACrB,GAAG,IAAI,CAAC,aAAa,UAAU;QAEhD,WAAK,KAAK,EAAC,gBAAgB;UACzB,eAAO,CACH,CACF,CACF,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { checkOneOf, checkType, 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 private collapsibleElement: HTMLElement;\n private isLoaded = false;\n\n @Element() host: HTMLPostCollapsibleElement;\n\n @State() collapseClasses: string;\n @State() collapseHeight: string | null = null;\n @State() collapsibleId: string;\n @State() hasHeader: boolean;\n @State() headingTag: string | undefined;\n @State() isOpen = true;\n @State() onAccordionButtonClick = () => this.toggle();\n\n /**\n * If `true`, the element is initially collapsed otherwise it is displayed.\n */\n @Prop() readonly collapsed?: boolean = false;\n\n @Watch('collapsed')\n validateCollapsed(newValue = this.collapsed) {\n checkType(newValue, 'boolean', '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 /**\n * Defines the hierarchical level of the collapsible header within the headings structure.\n */\n @Prop() readonly headingLevel?: number = 2;\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 = !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 private 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.onAccordionButtonClick}\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"]}
|
|
@@ -14,20 +14,19 @@ const ANIMATION_KEYS = [
|
|
|
14
14
|
*/
|
|
15
15
|
export class PostIcon {
|
|
16
16
|
constructor() {
|
|
17
|
-
this.
|
|
17
|
+
this.svgSource = '<svg viewBox="0 0 16 16"></svg>';
|
|
18
|
+
this.svgOutput = undefined;
|
|
19
|
+
this.animation = undefined;
|
|
18
20
|
this.base = undefined;
|
|
19
21
|
this.flipH = undefined;
|
|
20
22
|
this.flipV = undefined;
|
|
21
|
-
this.
|
|
23
|
+
this.name = undefined;
|
|
22
24
|
this.rotate = undefined;
|
|
23
|
-
this.
|
|
24
|
-
this.initialPath = undefined;
|
|
25
|
-
this.path = undefined;
|
|
26
|
-
this.svgSource = '<svg viewBox="0 0 16 16"></svg>';
|
|
27
|
-
this.svgOutput = undefined;
|
|
25
|
+
this.scale = undefined;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
validateAnimation(newValue = this.animation) {
|
|
28
|
+
if (newValue !== undefined)
|
|
29
|
+
checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon "animation" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);
|
|
31
30
|
}
|
|
32
31
|
validateBase(newValue = this.base) {
|
|
33
32
|
checkEmptyOrType(newValue, 'string', 'The post-icon "base" prop should be a string.');
|
|
@@ -38,15 +37,14 @@ export class PostIcon {
|
|
|
38
37
|
validateFlipV(newValue = this.flipV) {
|
|
39
38
|
checkEmptyOrType(newValue, 'boolean', 'The post-icon "flipV" prop should be a boolean.');
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
validateName(newValue = this.name) {
|
|
41
|
+
checkType(newValue, 'string', 'The post-icon "name" prop should be a string.');
|
|
43
42
|
}
|
|
44
43
|
validateRotate(newValue = this.rotate) {
|
|
45
44
|
checkEmptyOrType(newValue, 'number', 'The post-icon "rotate" prop should be a number.');
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon "animation" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);
|
|
46
|
+
validateScale(newValue = this.scale) {
|
|
47
|
+
checkEmptyOrType(newValue, 'number', 'The post-icon "scale" prop should be a number.');
|
|
50
48
|
}
|
|
51
49
|
connectedCallback() {
|
|
52
50
|
var _a;
|
|
@@ -66,13 +64,13 @@ export class PostIcon {
|
|
|
66
64
|
this.svgSource = (_a = window.localStorage.getItem(`post-icon-${this.name}`)) !== null && _a !== void 0 ? _a : this.svgSource;
|
|
67
65
|
}
|
|
68
66
|
componentWillLoad() {
|
|
69
|
-
this.
|
|
67
|
+
this.validateAnimation();
|
|
70
68
|
this.validateBase();
|
|
71
69
|
this.validateFlipH();
|
|
72
70
|
this.validateFlipV();
|
|
73
|
-
this.
|
|
71
|
+
this.validateName();
|
|
74
72
|
this.validateRotate();
|
|
75
|
-
this.
|
|
73
|
+
this.validateScale();
|
|
76
74
|
this.fetchSVG();
|
|
77
75
|
}
|
|
78
76
|
componentWillRender() {
|
|
@@ -89,9 +87,6 @@ export class PostIcon {
|
|
|
89
87
|
svgElement.setAttribute('style', svgStyles);
|
|
90
88
|
this.svgOutput = helperElement.innerHTML;
|
|
91
89
|
}
|
|
92
|
-
getPath(basePath) {
|
|
93
|
-
return new URL([...basePath.split('/'), `${this.name}.svg#icon`].join('/'), window.location.origin).toString();
|
|
94
|
-
}
|
|
95
90
|
fetchSVG() {
|
|
96
91
|
fetch(this.path)
|
|
97
92
|
.then(response => response.text())
|
|
@@ -117,6 +112,9 @@ export class PostIcon {
|
|
|
117
112
|
console.log(error);
|
|
118
113
|
});
|
|
119
114
|
}
|
|
115
|
+
getPath(basePath) {
|
|
116
|
+
return new URL([...basePath.split('/'), `${this.name}.svg#icon`].join('/'), window.location.origin).toString();
|
|
117
|
+
}
|
|
120
118
|
render() {
|
|
121
119
|
return (h(Host, null, h("div", { innerHTML: this.svgOutput })));
|
|
122
120
|
}
|
|
@@ -134,7 +132,7 @@ export class PostIcon {
|
|
|
134
132
|
}
|
|
135
133
|
static get properties() {
|
|
136
134
|
return {
|
|
137
|
-
"
|
|
135
|
+
"animation": {
|
|
138
136
|
"type": "string",
|
|
139
137
|
"mutable": false,
|
|
140
138
|
"complexType": {
|
|
@@ -143,12 +141,12 @@ export class PostIcon {
|
|
|
143
141
|
"references": {}
|
|
144
142
|
},
|
|
145
143
|
"required": false,
|
|
146
|
-
"optional":
|
|
144
|
+
"optional": true,
|
|
147
145
|
"docs": {
|
|
148
146
|
"tags": [],
|
|
149
|
-
"text": "The name
|
|
147
|
+
"text": "The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`)."
|
|
150
148
|
},
|
|
151
|
-
"attribute": "
|
|
149
|
+
"attribute": "animation",
|
|
152
150
|
"reflect": false
|
|
153
151
|
},
|
|
154
152
|
"base": {
|
|
@@ -202,21 +200,21 @@ export class PostIcon {
|
|
|
202
200
|
"attribute": "flip-v",
|
|
203
201
|
"reflect": false
|
|
204
202
|
},
|
|
205
|
-
"
|
|
206
|
-
"type": "
|
|
203
|
+
"name": {
|
|
204
|
+
"type": "string",
|
|
207
205
|
"mutable": false,
|
|
208
206
|
"complexType": {
|
|
209
|
-
"original": "
|
|
210
|
-
"resolved": "
|
|
207
|
+
"original": "string",
|
|
208
|
+
"resolved": "string",
|
|
211
209
|
"references": {}
|
|
212
210
|
},
|
|
213
211
|
"required": false,
|
|
214
|
-
"optional":
|
|
212
|
+
"optional": false,
|
|
215
213
|
"docs": {
|
|
216
214
|
"tags": [],
|
|
217
|
-
"text": "The
|
|
215
|
+
"text": "The name/id of the icon (e.g. 1000, 1001, ...)."
|
|
218
216
|
},
|
|
219
|
-
"attribute": "
|
|
217
|
+
"attribute": "name",
|
|
220
218
|
"reflect": false
|
|
221
219
|
},
|
|
222
220
|
"rotate": {
|
|
@@ -236,37 +234,34 @@ export class PostIcon {
|
|
|
236
234
|
"attribute": "rotate",
|
|
237
235
|
"reflect": false
|
|
238
236
|
},
|
|
239
|
-
"
|
|
240
|
-
"type": "
|
|
237
|
+
"scale": {
|
|
238
|
+
"type": "number",
|
|
241
239
|
"mutable": false,
|
|
242
240
|
"complexType": {
|
|
243
|
-
"original": "
|
|
244
|
-
"resolved": "
|
|
241
|
+
"original": "number",
|
|
242
|
+
"resolved": "number",
|
|
245
243
|
"references": {}
|
|
246
244
|
},
|
|
247
245
|
"required": false,
|
|
248
246
|
"optional": true,
|
|
249
247
|
"docs": {
|
|
250
248
|
"tags": [],
|
|
251
|
-
"text": "The
|
|
249
|
+
"text": "The `number` for the css `scale` transformation."
|
|
252
250
|
},
|
|
253
|
-
"attribute": "
|
|
251
|
+
"attribute": "scale",
|
|
254
252
|
"reflect": false
|
|
255
253
|
}
|
|
256
254
|
};
|
|
257
255
|
}
|
|
258
256
|
static get states() {
|
|
259
257
|
return {
|
|
260
|
-
"initialPath": {},
|
|
261
|
-
"path": {},
|
|
262
|
-
"svgSource": {},
|
|
263
258
|
"svgOutput": {}
|
|
264
259
|
};
|
|
265
260
|
}
|
|
266
261
|
static get watchers() {
|
|
267
262
|
return [{
|
|
268
|
-
"propName": "
|
|
269
|
-
"methodName": "
|
|
263
|
+
"propName": "animation",
|
|
264
|
+
"methodName": "validateAnimation"
|
|
270
265
|
}, {
|
|
271
266
|
"propName": "base",
|
|
272
267
|
"methodName": "validateBase"
|
|
@@ -277,14 +272,14 @@ export class PostIcon {
|
|
|
277
272
|
"propName": "flipV",
|
|
278
273
|
"methodName": "validateFlipV"
|
|
279
274
|
}, {
|
|
280
|
-
"propName": "
|
|
281
|
-
"methodName": "
|
|
275
|
+
"propName": "name",
|
|
276
|
+
"methodName": "validateName"
|
|
282
277
|
}, {
|
|
283
278
|
"propName": "rotate",
|
|
284
279
|
"methodName": "validateRotate"
|
|
285
280
|
}, {
|
|
286
|
-
"propName": "
|
|
287
|
-
"methodName": "
|
|
281
|
+
"propName": "scale",
|
|
282
|
+
"methodName": "validateScale"
|
|
288
283
|
}];
|
|
289
284
|
}
|
|
290
285
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-icon.js","sourceRoot":"","sources":["../../../src/components/post-icon/post-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE7E,MAAM,OAAO,GAAG,oEAAoE,CAAC;AACrF,MAAM,cAAc,GAAG;EACrB,OAAO;EACP,gBAAgB;EAChB,MAAM;EACN,cAAc;EACd,MAAM;EACN,OAAO;CACR,CAAC;AAEF;;GAEG;AAMH,MAAM,OAAO,QAAQ
|
|
1
|
+
{"version":3,"file":"post-icon.js","sourceRoot":"","sources":["../../../src/components/post-icon/post-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE7E,MAAM,OAAO,GAAG,oEAAoE,CAAC;AACrF,MAAM,cAAc,GAAG;EACrB,OAAO;EACP,gBAAgB;EAChB,MAAM;EACN,cAAc;EACd,MAAM;EACN,OA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,EAAE,CAAC;SACjB;aAAM;UACL,OAAO,CAAC,KAAK,CACX,8DAA8D,IAAI,CAAC,WAAW,IAAI,CACnF,CAAC;SACH;OACF;IACH,CAAC,CAAC;OACD,KAAK,CAAC,KAAK,CAAC,EAAE;MACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;EACP,CAAC;EAEO,OAAO,CAAC,QAAgB;IAC9B,OAAO,IAAI,GAAG,CACZ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC3D,MAAM,CAAC,QAAQ,CAAC,MAAM,CACvB,CAAC,QAAQ,EAAE,CAAC;EACf,CAAC;EAED,MAAM;IACJ,OAAO,CACL,EAAC,IAAI;MACH,WAAK,SAAS,EAAE,IAAI,CAAC,SAAS,GAAI,CAC7B,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["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 private initialPath: string;\n private path: string;\n private svgSource = '<svg viewBox=\"0 0 16 16\"></svg>';\n\n @State() svgOutput: string;\n\n /**\n * The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`).\n */\n @Prop() readonly animation?: string;\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 /**\n * The base path, where the icons are located (must be a public url).\n */\n @Prop() readonly base?: string;\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 /**\n * When set to `true`, the icon will be flipped horizontally.\n */\n @Prop() readonly flipH?: boolean;\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 /**\n * When set to `true`, the icon will be flipped vertically.\n */\n @Prop() readonly flipV?: boolean;\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 /**\n * The name/id of the icon (e.g. 1000, 1001, ...).\n */\n @Prop() readonly name: 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 /**\n * The `number` of degree for the css `rotate` transformation.\n */\n @Prop() readonly rotate?: number;\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 /**\n * The `number` for the css `scale` transformation.\n */\n @Prop() readonly scale?: number;\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 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.validateAnimation();\n this.validateBase();\n this.validateFlipH();\n this.validateFlipV();\n this.validateName();\n this.validateRotate();\n this.validateScale();\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 private 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 private getPath(basePath: string) {\n return new URL(\n [...basePath.split('/'), `${this.name}.svg#icon`].join('/'),\n window.location.origin,\n ).toString();\n }\n\n render() {\n return (\n <Host>\n <div innerHTML={this.svgOutput} />\n </Host>\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-element-height.js","sourceRoot":"","sources":["../../src/utils/get-element-height.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-element-height.js","sourceRoot":"","sources":["../../src/utils/get-element-height.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,gBAAgB,CAAC,EAAe,EAAE,mBAAsC,EAAE;EACxF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAAE,gBAAgB,GAAG,CAAC,gBAAgB,CAAC,CAAC;EAE5E,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;EACrF,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;EAE3D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;EAErC,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC;EAE9D,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["export 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: string | string[] = []): 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './get-element-height';\nexport * from './on-transition-end';\nexport * from './property-checkers';\nexport * from './should-reduce-motion';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-transition-end.js","sourceRoot":"","sources":["../../src/utils/on-transition-end.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"on-transition-end.js","sourceRoot":"","sources":["../../src/utils/on-transition-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EAAe;EACnD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;IAC3B,IAAI,kBAAkB,EAAE,EAAE;MACxB,OAAO,EAAE,CAAC;KACX;SAAM;MACL,EAAE,CAAC,eAAe,GAAG,GAAG,EAAE;QACxB,OAAO,EAAE,CAAC;QACV,EAAE,CAAC,eAAe,GAAG,IAAI,CAAC;MAC5B,CAAC,CAAC;KACH;EACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-one-of.js","sourceRoot":"","sources":["../../../src/utils/property-checkers/check-one-of.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,KAAa;EACxE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function checkType(value, type, error) {
|
|
2
|
+
const typeIsArray = type === 'array';
|
|
3
|
+
const valueIsArray = Array.isArray(value);
|
|
4
|
+
if (typeIsArray || valueIsArray) {
|
|
5
|
+
if (valueIsArray !== typeIsArray)
|
|
6
|
+
throw new Error(error);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
if (typeof value !== type)
|
|
10
|
+
throw new Error(error);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=check-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-type.js","sourceRoot":"","sources":["../../../src/utils/property-checkers/check-type.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,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,CAAC","sourcesContent":["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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-or.js","sourceRoot":"","sources":["../../../src/utils/property-checkers/empty-or.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AAE3C,MAAM,UAAU,OAAO,CAAsB,KAA2B;EACtE,OAAO,CAAC,GAAG,IAAO,EAAE,EAAE;IACpB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC;MAAE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;EAC3D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { emptyOr } from './empty-or';
|
|
2
|
+
import { checkOneOf } from './check-one-of';
|
|
3
|
+
import { checkType } from './check-type';
|
|
4
|
+
export const checkEmptyOrOneOf = emptyOr(checkOneOf);
|
|
5
|
+
export const checkEmptyOrType = emptyOr(checkType);
|
|
6
|
+
export * from './check-one-of';
|
|
7
|
+
export * from './check-type';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/property-checkers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC","sourcesContent":["import { emptyOr } from './empty-or';\nimport { checkOneOf } from './check-one-of';\nimport { checkType } from './check-type';\n\nexport const checkEmptyOrOneOf = emptyOr(checkOneOf);\nexport const checkEmptyOrType = emptyOr(checkType);\n\nexport * from './check-one-of';\nexport * from './check-type';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-reduce-motion.js","sourceRoot":"","sources":["../../src/utils/should-reduce-motion.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"should-reduce-motion.js","sourceRoot":"","sources":["../../src/utils/should-reduce-motion.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB;EAChC,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["export function shouldReduceMotion(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function checkOneOf(value, possibleValues, error) {
|
|
2
|
+
if (!possibleValues.includes(value))
|
|
3
|
+
throw new Error(error);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function checkType(value, type, error) {
|
|
7
|
+
const typeIsArray = type === 'array';
|
|
8
|
+
const valueIsArray = Array.isArray(value);
|
|
9
|
+
if (typeIsArray || valueIsArray) {
|
|
10
|
+
if (valueIsArray !== typeIsArray)
|
|
11
|
+
throw new Error(error);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
if (typeof value !== type)
|
|
15
|
+
throw new Error(error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { checkOneOf as a, checkType as c };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=check-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"check-type.js","mappings":"SAAgB,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,KAAa;EACxE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D;;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;;;;","names":[],"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"],"version":3}
|