@swisspost/design-system-components 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cjs/check-type-f24cf91d.js +24 -0
  2. package/dist/cjs/check-type-f24cf91d.js.map +1 -0
  3. package/dist/cjs/{index-8880977f.js → index-a8b23f1b.js} +1 -1
  4. package/dist/cjs/{index-8880977f.js.map → index-a8b23f1b.js.map} +1 -1
  5. package/dist/cjs/loader.cjs.js +3 -3
  6. package/dist/cjs/loader.cjs.js.map +1 -1
  7. package/dist/cjs/post-collapsible.cjs.entry.js +11 -19
  8. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  9. package/dist/cjs/post-components.cjs.js +3 -3
  10. package/dist/cjs/post-components.cjs.js.map +1 -1
  11. package/dist/cjs/post-icon.cjs.entry.js +39 -29
  12. package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
  13. package/dist/collection/collection-manifest.json +1 -1
  14. package/dist/collection/components/post-collapsible/post-collapsible.css +876 -3642
  15. package/dist/collection/components/post-collapsible/post-collapsible.js +12 -10
  16. package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -1
  17. package/dist/collection/components/post-icon/post-icon.js +41 -46
  18. package/dist/collection/components/post-icon/post-icon.js.map +1 -1
  19. package/dist/collection/utils/get-element-height.js +0 -3
  20. package/dist/collection/utils/get-element-height.js.map +1 -1
  21. package/dist/collection/utils/index.js +0 -3
  22. package/dist/collection/utils/index.js.map +1 -1
  23. package/dist/collection/utils/on-transition-end.js +0 -3
  24. package/dist/collection/utils/on-transition-end.js.map +1 -1
  25. package/dist/collection/utils/property-checkers/check-one-of.js +5 -0
  26. package/dist/collection/utils/property-checkers/check-one-of.js.map +1 -0
  27. package/dist/collection/utils/property-checkers/check-type.js +13 -0
  28. package/dist/collection/utils/property-checkers/check-type.js.map +1 -0
  29. package/dist/collection/utils/property-checkers/empty-or.js +9 -0
  30. package/dist/collection/utils/property-checkers/empty-or.js.map +1 -0
  31. package/dist/collection/utils/property-checkers/index.js +8 -0
  32. package/dist/collection/utils/property-checkers/index.js.map +1 -0
  33. package/dist/collection/utils/should-reduce-motion.js +0 -3
  34. package/dist/collection/utils/should-reduce-motion.js.map +1 -1
  35. package/dist/components/check-type.js +21 -0
  36. package/dist/components/check-type.js.map +1 -0
  37. package/dist/components/post-collapsible.js +12 -19
  38. package/dist/components/post-collapsible.js.map +1 -1
  39. package/dist/components/post-icon.js +37 -30
  40. package/dist/components/post-icon.js.map +1 -1
  41. package/dist/docs.json +2 -2
  42. package/dist/esm/check-type-67411ed3.js +21 -0
  43. package/dist/esm/check-type-67411ed3.js.map +1 -0
  44. package/dist/esm/{index-6d5a72fa.js → index-401f2d6a.js} +1 -1
  45. package/dist/esm/{index-6d5a72fa.js.map → index-401f2d6a.js.map} +1 -1
  46. package/dist/esm/loader.js +4 -4
  47. package/dist/esm/loader.js.map +1 -1
  48. package/dist/esm/post-collapsible.entry.js +10 -18
  49. package/dist/esm/post-collapsible.entry.js.map +1 -1
  50. package/dist/esm/post-components.js +4 -4
  51. package/dist/esm/post-components.js.map +1 -1
  52. package/dist/esm/post-icon.entry.js +35 -25
  53. package/dist/esm/post-icon.entry.js.map +1 -1
  54. package/dist/post-components/p-07a51673.entry.js +2 -0
  55. package/dist/post-components/p-07a51673.entry.js.map +1 -0
  56. package/dist/post-components/p-416f1e74.entry.js +2 -0
  57. package/dist/post-components/p-416f1e74.entry.js.map +1 -0
  58. package/dist/post-components/{p-a93114b9.js → p-f214c52a.js} +1 -1
  59. package/dist/post-components/{p-a93114b9.js.map → p-f214c52a.js.map} +1 -1
  60. package/dist/post-components/p-f549b3fc.js +2 -0
  61. package/dist/post-components/p-f549b3fc.js.map +1 -0
  62. package/dist/post-components/post-components.esm.js +1 -1
  63. package/dist/post-components/post-components.esm.js.map +1 -1
  64. package/dist/types/components/post-collapsible/post-collapsible.d.ts +14 -13
  65. package/dist/types/components/post-icon/post-icon.d.ts +22 -22
  66. package/dist/types/utils/property-checkers/check-one-of.d.ts +1 -0
  67. package/dist/types/utils/property-checkers/check-type.d.ts +2 -0
  68. package/dist/types/utils/property-checkers/empty-or.d.ts +1 -0
  69. package/dist/types/utils/property-checkers/index.d.ts +4 -0
  70. package/package.json +15 -9
  71. package/dist/cjs/property-checkers-586ad9d4.js +0 -40
  72. package/dist/cjs/property-checkers-586ad9d4.js.map +0 -1
  73. package/dist/collection/utils/property-checkers.js +0 -31
  74. package/dist/collection/utils/property-checkers.js.map +0 -1
  75. package/dist/components/property-checkers.js +0 -34
  76. package/dist/components/property-checkers.js.map +0 -1
  77. package/dist/esm/property-checkers-484ca671.js +0 -34
  78. package/dist/esm/property-checkers-484ca671.js.map +0 -1
  79. package/dist/post-components/p-7cd9c1ad.js +0 -2
  80. package/dist/post-components/p-7cd9c1ad.js.map +0 -1
  81. package/dist/post-components/p-b07185a3.entry.js +0 -2
  82. package/dist/post-components/p-b07185a3.entry.js.map +0 -1
  83. package/dist/post-components/p-c4af958b.entry.js +0 -2
  84. package/dist/post-components/p-c4af958b.entry.js.map +0 -1
  85. package/dist/types/utils/property-checkers.d.ts +0 -5
