@swisspost/design-system-components 1.3.10 → 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 (110) 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-f6bb523d.js → check-type-f24cf91d.js} +1 -4
  4. package/dist/cjs/{package-f6bb523d.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 +5 -4
  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-tab-header/post-tab-header.css +337 -0
  27. package/dist/collection/components/post-tab-header/post-tab-header.js +68 -0
  28. package/dist/collection/components/post-tab-header/post-tab-header.js.map +1 -0
  29. package/dist/collection/components/post-tab-panel/post-tab-panel.css +3 -0
  30. package/dist/collection/components/post-tab-panel/post-tab-panel.js +55 -0
  31. package/dist/collection/components/post-tab-panel/post-tab-panel.js.map +1 -0
  32. package/dist/collection/components/post-tabs/post-tabs.css +148 -0
  33. package/dist/collection/components/post-tabs/post-tabs.js +208 -0
  34. package/dist/collection/components/post-tabs/post-tabs.js.map +1 -0
  35. package/dist/components/check-non-empty.js +11 -0
  36. package/dist/components/check-non-empty.js.map +1 -0
  37. package/dist/{esm/package-bcf00737.js → components/check-type.js} +2 -4
  38. package/dist/components/check-type.js.map +1 -0
  39. package/dist/components/package.js +2 -20
  40. package/dist/components/package.js.map +1 -1
  41. package/dist/components/post-collapsible.js +2 -1
  42. package/dist/components/post-collapsible.js.map +1 -1
  43. package/dist/components/post-icon.js +3 -9
  44. package/dist/components/post-icon.js.map +1 -1
  45. package/dist/components/post-tab-header.d.ts +11 -0
  46. package/dist/components/post-tab-header.js +52 -0
  47. package/dist/components/post-tab-header.js.map +1 -0
  48. package/dist/components/post-tab-panel.d.ts +11 -0
  49. package/dist/components/post-tab-panel.js +46 -0
  50. package/dist/components/post-tab-panel.js.map +1 -0
  51. package/dist/components/post-tabs.d.ts +11 -0
  52. package/dist/components/post-tabs.js +158 -0
  53. package/dist/components/post-tabs.js.map +1 -0
  54. package/dist/docs.json +131 -1
  55. package/dist/esm/check-non-empty-554bdf88.js +11 -0
  56. package/dist/esm/check-non-empty-554bdf88.js.map +1 -0
  57. package/dist/esm/check-type-67411ed3.js +21 -0
  58. package/dist/esm/check-type-67411ed3.js.map +1 -0
  59. package/dist/esm/{index-60a84798.js → index-cc0e53f0.js} +15 -2
  60. package/dist/esm/index-cc0e53f0.js.map +1 -0
  61. package/dist/esm/loader.js +3 -3
  62. package/dist/esm/package-b514d0f6.js +5 -0
  63. package/dist/esm/package-b514d0f6.js.map +1 -0
  64. package/dist/esm/post-collapsible.entry.js +3 -2
  65. package/dist/esm/post-collapsible.entry.js.map +1 -1
  66. package/dist/esm/post-components.js +3 -3
  67. package/dist/esm/post-icon.entry.js +4 -10
  68. package/dist/esm/post-icon.entry.js.map +1 -1
  69. package/dist/esm/post-tab-header.entry.js +31 -0
  70. package/dist/esm/post-tab-header.entry.js.map +1 -0
  71. package/dist/esm/post-tab-panel.entry.js +25 -0
  72. package/dist/esm/post-tab-panel.entry.js.map +1 -0
  73. package/dist/esm/post-tabs.entry.js +137 -0
  74. package/dist/esm/post-tabs.entry.js.map +1 -0
  75. package/dist/post-components/p-1388585d.entry.js +2 -0
  76. package/dist/post-components/p-1388585d.entry.js.map +1 -0
  77. package/dist/post-components/p-58916755.js +2 -0
  78. package/dist/post-components/p-58916755.js.map +1 -0
  79. package/dist/post-components/p-5b3445dc.entry.js +2 -0
  80. package/dist/post-components/p-5b3445dc.entry.js.map +1 -0
  81. package/dist/post-components/p-6341b9b4.js +3 -0
  82. package/dist/post-components/p-6341b9b4.js.map +1 -0
  83. package/dist/post-components/p-6dad6a8a.entry.js +2 -0
  84. package/dist/post-components/{p-99ccf0cf.entry.js.map → p-6dad6a8a.entry.js.map} +1 -1
  85. package/dist/post-components/p-b95ec099.entry.js +2 -0
  86. package/dist/post-components/p-b95ec099.entry.js.map +1 -0
  87. package/dist/post-components/p-c8efe0ae.js +2 -0
  88. package/dist/post-components/p-c8efe0ae.js.map +1 -0
  89. package/dist/post-components/p-cc92afb7.entry.js +2 -0
  90. package/dist/post-components/p-cc92afb7.entry.js.map +1 -0
  91. package/dist/post-components/p-f549b3fc.js +2 -0
  92. package/dist/post-components/{p-4a3ff4c0.js.map → p-f549b3fc.js.map} +1 -1
  93. package/dist/post-components/post-components.esm.js +1 -1
  94. package/dist/post-components/post-components.esm.js.map +1 -1
  95. package/dist/types/animations/fade.d.ts +2 -0
  96. package/dist/types/animations/index.d.ts +1 -0
  97. package/dist/types/components/post-tab-header/post-tab-header.d.ts +11 -0
  98. package/dist/types/components/post-tab-panel/post-tab-panel.d.ts +10 -0
  99. package/dist/types/components/post-tabs/post-tabs.d.ts +34 -0
  100. package/dist/types/components.d.ts +75 -0
  101. package/package.json +6 -6
  102. package/dist/cjs/index-272283b3.js.map +0 -1
  103. package/dist/esm/index-60a84798.js.map +0 -1
  104. package/dist/esm/package-bcf00737.js.map +0 -1
  105. package/dist/post-components/p-0096c140.js +0 -3
  106. package/dist/post-components/p-0096c140.js.map +0 -1
  107. package/dist/post-components/p-4a3ff4c0.js +0 -2
  108. package/dist/post-components/p-99ccf0cf.entry.js +0 -2
  109. package/dist/post-components/p-cafa0281.entry.js +0 -2
  110. package/dist/post-components/p-cafa0281.entry.js.map +0 -1
@@ -0,0 +1,158 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { v as version } from './package.js';
3
+
4
+ const fadeDuration = 200;
5
+ const fadedOutKeyFrame = { opacity: '0' };
6
+ const fadedInKeyFrame = { opacity: '1' };
7
+ const fadeIn = (el) => el.animate([fadedOutKeyFrame, fadedInKeyFrame], { duration: fadeDuration });
8
+ const fadeOut = (el) => el.animate([fadedInKeyFrame, fadedOutKeyFrame], { duration: fadeDuration });
9
+
10
+ const postTabsCss = ".tabs-wrapper{position:relative;padding-top:1rem;border:0;background-color:#faf9f8}.tabs-wrapper::after{content:\"\";position:absolute;bottom:0;width:100%;height:1px;background-color:hsl(0, 0%, 80%)}.tabs-wrapper .tabs{background-color:transparent !important}@media (forced-colors: active), (-ms-high-contrast: active), (-ms-high-contrast: white-on-black){.tabs-wrapper::after{background-color:ButtonBorder}}.tabs{margin:0;padding:0;list-style:none;display:flex;flex-wrap:nowrap;overflow-x:auto;overscroll-behavior-x:contain;white-space:nowrap}.tabs::after{content:\"\";display:block;flex:1 0 auto;width:1rem}.tab-content{padding-top:1rem;padding-bottom:1rem}.bg-yellow .tabs-wrapper{background-color:#fc0}.bg-light .tabs-wrapper{background-color:#faf9f8}.bg-gray .tabs-wrapper{background-color:#f4f3f1}.bg-dark .tabs-wrapper{background-color:hsl(0, 0%, 20%)}.bg-primary .tabs-wrapper{background-color:hsl(0, 0%, 20%)}.bg-white .tabs-wrapper{background-color:#fff}.bg-black .tabs-wrapper{background-color:#000}.bg-success .tabs-wrapper{background-color:#2c911c}.bg-info .tabs-wrapper{background-color:#cce4ee}.bg-warning .tabs-wrapper{background-color:#f49e00}.bg-danger .tabs-wrapper{background-color:#a51728}.bg-nightblue .tabs-wrapper{background-color:#004976}.bg-nightblue-bright .tabs-wrapper{background-color:#0076a8}.bg-petrol .tabs-wrapper{background-color:#006d68}.bg-petrol-bright .tabs-wrapper{background-color:#00968f}.bg-coral .tabs-wrapper{background-color:#9e2a2f}.bg-coral-bright .tabs-wrapper{background-color:#e03c31}.bg-olive .tabs-wrapper{background-color:#716135}.bg-olive-bright .tabs-wrapper{background-color:#aa9d2e}.bg-purple .tabs-wrapper{background-color:#80276c}.bg-purple-bright .tabs-wrapper{background-color:#c5299b}.bg-aubergine .tabs-wrapper{background-color:#523178}.bg-aubergine-bright .tabs-wrapper{background-color:#7566a0}:host{display:block}";
11
+
12
+ const PostTabs$1 = /*@__PURE__*/ proxyCustomElement(class PostTabs extends HTMLElement {
13
+ constructor() {
14
+ super();
15
+ this.__registerHost();
16
+ this.__attachShadow();
17
+ this.tabChange = createEvent(this, "tabChange", 7);
18
+ this.isLoaded = false;
19
+ this.activePanel = undefined;
20
+ }
21
+ get tabs() {
22
+ return this.host.querySelectorAll('post-tab-header');
23
+ }
24
+ componentDidLoad() {
25
+ this.moveMisplacedTabs();
26
+ this.enableTabs();
27
+ const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;
28
+ this.show(initiallyActivePanel);
29
+ this.isLoaded = true;
30
+ }
31
+ /**
32
+ * Shows the panel with the given name and selects its associated tab.
33
+ * Any other panel that was previously shown becomes hidden and its associated tab is unselected.
34
+ */
35
+ async show(panelName) {
36
+ var _a;
37
+ // do nothing if the tab is already active
38
+ if (panelName === ((_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.panel)) {
39
+ return;
40
+ }
41
+ const previousTab = this.activeTab;
42
+ const newTab = this.host.querySelector(`post-tab-header[panel=${panelName}]`);
43
+ this.activateTab(newTab);
44
+ // if a panel is currently being displayed, remove it from the view and complete the associated animation
45
+ if (this.showing) {
46
+ this.showing.effect['target'].style.display = 'none';
47
+ this.showing.finish();
48
+ }
49
+ // hide the currently visible panel only if no other animation is running
50
+ if (previousTab && !this.showing && !this.hiding) {
51
+ this.hidePanel(previousTab.panel);
52
+ }
53
+ // wait for any hiding animation to complete before showing the selected tab
54
+ if (this.hiding) {
55
+ await this.hiding.finished;
56
+ }
57
+ this.showSelectedPanel();
58
+ // wait for any display animation to complete for the returned promise to fully resolve
59
+ if (this.showing) {
60
+ await this.showing.finished;
61
+ }
62
+ this.tabChange.emit(this.activeTab.panel);
63
+ }
64
+ moveMisplacedTabs() {
65
+ if (!this.tabs)
66
+ return;
67
+ this.tabs.forEach(tab => {
68
+ if (tab.getAttribute('slot') === 'tabs')
69
+ return;
70
+ tab.setAttribute('slot', 'tabs');
71
+ });
72
+ }
73
+ enableTabs() {
74
+ if (!this.tabs)
75
+ return;
76
+ this.tabs.forEach(async (tab) => {
77
+ await tab.componentOnReady();
78
+ const tabTitle = tab.shadowRoot.querySelector('.tab-title');
79
+ // if the tab has an "aria-controls" attribute it was already linked to its panel: do nothing
80
+ if (tabTitle.getAttribute('aria-controls'))
81
+ return;
82
+ const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');
83
+ tabTitle.setAttribute('aria-controls', tabPanel.id);
84
+ tabPanel.setAttribute('aria-labelledby', tabTitle.id);
85
+ tab.addEventListener('click', e => {
86
+ e.preventDefault();
87
+ this.show(tab.panel);
88
+ });
89
+ });
90
+ // if the currently active tab was removed from the DOM then select the first one
91
+ if (this.activeTab && !this.activeTab.isConnected) {
92
+ this.show(this.tabs.item(0).panel);
93
+ }
94
+ }
95
+ activateTab(tab) {
96
+ if (this.activeTab) {
97
+ const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');
98
+ tabTitle.setAttribute('aria-selected', 'false');
99
+ tabTitle.classList.remove('active');
100
+ }
101
+ const tabTitle = tab.shadowRoot.querySelector('.tab-title');
102
+ tabTitle.setAttribute('aria-selected', 'true');
103
+ tabTitle.classList.add('active');
104
+ this.activeTab = tab;
105
+ }
106
+ hidePanel(panelName) {
107
+ const previousPanel = this.getPanel(panelName);
108
+ if (!previousPanel)
109
+ return;
110
+ this.hiding = fadeOut(previousPanel);
111
+ this.hiding.onfinish = () => {
112
+ previousPanel.style.display = 'none';
113
+ this.hiding = null;
114
+ };
115
+ }
116
+ showSelectedPanel() {
117
+ const panel = this.getPanel(this.activeTab.panel);
118
+ panel.style.display = 'block';
119
+ // prevent the initially selected panel from fading in
120
+ if (!this.isLoaded)
121
+ return;
122
+ this.showing = fadeIn(panel);
123
+ this.showing.onfinish = () => {
124
+ this.showing = null;
125
+ };
126
+ }
127
+ getPanel(name) {
128
+ return this.host.querySelector(`post-tab-panel[name=${name}]`);
129
+ }
130
+ render() {
131
+ 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() }))));
132
+ }
133
+ get host() { return this; }
134
+ static get style() { return postTabsCss; }
135
+ }, [1, "post-tabs", {
136
+ "activePanel": [1, "active-panel"],
137
+ "show": [64]
138
+ }]);
139
+ function defineCustomElement$1() {
140
+ if (typeof customElements === "undefined") {
141
+ return;
142
+ }
143
+ const components = ["post-tabs"];
144
+ components.forEach(tagName => { switch (tagName) {
145
+ case "post-tabs":
146
+ if (!customElements.get(tagName)) {
147
+ customElements.define(tagName, PostTabs$1);
148
+ }
149
+ break;
150
+ } });
151
+ }
152
+
153
+ const PostTabs = PostTabs$1;
154
+ const defineCustomElement = defineCustomElement$1;
155
+
156
+ export { PostTabs, defineCustomElement };
157
+
158
+ //# sourceMappingURL=post-tabs.js.map
@@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;;;;;;;;;;","names":["PostTabs"],"sources":["./src/animations/fade.ts","./src/components/post-tabs/post-tabs.scss?tag=post-tabs&encapsulation=shadow","./src/components/post-tabs/post-tabs.tsx"],"sourcesContent":["const fadeDuration = 200;\nconst fadedOutKeyFrame = {opacity: '0'};\nconst fadedInKeyFrame = {opacity: '1'};\n\nexport const fadeIn = (el: Element): Animation => el.animate(\n [ fadedOutKeyFrame, fadedInKeyFrame ],\n { duration: fadeDuration }\n);\n\nexport const fadeOut = (el: Element): Animation => el.animate(\n [ fadedInKeyFrame, fadedOutKeyFrame ],\n { duration: fadeDuration }\n);\n","@use '@swisspost/design-system-styles/components/tabs/tabs-wrapper';\n\n:host {\n display: block;\n}\n","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"],"version":3}
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2023-08-14T11:59:52",
2
+ "timestamp": "2023-08-31T09:34:16",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "3.4.2",
@@ -235,6 +235,136 @@
235
235
  "dependents": [],
