@swisspost/design-system-components 1.3.9 → 1.3.10

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 (35) hide show
  1. package/dist/cjs/{package-c661bf2f.js → package-f6bb523d.js} +2 -2
  2. package/dist/cjs/{package-c661bf2f.js.map → package-f6bb523d.js.map} +1 -1
  3. package/dist/cjs/post-collapsible.cjs.entry.js +2 -2
  4. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  5. package/dist/cjs/post-icon.cjs.entry.js +1 -1
  6. package/dist/collection/components/post-collapsible/post-collapsible.css +165 -15688
  7. package/dist/components/package.js +1 -1
  8. package/dist/components/post-collapsible.js +1 -1
  9. package/dist/components/post-collapsible.js.map +1 -1
  10. package/dist/docs.json +1 -1
  11. package/dist/esm/{package-adf815bd.js → package-bcf00737.js} +2 -2
  12. package/dist/esm/{package-adf815bd.js.map → package-bcf00737.js.map} +1 -1
  13. package/dist/esm/post-collapsible.entry.js +2 -2
  14. package/dist/esm/post-collapsible.entry.js.map +1 -1
  15. package/dist/esm/post-icon.entry.js +1 -1
  16. package/dist/post-components/{p-05d38c8e.js → p-4a3ff4c0.js} +2 -2
  17. package/dist/post-components/p-99ccf0cf.entry.js +2 -0
  18. package/dist/post-components/p-99ccf0cf.entry.js.map +1 -0
  19. package/dist/post-components/{p-5cd6cb3a.entry.js → p-cafa0281.entry.js} +2 -2
  20. package/dist/post-components/post-components.esm.js +1 -1
  21. package/package.json +7 -8
  22. package/dist/collection/utils/property-checkers/tests/check-non-empty.spec.js +0 -36
  23. package/dist/collection/utils/property-checkers/tests/check-non-empty.spec.js.map +0 -1
  24. package/dist/collection/utils/property-checkers/tests/check-one-of.spec.js +0 -13
  25. package/dist/collection/utils/property-checkers/tests/check-one-of.spec.js.map +0 -1
  26. package/dist/collection/utils/property-checkers/tests/check-type.spec.js +0 -103
  27. package/dist/collection/utils/property-checkers/tests/check-type.spec.js.map +0 -1
  28. package/dist/collection/utils/property-checkers/tests/empty-or.spec.js +0 -23
  29. package/dist/collection/utils/property-checkers/tests/empty-or.spec.js.map +0 -1
  30. package/dist/collection/utils/tests/should-reduce-motion.spec.js +0 -16
  31. package/dist/collection/utils/tests/should-reduce-motion.spec.js.map +0 -1
  32. package/dist/post-components/p-4eaaf8eb.entry.js +0 -2
  33. package/dist/post-components/p-4eaaf8eb.entry.js.map +0 -1
  34. /package/dist/post-components/{p-05d38c8e.js.map → p-4a3ff4c0.js.map} +0 -0
  35. /package/dist/post-components/{p-5cd6cb3a.entry.js.map → p-cafa0281.entry.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement } from './index-60a84798.js';
2
- import { c as checkType, a as checkOneOf, v as version } from './package-adf815bd.js';
2
+ import { c as checkType, a as checkOneOf, v as version } from './package-bcf00737.js';
3
3
 
4
4
  const EMPTY_VALUES = [undefined, null, ''];
5
5
 
