@pine-ds/icons 3.2.0 → 3.3.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/components/pds-icon.d.ts +2 -2
- package/components/pds-icon.js +175 -171
- package/components/pds-icon.js.map +1 -1
- package/components/utils.js +65 -45
- package/components/utils.js.map +1 -1
- package/dist/cheatsheet.html +4 -4
- package/dist/cjs/{index-b35d5b0f.js → index-17212f65.js} +81 -21
- package/dist/cjs/index-17212f65.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/pds-icon.cjs.entry.js +152 -150
- package/dist/cjs/pds-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/pds-icons.cjs.js +3 -3
- package/dist/cjs/pds-icons.cjs.js.map +1 -1
- package/dist/cjs/utils-8c57ce6a.js +101 -0
- package/dist/cjs/utils-8c57ce6a.js.map +1 -0
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/pds-icon/pds-icon.js +189 -168
- package/dist/collection/components/pds-icon/pds-icon.js.map +1 -1
- package/dist/collection/components/pds-icon/request.js +21 -21
- package/dist/collection/components/pds-icon/request.js.map +1 -1
- package/dist/collection/components/pds-icon/svg/blog-filled.svg +1 -1
- package/dist/collection/components/pds-icon/test/pds-icon.e2e.js +6 -6
- package/dist/collection/components/pds-icon/test/pds-icon.e2e.js.map +1 -1
- package/dist/collection/components/pds-icon/test/pds-icon.spec.js +69 -31
- package/dist/collection/components/pds-icon/test/pds-icon.spec.js.map +1 -1
- package/dist/collection/components/pds-icon/utils.js +61 -51
- package/dist/collection/components/pds-icon/utils.js.map +1 -1
- package/dist/collection/components/pds-icon/validate.js +35 -35
- package/dist/collection/components/pds-icon/validate.js.map +1 -1
- package/dist/docs.json +23 -2
- package/dist/esm/{index-8effeb27.js → index-d1a605fc.js} +81 -21
- package/dist/esm/index-d1a605fc.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/pds-icon.entry.js +152 -150
- package/dist/esm/pds-icon.entry.js.map +1 -1
- package/dist/esm/pds-icons.js +4 -4
- package/dist/esm/pds-icons.js.map +1 -1
- package/dist/esm/utils-15462a67.js +95 -0
- package/dist/esm/utils-15462a67.js.map +1 -0
- package/dist/pds-icons/index.esm.js +1 -1
- package/dist/pds-icons/p-19d7058a.js +3 -0
- package/dist/pds-icons/p-19d7058a.js.map +1 -0
- package/dist/pds-icons/p-229b8f4e.entry.js +2 -0
- package/dist/pds-icons/p-229b8f4e.entry.js.map +1 -0
- package/dist/pds-icons/p-f0b1dbd6.js +2 -0
- package/dist/pds-icons/p-f0b1dbd6.js.map +1 -0
- package/dist/pds-icons/pds-icons.esm.js +1 -1
- package/dist/pds-icons/pds-icons.esm.js.map +1 -1
- package/dist/pds-icons.json +1 -1
- package/dist/pds-icons.symbols.svg +2 -2
- package/dist/svg/blog-filled.svg +1 -1
- package/dist/types/components/pds-icon/pds-icon.d.ts +41 -35
- package/dist/types/components/pds-icon/utils.d.ts +4 -4
- package/dist/types/components.d.ts +8 -0
- package/dist/types/stencil-public-runtime.d.ts +29 -0
- package/icons/index.d.ts +1 -1
- package/icons/index.js +2 -2
- package/icons/index.mjs +2 -2
- package/icons/package.json +1 -1
- package/package.json +6 -6
- package/dist/cjs/index-b35d5b0f.js.map +0 -1
- package/dist/cjs/utils-395a38b7.js +0 -81
- package/dist/cjs/utils-395a38b7.js.map +0 -1
- package/dist/esm/index-8effeb27.js.map +0 -1
- package/dist/esm/utils-a0ad61d0.js +0 -75
- package/dist/esm/utils-a0ad61d0.js.map +0 -1
- package/dist/pds-icons/p-91678731.entry.js +0 -2
- package/dist/pds-icons/p-91678731.entry.js.map +0 -1
- package/dist/pds-icons/p-a3383818.js +0 -3
- package/dist/pds-icons/p-a3383818.js.map +0 -1
- package/dist/pds-icons/p-dc5765cb.js +0 -2
- package/dist/pds-icons/p-dc5765cb.js.map +0 -1
|
@@ -2,185 +2,206 @@ import { Build, Host, h } from "@stencil/core";
|
|
|
2
2
|
import { getSvgContent, pdsIconContent } from "./request";
|
|
3
3
|
import { getName, getUrl, inheritAttributes } from "./utils";
|
|
4
4
|
export class PdsIcon {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
iconSize() {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
const sizes = {
|
|
21
|
-
small: '12px',
|
|
22
|
-
regular: '16px',
|
|
23
|
-
medium: '20px',
|
|
24
|
-
large: '24px',
|
|
25
|
-
};
|
|
26
|
-
if (sizes[this.size]) {
|
|
27
|
-
return sizes[this.size];
|
|
5
|
+
constructor() {
|
|
6
|
+
this.inheritedAttributes = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
7
|
+
this.hasAriaHidden = () => {
|
|
8
|
+
const { el } = this;
|
|
9
|
+
return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';
|
|
10
|
+
};
|
|
11
|
+
this.ariaLabel = undefined;
|
|
12
|
+
this.isVisible = false;
|
|
13
|
+
this.svgContent = undefined;
|
|
14
|
+
this.color = undefined;
|
|
15
|
+
this.icon = undefined;
|
|
16
|
+
this.name = undefined;
|
|
17
|
+
this.size = 'regular';
|
|
28
18
|
}
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
iconSize() {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const sizes = {
|
|
22
|
+
small: '12px',
|
|
23
|
+
regular: '16px',
|
|
24
|
+
medium: '20px',
|
|
25
|
+
large: '24px',
|
|
26
|
+
};
|
|
27
|
+
if (sizes[this.size]) {
|
|
28
|
+
return sizes[this.size];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return this.size;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
componentWillLoad() {
|
|
35
|
+
this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.waitUntilVisible(this.el, '50px', () => {
|
|
38
|
-
this.isVisible = true;
|
|
39
|
-
this.loadIcon();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
disconnectedCallback() {
|
|
43
|
-
if (this.io) {
|
|
44
|
-
this.io.disconnect();
|
|
45
|
-
this.io = undefined;
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
this.waitUntilVisible(this.el, '50px', () => {
|
|
39
|
+
this.isVisible = true;
|
|
40
|
+
this.loadIcon();
|
|
41
|
+
});
|
|
46
42
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (url) {
|
|
52
|
-
if (pdsIconContent.has(url)) {
|
|
53
|
-
this.svgContent = pdsIconContent.get(url);
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
if (this.io) {
|
|
45
|
+
this.io.disconnect();
|
|
46
|
+
this.io = undefined;
|
|
54
47
|
}
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
}
|
|
49
|
+
loadIcon() {
|
|
50
|
+
if (Build.isBrowser && this.isVisible) {
|
|
51
|
+
const url = getUrl(this);
|
|
52
|
+
if (url) {
|
|
53
|
+
if (pdsIconContent.has(url)) {
|
|
54
|
+
this.svgContent = pdsIconContent.get(url);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
getSvgContent(url).then(() => (this.svgContent = pdsIconContent.get(url)));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const label = getName(this.name, this.icon);
|
|
62
|
+
if (label) {
|
|
63
|
+
this.ariaLabel = label.replace(/\-/g, ' ');
|
|
57
64
|
}
|
|
58
|
-
}
|
|
59
65
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
render() {
|
|
67
|
+
const { ariaLabel, inheritedAttributes } = this;
|
|
68
|
+
const style = {
|
|
69
|
+
height: this.iconSize(),
|
|
70
|
+
width: this.iconSize(),
|
|
71
|
+
color: this.color,
|
|
72
|
+
};
|
|
73
|
+
return (h(Host, Object.assign({ "aria-label": ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null, role: "img", style: style, class: Object.assign({}, createColorClasses(this.color)) }, inheritedAttributes), Build.isBrowser && this.svgContent ? (h("div", { class: "icon-inner", innerHTML: this.svgContent })) : (h("div", { class: "icon-inner" }))));
|
|
63
74
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
waitUntilVisible(el, rootMargin, cb) {
|
|
78
|
-
if (Build.isBrowser && typeof window !== 'undefined' && (window).IntersectionObserver) {
|
|
79
|
-
const io = (this.io = new (window).IntersectionObserver((data) => {
|
|
80
|
-
if (data[0].isIntersecting) {
|
|
81
|
-
io.disconnect();
|
|
82
|
-
this.io = undefined;
|
|
83
|
-
cb();
|
|
75
|
+
/*****
|
|
76
|
+
* Private Methods
|
|
77
|
+
****/
|
|
78
|
+
waitUntilVisible(el, rootMargin, cb) {
|
|
79
|
+
if (Build.isBrowser && typeof window !== 'undefined' && (window).IntersectionObserver) {
|
|
80
|
+
const io = (this.io = new (window).IntersectionObserver((data) => {
|
|
81
|
+
if (data[0].isIntersecting) {
|
|
82
|
+
io.disconnect();
|
|
83
|
+
this.io = undefined;
|
|
84
|
+
cb();
|
|
85
|
+
}
|
|
86
|
+
}, { rootMargin }));
|
|
87
|
+
io.observe(el);
|
|
84
88
|
}
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
else {
|
|
90
|
+
// browser doesn't support IntersectionObserver
|
|
91
|
+
// so just fallback to always show it
|
|
92
|
+
cb();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
static get is() { return "pds-icon"; }
|
|
96
|
+
static get encapsulation() { return "shadow"; }
|
|
97
|
+
static get originalStyleUrls() {
|
|
98
|
+
return {
|
|
99
|
+
"$": ["pds-icon.scss"]
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
static get styleUrls() {
|
|
103
|
+
return {
|
|
104
|
+
"$": ["pds-icon.css"]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
static get assetsDirs() { return ["svg"]; }
|
|
108
|
+
static get properties() {
|
|
109
|
+
return {
|
|
110
|
+
"color": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"mutable": false,
|
|
113
|
+
"complexType": {
|
|
114
|
+
"original": "string",
|
|
115
|
+
"resolved": "string",
|
|
116
|
+
"references": {}
|
|
117
|
+
},
|
|
118
|
+
"required": false,
|
|
119
|
+
"optional": true,
|
|
120
|
+
"docs": {
|
|
121
|
+
"tags": [],
|
|
122
|
+
"text": "\nThe color of the icon"
|
|
123
|
+
},
|
|
124
|
+
"attribute": "color",
|
|
125
|
+
"reflect": false
|
|
126
|
+
},
|
|
127
|
+
"icon": {
|
|
128
|
+
"type": "any",
|
|
129
|
+
"mutable": false,
|
|
130
|
+
"complexType": {
|
|
131
|
+
"original": "any",
|
|
132
|
+
"resolved": "any",
|
|
133
|
+
"references": {}
|
|
134
|
+
},
|
|
135
|
+
"required": false,
|
|
136
|
+
"optional": true,
|
|
137
|
+
"docs": {
|
|
138
|
+
"tags": [],
|
|
139
|
+
"text": "This a combination of both `name` and `src`. If a `src` url is detected\nit will set the `src` property. Otherwise it assumes it's a built-in named\nSVG and set the `name` property."
|
|
140
|
+
},
|
|
141
|
+
"attribute": "icon",
|
|
142
|
+
"reflect": false
|
|
143
|
+
},
|
|
144
|
+
"name": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"mutable": false,
|
|
147
|
+
"complexType": {
|
|
148
|
+
"original": "string",
|
|
149
|
+
"resolved": "string",
|
|
150
|
+
"references": {}
|
|
151
|
+
},
|
|
152
|
+
"required": false,
|
|
153
|
+
"optional": true,
|
|
154
|
+
"docs": {
|
|
155
|
+
"tags": [],
|
|
156
|
+
"text": "The name of the icon to use from\nthe built-in set."
|
|
157
|
+
},
|
|
158
|
+
"attribute": "name",
|
|
159
|
+
"reflect": true
|
|
160
|
+
},
|
|
161
|
+
"size": {
|
|
162
|
+
"type": "string",
|
|
163
|
+
"mutable": false,
|
|
164
|
+
"complexType": {
|
|
165
|
+
"original": "| 'small' // 12px\n | 'regular' // 16px\n | 'medium' // 20px\n | 'large' // 24px\n | 'auto'\n | string",
|
|
166
|
+
"resolved": "string",
|
|
167
|
+
"references": {}
|
|
168
|
+
},
|
|
169
|
+
"required": false,
|
|
170
|
+
"optional": true,
|
|
171
|
+
"docs": {
|
|
172
|
+
"tags": [],
|
|
173
|
+
"text": "The size of the icon. This can be\n'small', 'regular', 'medium', large, or a\ncustom value (40px, 1rem, etc)"
|
|
174
|
+
},
|
|
175
|
+
"attribute": "size",
|
|
176
|
+
"reflect": true,
|
|
177
|
+
"defaultValue": "'regular'"
|
|
178
|
+
}
|
|
179
|
+
};
|
|
87
180
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
181
|
+
static get states() {
|
|
182
|
+
return {
|
|
183
|
+
"ariaLabel": {},
|
|
184
|
+
"isVisible": {},
|
|
185
|
+
"svgContent": {}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
static get elementRef() { return "el"; }
|
|
189
|
+
static get watchers() {
|
|
190
|
+
return [{
|
|
191
|
+
"propName": "name",
|
|
192
|
+
"methodName": "loadIcon"
|
|
193
|
+
}, {
|
|
194
|
+
"propName": "icon",
|
|
195
|
+
"methodName": "loadIcon"
|
|
196
|
+
}];
|
|
92
197
|
}
|
|
93
|
-
}
|
|
94
|
-
static get is() { return "pds-icon"; }
|
|
95
|
-
static get encapsulation() { return "shadow"; }
|
|
96
|
-
static get originalStyleUrls() {
|
|
97
|
-
return {
|
|
98
|
-
"$": ["pds-icon.scss"]
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
static get styleUrls() {
|
|
102
|
-
return {
|
|
103
|
-
"$": ["pds-icon.css"]
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
static get assetsDirs() { return ["svg"]; }
|
|
107
|
-
static get properties() {
|
|
108
|
-
return {
|
|
109
|
-
"color": {
|
|
110
|
-
"type": "string",
|
|
111
|
-
"mutable": false,
|
|
112
|
-
"complexType": {
|
|
113
|
-
"original": "string",
|
|
114
|
-
"resolved": "string",
|
|
115
|
-
"references": {}
|
|
116
|
-
},
|
|
117
|
-
"required": false,
|
|
118
|
-
"optional": true,
|
|
119
|
-
"docs": {
|
|
120
|
-
"tags": [],
|
|
121
|
-
"text": "\nThe color of the icon"
|
|
122
|
-
},
|
|
123
|
-
"attribute": "color",
|
|
124
|
-
"reflect": false
|
|
125
|
-
},
|
|
126
|
-
"name": {
|
|
127
|
-
"type": "string",
|
|
128
|
-
"mutable": false,
|
|
129
|
-
"complexType": {
|
|
130
|
-
"original": "string",
|
|
131
|
-
"resolved": "string",
|
|
132
|
-
"references": {}
|
|
133
|
-
},
|
|
134
|
-
"required": false,
|
|
135
|
-
"optional": true,
|
|
136
|
-
"docs": {
|
|
137
|
-
"tags": [],
|
|
138
|
-
"text": "The name of the icon to use from\nthe built-in set."
|
|
139
|
-
},
|
|
140
|
-
"attribute": "name",
|
|
141
|
-
"reflect": true
|
|
142
|
-
},
|
|
143
|
-
"size": {
|
|
144
|
-
"type": "string",
|
|
145
|
-
"mutable": false,
|
|
146
|
-
"complexType": {
|
|
147
|
-
"original": "| 'small' // 12px\n | 'regular' // 16px\n | 'medium' // 20px\n | 'large' // 24px\n | 'auto'\n | string",
|
|
148
|
-
"resolved": "string",
|
|
149
|
-
"references": {}
|
|
150
|
-
},
|
|
151
|
-
"required": false,
|
|
152
|
-
"optional": true,
|
|
153
|
-
"docs": {
|
|
154
|
-
"tags": [],
|
|
155
|
-
"text": "The size of the icon. This can be\n'small', 'regular', 'medium', large, or a\ncustom value (40px, 1rem, etc)"
|
|
156
|
-
},
|
|
157
|
-
"attribute": "size",
|
|
158
|
-
"reflect": true,
|
|
159
|
-
"defaultValue": "'regular'"
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
static get states() {
|
|
164
|
-
return {
|
|
165
|
-
"ariaLabel": {},
|
|
166
|
-
"isVisible": {},
|
|
167
|
-
"svgContent": {}
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
static get elementRef() { return "el"; }
|
|
171
|
-
static get watchers() {
|
|
172
|
-
return [{
|
|
173
|
-
"propName": "name",
|
|
174
|
-
"methodName": "loadIcon"
|
|
175
|
-
}];
|
|
176
|
-
}
|
|
177
198
|
}
|
|
178
199
|
const createColorClasses = (color) => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
200
|
+
return color
|
|
201
|
+
? {
|
|
202
|
+
'pds-color': true,
|
|
203
|
+
[`pds-color-${color}`]: true,
|
|
204
|
+
}
|
|
205
|
+
: null;
|
|
185
206
|
};
|
|
186
207
|
//# sourceMappingURL=pds-icon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds-icon.js","sourceRoot":"","sources":["../../../src/components/pds-icon/pds-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,SAAS,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F;AAED,MAAM,kBAAkB,GAAG,CAAC,KAAyB,EAAE,EAAE;IACvD,OAAO,KAAK;QACX,CAAC,CAAC;YACE,WAAW,EAAE,IAAI;YACjB,CAAC,aAAa,KAAK,EAAE,CAAC,EAAE,IAAI;SAC7B;QACH,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC","sourcesContent":["import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';\nimport { getSvgContent, pdsIconContent } from './request';\nimport { getName, getUrl, inheritAttributes } from './utils';\n\n@Component({\n tag: 'pds-icon',\n assetsDirs: ['svg'],\n styleUrl: 'pds-icon.scss',\n shadow: true,\n})\nexport class PdsIcon {\n private io?: IntersectionObserver;\n private inheritedAttributes: { [k: string]: any } = {}; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n @Element() el!: HTMLPdsIconElement;\n\n @State() private ariaLabel?: string;\n @State() private isVisible = false;\n @State() private svgContent?: string;\n\n /**\n *\n * The color of the icon\n *\n */\n @Prop() color?: string;\n\n /**\n * This a combination of both `name` and `src`. If a `src` url is detected\n * it will set the `src` property. Otherwise it assumes it's a built-in named\n * SVG and set the `name` property.\n */\n @Prop() icon?: any;\n\n /**\n * The name of the icon to use from\n * the built-in set.\n */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * The size of the icon. This can be\n * 'small', 'regular', 'medium', large, or a\n * custom value (40px, 1rem, etc)\n *\n */\n @Prop({ reflect: true }) size?:\n | 'small' // 12px\n | 'regular' // 16px\n | 'medium' // 20px\n | 'large' // 24px\n | 'auto'\n | string = 'regular'\n\n private iconSize() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sizes: { [key: string]: any } = {\n small: '12px',\n regular: '16px',\n medium: '20px',\n large: '24px',\n }\n\n if (sizes[this.size]) {\n return sizes[this.size];\n } else {\n return this.size;\n }\n }\n componentWillLoad() {\n this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);\n }\n\n connectedCallback() {\n this.waitUntilVisible(this.el, '50px', () => {\n this.isVisible = true;\n this.loadIcon();\n })\n }\n\n disconnectedCallback() {\n if (this.io) {\n this.io.disconnect();\n this.io = undefined;\n }\n }\n\n @Watch('name')\n @Watch('icon')\n loadIcon() {\n if (Build.isBrowser && this.isVisible) {\n const url = getUrl(this);\n if (url) {\n if (pdsIconContent.has(url)) {\n this.svgContent = pdsIconContent.get(url);\n } else {\n getSvgContent(url).then(() => (this.svgContent = pdsIconContent.get(url)));\n }\n }\n }\n\n const label = getName(this.name, this.icon);\n\n if (label) {\n this.ariaLabel = label.replace(/\\-/g, ' ');\n }\n }\n\n render() {\n const { ariaLabel, inheritedAttributes } = this;\n\n const style = {\n height: this.iconSize(),\n width: this.iconSize(),\n color: this.color,\n }\n\n return (\n\n <Host\n aria-label={ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null }\n role=\"img\"\n style={style}\n class={{\n ...createColorClasses(this.color),\n }}\n {...inheritedAttributes}\n >\n {Build.isBrowser && this.svgContent ? (\n <div class=\"icon-inner\" innerHTML={this.svgContent}></div>\n ) : (\n <div class=\"icon-inner\"></div>\n )}\n </Host>\n )\n }\n\n /*****\n * Private Methods\n ****/\n\n private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {\n if (Build.isBrowser && typeof window !== 'undefined' && (window).IntersectionObserver) {\n const io = (this.io = new (window).IntersectionObserver(\n (data: IntersectionObserverEntry[]) => {\n if (data[0].isIntersecting) {\n io.disconnect();\n this.io = undefined;\n cb();\n }\n },\n { rootMargin },\n ));\n\n io.observe(el);\n } else {\n // browser doesn't support IntersectionObserver\n // so just fallback to always show it\n cb();\n }\n }\n\n private hasAriaHidden = () => {\n const { el } = this;\n\n return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';\n }\n}\n\nconst createColorClasses = (color: string | undefined) => {\n return color\n ? {\n 'pds-color': true,\n [`pds-color-${color}`]: true,\n }\n : null;\n };\n"]}
|
|
@@ -2,28 +2,28 @@ import { validateContent } from "./validate";
|
|
|
2
2
|
export const pdsIconContent = new Map();
|
|
3
3
|
const requests = new Map(); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4
4
|
export const getSvgContent = (url, sanitize = false) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
let req = requests.get(url);
|
|
6
|
+
if (!req) {
|
|
7
|
+
if (typeof fetch != 'undefined' && typeof document !== 'undefined') {
|
|
8
|
+
// we don't have a request
|
|
9
|
+
req = fetch(url).then((rsp) => {
|
|
10
|
+
if (rsp.ok) {
|
|
11
|
+
return rsp.text().then((svgContent) => {
|
|
12
|
+
if (svgContent && sanitize !== false) {
|
|
13
|
+
svgContent = validateContent(svgContent);
|
|
14
|
+
}
|
|
15
|
+
pdsIconContent.set(url, svgContent || '');
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
pdsIconContent.set(url, '');
|
|
19
|
+
});
|
|
20
|
+
requests.set(url, req);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
pdsIconContent.set(url, '');
|
|
24
|
+
return Promise.resolve();
|
|
17
25
|
}
|
|
18
|
-
pdsIconContent.set(url, '');
|
|
19
|
-
});
|
|
20
|
-
requests.set(url, req);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
pdsIconContent.set(url, '');
|
|
24
|
-
return Promise.resolve();
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
return req;
|
|
27
|
+
return req;
|
|
28
28
|
};
|
|
29
29
|
//# sourceMappingURL=request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/components/pds-icon/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,G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,GAAG,EAAE,GAAG,CAAC,CAAC;SACxB;aAAM;YACL,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAA","sourcesContent":["import { validateContent } from './validate';\n\nexport const pdsIconContent = new Map<string, string>();\nconst requests = new Map<string, Promise<any>>(); // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport const getSvgContent = (url: string, sanitize = false) => {\n let req = requests.get(url);\n\n if(!req) {\n if (typeof fetch != 'undefined' && typeof document !== 'undefined') {\n // we don't have a request\n req = fetch(url).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n pdsIconContent.set(url, svgContent || '');\n });\n }\n pdsIconContent.set(url, '');\n });\n\n requests.set(url, req);\n } else {\n pdsIconContent.set(url, '');\n return Promise.resolve();\n }\n }\n return req;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="pdsicon"><path d="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="pdsicon"><path d="M14 0H2a.667.667 0 0 0-.667.667v14.666c0 .368.299.667.667.667h12a.667.667 0 0 0 .667-.667V.667A.667.667 0 0 0 14 0Zm-2 13c0 .184-.15.333-.333.333H4.333A.333.333 0 0 1 4 13v-.667c0-.184.15-.333.333-.333h7.334c.184 0 .333.15.333.333V13Zm0-3.333c0 .184-.15.333-.333.333H4.333A.333.333 0 0 1 4 9.667V9c0-.184.15-.333.333-.333h7.334c.184 0 .333.149.333.333v.667Zm0-3.334c0 .184-.15.334-.333.334H4.333A.333.333 0 0 1 4 6.333V3c0-.184.15-.333.333-.333h7.334c.184 0 .333.149.333.333v3.333Z"/></svg>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { newE2EPage } from "@stencil/core/testing";
|
|
2
2
|
describe('pds-icon', () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
it('renders', async () => {
|
|
4
|
+
const page = await newE2EPage();
|
|
5
|
+
await page.setContent('<pds-icon role="img" style="height: 16px; width: 16px;"></pds-icon>');
|
|
6
|
+
const element = await page.find('pds-icon');
|
|
7
|
+
expect(element).toHaveClass('hydrated');
|
|
8
|
+
});
|
|
9
9
|
});
|
|
10
10
|
//# sourceMappingURL=pds-icon.e2e.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds-icon.e2e.js","sourceRoot":"","sources":["../../../../src/components/pds-icon/test/pds-icon.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"pds-icon.e2e.js","sourceRoot":"","sources":["../../../../src/components/pds-icon/test/pds-icon.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,CAAC;QAEhC,MAAM,IAAI,CAAC,UAAU,CAAC,qEAAqE,CAAC,CAAC;QAC7F,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newE2EPage } from '@stencil/core/testing';\n\ndescribe('pds-icon', () => {\n it('renders', async () => {\n const page = await newE2EPage();\n\n await page.setContent('<pds-icon role=\"img\" style=\"height: 16px; width: 16px;\"></pds-icon>');\n const element = await page.find('pds-icon');\n expect(element).toHaveClass('hydrated');\n });\n});\n"]}
|
|
@@ -1,70 +1,108 @@
|
|
|
1
1
|
import { newSpecPage } from "@stencil/core/testing";
|
|
2
2
|
import { PdsIcon } from "../pds-icon";
|
|
3
3
|
describe('pds-icon', () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
it('renders', async () => {
|
|
5
|
+
const { root } = await newSpecPage({
|
|
6
|
+
components: [PdsIcon],
|
|
7
|
+
html: '<pds-icon></pds-icon>',
|
|
8
|
+
});
|
|
9
|
+
expect(root).toEqualHtml(`
|
|
10
10
|
<pds-icon role="img" size="regular" style="height: 16px; width: 16px;">
|
|
11
11
|
<mock:shadow-root>
|
|
12
12
|
<div class="icon-inner"></div>
|
|
13
13
|
</mock:shadow-root>
|
|
14
14
|
</pds-icon>
|
|
15
15
|
`);
|
|
16
|
-
});
|
|
17
|
-
it('renders the correct size when passed', async () => {
|
|
18
|
-
const { root } = await newSpecPage({
|
|
19
|
-
components: [PdsIcon],
|
|
20
|
-
html: '<pds-icon size="small"></pds-icon>',
|
|
21
16
|
});
|
|
22
|
-
|
|
17
|
+
it('renders the correct size when passed', async () => {
|
|
18
|
+
const { root } = await newSpecPage({
|
|
19
|
+
components: [PdsIcon],
|
|
20
|
+
html: '<pds-icon size="small"></pds-icon>',
|
|
21
|
+
});
|
|
22
|
+
expect(root).toEqualHtml(`
|
|
23
23
|
<pds-icon role="img" size="small" style="height: 12px; width: 12px;">
|
|
24
24
|
<mock:shadow-root>
|
|
25
25
|
<div class="icon-inner"></div>
|
|
26
26
|
</mock:shadow-root>
|
|
27
27
|
</pds-icon>
|
|
28
28
|
`);
|
|
29
|
-
});
|
|
30
|
-
it('allows custom size', async () => {
|
|
31
|
-
const { root } = await newSpecPage({
|
|
32
|
-
components: [PdsIcon],
|
|
33
|
-
html: '<pds-icon size="32px"></pds-icon>',
|
|
34
29
|
});
|
|
35
|
-
|
|
30
|
+
it('allows custom size', async () => {
|
|
31
|
+
const { root } = await newSpecPage({
|
|
32
|
+
components: [PdsIcon],
|
|
33
|
+
html: '<pds-icon size="32px"></pds-icon>',
|
|
34
|
+
});
|
|
35
|
+
expect(root).toEqualHtml(`
|
|
36
36
|
<pds-icon role="img" size="32px" style="height: 32px; width: 32px;">
|
|
37
37
|
<mock:shadow-root>
|
|
38
38
|
<div class="icon-inner"></div>
|
|
39
39
|
</mock:shadow-root>
|
|
40
40
|
</pds-icon>
|
|
41
41
|
`);
|
|
42
|
-
});
|
|
43
|
-
it('renders icon when found', async () => {
|
|
44
|
-
const { root } = await newSpecPage({
|
|
45
|
-
components: [PdsIcon],
|
|
46
|
-
html: '<pds-icon name="archive"></pds-icon>',
|
|
47
42
|
});
|
|
48
|
-
|
|
43
|
+
it('renders icon when found', async () => {
|
|
44
|
+
const { root } = await newSpecPage({
|
|
45
|
+
components: [PdsIcon],
|
|
46
|
+
html: '<pds-icon name="archive"></pds-icon>',
|
|
47
|
+
});
|
|
48
|
+
expect(root).toEqualHtml(`
|
|
49
49
|
<pds-icon aria-label="archive" name="archive" role="img" size="regular" style="height: 16px; width: 16px;">
|
|
50
50
|
<mock:shadow-root>
|
|
51
51
|
<div class="icon-inner"></div>
|
|
52
52
|
</mock:shadow-root>
|
|
53
53
|
</pds-icon>
|
|
54
54
|
`);
|
|
55
|
-
});
|
|
56
|
-
it('add correct styles when color specified', async () => {
|
|
57
|
-
const { root } = await newSpecPage({
|
|
58
|
-
components: [PdsIcon],
|
|
59
|
-
html: '<pds-icon name="archive" color="red"></pds-icon>',
|
|
60
55
|
});
|
|
61
|
-
|
|
56
|
+
it('add correct styles when color specified', async () => {
|
|
57
|
+
const { root } = await newSpecPage({
|
|
58
|
+
components: [PdsIcon],
|
|
59
|
+
html: '<pds-icon name="archive" color="red"></pds-icon>',
|
|
60
|
+
});
|
|
61
|
+
expect(root).toEqualHtml(`
|
|
62
62
|
<pds-icon aria-label="archive" class="pds-color pds-color-red" color="red" name="archive" role="img" size="regular" style="height: 16px; width: 16px; color: red">
|
|
63
63
|
<mock:shadow-root>
|
|
64
64
|
<div class="icon-inner"></div>
|
|
65
65
|
</mock:shadow-root>
|
|
66
66
|
</pds-icon>
|
|
67
67
|
`);
|
|
68
|
-
|
|
68
|
+
});
|
|
69
|
+
it('renders custom aria-label', async () => {
|
|
70
|
+
const { root } = await newSpecPage({
|
|
71
|
+
components: [PdsIcon],
|
|
72
|
+
html: `<pds-icon name="star" aria-label="custom label"></pds-icon>`,
|
|
73
|
+
});
|
|
74
|
+
expect(root).toEqualHtml(`
|
|
75
|
+
<pds-icon name="star" role="img" aria-label="custom label" size="regular" style="height: 16px; width: 16px;">
|
|
76
|
+
<mock:shadow-root>
|
|
77
|
+
<div class="icon-inner"></div>
|
|
78
|
+
</mock:shadow-root>
|
|
79
|
+
</pds-icon>
|
|
80
|
+
`);
|
|
81
|
+
});
|
|
82
|
+
it('renders custom label after changing source', async () => {
|
|
83
|
+
const page = await newSpecPage({
|
|
84
|
+
components: [PdsIcon],
|
|
85
|
+
html: `<pds-icon name="youtube" aria-label="custom label"></pds-icon>`,
|
|
86
|
+
});
|
|
87
|
+
const icon = page.root;
|
|
88
|
+
expect(icon).toEqualHtml(`
|
|
89
|
+
<pds-icon name="youtube" role="img" aria-label="custom label" size="regular" style="height: 16px; width: 16px;">
|
|
90
|
+
<mock:shadow-root>
|
|
91
|
+
<div class="icon-inner"></div>
|
|
92
|
+
</mock:shadow-root>
|
|
93
|
+
</pds-icon>
|
|
94
|
+
`);
|
|
95
|
+
if (icon) {
|
|
96
|
+
icon.name = 'trash';
|
|
97
|
+
}
|
|
98
|
+
await page.waitForChanges();
|
|
99
|
+
expect(icon).toEqualHtml(`
|
|
100
|
+
<pds-icon name="trash" role="img" aria-label="custom label" size="regular" style="height: 16px; width: 16px;">
|
|
101
|
+
<mock:shadow-root>
|
|
102
|
+
<div class="icon-inner"></div>
|
|
103
|
+
</mock:shadow-root>
|
|
104
|
+
</pds-icon>
|
|
105
|
+
`);
|
|
106
|
+
});
|
|
69
107
|
});
|
|
70
108
|
//# sourceMappingURL=pds-icon.spec.js.map
|