236
236
  "dependencies": [],
237
237
  "dependencyGraph": {}
238
+ },
239
+ {
240
+ "filePath": "./src/components/post-tab-header/post-tab-header.tsx",
241
+ "encapsulation": "shadow",
242
+ "tag": "post-tab-header",
243
+ "readme": "# post-tab-header\n\n\n",
244
+ "docs": "",
245
+ "docsTags": [],
246
+ "usage": {},
247
+ "props": [
248
+ {
249
+ "name": "panel",
250
+ "type": "string",
251
+ "mutable": false,
252
+ "attr": "panel",
253
+ "reflectToAttr": false,
254
+ "docs": "The name of the panel controlled by the tab header.",
255
+ "docsTags": [],
256
+ "values": [
257
+ {
258
+ "type": "string"
259
+ }
260
+ ],
261
+ "optional": false,
262
+ "required": false
263
+ }
264
+ ],
265
+ "methods": [],
266
+ "events": [],
267
+ "listeners": [],
268
+ "styles": [],
269
+ "slots": [],
270
+ "parts": [],
271
+ "dependents": [],
272
+ "dependencies": [],
273
+ "dependencyGraph": {}
274
+ },
275
+ {
276
+ "filePath": "./src/components/post-tab-panel/post-tab-panel.tsx",
277
+ "encapsulation": "shadow",
278
+ "tag": "post-tab-panel",
279
+ "readme": "# post-tab-panel\n\n\n",
280
+ "docs": "",
281
+ "docsTags": [],
282
+ "usage": {},
283
+ "props": [
284
+ {
285
+ "name": "name",
286
+ "type": "string",
287
+ "mutable": false,
288
+ "attr": "name",
289
+ "reflectToAttr": false,
290
+ "docs": "The name of the panel, used to associate it with a tab header.",
291
+ "docsTags": [],
292
+ "values": [
293
+ {
294
+ "type": "string"
295
+ }
296
+ ],
297
+ "optional": false,
298
+ "required": false
299
+ }
300
+ ],
301
+ "methods": [],
302
+ "events": [],
303
+ "listeners": [],
304
+ "styles": [],
305
+ "slots": [],
306
+ "parts": [],
307
+ "dependents": [],
308
+ "dependencies": [],
309
+ "dependencyGraph": {}
310
+ },
311
+ {
312
+ "filePath": "./src/components/post-tabs/post-tabs.tsx",
313
+ "encapsulation": "shadow",
314
+ "tag": "post-tabs",
315
+ "readme": "# post-tabs\n\n\n",
316
+ "docs": "",
317
+ "docsTags": [],
318
+ "usage": {},
319
+ "props": [
320
+ {
321
+ "name": "activePanel",
322
+ "type": "string",
323
+ "mutable": false,
324
+ "attr": "active-panel",
325
+ "reflectToAttr": false,
326
+ "docs": "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.**",
327
+ "docsTags": [],
328
+ "values": [
329
+ {
330
+ "type": "string"
331
+ }
332
+ ],
333
+ "optional": false,
334
+ "required": false
335
+ }
336
+ ],
337
+ "methods": [
338
+ {
339
+ "name": "show",
340
+ "returns": {
341
+ "type": "Promise<void>",
342
+ "docs": ""
343
+ },
344
+ "signature": "show(panelName: string) => Promise<void>",
345
+ "parameters": [],
346
+ "docs": "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.",
347
+ "docsTags": []
348
+ }
349
+ ],
350
+ "events": [
351
+ {
352
+ "event": "tabChange",
353
+ "detail": "string",
354
+ "bubbles": true,
355
+ "cancelable": true,
356
+ "composed": true,
357
+ "docs": "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.",
358
+ "docsTags": []
359
+ }
360
+ ],
361
+ "listeners": [],
362
+ "styles": [],
363
+ "slots": [],
364
+ "parts": [],
365
+ "dependents": [],
366
+ "dependencies": [],
367
+ "dependencyGraph": {}
238
368
  }
