@swisspost/design-system-components 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +0 -26
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/package-bd70f73c.js +7 -0
- package/dist/cjs/package-bd70f73c.js.map +1 -0
- package/dist/cjs/post-accordion.cjs.entry.js +1 -1
- package/dist/cjs/post-alert.cjs.entry.js +94 -7
- package/dist/cjs/post-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/post-collapsible.cjs.entry.js +86 -5
- package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
- package/dist/cjs/post-icon.cjs.entry.js +98 -6
- package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tab-header.cjs.entry.js +26 -5
- package/dist/cjs/post-tab-header.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tab-panel.cjs.entry.js +20 -4
- package/dist/cjs/post-tab-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tabs.cjs.entry.js +146 -5
- package/dist/cjs/post-tabs.cjs.entry.js.map +1 -1
- package/dist/cjs/post-tooltip.cjs.entry.js +5088 -5
- package/dist/cjs/post-tooltip.cjs.entry.js.map +1 -1
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/index.js +1 -8
- package/dist/collection/index.js.map +1 -1
- package/dist/components/index.js +0 -7
- package/dist/components/index.js.map +1 -1
- package/dist/components/package.js +1 -1
- package/dist/components/post-alert.js +134 -1
- package/dist/components/post-alert.js.map +1 -1
- package/dist/components/post-collapsible.js +113 -1
- package/dist/components/post-collapsible.js.map +1 -1
- package/dist/components/post-tab-header.js +47 -1
- package/dist/components/post-tab-header.js.map +1 -1
- package/dist/components/post-tab-panel.js +39 -1
- package/dist/components/post-tab-panel.js.map +1 -1
- package/dist/components/post-tabs.js +165 -1
- package/dist/components/post-tabs.js.map +1 -1
- package/dist/components/post-tooltip.js +5113 -1
- package/dist/components/post-tooltip.js.map +1 -1
- package/dist/docs.json +1 -1
- package/dist/esm/index.js +1 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package-f3f12016.js +5 -0
- package/dist/esm/package-f3f12016.js.map +1 -0
- package/dist/esm/post-accordion.entry.js +1 -1
- package/dist/esm/post-alert.entry.js +97 -6
- package/dist/esm/post-alert.entry.js.map +1 -1
- package/dist/esm/post-collapsible.entry.js +89 -4
- package/dist/esm/post-collapsible.entry.js.map +1 -1
- package/dist/esm/post-icon.entry.js +101 -5
- package/dist/esm/post-icon.entry.js.map +1 -1
- package/dist/esm/post-tab-header.entry.js +29 -4
- package/dist/esm/post-tab-header.entry.js.map +1 -1
- package/dist/esm/post-tab-panel.entry.js +23 -3
- package/dist/esm/post-tab-panel.entry.js.map +1 -1
- package/dist/esm/post-tabs.entry.js +149 -4
- package/dist/esm/post-tabs.entry.js.map +1 -1
- package/dist/esm/post-tooltip.entry.js +5091 -4
- package/dist/esm/post-tooltip.entry.js.map +1 -1
- package/dist/post-components/index.esm.js +1 -1
- package/dist/post-components/p-08d942a0.entry.js +2 -0
- package/dist/post-components/{p-332eef46.js.map → p-08d942a0.entry.js.map} +1 -1
- package/dist/{esm/post-alert-5dd43c8b.js → post-components/p-10c47e0a.entry.js} +2 -99
- package/dist/post-components/{p-c6b73d6e.js.map → p-10c47e0a.entry.js.map} +1 -1
- package/dist/post-components/{p-1a8a8ef2.js → p-2755ba2e.entry.js} +2 -2
- package/dist/post-components/p-4aae941f.js +2 -0
- package/dist/post-components/{p-e9dc9039.entry.js → p-6a0a1ce4.entry.js} +2 -2
- package/dist/post-components/p-7d91397a.entry.js +2 -0
- package/dist/post-components/p-871ade93.entry.js +2 -0
- package/dist/post-components/{p-574acdb0.js.map → p-871ade93.entry.js.map} +1 -1
- package/dist/post-components/p-a18e1d1c.entry.js +2 -0
- package/dist/post-components/{p-97000cb6.js.map → p-a18e1d1c.entry.js.map} +1 -1
- package/dist/post-components/{p-01e8dfe6.js → p-b4b7e30c.entry.js} +3 -3
- package/dist/post-components/post-components.esm.js +1 -1
- package/dist/types/index.d.ts +0 -7
- package/package.json +4 -4
- package/dist/cjs/package-7c4db872.js +0 -7
- package/dist/cjs/package-7c4db872.js.map +0 -1
- package/dist/cjs/post-alert-c037e6a3.js +0 -101
- package/dist/cjs/post-alert-c037e6a3.js.map +0 -1
- package/dist/cjs/post-collapsible-7c9d23a2.js +0 -93
- package/dist/cjs/post-collapsible-7c9d23a2.js.map +0 -1
- package/dist/cjs/post-icon-f418f76a.js +0 -105
- package/dist/cjs/post-icon-f418f76a.js.map +0 -1
- package/dist/cjs/post-tab-header-e08c2a42.js +0 -33
- package/dist/cjs/post-tab-header-e08c2a42.js.map +0 -1
- package/dist/cjs/post-tab-panel-721f7f32.js +0 -27
- package/dist/cjs/post-tab-panel-721f7f32.js.map +0 -1
- package/dist/cjs/post-tabs-4bcc867b.js +0 -153
- package/dist/cjs/post-tabs-4bcc867b.js.map +0 -1
- package/dist/cjs/post-tooltip-261c5cda.js +0 -5095
- package/dist/cjs/post-tooltip-261c5cda.js.map +0 -1
- package/dist/components/post-alert2.js +0 -138
- package/dist/components/post-alert2.js.map +0 -1
- package/dist/components/post-collapsible2.js +0 -117
- package/dist/components/post-collapsible2.js.map +0 -1
- package/dist/components/post-tab-header2.js +0 -51
- package/dist/components/post-tab-header2.js.map +0 -1
- package/dist/components/post-tab-panel2.js +0 -43
- package/dist/components/post-tab-panel2.js.map +0 -1
- package/dist/components/post-tabs2.js +0 -169
- package/dist/components/post-tabs2.js.map +0 -1
- package/dist/components/post-tooltip2.js +0 -5117
- package/dist/components/post-tooltip2.js.map +0 -1
- package/dist/esm/package-3bbdb32c.js +0 -5
- package/dist/esm/package-3bbdb32c.js.map +0 -1
- package/dist/esm/post-alert-5dd43c8b.js.map +0 -1
- package/dist/esm/post-collapsible-26dc2340.js +0 -91
- package/dist/esm/post-collapsible-26dc2340.js.map +0 -1
- package/dist/esm/post-icon-fb0eb8aa.js +0 -103
- package/dist/esm/post-icon-fb0eb8aa.js.map +0 -1
- package/dist/esm/post-tab-header-deebc551.js +0 -31
- package/dist/esm/post-tab-header-deebc551.js.map +0 -1
- package/dist/esm/post-tab-panel-4b820f71.js +0 -25
- package/dist/esm/post-tab-panel-4b820f71.js.map +0 -1
- package/dist/esm/post-tabs-2d8d6a33.js +0 -151
- package/dist/esm/post-tabs-2d8d6a33.js.map +0 -1
- package/dist/esm/post-tooltip-811309c5.js +0 -5093
- package/dist/esm/post-tooltip-811309c5.js.map +0 -1
- package/dist/post-components/p-0a49c1a3.entry.js +0 -2
- package/dist/post-components/p-27092ac3.entry.js +0 -2
- package/dist/post-components/p-27092ac3.entry.js.map +0 -1
- package/dist/post-components/p-332eef46.js +0 -2
- package/dist/post-components/p-541142fd.js +0 -2
- package/dist/post-components/p-541142fd.js.map +0 -1
- package/dist/post-components/p-574acdb0.js +0 -2
- package/dist/post-components/p-66460e3f.entry.js +0 -2
- package/dist/post-components/p-66460e3f.entry.js.map +0 -1
- package/dist/post-components/p-810ee105.entry.js +0 -2
- package/dist/post-components/p-810ee105.entry.js.map +0 -1
- package/dist/post-components/p-939df031.entry.js +0 -2
- package/dist/post-components/p-939df031.entry.js.map +0 -1
- package/dist/post-components/p-94b3f291.entry.js +0 -2
- package/dist/post-components/p-94b3f291.entry.js.map +0 -1
- package/dist/post-components/p-97000cb6.js +0 -2
- package/dist/post-components/p-abd149b3.entry.js +0 -2
- package/dist/post-components/p-abd149b3.entry.js.map +0 -1
- package/dist/post-components/p-c6b73d6e.js +0 -2
- package/dist/post-components/p-d4fb9f16.js +0 -2
- /package/dist/post-components/{p-1a8a8ef2.js.map → p-2755ba2e.entry.js.map} +0 -0
- /package/dist/post-components/{p-0a49c1a3.entry.js.map → p-4aae941f.js.map} +0 -0
- /package/dist/post-components/{p-e9dc9039.entry.js.map → p-6a0a1ce4.entry.js.map} +0 -0
- /package/dist/post-components/{p-d4fb9f16.js.map → p-7d91397a.entry.js.map} +0 -0
- /package/dist/post-components/{p-01e8dfe6.js.map → p-b4b7e30c.entry.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"package-3bbdb32c.js","mappings":";;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"post-alert-5dd43c8b.js","mappings":";;;;;;AAAO,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAU;;ACA/F,MAAM,YAAY,GAAG,2/lBAA2/lB;;MCWngmB,SAAS;;;;mBAGD,MAAM,CAAC,UAAU,EAAE;;;;gCAIN,MAAM,IAAI,CAAC,OAAO,EAAE;uBAKZ,KAAK;;iBAuBX,KAAK;;gBAsBJ,SAAS;;EA1C5C,mBAAmB,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW;IAClD,SAAS,CAAC,aAAa,EAAE,SAAS,EAAE,wDAAwD,CAAC,CAAC;IAC9F,UAAU,CAAC,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;GAC/C;EAQD,oBAAoB,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY;IACnD,IAAI,IAAI,CAAC,WAAW,EAAE;MACpB,aAAa,CAAC,YAAY,EAAE,2DAA2D,CAAC,CAAC;KAC1F;GACF;EAQD,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK;IAChC,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,kDAAkD,CAAC,CAAC;GACnF;EAUD,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI;IAC3B,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,yDAAyD,CAAC,CAAC;GACpG;EAQD,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI;IAC3B,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,wCAAwC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE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AClB,CACP;MACD,YAAM,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,UAAU,GAAG;KACxC,CAAC;IAEF,MAAM,kBAAkB,GAAG;MACzB,WAAK,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,UAAU,EAAE,KAAK,EAAC,eAAe,IACvD,mBAAmB,CAChB;MACN,WAAK,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,UAAU,EAAE,KAAK,EAAC,eAAe,IACxD,YAAM,IAAI,EAAC,SAAS,GAAE,CAClB;KACP,CAAC;IAEF,QACE,EAAC,IAAI,oBAAe,OAAO,IACzB,WAAK,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,IAClC,IAAI,CAAC,WAAW,KACf,cAAQ,KAAK,EAAC,WAAW,EAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,IAC1D,YAAM,KAAK,EAAC,iBAAiB,IAAE,IAAI,CAAC,YAAY,CAAQ,CACjD,CACV,EAEA,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,KAChC,iBAAW,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAI,CAC5D,EAEA,IAAI,CAAC,UAAU;QACZ,kBAAkB;QAClB,mBAAmB,CAEnB,CACD,EACP;GACH;;;;;;;;;;;;;;","names":[],"sources":["src/components/post-alert/alert-types.ts","src/components/post-alert/post-alert.scss?tag=post-alert&encapsulation=shadow","src/components/post-alert/post-alert.tsx"],"sourcesContent":["export const ALERT_TYPES = ['primary', 'success', 'danger', 'warning', 'info', 'gray'] as const;\n\nexport type AlertType = typeof ALERT_TYPES[number];\n","@use '@swisspost/design-system-styles/components/alert';\n@use '@swisspost/design-system-styles/components/close';\n@use '@swisspost/design-system-styles/core' as post;\n\n:host {\n display: block;\n\n ::slotted(*) {\n margin: 0 !important;\n }\n}\n\n.visually-hidden {\n @include post.visually-hidden();\n}\n\n@for $i from 1 through 6 {\n .alert-heading > ::slotted(h#{$i}) {\n font-size: inherit !important;\n font-weight: inherit !important;\n }\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { fadeOut } from '../../animations';\nimport { checkEmptyOrOneOf, checkEmptyOrPattern, checkNonEmpty, checkType } from '../../utils';\nimport { ALERT_TYPES, AlertType } from './alert-types';\n\n@Component({\n tag: 'post-alert',\n styleUrl: 'post-alert.scss',\n shadow: true,\n})\nexport class PostAlert {\n @Element() host: HTMLPostAlertElement;\n\n @State() alertId = crypto.randomUUID();\n @State() classes: string;\n @State() hasActions: boolean;\n @State() hasHeading: boolean;\n @State() onDismissButtonClick = () => this.dismiss();\n\n /**\n * If `true`, a close button (×) is displayed and the alert can be dismissed by the user.\n */\n @Prop() readonly dismissible: boolean = false;\n\n @Watch('dismissible')\n validateDismissible(isDismissible = this.dismissible) {\n checkType(isDismissible, 'boolean', 'The post-alert \"dismissible\" prop should be a boolean.');\n setTimeout(() => this.validateDismissLabel());\n }\n\n /**\n * The label to use for the close button of a dismissible alert.\n */\n @Prop() readonly dismissLabel: string;\n\n @Watch('dismissLabel')\n validateDismissLabel(dismissLabel = this.dismissLabel) {\n if (this.dismissible) {\n checkNonEmpty(dismissLabel, 'Dismissible post-alert\\'s require a \"dismiss-label\" prop.');\n }\n }\n\n /**\n * If `true`, the alert is positioned at the bottom of the window, from edge to edge.\n */\n @Prop() readonly fixed: boolean = false;\n\n @Watch('fixed')\n validateFixed(isFixed = this.fixed) {\n checkType(isFixed, 'boolean', 'The post-alert \"fixed\" prop should be a boolean.');\n }\n\n /**\n * The icon to display in the alert. By default, the icon depends on the alert type.\n *\n * If `none`, no icon is displayed.\n */\n @Prop() readonly icon: string;\n\n @Watch('icon')\n validateIcon(icon = this.icon) {\n checkEmptyOrPattern(icon, /\\d{4}|none/, 'The post-alert \"icon\" prop should be a 4-digits string.');\n }\n\n /**\n * The type of the alert.\n */\n @Prop() readonly type: AlertType = 'primary';\n\n @Watch('type')\n validateType(type = this.type) {\n checkEmptyOrOneOf(type, ALERT_TYPES, `The post-alert requires a type form: ${ALERT_TYPES.join(', ')}`);\n }\n\n /**\n * An event emitted when the alert element is dismissed, after the transition.\n * It has no payload and only relevant for dismissible alerts.\n */\n @Event() dismissed: EventEmitter<void>;\n\n connectedCallback() {\n this.validateDismissible();\n this.validateFixed();\n this.validateIcon();\n this.validateType();\n }\n\n componentWillRender() {\n this.hasHeading = this.host.querySelectorAll('[slot=heading]').length > 0;\n this.hasActions = this.host.querySelectorAll('[slot=actions]').length > 0;\n\n this.classes = `alert alert-${this.type ?? 'primary'}`;\n if (this.dismissible) this.classes += ' alert-dismissible';\n if (this.hasActions) this.classes += ' alert-action';\n if (this.fixed) this.classes += ' alert-fixed-bottom';\n if (this.icon === 'none') this.classes += ' no-icon';\n }\n\n /**\n * Triggers alert dismissal programmatically (same as clicking on the close button (×)).\n */\n @Method()\n async dismiss() {\n const dismissal = fadeOut(this.host);\n\n await dismissal.finished;\n\n this.host.remove();\n this.dismissed.emit();\n }\n\n render() {\n const defaultAlertContent = [\n this.hasHeading && (\n <div key={`${this.alertId}-heading`} class=\"alert-heading\">\n <slot name=\"heading\"/>\n </div>\n ),\n <slot key={`${this.alertId}-message`}/>\n ];\n\n const actionAlertContent = [\n <div key={`${this.alertId}-content`} class=\"alert-content\">\n {defaultAlertContent}\n </div>,\n <div key={`${this.alertId}-buttons`} class=\"alert-buttons\">\n <slot name=\"actions\"/>\n </div>,\n ];\n\n return (\n <Host data-version={version}>\n <div role=\"alert\" class={this.classes}>\n {this.dismissible && (\n <button class=\"btn-close\" onClick={this.onDismissButtonClick}>\n <span class=\"visually-hidden\">{this.dismissLabel}</span>\n </button>\n )}\n\n {this.icon && this.icon !== 'none' && (\n <post-icon key={`${this.alertId}-icon`} name={this.icon} />\n )}\n\n {this.hasActions\n ? actionAlertContent\n : defaultAlertContent\n }\n </div>\n </Host>\n );\n }\n\n}\n"],"version":3}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-4eff5fc5.js';
|
|
2
|
-
import { v as version } from './package-3bbdb32c.js';
|
|
3
|
-
import { d as checkEmptyOrType, b as checkEmptyOrOneOf } from './index-35921354.js';
|
|
4
|
-
|
|
5
|
-
function isMotionReduced() {
|
|
6
|
-
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const collapseDuration = 350;
|
|
10
|
-
const collapseEasing = 'ease';
|
|
11
|
-
const collapsedKeyframe = { height: '0', overflow: 'hidden' };
|
|
12
|
-
const collapse = (el) => {
|
|
13
|
-
const { height } = window.getComputedStyle(el);
|
|
14
|
-
const expandedKeyframe = { height };
|
|
15
|
-
return el.animate([expandedKeyframe, collapsedKeyframe], { duration: collapseDuration, easing: collapseEasing, fill: 'forwards' });
|
|
16
|
-
};
|
|
17
|
-
const expand = (el) => {
|
|
18
|
-
const expandedKeyframe = { height: `${el.scrollHeight}px` };
|
|
19
|
-
return el.animate([collapsedKeyframe, expandedKeyframe], { duration: collapseDuration, easing: collapseEasing, fill: 'forwards' });
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const HEADING_LEVELS = [1, 2, 3, 4, 5, 6];
|
|
23
|
-
|
|
24
|
-
const postCollapsibleCss = ".accordion-item{border-block-start:2px solid #e6e6e6}.accordion-header{font-size:1.0625rem;font-weight:700;line-height:1.5;margin:0}@media (min-width: 1024px){.accordion-header{font-size:1.25rem}}.accordion-button{padding:0;overflow:visible;border:0;background:none;color:inherit;font:inherit;-webkit-user-select:none;user-select:none;-webkit-appearance:button;appearance:button;width:100%;position:relative;padding-block:1rem;padding-inline-start:1rem;padding-inline-end:2.5rem;text-align:start}.accordion-button:not(:disabled){cursor:pointer}.accordion-button:disabled{opacity:.4}.accordion-button:focus{outline:none;box-shadow:0 0 0 .125rem rgba(51,51,51,.25)}.accordion-button::after{-webkit-mask-image:url(\"data:image/svg+xml,%3Csvg xml:space='preserve' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='icon'%3E%3Cpath d='m23.6 18.3-.9.9-6.7-6.6-6.6 6.6-.9-.9 7.5-7.6 7.6 7.6z'/%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3Csvg xml:space='preserve' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='icon'%3E%3Cpath d='m23.6 18.3-.9.9-6.7-6.6-6.6 6.6-.9-.9 7.5-7.6 7.6 7.6z'/%3E%3C/g%3E%3C/svg%3E\");background-color:currentColor;content:\"\";display:block;height:1.5rem;width:1.5rem;position:absolute;inset-inline-end:1rem;inset-block-start:50%;transform:translateY(-50%);transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1);border:1px solid rgb(var(--post-bg-rgb, 255, 255, 255))}.accordion-button.collapsed::after{transform:translateY(-50%) rotate(-180deg)}.accordion-button>.text-truncate{display:block}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.accordion-button:hover:not(:disabled),.accordion-button:focus-visible:not(:disabled){outline:2px solid Highlight}.accordion-button:disabled{opacity:1 !important}}.accordion-body{padding:.75rem 1rem 2.5rem;border-block-start:2px solid #e6e6e6}.accordion-body h1,.accordion-body .h1{font-size:1.0625rem;margin:2.5rem 0 0;font-weight:700}@media (min-width: 1024px){.accordion-body h1,.accordion-body .h1{font-size:1.25rem}}.accordion-body h2,.accordion-body .h2{font-size:1.0625rem;margin:2.5rem 0 0;font-weight:700}@media (min-width: 1024px){.accordion-body h2,.accordion-body .h2{font-size:1.25rem}}.accordion-body h3,.accordion-body .h3{font-size:1.0625rem;margin:2.5rem 0 0;font-weight:700}@media (min-width: 1024px){.accordion-body h3,.accordion-body .h3{font-size:1.25rem}}.accordion-body h4,.accordion-body .h4{font-size:1.0625rem;margin:2.5rem 0 0;font-weight:700}@media (min-width: 1024px){.accordion-body h4,.accordion-body .h4{font-size:1.25rem}}.accordion-body h5,.accordion-body .h5{font-size:1.0625rem;margin:2.5rem 0 0;font-weight:700}@media (min-width: 1024px){.accordion-body h5,.accordion-body .h5{font-size:1.25rem}}.accordion-body h6,.accordion-body .h6{font-size:1.0625rem;margin:2.5rem 0 0;font-weight:700}@media (min-width: 1024px){.accordion-body h6,.accordion-body .h6{font-size:1.25rem}}.accordion-button>:first-child,.accordion-body>:first-child{margin-block-start:0 !important}.accordion-button>:last-child,.accordion-body>:last-child{margin-block-end:0 !important}:host{display:block}:host .accordion-button>::slotted(.text-truncate){display:block}";
|
|
25
|
-
|
|
26
|
-
const PostCollapsible = class {
|
|
27
|
-
constructor(hostRef) {
|
|
28
|
-
registerInstance(this, hostRef);
|
|
29
|
-
this.collapseChange = createEvent(this, "collapseChange", 7);
|
|
30
|
-
this.isLoaded = false;
|
|
31
|
-
this.id = undefined;
|
|
32
|
-
this.isOpen = true;
|
|
33
|
-
this.hasHeader = undefined;
|
|
34
|
-
this.headingTag = undefined;
|
|
35
|
-
this.collapsed = false;
|
|
36
|
-
this.headingLevel = 2;
|
|
37
|
-
}
|
|
38
|
-
validateCollapsed(newValue = this.collapsed) {
|
|
39
|
-
checkEmptyOrType(newValue, 'boolean', 'The `collapsed` property of the `post-collapsible` must be a boolean.');
|
|
40
|
-
}
|
|
41
|
-
validateHeadingLevel(newValue = this.headingLevel) {
|
|
42
|
-
checkEmptyOrOneOf(newValue, HEADING_LEVELS, 'The `headingLevel` property of the `post-collapsible` must be a number between 1 and 6.');
|
|
43
|
-
}
|
|
44
|
-
connectedCallback() {
|
|
45
|
-
this.validateCollapsed();
|
|
46
|
-
this.validateHeadingLevel();
|
|
47
|
-
}
|
|
48
|
-
componentWillRender() {
|
|
49
|
-
var _a;
|
|
50
|
-
this.id = this.host.id || `c${crypto.randomUUID()}`;
|
|
51
|
-
this.hasHeader = this.host.querySelectorAll('[slot="header"]').length > 0;
|
|
52
|
-
this.headingTag = `h${(_a = this.headingLevel) !== null && _a !== void 0 ? _a : 2}`;
|
|
53
|
-
}
|
|
54
|
-
componentDidLoad() {
|
|
55
|
-
if (this.collapsed)
|
|
56
|
-
void this.toggle(false);
|
|
57
|
-
this.isLoaded = true;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Triggers the collapse programmatically.
|
|
61
|
-
*
|
|
62
|
-
* If there is a collapsing transition running already, it will be reversed.
|
|
63
|
-
*/
|
|
64
|
-
async toggle(open = !this.isOpen) {
|
|
65
|
-
if (open === this.isOpen)
|
|
66
|
-
return open;
|
|
67
|
-
this.isOpen = !this.isOpen;
|
|
68
|
-
if (this.isLoaded)
|
|
69
|
-
this.collapseChange.emit();
|
|
70
|
-
const animation = open ? expand(this.collapsible) : collapse(this.collapsible);
|
|
71
|
-
if (!this.isLoaded || isMotionReduced())
|
|
72
|
-
animation.finish();
|
|
73
|
-
await animation.finished;
|
|
74
|
-
animation.commitStyles();
|
|
75
|
-
return this.isOpen;
|
|
76
|
-
}
|
|
77
|
-
render() {
|
|
78
|
-
const collapse = (h("div", { "aria-labelledby": this.hasHeader ? `${this.id}--header` : undefined, class: `collapse${this.hasHeader ? ' accordion-collapse' : ''}`, id: `${this.id}--collapse`, ref: el => this.collapsible = el }, this.hasHeader ? (h("div", { class: "accordion-body" }, h("slot", null))) : (h("slot", null))));
|
|
79
|
-
return (h(Host, { id: this.id, "data-version": version }, this.hasHeader ? (h("div", { class: "accordion-item" }, h(this.headingTag, { class: "accordion-header", id: `${this.id}--header` }, h("button", { "aria-controls": `${this.id}--collapse`, "aria-expanded": `${this.isOpen}`, class: `accordion-button${this.isOpen ? '' : ' collapsed'}`, onClick: () => this.toggle(), type: "button" }, h("slot", { name: "header" }))), collapse)) : collapse));
|
|
80
|
-
}
|
|
81
|
-
get host() { return getElement(this); }
|
|
82
|
-
static get watchers() { return {
|
|
83
|
-
"collapsed": ["validateCollapsed"],
|
|
84
|
-
"headingLevel": ["validateHeadingLevel"]
|
|
85
|
-
}; }
|
|
86
|
-
};
|
|
87
|
-
PostCollapsible.style = postCollapsibleCss;
|
|
88
|
-
|
|
89
|
-
export { PostCollapsible as P };
|
|
90
|
-
|
|
91
|
-
//# sourceMappingURL=post-collapsible-26dc2340.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"post-collapsible-26dc2340.js","mappings":";;;;SAAgB,eAAe;EAC7B,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE;;ACFA,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,iBAAiB,GAAa,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAEjE,MAAM,QAAQ,GAAG,CAAC,EAAe;EACtC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;EAC/C,MAAM,gBAAgB,GAAa,EAAE,MAAM,EAAE,CAAC;EAE9C,OAAO,EAAE,CAAC,OAAO,CACf,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,EACrC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,CACzE,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,MAAM,GAAG,CAAC,EAAe;EACpC,MAAM,gBAAgB,GAAa,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,IAAI,EAAE,CAAC;EAEtE,OAAO,EAAE,CAAC,OAAO,CACf,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,EACrC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE,CACzE,CAAC;AACJ,CAAC;;ACrBM,MAAM,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAA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b,YAAM,IAAI,EAAC,QAAQ,GAAE,CACd,CACO,EAEjB,QAAQ,CACL,IACJ,QAAQ,CACP,EACP;GACH;;;;;;;;;;;","names":[],"sources":["src/utils/is-motion-reduced.ts","src/animations/collapse.ts","src/components/post-collapsible/heading-levels.ts","src/components/post-collapsible/post-collapsible.scss?tag=post-collapsible&encapsulation=shadow","src/components/post-collapsible/post-collapsible.tsx"],"sourcesContent":["export function isMotionReduced(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n","const collapseDuration = 350;\nconst collapseEasing = 'ease';\nconst collapsedKeyframe: Keyframe = { height: '0', overflow: 'hidden' };\n\nexport const collapse = (el: HTMLElement): Animation => {\n const { height } = window.getComputedStyle(el);\n const expandedKeyframe: Keyframe = { height };\n\n return el.animate(\n [expandedKeyframe, collapsedKeyframe],\n { duration: collapseDuration, easing: collapseEasing, fill: 'forwards' },\n );\n};\n\nexport const expand = (el: HTMLElement): Animation => {\n const expandedKeyframe: Keyframe = { height: `${el.scrollHeight}px` };\n\n return el.animate(\n [collapsedKeyframe, expandedKeyframe],\n { duration: collapseDuration, easing: collapseEasing, fill: 'forwards' },\n );\n};\n","export const HEADING_LEVELS = [1, 2, 3, 4, 5, 6] as const;\n\nexport type HeadingLevel = typeof HEADING_LEVELS[number];\n","@use '@swisspost/design-system-styles/components/accordion';\n\n:host {\n display: block;\n\n .accordion-button > ::slotted(.text-truncate) {\n display: block;\n }\n}\n","import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { collapse, expand } from '../../animations/collapse';\nimport { checkEmptyOrOneOf, checkEmptyOrType, isMotionReduced } from '../../utils';\nimport { HEADING_LEVELS, HeadingLevel } from './heading-levels';\n\n@Component({\n tag: 'post-collapsible',\n styleUrl: 'post-collapsible.scss',\n shadow: true,\n})\nexport class PostCollapsible {\n private isLoaded = false;\n private collapsible: HTMLElement;\n\n @Element() host: HTMLPostCollapsibleElement;\n\n @State() id: string;\n @State() isOpen = true;\n @State() hasHeader: boolean;\n @State() headingTag: string;\n\n /**\n * If `true`, the element is initially collapsed otherwise it is displayed.\n */\n @Prop() readonly collapsed?: boolean = false;\n\n @Watch('collapsed')\n validateCollapsed(newValue = this.collapsed) {\n checkEmptyOrType(newValue, 'boolean', 'The `collapsed` property of the `post-collapsible` must be a boolean.');\n }\n\n /**\n * Defines the hierarchical level of the collapsible header within the headings structure.\n */\n @Prop() readonly headingLevel?: HeadingLevel = 2;\n\n @Watch('headingLevel')\n validateHeadingLevel(newValue = this.headingLevel) {\n checkEmptyOrOneOf(newValue, HEADING_LEVELS, 'The `headingLevel` property of the `post-collapsible` must be a number between 1 and 6.');\n }\n\n /**\n * An event emitted when the collapse element is shown or hidden, before the transition. It has no payload.\n */\n @Event() collapseChange: EventEmitter<void>;\n\n connectedCallback() {\n this.validateCollapsed();\n this.validateHeadingLevel();\n }\n\n componentWillRender() {\n this.id = this.host.id || `c${crypto.randomUUID()}`;\n this.hasHeader = this.host.querySelectorAll('[slot=\"header\"]').length > 0;\n this.headingTag = `h${this.headingLevel ?? 2}`;\n }\n\n componentDidLoad() {\n if (this.collapsed) void this.toggle(false);\n this.isLoaded = true;\n }\n\n /**\n * Triggers the collapse programmatically.\n *\n * If there is a collapsing transition running already, it will be reversed.\n */\n @Method()\n async toggle(open = !this.isOpen): Promise<boolean> {\n if (open === this.isOpen) return open;\n\n this.isOpen = !this.isOpen;\n if (this.isLoaded) this.collapseChange.emit();\n\n const animation = open ? expand(this.collapsible): collapse(this.collapsible);\n\n if (!this.isLoaded || isMotionReduced()) animation.finish();\n\n await animation.finished;\n\n animation.commitStyles();\n\n return this.isOpen;\n }\n\n render() {\n const collapse = (\n <div\n aria-labelledby={this.hasHeader ? `${this.id}--header` : undefined}\n class={`collapse${this.hasHeader ? ' accordion-collapse' : ''}`}\n id={`${this.id}--collapse`}\n ref={el => this.collapsible = el}\n >\n {this.hasHeader ? (\n <div class=\"accordion-body\">\n <slot/>\n </div>\n ) : (\n <slot/>\n )}\n </div>\n );\n\n return (\n <Host id={this.id} data-version={version}>\n {this.hasHeader ? (\n <div class=\"accordion-item\">\n <this.headingTag class=\"accordion-header\" id={`${this.id}--header`}>\n <button\n aria-controls={`${this.id}--collapse`}\n aria-expanded={`${this.isOpen}`}\n class={`accordion-button${this.isOpen ? '' : ' collapsed'}`}\n onClick={() => this.toggle()}\n type=\"button\"\n >\n <slot name=\"header\"/>\n </button>\n </this.headingTag>\n\n {collapse}\n </div>\n ) : collapse}\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, g as getElement } from './index-4eff5fc5.js';
|
|
2
|
-
import { b as checkEmptyOrOneOf, d as checkEmptyOrType, c as checkType } from './index-35921354.js';
|
|
3
|
-
import { v as version } from './package-3bbdb32c.js';
|
|
4
|
-
import { c as checkNonEmpty } from './check-non-empty-09c39561.js';
|
|
5
|
-
|
|
6
|
-
const postIconCss = ":host{display:inline-block;width:1em;vertical-align:-0.15em}svg{display:block;width:100%;height:100%;fill:currentColor;background-color:currentColor;-webkit-mask-position:center center;mask-position:center center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:100%;mask-size:100%}:host([flip-h]:not([flip-h=false])){scale:-1 1}:host([flip-v]:not([flip-v=false])){scale:1 -1}:host([flip-h][flip-v]:not([flip-h=false],[flip-v=false])){scale:-1}:host([animation]){transform-origin:center}:host([animation=cylon]){animation:icon-animation-cylon .75s ease-in-out infinite alternate}:host([animation=cylon-vertical]){animation:icon-animation-cylon-vertical .75s ease-in-out infinite alternate}:host([animation=spin]){animation:icon-animation-spin 2s linear infinite normal}:host([animation=spin-reverse]){animation:icon-animation-spin 2s linear infinite reverse}:host([animation=fade]){animation:icon-animation-fade .75s ease-in-out infinite alternate}:host([animation=throb]){animation:icon-animation-throb .75s ease-in-out infinite alternate}@keyframes icon-animation-cylon{from{transform:translateX(-25%)}to{transform:translateX(25%)}}@keyframes icon-animation-cylon-vertical{from{transform:translateY(25%)}to{transform:translateY(-25%)}}@keyframes icon-animation-fade{from{opacity:.1}to{opacity:1}}@keyframes icon-animation-spin{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes icon-animation-throb{from{opacity:.5;transform:scale(0.5)}to{opacity:1;transform:scale(1)}}";
|
|
7
|
-
|
|
8
|
-
const CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';
|
|
9
|
-
const ANIMATION_NAMES = [
|
|
10
|
-
'cylon',
|
|
11
|
-
'cylon-vertical',
|
|
12
|
-
'spin',
|
|
13
|
-
'spin-reverse',
|
|
14
|
-
'fade',
|
|
15
|
-
'throb',
|
|
16
|
-
];
|
|
17
|
-
const ANIMATION_KEYS = [...ANIMATION_NAMES];
|
|
18
|
-
const PostIcon = class {
|
|
19
|
-
constructor(hostRef) {
|
|
20
|
-
registerInstance(this, hostRef);
|
|
21
|
-
this.svgStyles = undefined;
|
|
22
|
-
this.svgOutput = undefined;
|
|
23
|
-
this.animation = null;
|
|
24
|
-
this.base = null;
|
|
25
|
-
this.flipH = false;
|
|
26
|
-
this.flipV = false;
|
|
27
|
-
this.name = undefined;
|
|
28
|
-
this.rotate = null;
|
|
29
|
-
this.scale = null;
|
|
30
|
-
}
|
|
31
|
-
validateAnimation(newValue = this.animation) {
|
|
32
|
-
if (newValue !== undefined)
|
|
33
|
-
checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon "animation" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);
|
|
34
|
-
}
|
|
35
|
-
validateBase(newValue = this.base) {
|
|
36
|
-
checkEmptyOrType(newValue, 'string', 'The post-icon "base" prop should be a string.');
|
|
37
|
-
}
|
|
38
|
-
validateFlipH(newValue = this.flipH) {
|
|
39
|
-
checkEmptyOrType(newValue, 'boolean', 'The post-icon "flipH" prop should be a boolean.');
|
|
40
|
-
}
|
|
41
|
-
validateFlipV(newValue = this.flipV) {
|
|
42
|
-
checkEmptyOrType(newValue, 'boolean', 'The post-icon "flipV" prop should be a boolean.');
|
|
43
|
-
}
|
|
44
|
-
validateName(newValue = this.name) {
|
|
45
|
-
checkNonEmpty(newValue, 'The post-icon "name" prop is required!.');
|
|
46
|
-
checkType(newValue, 'string', 'The post-icon "name" prop should be a string.');
|
|
47
|
-
}
|
|
48
|
-
validateRotate(newValue = this.rotate) {
|
|
49
|
-
checkEmptyOrType(newValue, 'number', 'The post-icon "rotate" prop should be a number.');
|
|
50
|
-
}
|
|
51
|
-
validateScale(newValue = this.scale) {
|
|
52
|
-
checkEmptyOrType(newValue, 'number', 'The post-icon "scale" prop should be a number.');
|
|
53
|
-
}
|
|
54
|
-
componentWillLoad() {
|
|
55
|
-
this.validateBase();
|
|
56
|
-
this.validateName();
|
|
57
|
-
this.validateFlipH();
|
|
58
|
-
this.validateFlipV();
|
|
59
|
-
this.validateScale();
|
|
60
|
-
this.validateRotate();
|
|
61
|
-
this.validateAnimation();
|
|
62
|
-
}
|
|
63
|
-
componentWillRender() {
|
|
64
|
-
this.setPath();
|
|
65
|
-
}
|
|
66
|
-
setPath() {
|
|
67
|
-
var _a, _b, _c, _d;
|
|
68
|
-
// Construct icon path from different possible sources
|
|
69
|
-
const metaBase = (_b = (_a = document.head
|
|
70
|
-
.querySelector('meta[name="design-system-settings"][data-post-icon-base]')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-post-icon-base')) !== null && _b !== void 0 ? _b : null;
|
|
71
|
-
const fileBase = `${(_d = (_c = this.base) !== null && _c !== void 0 ? _c : metaBase) !== null && _d !== void 0 ? _d : CDN_URL}/`.replace(/\/\/$/, '/');
|
|
72
|
-
const fileName = `${this.name}.svg#icon`;
|
|
73
|
-
const filePath = `${fileBase}${fileName}`;
|
|
74
|
-
this.path = new URL(filePath, window.location.origin).toString();
|
|
75
|
-
}
|
|
76
|
-
render() {
|
|
77
|
-
// create inline styles for some properties
|
|
78
|
-
const svgStyles = Object.entries({
|
|
79
|
-
'-webkit-mask-image': `url('${this.path}')`,
|
|
80
|
-
'mask-image': `url('${this.path}')`,
|
|
81
|
-
'scale': this.scale && !isNaN(Number(this.scale)) ? `${this.scale}` : null,
|
|
82
|
-
'rotate': this.rotate && !isNaN(Number(this.rotate)) ? `${this.rotate}deg` : null,
|
|
83
|
-
})
|
|
84
|
-
.filter(([_key, value]) => value !== null)
|
|
85
|
-
.reduce((styles, [key, value]) => Object.assign(styles, { [key]: value }), {});
|
|
86
|
-
return (h(Host, { "data-version": version }, h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 32 32", style: svgStyles })));
|
|
87
|
-
}
|
|
88
|
-
get host() { return getElement(this); }
|
|
89
|
-
static get watchers() { return {
|
|
90
|
-
"animation": ["validateAnimation"],
|
|
91
|
-
"base": ["validateBase"],
|
|
92
|
-
"flipH": ["validateFlipH"],
|
|
93
|
-
"flipV": ["validateFlipV"],
|
|
94
|
-
"name": ["validateName"],
|
|
95
|
-
"rotate": ["validateRotate"],
|
|
96
|
-
"scale": ["validateScale"]
|
|
97
|
-
}; }
|
|
98
|
-
};
|
|
99
|
-
PostIcon.style = postIconCss;
|
|
100
|
-
|
|
101
|
-
export { PostIcon as P };
|
|
102
|
-
|
|
103
|
-
//# sourceMappingURL=post-icon-fb0eb8aa.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"post-icon-fb0eb8aa.js","mappings":";;;;;AAAA,MAAM,WAAW,GAAG,u+CAAu+C;;ACI3/C,MAAM,OAAO,GAAG,oEAAoE,CAAC;AACrF,MAAM,eAAe,GAAG;EACtB,OAAO;EACP,gBAAgB;EAChB,MAAM;EACN,cAAc;EACd,MAAM;EACN,OAAO;CACC,CAAC;AACX,MAAM,cAAc,GAAG,CAAC,GAAG,eAAe,CAAC,CAAC;MAY/B,QAAQ;;;;;qBAW6B,IAAI;gBAiBZ,IAAI;iBAUT,KAAK;iBAUL,KAAK;;kBAqBE,IAAI;iBAUL,IAAI;;EAjE7C,i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AG,EAAE,KAAK,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEjF,QACE,EAAC,IAAI,oBAAe,OAAO,IACzB,WAAK,KAAK,EAAC,4BAA4B,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAE,SAAS,GACtE,CACD,EACP;GACH;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/post-icon/post-icon.scss?tag=post-icon&encapsulation=shadow","src/components/post-icon/post-icon.tsx"],"sourcesContent":["@use 'sass:map';\n\n$post-icon-animations: (\n 'cylon': icon-animation-cylon 0.75s ease-in-out infinite alternate,\n 'cylon-vertical': icon-animation-cylon-vertical 0.75s ease-in-out infinite alternate,\n 'spin': icon-animation-spin 2s linear infinite normal,\n 'spin-reverse': icon-animation-spin 2s linear infinite reverse,\n 'fade': icon-animation-fade 0.75s ease-in-out infinite alternate,\n 'throb': icon-animation-throb 0.75s ease-in-out infinite alternate,\n);\n\n:host {\n display: inline-block;\n width: 1em;\n vertical-align: -0.15em;\n}\n\nsvg {\n display: block;\n width: 100%;\n height: 100%;\n fill: currentColor;\n background-color: currentColor;\n -webkit-mask-position: center center;\n mask-position: center center;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n -webkit-mask-size: 100%;\n mask-size: 100%;\n}\n\n// flip\n\n:host([flip-h]:not([flip-h='false'])) {\n scale: -1 1;\n}\n\n:host([flip-v]:not([flip-v='false'])) {\n scale: 1 -1;\n}\n\n:host([flip-h][flip-v]:not([flip-h='false'], [flip-v='false'])) {\n scale: -1;\n}\n\n// scale\n// done with inline styling\n\n// rotate\n// done with inline styling\n\n// animation\n\n:host([animation]) {\n transform-origin: center;\n}\n\n@each $key, $value in $post-icon-animations {\n :host([animation='#{$key}']) {\n animation: $value;\n }\n}\n\n@keyframes icon-animation-cylon {\n from {\n transform: translateX(-25%);\n }\n to {\n transform: translateX(25%);\n }\n}\n\n@keyframes icon-animation-cylon-vertical {\n from {\n transform: translateY(25%);\n }\n to {\n transform: translateY(-25%);\n }\n}\n\n@keyframes icon-animation-fade {\n from {\n opacity: 0.1;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes icon-animation-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(359deg);\n }\n}\n\n@keyframes icon-animation-throb {\n from {\n opacity: 0.5;\n transform: scale(0.5);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n","import { Component, Element, Host, h, Prop, State, Watch } from '@stencil/core';\nimport { checkNonEmpty, checkType, checkEmptyOrType, checkEmptyOrOneOf } from '../../utils';\nimport { version } from '../../../package.json';\n\nconst CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';\nconst ANIMATION_NAMES = [\n 'cylon',\n 'cylon-vertical',\n 'spin',\n 'spin-reverse',\n 'fade',\n 'throb',\n] as const;\nconst ANIMATION_KEYS = [...ANIMATION_NAMES];\n\ntype Animation = (typeof ANIMATION_NAMES)[number];\n\n/**\n * @class PostIcon - representing a stencil component\n */\n@Component({\n tag: 'post-icon',\n styleUrl: 'post-icon.scss',\n shadow: true,\n})\nexport class PostIcon {\n private path: string;\n\n @Element() host: HTMLPostIconElement;\n\n @State() svgStyles: string;\n @State() svgOutput: string;\n\n /**\n * The name of the animation.\n */\n @Prop() readonly animation?: Animation | null = null;\n\n @Watch('animation')\n validateAnimation(newValue = this.animation) {\n if (newValue !== undefined)\n checkEmptyOrOneOf(\n newValue,\n ANIMATION_KEYS,\n `The post-icon \"animation\" prop requires one of the following values: ${ANIMATION_KEYS.join(\n ', ',\n )}.`,\n );\n }\n\n /**\n * The base path, where the icons are located (must be a public url).<br/>Leave this field empty to use the default cdn url.\n */\n @Prop() readonly base?: string | null = null;\n\n @Watch('base')\n validateBase(newValue = this.base) {\n checkEmptyOrType(newValue, 'string', 'The post-icon \"base\" prop should be a string.');\n }\n\n /**\n * When set to `true`, the icon will be flipped horizontally.\n */\n @Prop() readonly flipH?: boolean = false;\n\n @Watch('flipH')\n validateFlipH(newValue = this.flipH) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipH\" prop should be a boolean.');\n }\n\n /**\n * When set to `true`, the icon will be flipped vertically.\n */\n @Prop() readonly flipV?: boolean = false;\n\n @Watch('flipV')\n validateFlipV(newValue = this.flipV) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipV\" prop should be a boolean.');\n }\n\n /**\n * The name/id of the icon (e.g. 1000, 1001, ...).\n */\n @Prop() readonly name!: string;\n\n @Watch('name')\n validateName(newValue = this.name) {\n checkNonEmpty(newValue, 'The post-icon \"name\" prop is required!.');\n checkType(newValue, 'string', 'The post-icon \"name\" prop should be a string.');\n }\n\n /**\n * The number of degree for the css rotate transformation.\n */\n @Prop() readonly rotate?: number | null = null;\n\n @Watch('rotate')\n validateRotate(newValue = this.rotate) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"rotate\" prop should be a number.');\n }\n\n /**\n * The number for the css scale transformation.\n */\n @Prop() readonly scale?: number | null = null;\n\n @Watch('scale')\n validateScale(newValue = this.scale) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"scale\" prop should be a number.');\n }\n\n componentWillLoad() {\n this.validateBase();\n this.validateName();\n this.validateFlipH();\n this.validateFlipV();\n this.validateScale();\n this.validateRotate();\n this.validateAnimation();\n }\n\n componentWillRender() {\n this.setPath();\n }\n\n private setPath() {\n // Construct icon path from different possible sources\n const metaBase =\n document.head\n .querySelector('meta[name=\"design-system-settings\"][data-post-icon-base]')\n ?.getAttribute('data-post-icon-base') ?? null;\n\n const fileBase = `${this.base ?? metaBase ?? CDN_URL}/`.replace(/\\/\\/$/, '/');\n const fileName = `${this.name}.svg#icon`;\n const filePath = `${fileBase}${fileName}`;\n\n this.path = new URL(filePath, window.location.origin).toString();\n }\n\n render() {\n // create inline styles for some properties\n const svgStyles = Object.entries({\n '-webkit-mask-image': `url('${this.path}')`,\n 'mask-image': `url('${this.path}')`,\n 'scale': this.scale && !isNaN(Number(this.scale)) ? `${this.scale}` : null,\n 'rotate': this.rotate && !isNaN(Number(this.rotate)) ? `${this.rotate}deg` : null,\n })\n .filter(([_key, value]) => value !== null)\n .reduce((styles, [key, value]) => Object.assign(styles, { [key]: value }), {});\n\n return (\n <Host data-version={version}>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\" style={svgStyles}>\n </svg>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, g as getElement } from './index-4eff5fc5.js';
|
|
2
|
-
import { v as version } from './package-3bbdb32c.js';
|
|
3
|
-
import { c as checkNonEmpty } from './check-non-empty-09c39561.js';
|
|
4
|
-
|
|
5
|
-
const postTabHeaderCss = ".tab-title[role=tab]{display:inline-block;position:relative;box-sizing:border-box;padding:1rem;transition:background-color 100ms;border-right:1px solid rgba(0,0,0,0);border-left:1px solid rgba(0,0,0,0);outline-color:currentColor;opacity:.7;color:var(--post-contrast-color);text-decoration:none}.tab-title[role=tab]:focus{background-color:unset;color:var(--post-contrast-color)}.tab-title[role=tab]:hover{opacity:1;background-color:#fff;color:var(--post-contrast-color)}.tab-title[role=tab]:focus-visible{outline:rgba(0,0,0,0);opacity:1;background-color:#fff;color:var(--post-contrast-color);box-shadow:none}.tab-title[role=tab]:focus-visible::after{content:\"\";display:block;position:absolute;top:2px;right:1px;bottom:0;left:1px;box-shadow:0 0 0 1px #fff,0 0 0 2px #333}.tab-title[role=tab].active{z-index:1;border-right-color:#ccc;border-left-color:#ccc;opacity:1;background-color:#fff;color:var(--post-contrast-color);font-weight:700}.tab-title[role=tab].active::before{content:\"\";display:block;position:absolute;top:0;right:-1px;left:-1px;height:.25rem;background-color:#fc0}:is(.bg-dark,.bg-primary,.bg-black,.bg-danger,.bg-nightblue,.bg-nightblue-bright,.bg-petrol,.bg-coral,.bg-olive,.bg-purple,.bg-purple-bright,.bg-aubergine,.bg-aubergine-bright) .tab-title[role=tab]:hover{background-color:rgba(255,255,255,.2)}:is(.bg-dark,.bg-primary,.bg-black,.bg-danger,.bg-nightblue,.bg-nightblue-bright,.bg-petrol,.bg-coral,.bg-olive,.bg-purple,.bg-purple-bright,.bg-aubergine,.bg-aubergine-bright) .tab-title[role=tab]:focus-visible{background-color:rgba(255,255,255,.2)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.tab-title[role=tab]{opacity:1;border-left-color:Canvas;border-right-color:Canvas;color:LinkText}.tab-title[role=tab]:hover,.tab-title[role=tab]:focus,.tab-title[role=tab]:focus-within,.tab-title[role=tab]:focus-visible{outline:2px solid Highlight;outline-offset:-0.25rem}.tab-title[role=tab].active{border-left-color:ButtonText;border-right-color:ButtonText;color:Highlight}.tab-title[role=tab].active::before{background-color:Highlight}}.bg-yellow .tab-title{background-color:#fc0}.bg-yellow .tab-title.active{background-color:#fc0}.bg-yellow .nav-item{background-color:#fc0}.bg-light .tab-title{background-color:#faf9f8}.bg-light .tab-title.active{background-color:#faf9f8}.bg-light .nav-item{background-color:#faf9f8}.bg-gray .tab-title{background-color:#f4f3f1}.bg-gray .tab-title.active{background-color:#f4f3f1}.bg-gray .nav-item{background-color:#f4f3f1}.bg-dark .tab-title{background-color:#333}.bg-dark .tab-title.active{background-color:#333}.bg-dark .nav-item{background-color:#333}.bg-primary .tab-title{background-color:#333}.bg-primary .tab-title.active{background-color:#333}.bg-primary .nav-item{background-color:#333}.bg-white .tab-title{background-color:#fff}.bg-white .tab-title.active{background-color:#fff}.bg-white .nav-item{background-color:#fff}.bg-black .tab-title{background-color:#000}.bg-black .tab-title.active{background-color:#000}.bg-black .nav-item{background-color:#000}.bg-success .tab-title{background-color:#2c911c}.bg-success .tab-title.active{background-color:#2c911c}.bg-success .nav-item{background-color:#2c911c}.bg-info .tab-title{background-color:#cce4ee}.bg-info .tab-title.active{background-color:#cce4ee}.bg-info .nav-item{background-color:#cce4ee}.bg-warning .tab-title{background-color:#f49e00}.bg-warning .tab-title.active{background-color:#f49e00}.bg-warning .nav-item{background-color:#f49e00}.bg-danger .tab-title{background-color:#a51728}.bg-danger .tab-title.active{background-color:#a51728}.bg-danger .nav-item{background-color:#a51728}.bg-nightblue .tab-title{background-color:#004976}.bg-nightblue .tab-title.active{background-color:#004976}.bg-nightblue .nav-item{background-color:#004976}.bg-nightblue-bright .tab-title{background-color:#0076a8}.bg-nightblue-bright .tab-title.active{background-color:#0076a8}.bg-nightblue-bright .nav-item{background-color:#0076a8}.bg-petrol .tab-title{background-color:#006d68}.bg-petrol .tab-title.active{background-color:#006d68}.bg-petrol .nav-item{background-color:#006d68}.bg-petrol-bright .tab-title{background-color:#00968f}.bg-petrol-bright .tab-title.active{background-color:#00968f}.bg-petrol-bright .nav-item{background-color:#00968f}.bg-coral .tab-title{background-color:#9e2a2f}.bg-coral .tab-title.active{background-color:#9e2a2f}.bg-coral .nav-item{background-color:#9e2a2f}.bg-coral-bright .tab-title{background-color:#e03c31}.bg-coral-bright .tab-title.active{background-color:#e03c31}.bg-coral-bright .nav-item{background-color:#e03c31}.bg-olive .tab-title{background-color:#716135}.bg-olive .tab-title.active{background-color:#716135}.bg-olive .nav-item{background-color:#716135}.bg-olive-bright .tab-title{background-color:#aa9d2e}.bg-olive-bright .tab-title.active{background-color:#aa9d2e}.bg-olive-bright .nav-item{background-color:#aa9d2e}.bg-purple .tab-title{background-color:#80276c}.bg-purple .tab-title.active{background-color:#80276c}.bg-purple .nav-item{background-color:#80276c}.bg-purple-bright .tab-title{background-color:#c5299b}.bg-purple-bright .tab-title.active{background-color:#c5299b}.bg-purple-bright .nav-item{background-color:#c5299b}.bg-aubergine .tab-title{background-color:#523178}.bg-aubergine .tab-title.active{background-color:#523178}.bg-aubergine .nav-item{background-color:#523178}.bg-aubergine-bright .tab-title{background-color:#7566a0}.bg-aubergine-bright .tab-title.active{background-color:#7566a0}.bg-aubergine-bright .nav-item{background-color:#7566a0}[class*=bg-] .tab-title.active:focus::after{background-color:rgba(255,255,255,.2)}@supports selector(*:focus-visible){[class*=bg-] .tab-title.active:focus::after{background-color:unset}[class*=bg-] .tab-title.active:focus-visible::after{background-color:rgba(255,255,255,.2)}}/*!\n * Copyright 2021 by Swiss Post, Information Technology\n */:host{display:block}.tab-title{padding:0;overflow:visible;border:0;background:none;color:inherit;font:inherit;-webkit-user-select:none;user-select:none;-webkit-appearance:button;appearance:button}";
|
|
6
|
-
|
|
7
|
-
const PostTabHeader = class {
|
|
8
|
-
constructor(hostRef) {
|
|
9
|
-
registerInstance(this, hostRef);
|
|
10
|
-
this.tabId = undefined;
|
|
11
|
-
this.panel = undefined;
|
|
12
|
-
}
|
|
13
|
-
validateFor(newValue) {
|
|
14
|
-
checkNonEmpty(newValue, 'The "panel" prop is required for the post-tab-header.');
|
|
15
|
-
}
|
|
16
|
-
componentWillLoad() {
|
|
17
|
-
this.tabId = `tab-${this.host.id || crypto.randomUUID()}`;
|
|
18
|
-
}
|
|
19
|
-
render() {
|
|
20
|
-
return (h(Host, { "data-version": version }, h("button", { "aria-selected": "false", class: "tab-title", id: this.tabId, role: "tab", tabindex: "-1", type: "button" }, h("slot", null))));
|
|
21
|
-
}
|
|
22
|
-
get host() { return getElement(this); }
|
|
23
|
-
static get watchers() { return {
|
|
24
|
-
"panel": ["validateFor"]
|
|
25
|
-
}; }
|
|
26
|
-
};
|
|
27
|
-
PostTabHeader.style = postTabHeaderCss;
|
|
28
|
-
|
|
29
|
-
export { PostTabHeader as P };
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=post-tab-header-deebc551.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"post-tab-header-deebc551.js","mappings":";;;;AAAA,MAAM,gBAAgB,GAAG,k+LAAk+L;;MCS9+L,aAAa;;;;;;EAWxB,WAAW,CAAC,QAAyC;IACnD,aAAa,CAAC,QAAQ,EAAE,uDAAuD,CAAC,CAAC;GAClF;EAED,iBAAiB;IACf,IAAI,CAAC,KAAK,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;GAC3D;EAED,MAAM;IACJ,QACE,EAAC,IAAI,oBAAe,OAAO,IACzB,+BAAsB,OAAO,EAAC,KAAK,EAAC,WAAW,EAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,EAAC,IAAI,EAAC,QAAQ,IACpG,eAAQ,CACD,CACJ,EACP;GACH;;;;;;;;;;","names":[],"sources":["src/components/post-tab-header/post-tab-header.scss?tag=post-tab-header&encapsulation=shadow","src/components/post-tab-header/post-tab-header.tsx"],"sourcesContent":["@use '@swisspost/design-system-styles/components/tabs/tab-title';\n@use '@swisspost/design-system-styles/core' as post;\n\n:host {\n display: block;\n}\n\n.tab-title {\n @include post.reset-button;\n}\n","import { Component, Element, h, Host, Prop, State, Watch } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { checkNonEmpty } from '../../utils';\n\n@Component({\n tag: 'post-tab-header',\n styleUrl: 'post-tab-header.scss',\n shadow: true,\n})\nexport class PostTabHeader {\n @Element() host: HTMLPostTabHeaderElement;\n\n @State() tabId: string;\n\n /**\n * The name of the panel controlled by the tab header.\n */\n @Prop() readonly panel: HTMLPostTabPanelElement['name'];\n\n @Watch('panel')\n validateFor(newValue: HTMLPostTabPanelElement['name']) {\n checkNonEmpty(newValue, 'The \"panel\" prop is required for the post-tab-header.');\n }\n\n componentWillLoad() {\n this.tabId = `tab-${this.host.id || crypto.randomUUID()}`;\n }\n\n render() {\n return (\n <Host data-version={version}>\n <button aria-selected=\"false\" class=\"tab-title\" id={this.tabId} role=\"tab\" tabindex=\"-1\" type=\"button\">\n <slot />\n </button>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, g as getElement } from './index-4eff5fc5.js';
|
|
2
|
-
import { v as version } from './package-3bbdb32c.js';
|
|
3
|
-
|
|
4
|
-
const postTabPanelCss = ":host{display:none}";
|
|
5
|
-
|
|
6
|
-
const PostTabPanel = class {
|
|
7
|
-
constructor(hostRef) {
|
|
8
|
-
registerInstance(this, hostRef);
|
|
9
|
-
this.panelId = undefined;
|
|
10
|
-
this.name = undefined;
|
|
11
|
-
}
|
|
12
|
-
componentWillLoad() {
|
|
13
|
-
// get the id set on the host element or use a random id by default
|
|
14
|
-
this.panelId = `panel-${this.host.id || crypto.randomUUID()}`;
|
|
15
|
-
}
|
|
16
|
-
render() {
|
|
17
|
-
return (h(Host, { "data-version": version }, h("div", { class: "tab-pane", id: this.panelId, role: "tabpanel" }, h("slot", null))));
|
|
18
|
-
}
|
|
19
|
-
get host() { return getElement(this); }
|
|
20
|
-
};
|
|
21
|
-
PostTabPanel.style = postTabPanelCss;
|
|
22
|
-
|
|
23
|
-
export { PostTabPanel as P };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=post-tab-panel-4b820f71.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"post-tab-panel-4b820f71.js","mappings":";;;AAAA,MAAM,eAAe,GAAG,qBAAqB;;MCQhC,YAAY;;;;;;EAUvB,iBAAiB;;IAEf,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;GAC/D;EAED,MAAM;IACJ,QACE,EAAC,IAAI,oBAAe,OAAO,IACzB,WACE,KAAK,EAAC,UAAU,EAChB,EAAE,EAAE,IAAI,CAAC,OAAO,EAChB,IAAI,EAAC,UAAU,IAEf,eAAO,CACH,CACD,EACP;GACH;;;;;;;","names":[],"sources":["src/components/post-tab-panel/post-tab-panel.scss?tag=post-tab-panel&encapsulation=shadow","src/components/post-tab-panel/post-tab-panel.tsx"],"sourcesContent":[":host {\n display: none;\n}\n","import { Component, Element, h, Host, Prop, State } from '@stencil/core';\nimport { version } from '../../../package.json';\n\n@Component({\n tag: 'post-tab-panel',\n styleUrl: 'post-tab-panel.scss',\n shadow: true,\n})\nexport class PostTabPanel {\n @Element() host: HTMLPostTabPanelElement;\n\n @State() panelId: string;\n\n /**\n * The name of the panel, used to associate it with a tab header.\n */\n @Prop() readonly name: string;\n\n componentWillLoad() {\n // get the id set on the host element or use a random id by default\n this.panelId = `panel-${this.host.id || crypto.randomUUID()}`;\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div\n class=\"tab-pane\"\n id={this.panelId}\n role=\"tabpanel\"\n >\n <slot/>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-4eff5fc5.js';
|
|
2
|
-
import { v as version } from './package-3bbdb32c.js';
|
|
3
|
-
import { f as fadeOut, a as fadeIn } from './fade-7fd71785.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 = class {
|
|
8
|
-
constructor(hostRef) {
|
|
9
|
-
registerInstance(this, hostRef);
|
|
10
|
-
this.tabChange = createEvent(this, "tabChange", 7);
|
|
11
|
-
this.isLoaded = false;
|
|
12
|
-
this.activePanel = undefined;
|
|
13
|
-
}
|
|
14
|
-
get tabs() {
|
|
15
|
-
return this.host.querySelectorAll('post-tab-header');
|
|
16
|
-
}
|
|
17
|
-
componentDidLoad() {
|
|
18
|
-
this.moveMisplacedTabs();
|
|
19
|
-
this.enableTabs();
|
|
20
|
-
const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;
|
|
21
|
-
void this.show(initiallyActivePanel);
|
|
22
|
-
this.isLoaded = true;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Shows the panel with the given name and selects its associated tab.
|
|
26
|
-
* Any other panel that was previously shown becomes hidden and its associated tab is unselected.
|
|
27
|
-
*/
|
|
28
|
-
async show(panelName) {
|
|
29
|
-
var _a;
|
|
30
|
-
// do nothing if the tab is already active
|
|
31
|
-
if (panelName === ((_a = this.activeTab) === null || _a === void 0 ? void 0 : _a.panel)) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const previousTab = this.activeTab;
|
|
35
|
-
const newTab = this.host.querySelector(`post-tab-header[panel=${panelName}]`);
|
|
36
|
-
this.activateTab(newTab);
|
|
37
|
-
// if a panel is currently being displayed, remove it from the view and complete the associated animation
|
|
38
|
-
if (this.showing) {
|
|
39
|
-
this.showing.effect['target'].style.display = 'none';
|
|
40
|
-
this.showing.finish();
|
|
41
|
-
}
|
|
42
|
-
// hide the currently visible panel only if no other animation is running
|
|
43
|
-
if (previousTab && !this.showing && !this.hiding) {
|
|
44
|
-
this.hidePanel(previousTab.panel);
|
|
45
|
-
}
|
|
46
|
-
// wait for any hiding animation to complete before showing the selected tab
|
|
47
|
-
if (this.hiding) {
|
|
48
|
-
await this.hiding.finished;
|
|
49
|
-
}
|
|
50
|
-
this.showSelectedPanel();
|
|
51
|
-
// wait for any display animation to complete for the returned promise to fully resolve
|
|
52
|
-
if (this.showing) {
|
|
53
|
-
await this.showing.finished;
|
|
54
|
-
}
|
|
55
|
-
this.tabChange.emit(this.activeTab.panel);
|
|
56
|
-
}
|
|
57
|
-
moveMisplacedTabs() {
|
|
58
|
-
if (!this.tabs)
|
|
59
|
-
return;
|
|
60
|
-
this.tabs.forEach(tab => {
|
|
61
|
-
if (tab.getAttribute('slot') === 'tabs')
|
|
62
|
-
return;
|
|
63
|
-
tab.setAttribute('slot', 'tabs');
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
enableTabs() {
|
|
67
|
-
if (!this.tabs)
|
|
68
|
-
return;
|
|
69
|
-
this.tabs.forEach(async (tab) => {
|
|
70
|
-
await tab.componentOnReady();
|
|
71
|
-
const tabTitle = tab.shadowRoot.querySelector('.tab-title');
|
|
72
|
-
// if the tab has an "aria-controls" attribute it was already linked to its panel: do nothing
|
|
73
|
-
if (tabTitle.getAttribute('aria-controls'))
|
|
74
|
-
return;
|
|
75
|
-
const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');
|
|
76
|
-
tabTitle.setAttribute('aria-controls', tabPanel.id);
|
|
77
|
-
tabPanel.setAttribute('aria-labelledby', tabTitle.id);
|
|
78
|
-
tab.addEventListener('click', () => {
|
|
79
|
-
void this.show(tab.panel);
|
|
80
|
-
});
|
|
81
|
-
tab.addEventListener('keydown', ({ key }) => {
|
|
82
|
-
if (key === 'ArrowRight' || key === 'ArrowLeft')
|
|
83
|
-
this.navigateTabs(tab, key);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
// if the currently active tab was removed from the DOM then select the first one
|
|
87
|
-
if (this.activeTab && !this.activeTab.isConnected) {
|
|
88
|
-
void this.show(this.tabs.item(0).panel);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
activateTab(tab) {
|
|
92
|
-
if (this.activeTab) {
|
|
93
|
-
const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');
|
|
94
|
-
tabTitle.setAttribute('aria-selected', 'false');
|
|
95
|
-
tabTitle.setAttribute('tabindex', '-1');
|
|
96
|
-
tabTitle.classList.remove('active');
|
|
97
|
-
}
|
|
98
|
-
const tabTitle = tab.shadowRoot.querySelector('.tab-title');
|
|
99
|
-
tabTitle.setAttribute('aria-selected', 'true');
|
|
100
|
-
tabTitle.removeAttribute('tabindex');
|
|
101
|
-
tabTitle.classList.add('active');
|
|
102
|
-
this.activeTab = tab;
|
|
103
|
-
}
|
|
104
|
-
hidePanel(panelName) {
|
|
105
|
-
const previousPanel = this.getPanel(panelName);
|
|
106
|
-
if (!previousPanel)
|
|
107
|
-
return;
|
|
108
|
-
this.hiding = fadeOut(previousPanel);
|
|
109
|
-
this.hiding.onfinish = () => {
|
|
110
|
-
previousPanel.style.display = 'none';
|
|
111
|
-
this.hiding = null;
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
showSelectedPanel() {
|
|
115
|
-
const panel = this.getPanel(this.activeTab.panel);
|
|
116
|
-
panel.style.display = 'block';
|
|
117
|
-
// prevent the initially selected panel from fading in
|
|
118
|
-
if (!this.isLoaded)
|
|
119
|
-
return;
|
|
120
|
-
this.showing = fadeIn(panel);
|
|
121
|
-
this.showing.onfinish = () => {
|
|
122
|
-
this.showing = null;
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
getPanel(name) {
|
|
126
|
-
return this.host.querySelector(`post-tab-panel[name=${name}]`);
|
|
127
|
-
}
|
|
128
|
-
navigateTabs(tab, key) {
|
|
129
|
-
const activeTabIndex = Array.from(this.tabs).indexOf(tab);
|
|
130
|
-
let nextTab;
|
|
131
|
-
if (key === 'ArrowRight') {
|
|
132
|
-
nextTab = this.tabs[activeTabIndex + 1] || this.tabs[0];
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
nextTab = this.tabs[activeTabIndex - 1] || this.tabs[this.tabs.length - 1];
|
|
136
|
-
}
|
|
137
|
-
if (!nextTab)
|
|
138
|
-
return;
|
|
139
|
-
const nextTabTitle = nextTab.shadowRoot.querySelector('.tab-title');
|
|
140
|
-
nextTabTitle.focus();
|
|
141
|
-
}
|
|
142
|
-
render() {
|
|
143
|
-
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() }))));
|
|
144
|
-
}
|
|
145
|
-
get host() { return getElement(this); }
|
|
146
|
-
};
|
|
147
|
-
PostTabs.style = postTabsCss;
|
|
148
|
-
|
|
149
|
-
export { PostTabs as P };
|
|
150
|
-
|
|
151
|
-
//# sourceMappingURL=post-tabs-2d8d6a33.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"post-tabs-2d8d6a33.js","mappings":";;;;AAAA,MAAM,WAAW,GAAG,yzDAAyzD;;MCSh0D,QAAQ;;;;IAIX,aAAQ,GAAG,KAAK,CAAC;;;EAEzB,IAAY,IAAI;IACd,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CA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,IACvB,WAAK,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,SAAS,IAC9B,YAAM,IAAI,EAAC,MAAM,EAAC,YAAY,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,GAAI,CACvD,CACF,EACN,WAAK,KAAK,EAAC,aAAa,IACtB,YAAM,YAAY,EAAE,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}
|