@swisspost/design-system-components 1.3.9 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/cjs/check-non-empty-35b4d0b5.js +14 -0
  2. package/dist/cjs/check-non-empty-35b4d0b5.js.map +1 -0
  3. package/dist/cjs/{package-c661bf2f.js → check-type-f24cf91d.js} +1 -4
  4. package/dist/cjs/{package-c661bf2f.js.map → check-type-f24cf91d.js.map} +1 -1
  5. package/dist/cjs/{index-272283b3.js → index-50d7d035.js} +15 -1
  6. package/dist/cjs/index-50d7d035.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/package-e8a6597e.js +7 -0
  9. package/dist/cjs/package-e8a6597e.js.map +1 -0
  10. package/dist/cjs/post-collapsible.cjs.entry.js +6 -5
  11. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  12. package/dist/cjs/post-components.cjs.js +2 -2
  13. package/dist/cjs/post-icon.cjs.entry.js +9 -15
  14. package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
  15. package/dist/cjs/post-tab-header.cjs.entry.js +35 -0
  16. package/dist/cjs/post-tab-header.cjs.entry.js.map +1 -0
  17. package/dist/cjs/post-tab-panel.cjs.entry.js +29 -0
  18. package/dist/cjs/post-tab-panel.cjs.entry.js.map +1 -0
  19. package/dist/cjs/post-tabs.cjs.entry.js +141 -0
  20. package/dist/cjs/post-tabs.cjs.entry.js.map +1 -0
  21. package/dist/collection/animations/fade.js +6 -0
  22. package/dist/collection/animations/fade.js.map +1 -0
  23. package/dist/collection/animations/index.js +2 -0
  24. package/dist/collection/animations/index.js.map +1 -0
  25. package/dist/collection/collection-manifest.json +4 -1
  26. package/dist/collection/components/post-collapsible/post-collapsible.css +165 -15688
  27. package/dist/collection/components/post-tab-header/post-tab-header.css +337 -0
  28. package/dist/collection/components/post-tab-header/post-tab-header.js +68 -0
  29. package/dist/collection/components/post-tab-header/post-tab-header.js.map +1 -0
  30. package/dist/collection/components/post-tab-panel/post-tab-panel.css +3 -0
  31. package/dist/collection/components/post-tab-panel/post-tab-panel.js +55 -0
  32. package/dist/collection/components/post-tab-panel/post-tab-panel.js.map +1 -0
  33. package/dist/collection/components/post-tabs/post-tabs.css +148 -0
  34. package/dist/collection/components/post-tabs/post-tabs.js +208 -0
  35. package/dist/collection/components/post-tabs/post-tabs.js.map +1 -0
  36. package/dist/components/check-non-empty.js +11 -0
  37. package/dist/components/check-non-empty.js.map +1 -0
  38. package/dist/{esm/package-adf815bd.js → components/check-type.js} +2 -4
  39. package/dist/components/check-type.js.map +1 -0
  40. package/dist/components/package.js +2 -20
  41. package/dist/components/package.js.map +1 -1
  42. package/dist/components/post-collapsible.js +3 -2
  43. package/dist/components/post-collapsible.js.map +1 -1
  44. package/dist/components/post-icon.js +3 -9
  45. package/dist/components/post-icon.js.map +1 -1
  46. package/dist/components/post-tab-header.d.ts +11 -0
  47. package/dist/components/post-tab-header.js +52 -0
  48. package/dist/components/post-tab-header.js.map +1 -0
  49. package/dist/components/post-tab-panel.d.ts +11 -0
  50. package/dist/components/post-tab-panel.js +46 -0
  51. package/dist/components/post-tab-panel.js.map +1 -0
  52. package/dist/components/post-tabs.d.ts +11 -0
  53. package/dist/components/post-tabs.js +158 -0
  54. package/dist/components/post-tabs.js.map +1 -0
  55. package/dist/docs.json +131 -1
  56. package/dist/esm/check-non-empty-554bdf88.js +11 -0
  57. package/dist/esm/check-non-empty-554bdf88.js.map +1 -0
  58. package/dist/esm/check-type-67411ed3.js +21 -0
  59. package/dist/esm/check-type-67411ed3.js.map +1 -0
  60. package/dist/esm/{index-60a84798.js → index-cc0e53f0.js} +15 -2
  61. package/dist/esm/index-cc0e53f0.js.map +1 -0
  62. package/dist/esm/loader.js +3 -3
  63. package/dist/esm/package-b514d0f6.js +5 -0
  64. package/dist/esm/package-b514d0f6.js.map +1 -0
  65. package/dist/esm/post-collapsible.entry.js +4 -3
  66. package/dist/esm/post-collapsible.entry.js.map +1 -1
  67. package/dist/esm/post-components.js +3 -3
  68. package/dist/esm/post-icon.entry.js +4 -10
  69. package/dist/esm/post-icon.entry.js.map +1 -1
  70. package/dist/esm/post-tab-header.entry.js +31 -0
  71. package/dist/esm/post-tab-header.entry.js.map +1 -0
  72. package/dist/esm/post-tab-panel.entry.js +25 -0
  73. package/dist/esm/post-tab-panel.entry.js.map +1 -0
  74. package/dist/esm/post-tabs.entry.js +137 -0
  75. package/dist/esm/post-tabs.entry.js.map +1 -0
  76. package/dist/post-components/p-1388585d.entry.js +2 -0
  77. package/dist/post-components/p-1388585d.entry.js.map +1 -0
  78. package/dist/post-components/p-58916755.js +2 -0
  79. package/dist/post-components/p-58916755.js.map +1 -0
  80. package/dist/post-components/p-5b3445dc.entry.js +2 -0
  81. package/dist/post-components/p-5b3445dc.entry.js.map +1 -0
  82. package/dist/post-components/p-6341b9b4.js +3 -0
  83. package/dist/post-components/p-6341b9b4.js.map +1 -0
  84. package/dist/post-components/p-6dad6a8a.entry.js +2 -0
  85. package/dist/post-components/p-6dad6a8a.entry.js.map +1 -0
  86. package/dist/post-components/p-b95ec099.entry.js +2 -0
  87. package/dist/post-components/p-b95ec099.entry.js.map +1 -0
  88. package/dist/post-components/p-c8efe0ae.js +2 -0
  89. package/dist/post-components/p-c8efe0ae.js.map +1 -0
  90. package/dist/post-components/p-cc92afb7.entry.js +2 -0
  91. package/dist/post-components/p-cc92afb7.entry.js.map +1 -0
  92. package/dist/post-components/p-f549b3fc.js +2 -0
  93. package/dist/post-components/{p-05d38c8e.js.map → p-f549b3fc.js.map} +1 -1
  94. package/dist/post-components/post-components.esm.js +1 -1
  95. package/dist/post-components/post-components.esm.js.map +1 -1
  96. package/dist/types/animations/fade.d.ts +2 -0
  97. package/dist/types/animations/index.d.ts +1 -0
  98. package/dist/types/components/post-tab-header/post-tab-header.d.ts +11 -0
  99. package/dist/types/components/post-tab-panel/post-tab-panel.d.ts +10 -0
  100. package/dist/types/components/post-tabs/post-tabs.d.ts +34 -0
  101. package/dist/types/components.d.ts +75 -0
  102. package/package.json +7 -8
  103. package/dist/cjs/index-272283b3.js.map +0 -1
  104. package/dist/collection/utils/property-checkers/tests/check-non-empty.spec.js +0 -36
  105. package/dist/collection/utils/property-checkers/tests/check-non-empty.spec.js.map +0 -1
  106. package/dist/collection/utils/property-checkers/tests/check-one-of.spec.js +0 -13
  107. package/dist/collection/utils/property-checkers/tests/check-one-of.spec.js.map +0 -1
  108. package/dist/collection/utils/property-checkers/tests/check-type.spec.js +0 -103
  109. package/dist/collection/utils/property-checkers/tests/check-type.spec.js.map +0 -1
  110. package/dist/collection/utils/property-checkers/tests/empty-or.spec.js +0 -23
  111. package/dist/collection/utils/property-checkers/tests/empty-or.spec.js.map +0 -1
  112. package/dist/collection/utils/tests/should-reduce-motion.spec.js +0 -16
  113. package/dist/collection/utils/tests/should-reduce-motion.spec.js.map +0 -1
  114. package/dist/esm/index-60a84798.js.map +0 -1
  115. package/dist/esm/package-adf815bd.js.map +0 -1
  116. package/dist/post-components/p-0096c140.js +0 -3
  117. package/dist/post-components/p-0096c140.js.map +0 -1
  118. package/dist/post-components/p-05d38c8e.js +0 -2
  119. package/dist/post-components/p-4eaaf8eb.entry.js +0 -2
  120. package/dist/post-components/p-4eaaf8eb.entry.js.map +0 -1
  121. package/dist/post-components/p-5cd6cb3a.entry.js +0 -2
  122. package/dist/post-components/p-5cd6cb3a.entry.js.map +0 -1