@@ -1,2 +1,2 @@
1
- function r(r,o,n){if(!o.includes(r))throw new Error(n)}function o(r,o,n){const t=o==="array";const a=Array.isArray(r);if(t||a){if(a!==t)throw new Error(n)}else{if(typeof r!==o)throw new Error(n)}}const n="1.3.9";export{r as a,o as c,n as v};
2
- //# sourceMappingURL=p-05d38c8e.js.map
1
+ function r(r,o,n){if(!o.includes(r))throw new Error(n)}function o(r,o,n){const t=o==="array";const a=Array.isArray(r);if(t||a){if(a!==t)throw new Error(n)}else{if(typeof r!==o)throw new Error(n)}}const n="1.3.10";export{r as a,o as c,n as v};
2
+ //# sourceMappingURL=p-4a3ff4c0.js.map
@@ -0,0 +1,2 @@
1
+ import{r as o,h as t,H as i,g as e}from"./p-0096c140.js";import{c as n,a as s,v as a}from"./p-4a3ff4c0.js";function r(o,t=[]){if(!Array.isArray(t))t=[t];const i=t.filter((t=>!o.classList.contains(t)));if(i.length)o.classList.add(...i);const e=o.scrollHeight;if(i.length)o.classList.remove(...i);return e}function d(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}async function c(o){return new Promise((t=>{if(d()){t()}else{o.ontransitionend=()=>{t();o.ontransitionend=null}}}))}const h=".accordion-item{border-block-start:2px solid hsl(0, 0%, 90%)}.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;user-select:none;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:0.4}.accordion-button:focus{outline:none;box-shadow:0 0 0 0.125rem rgba(51, 51, 51, 0.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:0.75rem 1rem 2.5rem;border-block-start:2px solid hsl(0, 0%, 90%)}.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}/*!\n * Bootstrap Utilities v5.1.3 (https://getbootstrap.com/)\n * Copyright 2011-2021 The Bootstrap Authors\n * Copyright 2011-2021 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n\n * The MIT License (MIT)\n\n * Copyright (c) 2011-2020 Twitter, Inc.\n * Copyright (c) 2011-2020 The Bootstrap Authors\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */.fade{transition:opacity 200ms linear}@media (prefers-reduced-motion: reduce){.fade{transition:none}}.fade:not(.show){opacity:0}.collapse:not(.show){display:none}.collapsing{height:0;overflow:hidden;transition:height 250ms cubic-bezier(0.4, 0, 0.2, 1), padding 250ms cubic-bezier(0.4, 0, 0.2, 1)}@media (prefers-reduced-motion: reduce){.collapsing{transition:none}}.collapsing.collapse-horizontal{width:0;height:auto;transition:width 0.35s ease}@media (prefers-reduced-motion: reduce){.collapsing.collapse-horizontal{transition:none}}:host{display:block}:host .accordion-button>::slotted(.text-truncate){display:block}";let l=0;const p=class{constructor(t){o(this,t);this.isLoaded=false;this.collapseClasses=undefined;this.collapseHeight=null;this.collapsibleId=undefined;this.hasHeader=undefined;this.headingTag=undefined;this.isOpen=true;this.onAccordionButtonClick=()=>this.toggle();this.collapsed=false;this.headingLevel=2}validateCollapsed(o=this.collapsed){n(o,"boolean",'The post-collapsible "collapsed" prop should be a boolean.');if(!this.isLoaded){this.isOpen=!o;this.collapseClasses=this.getCollapseClasses()}else{setTimeout((()=>{this.toggle(!o)}))}}validateHeadingLevel(o=this.headingLevel){s(o,[1,2,3,4,5,6],"The post-collapsible element requires a heading level between 1 and 6.");this.headingTag=`h${o}`}componentWillLoad(){this.validateCollapsed();this.validateHeadingLevel();this.hasHeader=this.host.querySelectorAll('[slot="header"]').length>0;if(!this.hasHeader){console.warn("Be sure to bind the post-collapsible to its control using aria-controls and aria-expanded attributes. More information here: https://getbootstrap.com/docs/5.2/components/collapse/#accessibility")}this.collapsibleId=this.host.id||`post-collapsible-${l++}`;this.collapseClasses=this.getCollapseClasses()}componentDidLoad(){this.isLoaded=true;this.collapsibleElement=this.host.shadowRoot.querySelector(`#${this.collapsibleId}--collapse`)}async toggle(o=!this.isOpen){if(o!==this.isOpen){this.isOpen=!this.isOpen;this.startTransition();await c(this.collapsibleElement).then((()=>{this.collapseHeight=null;this.collapseClasses=this.getCollapseClasses()}));return this.isOpen}}startTransition(){const o=r(this.collapsibleElement,"show");this.collapseHeight=`${this.isOpen?0:o}px`;this.collapseClasses="collapsing";setTimeout((()=>{this.collapseHeight=`${this.isOpen?o:0}px`}),50)}getCollapseClasses(){return this.isOpen?"collapse show":"collapse"}render(){if(!this.hasHeader){return t("div",{id:`${this.collapsibleId}--collapse`,class:this.collapseClasses,style:{height:this.collapseHeight}},t("slot",null))}return t(i,{"data-version":a},t("div",{class:"accordion-item"},t(this.headingTag,{class:"accordion-header",id:`${this.collapsibleId}--header`},t("button",{class:`accordion-button ${this.isOpen?"":"collapsed"}`,type:"button","aria-expanded":`${this.isOpen}`,"aria-controls":`${this.collapsibleId}--collapse`,onClick:this.onAccordionButtonClick},t("slot",{name:"header"}))),t("div",{id:`${this.collapsibleId}--collapse`,class:`accordion-collapse ${this.collapseClasses}`,style:{height:this.collapseHeight},"aria-labelledby":`${this.collapsibleId}--header`},t("div",{class:"accordion-body"},t("slot",null)))))}get host(){return e(this)}static get watchers(){return{collapsed:["validateCollapsed"],headingLevel:["validateHeadingLevel"]}}};p.style=h;export{p as post_collapsible};
2
+ //# sourceMappingURL=p-99ccf0cf.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getElementHeight","el","classesWhenShown","Array","isArray","classesToAdd","filter","klass","classList","contains","length","add","scrollHeight","remove","shouldReduceMotion","window","matchMedia","matches","async","onTransitionEnd","Promise","resolve","ontransitionend","postCollapsibleCss","nextId","PostCollapsible","this","isLoaded","toggle","validateCollapsed","newValue","collapsed","checkType","isOpen","collapseClasses","getCollapseClasses","setTimeout","validateHeadingLevel","headingLevel","checkOneOf","headingTag","componentWillLoad","hasHeader","host","querySelectorAll","console","warn","collapsibleId","id","componentDidLoad","collapsibleElement","shadowRoot","querySelector","open","startTransition","then","collapseHeight","expandedHeight","render","h","class","style","height","Host","version","type","onClick","onAccordionButtonClick","name"],"sources":["./src/utils/get-element-height.ts","./src/utils/should-reduce-motion.ts","./src/utils/on-transition-end.ts","./src/components/post-collapsible/post-collapsible.scss?tag=post-collapsible&encapsulation=shadow","./src/components/post-collapsible/post-collapsible.tsx"],"sourcesContent":["export function getElementHeight(el: HTMLElement): number;\nexport function getElementHeight(el: HTMLElement, classWhenShown: string): number;\nexport function getElementHeight(el: HTMLElement, classesWhenShown: string[]): number;\nexport function getElementHeight(el: HTMLElement, classesWhenShown: string | string[] = []): number {\n if (!Array.isArray(classesWhenShown)) classesWhenShown = [classesWhenShown];\n\n const classesToAdd = classesWhenShown.filter(klass => !el.classList.contains(klass));\n if (classesToAdd.length) el.classList.add(...classesToAdd);\n\n const scrollHeight = el.scrollHeight;\n\n if (classesToAdd.length) el.classList.remove(...classesToAdd);\n\n return scrollHeight;\n}\n","export function shouldReduceMotion(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n","import { shouldReduceMotion } from './should-reduce-motion';\n\nexport async function onTransitionEnd(el: HTMLElement): Promise<void> {\n return new Promise(resolve => {\n if (shouldReduceMotion()) {\n resolve();\n } else {\n el.ontransitionend = () => {\n resolve();\n el.ontransitionend = null;\n };\n }\n });\n}\n","@use '@swisspost/design-system-styles/components/accordion';\n@use '@swisspost/design-system-styles/components/transitions';\n\n:host {\n display: block;\n\n .accordion-button > ::slotted(.text-truncate) {\n display: block;\n }\n}\n","import { Component, Element, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport { checkOneOf, checkType, getElementHeight, onTransitionEnd } from '../../utils';\nimport { version } from '../../../package.json';\n\nlet nextId = 0;\n\n@Component({\n tag: 'post-collapsible',\n styleUrl: 'post-collapsible.scss',\n shadow: true,\n})\nexport class PostCollapsible {\n private collapsibleElement: HTMLElement;\n private isLoaded = false;\n\n @Element() host: HTMLPostCollapsibleElement;\n\n @State() collapseClasses: string;\n @State() collapseHeight: string | null = null;\n @State() collapsibleId: string;\n @State() hasHeader: boolean;\n @State() headingTag: string | undefined;\n @State() isOpen = true;\n @State() onAccordionButtonClick = () => this.toggle();\n\n /**\n * If `true`, the element is initially collapsed otherwise it is displayed.\n */\n @Prop() readonly collapsed?: boolean = false;\n\n @Watch('collapsed')\n validateCollapsed(newValue = this.collapsed) {\n checkType(newValue, 'boolean', 'The post-collapsible \"collapsed\" prop should be a boolean.');\n\n if (!this.isLoaded) {\n this.isOpen = !newValue;\n this.collapseClasses = this.getCollapseClasses();\n } else {\n setTimeout(() => {\n this.toggle(!newValue);\n });\n }\n }\n\n /**\n * Defines the hierarchical level of the collapsible header within the headings structure.\n */\n @Prop() readonly headingLevel?: number = 2;\n\n @Watch('headingLevel')\n validateHeadingLevel(newValue = this.headingLevel) {\n checkOneOf(\n newValue,\n [1, 2, 3, 4, 5, 6],\n 'The post-collapsible element requires a heading level between 1 and 6.',\n );\n\n this.headingTag = `h${newValue}`;\n }\n\n componentWillLoad() {\n this.validateCollapsed();\n this.validateHeadingLevel();\n\n this.hasHeader = this.host.querySelectorAll('[slot=\"header\"]').length > 0;\n if (!this.hasHeader) {\n console.warn(\n 'Be sure to bind the post-collapsible to its control using aria-controls and aria-expanded attributes. More information here: https://getbootstrap.com/docs/5.2/components/collapse/#accessibility',\n );\n }\n\n this.collapsibleId = this.host.id || `post-collapsible-${nextId++}`;\n this.collapseClasses = this.getCollapseClasses();\n }\n\n componentDidLoad() {\n this.isLoaded = true;\n this.collapsibleElement = this.host.shadowRoot.querySelector(\n `#${this.collapsibleId}--collapse`,\n );\n }\n\n /**\n * Triggers the collapse programmatically.\n */\n @Method()\n async toggle(open = !this.isOpen): Promise<boolean> {\n if (open !== this.isOpen) {\n this.isOpen = !this.isOpen;\n\n this.startTransition();\n\n await onTransitionEnd(this.collapsibleElement).then(() => {\n this.collapseHeight = null;\n this.collapseClasses = this.getCollapseClasses();\n });\n\n return this.isOpen;\n }\n }\n\n private startTransition() {\n const expandedHeight = getElementHeight(this.collapsibleElement, 'show');\n\n this.collapseHeight = `${this.isOpen ? 0 : expandedHeight}px`;\n this.collapseClasses = 'collapsing';\n\n setTimeout(() => {\n this.collapseHeight = `${this.isOpen ? expandedHeight : 0}px`;\n }, 50);\n }\n\n private getCollapseClasses() {\n return this.isOpen ? 'collapse show' : 'collapse';\n }\n\n render() {\n if (!this.hasHeader) {\n return (\n <div\n id={`${this.collapsibleId}--collapse`}\n class={this.collapseClasses}\n style={{ height: this.collapseHeight }}\n >\n <slot />\n </div>\n );\n }\n\n return (\n <Host data-version={version}>\n <div class=\"accordion-item\">\n <this.headingTag class=\"accordion-header\" id={`${this.collapsibleId}--header`}>\n <button\n class={`accordion-button ${this.isOpen ? '' : 'collapsed'}`}\n type=\"button\"\n aria-expanded={`${this.isOpen}`}\n aria-controls={`${this.collapsibleId}--collapse`}\n onClick={this.onAccordionButtonClick}\n >\n <slot name=\"header\" />\n </button>\n </this.headingTag>\n <div\n id={`${this.collapsibleId}--collapse`}\n class={`accordion-collapse ${this.collapseClasses}`}\n style={{ height: this.collapseHeight }}\n aria-labelledby={`${this.collapsibleId}--header`}\n >\n <div class=\"accordion-body\">\n <slot />\n </div>\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"mappings":"oHAGgBA,EAAiBC,EAAiBC,EAAsC,IACtF,IAAKC,MAAMC,QAAQF,GAAmBA,EAAmB,CAACA,GAE1D,MAAMG,EAAeH,EAAiBI,QAAOC,IAAUN,EAAGO,UAAUC,SAASF,KAC7E,GAAIF,EAAaK,OAAQT,EAAGO,UAAUG,OAAON,GAE7C,M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,KAAK4B,wBAECnC,EAAgBO,KAAKwB,oBAAoBK,MAAK,KAClD7B,KAAK8B,eAAiB,KACtB9B,KAAKQ,gBAAkBR,KAAKS,oBAAoB,IAGlD,OAAOT,KAAKO,M,EAIRqB,kBACN,MAAMG,EAAiBzD,EAAiB0B,KAAKwB,mBAAoB,QAEjExB,KAAK8B,eAAiB,GAAG9B,KAAKO,OAAS,EAAIwB,MAC3C/B,KAAKQ,gBAAkB,aAEvBE,YAAW,KACTV,KAAK8B,eAAiB,GAAG9B,KAAKO,OAASwB,EAAiB,KAAK,GAC5D,G,CAGGtB,qBACN,OAAOT,KAAKO,OAAS,gBAAkB,U,CAGzCyB,SACE,IAAKhC,KAAKgB,UAAW,CACnB,OACEiB,EAAA,OACEX,GAAI,GAAGtB,KAAKqB,0BACZa,MAAOlC,KAAKQ,gBACZ2B,MAAO,CAAEC,OAAQpC,KAAK8B,iBAEtBG,EAAA,a,CAKN,OACEA,EAACI,EAAI,gBAAeC,GAClBL,EAAA,OAAKC,MAAM,kBACTD,EAACjC,KAAKc,WAAU,CAACoB,MAAM,mBAAmBZ,GAAI,GAAGtB,KAAKqB,yBACpDY,EAAA,UACEC,MAAO,oBAAoBlC,KAAKO,OAAS,GAAK,cAC9CgC,KAAK,SAAQ,gBACE,GAAGvC,KAAKO,SAAQ,gBAChB,GAAGP,KAAKqB,0BACvBmB,QAASxC,KAAKyC,wBAEdR,EAAA,QAAMS,KAAK,aAGfT,EAAA,OACEX,GAAI,GAAGtB,KAAKqB,0BACZa,MAAO,sBAAsBlC,KAAKQ,kBAClC2B,MAAO,CAAEC,OAAQpC,KAAK8B,gBAAgB,kBACrB,GAAG9B,KAAKqB,yBAEzBY,EAAA,OAAKC,MAAM,kBACTD,EAAA,gB"}
@@ -1,2 +1,2 @@
1
- import{r as t,h as i,H as n,g as a}from"./p-0096c140.js";import{c as e,a as o,v as s}from"./p-05d38c8e.js";const l=[undefined,null,""];function r(t){return(...i)=>{const n=i[0];if(!l.some((t=>t===n)))t(...i)}}function c(t,i){if(l.some((i=>i===t))){throw new Error(i)}}const m=r(o);const h=r(e);const p=":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 0.75s ease-in-out infinite alternate}:host([animation=cylon-vertical]){animation:icon-animation-cylon-vertical 0.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 0.75s ease-in-out infinite alternate}:host([animation=throb]){animation:icon-animation-throb 0.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:0.1}to{opacity:1}}@keyframes icon-animation-spin{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes icon-animation-throb{from{opacity:0.5;transform:scale(0.5)}to{opacity:1;transform:scale(1)}}";const f="https://unpkg.com/@swisspost/design-system-icons/public/post-icons";const d=["cylon","cylon-vertical","spin","spin-reverse","fade","throb"];const u=[...d];const v=class{constructor(i){t(this,i);this.svgStyles=undefined;this.svgOutput=undefined;this.animation=null;this.base=null;this.flipH=false;this.flipV=false;this.name=undefined;this.rotate=null;this.scale=null}validateAnimation(t=this.animation){if(t!==undefined)m(t,u,`The post-icon "animation" prop requires one of the following values: ${u.join(", ")}.`)}validateBase(t=this.base){h(t,"string",'The post-icon "base" prop should be a string.')}validateFlipH(t=this.flipH){h(t,"boolean",'The post-icon "flipH" prop should be a boolean.')}validateFlipV(t=this.flipV){h(t,"boolean",'The post-icon "flipV" prop should be a boolean.')}validateName(t=this.name){c(t,'The post-icon "name" prop is required!.');e(t,"string",'The post-icon "name" prop should be a string.')}validateRotate(t=this.rotate){h(t,"number",'The post-icon "rotate" prop should be a number.')}validateScale(t=this.scale){h(t,"number",'The post-icon "scale" prop should be a number.')}componentWillLoad(){this.validateBase();this.validateName();this.validateFlipH();this.validateFlipV();this.validateScale();this.validateRotate();this.validateAnimation()}componentWillRender(){this.setPath()}setPath(){var t,i,n,a;const e=(i=(t=document.head.querySelector('meta[name="design-system-settings"][data-post-icon-base]'))===null||t===void 0?void 0:t.getAttribute("data-post-icon-base"))!==null&&i!==void 0?i:null;const o=`${(a=(n=this.base)!==null&&n!==void 0?n:e)!==null&&a!==void 0?a:f}/`.replace(/\/\/$/,"/");const s=`${this.name}.svg#icon`;const l=`${o}${s}`;this.path=new URL(l,window.location.origin).toString()}render(){const t=Object.entries({"-webkit-mask-image":`url('${this.path}')`,"mask-image":`url('${this.path}')`,scale:this.scale&&!isNaN(Number(this.scale))?`${this.scale}`:null,rotate:this.rotate&&!isNaN(Number(this.rotate))?`${this.rotate}deg`:null}).filter((([t,i])=>i!==null)).reduce(((t,[i,n])=>Object.assign(t,{[i]:n})),{});return i(n,{"data-version":s},i("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",style:t}))}get host(){return a(this)}static get watchers(){return{animation:["validateAnimation"],base:["validateBase"],flipH:["validateFlipH"],flipV:["validateFlipV"],name:["validateName"],rotate:["validateRotate"],scale:["validateScale"]}}};v.style=p;export{v as post_icon};
2
- //# sourceMappingURL=p-5cd6cb3a.entry.js.map
1
+ import{r as t,h as i,H as n,g as a}from"./p-0096c140.js";import{c as o,a as e,v as s}from"./p-4a3ff4c0.js";const l=[undefined,null,""];function r(t){return(...i)=>{const n=i[0];if(!l.some((t=>t===n)))t(...i)}}function c(t,i){if(l.some((i=>i===t))){throw new Error(i)}}const m=r(e);const h=r(o);const p=":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 0.75s ease-in-out infinite alternate}:host([animation=cylon-vertical]){animation:icon-animation-cylon-vertical 0.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 0.75s ease-in-out infinite alternate}:host([animation=throb]){animation:icon-animation-throb 0.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:0.1}to{opacity:1}}@keyframes icon-animation-spin{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes icon-animation-throb{from{opacity:0.5;transform:scale(0.5)}to{opacity:1;transform:scale(1)}}";const f="https://unpkg.com/@swisspost/design-system-icons/public/post-icons";const d=["cylon","cylon-vertical","spin","spin-reverse","fade","throb"];const u=[...d];const v=class{constructor(i){t(this,i);this.svgStyles=undefined;this.svgOutput=undefined;this.animation=null;this.base=null;this.flipH=false;this.flipV=false;this.name=undefined;this.rotate=null;this.scale=null}validateAnimation(t=this.animation){if(t!==undefined)m(t,u,`The post-icon "animation" prop requires one of the following values: ${u.join(", ")}.`)}validateBase(t=this.base){h(t,"string",'The post-icon "base" prop should be a string.')}validateFlipH(t=this.flipH){h(t,"boolean",'The post-icon "flipH" prop should be a boolean.')}validateFlipV(t=this.flipV){h(t,"boolean",'The post-icon "flipV" prop should be a boolean.')}validateName(t=this.name){c(t,'The post-icon "name" prop is required!.');o(t,"string",'The post-icon "name" prop should be a string.')}validateRotate(t=this.rotate){h(t,"number",'The post-icon "rotate" prop should be a number.')}validateScale(t=this.scale){h(t,"number",'The post-icon "scale" prop should be a number.')}componentWillLoad(){this.validateBase();this.validateName();this.validateFlipH();this.validateFlipV();this.validateScale();this.validateRotate();this.validateAnimation()}componentWillRender(){this.setPath()}setPath(){var t,i,n,a;const o=(i=(t=document.head.querySelector('meta[name="design-system-settings"][data-post-icon-base]'))===null||t===void 0?void 0:t.getAttribute("data-post-icon-base"))!==null&&i!==void 0?i:null;const e=`${(a=(n=this.base)!==null&&n!==void 0?n:o)!==null&&a!==void 0?a:f}/`.replace(/\/\/$/,"/");const s=`${this.name}.svg#icon`;const l=`${e}${s}`;this.path=new URL(l,window.location.origin).toString()}render(){const t=Object.entries({"-webkit-mask-image":`url('${this.path}')`,"mask-image":`url('${this.path}')`,scale:this.scale&&!isNaN(Number(this.scale))?`${this.scale}`:null,rotate:this.rotate&&!isNaN(Number(this.rotate))?`${this.rotate}deg`:null}).filter((([t,i])=>i!==null)).reduce(((t,[i,n])=>Object.assign(t,{[i]:n})),{});return i(n,{"data-version":s},i("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",style:t}))}get host(){return a(this)}static get watchers(){return{animation:["validateAnimation"],base:["validateBase"],flipH:["validateFlipH"],flipV:["validateFlipV"],name:["validateName"],rotate:["validateRotate"],scale:["validateScale"]}}};v.style=p;export{v as post_icon};
2
+ //# sourceMappingURL=p-cafa0281.entry.js.map
@@ -1,2 +1,2 @@
1
- import{p as e,b as a}from"./p-0096c140.js";export{s as setNonce}from"./p-0096c140.js";const l=()=>{const s=import.meta.url;const a={};if(s!==""){a.resourcesUrl=new URL(".",s).href}return e(a)};l().then((e=>a([["p-4eaaf8eb",[[1,"post-collapsible",{collapsed:[4],headingLevel:[2,"heading-level"],collapseClasses:[32],collapseHeight:[32],collapsibleId:[32],hasHeader:[32],headingTag:[32],isOpen:[32],onAccordionButtonClick:[32],toggle:[64]}]]],["p-5cd6cb3a",[[1,"post-icon",{animation:[1],base:[1],flipH:[4,"flip-h"],flipV:[4,"flip-v"],name:[1],rotate:[2],scale:[2],svgStyles:[32],svgOutput:[32]}]]]],e)));
1
+ import{p as e,b as a}from"./p-0096c140.js";export{s as setNonce}from"./p-0096c140.js";const l=()=>{const s=import.meta.url;const a={};if(s!==""){a.resourcesUrl=new URL(".",s).href}return e(a)};l().then((e=>a([["p-99ccf0cf",[[1,"post-collapsible",{collapsed:[4],headingLevel:[2,"heading-level"],collapseClasses:[32],collapseHeight:[32],collapsibleId:[32],hasHeader:[32],headingTag:[32],isOpen:[32],onAccordionButtonClick:[32],toggle:[64]}]]],["p-cafa0281",[[1,"post-icon",{animation:[1],base:[1],flipH:[4,"flip-h"],flipV:[4,"flip-v"],name:[1],rotate:[2],scale:[2],svgStyles:[32],svgOutput:[32]}]]]],e)));
2
2
  //# sourceMappingURL=post-components.esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swisspost/design-system-components",
