@swisspost/design-system-components 1.6.1 → 1.6.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.
Files changed (164) hide show
  1. package/dist/cjs/{index-b619e205.js → index-e7618bb3.js} +16 -6
  2. package/dist/cjs/index-e7618bb3.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +26 -0
  4. package/dist/cjs/index.cjs.js.map +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/package-041a8597.js +7 -0
  7. package/dist/cjs/package-041a8597.js.map +1 -0
  8. package/dist/cjs/post-accordion.cjs.entry.js +2 -2
  9. package/dist/cjs/post-alert-1fb90f2d.js +101 -0
  10. package/dist/cjs/post-alert-1fb90f2d.js.map +1 -0
  11. package/dist/cjs/post-alert.cjs.entry.js +7 -94
  12. package/dist/cjs/post-alert.cjs.entry.js.map +1 -1
  13. package/dist/cjs/post-collapsible-e46002bb.js +93 -0
  14. package/dist/cjs/post-collapsible-e46002bb.js.map +1 -0
  15. package/dist/cjs/post-collapsible.cjs.entry.js +5 -86
  16. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  17. package/dist/cjs/post-components.cjs.js +2 -2
  18. package/dist/cjs/post-components.cjs.js.map +1 -1
  19. package/dist/cjs/post-icon-91f6603a.js +105 -0
  20. package/dist/cjs/post-icon-91f6603a.js.map +1 -0
  21. package/dist/cjs/post-icon.cjs.entry.js +6 -98
  22. package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
  23. package/dist/cjs/post-tab-header-a3845fe5.js +33 -0
  24. package/dist/cjs/post-tab-header-a3845fe5.js.map +1 -0
  25. package/dist/cjs/post-tab-header.cjs.entry.js +5 -26
  26. package/dist/cjs/post-tab-header.cjs.entry.js.map +1 -1
  27. package/dist/cjs/post-tab-panel-b7326ff8.js +27 -0
  28. package/dist/cjs/post-tab-panel-b7326ff8.js.map +1 -0
  29. package/dist/cjs/post-tab-panel.cjs.entry.js +4 -20
  30. package/dist/cjs/post-tab-panel.cjs.entry.js.map +1 -1
  31. package/dist/cjs/post-tabs-384a1fab.js +153 -0
  32. package/dist/cjs/post-tabs-384a1fab.js.map +1 -0
  33. package/dist/cjs/post-tabs.cjs.entry.js +5 -146
  34. package/dist/cjs/post-tabs.cjs.entry.js.map +1 -1
  35. package/dist/cjs/post-tooltip-2becc97a.js +5167 -0
  36. package/dist/cjs/post-tooltip-2becc97a.js.map +1 -0
  37. package/dist/cjs/post-tooltip.cjs.entry.js +5 -5088
  38. package/dist/cjs/post-tooltip.cjs.entry.js.map +1 -1
  39. package/dist/collection/collection-manifest.json +4 -4
  40. package/dist/collection/components/post-alert/post-alert.css +1 -1
  41. package/dist/collection/components/post-tooltip/post-tooltip.css +1 -1
  42. package/dist/collection/components/post-tooltip/post-tooltip.js +1 -1
  43. package/dist/collection/index.js +8 -1
  44. package/dist/collection/index.js.map +1 -1
  45. package/dist/components/index.js +7 -0
  46. package/dist/components/index.js.map +1 -1
  47. package/dist/components/package.js +1 -1
  48. package/dist/components/post-alert.js +1 -134
  49. package/dist/components/post-alert.js.map +1 -1
  50. package/dist/components/post-alert2.js +138 -0
  51. package/dist/components/post-alert2.js.map +1 -0
  52. package/dist/components/post-collapsible.js +1 -113
  53. package/dist/components/post-collapsible.js.map +1 -1
  54. package/dist/components/post-collapsible2.js +117 -0
  55. package/dist/components/post-collapsible2.js.map +1 -0
  56. package/dist/components/post-tab-header.js +1 -47
  57. package/dist/components/post-tab-header.js.map +1 -1
  58. package/dist/components/post-tab-header2.js +51 -0
  59. package/dist/components/post-tab-header2.js.map +1 -0
  60. package/dist/components/post-tab-panel.js +1 -39
  61. package/dist/components/post-tab-panel.js.map +1 -1
  62. package/dist/components/post-tab-panel2.js +43 -0
  63. package/dist/components/post-tab-panel2.js.map +1 -0
  64. package/dist/components/post-tabs.js +1 -165
  65. package/dist/components/post-tabs.js.map +1 -1
  66. package/dist/components/post-tabs2.js +169 -0
  67. package/dist/components/post-tabs2.js.map +1 -0
  68. package/dist/components/post-tooltip.js +1 -5113
  69. package/dist/components/post-tooltip.js.map +1 -1
  70. package/dist/components/post-tooltip2.js +5189 -0
  71. package/dist/components/post-tooltip2.js.map +1 -0
  72. package/dist/docs.json +5 -5
  73. package/dist/esm/{index-4eff5fc5.js → index-08d62a75.js} +16 -6
  74. package/dist/esm/index-08d62a75.js.map +1 -0
  75. package/dist/esm/index.js +14 -1
  76. package/dist/esm/index.js.map +1 -1
  77. package/dist/esm/loader.js +2 -2
  78. package/dist/esm/package-a962a93d.js +5 -0
  79. package/dist/esm/package-a962a93d.js.map +1 -0
  80. package/dist/esm/post-accordion.entry.js +2 -2
  81. package/dist/{post-components/p-10c47e0a.entry.js → esm/post-alert-46926902.js} +99 -2
  82. package/dist/esm/post-alert-46926902.js.map +1 -0
  83. package/dist/esm/post-alert.entry.js +6 -97
  84. package/dist/esm/post-alert.entry.js.map +1 -1
  85. package/dist/esm/post-collapsible-f1b6592d.js +91 -0
  86. package/dist/esm/post-collapsible-f1b6592d.js.map +1 -0
  87. package/dist/esm/post-collapsible.entry.js +4 -89
  88. package/dist/esm/post-collapsible.entry.js.map +1 -1
  89. package/dist/esm/post-components.js +3 -3
  90. package/dist/esm/post-components.js.map +1 -1
  91. package/dist/esm/post-icon-fb627697.js +103 -0
  92. package/dist/esm/post-icon-fb627697.js.map +1 -0
  93. package/dist/esm/post-icon.entry.js +5 -101
  94. package/dist/esm/post-icon.entry.js.map +1 -1
  95. package/dist/esm/post-tab-header-84b12382.js +31 -0
  96. package/dist/esm/post-tab-header-84b12382.js.map +1 -0
  97. package/dist/esm/post-tab-header.entry.js +4 -29
  98. package/dist/esm/post-tab-header.entry.js.map +1 -1
  99. package/dist/esm/post-tab-panel-216c0b6e.js +25 -0
  100. package/dist/esm/post-tab-panel-216c0b6e.js.map +1 -0
  101. package/dist/esm/post-tab-panel.entry.js +3 -23
  102. package/dist/esm/post-tab-panel.entry.js.map +1 -1
  103. package/dist/esm/post-tabs-e235d663.js +151 -0
  104. package/dist/esm/post-tabs-e235d663.js.map +1 -0
  105. package/dist/esm/post-tabs.entry.js +4 -149
  106. package/dist/esm/post-tabs.entry.js.map +1 -1
  107. package/dist/esm/post-tooltip-47f2146d.js +5165 -0
  108. package/dist/esm/post-tooltip-47f2146d.js.map +1 -0
  109. package/dist/esm/post-tooltip.entry.js +4 -5091
  110. package/dist/esm/post-tooltip.entry.js.map +1 -1
  111. package/dist/post-components/index.esm.js +1 -1
  112. package/dist/post-components/p-03fe58da.js +2 -0
  113. package/dist/post-components/{p-08d942a0.entry.js.map → p-03fe58da.js.map} +1 -1
  114. package/dist/post-components/p-151b55c0.entry.js +2 -0
  115. package/dist/post-components/p-21549a50.js +2 -0
  116. package/dist/post-components/{p-871ade93.entry.js.map → p-21549a50.js.map} +1 -1
  117. package/dist/post-components/p-4cb18ddf.js +9 -0
  118. package/dist/post-components/p-4cb18ddf.js.map +1 -0
  119. package/dist/post-components/p-4e24f13b.entry.js +2 -0
  120. package/dist/post-components/p-4e24f13b.entry.js.map +1 -0
  121. package/dist/post-components/{p-2755ba2e.entry.js → p-57b48dff.js} +2 -2
  122. package/dist/post-components/p-57fdeeab.js +2 -0
  123. package/dist/post-components/{p-10c47e0a.entry.js.map → p-57fdeeab.js.map} +1 -1
  124. package/dist/post-components/p-58cc7b5a.entry.js +2 -0
  125. package/dist/post-components/p-58cc7b5a.entry.js.map +1 -0
  126. package/dist/post-components/p-6cafa644.entry.js +2 -0
  127. package/dist/post-components/p-6cafa644.entry.js.map +1 -0
  128. package/dist/post-components/p-7f370d77.entry.js +2 -0
  129. package/dist/post-components/p-7f370d77.entry.js.map +1 -0
  130. package/dist/post-components/p-7f4eba57.js +2 -0
  131. package/dist/post-components/p-8c006e7d.js +3 -0
  132. package/dist/post-components/p-8c006e7d.js.map +1 -0
  133. package/dist/post-components/p-aee47e1a.entry.js +2 -0
  134. package/dist/post-components/p-aee47e1a.entry.js.map +1 -0
  135. package/dist/post-components/p-b5e1fd89.js +2 -0
  136. package/dist/post-components/{p-a18e1d1c.entry.js.map → p-b5e1fd89.js.map} +1 -1
  137. package/dist/post-components/{p-6a0a1ce4.entry.js → p-ce907090.entry.js} +2 -2
  138. package/dist/post-components/p-d13111f2.js +2 -0
  139. package/dist/post-components/p-d13111f2.js.map +1 -0
  140. package/dist/post-components/p-f35c2075.entry.js +2 -0
  141. package/dist/post-components/p-f35c2075.entry.js.map +1 -0
  142. package/dist/post-components/post-components.esm.js +1 -1
  143. package/dist/post-components/post-components.esm.js.map +1 -1
  144. package/dist/types/index.d.ts +7 -0
  145. package/package.json +12 -12
  146. package/dist/cjs/index-b619e205.js.map +0 -1
  147. package/dist/cjs/package-bd70f73c.js +0 -7
  148. package/dist/cjs/package-bd70f73c.js.map +0 -1
  149. package/dist/esm/index-4eff5fc5.js.map +0 -1
  150. package/dist/esm/package-f3f12016.js +0 -5
  151. package/dist/esm/package-f3f12016.js.map +0 -1
  152. package/dist/post-components/p-08d942a0.entry.js +0 -2
  153. package/dist/post-components/p-4aae941f.js +0 -2
  154. package/dist/post-components/p-7d91397a.entry.js +0 -2
  155. package/dist/post-components/p-871ade93.entry.js +0 -2
  156. package/dist/post-components/p-a18e1d1c.entry.js +0 -2
  157. package/dist/post-components/p-a7649277.js +0 -3
  158. package/dist/post-components/p-a7649277.js.map +0 -1
  159. package/dist/post-components/p-b4b7e30c.entry.js +0 -9
  160. package/dist/post-components/p-b4b7e30c.entry.js.map +0 -1
  161. /package/dist/post-components/{p-4aae941f.js.map → p-151b55c0.entry.js.map} +0 -0
  162. /package/dist/post-components/{p-2755ba2e.entry.js.map → p-57b48dff.js.map} +0 -0
  163. /package/dist/post-components/{p-7d91397a.entry.js.map → p-7f4eba57.js.map} +0 -0
  164. /package/dist/post-components/{p-6a0a1ce4.entry.js.map → p-ce907090.entry.js.map} +0 -0