239
369
  ]
240
370
  }
@@ -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-554bdf88.js.map
@@ -0,0 +1 @@
1
+ {"file":"check-non-empty-554bdf88.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}
@@ -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-67411ed3.js.map
@@ -0,0 +1 @@
1
+ {"file":"check-type-67411ed3.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}
@@ -257,6 +257,19 @@ const parsePropertyValue = (propValue, propType) => {
257
257
  return propValue;
258
258
  };
259
259
  const getElement = (ref) => (getHostRef(ref).$hostElement$ );
260
+ const createEvent = (ref, name, flags) => {
261
+ const elm = getElement(ref);
262
+ return {
263
+ emit: (detail) => {
264
+ return emitEvent(elm, name, {
265
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
266
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
267
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
268
+ detail,
269
+ });
270
+ },
271
+ };
272
+ };
260
273
  /**
261
274
  * Helper function to create & dispatch a custom Event on a provided target
262
275
  * @param elm the target of the Event
@@ -1585,6 +1598,6 @@ const flush = () => {
1585
1598
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1586
1599
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1587
1600
 
1588
- export { Host as H, bootstrapLazy as b, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
1601
+ export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
1589
1602
 
1590
- //# sourceMappingURL=index-60a84798.js.map
1603
+ //# sourceMappingURL=index-cc0e53f0.js.map