3
- "version": "1.3.9",
3
+ "version": "1.3.10",
4
4
  "description": "A collection of web components built with Stencil JS for the Swiss Post Design System.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "loader/index.cjs.js",
@@ -25,10 +25,10 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@stencil/core": "3.4.2",
28
- "@swisspost/design-system-styles": "6.2.6"
28
+ "@swisspost/design-system-styles": "6.3.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@percy/cli": "1.26.2",
31
+ "@percy/cli": "1.26.3",
32
32
  "@percy/cypress": "3.1.2",
33
33
  "@stencil-community/eslint-plugin": "^0.5.0",
34
34
  "@stencil/react-output-target": "0.5.3",
@@ -37,16 +37,15 @@
37
37
  "@typescript-eslint/eslint-plugin": "5.62.0",
38
38
  "@typescript-eslint/parser": "5.62.0",
39
39
  "bootstrap": "5.3.1",
40
- "cypress": "12.17.2",
40
+ "cypress": "12.17.3",
41
41
  "cypress-storybook": "0.5.1",
42
- "eslint": "8.45.0",
43
- "eslint-plugin-react": "7.33.0",
42
+ "eslint": "8.47.0",
43
+ "eslint-plugin-react": "7.33.1",
44
44
  "jest": "27.5.1",
45
45
  "jest-cli": "27.5.1",
