@hanzogui/helpers-icon 2.0.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/LICENSE +21 -0
- package/dist/cjs/IconProps.cjs +16 -0
- package/dist/cjs/IconProps.native.js +19 -0
- package/dist/cjs/IconProps.native.js.map +1 -0
- package/dist/cjs/index.cjs +19 -0
- package/dist/cjs/index.native.js +22 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/themed.cjs +74 -0
- package/dist/cjs/themed.native.js +81 -0
- package/dist/cjs/themed.native.js.map +1 -0
- package/dist/esm/IconProps.mjs +2 -0
- package/dist/esm/IconProps.mjs.map +1 -0
- package/dist/esm/IconProps.native.js +2 -0
- package/dist/esm/IconProps.native.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +3 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/themed.mjs +50 -0
- package/dist/esm/themed.mjs.map +1 -0
- package/dist/esm/themed.native.js +54 -0
- package/dist/esm/themed.native.js.map +1 -0
- package/package.json +49 -0
- package/src/IconProps.ts +21 -0
- package/src/index.ts +2 -0
- package/src/themed.tsx +93 -0
- package/types/IconProps.d.ts +13 -0
- package/types/IconProps.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/themed.d.ts +20 -0
- package/types/themed.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
};
|
|
12
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
13
|
+
value: !0
|
|
14
|
+
}), mod);
|
|
15
|
+
var IconProps_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(IconProps_exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
+
value: !0
|
|
16
|
+
}), mod);
|
|
17
|
+
var IconProps_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(IconProps_exports);
|
|
19
|
+
//# sourceMappingURL=IconProps.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","IconProps_exports"],"sources":["../../src/IconProps.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./IconProps.cjs"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./themed.cjs"), module.exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
return to;
|
|
13
|
+
},
|
|
14
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
+
value: !0
|
|
17
|
+
}), mod);
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("./IconProps.native.js"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./themed.native.js"), module.exports);
|
|
22
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,wBADd,GAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var themed_exports = {};
|
|
22
|
+
__export(themed_exports, {
|
|
23
|
+
SizableContext: () => import_sizable_context.SizableContext,
|
|
24
|
+
themed: () => themed
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(themed_exports);
|
|
27
|
+
var import_core = require("@hanzogui/core"),
|
|
28
|
+
import_sizable_context = require("@hanzogui/sizable-context"),
|
|
29
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
function needsFullStyleResolution(props) {
|
|
31
|
+
for (const key in props) if (key[0] === "$") return !0;
|
|
32
|
+
return !1;
|
|
33
|
+
}
|
|
34
|
+
function themed(Component, optsIn = {}) {
|
|
35
|
+
const opts = {
|
|
36
|
+
defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || "$color",
|
|
37
|
+
defaultStrokeWidth: 2,
|
|
38
|
+
fallbackColor: "#000",
|
|
39
|
+
resolveValues: process.env.HANZO_GUI_ICON_COLOR_RESOLVE || "auto",
|
|
40
|
+
...optsIn
|
|
41
|
+
},
|
|
42
|
+
IconWrapper = propsIn => {
|
|
43
|
+
const styledContext = import_sizable_context.SizableContext.useStyledContext(),
|
|
44
|
+
needsMedia = needsFullStyleResolution(propsIn),
|
|
45
|
+
[props, style, theme] = (0, import_core.usePropsAndStyle)(propsIn, {
|
|
46
|
+
...opts,
|
|
47
|
+
forComponent: import_core.Text,
|
|
48
|
+
resolveValues: opts.resolveValues,
|
|
49
|
+
noMedia: !needsMedia
|
|
50
|
+
}),
|
|
51
|
+
defaultColor = opts.defaultThemeColor,
|
|
52
|
+
colorIn = style.color || (defaultColor ? theme[defaultColor] : void 0) || (props.disableTheme ? null : theme.color) || opts.fallbackColor,
|
|
53
|
+
color = (0, import_core.getVariable)(colorIn),
|
|
54
|
+
size = typeof props.size == "string" ? (0, import_core.getTokenValue)(props.size, "size") : props.size || (styledContext.size === "$true" ? void 0 : styledContext.size),
|
|
55
|
+
strokeWidth = typeof props.strokeWidth == "string" ? (0, import_core.getTokenValue)(props.strokeWidth, "size") : props.strokeWidth ?? `${opts.defaultStrokeWidth}`,
|
|
56
|
+
finalProps = {
|
|
57
|
+
...props,
|
|
58
|
+
color,
|
|
59
|
+
size,
|
|
60
|
+
strokeWidth,
|
|
61
|
+
style
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Component, {
|
|
64
|
+
...finalProps
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
wrapped = propsIn => /* @__PURE__ */(0, import_jsx_runtime.jsx)(IconWrapper, {
|
|
68
|
+
...propsIn
|
|
69
|
+
});
|
|
70
|
+
return wrapped.staticConfig = {
|
|
71
|
+
isHOC: !0,
|
|
72
|
+
acceptsClassName: !0
|
|
73
|
+
}, wrapped;
|
|
74
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), mod);
|
|
23
|
+
var themed_exports = {};
|
|
24
|
+
__export(themed_exports, {
|
|
25
|
+
SizableContext: () => import_sizable_context.SizableContext,
|
|
26
|
+
themed: () => themed
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(themed_exports);
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
30
|
+
import_core = require("@hanzogui/core"),
|
|
31
|
+
import_sizable_context = require("@hanzogui/sizable-context");
|
|
32
|
+
function needsFullStyleResolution(props) {
|
|
33
|
+
for (var key in props) if (key[0] === "$") return !0;
|
|
34
|
+
return !1;
|
|
35
|
+
}
|
|
36
|
+
function themed(Component) {
|
|
37
|
+
var optsIn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {},
|
|
38
|
+
opts = {
|
|
39
|
+
defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || "$color",
|
|
40
|
+
defaultStrokeWidth: 2,
|
|
41
|
+
fallbackColor: "#000",
|
|
42
|
+
resolveValues: process.env.HANZO_GUI_ICON_COLOR_RESOLVE || "auto",
|
|
43
|
+
...optsIn
|
|
44
|
+
},
|
|
45
|
+
IconWrapper = function (propsIn) {
|
|
46
|
+
var styledContext = import_sizable_context.SizableContext.useStyledContext(),
|
|
47
|
+
needsMedia = needsFullStyleResolution(propsIn),
|
|
48
|
+
[props, style, theme] = (0, import_core.usePropsAndStyle)(propsIn, {
|
|
49
|
+
...opts,
|
|
50
|
+
forComponent: import_core.Text,
|
|
51
|
+
resolveValues: opts.resolveValues,
|
|
52
|
+
noMedia: !needsMedia
|
|
53
|
+
}),
|
|
54
|
+
defaultColor = opts.defaultThemeColor,
|
|
55
|
+
colorIn = style.color || (defaultColor ? theme[defaultColor] : void 0) || (props.disableTheme ? null : theme.color) || opts.fallbackColor,
|
|
56
|
+
color = (0, import_core.getVariable)(colorIn),
|
|
57
|
+
size = typeof props.size == "string" ? (0, import_core.getTokenValue)(props.size, "size") : props.size || (styledContext.size === "$true" ? void 0 : styledContext.size),
|
|
58
|
+
_props_strokeWidth,
|
|
59
|
+
strokeWidth = typeof props.strokeWidth == "string" ? (0, import_core.getTokenValue)(props.strokeWidth, "size") : (_props_strokeWidth = props.strokeWidth) !== null && _props_strokeWidth !== void 0 ? _props_strokeWidth : `${opts.defaultStrokeWidth}`,
|
|
60
|
+
finalProps = {
|
|
61
|
+
...props,
|
|
62
|
+
color,
|
|
63
|
+
size,
|
|
64
|
+
strokeWidth,
|
|
65
|
+
style
|
|
66
|
+
};
|
|
67
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Component, {
|
|
68
|
+
...finalProps
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
wrapped = function (propsIn) {
|
|
72
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(IconWrapper, {
|
|
73
|
+
...propsIn
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
return wrapped.staticConfig = {
|
|
77
|
+
isHOC: !0,
|
|
78
|
+
acceptsClassName: !0
|
|
79
|
+
}, wrapped;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=themed.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","themed_exports","__export","SizableContext","import_sizable_context","themed","module","exports","import_jsx_runtime","require","import_core","needsFullStyleResolution","props","key","Component","optsIn","arguments","length","opts","defaultThemeColor","process","env","DEFAULT_ICON_THEME_COLOR","defaultStrokeWidth","fallbackColor","resolveValues","HANZO_GUI_ICON_COLOR_RESOLVE","IconWrapper","propsIn","styledContext","useStyledContext","needsMedia","style","theme","usePropsAndStyle","forComponent","Text","noMedia","defaultColor","colorIn","color","disableTheme","getVariable","size","getTokenValue","_props_strokeWidth","strokeWidth","finalProps","jsx","wrapped"],"sources":["../../src/themed.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,cAAA;AAAAC,QAAA,CAAAD,cAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAC,sB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OAAA;QAAAI,IAAA,UAAA/B,KAAA,CAAA+B,IAAA,mBAAAjC,WAAA,CAAAkC,aAAA,EAAAhC,KAAA,CAAA+B,IAAA,YAAA/B,KAAA,CAAA+B,IAAA,KAAAd,aAAA,CAAAc,IAAA,wBAAAd,aAAA,CAAAc,IAAA;QAAAE,kBAAA;QAAAC,WAAA,UAAAlC,KAAA,CAAAkC,WAAA,mBAAApC,WAAA,CAAAkC,aAAA,EAAAhC,KAAA,CAAAkC,WAAA,aAAAD,kBAAA,GAAAjC,KAAA,CAAAkC,WAAA,cAAAD,kBAAA,cAAAA,kBAAA,MAAA3B,IAAA,CAAAK,kBAAA;QAAAwB,UAAA;UACH,GAAAnC,KAAA;UACA4B,KAAA;UACAG,IAAA;UACAG,WAAA;UACFd;QAEA;MACF,OAEM,eAAW,CACR,GAAAxB,kBAAA,CAAAwC,GAAA,EAAAlC,SAAA;QAIT,GAAAiC;MACE;IAAO;IACPE,OAAA,YAAAA,CAAkBrB,OAAA;MACpB,OAEO,mBAAApB,kBAAA,CAAAwC,GAAA,EAAArB,WAAA;QACT,GAAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getTokenValue, getVariable, Text, usePropsAndStyle } from "@hanzogui/core";
|
|
2
|
+
import { SizableContext } from "@hanzogui/sizable-context";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
function needsFullStyleResolution(props) {
|
|
5
|
+
for (const key in props) if (key[0] === "$") return !0;
|
|
6
|
+
return !1;
|
|
7
|
+
}
|
|
8
|
+
function themed(Component, optsIn = {}) {
|
|
9
|
+
const opts = {
|
|
10
|
+
defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || "$color",
|
|
11
|
+
defaultStrokeWidth: 2,
|
|
12
|
+
fallbackColor: "#000",
|
|
13
|
+
resolveValues: process.env.HANZO_GUI_ICON_COLOR_RESOLVE || "auto",
|
|
14
|
+
...optsIn
|
|
15
|
+
},
|
|
16
|
+
IconWrapper = propsIn => {
|
|
17
|
+
const styledContext = SizableContext.useStyledContext(),
|
|
18
|
+
needsMedia = needsFullStyleResolution(propsIn),
|
|
19
|
+
[props, style, theme] = usePropsAndStyle(propsIn, {
|
|
20
|
+
...opts,
|
|
21
|
+
forComponent: Text,
|
|
22
|
+
resolveValues: opts.resolveValues,
|
|
23
|
+
noMedia: !needsMedia
|
|
24
|
+
}),
|
|
25
|
+
defaultColor = opts.defaultThemeColor,
|
|
26
|
+
colorIn = style.color || (defaultColor ? theme[defaultColor] : void 0) || (props.disableTheme ? null : theme.color) || opts.fallbackColor,
|
|
27
|
+
color = getVariable(colorIn),
|
|
28
|
+
size = typeof props.size == "string" ? getTokenValue(props.size, "size") : props.size || (styledContext.size === "$true" ? void 0 : styledContext.size),
|
|
29
|
+
strokeWidth = typeof props.strokeWidth == "string" ? getTokenValue(props.strokeWidth, "size") : props.strokeWidth ?? `${opts.defaultStrokeWidth}`,
|
|
30
|
+
finalProps = {
|
|
31
|
+
...props,
|
|
32
|
+
color,
|
|
33
|
+
size,
|
|
34
|
+
strokeWidth,
|
|
35
|
+
style
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */jsx(Component, {
|
|
38
|
+
...finalProps
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
wrapped = propsIn => /* @__PURE__ */jsx(IconWrapper, {
|
|
42
|
+
...propsIn
|
|
43
|
+
});
|
|
44
|
+
return wrapped.staticConfig = {
|
|
45
|
+
isHOC: !0,
|
|
46
|
+
acceptsClassName: !0
|
|
47
|
+
}, wrapped;
|
|
48
|
+
}
|
|
49
|
+
export { SizableContext, themed };
|
|
50
|
+
//# sourceMappingURL=themed.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getTokenValue","getVariable","Text","usePropsAndStyle","SizableContext","jsx","needsFullStyleResolution","props","key","themed","Component","optsIn","opts","defaultThemeColor","process","env","DEFAULT_ICON_THEME_COLOR","defaultStrokeWidth","fallbackColor","resolveValues","HANZO_GUI_ICON_COLOR_RESOLVE","IconWrapper","propsIn","styledContext","useStyledContext","needsMedia","style","theme","forComponent","noMedia","defaultColor","colorIn","color","disableTheme","size","strokeWidth","finalProps","wrapped","staticConfig","isHOC","acceptsClassName"],"sources":["../../src/themed.tsx"],"sourcesContent":[null],"mappings":"AAAA,SACEA,aAAA,EACAC,WAAA,EACAC,IAAA,EACAC,gBAAA,QAEK;AACP,SAASC,cAAA,QAAsB;AAuEpB,SAAAC,GAAA;AAvDX,SAASC,yBAAyBC,KAAA,EAA2B;EAC3D,WAAWC,GAAA,IAAOD,KAAA,EAChB,IAAIC,GAAA,CAAI,CAAC,MAAM,KAAK,OAAO;EAE7B,OAAO;AACT;AAEO,SAASC,OAAOC,SAAA,EAA0BC,MAAA,GAAkB,CAAC,GAAG;EACrE,MAAMC,IAAA,GAAgB;MACpBC,iBAAA,EAAmBC,OAAA,CAAQC,GAAA,CAAIC,wBAAA,IAA4B;MAC3DC,kBAAA,EAAoB;MACpBC,aAAA,EAAe;MACfC,aAAA,EAAgBL,OAAA,CAAQC,GAAA,CAAIK,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B,WAAA;MAAa,GAAGC;IAAA,CAAS;EAInC,OAAAe,OAAA,CAAQC,YAAA,GAAkB;IACxBC,KAAA,EAAO;IACPC,gBAAA,EAAkB;EACpB,GAEOH,OAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getTokenValue, getVariable, Text, usePropsAndStyle } from "@hanzogui/core";
|
|
3
|
+
import { SizableContext } from "@hanzogui/sizable-context";
|
|
4
|
+
function needsFullStyleResolution(props) {
|
|
5
|
+
for (var key in props) if (key[0] === "$") return !0;
|
|
6
|
+
return !1;
|
|
7
|
+
}
|
|
8
|
+
function themed(Component) {
|
|
9
|
+
var optsIn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {},
|
|
10
|
+
opts = {
|
|
11
|
+
defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || "$color",
|
|
12
|
+
defaultStrokeWidth: 2,
|
|
13
|
+
fallbackColor: "#000",
|
|
14
|
+
resolveValues: process.env.HANZO_GUI_ICON_COLOR_RESOLVE || "auto",
|
|
15
|
+
...optsIn
|
|
16
|
+
},
|
|
17
|
+
IconWrapper = function (propsIn) {
|
|
18
|
+
var styledContext = SizableContext.useStyledContext(),
|
|
19
|
+
needsMedia = needsFullStyleResolution(propsIn),
|
|
20
|
+
[props, style, theme] = usePropsAndStyle(propsIn, {
|
|
21
|
+
...opts,
|
|
22
|
+
forComponent: Text,
|
|
23
|
+
resolveValues: opts.resolveValues,
|
|
24
|
+
noMedia: !needsMedia
|
|
25
|
+
}),
|
|
26
|
+
defaultColor = opts.defaultThemeColor,
|
|
27
|
+
colorIn = style.color || (defaultColor ? theme[defaultColor] : void 0) || (props.disableTheme ? null : theme.color) || opts.fallbackColor,
|
|
28
|
+
color = getVariable(colorIn),
|
|
29
|
+
size = typeof props.size == "string" ? getTokenValue(props.size, "size") : props.size || (styledContext.size === "$true" ? void 0 : styledContext.size),
|
|
30
|
+
_props_strokeWidth,
|
|
31
|
+
strokeWidth = typeof props.strokeWidth == "string" ? getTokenValue(props.strokeWidth, "size") : (_props_strokeWidth = props.strokeWidth) !== null && _props_strokeWidth !== void 0 ? _props_strokeWidth : `${opts.defaultStrokeWidth}`,
|
|
32
|
+
finalProps = {
|
|
33
|
+
...props,
|
|
34
|
+
color,
|
|
35
|
+
size,
|
|
36
|
+
strokeWidth,
|
|
37
|
+
style
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */_jsx(Component, {
|
|
40
|
+
...finalProps
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
wrapped = function (propsIn) {
|
|
44
|
+
return /* @__PURE__ */_jsx(IconWrapper, {
|
|
45
|
+
...propsIn
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return wrapped.staticConfig = {
|
|
49
|
+
isHOC: !0,
|
|
50
|
+
acceptsClassName: !0
|
|
51
|
+
}, wrapped;
|
|
52
|
+
}
|
|
53
|
+
export { SizableContext, themed };
|
|
54
|
+
//# sourceMappingURL=themed.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","getTokenValue","getVariable","Text","usePropsAndStyle","SizableContext","needsFullStyleResolution","props","key","themed","Component","optsIn","arguments","length","opts","defaultThemeColor","process","env","DEFAULT_ICON_THEME_COLOR","defaultStrokeWidth","fallbackColor","resolveValues","HANZO_GUI_ICON_COLOR_RESOLVE","IconWrapper","propsIn","styledContext","useStyledContext","needsMedia","style","theme","forComponent","noMedia","defaultColor","colorIn","color","disableTheme","size","_props_strokeWidth","strokeWidth","finalProps","wrapped","staticConfig","isHOC","acceptsClassName"],"sources":["../../src/themed.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAAAA,GAAA,IAAAC,IAAA;AAAA,SACEC,aAAA,EAAAC,WAAA,EAAAC,IAAA,EAAAC,gBAAA;AAAA,SACAC,cAAA;AAAA,SACAC,yBAAAC,KAAA;EACA,SAAAC,GA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cAAAA,kBAAA,MAAAvB,IAAA,CAAAK,kBAAA;QAAAoB,UAAA;UACtD,GAAGhC,KAAA;UACH2B,KAAA;UACAE,IAAA;UACAE,WAAU;UACXV;QAsBkB;MACd,OACH,eAAA5B,IAAA,CAAAU,SAAA;QACA,GAAA6B;MAAA,EACA;IAAA;IAAAC,OACA,YAAAA,CAAAhB,OAAA;MACF,sBAAAxB,IAAA,CAAAuB,WAAA;QAEA,GAAAC;MACF,CAEM;IAKN;EAA0B,OACxBgB,OAAO,CAAAC,YAAA;IACPC,KAAA;IACFC,gBAEO;EACT,GAAAH,OAAA","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hanzogui/helpers-icon",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Utilities for icon packages",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"source": "src/index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"types",
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "dist/cjs",
|
|
15
|
+
"module": "dist/esm",
|
|
16
|
+
"types": "./types/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./types/index.d.ts",
|
|
21
|
+
"react-native": "./dist/esm/index.native.js",
|
|
22
|
+
"browser": "./dist/esm/index.mjs",
|
|
23
|
+
"module": "./dist/esm/index.mjs",
|
|
24
|
+
"import": "./dist/esm/index.mjs",
|
|
25
|
+
"require": "./dist/cjs/index.cjs",
|
|
26
|
+
"default": "./dist/esm/index.mjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "hanzo-gui-build",
|
|
31
|
+
"watch": "hanzo-gui-build --watch",
|
|
32
|
+
"clean": "hanzo-gui-build clean",
|
|
33
|
+
"clean:build": "hanzo-gui-build clean:build"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@hanzogui/core": "workspace:*",
|
|
37
|
+
"@hanzogui/sizable-context": "workspace:*"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@hanzogui/build": "workspace:*",
|
|
41
|
+
"react": ">=19",
|
|
42
|
+
"react-native-svg": "15.15.3"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": ">=19",
|
|
46
|
+
"react-native-svg": ">=12"
|
|
47
|
+
},
|
|
48
|
+
"skipPublishIfUnchanged": false
|
|
49
|
+
}
|
package/src/IconProps.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ColorTokens,
|
|
3
|
+
GetFinalProps,
|
|
4
|
+
SizeTokens,
|
|
5
|
+
StackStyleBase,
|
|
6
|
+
ThemeTokens,
|
|
7
|
+
} from '@hanzogui/core'
|
|
8
|
+
import type { SvgProps } from 'react-native-svg'
|
|
9
|
+
|
|
10
|
+
export interface IconStyleProps extends StackStyleBase {
|
|
11
|
+
size?: number | SizeTokens
|
|
12
|
+
strokeWidth?: number | SizeTokens
|
|
13
|
+
color?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type NonStyleProps = Omit<SvgProps, keyof IconStyleProps> & {
|
|
17
|
+
disableTheme?: boolean
|
|
18
|
+
style?: SvgProps['style']
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type IconProps = GetFinalProps<NonStyleProps, IconStyleProps, {}>
|
package/src/index.ts
ADDED
package/src/themed.tsx
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getTokenValue,
|
|
3
|
+
getVariable,
|
|
4
|
+
Text,
|
|
5
|
+
usePropsAndStyle,
|
|
6
|
+
type ResolveVariableAs,
|
|
7
|
+
} from '@hanzogui/core'
|
|
8
|
+
import { SizableContext } from '@hanzogui/sizable-context'
|
|
9
|
+
|
|
10
|
+
import type { FC } from 'react'
|
|
11
|
+
import type { IconProps } from './IconProps'
|
|
12
|
+
|
|
13
|
+
export { SizableContext }
|
|
14
|
+
|
|
15
|
+
type Options = {
|
|
16
|
+
noClass?: boolean
|
|
17
|
+
defaultThemeColor?: string
|
|
18
|
+
defaultStrokeWidth?: number
|
|
19
|
+
fallbackColor?: string
|
|
20
|
+
resolveValues?: ResolveVariableAs
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// check if props contain media queries ($sm, $md, etc) or other complex hanzo-gui features
|
|
24
|
+
function needsFullStyleResolution(props: IconProps): boolean {
|
|
25
|
+
for (const key in props) {
|
|
26
|
+
if (key[0] === '$') return true
|
|
27
|
+
}
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function themed(Component: FC<IconProps>, optsIn: Options = {}) {
|
|
32
|
+
const opts: Options = {
|
|
33
|
+
defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || '$color',
|
|
34
|
+
defaultStrokeWidth: 2,
|
|
35
|
+
fallbackColor: '#000',
|
|
36
|
+
resolveValues: (process.env.HANZO_GUI_ICON_COLOR_RESOLVE as any) || 'auto',
|
|
37
|
+
...optsIn,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const IconWrapper = (propsIn: IconProps) => {
|
|
41
|
+
const styledContext = SizableContext.useStyledContext()
|
|
42
|
+
const needsMedia = needsFullStyleResolution(propsIn)
|
|
43
|
+
|
|
44
|
+
const [props, style, theme] = usePropsAndStyle(propsIn, {
|
|
45
|
+
...opts,
|
|
46
|
+
forComponent: Text,
|
|
47
|
+
resolveValues: opts.resolveValues,
|
|
48
|
+
noMedia: !needsMedia,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const defaultColor = opts.defaultThemeColor
|
|
52
|
+
|
|
53
|
+
const colorIn =
|
|
54
|
+
style.color ||
|
|
55
|
+
(defaultColor ? theme[defaultColor as string] : undefined) ||
|
|
56
|
+
(!props.disableTheme ? theme.color : null) ||
|
|
57
|
+
opts.fallbackColor
|
|
58
|
+
|
|
59
|
+
const color = getVariable(colorIn)
|
|
60
|
+
|
|
61
|
+
const size =
|
|
62
|
+
typeof props.size === 'string'
|
|
63
|
+
? getTokenValue(props.size as any, 'size')
|
|
64
|
+
: props.size || (styledContext.size === '$true' ? undefined : styledContext.size)
|
|
65
|
+
|
|
66
|
+
const strokeWidth =
|
|
67
|
+
typeof props.strokeWidth === 'string'
|
|
68
|
+
? getTokenValue(props.strokeWidth as any, 'size')
|
|
69
|
+
: (props.strokeWidth ?? `${opts.defaultStrokeWidth}`)
|
|
70
|
+
|
|
71
|
+
const finalProps = {
|
|
72
|
+
...props,
|
|
73
|
+
color,
|
|
74
|
+
size,
|
|
75
|
+
strokeWidth,
|
|
76
|
+
style: style as any,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return <Component {...finalProps} />
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const wrapped = (propsIn: IconProps) => {
|
|
83
|
+
return <IconWrapper {...propsIn} />
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// add staticConfig so styled() works properly with themed icons
|
|
87
|
+
wrapped['staticConfig'] = {
|
|
88
|
+
isHOC: true,
|
|
89
|
+
acceptsClassName: true,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return wrapped
|
|
93
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GetFinalProps, SizeTokens, StackStyleBase } from '@hanzogui/core';
|
|
2
|
+
import type { SvgProps } from 'react-native-svg';
|
|
3
|
+
export interface IconStyleProps extends StackStyleBase {
|
|
4
|
+
size?: number | SizeTokens;
|
|
5
|
+
strokeWidth?: number | SizeTokens;
|
|
6
|
+
color?: string;
|
|
7
|
+
}
|
|
8
|
+
export type NonStyleProps = Omit<SvgProps, keyof IconStyleProps> & {
|
|
9
|
+
disableTheme?: boolean;
|
|
10
|
+
style?: SvgProps['style'];
|
|
11
|
+
};
|
|
12
|
+
export type IconProps = GetFinalProps<NonStyleProps, IconStyleProps, {}>;
|
|
13
|
+
//# sourceMappingURL=IconProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconProps.d.ts","sourceRoot":"","sources":["../src/IconProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,UAAU,EACV,cAAc,EAEf,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IACjC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,cAAc,CAAC,GAAG;IACjE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,EAAE,cAAc,EAAE,EAAE,CAAC,CAAA"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ResolveVariableAs } from '@hanzogui/core';
|
|
2
|
+
import { SizableContext } from '@hanzogui/sizable-context';
|
|
3
|
+
import type { FC } from 'react';
|
|
4
|
+
import type { IconProps } from './IconProps';
|
|
5
|
+
export { SizableContext };
|
|
6
|
+
type Options = {
|
|
7
|
+
noClass?: boolean;
|
|
8
|
+
defaultThemeColor?: string;
|
|
9
|
+
defaultStrokeWidth?: number;
|
|
10
|
+
fallbackColor?: string;
|
|
11
|
+
resolveValues?: ResolveVariableAs;
|
|
12
|
+
};
|
|
13
|
+
export declare function themed(Component: FC<IconProps>, optsIn?: Options): {
|
|
14
|
+
(propsIn: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
staticConfig: {
|
|
16
|
+
isHOC: boolean;
|
|
17
|
+
acceptsClassName: boolean;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=themed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themed.d.ts","sourceRoot":"","sources":["../src/themed.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,CAAA;AAEzB,KAAK,OAAO,GAAG;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAClC,CAAA;AAUD,wBAAgB,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,GAAE,OAAY;cAmDzC,SAAS;;;;;EAWpC"}
|