@@ -1,168 +1,4 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { v as version } from './package.js';
3
- import { f as fadeOut, a as fadeIn } from './fade.js';
4
-
5
- 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:#ccc}.tabs-wrapper .tabs{background-color:rgba(0,0,0,0) !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:#333}.bg-primary .tabs-wrapper{background-color:#333}.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}";
6
-
7
- const PostTabs$1 = /*@__PURE__*/ proxyCustomElement(class PostTabs extends HTMLElement {
8
- constructor() {
9
- super();
10
- this.__registerHost();
11
- this.__attachShadow();
12
- this.tabChange = createEvent(this, "tabChange", 7);
13
- this.isLoaded = false;
14
- this.activePanel = undefined;
15
- }
16
- get tabs() {
17
- return this.host.querySelectorAll('post-tab-header');
18
- }
19
- componentDidLoad() {
20
- this.moveMisplacedTabs();
21
- this.enableTabs();
22
- const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;
23
- void this.show(initiallyActivePanel);
24
- this.isLoaded = true;
25
- }
26
- /**
27
- * Shows the panel with the given name and selects its associated tab.
28
- * Any other panel that was previously shown becomes hidden and its associated tab is unselected.
29
- */
30
- async show(panelName) {
31
- var _a;
32
- // do nothing if the tab is already active
33
- if (panelName === ((_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.panel)) {
34
- return;
35
- }
36
- const previousTab = this.activeTab;
37
- const newTab = this.host.querySelector(`post-tab-header[panel=${panelName}]`);
38
- this.activateTab(newTab);
39
- // if a panel is currently being displayed, remove it from the view and complete the associated animation
40
- if (this.showing) {
41
- this.showing.effect['target'].style.display = 'none';
42
- this.showing.finish();
43
- }
44
- // hide the currently visible panel only if no other animation is running
45
- if (previousTab && !this.showing && !this.hiding) {
46
- this.hidePanel(previousTab.panel);
47
- }
48
- // wait for any hiding animation to complete before showing the selected tab
49
- if (this.hiding) {
50
- await this.hiding.finished;
51
- }
52
- this.showSelectedPanel();
53
- // wait for any display animation to complete for the returned promise to fully resolve
54
- if (this.showing) {
55
- await this.showing.finished;
56
- }
57
- this.tabChange.emit(this.activeTab.panel);
58
- }
59
- moveMisplacedTabs() {
60
- if (!this.tabs)
61
- return;
62
- this.tabs.forEach(tab => {
63
- if (tab.getAttribute('slot') === 'tabs')
64
- return;
65
- tab.setAttribute('slot', 'tabs');
66
- });
67
- }
68
- enableTabs() {
69
- if (!this.tabs)
70
- return;
71
- this.tabs.forEach(async (tab) => {
72
- await tab.componentOnReady();
73
- const tabTitle = tab.shadowRoot.querySelector('.tab-title');
74
- // if the tab has an "aria-controls" attribute it was already linked to its panel: do nothing
75
- if (tabTitle.getAttribute('aria-controls'))
76
- return;
77
- const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');
78
- tabTitle.setAttribute('aria-controls', tabPanel.id);
79
- tabPanel.setAttribute('aria-labelledby', tabTitle.id);
80
- tab.addEventListener('click', () => {
81
- void this.show(tab.panel);
82
- });
83
- tab.addEventListener('keydown', ({ key }) => {
84
- if (key === 'ArrowRight' || key === 'ArrowLeft')
85
- this.navigateTabs(tab, key);
86
- });
87
- });
88
- // if the currently active tab was removed from the DOM then select the first one
89
- if (this.activeTab && !this.activeTab.isConnected) {
90
- void this.show(this.tabs.item(0).panel);
91
- }
92
- }
93
- activateTab(tab) {
94
- if (this.activeTab) {
95
- const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');
96
- tabTitle.setAttribute('aria-selected', 'false');
97
- tabTitle.setAttribute('tabindex', '-1');
98
- tabTitle.classList.remove('active');
99
- }
100
- const tabTitle = tab.shadowRoot.querySelector('.tab-title');
101
- tabTitle.setAttribute('aria-selected', 'true');
102
- tabTitle.removeAttribute('tabindex');
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
- navigateTabs(tab, key) {
131
- const activeTabIndex = Array.from(this.tabs).indexOf(tab);
132
- let nextTab;
133
- if (key === 'ArrowRight') {
134
- nextTab = this.tabs[activeTabIndex + 1] || this.tabs[0];
135
- }
136
- else {
137
- nextTab = this.tabs[activeTabIndex - 1] || this.tabs[this.tabs.length - 1];
138
- }
139
- if (!nextTab)
140
- return;
141
- const nextTabTitle = nextTab.shadowRoot.querySelector('.tab-title');
142
- nextTabTitle.focus();
143
- }
144
- render() {
145
- return (h(Host, { "data-version": version }, h("div", { class: "tabs-wrapper" }, h("div", { class: "tabs", role: "tablist" }, h("slot", { name: "tabs", onSlotchange: () => this.enableTabs() }))), h("div", { class: "tab-content" }, h("slot", { onSlotchange: () => this.moveMisplacedTabs() }))));
146
- }
147
- get host() { return this; }
148
- static get style() { return postTabsCss; }
149
- }, [1, "post-tabs", {
150
- "activePanel": [1, "active-panel"],
151
- "show": [64]
152
- }]);
153
- function defineCustomElement$1() {
154
- if (typeof customElements === "undefined") {
155
- return;
156
- }
157
- const components = ["post-tabs"];
158
- components.forEach(tagName => { switch (tagName) {
159
- case "post-tabs":
160
- if (!customElements.get(tagName)) {
161
- customElements.define(tagName, PostTabs$1);
162
- }
163
- break;
164
- } });
165
- }
1
+ import { P as PostTabs$1, d as defineCustomElement$1 } from './post-tabs2.js';
166
2
 
167
3
  const PostTabs = PostTabs$1;
168
4
  const defineCustomElement = defineCustomElement$1;
@@ -1 +1 @@
1
- {"file":"post-tabs.js","mappings":";;;;AAAA,MAAM,WAAW,GAAG,yzDAAyzD;;MCSh0DA,UAAQ;;;;;;IAIX,aAAQ,GAAG,KAAK,CAAC;;;EAEzB,IAAY,IAAI;IACd,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;GACtD;EAkBD,gBAAgB;IACd,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACzB,IAAI,CAAC,UAAU,EAAE,CAAC;IAElB,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;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,GAAI,CAClD,CACD,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["PostTabs"],"sources":["src/components/post-tabs/post-tabs.scss?tag=post-tabs&encapsulation=shadow","src/components/post-tabs/post-tabs.tsx"],"sourcesContent":["@use '@swisspost/design-system-styles/components/tabs/tabs-wrapper';\n\n:host {\n display: block;\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, 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 void 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(\n `post-tab-header[panel=${panelName}]`,\n );\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\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', () => {\n void this.show(tab.panel);\n });\n\n tab.addEventListener('keydown', ({ key }) => {\n if (key === 'ArrowRight' || key === 'ArrowLeft') this.navigateTabs(tab, key);\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 void 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.setAttribute('tabindex', '-1');\n tabTitle.classList.remove('active');\n }\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'true');\n tabTitle.removeAttribute('tabindex');\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(`post-tab-panel[name=${name}]`);\n }\n\n private navigateTabs(tab: HTMLPostTabHeaderElement, key: 'ArrowRight' | 'ArrowLeft') {\n const activeTabIndex = Array.from(this.tabs).indexOf(tab);\n\n let nextTab: HTMLPostTabHeaderElement;\n if (key === 'ArrowRight') {\n nextTab = this.tabs[activeTabIndex + 1] || this.tabs[0];\n } else {\n nextTab = this.tabs[activeTabIndex - 1] || this.tabs[this.tabs.length - 1];\n }\n\n if (!nextTab) return;\n\n const nextTabTitle = nextTab.shadowRoot.querySelector('.tab-title') as HTMLAnchorElement;\n nextTabTitle.focus();\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div class=\"tabs-wrapper\">\n <div class=\"tabs\" role=\"tablist\">\n <slot name=\"tabs\" onSlotchange={() => this.enableTabs()} />\n </div>\n </div>\n <div class=\"tab-content\">\n <slot onSlotchange={() => this.moveMisplacedTabs()} />\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
1
+ {"file":"post-tabs.js","mappings":";;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -0,0 +1,169 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { v as version } from './package.js';
3
+ import { f as fadeOut, a as fadeIn } from './fade.js';
4
+
5
+ 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:#ccc}.tabs-wrapper .tabs{background-color:rgba(0,0,0,0) !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:#333}.bg-primary .tabs-wrapper{background-color:#333}.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}";
6
+
7
+ const PostTabs = /*@__PURE__*/ proxyCustomElement(class PostTabs extends HTMLElement {
8
+ constructor() {
9
+ super();
10
+ this.__registerHost();
11
+ this.__attachShadow();
12
+ this.tabChange = createEvent(this, "tabChange", 7);
13
+ this.isLoaded = false;
14
+ this.activePanel = undefined;
15
+ }
16
+ get tabs() {
17
+ return this.host.querySelectorAll('post-tab-header');
18
+ }
19
+ componentDidLoad() {
20
+ this.moveMisplacedTabs();
21
+ this.enableTabs();
22
+ const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;
23
+ void this.show(initiallyActivePanel);
24
+ this.isLoaded = true;
25
+ }
26
+ /**
27
+ * Shows the panel with the given name and selects its associated tab.
28
+ * Any other panel that was previously shown becomes hidden and its associated tab is unselected.
29
+ */
30
+ async show(panelName) {
31
+ var _a;
32
+ // do nothing if the tab is already active
33
+ if (panelName === ((_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.panel)) {
34
+ return;
35
+ }
36
+ const previousTab = this.activeTab;
37
+ const newTab = this.host.querySelector(`post-tab-header[panel=${panelName}]`);
38
+ this.activateTab(newTab);
39
+ // if a panel is currently being displayed, remove it from the view and complete the associated animation
40
+ if (this.showing) {
41
+ this.showing.effect['target'].style.display = 'none';
42
+ this.showing.finish();
43
+ }
44
+ // hide the currently visible panel only if no other animation is running
45
+ if (previousTab && !this.showing && !this.hiding) {
46
+ this.hidePanel(previousTab.panel);
47
+ }
48
+ // wait for any hiding animation to complete before showing the selected tab
49
+ if (this.hiding) {
50
+ await this.hiding.finished;
51
+ }
52
+ this.showSelectedPanel();
53
+ // wait for any display animation to complete for the returned promise to fully resolve
54
+ if (this.showing) {
55
+ await this.showing.finished;
56
+ }
57
+ this.tabChange.emit(this.activeTab.panel);
58
+ }
59
+ moveMisplacedTabs() {
60
+ if (!this.tabs)
61
+ return;
62
+ this.tabs.forEach(tab => {
63
+ if (tab.getAttribute('slot') === 'tabs')
64
+ return;
65
+ tab.setAttribute('slot', 'tabs');
66
+ });
67
+ }
68
+ enableTabs() {
69
+ if (!this.tabs)
70
+ return;
71
+ this.tabs.forEach(async (tab) => {
72
+ await tab.componentOnReady();
73
+ const tabTitle = tab.shadowRoot.querySelector('.tab-title');
74
+ // if the tab has an "aria-controls" attribute it was already linked to its panel: do nothing
75
+ if (tabTitle.getAttribute('aria-controls'))
76
+ return;
77
+ const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');
78
+ tabTitle.setAttribute('aria-controls', tabPanel.id);
79
+ tabPanel.setAttribute('aria-labelledby', tabTitle.id);
80
+ tab.addEventListener('click', () => {
81
+ void this.show(tab.panel);
82
+ });
83
+ tab.addEventListener('keydown', ({ key }) => {
84
+ if (key === 'ArrowRight' || key === 'ArrowLeft')
85
+ this.navigateTabs(tab, key);
86
+ });
87
+ });
88
+ // if the currently active tab was removed from the DOM then select the first one
89
+ if (this.activeTab && !this.activeTab.isConnected) {
90
+ void this.show(this.tabs.item(0).panel);
91
+ }
92
+ }
93
+ activateTab(tab) {
94
+ if (this.activeTab) {
95
+ const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');
96
+ tabTitle.setAttribute('aria-selected', 'false');
97
+ tabTitle.setAttribute('tabindex', '-1');
98
+ tabTitle.classList.remove('active');
99
+ }
100
+ const tabTitle = tab.shadowRoot.querySelector('.tab-title');
101
+ tabTitle.setAttribute('aria-selected', 'true');
102
+ tabTitle.removeAttribute('tabindex');
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
+ navigateTabs(tab, key) {
131
+ const activeTabIndex = Array.from(this.tabs).indexOf(tab);
132
+ let nextTab;
133
+ if (key === 'ArrowRight') {
134
+ nextTab = this.tabs[activeTabIndex + 1] || this.tabs[0];
135
+ }
136
+ else {
137
+ nextTab = this.tabs[activeTabIndex - 1] || this.tabs[this.tabs.length - 1];
138
+ }
139
+ if (!nextTab)
140
+ return;
141
+ const nextTabTitle = nextTab.shadowRoot.querySelector('.tab-title');
142
+ nextTabTitle.focus();
143
+ }
144
+ render() {
145
+ return (h(Host, { "data-version": version }, h("div", { class: "tabs-wrapper" }, h("div", { class: "tabs", role: "tablist" }, h("slot", { name: "tabs", onSlotchange: () => this.enableTabs() }))), h("div", { class: "tab-content" }, h("slot", { onSlotchange: () => this.moveMisplacedTabs() }))));
146
+ }
147
+ get host() { return this; }
148
+ static get style() { return postTabsCss; }
149
+ }, [1, "post-tabs", {
150
+ "activePanel": [1, "active-panel"],
151
+ "show": [64]
152
+ }]);
153
+ function defineCustomElement() {
154
+ if (typeof customElements === "undefined") {
155
+ return;
156
+ }
157
+ const components = ["post-tabs"];
158
+ components.forEach(tagName => { switch (tagName) {
159
+ case "post-tabs":
160
+ if (!customElements.get(tagName)) {
161
+ customElements.define(tagName, PostTabs);
162
+ }
163
+ break;
164
+ } });
165
+ }
166
+
167
+ export { PostTabs as P, defineCustomElement as d };
168
+
169
+ //# sourceMappingURL=post-tabs2.js.map
@@ -0,0 +1 @@
1
+ {"file":"post-tabs2.js","mappings":";;;;AAAA,MAAM,WAAW,GAAG,yzDAAyzD;;MCSh0D,QAAQ;;;;;;IAIX,aAAQ,GAAG,KAAK,CAAC;;;EAEzB,IAAY,IAAI;IACd,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;GACtD;EAkBD,gBAAgB;IACd,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACzB,IAAI,CAAC,UAAU,EAAE,CAAC;IAElB,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CA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E,MAAM,IAAI,CAAC,iBAAiB,EAAE,GAAI,CAClD,CACD,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/post-tabs/post-tabs.scss?tag=post-tabs&encapsulation=shadow","src/components/post-tabs/post-tabs.tsx"],"sourcesContent":["@use '@swisspost/design-system-styles/components/tabs/tabs-wrapper';\n\n:host {\n display: block;\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, 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 void 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(\n `post-tab-header[panel=${panelName}]`,\n );\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\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', () => {\n void this.show(tab.panel);\n });\n\n tab.addEventListener('keydown', ({ key }) => {\n if (key === 'ArrowRight' || key === 'ArrowLeft') this.navigateTabs(tab, key);\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 void 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.setAttribute('tabindex', '-1');\n tabTitle.classList.remove('active');\n }\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'true');\n tabTitle.removeAttribute('tabindex');\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(`post-tab-panel[name=${name}]`);\n }\n\n private navigateTabs(tab: HTMLPostTabHeaderElement, key: 'ArrowRight' | 'ArrowLeft') {\n const activeTabIndex = Array.from(this.tabs).indexOf(tab);\n\n let nextTab: HTMLPostTabHeaderElement;\n if (key === 'ArrowRight') {\n nextTab = this.tabs[activeTabIndex + 1] || this.tabs[0];\n } else {\n nextTab = this.tabs[activeTabIndex - 1] || this.tabs[this.tabs.length - 1];\n }\n\n if (!nextTab) return;\n\n const nextTabTitle = nextTab.shadowRoot.querySelector('.tab-title') as HTMLAnchorElement;\n nextTabTitle.focus();\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div class=\"tabs-wrapper\">\n <div class=\"tabs\" role=\"tablist\">\n <slot name=\"tabs\" onSlotchange={() => this.enableTabs()} />\n </div>\n </div>\n <div class=\"tab-content\">\n <slot onSlotchange={() => this.moveMisplacedTabs()} />\n </div>\n </Host>\n );\n }\n}\n"],"version":3}