@@ -1,20 +1,21 @@
1
1
  import { h } from '@stencil/core';
2
- import { checkBoolean, checkOneOf, getElementHeight, onTransitionEnd } from '../../utils';
2
+ import { checkOneOf, checkType, getElementHeight, onTransitionEnd } from '../../utils';
3
3
  let nextId = 0;
4
4
  export class PostCollapsible {
5
5
  constructor() {
6
6
  this.isLoaded = false;
7
- this.collapsed = false;
8
- this.headingLevel = 2;
9
- this.isOpen = true;
10
7
  this.collapseClasses = undefined;
11
8
  this.collapseHeight = null;
12
- this.headingTag = undefined;
13
9
  this.collapsibleId = undefined;
14
10
  this.hasHeader = undefined;
11
+ this.headingTag = undefined;
12
+ this.isOpen = true;
13
+ this.onAccordionButtonClick = () => this.toggle();
14
+ this.collapsed = false;
15
+ this.headingLevel = 2;
15
16
  }
16
17
  validateCollapsed(newValue = this.collapsed) {
17
- checkBoolean(newValue, 'The post-collapsible "collapsed" prop should be a boolean.');
18
+ checkType(newValue, 'boolean', 'The post-collapsible "collapsed" prop should be a boolean.');
18
19
  if (!this.isLoaded) {
19
20
  this.isOpen = !newValue;
20
21
  this.collapseClasses = this.getCollapseClasses();
@@ -72,7 +73,7 @@ export class PostCollapsible {
72
73
  if (!this.hasHeader) {
73
74
  return (h("div", { id: `${this.collapsibleId}--collapse`, class: this.collapseClasses, style: { height: this.collapseHeight } }, h("slot", null)));
74
75
  }
75
- return (h("div", { class: "accordion-item" }, h(this.headingTag, { class: "accordion-header", id: `${this.collapsibleId}--header` }, h("button", { class: `accordion-button ${this.isOpen ? '' : 'collapsed'}`, type: "button", "aria-expanded": `${this.isOpen}`, "aria-controls": `${this.collapsibleId}--collapse`, onClick: () => this.toggle() }, h("slot", { name: "header" }))), h("div", { id: `${this.collapsibleId}--collapse`, class: `accordion-collapse ${this.collapseClasses}`, style: { height: this.collapseHeight }, "aria-labelledby": `${this.collapsibleId}--header` }, h("div", { class: "accordion-body" }, h("slot", null)))));
76
+ return (h("div", { class: "accordion-item" }, h(this.headingTag, { class: "accordion-header", id: `${this.collapsibleId}--header` }, h("button", { class: `accordion-button ${this.isOpen ? '' : 'collapsed'}`, type: "button", "aria-expanded": `${this.isOpen}`, "aria-controls": `${this.collapsibleId}--collapse`, onClick: this.onAccordionButtonClick }, h("slot", { name: "header" }))), h("div", { id: `${this.collapsibleId}--collapse`, class: `accordion-collapse ${this.collapseClasses}`, style: { height: this.collapseHeight }, "aria-labelledby": `${this.collapsibleId}--header` }, h("div", { class: "accordion-body" }, h("slot", null)))));
76
77
  }
77
78
  static get is() { return "post-collapsible"; }
78
79
  static get encapsulation() { return "shadow"; }
@@ -128,12 +129,13 @@ export class PostCollapsible {
128
129
  }
129
130
  static get states() {
130
131
  return {
131
- "isOpen": {},
132
132
  "collapseClasses": {},
133
133
  "collapseHeight": {},
134
- "headingTag": {},
135
134
  "collapsibleId": {},
136
- "hasHeader": {}
135
+ "hasHeader": {},
136
+ "headingTag": {},
137
+ "isOpen": {},
138
+ "onAccordionButtonClick": {}
137
139
  };
138
140
  }
139
141
  static get methods() {
@@ -1 +1 @@
1
- {"version":3,"file":"post-collapsible.js","sourceRoot":"","sources":["../../../src/components/post-collapsible/post-collapsible.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1F,IAAI,MAAM,GAAG,CAAC,CAAC;AAOf,MAAM,OAAO,eAAe;;IAoB1B,aAAQ,GAAG,KAAK,CAAC;qBAhBa,KAAK;wBAKH,CAAC;kBAEf,IAAI;;0BAEmB,IAAI;;;;;EAW7C,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS;IACzC,YAAY,CAAC,QAAQ,EAAE,4DAA4D,CAAC,CAAC;IAErF,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAClB,IAAI,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC;MACxB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAClD;SAAM;MACL,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;MACzB,CAAC,CAAC,CAAC;KACJ;EACH,CAAC;EAGD,oBAAoB,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY;IAC/C,UAAU,CACR,QAAQ,EACR,CAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,EACpB,wEAAwE,CACzE,CAAC;IAEF,IAAI,CAAC,UAAU,GAAG,IAAI,QAAQ,EAAE,CAAC;EACnC,CAAC;EAED,iBAAiB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AAE,sBAAsB,IAAI,CAAC,eAAe,EAAE,EACnD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,qBACrB,GAAG,IAAI,CAAC,aAAa,UAAU;QAEhD,WAAK,KAAK,EAAC,gBAAgB;UACzB,eAAO,CACH,CACF,CACF,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { checkBoolean, checkOneOf, getElementHeight, onTransitionEnd } from '../../utils';\n\nlet nextId = 0;\n\n@Component({\n tag: 'post-collapsible',\n styleUrl: 'post-collapsible.scss',\n shadow: true,\n})\nexport class PostCollapsible {\n /**\n * If `true`, the element is initially collapsed otherwise it is displayed.\n */\n @Prop() collapsed?: boolean = false;\n\n /**\n * Defines the hierarchical level of the collapsible header within the headings structure.\n */\n @Prop() headingLevel?: number = 2;\n\n @State() isOpen = true;\n @State() collapseClasses: string;\n @State() collapseHeight: string | null = null;\n @State() headingTag: string | undefined;\n @State() collapsibleId: string;\n @State() hasHeader: boolean;\n\n @Element() host: HTMLElement;\n\n isLoaded = false;\n collapsibleElement: HTMLElement;\n\n @Watch('collapsed')\n validateCollapsed(newValue = this.collapsed) {\n checkBoolean(newValue, '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 @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('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 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(`#${this.collapsibleId}--collapse`);\n }\n\n /**\n * Triggers the collapse programmatically.\n */\n @Method()\n async toggle(open: boolean = !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 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 <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.toggle()}\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 );\n }\n}\n"]}
1
+ {"version":3,"file":"post-collapsible.js","sourceRoot":"","sources":["../../../src/components/post-collapsible/post-collapsible.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEvF,IAAI,MAAM,GAAG,CAAC,CAAC;AAOf,MAAM,OAAO,eAAe;;IAElB,aAAQ,GAAG,KAAK,CAAC;;0BAKgB,IAAI;;;;kBAI3B,IAAI;kCACY,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE;qBAKd,KAAK;wBAmBH,CAAC;;EAhB1C,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS;IACzC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,4DAA4D,CAAC,CAAC;IAE7F,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;MAClB,IAAI,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC;MACxB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAClD;SAAM;MACL,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;MACzB,CAAC,CAAC,CAAC;KACJ;EACH,CAAC;EAQD,oBAAoB,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY;IAC/C,UAAU,CACR,QAAQ,EACR,CAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,EACpB,wEAAwE,CACzE,CAAC;IAEF,IAAI,CAAC,UAAU,GAAG,IAAI,QAAQ,EAAE,CAAC;EACnC,C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K,EAAE,sBAAsB,IAAI,CAAC,eAAe,EAAE,EACnD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,qBACrB,GAAG,IAAI,CAAC,aAAa,UAAU;QAEhD,WAAK,KAAK,EAAC,gBAAgB;UACzB,eAAO,CACH,CACF,CACF,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { checkOneOf, checkType, getElementHeight, onTransitionEnd } from '../../utils';\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('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 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(`#${this.collapsibleId}--collapse`);\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 <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 );\n }\n}\n"]}
@@ -14,20 +14,19 @@ const ANIMATION_KEYS = [
14
14
  */
15
15
  export class PostIcon {
16
16
  constructor() {
17
- this.name = undefined;
17
+ this.svgSource = '<svg viewBox="0 0 16 16"></svg>';
18
+ this.svgOutput = undefined;
19
+ this.animation = undefined;
18
20
  this.base = undefined;
19
21
  this.flipH = undefined;
20
22
  this.flipV = undefined;
21
- this.scale = undefined;
23
+ this.name = undefined;
22
24
  this.rotate = undefined;
23
- this.animation = undefined;
24
- this.initialPath = undefined;
25
- this.path = undefined;
26
- this.svgSource = '<svg viewBox="0 0 16 16"></svg>';
27
- this.svgOutput = undefined;
25
+ this.scale = undefined;
28
26
  }
29
- validateName(newValue = this.name) {
30
- checkType(newValue, 'string', 'The post-icon "name" prop should be a string.');
27
+ validateAnimation(newValue = this.animation) {
28
+ if (newValue !== undefined)
29
+ checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon "animation" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);
31
30
  }
32
31
  validateBase(newValue = this.base) {
33
32
  checkEmptyOrType(newValue, 'string', 'The post-icon "base" prop should be a string.');
@@ -38,15 +37,14 @@ export class PostIcon {
38
37
  validateFlipV(newValue = this.flipV) {
39
38
  checkEmptyOrType(newValue, 'boolean', 'The post-icon "flipV" prop should be a boolean.');
40
39
  }
41
- validateScale(newValue = this.scale) {
42
- checkEmptyOrType(newValue, 'number', 'The post-icon "scale" prop should be a number.');
40
+ validateName(newValue = this.name) {
41
+ checkType(newValue, 'string', 'The post-icon "name" prop should be a string.');
43
42
  }
44
43
  validateRotate(newValue = this.rotate) {
45
44
  checkEmptyOrType(newValue, 'number', 'The post-icon "rotate" prop should be a number.');
46
45
  }
47
- validateAnimation(newValue = this.animation) {
48
- if (newValue !== undefined)
49
- checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon "animation" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);
46
+ validateScale(newValue = this.scale) {
47
+ checkEmptyOrType(newValue, 'number', 'The post-icon "scale" prop should be a number.');
50
48
  }
51
49
  connectedCallback() {
52
50
  var _a;
@@ -66,13 +64,13 @@ export class PostIcon {
66
64
  this.svgSource = (_a = window.localStorage.getItem(`post-icon-${this.name}`)) !== null && _a !== void 0 ? _a : this.svgSource;
67
65
  }
68
66
  componentWillLoad() {
69
- this.validateName();
67
+ this.validateAnimation();
70
68
  this.validateBase();
71
69
  this.validateFlipH();
72
70
  this.validateFlipV();
73
- this.validateScale();
71
+ this.validateName();
74
72
  this.validateRotate();
75
- this.validateAnimation();
73
+ this.validateScale();
76
74
  this.fetchSVG();
77
75
  }
78
76
  componentWillRender() {
@@ -89,9 +87,6 @@ export class PostIcon {
89
87
  svgElement.setAttribute('style', svgStyles);
90
88
  this.svgOutput = helperElement.innerHTML;
91
89
  }
92
- getPath(basePath) {
93
- return new URL([...basePath.split('/'), `${this.name}.svg#icon`].join('/'), window.location.origin).toString();
94
- }
95
90
  fetchSVG() {
96
91
  fetch(this.path)
97
92
  .then(response => response.text())
@@ -117,6 +112,9 @@ export class PostIcon {
117
112
  console.log(error);
118
113
  });
119
114
  }
115
+ getPath(basePath) {
116
+ return new URL([...basePath.split('/'), `${this.name}.svg#icon`].join('/'), window.location.origin).toString();
117
+ }
120
118
  render() {
121
119
  return (h(Host, null, h("div", { innerHTML: this.svgOutput })));
122
120
  }
@@ -134,7 +132,7 @@ export class PostIcon {
134
132
  }
135
133
  static get properties() {
136
134
  return {
137
- "name": {
135
+ "animation": {
138
136
  "type": "string",
139
137
  "mutable": false,
140
138
  "complexType": {
@@ -143,12 +141,12 @@ export class PostIcon {
143
141
  "references": {}
144
142
  },
145
143
  "required": false,
146
- "optional": false,
144
+ "optional": true,
147
145
  "docs": {
148
146
  "tags": [],
149
- "text": "The name/id of the icon (e.g. 1000, 1001, ...)."
147
+ "text": "The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`)."
150
148
  },
151
- "attribute": "name",
149
+ "attribute": "animation",
152
150
  "reflect": false
153
151
  },
154
152
  "base": {
@@ -202,21 +200,21 @@ export class PostIcon {
202
200
  "attribute": "flip-v",
203
201
  "reflect": false
204
202
  },
205
- "scale": {
206
- "type": "number",
203
+ "name": {
204
+ "type": "string",
207
205
  "mutable": false,
208
206
  "complexType": {
209
- "original": "number",
210
- "resolved": "number",
207
+ "original": "string",
208
+ "resolved": "string",
211
209
  "references": {}
212
210
  },
213
211
  "required": false,
214
- "optional": true,
212
+ "optional": false,
215
213
  "docs": {
216
214
  "tags": [],
217
- "text": "The `number` for the css `scale` transformation."
215
+ "text": "The name/id of the icon (e.g. 1000, 1001, ...)."
218
216
  },
219
- "attribute": "scale",
217
+ "attribute": "name",
220
218
  "reflect": false
221
219
  },
222
220
  "rotate": {
@@ -236,37 +234,34 @@ export class PostIcon {
236
234
  "attribute": "rotate",
237
235
  "reflect": false
238
236
  },
239
- "animation": {
240
- "type": "string",
237
+ "scale": {
238
+ "type": "number",
241
239
  "mutable": false,
242
240
  "complexType": {
243
- "original": "string",
244
- "resolved": "string",
241
+ "original": "number",
242
+ "resolved": "number",
245
243
  "references": {}
246
244
  },
247
245
  "required": false,
248
246
  "optional": true,
249
247
  "docs": {
250
248
  "tags": [],
251
- "text": "The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`)."
249
+ "text": "The `number` for the css `scale` transformation."
252
250
  },
253
- "attribute": "animation",
251
+ "attribute": "scale",
254
252
  "reflect": false
255
253
  }
256
254
  };
257
255
  }
258
256
  static get states() {
259
257
  return {
260
- "initialPath": {},
261
- "path": {},
262
- "svgSource": {},
263
258
  "svgOutput": {}
264
259
  };
265
260
  }
266
261
  static get watchers() {
267
262
  return [{
268
- "propName": "name",
269
- "methodName": "validateName"
263
+ "propName": "animation",
264
+ "methodName": "validateAnimation"
270
265
  }, {
271
266
  "propName": "base",
272
267
  "methodName": "validateBase"
@@ -277,14 +272,14 @@ export class PostIcon {
277
272
  "propName": "flipV",
278
273
  "methodName": "validateFlipV"
279
274
  }, {
280
- "propName": "scale",
281
- "methodName": "validateScale"
275
+ "propName": "name",
276
+ "methodName": "validateName"
282
277
  }, {
283
278
  "propName": "rotate",
284
279
  "methodName": "validateRotate"
285
280
  }, {
286
- "propName": "animation",
287
- "methodName": "validateAnimation"
281
+ "propName": "scale",
282
+ "methodName": "validateScale"
288
283
  }];
289
284
  }
290
285
  }
@@ -1 +1 @@
1
- {"version":3,"file":"post-icon.js","sourceRoot":"","sources":["../../../src/components/post-icon/post-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE7E,MAAM,OAAO,GAAG,oEAAoE,CAAC;AACrF,MAAM,cAAc,GAAG;EACrB,OAAO;EACP,gBAAgB;EAChB,MAAM;EACN,cAAc;EACd,MAAM;EACN,OAAO;CACR,CAAC;AAEF;;GAEG;AAMH,MAAM,OAAO,QAAQ;;;;;;;;;;;qBAqCU,iCAAiC;;;EAI9D,YAAY,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI;IAC/B,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,+CAA+C,CAAC,CAAC;EACjF,CAAC;EAGD,YAAY,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI;IAC/B,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,+CAA+C,CAAC,CAAC;EACxF,CAAC;EAGD,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK;IACjC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,iDAAiD,CAAC,CAAC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AC,CAAC,CAAC;EACP,CAAC;EAED,MAAM;IACJ,OAAO,CACL,EAAC,IAAI;MACH,WAAK,SAAS,EAAE,IAAI,CAAC,SAAS,GAAI,CAC7B,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Watch } from '@stencil/core';\nimport { checkType, checkEmptyOrType, checkEmptyOrOneOf } from '../../utils';\n\nconst CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';\nconst ANIMATION_KEYS = [\n 'cylon',\n 'cylon-vertical',\n 'spin',\n 'spin-reverse',\n 'fade',\n 'throb'\n];\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 /**\n * The name/id of the icon (e.g. 1000, 1001, ...).\n */\n @Prop() name: string;\n\n /**\n * The base path, where the icons are located (must be a public url).\n */\n @Prop() base?: string;\n\n /**\n * When set to `true`, the icon will be flipped horizontally.\n */\n @Prop() flipH?: boolean;\n\n /**\n * When set to `true`, the icon will be flipped vertically.\n */\n @Prop() flipV?: boolean;\n\n /**\n * The `number` for the css `scale` transformation.\n */\n @Prop() scale?: number;\n\n /**\n * The `number` of degree for the css `rotate` transformation.\n */\n @Prop() rotate?: number;\n\n /**\n * The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`).\n */\n @Prop() animation?: string;\n @State() initialPath: string;\n @State() path: string;\n @State() svgSource: string = '<svg viewBox=\"0 0 16 16\"></svg>';\n @State() svgOutput: string;\n\n @Watch('name')\n validateName(newValue = this.name) {\n checkType(newValue, 'string', 'The post-icon \"name\" prop should be a string.');\n }\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 @Watch('flipH')\n validateFlipH(newValue = this.flipH) {\n checkEmptyOrType(newValue, 'boolean', 'The post-icon \"flipH\" prop should be a boolean.');\n }\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 @Watch('scale')\n validateScale(newValue = this.scale) {\n checkEmptyOrType(newValue, 'number', 'The post-icon \"scale\" prop should be a number.');\n }\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 @Watch('animation')\n validateAnimation(newValue = this.animation) {\n if (newValue !== undefined) checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon \"animation\" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);\n }\n\n connectedCallback() {\n // Construct icon path from different possible sources\n let basePath: string;\n const metaBase = document.head.querySelector(\n 'meta[name=\"design-system-settings\"][data-post-icon-base]',\n );\n\n if (this.base) {\n basePath = this.base;\n } else if (metaBase) {\n basePath = metaBase.getAttribute('data-post-icon-base');\n } else {\n basePath = CDN_URL;\n }\n\n this.path = this.getPath(basePath);\n this.svgSource = window.localStorage.getItem(`post-icon-${this.name}`) ?? this.svgSource;\n }\n\n componentWillLoad() {\n this.validateName();\n this.validateBase();\n this.validateFlipH();\n this.validateFlipV();\n this.validateScale();\n this.validateRotate();\n this.validateAnimation();\n\n this.fetchSVG();\n }\n\n componentWillRender() {\n const svgStyles = Object.entries({\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 .map(([key, value]) => `${key}: ${value}`)\n .join(';');\n\n const helperElement = document.createElement('div');\n helperElement.innerHTML = this.svgSource;\n\n const svgElement = helperElement.querySelector('svg');\n svgElement.setAttribute('style', svgStyles);\n\n this.svgOutput = helperElement.innerHTML;\n }\n\n getPath(basePath: string) {\n return new URL(\n [...basePath.split('/'), `${this.name}.svg#icon`].join('/'),\n window.location.origin,\n ).toString();\n }\n\n fetchSVG() {\n fetch(this.path)\n .then(response => response.text())\n .then(textResponse => {\n const match = textResponse.match(/^<svg\\b([\\s\\S]*)><\\/svg>/);\n\n if (match !== null) {\n this.svgSource = match[0];\n window.localStorage.setItem(`post-icon-${this.name}`, this.svgSource);\n } else {\n this.initialPath = this.path;\n this.path = this.getPath(CDN_URL);\n\n if (this.initialPath !== this.path) {\n console.warn(\n `Warning in <post-icon/>: The content on the path \"${this.path}\" seems to be no svg-only content. We'll gonna try to load the icon from the cdn.`,\n );\n this.fetchSVG();\n } else {\n console.error(\n `Error in <post-icon/>: Could not load the svg on the path \"${this.initialPath}\"!`,\n );\n }\n }\n })\n .catch(error => {\n console.log(error);\n });\n }\n\n render() {\n return (\n <Host>\n <div innerHTML={this.svgOutput} />\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"post-icon.js","sourceRoot":"","sources":["../../../src/components/post-icon/post-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE7E,MAAM,OAAO,GAAG,oEAAoE,CAAC;AACrF,MAAM,cAAc,GAAG;EACrB,OAAO;EACP,gBAAgB;EAChB,MAAM;EACN,cAAc;EACd,MAAM;EACN,OAAO;CACR,CAAC;AAEF;;GAEG;AAMH,MAAM,OAAO,QAAQ;;IAGX,cAAS,GAAG,iCAAiC,CAAC;;;;;;;;;;EAUtD,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC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AK,CAAC,EAAE;MACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;EACP,CAAC;EAEO,OAAO,CAAC,QAAgB;IAC9B,OAAO,IAAI,GAAG,CACZ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC3D,MAAM,CAAC,QAAQ,CAAC,MAAM,CACvB,CAAC,QAAQ,EAAE,CAAC;EACf,CAAC;EAED,MAAM;IACJ,OAAO,CACL,EAAC,IAAI;MACH,WAAK,SAAS,EAAE,IAAI,CAAC,SAAS,GAAI,CAC7B,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Watch } from '@stencil/core';\nimport { checkType, checkEmptyOrType, checkEmptyOrOneOf } from '../../utils';\n\nconst CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';\nconst ANIMATION_KEYS = [\n 'cylon',\n 'cylon-vertical',\n 'spin',\n 'spin-reverse',\n 'fade',\n 'throb'\n];\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 initialPath: string;\n private path: string;\n private svgSource = '<svg viewBox=\"0 0 16 16\"></svg>';\n\n @State() svgOutput: string;\n\n /**\n * The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`).\n */\n @Prop() readonly animation?: string;\n\n @Watch('animation')\n validateAnimation(newValue = this.animation) {\n if (newValue !== undefined) checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon \"animation\" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);\n }\n\n /**\n * The base path, where the icons are located (must be a public url).\n */\n @Prop() readonly base?: string;\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;\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;\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 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;\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;\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 connectedCallback() {\n // Construct icon path from different possible sources\n let basePath: string;\n const metaBase = document.head.querySelector(\n 'meta[name=\"design-system-settings\"][data-post-icon-base]',\n );\n\n if (this.base) {\n basePath = this.base;\n } else if (metaBase) {\n basePath = metaBase.getAttribute('data-post-icon-base');\n } else {\n basePath = CDN_URL;\n }\n\n this.path = this.getPath(basePath);\n this.svgSource = window.localStorage.getItem(`post-icon-${this.name}`) ?? this.svgSource;\n }\n\n componentWillLoad() {\n this.validateAnimation();\n this.validateBase();\n this.validateFlipH();\n this.validateFlipV();\n this.validateName();\n this.validateRotate();\n this.validateScale();\n\n this.fetchSVG();\n }\n\n componentWillRender() {\n const svgStyles = Object.entries({\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 .map(([key, value]) => `${key}: ${value}`)\n .join(';');\n\n const helperElement = document.createElement('div');\n helperElement.innerHTML = this.svgSource;\n\n const svgElement = helperElement.querySelector('svg');\n svgElement.setAttribute('style', svgStyles);\n\n this.svgOutput = helperElement.innerHTML;\n }\n\n private fetchSVG() {\n fetch(this.path)\n .then(response => response.text())\n .then(textResponse => {\n const match = textResponse.match(/^<svg\\b([\\s\\S]*)><\\/svg>/);\n\n if (match !== null) {\n this.svgSource = match[0];\n window.localStorage.setItem(`post-icon-${this.name}`, this.svgSource);\n } else {\n this.initialPath = this.path;\n this.path = this.getPath(CDN_URL);\n\n if (this.initialPath !== this.path) {\n console.warn(\n `Warning in <post-icon/>: The content on the path \"${this.path}\" seems to be no svg-only content. We'll gonna try to load the icon from the cdn.`,\n );\n this.fetchSVG();\n } else {\n console.error(\n `Error in <post-icon/>: Could not load the svg on the path \"${this.initialPath}\"!`,\n );\n }\n }\n })\n .catch(error => {\n console.log(error);\n });\n }\n\n private getPath(basePath: string) {\n return new URL(\n [...basePath.split('/'), `${this.name}.svg#icon`].join('/'),\n window.location.origin,\n ).toString();\n }\n\n render() {\n return (\n <Host>\n <div innerHTML={this.svgOutput} />\n </Host>\n );\n }\n}\n"]}
@@ -1,6 +1,3 @@
1
- /*
2
- * Copyright 2022 by Swiss Post, Information Technology
3
- */
4
1
  export function getElementHeight(el, classesWhenShown = []) {
5
2
  if (!Array.isArray(classesWhenShown))
6
3
  classesWhenShown = [classesWhenShown];
@@ -1 +1 @@
1
- {"version":3,"file":"get-element-height.js","sourceRoot":"","sources":["../../src/utils/get-element-height.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,UAAU,gBAAgB,CAAC,EAAe,EAAE,mBAAwB,EAAE;EAC1E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAAE,gBAAgB,GAAG,CAAC,gBAAgB,CAAC,CAAC;EAE5E,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;EACrF,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;EAE3D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;EAErC,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC;EAE9D,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["/*\n * Copyright 2022 by Swiss Post, Information Technology\n */\n\nexport 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: any = []): 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"]}
1
+ {"version":3,"file":"get-element-height.js","sourceRoot":"","sources":["../../src/utils/get-element-height.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,gBAAgB,CAAC,EAAe,EAAE,mBAAsC,EAAE;EACxF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAAE,gBAAgB,GAAG,CAAC,gBAAgB,CAAC,CAAC;EAE5E,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;EACrF,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;EAE3D,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;EAErC,IAAI,YAAY,CAAC,MAAM;IAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC;EAE9D,OAAO,YAAY,CAAC;AACtB,CAAC","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"]}
@@ -1,6 +1,3 @@
1
- /*
2
- * Copyright 2022 by Swiss Post, Information Technology
3
- */
4
1
  export * from './get-element-height';
5
2
  export * from './on-transition-end';
6
3
  export * from './property-checkers';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC","sourcesContent":["/*\n * Copyright 2022 by Swiss Post, Information Technology\n */\n\nexport * from './get-element-height';\nexport * from './on-transition-end';\nexport * from './property-checkers';\nexport * from './should-reduce-motion';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './get-element-height';\nexport * from './on-transition-end';\nexport * from './property-checkers';\nexport * from './should-reduce-motion';\n"]}
@@ -1,6 +1,3 @@
1
- /*
2
- * Copyright 2022 by Swiss Post, Information Technology
3
- */
4
1
  import { shouldReduceMotion } from './should-reduce-motion';
5
2
  export async function onTransitionEnd(el) {
6
3
  return new Promise(resolve => {
@@ -1 +1 @@
1
- {"version":3,"file":"on-transition-end.js","sourceRoot":"","sources":["../../src/utils/on-transition-end.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EAAe;EACnD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;IAC3B,IAAI,kBAAkB,EAAE,EAAE;MACxB,OAAO,EAAE,CAAC;KACX;SAAM;MACL,EAAE,CAAC,eAAe,GAAG,GAAG,EAAE;QACxB,OAAO,EAAE,CAAC;QACV,EAAE,CAAC,eAAe,GAAG,IAAI,CAAC;MAC5B,CAAC,CAAC;KACH;EACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright 2022 by Swiss Post, Information Technology\n */\n\nimport { 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"]}
1
+ {"version":3,"file":"on-transition-end.js","sourceRoot":"","sources":["../../src/utils/on-transition-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EAAe;EACnD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;IAC3B,IAAI,kBAAkB,EAAE,EAAE;MACxB,OAAO,EAAE,CAAC;KACX;SAAM;MACL,EAAE,CAAC,eAAe,GAAG,GAAG,EAAE;QACxB,OAAO,EAAE,CAAC;QACV,EAAE,CAAC,eAAe,GAAG,IAAI,CAAC;MAC5B,CAAC,CAAC;KACH;EACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["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"]}
@@ -0,0 +1,5 @@
1
+ export function checkOneOf(value, possibleValues, error) {
2
+ if (!possibleValues.includes(value))
3
+ throw new Error(error);
4
+ }
5
+ //# sourceMappingURL=check-one-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-one-of.js","sourceRoot":"","sources":["../../../src/utils/property-checkers/check-one-of.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,KAAa;EACxE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n"]}
@@ -0,0 +1,13 @@
1
+ export function checkType(value, type, error) {
2
+ const typeIsArray = type === 'array';
3
+ const valueIsArray = Array.isArray(value);
4
+ if (typeIsArray || valueIsArray) {
5
+ if (valueIsArray !== typeIsArray)
6
+ throw new Error(error);
7
+ }
8
+ else {
9
+ if (typeof value !== type)
10
+ throw new Error(error);
11
+ }
12
+ }
13
+ //# sourceMappingURL=check-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-type.js","sourceRoot":"","sources":["../../../src/utils/property-checkers/check-type.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,IAAkB,EAAE,KAAa;EACzE,MAAM,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC;EACrC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,YAAY,KAAK,WAAW;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GAC1D;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,IAAI;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GACnD;AACH,CAAC","sourcesContent":["export type PropertyType =\n | 'boolean'\n | 'number'\n | 'string'\n | 'array'\n | 'object'\n | 'function';\n\nexport function checkType(value: unknown, type: PropertyType, error: string) {\n const typeIsArray = type === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if (valueIsArray !== typeIsArray) throw new Error(error);\n } else {\n if (typeof value !== type) throw new Error(error);\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ const EMPTY_VALUES = [undefined, null, ''];
2
+ export function emptyOr(check) {
3
+ return (...args) => {
4
+ const value = args[0];
5
+ if (!EMPTY_VALUES.some(v => v === value))
6
+ check(...args);
7
+ };
8
+ }
9
+ //# sourceMappingURL=empty-or.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-or.js","sourceRoot":"","sources":["../../../src/utils/property-checkers/empty-or.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AAE3C,MAAM,UAAU,OAAO,CAAsB,KAA2B;EACtE,OAAO,CAAC,GAAG,IAAO,EAAE,EAAE;IACpB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC;MAAE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;EAC3D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\n\nexport function emptyOr<T extends unknown[]>(check: (...args: T) => void) {\n return (...args: T) => {\n const value = args[0];\n if (!EMPTY_VALUES.some(v => v === value)) check(...args);\n };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { emptyOr } from './empty-or';
2
+ import { checkOneOf } from './check-one-of';
3
+ import { checkType } from './check-type';
4
+ export const checkEmptyOrOneOf = emptyOr(checkOneOf);
5
+ export const checkEmptyOrType = emptyOr(checkType);
6
+ export * from './check-one-of';
7
+ export * from './check-type';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/property-checkers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC","sourcesContent":["import { emptyOr } from './empty-or';\nimport { checkOneOf } from './check-one-of';\nimport { checkType } from './check-type';\n\nexport const checkEmptyOrOneOf = emptyOr(checkOneOf);\nexport const checkEmptyOrType = emptyOr(checkType);\n\nexport * from './check-one-of';\nexport * from './check-type';\n"]}
@@ -1,6 +1,3 @@
1
- /*
2
- * Copyright 2022 by Swiss Post, Information Technology
3
- */
4
1
  export function shouldReduceMotion() {
5
2
  return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
6
3
  }
@@ -1 +1 @@
1
- {"version":3,"file":"should-reduce-motion.js","sourceRoot":"","sources":["../../src/utils/should-reduce-motion.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,kBAAkB;EAChC,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["/*\n * Copyright 2022 by Swiss Post, Information Technology\n */\n\nexport function shouldReduceMotion(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
1
+ {"version":3,"file":"should-reduce-motion.js","sourceRoot":"","sources":["../../src/utils/should-reduce-motion.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB;EAChC,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["export function shouldReduceMotion(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ function checkOneOf(value, possibleValues, error) {
2
+ if (!possibleValues.includes(value))
3
+ throw new Error(error);
4
+ }
5
+
6
+ function checkType(value, type, error) {
7
+ const typeIsArray = type === 'array';
8
+ const valueIsArray = Array.isArray(value);
9
+ if (typeIsArray || valueIsArray) {
10
+ if (valueIsArray !== typeIsArray)
11
+ throw new Error(error);
12
+ }
13
+ else {
14
+ if (typeof value !== type)
15
+ throw new Error(error);
16
+ }
17
+ }
18
+
19
+ export { checkOneOf as a, checkType as c };
20
+
21
+ //# sourceMappingURL=check-type.js.map
@@ -0,0 +1 @@
1
+ {"file":"check-type.js","mappings":"SAAgB,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,KAAa;EACxE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D;;SCMgB,SAAS,CAAC,KAAc,EAAE,IAAkB,EAAE,KAAa;EACzE,MAAM,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC;EACrC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,YAAY,KAAK,WAAW;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GAC1D;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,IAAI;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GACnD;AACH;;;;","names":[],"sources":["./src/utils/property-checkers/check-one-of.ts","./src/utils/property-checkers/check-type.ts"],"sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n","export type PropertyType =\n | 'boolean'\n | 'number'\n | 'string'\n | 'array'\n | 'object'\n | 'function';\n\nexport function checkType(value: unknown, type: PropertyType, error: string) {\n const typeIsArray = type === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if (valueIsArray !== typeIsArray) throw new Error(error);\n } else {\n if (typeof value !== type) throw new Error(error);\n }\n}\n"],"version":3}