@hanzogui/helpers-icon 2.0.0-rc.41-hanzoai.5

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 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,18 @@
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") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
15
+ value: true
16
+ }), mod);
17
+ var IconProps_exports = {};
18
+ module.exports = __toCommonJS(IconProps_exports);
@@ -0,0 +1,21 @@
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") {
9
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
+ get: () => from[key],
11
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
+ });
13
+ }
14
+ return to;
15
+ };
16
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
17
+ value: true
18
+ }), mod);
19
+ var IconProps_exports = {};
20
+ module.exports = __toCommonJS(IconProps_exports);
21
+ //# 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,21 @@
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") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: true
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./IconProps.cjs"), module.exports);
21
+ __reExport(index_exports, require("./themed.cjs"), module.exports);
@@ -0,0 +1,24 @@
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") {
9
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
+ get: () => from[key],
11
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
+ });
13
+ }
14
+ return to;
15
+ };
16
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
+ value: true
19
+ }), mod);
20
+ var index_exports = {};
21
+ module.exports = __toCommonJS(index_exports);
22
+ __reExport(index_exports, require("./IconProps.native.js"), module.exports);
23
+ __reExport(index_exports, require("./themed.native.js"), module.exports);
24
+ //# 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,81 @@
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: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
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_core = require("@hanzogui/core");
30
+ var import_sizable_context = require("@hanzogui/sizable-context");
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ function needsFullStyleResolution(props) {
33
+ for (const key in props) {
34
+ if (key[0] === "$") return true;
35
+ }
36
+ return false;
37
+ }
38
+ function themed(Component, optsIn = {}) {
39
+ const opts = {
40
+ defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || "$color",
41
+ defaultStrokeWidth: 2,
42
+ fallbackColor: "#000",
43
+ resolveValues: process.env.TAMAGUI_ICON_COLOR_RESOLVE || "auto",
44
+ ...optsIn
45
+ };
46
+ const IconWrapper = propsIn => {
47
+ const styledContext = import_sizable_context.SizableContext.useStyledContext();
48
+ const needsMedia = needsFullStyleResolution(propsIn);
49
+ const [props, style, theme] = (0, import_core.usePropsAndStyle)(propsIn, {
50
+ ...opts,
51
+ forComponent: import_core.Text,
52
+ resolveValues: opts.resolveValues,
53
+ noMedia: !needsMedia
54
+ });
55
+ const defaultColor = opts.defaultThemeColor;
56
+ const colorIn = style.color || (defaultColor ? theme[defaultColor] : void 0) || (!props.disableTheme ? theme.color : null) || opts.fallbackColor;
57
+ const color = (0, import_core.getVariable)(colorIn);
58
+ const size = typeof props.size === "string" ? (0, import_core.getTokenValue)(props.size, "size") : props.size || (styledContext.size === "$true" ? void 0 : styledContext.size);
59
+ const strokeWidth = typeof props.strokeWidth === "string" ? (0, import_core.getTokenValue)(props.strokeWidth, "size") : props.strokeWidth ?? `${opts.defaultStrokeWidth}`;
60
+ const 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
+ const wrapped = propsIn => {
72
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(IconWrapper, {
73
+ ...propsIn
74
+ });
75
+ };
76
+ wrapped["staticConfig"] = {
77
+ isHOC: true,
78
+ acceptsClassName: true
79
+ };
80
+ return wrapped;
81
+ }
@@ -0,0 +1,86 @@
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: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var themed_exports = {};
26
+ __export(themed_exports, {
27
+ SizableContext: () => import_sizable_context.SizableContext,
28
+ themed: () => themed
29
+ });
30
+ module.exports = __toCommonJS(themed_exports);
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ var import_core = require("@hanzogui/core");
33
+ var import_sizable_context = require("@hanzogui/sizable-context");
34
+ function needsFullStyleResolution(props) {
35
+ for (var key in props) {
36
+ if (key[0] === "$") return true;
37
+ }
38
+ return false;
39
+ }
40
+ function themed(Component) {
41
+ var optsIn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
42
+ var opts = {
43
+ defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || "$color",
44
+ defaultStrokeWidth: 2,
45
+ fallbackColor: "#000",
46
+ resolveValues: process.env.TAMAGUI_ICON_COLOR_RESOLVE || "auto",
47
+ ...optsIn
48
+ };
49
+ var IconWrapper = function (propsIn) {
50
+ var styledContext = import_sizable_context.SizableContext.useStyledContext();
51
+ var needsMedia = needsFullStyleResolution(propsIn);
52
+ var [props, style, theme] = (0, import_core.usePropsAndStyle)(propsIn, {
53
+ ...opts,
54
+ forComponent: import_core.Text,
55
+ resolveValues: opts.resolveValues,
56
+ noMedia: !needsMedia
57
+ });
58
+ var defaultColor = opts.defaultThemeColor;
59
+ var colorIn = style.color || (defaultColor ? theme[defaultColor] : void 0) || (!props.disableTheme ? theme.color : null) || opts.fallbackColor;
60
+ var color = (0, import_core.getVariable)(colorIn);
61
+ var size = typeof props.size === "string" ? (0, import_core.getTokenValue)(props.size, "size") : props.size || (styledContext.size === "$true" ? void 0 : styledContext.size);
62
+ var _props_strokeWidth;
63
+ var 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}`;
64
+ var finalProps = {
65
+ ...props,
66
+ color,
67
+ size,
68
+ strokeWidth,
69
+ style
70
+ };
71
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Component, {
72
+ ...finalProps
73
+ });
74
+ };
75
+ var wrapped = function (propsIn) {
76
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(IconWrapper, {
77
+ ...propsIn
78
+ });
79
+ };
80
+ wrapped["staticConfig"] = {
81
+ isHOC: true,
82
+ acceptsClassName: true
83
+ };
84
+ return wrapped;
85
+ }
86
+ //# 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","TAMAGUI_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,sBAAA,CAAAD,cAAA;EAAAE,MAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAM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Aa,CAAA+B,IAAA,oBAAAjC,WAAA,CAAAkC,aAAA,EAAAhC,KAAA,CAAA+B,IAAA,YAAA/B,KAAA,CAAA+B,IAAA,KAAAd,aAAA,CAAAc,IAAA,wBAAAd,aAAA,CAAAc,IAAA;IAAA,IACjBE,kBAAG;IAAA,IACHC,WAAA,UAAAlC,KAAA,CAAAkC,WAAA,oBAAApC,WAAA,CAAAkC,aAAA,EAAAhC,KAAA,CAAAkC,WAAA,aAAAD,kBAAA,GAAAjC,KAAA,CAAAkC,WAAA,cAAAD,kBAAA,cAAAA,kBAAA,MAAA3B,IAAA,CAAAK,kBAAA;IAAA,IACAwB,UAAA;MACA,GAAAnC,KAAA;MACA4B,KAAA;MACFG,IAAA;MAEAG,WAAO;MACTd;IAEA;IACE,OAAO,mBAAAxB,kBAAA,CAAAwC,GAAA,EAAClC,SAAA;MACV,GAAAiC;IAGA;EAA0B;EACjB,IACPE,OAAA,YAAAA,CAAkBrB,OAAA;IACpB,0BAAApB,kBAAA,CAAAwC,GAAA,EAAArB,WAAA;MAEA,GAAOC;IACT","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=IconProps.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=IconProps.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export * from "./IconProps.mjs";
2
+ export * from "./themed.mjs";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export * from "./IconProps.mjs";
2
+ export * from "./themed.mjs";
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export * from "./IconProps.native.js";
2
+ export * from "./themed.native.js";
3
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
@@ -0,0 +1,55 @@
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) {
6
+ if (key[0] === "$") return true;
7
+ }
8
+ return false;
9
+ }
10
+ function themed(Component, optsIn = {}) {
11
+ const opts = {
12
+ defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || "$color",
13
+ defaultStrokeWidth: 2,
14
+ fallbackColor: "#000",
15
+ resolveValues: process.env.TAMAGUI_ICON_COLOR_RESOLVE || "auto",
16
+ ...optsIn
17
+ };
18
+ const IconWrapper = propsIn => {
19
+ const styledContext = SizableContext.useStyledContext();
20
+ const needsMedia = needsFullStyleResolution(propsIn);
21
+ const [props, style, theme] = usePropsAndStyle(propsIn, {
22
+ ...opts,
23
+ forComponent: Text,
24
+ resolveValues: opts.resolveValues,
25
+ noMedia: !needsMedia
26
+ });
27
+ const defaultColor = opts.defaultThemeColor;
28
+ const colorIn = style.color || (defaultColor ? theme[defaultColor] : void 0) || (!props.disableTheme ? theme.color : null) || opts.fallbackColor;
29
+ const color = getVariable(colorIn);
30
+ const size = typeof props.size === "string" ? getTokenValue(props.size, "size") : props.size || (styledContext.size === "$true" ? void 0 : styledContext.size);
31
+ const strokeWidth = typeof props.strokeWidth === "string" ? getTokenValue(props.strokeWidth, "size") : props.strokeWidth ?? `${opts.defaultStrokeWidth}`;
32
+ const finalProps = {
33
+ ...props,
34
+ color,
35
+ size,
36
+ strokeWidth,
37
+ style
38
+ };
39
+ return /* @__PURE__ */jsx(Component, {
40
+ ...finalProps
41
+ });
42
+ };
43
+ const wrapped = propsIn => {
44
+ return /* @__PURE__ */jsx(IconWrapper, {
45
+ ...propsIn
46
+ });
47
+ };
48
+ wrapped["staticConfig"] = {
49
+ isHOC: true,
50
+ acceptsClassName: true
51
+ };
52
+ return wrapped;
53
+ }
54
+ export { SizableContext, themed };
55
+ //# 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","TAMAGUI_ICON_COLOR_RESOLVE","IconWrapper","propsIn","styledContext","useStyledContext","needsMedia","style","theme","forComponent","noMedia","defaultColor","colorIn","color","disableTheme","size","strokeWidth","finalProps","wrapped","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,EAAO;IACvB,IAAIC,GAAA,CAAI,CAAC,MAAM,KAAK,OAAO;EAC7B;EACA,OAAO;AACT;AAEO,SAASC,OAAOC,SAAA,EAA0BC,MAAA,GAAkB,CAAC,GAAG;EACrE,MAAMC,IAAA,GAAgB;IACpBC,iBAAA,EAAmBC,OAAA,CAAQC,GAAA,CAAIC,wBAAA,IAA4B;IAC3DC,kBAAA,EAAoB;IACpBC,aAAA,EAAe;IACfC,aAAA,EAAgBL,OAAA,CAAQC,GAAA,CAAIK,0BAAA,IAAsC;IAClE,GAAGT;EACL;EAEA,MAA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uB;IACtC,OAAO,eAAAjB,GAAA,CAACgB,WAAA;MAAa,GAAGC;IAAA,CAAS;EACnC;EAGAe,OAAA,CAAQ,cAAc,IAAI;IACxBC,KAAA,EAAO;IACPC,gBAAA,EAAkB;EACpB;EAEA,OAAOF,OAAA;AACT","ignoreList":[]}
@@ -0,0 +1,57 @@
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) {
6
+ if (key[0] === "$") return true;
7
+ }
8
+ return false;
9
+ }
10
+ function themed(Component) {
11
+ var optsIn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
12
+ var opts = {
13
+ defaultThemeColor: process.env.DEFAULT_ICON_THEME_COLOR || "$color",
14
+ defaultStrokeWidth: 2,
15
+ fallbackColor: "#000",
16
+ resolveValues: process.env.TAMAGUI_ICON_COLOR_RESOLVE || "auto",
17
+ ...optsIn
18
+ };
19
+ var IconWrapper = function (propsIn) {
20
+ var styledContext = SizableContext.useStyledContext();
21
+ var needsMedia = needsFullStyleResolution(propsIn);
22
+ var [props, style, theme] = usePropsAndStyle(propsIn, {
23
+ ...opts,
24
+ forComponent: Text,
25
+ resolveValues: opts.resolveValues,
26
+ noMedia: !needsMedia
27
+ });
28
+ var defaultColor = opts.defaultThemeColor;
29
+ var colorIn = style.color || (defaultColor ? theme[defaultColor] : void 0) || (!props.disableTheme ? theme.color : null) || opts.fallbackColor;
30
+ var color = getVariable(colorIn);
31
+ var size = typeof props.size === "string" ? getTokenValue(props.size, "size") : props.size || (styledContext.size === "$true" ? void 0 : styledContext.size);
32
+ var _props_strokeWidth;
33
+ var strokeWidth = typeof props.strokeWidth === "string" ? getTokenValue(props.strokeWidth, "size") : (_props_strokeWidth = props.strokeWidth) !== null && _props_strokeWidth !== void 0 ? _props_strokeWidth : `${opts.defaultStrokeWidth}`;
34
+ var finalProps = {
35
+ ...props,
36
+ color,
37
+ size,
38
+ strokeWidth,
39
+ style
40
+ };
41
+ return /* @__PURE__ */_jsx(Component, {
42
+ ...finalProps
43
+ });
44
+ };
45
+ var wrapped = function (propsIn) {
46
+ return /* @__PURE__ */_jsx(IconWrapper, {
47
+ ...propsIn
48
+ });
49
+ };
50
+ wrapped["staticConfig"] = {
51
+ isHOC: true,
52
+ acceptsClassName: true
53
+ };
54
+ return wrapped;
55
+ }
56
+ export { SizableContext, themed };
57
+ //# 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","TAMAGUI_ICON_COLOR_RESOLVE","IconWrapper","propsIn","styledContext","useStyledContext","needsMedia","style","theme","forComponent","noMedia","defaultColor","colorIn","color","disableTheme","size","_props_strokeWidth","strokeWidth","finalProps","wrapped","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,GAAA,IAAAD,KAAA;IAAA,IAEKC,GAAA;EACP;EAuEW;AAvDX;AACE,SAAAC,MAAWA,CAAAC,SAAO,EAAO;EACvB,IAAAC,MAAQ,GAACC,SAAW,CAAAC,MAAO,QAAAD,SAAA,iBAAAA,SAAA;EAC7B,IAAAE,IAAA;IACAC,iBAAO,EAAAC,OAAA,CAAAC,GAAA,CAAAC,wBAAA;IACTC,kBAAA;IAEOC,aAAgB;IACrBC,aAAsB,EAAAL,OAAA,CAAAC,GAAA,CAAAK,0BAAA;IACpB,GAAAX;EAA2D;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AAAuB,WAAA;MACtC,GAAAC;IACF;EAGA;EAA0BgB,OACxB,eAAO;IACPC,KAAA;IACFC,gBAAA;EAEA;EACF,OAAAF,OAAA","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@hanzogui/helpers-icon",
3
+ "version": "2.0.0-rc.41-hanzoai.5",
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": "hanzogui-build",
31
+ "watch": "hanzogui-build --watch",
32
+ "clean": "hanzogui-build clean",
33
+ "clean:build": "hanzogui-build clean:build"
34
+ },
35
+ "dependencies": {
36
+ "@hanzogui/core": "2.0.0-rc.41-hanzoai.5",
37
+ "@hanzogui/sizable-context": "2.0.0-rc.41-hanzoai.5"
38
+ },
39
+ "devDependencies": {
40
+ "@hanzogui/build": "2.0.0-rc.41-hanzoai.5",
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
+ }
@@ -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
@@ -0,0 +1,2 @@
1
+ export * from './IconProps'
2
+ export * from './themed'
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 hanzogui 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.TAMAGUI_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"}
@@ -0,0 +1,3 @@
1
+ export * from './IconProps';
2
+ export * from './themed';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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"}