@imtf/icons 0.0.3 → 0.0.4

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.
@@ -0,0 +1,9 @@
1
+ import React, { ReactElement } from 'react';
2
+ interface IconSVGProps {
3
+ color?: string;
4
+ size?: string | number;
5
+ src?: string;
6
+ children?: ReactElement;
7
+ }
8
+ declare const IconSVG: React.FC<IconSVGProps>;
9
+ export default IconSVG;
@@ -0,0 +1,2 @@
1
+ export { default as IconSVG } from './IconSVG.js';
2
+ export * from './IconSVG.js';
@@ -1 +1,2 @@
1
1
  export * from './providers';
2
+ export * from './components';
package/lib/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import require$$0, { createContext, useMemo } from 'react';
1
+ import require$$0, { createContext, useMemo, useContext, useEffect } from 'react';
2
2
 
3
3
  /*! *****************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
@@ -2331,4 +2331,27 @@ var IconProvider = function (_a) {
2331
2331
  return (jsxRuntime.exports.jsx(IconContext.Provider, __assign({ value: __assign(__assign(__assign({}, defaultContext), props), defaultValue) }, { children: children }), void 0));
2332
2332
  };
2333
2333
 
2334
- export { IconContext, IconProvider, defaultContext, withIconContext };
2334
+ var IconSVG = function (_a) {
2335
+ var defaultColor = _a.color, size = _a.size, src = _a.src, children = _a.children, props = __rest(_a, ["color", "size", "src", "children"]);
2336
+ var defaultContextValues = useContext(IconContext);
2337
+ var defaultValues = __assign(__assign(__assign({}, defaultContextValues), { color: defaultColor || defaultContextValues.color, size: size || defaultContextValues.size }), props);
2338
+ var color = useMemo(function () { return lodash_get(defaultValues.palette, defaultValues.color, defaultValues.color); }, [defaultValues.color, defaultValues.palette]);
2339
+ useEffect(function () {
2340
+ if (src && !children) {
2341
+ var wrapper = document.getElementById('SVGWrapper');
2342
+ wrapper.innerHTML = atob(src);
2343
+ var svg = wrapper === null || wrapper === void 0 ? void 0 : wrapper.children;
2344
+ var path = svg === null || svg === void 0 ? void 0 : svg[0].firstElementChild;
2345
+ svg === null || svg === void 0 ? void 0 : svg[0].setAttribute('width', typeof defaultValues.size === 'number'
2346
+ ? defaultValues.size + 'px'
2347
+ : defaultValues.size);
2348
+ svg === null || svg === void 0 ? void 0 : svg[0].setAttribute('height', typeof defaultValues.size === 'number'
2349
+ ? defaultValues.size + 'px'
2350
+ : defaultValues.size);
2351
+ path === null || path === void 0 ? void 0 : path.setAttribute('fill', color);
2352
+ }
2353
+ }, [color, src, children, size]);
2354
+ return children ? (require$$0.cloneElement(children, __assign({ fill: color, width: size, height: size }, props))) : src ? (jsxRuntime.exports.jsx("div", { id: "SVGWrapper" }, void 0)) : null;
2355
+ };
2356
+
2357
+ export { IconContext, IconProvider, IconSVG, defaultContext, withIconContext };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtf/icons",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "description": "Library of icons (React components, font and svg)",
6
6
  "module": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",