@skbkontur/icons 1.14.1 → 1.15.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/CHANGELOG.md +22 -0
- package/esm/internal/BaseIcon.js +37 -16
- package/esm/internal/utils.d.ts +24 -0
- package/esm/internal/utils.js +28 -0
- package/internal/BaseIcon.js +35 -14
- package/internal/utils.d.ts +24 -0
- package/internal/utils.js +31 -1
- package/package.json +2 -2
- package/esm/internal/cssRules.d.ts +0 -1
- package/esm/internal/cssRules.js +0 -6
- package/esm/internal/injectCss.d.ts +0 -6
- package/esm/internal/injectCss.js +0 -63
- package/internal/cssRules.d.ts +0 -1
- package/internal/cssRules.js +0 -9
- package/internal/injectCss.d.ts +0 -6
- package/internal/injectCss.js +0 -67
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.15.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/icons@1.14.2...@skbkontur/icons@1.15.0) (2024-12-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **icons:** full support SOP and async attachment ([02099ee](https://git.skbkontur.ru/ui/ui-parking/commits/02099ee63d81880c87125672bd70c355318da275))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.14.2](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/icons@1.14.1...@skbkontur/icons@1.14.2) (2024-12-09)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **icons:** tslib version ([af7218a](https://git.skbkontur.ru/ui/ui-parking/commits/af7218aed0b16fd66f6322d0a7c568435cf62c95))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [1.14.1](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/icons@1.14.0...@skbkontur/icons@1.14.1) (2024-11-25)
|
|
7
29
|
|
|
8
30
|
|
package/esm/internal/BaseIcon.js
CHANGED
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
2
|
/* eslint-disable react/display-name */
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
4
4
|
import { IconDataTids } from './Icon';
|
|
5
5
|
import { forwardRef } from '../helpers/forwardRef';
|
|
6
|
-
import {
|
|
7
|
-
import { injectCss } from './injectCss';
|
|
6
|
+
import { isDocument, isShadowRoot, ZERO_WIDTH_SPACE } from './utils';
|
|
8
7
|
export var BaseIcon = forwardRef('BaseIcon', function (_a, ref) {
|
|
9
|
-
var color = _a.color, size = _a.size, style = _a.style, _b = _a["aria-hidden"], ariaHidden = _b === void 0 ? true : _b, _c = _a.viewBoxSize, viewBoxSize = _c === void 0 ? 16 : _c, _d = _a.align, align = _d === void 0 ? 'center' : _d, children = _a.children, rest = __rest(_a, ["color", "size", "style", 'aria-hidden', "viewBoxSize", "align", "children"]);
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
var color = _a.color, size = _a.size, style = _a.style, _b = _a["aria-hidden"], ariaHidden = _b === void 0 ? true : _b, _c = _a.viewBoxSize, viewBoxSize = _c === void 0 ? 16 : _c, _d = _a.align, align = _d === void 0 ? 'center' : _d, children = _a.children, tabIndex = _a.tabIndex, onKeyUp = _a.onKeyUp, onBlur = _a.onBlur, rest = __rest(_a, ["color", "size", "style", 'aria-hidden', "viewBoxSize", "align", "children", "tabIndex", "onKeyUp", "onBlur"]);
|
|
9
|
+
var zeroWidthSpaceRef = useRef(null);
|
|
10
|
+
var _e = useState(false), focusVisible = _e[0], setFocusVisible = _e[1];
|
|
11
|
+
useLayoutEffect(function () {
|
|
12
|
+
var element = zeroWidthSpaceRef.current;
|
|
13
|
+
if (!element || !element.attachShadow) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
var zeroWidthSpace = element.ownerDocument.createElement('span');
|
|
17
|
+
element.append(zeroWidthSpace);
|
|
18
|
+
try {
|
|
19
|
+
var shadow = zeroWidthSpace.attachShadow({ mode: 'closed' });
|
|
20
|
+
shadow.textContent = ZERO_WIDTH_SPACE;
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
console.error(e);
|
|
24
|
+
}
|
|
25
|
+
return function () { return zeroWidthSpace.remove(); };
|
|
26
|
+
}, [zeroWidthSpaceRef.current]);
|
|
27
|
+
var enableFocusVisibleOnTab = useCallback(function (e) {
|
|
28
|
+
var root = e.currentTarget.getRootNode();
|
|
29
|
+
if (!focusVisible &&
|
|
30
|
+
e.key === 'Tab' &&
|
|
31
|
+
(isDocument(root) || isShadowRoot(root)) &&
|
|
32
|
+
root.activeElement === e.currentTarget) {
|
|
33
|
+
setFocusVisible(true);
|
|
34
|
+
}
|
|
35
|
+
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(e);
|
|
36
|
+
}, [focusVisible, onKeyUp]);
|
|
37
|
+
var disableFocusVisible = useCallback(function (e) {
|
|
38
|
+
focusVisible && setFocusVisible(false);
|
|
39
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
40
|
+
}, [focusVisible, onBlur]);
|
|
41
|
+
var icon = (React.createElement("svg", __assign({ "data-tid": IconDataTids.root, ref: ref, width: size || viewBoxSize, height: size || viewBoxSize, style: __assign({ fill: color !== null && color !== void 0 ? color : 'currentColor', marginBottom: align === 'none' || align === 'center' ? 0 : '-0.1875em', flexShrink: 0, outline: focusVisible ? undefined : 'none' }, (align !== 'center' ? style : {})), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 " + viewBoxSize + " " + viewBoxSize, "aria-hidden": ariaHidden, tabIndex: tabIndex, onKeyUp: enableFocusVisibleOnTab, onBlur: disableFocusVisible }, rest), children));
|
|
23
42
|
if (align === 'center') {
|
|
24
|
-
return (React.createElement("span", {
|
|
43
|
+
return (React.createElement("span", { "aria-hidden": ariaHidden, style: __assign({ display: 'inline-flex', WebkitBoxAlign: 'center', alignItems: 'center' }, style) },
|
|
44
|
+
React.createElement("span", { ref: zeroWidthSpaceRef }),
|
|
45
|
+
icon));
|
|
25
46
|
}
|
|
26
47
|
return icon;
|
|
27
48
|
});
|
package/esm/internal/utils.d.ts
CHANGED
|
@@ -19,3 +19,27 @@ export declare const isNonNullable: <T>(value: T) => value is NonNullable<T>;
|
|
|
19
19
|
* });
|
|
20
20
|
*/
|
|
21
21
|
export declare function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>): (value: any) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Character for center alignment.
|
|
24
|
+
*
|
|
25
|
+
* @see https://www.fileformat.info/info/unicode/char/200b/index.htm
|
|
26
|
+
*/
|
|
27
|
+
export declare const ZERO_WIDTH_SPACE: string;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if the node is a Document.
|
|
30
|
+
*
|
|
31
|
+
* Suitable for use in same-origin iframes.
|
|
32
|
+
*
|
|
33
|
+
* @param {Node} node - The node to check.
|
|
34
|
+
* @returns {boolean} - True if the node is a Document, otherwise false.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isDocument(node: Node): node is Document;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if the node is a ShadowRoot.
|
|
39
|
+
*
|
|
40
|
+
* Suitable for use in same-origin iframes.
|
|
41
|
+
*
|
|
42
|
+
* @param {Node} node - The node to check.
|
|
43
|
+
* @returns {boolean} - True if the node is a ShadowRoot, otherwise false.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isShadowRoot(node: Node): node is ShadowRoot;
|
package/esm/internal/utils.js
CHANGED
|
@@ -32,3 +32,31 @@ export function mergeRefs(refs) {
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Character for center alignment.
|
|
37
|
+
*
|
|
38
|
+
* @see https://www.fileformat.info/info/unicode/char/200b/index.htm
|
|
39
|
+
*/
|
|
40
|
+
export var ZERO_WIDTH_SPACE = String.fromCharCode(0x200b);
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the node is a Document.
|
|
43
|
+
*
|
|
44
|
+
* Suitable for use in same-origin iframes.
|
|
45
|
+
*
|
|
46
|
+
* @param {Node} node - The node to check.
|
|
47
|
+
* @returns {boolean} - True if the node is a Document, otherwise false.
|
|
48
|
+
*/
|
|
49
|
+
export function isDocument(node) {
|
|
50
|
+
return node.nodeType === Node.DOCUMENT_NODE;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Checks if the node is a ShadowRoot.
|
|
54
|
+
*
|
|
55
|
+
* Suitable for use in same-origin iframes.
|
|
56
|
+
*
|
|
57
|
+
* @param {Node} node - The node to check.
|
|
58
|
+
* @returns {boolean} - True if the node is a ShadowRoot, otherwise false.
|
|
59
|
+
*/
|
|
60
|
+
export function isShadowRoot(node) {
|
|
61
|
+
return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && 'adoptedStyleSheets' in node;
|
|
62
|
+
}
|
package/internal/BaseIcon.js
CHANGED
|
@@ -7,24 +7,45 @@ var react_1 = tslib_1.__importStar(require("react"));
|
|
|
7
7
|
var Icon_1 = require("./Icon");
|
|
8
8
|
var forwardRef_1 = require("../helpers/forwardRef");
|
|
9
9
|
var utils_1 = require("./utils");
|
|
10
|
-
var injectCss_1 = require("./injectCss");
|
|
11
10
|
exports.BaseIcon = forwardRef_1.forwardRef('BaseIcon', function (_a, ref) {
|
|
12
|
-
var color = _a.color, size = _a.size, style = _a.style, _b = _a["aria-hidden"], ariaHidden = _b === void 0 ? true : _b, _c = _a.viewBoxSize, viewBoxSize = _c === void 0 ? 16 : _c, _d = _a.align, align = _d === void 0 ? 'center' : _d, children = _a.children, rest = tslib_1.__rest(_a, ["color", "size", "style", 'aria-hidden', "viewBoxSize", "align", "children"]);
|
|
13
|
-
var
|
|
14
|
-
react_1.
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
var color = _a.color, size = _a.size, style = _a.style, _b = _a["aria-hidden"], ariaHidden = _b === void 0 ? true : _b, _c = _a.viewBoxSize, viewBoxSize = _c === void 0 ? 16 : _c, _d = _a.align, align = _d === void 0 ? 'center' : _d, children = _a.children, tabIndex = _a.tabIndex, onKeyUp = _a.onKeyUp, onBlur = _a.onBlur, rest = tslib_1.__rest(_a, ["color", "size", "style", 'aria-hidden', "viewBoxSize", "align", "children", "tabIndex", "onKeyUp", "onBlur"]);
|
|
12
|
+
var zeroWidthSpaceRef = react_1.useRef(null);
|
|
13
|
+
var _e = react_1.useState(false), focusVisible = _e[0], setFocusVisible = _e[1];
|
|
14
|
+
react_1.useLayoutEffect(function () {
|
|
15
|
+
var element = zeroWidthSpaceRef.current;
|
|
16
|
+
if (!element || !element.attachShadow) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
var zeroWidthSpace = element.ownerDocument.createElement('span');
|
|
20
|
+
element.append(zeroWidthSpace);
|
|
21
|
+
try {
|
|
22
|
+
var shadow = zeroWidthSpace.attachShadow({ mode: 'closed' });
|
|
23
|
+
shadow.textContent = utils_1.ZERO_WIDTH_SPACE;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
console.error(e);
|
|
27
|
+
}
|
|
28
|
+
return function () { return zeroWidthSpace.remove(); };
|
|
29
|
+
}, [zeroWidthSpaceRef.current]);
|
|
30
|
+
var enableFocusVisibleOnTab = react_1.useCallback(function (e) {
|
|
31
|
+
var root = e.currentTarget.getRootNode();
|
|
32
|
+
if (!focusVisible &&
|
|
33
|
+
e.key === 'Tab' &&
|
|
34
|
+
(utils_1.isDocument(root) || utils_1.isShadowRoot(root)) &&
|
|
35
|
+
root.activeElement === e.currentTarget) {
|
|
36
|
+
setFocusVisible(true);
|
|
37
|
+
}
|
|
38
|
+
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(e);
|
|
39
|
+
}, [focusVisible, onKeyUp]);
|
|
40
|
+
var disableFocusVisible = react_1.useCallback(function (e) {
|
|
41
|
+
focusVisible && setFocusVisible(false);
|
|
42
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
43
|
+
}, [focusVisible, onBlur]);
|
|
44
|
+
var icon = (react_1.default.createElement("svg", tslib_1.__assign({ "data-tid": Icon_1.IconDataTids.root, ref: ref, width: size || viewBoxSize, height: size || viewBoxSize, style: tslib_1.__assign({ fill: color !== null && color !== void 0 ? color : 'currentColor', marginBottom: align === 'none' || align === 'center' ? 0 : '-0.1875em', flexShrink: 0, outline: focusVisible ? undefined : 'none' }, (align !== 'center' ? style : {})), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 " + viewBoxSize + " " + viewBoxSize, "aria-hidden": ariaHidden, tabIndex: tabIndex, onKeyUp: enableFocusVisibleOnTab, onBlur: disableFocusVisible }, rest), children));
|
|
26
45
|
if (align === 'center') {
|
|
27
|
-
return (react_1.default.createElement("span", {
|
|
46
|
+
return (react_1.default.createElement("span", { "aria-hidden": ariaHidden, style: tslib_1.__assign({ display: 'inline-flex', WebkitBoxAlign: 'center', alignItems: 'center' }, style) },
|
|
47
|
+
react_1.default.createElement("span", { ref: zeroWidthSpaceRef }),
|
|
48
|
+
icon));
|
|
28
49
|
}
|
|
29
50
|
return icon;
|
|
30
51
|
});
|
package/internal/utils.d.ts
CHANGED
|
@@ -19,3 +19,27 @@ export declare const isNonNullable: <T>(value: T) => value is NonNullable<T>;
|
|
|
19
19
|
* });
|
|
20
20
|
*/
|
|
21
21
|
export declare function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>): (value: any) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Character for center alignment.
|
|
24
|
+
*
|
|
25
|
+
* @see https://www.fileformat.info/info/unicode/char/200b/index.htm
|
|
26
|
+
*/
|
|
27
|
+
export declare const ZERO_WIDTH_SPACE: string;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if the node is a Document.
|
|
30
|
+
*
|
|
31
|
+
* Suitable for use in same-origin iframes.
|
|
32
|
+
*
|
|
33
|
+
* @param {Node} node - The node to check.
|
|
34
|
+
* @returns {boolean} - True if the node is a Document, otherwise false.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isDocument(node: Node): node is Document;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if the node is a ShadowRoot.
|
|
39
|
+
*
|
|
40
|
+
* Suitable for use in same-origin iframes.
|
|
41
|
+
*
|
|
42
|
+
* @param {Node} node - The node to check.
|
|
43
|
+
* @returns {boolean} - True if the node is a ShadowRoot, otherwise false.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isShadowRoot(node: Node): node is ShadowRoot;
|
package/internal/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeRefs = exports.isNonNullable = void 0;
|
|
3
|
+
exports.isShadowRoot = exports.isDocument = exports.ZERO_WIDTH_SPACE = exports.mergeRefs = exports.isNonNullable = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Проверяет, не является ли переданный аргумент null или undefined и исключает типы null и undefined из типа аргумента
|
|
6
6
|
*
|
|
@@ -36,3 +36,33 @@ function mergeRefs(refs) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
exports.mergeRefs = mergeRefs;
|
|
39
|
+
/**
|
|
40
|
+
* Character for center alignment.
|
|
41
|
+
*
|
|
42
|
+
* @see https://www.fileformat.info/info/unicode/char/200b/index.htm
|
|
43
|
+
*/
|
|
44
|
+
exports.ZERO_WIDTH_SPACE = String.fromCharCode(0x200b);
|
|
45
|
+
/**
|
|
46
|
+
* Checks if the node is a Document.
|
|
47
|
+
*
|
|
48
|
+
* Suitable for use in same-origin iframes.
|
|
49
|
+
*
|
|
50
|
+
* @param {Node} node - The node to check.
|
|
51
|
+
* @returns {boolean} - True if the node is a Document, otherwise false.
|
|
52
|
+
*/
|
|
53
|
+
function isDocument(node) {
|
|
54
|
+
return node.nodeType === Node.DOCUMENT_NODE;
|
|
55
|
+
}
|
|
56
|
+
exports.isDocument = isDocument;
|
|
57
|
+
/**
|
|
58
|
+
* Checks if the node is a ShadowRoot.
|
|
59
|
+
*
|
|
60
|
+
* Suitable for use in same-origin iframes.
|
|
61
|
+
*
|
|
62
|
+
* @param {Node} node - The node to check.
|
|
63
|
+
* @returns {boolean} - True if the node is a ShadowRoot, otherwise false.
|
|
64
|
+
*/
|
|
65
|
+
function isShadowRoot(node) {
|
|
66
|
+
return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && 'adoptedStyleSheets' in node;
|
|
67
|
+
}
|
|
68
|
+
exports.isShadowRoot = isShadowRoot;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/icons",
|
|
3
3
|
"description": "react-ui-icons",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.15.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
7
7
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"icons": "yarn icons:generate && yarn lint:fix"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"tslib": "2"
|
|
22
|
+
"tslib": "^2.8.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"svgo": "2.8.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const CSSRules: readonly string[];
|
package/esm/internal/cssRules.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export var CSSRules = [
|
|
2
|
-
".ui-parking-icon-centered { \n display: -webkit-inline-box;\n display: inline-flex;\n -webkit-box-align: center;\n align-items: center; \n }",
|
|
3
|
-
".ui-parking-icon-centered::before {\n /*\n * ZERO WIDTH SPACE\n *\n * Symbol to align to baseline\n *\n * @see https://www.fileformat.info/info/unicode/char/200b/index.htm\n */\n content: '\\200B';\n }",
|
|
4
|
-
".ui-parking-icon-base { \n outline: none; \n }",
|
|
5
|
-
".ui-parking-icon-base:focus-visible { \n outline: blue auto 5px; \n }",
|
|
6
|
-
];
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { __spreadArrays } from "tslib";
|
|
2
|
-
import { CSSRules } from './cssRules';
|
|
3
|
-
function checkRuleExists(rootNodeStyles, cssText) {
|
|
4
|
-
return rootNodeStyles.some(function (cssRules) { return Array.from(cssRules).some(function (r) { return r.cssText === cssText; }); });
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Not attached element can return the root of the DOM tree it belongs to, or itself - HTMLElement, Text, etc
|
|
8
|
-
*/
|
|
9
|
-
function getSafeRootNode(element) {
|
|
10
|
-
var _a;
|
|
11
|
-
var rootNode = (_a = element.getRootNode) === null || _a === void 0 ? void 0 : _a.call(element);
|
|
12
|
-
return (rootNode instanceof Document || rootNode instanceof ShadowRoot ? rootNode : element.ownerDocument);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Whether the current browser supports `adoptedStyleSheets`.
|
|
16
|
-
* https://github.com/lit/lit-element/blob/master/src/lib/css-tag.ts#L14
|
|
17
|
-
*/
|
|
18
|
-
var supportsAdoptingStyleSheets = Boolean(typeof window !== 'undefined' &&
|
|
19
|
-
window.ShadowRoot &&
|
|
20
|
-
(window.ShadyCSS === undefined || window.ShadyCSS.nativeShadow) &&
|
|
21
|
-
'adoptedStyleSheets' in Document.prototype &&
|
|
22
|
-
'replace' in CSSStyleSheet.prototype);
|
|
23
|
-
export function injectCss(element) {
|
|
24
|
-
var _a;
|
|
25
|
-
var rootNode = getSafeRootNode(element);
|
|
26
|
-
if (supportsAdoptingStyleSheets) {
|
|
27
|
-
var currentWindow = element.ownerDocument.defaultView;
|
|
28
|
-
if (!currentWindow) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
var rootNodeStyles_1 = rootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
|
|
32
|
-
var cssRulesStyleSheet_1 = new currentWindow.CSSStyleSheet();
|
|
33
|
-
CSSRules.forEach(function (rule) { return cssRulesStyleSheet_1.insertRule(rule); });
|
|
34
|
-
var filteredStyleSheet_1 = new currentWindow.CSSStyleSheet();
|
|
35
|
-
Array.from(cssRulesStyleSheet_1.cssRules).forEach(function (cssRule) {
|
|
36
|
-
if (!checkRuleExists(rootNodeStyles_1, cssRule.cssText)) {
|
|
37
|
-
filteredStyleSheet_1.insertRule(cssRule.cssText);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
if (filteredStyleSheet_1.cssRules.length > 0) {
|
|
41
|
-
try {
|
|
42
|
-
rootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
// fix for old chrome https://chromestatus.com/feature/5638996492288000 , but slow performance
|
|
46
|
-
rootNode.adoptedStyleSheets = __spreadArrays(rootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
var styleId = 'ui-parking-icons-style';
|
|
52
|
-
var isShadowRoot = !!rootNode.host;
|
|
53
|
-
var rootElement = isShadowRoot ? rootNode.firstElementChild : rootNode;
|
|
54
|
-
var hasInsertStyles = (_a = rootElement) === null || _a === void 0 ? void 0 : _a.querySelector("#" + styleId);
|
|
55
|
-
var elementForStyle = isShadowRoot ? rootElement : rootElement.getElementsByTagName('head')[0];
|
|
56
|
-
if (!hasInsertStyles) {
|
|
57
|
-
var style = element.ownerDocument.createElement('style');
|
|
58
|
-
style.id = styleId;
|
|
59
|
-
style.innerHTML = CSSRules.join('');
|
|
60
|
-
elementForStyle === null || elementForStyle === void 0 ? void 0 : elementForStyle.appendChild(style);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
package/internal/cssRules.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const CSSRules: readonly string[];
|
package/internal/cssRules.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CSSRules = void 0;
|
|
4
|
-
exports.CSSRules = [
|
|
5
|
-
".ui-parking-icon-centered { \n display: -webkit-inline-box;\n display: inline-flex;\n -webkit-box-align: center;\n align-items: center; \n }",
|
|
6
|
-
".ui-parking-icon-centered::before {\n /*\n * ZERO WIDTH SPACE\n *\n * Symbol to align to baseline\n *\n * @see https://www.fileformat.info/info/unicode/char/200b/index.htm\n */\n content: '\\200B';\n }",
|
|
7
|
-
".ui-parking-icon-base { \n outline: none; \n }",
|
|
8
|
-
".ui-parking-icon-base:focus-visible { \n outline: blue auto 5px; \n }",
|
|
9
|
-
];
|
package/internal/injectCss.d.ts
DELETED
package/internal/injectCss.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.injectCss = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var cssRules_1 = require("./cssRules");
|
|
6
|
-
function checkRuleExists(rootNodeStyles, cssText) {
|
|
7
|
-
return rootNodeStyles.some(function (cssRules) { return Array.from(cssRules).some(function (r) { return r.cssText === cssText; }); });
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Not attached element can return the root of the DOM tree it belongs to, or itself - HTMLElement, Text, etc
|
|
11
|
-
*/
|
|
12
|
-
function getSafeRootNode(element) {
|
|
13
|
-
var _a;
|
|
14
|
-
var rootNode = (_a = element.getRootNode) === null || _a === void 0 ? void 0 : _a.call(element);
|
|
15
|
-
return (rootNode instanceof Document || rootNode instanceof ShadowRoot ? rootNode : element.ownerDocument);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Whether the current browser supports `adoptedStyleSheets`.
|
|
19
|
-
* https://github.com/lit/lit-element/blob/master/src/lib/css-tag.ts#L14
|
|
20
|
-
*/
|
|
21
|
-
var supportsAdoptingStyleSheets = Boolean(typeof window !== 'undefined' &&
|
|
22
|
-
window.ShadowRoot &&
|
|
23
|
-
(window.ShadyCSS === undefined || window.ShadyCSS.nativeShadow) &&
|
|
24
|
-
'adoptedStyleSheets' in Document.prototype &&
|
|
25
|
-
'replace' in CSSStyleSheet.prototype);
|
|
26
|
-
function injectCss(element) {
|
|
27
|
-
var _a;
|
|
28
|
-
var rootNode = getSafeRootNode(element);
|
|
29
|
-
if (supportsAdoptingStyleSheets) {
|
|
30
|
-
var currentWindow = element.ownerDocument.defaultView;
|
|
31
|
-
if (!currentWindow) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
var rootNodeStyles_1 = rootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
|
|
35
|
-
var cssRulesStyleSheet_1 = new currentWindow.CSSStyleSheet();
|
|
36
|
-
cssRules_1.CSSRules.forEach(function (rule) { return cssRulesStyleSheet_1.insertRule(rule); });
|
|
37
|
-
var filteredStyleSheet_1 = new currentWindow.CSSStyleSheet();
|
|
38
|
-
Array.from(cssRulesStyleSheet_1.cssRules).forEach(function (cssRule) {
|
|
39
|
-
if (!checkRuleExists(rootNodeStyles_1, cssRule.cssText)) {
|
|
40
|
-
filteredStyleSheet_1.insertRule(cssRule.cssText);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
if (filteredStyleSheet_1.cssRules.length > 0) {
|
|
44
|
-
try {
|
|
45
|
-
rootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
// fix for old chrome https://chromestatus.com/feature/5638996492288000 , but slow performance
|
|
49
|
-
rootNode.adoptedStyleSheets = tslib_1.__spreadArrays(rootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
var styleId = 'ui-parking-icons-style';
|
|
55
|
-
var isShadowRoot = !!rootNode.host;
|
|
56
|
-
var rootElement = isShadowRoot ? rootNode.firstElementChild : rootNode;
|
|
57
|
-
var hasInsertStyles = (_a = rootElement) === null || _a === void 0 ? void 0 : _a.querySelector("#" + styleId);
|
|
58
|
-
var elementForStyle = isShadowRoot ? rootElement : rootElement.getElementsByTagName('head')[0];
|
|
59
|
-
if (!hasInsertStyles) {
|
|
60
|
-
var style = element.ownerDocument.createElement('style');
|
|
61
|
-
style.id = styleId;
|
|
62
|
-
style.innerHTML = cssRules_1.CSSRules.join('');
|
|
63
|
-
elementForStyle === null || elementForStyle === void 0 ? void 0 : elementForStyle.appendChild(style);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.injectCss = injectCss;
|