@oiz/stzh-components 3.3.0-beta1 → 3.3.0-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{app-globals-c314a0a4.js → app-globals-a46f6656.js} +2 -2
- package/dist/cjs/{app-globals-c314a0a4.js.map → app-globals-a46f6656.js.map} +1 -1
- package/dist/cjs/index-92254d32.js +4 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/stzh-app-nav.cjs.entry.js +32 -0
- package/dist/cjs/stzh-app-nav.cjs.entry.js.map +1 -0
- package/dist/cjs/stzh-badge_3.cjs.entry.js +38 -17
- package/dist/cjs/stzh-badge_3.cjs.entry.js.map +1 -1
- package/dist/cjs/stzh-components.cjs.js +2 -2
- package/dist/cjs/stzh-datepicker_3.cjs.entry.js +2 -0
- package/dist/cjs/stzh-datepicker_3.cjs.entry.js.map +1 -1
- package/dist/cjs/stzh-header.cjs.entry.js +57 -17
- package/dist/cjs/stzh-header.cjs.entry.js.map +1 -1
- package/dist/cjs/stzh-olmap.cjs.entry.js.map +1 -1
- package/dist/cjs/stzh-pagetitle.cjs.entry.js +1 -1
- package/dist/cjs/stzh-pagetitle.cjs.entry.js.map +1 -1
- package/dist/cjs/stzh-row.cjs.entry.js +1 -1
- package/dist/cjs/stzh-row.cjs.entry.js.map +1 -1
- package/dist/collection/assets/i18n/de.json +3 -0
- package/dist/collection/assets/i18n/en.json +3 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/stzh-app-nav/stzh-app-nav.css +247 -0
- package/dist/collection/components/stzh-app-nav/stzh-app-nav.e2e.js +16 -0
- package/dist/collection/components/stzh-app-nav/stzh-app-nav.e2e.js.map +1 -0
- package/dist/collection/components/stzh-app-nav/stzh-app-nav.js +79 -0
- package/dist/collection/components/stzh-app-nav/stzh-app-nav.js.map +1 -0
- package/dist/collection/components/stzh-app-nav/stzh-app-nav.localization.js +2 -0
- package/dist/collection/components/stzh-app-nav/stzh-app-nav.localization.js.map +1 -0
- package/dist/collection/components/stzh-app-nav/stzh-app-nav.stories.js +68 -0
- package/dist/collection/components/stzh-datepicker/stzh-datepicker.js +2 -0
- package/dist/collection/components/stzh-datepicker/stzh-datepicker.js.map +1 -1
- package/dist/collection/components/stzh-header/stzh-header.css +31 -2
- package/dist/collection/components/stzh-header/stzh-header.js +144 -21
- package/dist/collection/components/stzh-header/stzh-header.js.map +1 -1
- package/dist/collection/components/stzh-header/stzh-header.stories.js +72 -62
- package/dist/collection/components/stzh-icon/stzh-icon.js +38 -17
- package/dist/collection/components/stzh-icon/stzh-icon.js.map +1 -1
- package/dist/collection/components/stzh-olmap/stzh-olmap.js +1 -1
- package/dist/collection/components/stzh-olmap/stzh-olmap.js.map +1 -1
- package/dist/collection/components/stzh-pagetitle/stzh-pagetitle.css +0 -1
- package/dist/collection/components/stzh-row/stzh-row.css +184 -240
- package/dist/collection/index.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js.map +1 -1
- package/dist/components/stzh-app-nav.d.ts +11 -0
- package/dist/components/stzh-app-nav.js +8 -0
- package/dist/components/stzh-app-nav.js.map +1 -0
- package/dist/components/stzh-app-nav2.js +64 -0
- package/dist/components/stzh-app-nav2.js.map +1 -0
- package/dist/components/stzh-datepicker2.js +2 -0
- package/dist/components/stzh-datepicker2.js.map +1 -1
- package/dist/components/stzh-header.js +84 -25
- package/dist/components/stzh-header.js.map +1 -1
- package/dist/components/stzh-icon2.js +38 -17
- package/dist/components/stzh-icon2.js.map +1 -1
- package/dist/components/stzh-olmap.js.map +1 -1
- package/dist/components/stzh-pagetitle.js +1 -1
- package/dist/components/stzh-pagetitle.js.map +1 -1
- package/dist/components/stzh-row.js +1 -1
- package/dist/components/stzh-row.js.map +1 -1
- package/dist/esm/{app-globals-b82e4e9d.js → app-globals-93cc928b.js} +2 -2
- package/dist/esm/{app-globals-b82e4e9d.js.map → app-globals-93cc928b.js.map} +1 -1
- package/dist/esm/index-e3050b18.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/stzh-app-nav.entry.js +28 -0
- package/dist/esm/stzh-app-nav.entry.js.map +1 -0
- package/dist/esm/stzh-badge_3.entry.js +38 -17
- package/dist/esm/stzh-badge_3.entry.js.map +1 -1
- package/dist/esm/stzh-components.js +2 -2
- package/dist/esm/stzh-datepicker_3.entry.js +2 -0
- package/dist/esm/stzh-datepicker_3.entry.js.map +1 -1
- package/dist/esm/stzh-header.entry.js +57 -17
- package/dist/esm/stzh-header.entry.js.map +1 -1
- package/dist/esm/stzh-olmap.entry.js.map +1 -1
- package/dist/esm/stzh-pagetitle.entry.js +1 -1
- package/dist/esm/stzh-pagetitle.entry.js.map +1 -1
- package/dist/esm/stzh-row.entry.js +1 -1
- package/dist/esm/stzh-row.entry.js.map +1 -1
- package/dist/stzh-components/assets/i18n/de.json +3 -0
- package/dist/stzh-components/assets/i18n/en.json +3 -0
- package/dist/stzh-components/index.esm.js.map +1 -1
- package/dist/stzh-components/{p-d869745a.js → p-097bf2c2.js} +2 -2
- package/dist/stzh-components/p-10dc377b.entry.js +2 -0
- package/dist/stzh-components/p-10dc377b.entry.js.map +1 -0
- package/dist/stzh-components/p-487b6e52.entry.js +2 -0
- package/dist/stzh-components/p-487b6e52.entry.js.map +1 -0
- package/dist/stzh-components/p-4f7f4362.entry.js +2 -0
- package/dist/stzh-components/p-4f7f4362.entry.js.map +1 -0
- package/dist/stzh-components/p-6a1d65ce.entry.js +2 -0
- package/dist/stzh-components/p-6a1d65ce.entry.js.map +1 -0
- package/dist/stzh-components/p-b4f5d152.entry.js.map +1 -1
- package/dist/stzh-components/{p-c9265a65.entry.js → p-f0887c02.entry.js} +2 -2
- package/dist/stzh-components/p-f0887c02.entry.js.map +1 -0
- package/dist/stzh-components/p-f42f6787.entry.js +2 -0
- package/dist/stzh-components/p-f42f6787.entry.js.map +1 -0
- package/dist/stzh-components/stzh-components.esm.js +1 -1
- package/dist/stzh-components/stzh-components.esm.js.map +1 -1
- package/dist/types/components/stzh-app-nav/stzh-app-nav.d.ts +11 -0
- package/dist/types/components/stzh-app-nav/stzh-app-nav.localization.d.ts +4 -0
- package/dist/types/components/stzh-header/stzh-header.d.ts +18 -5
- package/dist/types/components/stzh-icon/stzh-icon.d.ts +3 -1
- package/dist/types/components/stzh-olmap/stzh-olmap.d.ts +1 -1
- package/dist/types/components.d.ts +75 -12
- package/dist/types/index.d.ts +10 -0
- package/dist/vscode-data.json +22 -6
- package/package.json +1 -1
- package/dist/stzh-components/p-6e29bc61.entry.js +0 -2
- package/dist/stzh-components/p-6e29bc61.entry.js.map +0 -1
- package/dist/stzh-components/p-b047262a.entry.js +0 -2
- package/dist/stzh-components/p-b047262a.entry.js.map +0 -1
- package/dist/stzh-components/p-b608bf1a.entry.js +0 -2
- package/dist/stzh-components/p-b608bf1a.entry.js.map +0 -1
- package/dist/stzh-components/p-b62c870a.entry.js +0 -2
- package/dist/stzh-components/p-b62c870a.entry.js.map +0 -1
- package/dist/stzh-components/p-c9265a65.entry.js.map +0 -1
- /package/dist/stzh-components/{p-d869745a.js.map → p-097bf2c2.js.map} +0 -0
|
@@ -3,6 +3,8 @@ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal
|
|
|
3
3
|
const stzhIconCss = ":host{font-family:var(--stzh-font-family-medium);font-weight:var(--stzh-font-weight-medium);font-style:var(--stzh-font-style-medium);color:var(--stzh-base-color);box-sizing:border-box;display:block;}:host[hidden]{display:none}:host::-moz-selection{color:var(--stzh-selection-color);background-color:var(--stzh-selection-background-color)}:host::selection{color:var(--stzh-selection-color);background-color:var(--stzh-selection-background-color)}:host *,:host *::before,:host *::after{box-sizing:border-box;text-underline-offset:var(--stzh-link-text-underline-offset);text-decoration-thickness:var(--stzh-link-text-decoration-thickness);-webkit-text-decoration-skip-ink:var(--stzh-link-text-decoration-skip-ink);text-decoration-skip-ink:var(--stzh-link-text-decoration-skip-ink)}:host .has-focus{outline:var(--stzh-flyingfocus-color) solid 0.125rem;outline-offset:0.125rem}:host .stzh-fylingfocus-focused{outline-style:none !important}:host .stzh-fylingfocus-focused::-moz-focus-inner{border:0 !important}:host{--size:var(--stzh-icon-size);--color:var(--stzh-icon-color);--vertical-align:var(--stzh-icon-vertical-align);display:inline-flex;justify-content:center;align-items:center;color:var(--color);vertical-align:var(--vertical-align);width:var(--size);height:var(--size)}@media print{:host{-webkit-print-color-adjust:exact;print-color-adjust:exact}}.stzh-icon{display:none}.stzh-icon__svg{width:var(--size);height:var(--size)}";
|
|
4
4
|
|
|
5
5
|
let iconCounter = 0;
|
|
6
|
+
// Shared cache for all instances to store fetched SVG icons
|
|
7
|
+
const iconCache = new Map();
|
|
6
8
|
const StzhIcon = /*@__PURE__*/ proxyCustomElement(class StzhIcon extends HTMLElement {
|
|
7
9
|
constructor() {
|
|
8
10
|
super();
|
|
@@ -16,24 +18,30 @@ const StzhIcon = /*@__PURE__*/ proxyCustomElement(class StzhIcon extends HTMLEle
|
|
|
16
18
|
async nameWatcher(name) {
|
|
17
19
|
this.iconDisplay = "none";
|
|
18
20
|
if (name) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const svgDoc = parser.parseFromString(svgString, 'image/svg+xml');
|
|
24
|
-
this.svgElement = svgDoc.documentElement;
|
|
25
|
-
this.svgElement.classList.add('stzh-icon__svg');
|
|
26
|
-
// for some obscure reason we need to delay showing the icon in safari,
|
|
27
|
-
// otherwise the icon doesn't show up randomly
|
|
28
|
-
// TODO: sometimes the icon still randomely disappears when clicked on page (check on newer safari if problems still occur)
|
|
29
|
-
window.setTimeout(() => {
|
|
30
|
-
this.iconDisplay = "contents";
|
|
31
|
-
}, 0);
|
|
32
|
-
this.a11yTitleWatcher(this.a11yTitle);
|
|
21
|
+
if (iconCache.has(name)) {
|
|
22
|
+
this.svgHtml = await iconCache.get(name);
|
|
23
|
+
this.updateAccessibilityAttributes();
|
|
24
|
+
this.showIcon();
|
|
33
25
|
}
|
|
34
26
|
else {
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const fetchSvgPromise = fetch(`${window.stzhComponents.pathMedia}/icons/mono/${this.name}.svg`)
|
|
28
|
+
.then(response => {
|
|
29
|
+
if (response.status === 200) {
|
|
30
|
+
return response.text();
|
|
31
|
+
}
|
|
32
|
+
throw new Error('Failed to fetch icon');
|
|
33
|
+
})
|
|
34
|
+
.then(svgString => {
|
|
35
|
+
const parser = new DOMParser();
|
|
36
|
+
const svgDoc = parser.parseFromString(svgString, 'image/svg+xml');
|
|
37
|
+
const svgElement = svgDoc.documentElement;
|
|
38
|
+
svgElement.classList.add('stzh-icon__svg');
|
|
39
|
+
return svgElement.outerHTML;
|
|
40
|
+
});
|
|
41
|
+
iconCache.set(name, fetchSvgPromise);
|
|
42
|
+
this.svgHtml = await fetchSvgPromise;
|
|
43
|
+
this.updateAccessibilityAttributes();
|
|
44
|
+
this.showIcon();
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
47
|
else {
|
|
@@ -42,6 +50,8 @@ const StzhIcon = /*@__PURE__*/ proxyCustomElement(class StzhIcon extends HTMLEle
|
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
a11yTitleWatcher(a11yTitle) {
|
|
53
|
+
if (!this.svgElement)
|
|
54
|
+
return;
|
|
45
55
|
this.svgElement.setAttribute("aria-hidden", a11yTitle ? "false" : "true");
|
|
46
56
|
this.svgElement.setAttribute("focusable", a11yTitle ? "true" : "false");
|
|
47
57
|
this.svgElement.setAttribute("aria-labelledby", a11yTitle ? `${this.iconId}-title` : null);
|
|
@@ -56,7 +66,18 @@ const StzhIcon = /*@__PURE__*/ proxyCustomElement(class StzhIcon extends HTMLEle
|
|
|
56
66
|
}
|
|
57
67
|
async componentWillLoad() {
|
|
58
68
|
this.iconId = `stzh-icon-${iconCounter++}`;
|
|
59
|
-
this.nameWatcher(this.name);
|
|
69
|
+
await this.nameWatcher(this.name);
|
|
70
|
+
}
|
|
71
|
+
updateAccessibilityAttributes() {
|
|
72
|
+
this.a11yTitleWatcher(this.a11yTitle);
|
|
73
|
+
}
|
|
74
|
+
showIcon() {
|
|
75
|
+
// for some obscure reason we need to delay showing the icon in safari,
|
|
76
|
+
// otherwise the icon doesn't show up randomly
|
|
77
|
+
// TODO: sometimes the icon still randomely disappears when clicked on page (check on newer safari if problems still occur)
|
|
78
|
+
window.setTimeout(() => {
|
|
79
|
+
this.iconDisplay = "contents";
|
|
80
|
+
}, 0);
|
|
60
81
|
}
|
|
61
82
|
render() {
|
|
62
83
|
return (h(Host, null, h("div", { class: "stzh-icon", style: { display: this.iconDisplay }, innerHTML: this.svgHtml })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"stzh-icon2.js","mappings":";;AAAA,MAAM,WAAW,GAAG,u5CAAu5C;;ACU36C,IAAI,WAAW,GAAG,CAAC,CAAC;
|
|
1
|
+
{"file":"stzh-icon2.js","mappings":"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","names":[],"sources":["src/components/stzh-icon/stzh-icon.scss?tag=stzh-icon&encapsulation=shadow","src/components/stzh-icon/stzh-icon.tsx"],"sourcesContent":["/**\n * @prop --size: Icon size\n * @prop --color: Icon color\n *\n * @prop --stzh-icon-size: **Global**: Default icon size. [See available icon sizes here](/docs/tokens-icons--docs#sizes).\n * @prop --stzh-icon-color: **Global**: Icon color\n * @prop --stzh-icon-vertical-align: **Global**: Icon vertical alignment\n */\n\n:host {\n --size: #{iconSize()};\n --color: #{$iconColor};\n --vertical-align: #{$iconVerticalAlign};\n\n display: inline-flex;\n justify-content: center;\n align-items: center;\n color: var(--color);\n vertical-align: var(--vertical-align);\n width: var(--size);\n height: var(--size);\n\n @media print {\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n }\n}\n\n.stzh-icon {\n display: none;\n\n &__svg {\n width: var(--size);\n height: var(--size);\n }\n}\n","import {\n Component,\n Host,\n h,\n Prop,\n Watch,\n State,\n Element\n} from \"@stencil/core\";\n\nlet iconCounter = 0;\n\n// Shared cache for all instances to store fetched SVG icons\nconst iconCache = new Map<string, Promise<string>>();\n\n@Component({\n tag: \"stzh-icon\",\n styleUrl: \"stzh-icon.scss\",\n shadow: true\n})\nexport class StzhIcon {\n /**\n * Icon which should be displayed\n * See the [icon overview](stzh-components/assets/svgsprites/symbol/sprite.symbol.html) for a list of all available icons.\n */\n @Prop() name: string = \"\";\n\n /**\n * Hidden icon title for screenreader\n * (usually not needed when e.g. inside links or buttons that have text)\n */\n @Prop({ attribute: 'a11y-title' }) a11yTitle: string = \"\";\n\n @Element() element: HTMLStzhIconElement;\n\n @State() svgHtml: string = \"\";\n @State() iconDisplay: string = \"none\";\n\n @Watch(\"name\")\n async nameWatcher(name: string) {\n this.iconDisplay = \"none\";\n\n if (name) {\n if (iconCache.has(name)) {\n this.svgHtml = await iconCache.get(name)!;\n this.updateAccessibilityAttributes();\n this.showIcon();\n } else {\n const fetchSvgPromise = fetch(`${window.stzhComponents.pathMedia}/icons/mono/${this.name}.svg`)\n .then(response => {\n if (response.status === 200) {\n return response.text();\n }\n throw new Error('Failed to fetch icon');\n })\n .then(svgString => {\n const parser = new DOMParser();\n const svgDoc = parser.parseFromString(svgString, 'image/svg+xml');\n const svgElement = svgDoc.documentElement as unknown as SVGElement;\n svgElement.classList.add('stzh-icon__svg');\n\n return svgElement.outerHTML;\n });\n\n iconCache.set(name, fetchSvgPromise);\n\n this.svgHtml = await fetchSvgPromise;\n this.updateAccessibilityAttributes();\n this.showIcon();\n }\n } else {\n this.svgElement = null;\n this.svgHtml = '';\n }\n }\n\n @Watch(\"a11yTitle\")\n a11yTitleWatcher(a11yTitle: string) {\n if (!this.svgElement) return;\n\n this.svgElement.setAttribute(\"aria-hidden\", a11yTitle ? \"false\" : \"true\");\n this.svgElement.setAttribute(\"focusable\", a11yTitle ? \"true\" : \"false\");\n this.svgElement.setAttribute(\"aria-labelledby\", a11yTitle ? `${this.iconId}-title` : null);\n\n let title = this.svgElement.querySelector('title');\n\n if (!title) {\n title = document.createElement('title');\n title.id = `${this.iconId}-title`;\n this.svgElement.appendChild(title);\n }\n\n title.innerHTML = a11yTitle;\n this.svgHtml = this.svgElement.outerHTML;\n }\n\n private svgElement: SVGElement | null;\n private iconId: string;\n\n async componentWillLoad() {\n this.iconId = `stzh-icon-${iconCounter++}`;\n await this.nameWatcher(this.name);\n }\n\n private updateAccessibilityAttributes() {\n this.a11yTitleWatcher(this.a11yTitle);\n }\n\n private showIcon() {\n // for some obscure reason we need to delay showing the icon in safari,\n // otherwise the icon doesn't show up randomly\n // TODO: sometimes the icon still randomely disappears when clicked on page (check on newer safari if problems still occur)\n window.setTimeout(() => {\n this.iconDisplay = \"contents\";\n }, 0);\n }\n\n render() {\n return (\n <Host>\n <div class=\"stzh-icon\" style={{ display: this.iconDisplay }} innerHTML={this.svgHtml}></div>\n </Host>\n );\n }\n}\n"],"version":3}
|