@@ -0,0 +1,208 @@
1
+ import { Host, h } from '@stencil/core';
2
+ import { version } from '../../../package.json';
3
+ import { fadeIn, fadeOut } from '../../animations';
4
+ export class PostTabs {
5
+ constructor() {
6
+ this.isLoaded = false;
7
+ this.activePanel = undefined;
8
+ }
9
+ get tabs() {
10
+ return this.host.querySelectorAll('post-tab-header');
11
+ }
12
+ componentDidLoad() {
13
+ this.moveMisplacedTabs();
14
+ this.enableTabs();
15
+ const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;
16
+ this.show(initiallyActivePanel);
17
+ this.isLoaded = true;
18
+ }
19
+ /**
20
+ * Shows the panel with the given name and selects its associated tab.
21
+ * Any other panel that was previously shown becomes hidden and its associated tab is unselected.
22
+ */
23
+ async show(panelName) {
24
+ var _a;
25
+ // do nothing if the tab is already active
26
+ if (panelName === ((_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.panel)) {
27
+ return;
28
+ }
29
+ const previousTab = this.activeTab;
30
+ const newTab = this.host.querySelector(`post-tab-header[panel=${panelName}]`);
31
+ this.activateTab(newTab);
32
+ // if a panel is currently being displayed, remove it from the view and complete the associated animation
33
+ if (this.showing) {
34
+ this.showing.effect['target'].style.display = 'none';
35
+ this.showing.finish();
36
+ }
37
+ // hide the currently visible panel only if no other animation is running
38
+ if (previousTab && !this.showing && !this.hiding) {
39
+ this.hidePanel(previousTab.panel);
40
+ }
41
+ // wait for any hiding animation to complete before showing the selected tab
42
+ if (this.hiding) {
43
+ await this.hiding.finished;
44
+ }
45
+ this.showSelectedPanel();
46
+ // wait for any display animation to complete for the returned promise to fully resolve
47
+ if (this.showing) {
48
+ await this.showing.finished;
49
+ }
50
+ this.tabChange.emit(this.activeTab.panel);
51
+ }
52
+ moveMisplacedTabs() {
53
+ if (!this.tabs)
54
+ return;
55
+ this.tabs.forEach(tab => {
56
+ if (tab.getAttribute('slot') === 'tabs')
57
+ return;
58
+ tab.setAttribute('slot', 'tabs');
59
+ });
60
+ }
61
+ enableTabs() {
62
+ if (!this.tabs)
63
+ return;
64
+ this.tabs.forEach(async (tab) => {
65
+ await tab.componentOnReady();
66
+ const tabTitle = tab.shadowRoot.querySelector('.tab-title');
67
+ // if the tab has an "aria-controls" attribute it was already linked to its panel: do nothing
68
+ if (tabTitle.getAttribute('aria-controls'))
69
+ return;
70
+ const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');
71
+ tabTitle.setAttribute('aria-controls', tabPanel.id);
72
+ tabPanel.setAttribute('aria-labelledby', tabTitle.id);
73
+ tab.addEventListener('click', e => {
74
+ e.preventDefault();
75
+ this.show(tab.panel);
76
+ });
77
+ });
78
+ // if the currently active tab was removed from the DOM then select the first one
79
+ if (this.activeTab && !this.activeTab.isConnected) {
80
+ this.show(this.tabs.item(0).panel);
81
+ }
82
+ }
83
+ activateTab(tab) {
84
+ if (this.activeTab) {
85
+ const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');
86
+ tabTitle.setAttribute('aria-selected', 'false');
87
+ tabTitle.classList.remove('active');
88
+ }
89
+ const tabTitle = tab.shadowRoot.querySelector('.tab-title');
90
+ tabTitle.setAttribute('aria-selected', 'true');
91
+ tabTitle.classList.add('active');
92
+ this.activeTab = tab;
93
+ }
94
+ hidePanel(panelName) {
95
+ const previousPanel = this.getPanel(panelName);
96
+ if (!previousPanel)
97
+ return;
98
+ this.hiding = fadeOut(previousPanel);
99
+ this.hiding.onfinish = () => {
100
+ previousPanel.style.display = 'none';
101
+ this.hiding = null;
102
+ };
103
+ }
104
+ showSelectedPanel() {
105
+ const panel = this.getPanel(this.activeTab.panel);
106
+ panel.style.display = 'block';
107
+ // prevent the initially selected panel from fading in
108
+ if (!this.isLoaded)
109
+ return;
110
+ this.showing = fadeIn(panel);
111
+ this.showing.onfinish = () => {
112
+ this.showing = null;
113
+ };
114
+ }
115
+ getPanel(name) {
116
+ return this.host.querySelector(`post-tab-panel[name=${name}]`);
117
+ }
118
+ render() {
119
+ return (h(Host, { "data-version": version }, h("div", { class: "tabs-wrapper" }, h("ul", { class: "tabs nav", role: "tablist" }, h("slot", { name: "tabs", onSlotchange: () => this.enableTabs() }))), h("div", { class: "tab-content" }, h("slot", { onSlotchange: () => this.moveMisplacedTabs() }))));
120
+ }
121
+ static get is() { return "post-tabs"; }
122
+ static get encapsulation() { return "shadow"; }
123
+ static get originalStyleUrls() {
124
+ return {
125
+ "$": ["post-tabs.scss"]
126
+ };
127
+ }
128
+ static get styleUrls() {
129
+ return {
130
+ "$": ["post-tabs.css"]
131
+ };
132
+ }
133
+ static get properties() {
134
+ return {
135
+ "activePanel": {
136
+ "type": "string",
137
+ "mutable": false,
138
+ "complexType": {
139
+ "original": "HTMLPostTabPanelElement['name']",
140
+ "resolved": "string",
141
+ "references": {
142
+ "HTMLPostTabPanelElement": {
143
+ "location": "global"
144
+ }
145
+ }
146
+ },
147
+ "required": false,
148
+ "optional": false,
149
+ "docs": {
150
+ "tags": [],
151
+ "text": "The name of the panel that is initially shown.\nIf not specified, it defaults to the panel associated with the first tab.\n\n**Changing this value after initialization has no effect.**"
152
+ },
153
+ "attribute": "active-panel",
154
+ "reflect": false
155
+ }
156
+ };
157
+ }
158
+ static get events() {
159
+ return [{
160
+ "method": "tabChange",
161
+ "name": "tabChange",
162
+ "bubbles": true,
163
+ "cancelable": true,
164
+ "composed": true,
165
+ "docs": {
166
+ "tags": [],
167
+ "text": "An event emitted after the active tab changes, when the fade in transition of its associated panel is finished.\nThe payload is the name of the newly shown panel."
168
+ },
169
+ "complexType": {
170
+ "original": "HTMLPostTabPanelElement['name']",
171
+ "resolved": "string",
172
+ "references": {
173
+ "HTMLPostTabPanelElement": {
174
+ "location": "global"
175
+ }
176
+ }
177
+ }
178
+ }];
179
+ }
180
+ static get methods() {
181
+ return {
182
+ "show": {
183
+ "complexType": {
184
+ "signature": "(panelName: string) => Promise<void>",
185
+ "parameters": [{
186
+ "tags": [],
187
+ "text": ""
188
+ }],
189
+ "references": {
190
+ "Promise": {
191
+ "location": "global"
192
+ },
193
+ "HTMLPostTabHeaderElement": {
194
+ "location": "global"
195
+ }
196
+ },
197
+ "return": "Promise<void>"
198
+ },
199
+ "docs": {
200
+ "text": "Shows the panel with the given name and selects its associated tab.\nAny other panel that was previously shown becomes hidden and its associated tab is unselected.",
201
+ "tags": []
202
+ }
203
+ }
204
+ };
205
+ }
206
+ static get elementRef() { return "host"; }
207
+ }
208
+ //# sourceMappingURL=post-tabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-tabs.js","sourceRoot":"","sources":["../../../../src/components/post-tabs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CAClD,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Element, Method, Event, EventEmitter, Prop } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { fadeIn, fadeOut } from '../../animations';\n\n@Component({\n tag: 'post-tabs',\n styleUrl: 'post-tabs.scss',\n shadow: true,\n})\nexport class PostTabs {\n private activeTab: HTMLPostTabHeaderElement;\n private showing: Animation;\n private hiding: Animation;\n private isLoaded = false;\n\n private get tabs(): NodeListOf<HTMLPostTabHeaderElement> {\n return this.host.querySelectorAll('post-tab-header');\n }\n\n @Element() host: HTMLPostTabsElement;\n\n /**\n * The name of the panel that is initially shown.\n * If not specified, it defaults to the panel associated with the first tab.\n *\n * **Changing this value after initialization has no effect.**\n */\n @Prop() readonly activePanel: HTMLPostTabPanelElement['name'];\n\n /**\n * An event emitted after the active tab changes, when the fade in transition of its associated panel is finished.\n * The payload is the name of the newly shown panel.\n */\n @Event() tabChange: EventEmitter<HTMLPostTabPanelElement['name']>;\n\n componentDidLoad() {\n this.moveMisplacedTabs();\n this.enableTabs();\n\n const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;\n this.show(initiallyActivePanel);\n\n this.isLoaded = true;\n }\n\n /**\n * Shows the panel with the given name and selects its associated tab.\n * Any other panel that was previously shown becomes hidden and its associated tab is unselected.\n */\n @Method()\n async show(panelName: string) {\n // do nothing if the tab is already active\n if (panelName === this.activeTab?.panel) {\n return;\n }\n\n const previousTab = this.activeTab;\n const newTab : HTMLPostTabHeaderElement = this.host.querySelector(`post-tab-header[panel=${panelName}]`);\n this.activateTab(newTab);\n\n // if a panel is currently being displayed, remove it from the view and complete the associated animation\n if (this.showing) {\n this.showing.effect['target'].style.display = 'none';\n this.showing.finish();\n }\n\n // hide the currently visible panel only if no other animation is running\n if (previousTab && !this.showing && !this.hiding) {\n this.hidePanel(previousTab.panel);\n }\n\n // wait for any hiding animation to complete before showing the selected tab\n if (this.hiding) {\n await this.hiding.finished;\n }\n\n this.showSelectedPanel();\n\n // wait for any display animation to complete for the returned promise to fully resolve\n if (this.showing) {\n await this.showing.finished;\n }\n\n this.tabChange.emit(this.activeTab.panel);\n }\n private moveMisplacedTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(tab => {\n if (tab.getAttribute('slot') === 'tabs') return;\n tab.setAttribute('slot', 'tabs');\n });\n }\n\n private enableTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(async tab => {\n await tab.componentOnReady();\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n\n // if the tab has an \"aria-controls\" attribute it was already linked to its panel: do nothing\n if (tabTitle.getAttribute('aria-controls')) return;\n\n const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');\n tabTitle.setAttribute('aria-controls', tabPanel.id);\n tabPanel.setAttribute('aria-labelledby', tabTitle.id);\n\n tab.addEventListener('click', e => {\n e.preventDefault();\n this.show(tab.panel);\n });\n });\n\n // if the currently active tab was removed from the DOM then select the first one\n if (this.activeTab && !this.activeTab.isConnected) {\n this.show(this.tabs.item(0).panel);\n }\n }\n\n private activateTab(tab: HTMLPostTabHeaderElement) {\n if (this.activeTab) {\n const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'false');\n tabTitle.classList.remove('active');\n }\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'true');\n tabTitle.classList.add('active');\n\n this.activeTab = tab;\n }\n\n private hidePanel(panelName: HTMLPostTabPanelElement['name']) {\n const previousPanel = this.getPanel(panelName);\n\n if (!previousPanel) return;\n\n this.hiding = fadeOut(previousPanel);\n this.hiding.onfinish = () => {\n previousPanel.style.display = 'none';\n this.hiding = null;\n };\n }\n\n private showSelectedPanel() {\n const panel = this.getPanel(this.activeTab.panel);\n panel.style.display = 'block';\n\n // prevent the initially selected panel from fading in\n if (!this.isLoaded) return;\n\n this.showing = fadeIn(panel);\n this.showing.onfinish = () => {\n this.showing = null;\n };\n }\n\n private getPanel(name: string): HTMLPostTabPanelElement {\n return this.host.querySelector(\n `post-tab-panel[name=${name}]`\n );\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div class=\"tabs-wrapper\">\n <ul class=\"tabs nav\" role=\"tablist\">\n <slot name=\"tabs\" onSlotchange={() => this.enableTabs()} />\n </ul>\n </div>\n <div class=\"tab-content\">\n <slot onSlotchange={() => this.moveMisplacedTabs()} />\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ const EMPTY_VALUES = [undefined, null, ''];
2
+
3
+ function checkNonEmpty(value, error) {
4
+ if (EMPTY_VALUES.some(v => v === value)) {
5
+ throw new Error(error);
6
+ }
7
+ }
8
+
9
+ export { EMPTY_VALUES as E, checkNonEmpty as c };
10
+
11
+ //# sourceMappingURL=check-non-empty.js.map
@@ -0,0 +1 @@
1
+ {"file":"check-non-empty.js","mappings":"MAAa,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE;;SCEhC,aAAa,CAAC,KAAc,EAAE,KAAa;EACzD,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE;IACvC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GACxB;AACH;;;;","names":[],"sources":["./src/utils/property-checkers/constants.ts","./src/utils/property-checkers/check-non-empty.ts"],"sourcesContent":["export const EMPTY_VALUES = [undefined, null, ''];\n","import { EMPTY_VALUES } from './constants';\n\nexport function checkNonEmpty(value: unknown, error: string) {\n if (EMPTY_VALUES.some(v => v === value)) {\n throw new Error(error);\n }\n}\n"],"version":3}
@@ -16,8 +16,6 @@ function checkType(value, type, error) {
16
16
  }
17
17
  }
18
18
 
19
- const version = "1.3.9";
19
+ export { checkOneOf as a, checkType as c };
20
20
 
21
- export { checkOneOf as a, checkType as c, version as v };
22
-
23
- //# sourceMappingURL=package-adf815bd.js.map
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}
@@ -1,23 +1,5 @@
1
- function checkOneOf(value, possibleValues, error) {
2
- if (!possibleValues.includes(value))
3
- throw new Error(error);
4
- }
1
+ const version = "1.4.0";
5
2
 
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
- const version = "1.3.9";
20
-
21
- export { checkOneOf as a, checkType as c, version as v };
3
+ export { version as v };
22
4
 
23
5
  //# sourceMappingURL=package.js.map
@@ -1 +1 @@
1
- {"file":"package.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}
1
+ {"file":"package.js","mappings":";;;;","names":[],"sources":[],"sourcesContent":[],"version":3}