@swisspost/design-system-components 1.0.0-beta.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -23
- package/dist/cjs/{index-5c30acf6.js → index-8880977f.js} +588 -154
- package/dist/cjs/index-8880977f.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +6 -3
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/post-collapsible.cjs.entry.js +134 -0
- package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -0
- package/dist/cjs/post-components.cjs.js +12 -3
- package/dist/cjs/post-components.cjs.js.map +1 -0
- package/dist/cjs/post-icon.cjs.entry.js +142 -0
- package/dist/cjs/post-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/property-checkers-586ad9d4.js +40 -0
- package/dist/cjs/property-checkers-586ad9d4.js.map +1 -0
- package/dist/collection/collection-manifest.json +4 -3
- package/dist/collection/components/post-collapsible/post-collapsible.css +17142 -0
- package/dist/collection/components/post-collapsible/post-collapsible.js +173 -0
- package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -0
- package/dist/collection/components/post-icon/post-icon.css +94 -0
- package/dist/collection/components/post-icon/post-icon.js +291 -0
- package/dist/collection/components/post-icon/post-icon.js.map +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/utils/get-element-height.js +15 -0
- package/dist/collection/utils/get-element-height.js.map +1 -0
- package/dist/collection/utils/index.js +8 -0
- package/dist/collection/utils/index.js.map +1 -0
- package/dist/collection/utils/on-transition-end.js +18 -0
- package/dist/collection/utils/on-transition-end.js.map +1 -0
- package/dist/collection/utils/property-checkers.js +31 -0
- package/dist/collection/utils/property-checkers.js.map +1 -0
- package/dist/collection/utils/should-reduce-motion.js +7 -0
- package/dist/collection/utils/should-reduce-motion.js.map +1 -0
- package/dist/components/index.d.ts +9 -4
- package/dist/components/index.js +3 -2
- package/dist/components/index.js.map +1 -0
- package/dist/components/post-collapsible.d.ts +11 -0
- package/dist/components/post-collapsible.js +158 -0
- package/dist/components/post-collapsible.js.map +1 -0
- package/dist/components/{my-component.d.ts → post-icon.d.ts} +4 -4
- package/dist/components/post-icon.js +168 -0
- package/dist/components/post-icon.js.map +1 -0
- package/dist/components/property-checkers.js +34 -0
- package/dist/components/property-checkers.js.map +1 -0
- package/dist/docs.d.ts +24 -0
- package/dist/docs.json +153 -41
- package/dist/esm/{index-865c32d6.js → index-6d5a72fa.js} +586 -154
- package/dist/esm/index-6d5a72fa.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +6 -3
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/post-collapsible.entry.js +130 -0
- package/dist/esm/post-collapsible.entry.js.map +1 -0
- package/dist/esm/post-components.js +9 -3
- package/dist/esm/post-components.js.map +1 -0
- package/dist/esm/post-icon.entry.js +138 -0
- package/dist/esm/post-icon.entry.js.map +1 -0
- package/dist/esm/property-checkers-484ca671.js +34 -0
- package/dist/esm/property-checkers-484ca671.js.map +1 -0
- package/dist/post-components/index.esm.js +2 -0
- package/dist/post-components/index.esm.js.map +1 -0
- package/dist/post-components/p-6588c1b7.entry.js +2 -0
- package/dist/post-components/p-6588c1b7.entry.js.map +1 -0
- package/dist/post-components/p-7cd9c1ad.js +2 -0
- package/dist/post-components/p-7cd9c1ad.js.map +1 -0
- package/dist/post-components/p-a93114b9.js +3 -0
- package/dist/post-components/p-a93114b9.js.map +1 -0
- package/dist/post-components/p-b07185a3.entry.js +2 -0
- package/dist/post-components/p-b07185a3.entry.js.map +1 -0
- package/dist/post-components/post-components.esm.js +2 -1
- package/dist/post-components/post-components.esm.js.map +1 -0
- package/dist/types/components/post-collapsible/post-collapsible.d.ts +30 -0
- package/dist/types/components/post-icon/post-icon.d.ts +50 -0
- package/dist/types/components.d.ts +96 -28
- package/dist/types/stencil-public-runtime.d.ts +91 -19
- package/dist/types/utils/get-element-height.d.ts +3 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/on-transition-end.d.ts +1 -0
- package/dist/types/utils/property-checkers.d.ts +5 -0
- package/dist/types/utils/should-reduce-motion.d.ts +1 -0
- package/loader/index.d.ts +9 -0
- package/package.json +18 -37
- package/dist/cjs/my-component.cjs.entry.js +0 -35
- package/dist/collection/components/my-component/my-component.css +0 -3
- package/dist/collection/components/my-component/my-component.js +0 -129
- package/dist/collection/components/my-component/my-component.stories.js +0 -19
- package/dist/collection/stories/Button.js +0 -21
- package/dist/collection/stories/Button.stories.js +0 -48
- package/dist/collection/stories/Header.js +0 -45
- package/dist/collection/stories/Header.stories.js +0 -20
- package/dist/collection/stories/Page.js +0 -67
- package/dist/collection/stories/Page.stories.js +0 -24
- package/dist/collection/stories/assets/code-brackets.svg +0 -1
- package/dist/collection/stories/assets/colors.svg +0 -1
- package/dist/collection/stories/assets/comments.svg +0 -1
- package/dist/collection/stories/assets/direction.svg +0 -1
- package/dist/collection/stories/assets/flow.svg +0 -1
- package/dist/collection/stories/assets/plugin.svg +0 -1
- package/dist/collection/stories/assets/repo.svg +0 -1
- package/dist/collection/stories/assets/stackalt.svg +0 -1
- package/dist/collection/utils/utils.js +0 -3
- package/dist/components/my-component.js +0 -54
- package/dist/esm/my-component.entry.js +0 -31
- package/dist/post-components/p-89fc10d3.js +0 -2
- package/dist/post-components/p-e4e802f7.entry.js +0 -1
- package/dist/types/components/my-component/my-component.d.ts +0 -22
- package/dist/types/components/my-component/my-component.stories.d.ts +0 -12
- package/dist/types/utils/utils.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"post-collapsible.js","mappings":";;;AAAA;;;SAOgB,gBAAgB,CAAC,EAAe,EAAE,mBAAwB,EAAE;EAC1E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gB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,GAAG,IAAI,CAAC,MAAM,EAAE,mBAChB,GAAG,IAAI,CAAC,aAAa,YAAY,EAChD,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,IAE5B,YAAM,IAAI,EAAC,QAAQ,GAAE,CACd,CACO,EAClB,WACE,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa,YAAY,EACrC,KAAK,EAAE,sBAAsB,IAAI,CAAC,eAAe,EAAE,EACnD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,qBACrB,GAAG,IAAI,CAAC,aAAa,UAAU,IAEhD,WAAK,KAAK,EAAC,gBAAgB,IACzB,eAAO,CACH,CACF,CACF,EACN;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["PostCollapsible"],"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":["/*\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","/*\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","/*\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","@use '@swisspost/design-system-styles/basics';\n@use '@swisspost/design-system-styles/components/accordion';\n@use '@swisspost/design-system-styles/components/transitions';\n\n:host {\n display: block;\n}\n","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"],"version":3}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Components, JSX } from "../types/components";
|
|
2
2
|
|
|
3
|
-
interface
|
|
4
|
-
export const
|
|
5
|
-
prototype:
|
|
6
|
-
new ():
|
|
3
|
+
interface PostIcon extends Components.PostIcon, HTMLElement {}
|
|
4
|
+
export const PostIcon: {
|
|
5
|
+
prototype: PostIcon;
|
|
6
|
+
new (): PostIcon;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Used to define this component and all nested components recursively.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { b as checkType, d as checkEmptyOrType, e as checkEmptyOrOneOf } from './property-checkers.js';
|
|
3
|
+
|
|
4
|
+
const postIconCss = ":host{display:inline-block;width:1em;vertical-align:-0.15em}svg{display:block;width:100%;fill:currentColor}:host([flip-h]) svg{scale:-1 1}:host([flip-v]) svg{scale:1 -1}:host([flip-h][flip-v]) svg{scale:-1}:host([animation]) svg{transform-origin:center}:host([animation=cylon]) svg{animation:icon-animation-cylon 0.75s ease-in-out infinite alternate}:host([animation=cylon-vertical]) svg{animation:icon-animation-cylon-vertical 0.75s ease-in-out infinite alternate}:host([animation=spin]) svg{animation:icon-animation-spin 2s linear infinite normal}:host([animation=spin-reverse]) svg{animation:icon-animation-spin 2s linear infinite reverse}:host([animation=fade]) svg{animation:icon-animation-fade 0.75s ease-in-out infinite alternate}:host([animation=throb]) svg{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)}}";
|
|
5
|
+
|
|
6
|
+
const CDN_URL = 'https://unpkg.com/@swisspost/design-system-icons/public/post-icons';
|
|
7
|
+
const ANIMATION_KEYS = [
|
|
8
|
+
'cylon',
|
|
9
|
+
'cylon-vertical',
|
|
10
|
+
'spin',
|
|
11
|
+
'spin-reverse',
|
|
12
|
+
'fade',
|
|
13
|
+
'throb'
|
|
14
|
+
];
|
|
15
|
+
const PostIcon$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.__registerHost();
|
|
19
|
+
this.__attachShadow();
|
|
20
|
+
this.name = undefined;
|
|
21
|
+
this.base = undefined;
|
|
22
|
+
this.flipH = undefined;
|
|
23
|
+
this.flipV = undefined;
|
|
24
|
+
this.scale = undefined;
|
|
25
|
+
this.rotate = undefined;
|
|
26
|
+
this.animation = undefined;
|
|
27
|
+
this.initialPath = undefined;
|
|
28
|
+
this.path = undefined;
|
|
29
|
+
this.svgSource = '<svg viewBox="0 0 16 16"></svg>';
|
|
30
|
+
this.svgOutput = undefined;
|
|
31
|
+
}
|
|
32
|
+
validateName(newValue = this.name) {
|
|
33
|
+
checkType(newValue, 'string', 'The post-icon "name" prop should be a string.');
|
|
34
|
+
}
|
|
35
|
+
validateBase(newValue = this.base) {
|
|
36
|
+
checkEmptyOrType(newValue, 'string', 'The post-icon "base" prop should be a string.');
|
|
37
|
+
}
|
|
38
|
+
validateFlipH(newValue = this.flipH) {
|
|
39
|
+
checkEmptyOrType(newValue, 'boolean', 'The post-icon "flipH" prop should be a boolean.');
|
|
40
|
+
}
|
|
41
|
+
validateFlipV(newValue = this.flipV) {
|
|
42
|
+
checkEmptyOrType(newValue, 'boolean', 'The post-icon "flipV" prop should be a boolean.');
|
|
43
|
+
}
|
|
44
|
+
validateScale(newValue = this.scale) {
|
|
45
|
+
checkEmptyOrType(newValue, 'number', 'The post-icon "scale" prop should be a number.');
|
|
46
|
+
}
|
|
47
|
+
validateRotate(newValue = this.rotate) {
|
|
48
|
+
checkEmptyOrType(newValue, 'number', 'The post-icon "rotate" prop should be a number.');
|
|
49
|
+
}
|
|
50
|
+
validateAnimation(newValue = this.animation) {
|
|
51
|
+
if (newValue !== undefined)
|
|
52
|
+
checkEmptyOrOneOf(newValue, ANIMATION_KEYS, `The post-icon "animation" prop requires one of the following values: ${ANIMATION_KEYS.join(', ')}.`);
|
|
53
|
+
}
|
|
54
|
+
connectedCallback() {
|
|
55
|
+
var _a;
|
|
56
|
+
// Construct icon path from different possible sources
|
|
57
|
+
let basePath;
|
|
58
|
+
const metaBase = document.head.querySelector('meta[name="design-system-settings"][data-post-icon-base]');
|
|
59
|
+
if (this.base) {
|
|
60
|
+
basePath = this.base;
|
|
61
|
+
}
|
|
62
|
+
else if (metaBase) {
|
|
63
|
+
basePath = metaBase.getAttribute('data-post-icon-base');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
basePath = CDN_URL;
|
|
67
|
+
}
|
|
68
|
+
this.path = this.getPath(basePath);
|
|
69
|
+
this.svgSource = (_a = window.localStorage.getItem(`post-icon-${this.name}`)) !== null && _a !== void 0 ? _a : this.svgSource;
|
|
70
|
+
}
|
|
71
|
+
componentWillLoad() {
|
|
72
|
+
this.validateName();
|
|
73
|
+
this.validateBase();
|
|
74
|
+
this.validateFlipH();
|
|
75
|
+
this.validateFlipV();
|
|
76
|
+
this.validateScale();
|
|
77
|
+
this.validateRotate();
|
|
78
|
+
this.validateAnimation();
|
|
79
|
+
this.fetchSVG();
|
|
80
|
+
}
|
|
81
|
+
componentWillRender() {
|
|
82
|
+
const svgStyles = Object.entries({
|
|
83
|
+
scale: this.scale && !isNaN(Number(this.scale)) ? `${this.scale}` : null,
|
|
84
|
+
rotate: this.rotate && !isNaN(Number(this.rotate)) ? `${this.rotate}deg` : null,
|
|
85
|
+
})
|
|
86
|
+
.filter(([_key, value]) => value !== null)
|
|
87
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
88
|
+
.join(';');
|
|
89
|
+
const helperElement = document.createElement('div');
|
|
90
|
+
helperElement.innerHTML = this.svgSource;
|
|
91
|
+
const svgElement = helperElement.querySelector('svg');
|
|
92
|
+
svgElement.setAttribute('style', svgStyles);
|
|
93
|
+
this.svgOutput = helperElement.innerHTML;
|
|
94
|
+
}
|
|
95
|
+
getPath(basePath) {
|
|
96
|
+
return new URL([...basePath.split('/'), `${this.name}.svg#icon`].join('/'), window.location.origin).toString();
|
|
97
|
+
}
|
|
98
|
+
fetchSVG() {
|
|
99
|
+
fetch(this.path)
|
|
100
|
+
.then(response => response.text())
|
|
101
|
+
.then(textResponse => {
|
|
102
|
+
const match = textResponse.match(/^<svg\b([\s\S]*)><\/svg>/);
|
|
103
|
+
if (match !== null) {
|
|
104
|
+
this.svgSource = match[0];
|
|
105
|
+
window.localStorage.setItem(`post-icon-${this.name}`, this.svgSource);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.initialPath = this.path;
|
|
109
|
+
this.path = this.getPath(CDN_URL);
|
|
110
|
+
if (this.initialPath !== this.path) {
|
|
111
|
+
console.warn(`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.`);
|
|
112
|
+
this.fetchSVG();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
console.error(`Error in <post-icon/>: Could not load the svg on the path "${this.initialPath}"!`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
.catch(error => {
|
|
120
|
+
console.log(error);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
render() {
|
|
124
|
+
return (h(Host, null, h("div", { innerHTML: this.svgOutput })));
|
|
125
|
+
}
|
|
126
|
+
static get watchers() { return {
|
|
127
|
+
"name": ["validateName"],
|
|
128
|
+
"base": ["validateBase"],
|
|
129
|
+
"flipH": ["validateFlipH"],
|
|
130
|
+
"flipV": ["validateFlipV"],
|
|
131
|
+
"scale": ["validateScale"],
|
|
132
|
+
"rotate": ["validateRotate"],
|
|
133
|
+
"animation": ["validateAnimation"]
|
|
134
|
+
}; }
|
|
135
|
+
static get style() { return postIconCss; }
|
|
136
|
+
}, [1, "post-icon", {
|
|
137
|
+
"name": [1],
|
|
138
|
+
"base": [1],
|
|
139
|
+
"flipH": [4, "flip-h"],
|
|
140
|
+
"flipV": [4, "flip-v"],
|
|
141
|
+
"scale": [2],
|
|
142
|
+
"rotate": [2],
|
|
143
|
+
"animation": [1],
|
|
144
|
+
"initialPath": [32],
|
|
145
|
+
"path": [32],
|
|
146
|
+
"svgSource": [32],
|
|
147
|
+
"svgOutput": [32]
|
|
148
|
+
}]);
|
|
149
|
+
function defineCustomElement$1() {
|
|
150
|
+
if (typeof customElements === "undefined") {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const components = ["post-icon"];
|
|
154
|
+
components.forEach(tagName => { switch (tagName) {
|
|
155
|
+
case "post-icon":
|
|
156
|
+
if (!customElements.get(tagName)) {
|
|
157
|
+
customElements.define(tagName, PostIcon$1);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
} });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const PostIcon = PostIcon$1;
|
|
164
|
+
const defineCustomElement = defineCustomElement$1;
|
|
165
|
+
|
|
166
|
+
export { PostIcon, defineCustomElement };
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=post-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"post-icon.js","mappings":";;;AAAA,MAAM,WAAW,GAAG,swCAAswC;;ACG1xC,MAAM,OAAO,GAAG,oEAAoE,CAAC;AACrF,MAAM,cAAc,GAAG;EACrB,OAAO;EACP,gBAAgB;EAChB,MAAM;EACN,cAAc;EACd,MAAM;EACN,OAAO;CACR,CAAC;MAUWA,UAAQ;;;;;;;;;;;;;;qBAqCU,iCAAiC;;;EAI9D,YAAY,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI;IAC/B,SAAS,CAAC,QAAQ,EAAE,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ACH;OACF;KACF,CAAC;OACD,KAAK,CAAC,KAAK;MACV,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB,CAAC,CAAC;GACN;EAED,MAAM;IACJ,QACE,EAAC,IAAI,QACH,WAAK,SAAS,EAAE,IAAI,CAAC,SAAS,GAAI,CAC7B,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["PostIcon"],"sources":["./src/components/post-icon/post-icon.scss?tag=post-icon&encapsulation=shadow","./src/components/post-icon/post-icon.tsx"],"sourcesContent":["@use 'sass:map';\n\n$post-icon-animations: (\n 'cylon': icon-animation-cylon .75s ease-in-out infinite alternate,\n 'cylon-vertical': icon-animation-cylon-vertical .75s ease-in-out infinite alternate,\n 'spin': icon-animation-spin 2s linear infinite normal,\n 'spin-reverse': icon-animation-spin 2s linear infinite reverse,\n 'fade': icon-animation-fade .75s ease-in-out infinite alternate,\n 'throb': icon-animation-throb .75s ease-in-out infinite alternate\n);\n\n:host {\n display: inline-block;\n width: 1em;\n vertical-align: -0.15em;\n}\n\nsvg {\n display: block;\n width: 100%;\n fill: currentColor;\n}\n\n// flip\n\n:host([flip-h]) {\n svg { scale: -1 1; }\n}\n\n:host([flip-v]) {\n svg { scale: 1 -1; }\n}\n\n:host([flip-h][flip-v]) {\n svg { scale: -1; }\n}\n\n// scale\n// done with inline styling\n\n// rotate\n// done with inline styling\n\n// animation\n\n:host([animation]) {\n svg {\n transform-origin: center;\n }\n}\n\n@each $key, $value in $post-icon-animations {\n :host([animation=\"#{$key}\"]) {\n svg {\n animation: $value;\n }\n }\n}\n\n@keyframes icon-animation-cylon {\n from { transform: translateX(-25%) }\n to { transform: translateX(25%) }\n}\n\n@keyframes icon-animation-cylon-vertical {\n from { transform: translateY(25%); }\n to { transform: translateY(-25%); }\n}\n\n@keyframes icon-animation-fade {\n from { opacity: .1; }\n to { opacity: 1; }\n}\n\n@keyframes icon-animation-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(359deg); }\n}\n\n@keyframes icon-animation-throb {\n from {\n opacity: .5;\n transform: scale(0.5);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n","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"],"version":3}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const EMPTY_VALUES = [undefined, null, ''];
|
|
2
|
+
function checkType(value, type, errorMessage) {
|
|
3
|
+
const lowerCaseType = type.toLowerCase();
|
|
4
|
+
const typeIsArray = lowerCaseType === 'array';
|
|
5
|
+
const valueIsArray = Array.isArray(value);
|
|
6
|
+
if (typeIsArray || valueIsArray) {
|
|
7
|
+
if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))
|
|
8
|
+
throw new Error(errorMessage);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
if (typeof value !== lowerCaseType)
|
|
12
|
+
throw new Error(errorMessage);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function checkEmptyOrType(value, type, errorMessage) {
|
|
16
|
+
if (!EMPTY_VALUES.some(v => v === value))
|
|
17
|
+
checkType(value, type, errorMessage);
|
|
18
|
+
}
|
|
19
|
+
function checkOneOf(value, possibleValues, errorMessage) {
|
|
20
|
+
if (!possibleValues.includes(value))
|
|
21
|
+
throw new Error(errorMessage);
|
|
22
|
+
}
|
|
23
|
+
function checkEmptyOrOneOf(value, possibleValues, errorMessage) {
|
|
24
|
+
if (!EMPTY_VALUES.some(v => v === value))
|
|
25
|
+
checkOneOf(value, possibleValues, errorMessage);
|
|
26
|
+
}
|
|
27
|
+
function checkBoolean(value, errorMessage) {
|
|
28
|
+
if (typeof value !== 'boolean')
|
|
29
|
+
throw new Error(errorMessage);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { checkOneOf as a, checkType as b, checkBoolean as c, checkEmptyOrType as d, checkEmptyOrOneOf as e };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=property-checkers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"property-checkers.js","mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;SAE3B,SAAS,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EAC1E,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;EACzC,MAAM,WAAW,GAAG,aAAa,KAAK,OAAO,CAAC;EAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,MAAM,CAAC,WAAW,IAAI,YAAY,CAAC;MAClE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACjC;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,aAAa;MAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;GACnE;AACH,CAAC;SAEe,gBAAgB,CAAC,KAAc,EAAE,IAAY,EAAE,YAAoB;EACjF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IAAE,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;AACjF,CAAC;SAEe,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC;SAEe,iBAAiB,CAAI,KAAQ,EAAE,cAAmB,EAAE,YAAoB;EACtF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC;IAAE,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AAC5F,CAAC;SAEe,YAAY,CAAC,KAAc,EAAE,YAAoB;EAC/D,IAAI,OAAO,KAAK,KAAK,SAAS;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChE;;;;","names":[],"sources":["./src/utils/property-checkers.ts"],"sourcesContent":["const EMPTY_VALUES = [undefined, null, ''];\n\nexport function checkType(value: unknown, type: string, errorMessage: string) {\n const lowerCaseType = type.toLowerCase();\n const typeIsArray = lowerCaseType === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if ((typeIsArray && !valueIsArray) || (!typeIsArray && valueIsArray))\n throw new Error(errorMessage);\n } else {\n if (typeof value !== lowerCaseType) throw new Error(errorMessage);\n }\n}\n\nexport function checkEmptyOrType(value: unknown, type: string, errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkType(value, type, errorMessage);\n}\n\nexport function checkOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!possibleValues.includes(value)) throw new Error(errorMessage);\n}\n\nexport function checkEmptyOrOneOf<T>(value: T, possibleValues: T[], errorMessage: string) {\n if (!EMPTY_VALUES.some(v => v === value)) checkOneOf(value, possibleValues, errorMessage);\n}\n\nexport function checkBoolean(value: unknown, errorMessage: string) {\n if (typeof value !== 'boolean') throw new Error(errorMessage);\n}\n"],"version":3}
|
package/dist/docs.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export interface JsonDocsComponent {
|
|
|
23
23
|
readme: string;
|
|
24
24
|
docs: string;
|
|
25
25
|
docsTags: JsonDocsTag[];
|
|
26
|
+
/**
|
|
27
|
+
* The text from the class-level JSDoc for a Stencil component, if present.
|
|
28
|
+
*/
|
|
29
|
+
overview?: string;
|
|
26
30
|
usage: JsonDocsUsage;
|
|
27
31
|
props: JsonDocsProp[];
|
|
28
32
|
methods: JsonDocsMethod[];
|
|
@@ -47,6 +51,26 @@ export interface JsonDocsValue {
|
|
|
47
51
|
value?: string;
|
|
48
52
|
type: string;
|
|
49
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* A mapping of file names to their contents.
|
|
56
|
+
*
|
|
57
|
+
* This type is meant to be used when reading one or more usage markdown files associated with a component. For the
|
|
58
|
+
* given directory structure:
|
|
59
|
+
* ```
|
|
60
|
+
* src/components/my-component
|
|
61
|
+
* ├── my-component.tsx
|
|
62
|
+
* └── usage
|
|
63
|
+
* ├── bar.md
|
|
64
|
+
* └── foo.md
|
|
65
|
+
* ```
|
|
66
|
+
* an instance of this type would include the name of the markdown file, mapped to its contents:
|
|
67
|
+
* ```ts
|
|
68
|
+
* {
|
|
69
|
+
* 'bar': STRING_CONTENTS_OF_BAR.MD
|
|
70
|
+
* 'foo': STRING_CONTENTS_OF_FOO.MD
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
50
74
|
export interface JsonDocsUsage {
|
|
51
75
|
[key: string]: string;
|
|
52
76
|
}
|
package/dist/docs.json
CHANGED
|
@@ -1,61 +1,163 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "
|
|
2
|
+
"timestamp": "2023-02-17T08:18:59",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
|
-
"version": "
|
|
6
|
-
"typescriptVersion": "4.
|
|
5
|
+
"version": "3.0.1",
|
|
6
|
+
"typescriptVersion": "4.9.5"
|
|
7
7
|
},
|
|
8
8
|
"components": [
|
|
9
9
|
{
|
|
10
|
-
"filePath": "./src/components/
|
|
10
|
+
"filePath": "./src/components/post-collapsible/post-collapsible.tsx",
|
|
11
11
|
"encapsulation": "shadow",
|
|
12
|
-
"tag": "
|
|
13
|
-
"readme": "#
|
|
14
|
-
"docs": "
|
|
12
|
+
"tag": "post-collapsible",
|
|
13
|
+
"readme": "# post-collapsible\n\n\n",
|
|
14
|
+
"docs": "",
|
|
15
15
|
"docsTags": [],
|
|
16
16
|
"usage": {},
|
|
17
17
|
"props": [
|
|
18
18
|
{
|
|
19
|
-
"name": "
|
|
19
|
+
"name": "collapsed",
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"mutable": false,
|
|
22
|
+
"attr": "collapsed",
|
|
23
|
+
"reflectToAttr": false,
|
|
24
|
+
"docs": "If `true`, the element is initially collapsed otherwise it is displayed.",
|
|
25
|
+
"docsTags": [],
|
|
26
|
+
"default": "false",
|
|
27
|
+
"values": [
|
|
28
|
+
{
|
|
29
|
+
"type": "boolean"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"optional": true,
|
|
33
|
+
"required": false
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "headingLevel",
|
|
37
|
+
"type": "number",
|
|
38
|
+
"mutable": false,
|
|
39
|
+
"attr": "heading-level",
|
|
40
|
+
"reflectToAttr": false,
|
|
41
|
+
"docs": "Defines the hierarchical level of the collapsible header within the headings structure.",
|
|
42
|
+
"docsTags": [],
|
|
43
|
+
"default": "2",
|
|
44
|
+
"values": [
|
|
45
|
+
{
|
|
46
|
+
"type": "number"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"optional": true,
|
|
50
|
+
"required": false
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"methods": [
|
|
54
|
+
{
|
|
55
|
+
"name": "toggle",
|
|
56
|
+
"returns": {
|
|
57
|
+
"type": "Promise<boolean>",
|
|
58
|
+
"docs": ""
|
|
59
|
+
},
|
|
60
|
+
"signature": "toggle(open?: boolean) => Promise<boolean>",
|
|
61
|
+
"parameters": [],
|
|
62
|
+
"docs": "Triggers the collapse programmatically.",
|
|
63
|
+
"docsTags": []
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"events": [],
|
|
67
|
+
"listeners": [],
|
|
68
|
+
"styles": [],
|
|
69
|
+
"slots": [],
|
|
70
|
+
"parts": [],
|
|
71
|
+
"dependents": [],
|
|
72
|
+
"dependencies": [],
|
|
73
|
+
"dependencyGraph": {}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"filePath": "./src/components/post-icon/post-icon.tsx",
|
|
77
|
+
"encapsulation": "shadow",
|
|
78
|
+
"tag": "post-icon",
|
|
79
|
+
"readme": "# post-icon\n\nsome content\n",
|
|
80
|
+
"docs": "some content",
|
|
81
|
+
"docsTags": [
|
|
82
|
+
{
|
|
83
|
+
"name": "class",
|
|
84
|
+
"text": "PostIcon - representing a stencil component"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"usage": {},
|
|
88
|
+
"props": [
|
|
89
|
+
{
|
|
90
|
+
"name": "animation",
|
|
20
91
|
"type": "string",
|
|
21
92
|
"mutable": false,
|
|
22
|
-
"attr": "
|
|
93
|
+
"attr": "animation",
|
|
23
94
|
"reflectToAttr": false,
|
|
24
|
-
"docs": "The
|
|
95
|
+
"docs": "The name of the animation (`cylon`, `cylon-vertical`, `spin`, `spin-reverse`, `fade`, `throb`).",
|
|
25
96
|
"docsTags": [],
|
|
26
97
|
"values": [
|
|
27
98
|
{
|
|
28
99
|
"type": "string"
|
|
29
100
|
}
|
|
30
101
|
],
|
|
31
|
-
"optional":
|
|
102
|
+
"optional": true,
|
|
32
103
|
"required": false
|
|
33
104
|
},
|
|
34
105
|
{
|
|
35
|
-
"name": "
|
|
106
|
+
"name": "base",
|
|
36
107
|
"type": "string",
|
|
37
108
|
"mutable": false,
|
|
38
|
-
"attr": "
|
|
109
|
+
"attr": "base",
|
|
39
110
|
"reflectToAttr": false,
|
|
40
|
-
"docs": "The
|
|
111
|
+
"docs": "The base path, where the icons are located (must be a public url).",
|
|
41
112
|
"docsTags": [],
|
|
42
113
|
"values": [
|
|
43
114
|
{
|
|
44
115
|
"type": "string"
|
|
45
116
|
}
|
|
46
117
|
],
|
|
47
|
-
"optional":
|
|
118
|
+
"optional": true,
|
|
48
119
|
"required": false
|
|
49
120
|
},
|
|
50
121
|
{
|
|
51
|
-
"name": "
|
|
122
|
+
"name": "flipH",
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"mutable": false,
|
|
125
|
+
"attr": "flip-h",
|
|
126
|
+
"reflectToAttr": false,
|
|
127
|
+
"docs": "When set to `true`, the icon will be flipped horizontally.",
|
|
128
|
+
"docsTags": [],
|
|
129
|
+
"values": [
|
|
130
|
+
{
|
|
131
|
+
"type": "boolean"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"optional": true,
|
|
135
|
+
"required": false
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "flipV",
|
|
139
|
+
"type": "boolean",
|
|
140
|
+
"mutable": false,
|
|
141
|
+
"attr": "flip-v",
|
|
142
|
+
"reflectToAttr": false,
|
|
143
|
+
"docs": "When set to `true`, the icon will be flipped vertically.",
|
|
144
|
+
"docsTags": [],
|
|
145
|
+
"values": [
|
|
146
|
+
{
|
|
147
|
+
"type": "boolean"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"optional": true,
|
|
151
|
+
"required": false
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"name": "name",
|
|
52
155
|
"type": "string",
|
|
53
156
|
"mutable": false,
|
|
54
|
-
"attr": "
|
|
157
|
+
"attr": "name",
|
|
55
158
|
"reflectToAttr": false,
|
|
56
|
-
"docs": "The
|
|
159
|
+
"docs": "The name/id of the icon (e.g. 1000, 1001, ...).",
|
|
57
160
|
"docsTags": [],
|
|
58
|
-
"default": "''",
|
|
59
161
|
"values": [
|
|
60
162
|
{
|
|
61
163
|
"type": "string"
|
|
@@ -63,32 +165,42 @@
|
|
|
63
165
|
],
|
|
64
166
|
"optional": false,
|
|
65
167
|
"required": false
|
|
66
|
-
}
|
|
67
|
-
],
|
|
68
|
-
"methods": [
|
|
168
|
+
},
|
|
69
169
|
{
|
|
70
|
-
"name": "
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
170
|
+
"name": "rotate",
|
|
171
|
+
"type": "number",
|
|
172
|
+
"mutable": false,
|
|
173
|
+
"attr": "rotate",
|
|
174
|
+
"reflectToAttr": false,
|
|
175
|
+
"docs": "The `number` of degree for the css `rotate` transformation.",
|
|
176
|
+
"docsTags": [],
|
|
177
|
+
"values": [
|
|
178
|
+
{
|
|
179
|
+
"type": "number"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"optional": true,
|
|
183
|
+
"required": false
|
|
184
|
+
},
|
|
82
185
|
{
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"docs": "
|
|
89
|
-
"docsTags": []
|
|
186
|
+
"name": "scale",
|
|
187
|
+
"type": "number",
|
|
188
|
+
"mutable": false,
|
|
189
|
+
"attr": "scale",
|
|
190
|
+
"reflectToAttr": false,
|
|
191
|
+
"docs": "The `number` for the css `scale` transformation.",
|
|
192
|
+
"docsTags": [],
|
|
193
|
+
"values": [
|
|
194
|
+
{
|
|
195
|
+
"type": "number"
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
"optional": true,
|
|
199
|
+
"required": false
|
|
90
200
|
}
|
|
91
201
|
],
|
|
202
|
+
"methods": [],
|
|
203
|
+
"events": [],
|
|
92
204
|
"listeners": [],
|
|
93
205
|
"styles": [],
|
|
94
206
|
"slots": [],
|