etudes 0.41.0 → 0.42.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/lib/FlatSVG.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
2
|
import { CSSProp } from 'styled-components';
|
|
3
3
|
export declare type Props = HTMLAttributes<HTMLDivElement> & {
|
|
4
4
|
/**
|
|
@@ -35,8 +35,43 @@ export declare type Props = HTMLAttributes<HTMLDivElement> & {
|
|
|
35
35
|
*/
|
|
36
36
|
whitelistedAttributes?: string[];
|
|
37
37
|
};
|
|
38
|
+
declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
39
|
+
/**
|
|
40
|
+
* The SVG string markup, i.e. "<svg>...</svg>".
|
|
41
|
+
*/
|
|
42
|
+
markup: string;
|
|
43
|
+
/**
|
|
44
|
+
* Specifies whether the 'class' should be removed in the SVG root node and all of its child
|
|
45
|
+
* nodes.
|
|
46
|
+
*/
|
|
47
|
+
stripClasses?: boolean | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Specifies whether extraneous attributes should be removed from the SVG root node. The
|
|
50
|
+
* `whitelistedAttributes` prop defines what attributes should be kept.
|
|
51
|
+
*/
|
|
52
|
+
stripExtraneousAttributes?: boolean | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Specifies whether the 'id' attribute should be removed in the SVG root node and all of its
|
|
55
|
+
* child nodes.
|
|
56
|
+
*/
|
|
57
|
+
stripIds?: boolean | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Specifies whether the 'style' atribute and any <style> nodes should be removed in the SVG root
|
|
60
|
+
* node and all of its child nodes.
|
|
61
|
+
*/
|
|
62
|
+
stripStyles?: boolean | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Extended CSS to be provided to the SVG root node.
|
|
65
|
+
*/
|
|
66
|
+
cssSVG?: CSSProp<any> | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Specifies attribute names to exclude from being stripped if `stripExtraneousAttributes` is
|
|
69
|
+
* enabled. By default, only `viewBox` is whitelisted.
|
|
70
|
+
*/
|
|
71
|
+
whitelistedAttributes?: string[] | undefined;
|
|
72
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
38
73
|
/**
|
|
39
74
|
* A component whose root element wraps an SVG markup. When wrapping the SVG, it will attempt to
|
|
40
75
|
* sanitize the markup (i.e. stripping useless attributes) according to the props specified.
|
|
41
76
|
*/
|
|
42
|
-
export default
|
|
77
|
+
export default _default;
|
package/lib/FlatSVG.js
CHANGED
|
@@ -14,6 +14,25 @@ var __assign = (this && this.__assign) || function () {
|
|
|
14
14
|
};
|
|
15
15
|
return __assign.apply(this, arguments);
|
|
16
16
|
};
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
17
36
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
37
|
var t = {};
|
|
19
38
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -54,7 +73,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
54
73
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
74
|
};
|
|
56
75
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
var react_1 =
|
|
76
|
+
var react_1 = __importStar(require("react"));
|
|
58
77
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
59
78
|
function removeStyles(element) {
|
|
60
79
|
element.removeAttribute('style');
|
|
@@ -92,7 +111,7 @@ function removeAttributes(element, attributes, recursive, whitelist) {
|
|
|
92
111
|
* A component whose root element wraps an SVG markup. When wrapping the SVG, it will attempt to
|
|
93
112
|
* sanitize the markup (i.e. stripping useless attributes) according to the props specified.
|
|
94
113
|
*/
|
|
95
|
-
function
|
|
114
|
+
exports.default = (0, react_1.forwardRef)(function (_a, ref) {
|
|
96
115
|
var markup = _a.markup, _b = _a.stripClasses, stripClasses = _b === void 0 ? true : _b, _c = _a.stripExtraneousAttributes, stripExtraneousAttributes = _c === void 0 ? true : _c, _d = _a.stripIds, stripIds = _d === void 0 ? true : _d, _e = _a.stripStyles, stripStyles = _e === void 0 ? true : _e, cssSVG = _a.cssSVG, _f = _a.whitelistedAttributes, whitelistedAttributes = _f === void 0 ? ['viewBox'] : _f, props = __rest(_a, ["markup", "stripClasses", "stripExtraneousAttributes", "stripIds", "stripStyles", "cssSVG", "whitelistedAttributes"]);
|
|
97
116
|
function sanitizedMarkup() {
|
|
98
117
|
var mockContainer = document.createElement('div');
|
|
@@ -113,9 +132,8 @@ function FlatSVG(_a) {
|
|
|
113
132
|
removeStyles(svgElement);
|
|
114
133
|
return svgElement.outerHTML;
|
|
115
134
|
}
|
|
116
|
-
return (react_1.default.createElement(StyledRoot, __assign({ dangerouslySetInnerHTML: { __html: sanitizedMarkup() }, cssSVG: cssSVG }, props)));
|
|
117
|
-
}
|
|
118
|
-
exports.default = FlatSVG;
|
|
135
|
+
return (react_1.default.createElement(StyledRoot, __assign({ ref: ref, dangerouslySetInnerHTML: { __html: sanitizedMarkup() }, cssSVG: cssSVG }, props)));
|
|
136
|
+
});
|
|
119
137
|
var StyledRoot = styled_components_1.default.figure(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n > svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n\n ", "\n }\n"], ["\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n > svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n\n ", "\n }\n"])), function (props) { return props.cssSVG; });
|
|
120
138
|
var templateObject_1;
|
|
121
139
|
//# sourceMappingURL=FlatSVG.js.map
|
package/lib/FlatSVG.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlatSVG.js","sourceRoot":"/","sources":["FlatSVG.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FlatSVG.js","sourceRoot":"/","sources":["FlatSVG.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyD;AACzD,wEAAmD;AA4CnD,SAAS,YAAY,CAAC,OAAgB;IACpC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAEhC,IAAM,YAAY,GAAG,OA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E,gBAAgB,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAA;QAC/D,IAAI,WAAW;YAAE,YAAY,CAAC,UAAU,CAAC,CAAA;QAEzC,OAAO,UAAU,CAAC,SAAS,CAAA;IAC7B,CAAC;IAED,OAAO,CACL,8BAAC,UAAU,aACT,GAAG,EAAE,GAAG,EACR,uBAAuB,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,EACtD,MAAM,EAAE,MAAM,IACV,KAAK,EACT,CACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAM,UAAU,GAAG,2BAAM,CAAC,MAAM,okBAA6B,sfAuBvD,EAAqB,SAE1B,KAFK,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,MAAM,EAAZ,CAAY,CAE1B,CAAA","sourcesContent":["import React, { forwardRef, HTMLAttributes } from 'react'\nimport styled, { CSSProp } from 'styled-components'\n\nexport type Props = HTMLAttributes<HTMLDivElement> & {\n /**\n * The SVG string markup, i.e. \"<svg>...</svg>\".\n */\n markup: string\n\n /**\n * Specifies whether the 'class' should be removed in the SVG root node and all of its child\n * nodes.\n */\n stripClasses?: boolean\n\n /**\n * Specifies whether extraneous attributes should be removed from the SVG root node. The\n * `whitelistedAttributes` prop defines what attributes should be kept.\n */\n stripExtraneousAttributes?: boolean\n\n /**\n * Specifies whether the 'id' attribute should be removed in the SVG root node and all of its\n * child nodes.\n */\n stripIds?: boolean\n\n /**\n * Specifies whether the 'style' atribute and any <style> nodes should be removed in the SVG root\n * node and all of its child nodes.\n */\n stripStyles?: boolean\n\n /**\n * Extended CSS to be provided to the SVG root node.\n */\n cssSVG?: CSSProp<any>\n\n /**\n * Specifies attribute names to exclude from being stripped if `stripExtraneousAttributes` is\n * enabled. By default, only `viewBox` is whitelisted.\n */\n whitelistedAttributes?: string[]\n}\n\nfunction removeStyles(element: Element) {\n element.removeAttribute('style')\n\n const inlineStyles = element.getElementsByTagName('style')\n const numInlineStyles = inlineStyles.length\n\n for (let i = 0; i < numInlineStyles; i++) {\n const inlineStyle = inlineStyles[i]\n inlineStyle.remove()\n }\n\n const numChildren = element.children.length\n\n for (let i = 0; i < numChildren; i++) {\n removeStyles(element.children[i])\n }\n}\n\nfunction removeAttributes(element: Element, attributes: string[] | undefined = undefined, recursive = false, whitelist: string[] = []) {\n const attrs = attributes ?? element.getAttributeNames()\n const numAttrs = attrs.length\n\n for (let i = 0; i < numAttrs; i++) {\n const attr = attrs[i]\n const keep = whitelist.indexOf(attr) > -1\n if (!keep) element.removeAttribute(attr)\n }\n\n if (recursive) {\n const numChildren = element.children.length\n\n for (let i = 0; i < numChildren; i++) {\n removeAttributes(element.children[i], attributes, recursive, whitelist)\n }\n }\n}\n\n/**\n * A component whose root element wraps an SVG markup. When wrapping the SVG, it will attempt to\n * sanitize the markup (i.e. stripping useless attributes) according to the props specified.\n */\nexport default forwardRef<HTMLDivElement, Props>(({\n markup,\n stripClasses = true,\n stripExtraneousAttributes = true,\n stripIds = true,\n stripStyles = true,\n cssSVG,\n whitelistedAttributes = ['viewBox'],\n ...props\n}, ref) => {\n function sanitizedMarkup(): string {\n const mockContainer = document.createElement('div')\n mockContainer.innerHTML = markup\n\n const elements = mockContainer.getElementsByTagName('svg')\n if (elements.length > 1) throw new Error('More than one SVG element found in provided markup')\n\n const svgElement = elements[0]\n if (!svgElement) throw new Error('No SVG in provided markup')\n\n if (stripExtraneousAttributes) removeAttributes(svgElement, undefined, false, [...whitelistedAttributes, 'style', 'class', 'id'])\n if (stripIds) removeAttributes(svgElement, ['id'], true)\n if (stripClasses) removeAttributes(svgElement, ['class'], true)\n if (stripStyles) removeStyles(svgElement)\n\n return svgElement.outerHTML\n }\n\n return (\n <StyledRoot\n ref={ref}\n dangerouslySetInnerHTML={{ __html: sanitizedMarkup() }}\n cssSVG={cssSVG}\n {...props}\n />\n )\n})\n\nconst StyledRoot = styled.figure<{ cssSVG: Props['cssSVG'] }>`\n box-sizing: border-box;\n display: inline-block;\n flex: 0 0 auto;\n height: auto;\n position: relative;\n width: auto;\n\n > svg {\n height: auto;\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n width: auto;\n\n * {\n transition-delay: inherit;\n transition-duration: inherit;\n transition-property: inherit;\n transition-timing-function: inherit;\n }\n\n ${props => props.cssSVG}\n }\n`\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
var react_1 = require("react");
|
|
29
|
+
function useDocumentTitle(title, deps) {
|
|
30
|
+
(0, react_1.useEffect)(function () {
|
|
31
|
+
document.title = title;
|
|
32
|
+
}, __spreadArray([title], __read(deps ? deps : []), false));
|
|
33
|
+
}
|
|
34
|
+
exports.default = useDocumentTitle;
|
|
35
|
+
//# sourceMappingURL=useDocumentTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDocumentTitle.js","sourceRoot":"/","sources":["hooks/useDocumentTitle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAiD;AAEjD,SAAwB,gBAAgB,CAAC,KAAa,EAAE,IAAqB;IAC3E,IAAA,iBAAS,EAAC;QACR,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAA;IACxB,CAAC,iBAAG,KAAK,UAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAE,CAAA;AAClC,CAAC;AAJD,mCAIC","sourcesContent":["import { DependencyList, useEffect } from 'react'\n\nexport default function useDocumentTitle(title: string, deps?: DependencyList) {\n useEffect(() => {\n document.title = title\n }, [title, ...deps ? deps : []])\n}\n"]}
|