46
46
  "npm-run-all": "4.1.5",
47
- "puppeteer": "20.9.0",
48
47
  "rimraf": "5.0.1",
49
- "sass": "1.64.1",
48
+ "sass": "1.65.1",
50
49
  "typescript": "4.9.5"
51
50
  },
52
51
  "scripts": {
@@ -1,36 +0,0 @@
1
- import { EMPTY_VALUES } from '../constants';
2
- import { checkNonEmpty } from '../check-non-empty';
3
- const TEST_VALUES = [
4
- undefined,
5
- null,
6
- '',
7
- 'string',
8
- NaN,
9
- -1000,
10
- 0,
11
- 1000,
12
- false,
13
- true,
14
- {},
15
- [],
16
- () => {
17
- /* empty */
18
- },
19
- ];
20
- const NON_EMPTY_VALUES = TEST_VALUES.filter(tValue => !EMPTY_VALUES.some(eValue => eValue === tValue));
21
- describe('notEmpty', () => {
22
- const error = 'Is empty!';
23
- describe('empty value', () => {
24
- it('should not throw an error if the value is an non-empty value', () => {
25
- NON_EMPTY_VALUES.forEach(value => {
26
- expect(() => checkNonEmpty(value, error)).not.toThrow();
27
- });
28
- });
29
- it('should throw an error if the value is an empty value', () => {
30
- EMPTY_VALUES.forEach(value => {
31
- expect(() => checkNonEmpty(value, error)).toThrow(error);
32
- });
33
- });
34
- });
35
- });
36
- //# sourceMappingURL=check-non-empty.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-non-empty.spec.js","sourceRoot":"","sources":["../../../../../src/utils/property-checkers/tests/check-non-empty.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,GAAG;EAClB,SAAS;EACT,IAAI;EACJ,EAAE;EACF,QAAQ;EACR,GAAG;EACH,CAAC,IAAI;EACL,CAAC;EACD,IAAI;EACJ,KAAK;EACL,IAAI;EACJ,EAAE;EACF,EAAE;EACF,GAAG,EAAE;IACH,WAAW;EACb,CAAC;CACF,CAAC;AACF,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAM,CACzC,MAAM,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,CAC1D,CAAC;AAEF,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;EACxB,MAAM,KAAK,GAAG,WAAW,CAAC;EAE1B,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;MACtE,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC/B,MAAM,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;MAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;MAC9D,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC3B,MAAM,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;MAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { EMPTY_VALUES } from '../constants';\nimport { checkNonEmpty } from '../check-non-empty';\n\nconst TEST_VALUES = [\n undefined,\n null,\n '',\n 'string',\n NaN,\n -1000,\n 0,\n 1000,\n false,\n true,\n {},\n [],\n () => {\n /* empty */\n },\n];\nconst NON_EMPTY_VALUES = TEST_VALUES.filter(\n tValue => !EMPTY_VALUES.some(eValue => eValue === tValue),\n);\n\ndescribe('notEmpty', () => {\n const error = 'Is empty!';\n\n describe('empty value', () => {\n it('should not throw an error if the value is an non-empty value', () => {\n NON_EMPTY_VALUES.forEach(value => {\n expect(() => checkNonEmpty(value, error)).not.toThrow();\n });\n });\n\n it('should throw an error if the value is an empty value', () => {\n EMPTY_VALUES.forEach(value => {\n expect(() => checkNonEmpty(value, error)).toThrow(error);\n });\n });\n });\n});\n"]}
@@ -1,13 +0,0 @@
1
- import { checkOneOf } from '../check-one-of';
2
- describe('checkOneOf', () => {
3
- const possibleValues = ['A', 'B', 'C', 'D'];
4
- const error = 'Is not one of.';
5
- const runCheckForValue = value => () => checkOneOf(value, possibleValues, error);
6
- it('should not throw an error if the value is one of the possible values', () => {
7
- expect(runCheckForValue('A')).not.toThrow();
8
- });
9
- it('should throw the provided error if the value is not one of the possible values', () => {
10
- expect(runCheckForValue('E')).toThrow(error);
11
- });
12
- });
13
- //# sourceMappingURL=check-one-of.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-one-of.spec.js","sourceRoot":"","sources":["../../../../../src/utils/property-checkers/tests/check-one-of.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;EAC1B,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;EAC5C,MAAM,KAAK,GAAG,gBAAgB,CAAC;EAC/B,MAAM,gBAAgB,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;EAEjF,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;IAC9E,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;EAC9C,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,gFAAgF,EAAE,GAAG,EAAE;IACxF,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { checkOneOf } from '../check-one-of';\n\ndescribe('checkOneOf', () => {\n const possibleValues = ['A', 'B', 'C', 'D'];\n const error = 'Is not one of.';\n const runCheckForValue = value => () => checkOneOf(value, possibleValues, error);\n\n it('should not throw an error if the value is one of the possible values', () => {\n expect(runCheckForValue('A')).not.toThrow();\n });\n\n it('should throw the provided error if the value is not one of the possible values', () => {\n expect(runCheckForValue('E')).toThrow(error);\n });\n});\n"]}
@@ -1,103 +0,0 @@
1
- import { checkType } from '../check-type';
2
- describe('checkType', () => {
3
- let type;
4
- let error;
5
- const runCheckForValue = value => () => checkType(value, type, error);
6
- describe('boolean', () => {
7
- beforeAll(() => {
8
- type = 'boolean';
9
- error = 'Not a boolean.';
10
- });
11
- it('should not throw an error if the value is a boolean', () => {
12
- [true, false].forEach(boolean => {
13
- expect(runCheckForValue(boolean)).not.toThrow();
14
- });
15
- });
16
- it('should throw an error if the value is not a boolean', () => {
17
- [undefined, null, 42, NaN, 'string', [], {}, () => { }].forEach(nonBoolean => {
18
- expect(runCheckForValue(nonBoolean)).toThrow(error);
19
- });
20
- });
21
- });
22
- describe('number', () => {
23
- beforeAll(() => {
24
- type = 'number';
25
- error = 'Not a number.';
26
- });
27
- it('should not throw an error if the value is a number', () => {
28
- [42, 4.2, 4200, 2.4434634e9, NaN].forEach(number => {
29
- expect(runCheckForValue(number)).not.toThrow();
30
- });
31
- });
32
- it('should throw an error if the value is not a number', () => {
33
- [undefined, null, true, 'string', [], {}, () => { }].forEach(nonNumber => {
34
- expect(runCheckForValue(nonNumber)).toThrow(error);
35
- });
36
- });
37
- });
38
- describe('string', () => {
39
- beforeAll(() => {
40
- type = 'string';
41
- error = 'Not a string.';
42
- });
43
- it('should not throw an error if the value is a string', () => {
44
- ['', 'string', '42', '¡¡Olé 🙌!!'].forEach(string => {
45
- expect(runCheckForValue(string)).not.toThrow();
46
- });
47
- });
48
- it('should throw an error if the value is not string', () => {
49
- [undefined, null, true, 42, NaN, [], {}, () => { }].forEach(nonString => {
50
- expect(runCheckForValue(nonString)).toThrow(error);
51
- });
52
- });
53
- });
54
- describe('array', () => {
55
- beforeAll(() => {
56
- type = 'array';
57
- error = 'Not an array.';
58
- });
59
- it('should not throw an error if the value is an array', () => {
60
- [[], [1, 'a']].forEach(array => {
61
- expect(runCheckForValue(array)).not.toThrow();
62
- });
63
- });
64
- it('should throw an error if the value is not an array', () => {
65
- [undefined, null, true, 42, NaN, 'string', {}, () => { }].forEach(nonArray => {
66
- expect(runCheckForValue(nonArray)).toThrow(error);
67
- });
68
- });
69
- });
70
- describe('object', () => {
71
- beforeAll(() => {
72
- type = 'object';
73
- error = 'Not an object.';
74
- });
75
- it('should not throw an error if the value is an object', () => {
76
- [null, {}].forEach(object => {
77
- expect(runCheckForValue(object)).not.toThrow();
78
- });
79
- });
80
- it('should throw an error if the value is not an object', () => {
81
- [undefined, true, 42, NaN, 'string', () => { }].forEach(nonObject => {
82
- expect(runCheckForValue(nonObject)).toThrow(error);
83
- });
84
- });
85
- });
86
- describe('function', () => {
87
- beforeAll(() => {
88
- type = 'function';
89
- error = 'Not a function.';
90
- });
91
- it('should not throw an error if the value is a function', () => {
92
- [function () { }, () => { }].forEach(fn => {
93
- expect(runCheckForValue(fn)).not.toThrow();
94
- });
95
- });
96
- it('should throw an error if the value is not a function', () => {
97
- [undefined, null, true, 42, NaN, 'string', [], {}].forEach(nonFn => {
98
- expect(runCheckForValue(nonFn)).toThrow(error);
99
- });
100
- });
101
- });
102
- });
103
- //# sourceMappingURL=check-type.spec.js.map
@@ -1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AAC,EAAE;QACjE,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;MACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { checkType, PropertyType } from '../check-type';\n\ndescribe('checkType', () => {\n let type: PropertyType;\n let error: string;\n const runCheckForValue = value => () => checkType(value, type, error);\n\n describe('boolean', () => {\n beforeAll(() => {\n type = 'boolean';\n error = 'Not a boolean.';\n });\n\n it('should not throw an error if the value is a boolean', () => {\n [true, false].forEach(boolean => {\n expect(runCheckForValue(boolean)).not.toThrow();\n });\n });\n\n it('should throw an error if the value is not a boolean', () => {\n [undefined, null, 42, NaN, 'string', [], {}, () => {/* empty */}].forEach(nonBoolean => {\n expect(runCheckForValue(nonBoolean)).toThrow(error);\n });\n });\n });\n\n describe('number', () => {\n beforeAll(() => {\n type = 'number';\n error = 'Not a number.';\n });\n\n it('should not throw an error if the value is a number', () => {\n [ 42, 4.2, 4_200, 2.4434634e9, NaN ].forEach(number => {\n expect(runCheckForValue(number)).not.toThrow();\n });\n });\n\n it('should throw an error if the value is not a number', () => {\n [undefined, null, true, 'string', [], {}, () => {/* empty */}].forEach(nonNumber => {\n expect(runCheckForValue(nonNumber)).toThrow(error);\n });\n });\n });\n\n describe('string', () => {\n beforeAll(() => {\n type = 'string';\n error = 'Not a string.';\n });\n\n it('should not throw an error if the value is a string', () => {\n ['', 'string', '42', '¡¡Olé 🙌!!'].forEach(string => {\n expect(runCheckForValue(string)).not.toThrow();\n });\n });\n\n it('should throw an error if the value is not string', () => {\n [undefined, null, true, 42, NaN, [], {}, () => {/* empty */}].forEach(nonString => {\n expect(runCheckForValue(nonString)).toThrow(error);\n });\n });\n });\n\n describe('array', () => {\n beforeAll(() => {\n type = 'array';\n error = 'Not an array.';\n });\n\n it('should not throw an error if the value is an array', () => {\n [[], [1, 'a']].forEach(array => {\n expect(runCheckForValue(array)).not.toThrow();\n });\n });\n\n it('should throw an error if the value is not an array', () => {\n [undefined, null, true, 42, NaN, 'string', {}, () => {/* empty */}].forEach(nonArray => {\n expect(runCheckForValue(nonArray)).toThrow(error);\n });\n });\n });\n\n describe('object', () => {\n beforeAll(() => {\n type = 'object';\n error = 'Not an object.';\n });\n\n it('should not throw an error if the value is an object', () => {\n [null, {}].forEach(object => {\n expect(runCheckForValue(object)).not.toThrow();\n });\n });\n\n it('should throw an error if the value is not an object', () => {\n [undefined, true, 42, NaN, 'string', () => {/* empty */}].forEach(nonObject => {\n expect(runCheckForValue(nonObject)).toThrow(error);\n });\n });\n });\n\n describe('function', () => {\n beforeAll(() => {\n type = 'function';\n error = 'Not a function.';\n });\n\n it('should not throw an error if the value is a function', () => {\n [function () {/* empty */}, () => {/* empty */}].forEach(fn => {\n expect(runCheckForValue(fn)).not.toThrow();\n });\n });\n\n it('should throw an error if the value is not a function', () => {\n [undefined, null, true, 42, NaN, 'string', [], {}].forEach(nonFn => {\n expect(runCheckForValue(nonFn)).toThrow(error);\n });\n });\n });\n});\n"]}
@@ -1,23 +0,0 @@
1
- import { emptyOr } from '../empty-or';
2
- describe('emptyOr', () => {
3
- const mockCheck = jest.fn();
4
- const mockEmptyOrCheck = emptyOr(mockCheck);
5
- it('should not run the check if the provided value is empty', () => {
6
- [undefined, null, ''].forEach(emptyValue => {
7
- mockEmptyOrCheck(emptyValue);
8
- expect(mockCheck).not.toHaveBeenCalled();
9
- });
10
- });
11
- it('should run the check if the provided value is not empty', () => {
12
- [0, NaN, ' ', false, [], {}, () => { }].forEach((nonEmptyValue, index) => {
13
- mockEmptyOrCheck(nonEmptyValue);
14
- expect(mockCheck).toHaveBeenCalledTimes(index + 1);
15
- });
16
- });
17
- it('should pass all provided arguments to the nested check function', () => {
18
- const args = ['non empty value', true, false, ['arg in an array'], { arg: 'in an object' }];
19
- mockEmptyOrCheck(...args);
20
- expect(mockCheck).toHaveBeenCalledWith(...args);
21
- });
22
- });
23
- //# sourceMappingURL=empty-or.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"empty-or.spec.js","sourceRoot":"","sources":["../../../../../src/utils/property-checkers/tests/empty-or.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;EACvB,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;EAC5B,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;EAE5C,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;IACjE,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;MACzC,gBAAgB,CAAC,UAAU,CAAC,CAAC;MAC7B,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;IACjE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,KAAK,EAAE,EAAE;MACjF,gBAAgB,CAAC,aAAa,CAAC,CAAC;MAChC,MAAM,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;IACzE,MAAM,IAAI,GAAG,CAAC,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,iBAAiB,CAAC,EAAE,EAAC,GAAG,EAAE,cAAc,EAAC,CAAC,CAAC;IAC1F,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1B,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,CAAC;EAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { emptyOr } from '../empty-or';\n\ndescribe('emptyOr', () => {\n const mockCheck = jest.fn();\n const mockEmptyOrCheck = emptyOr(mockCheck);\n\n it('should not run the check if the provided value is empty', () => {\n [undefined, null, ''].forEach(emptyValue => {\n mockEmptyOrCheck(emptyValue);\n expect(mockCheck).not.toHaveBeenCalled();\n });\n });\n\n it('should run the check if the provided value is not empty', () => {\n [0, NaN, ' ', false, [], {}, () => {/* empty */}].forEach((nonEmptyValue, index) => {\n mockEmptyOrCheck(nonEmptyValue);\n expect(mockCheck).toHaveBeenCalledTimes(index + 1);\n });\n });\n\n it('should pass all provided arguments to the nested check function', () => {\n const args = ['non empty value', true, false, ['arg in an array'], {arg: 'in an object'}];\n mockEmptyOrCheck(...args);\n expect(mockCheck).toHaveBeenCalledWith(...args);\n });\n});\n"]}
@@ -1,16 +0,0 @@
1
- import { shouldReduceMotion } from '../should-reduce-motion';
2
- describe('shouldReduceMotion', () => {
3
- let matchMedia;
4
- beforeEach(() => {
5
- matchMedia = window.matchMedia = jest.fn();
6
- });
7
- it('should return true if reduced motion is requested', () => {
8
- matchMedia.mockReturnValue({ matches: true });
9
- expect(shouldReduceMotion()).toBe(true);
10
- });
11
- it('should return false if reduced motion is not requested', () => {
12
- matchMedia.mockReturnValue({ matches: false });
13
- expect(shouldReduceMotion()).toBe(false);
14
- });
15
- });
16
- //# sourceMappingURL=should-reduce-motion.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"should-reduce-motion.spec.js","sourceRoot":"","sources":["../../../../src/utils/tests/should-reduce-motion.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;EAClC,IAAI,UAAU,CAAC;EAEf,UAAU,CAAC,GAAG,EAAE;IACd,UAAU,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;EAC7C,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;IAC3D,UAAU,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;EAC1C,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;IAChE,UAAU,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC3C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { shouldReduceMotion } from '../should-reduce-motion';\n\ndescribe('shouldReduceMotion', () => {\n let matchMedia;\n\n beforeEach(() => {\n matchMedia = window.matchMedia = jest.fn();\n });\n\n it('should return true if reduced motion is requested', () => {\n matchMedia.mockReturnValue({ matches: true });\n expect(shouldReduceMotion()).toBe(true);\n });\n\n it('should return false if reduced motion is not requested', () => {\n matchMedia.mockReturnValue({ matches: false });\n expect(shouldReduceMotion()).toBe(false);\n });\n});\n"]}