@hanzogui/component-helpers 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/README.md +1 -0
- package/dist/cjs/getIcon.cjs +42 -0
- package/dist/cjs/getIcon.native.js +47 -0
- package/dist/cjs/getIcon.native.js.map +1 -0
- package/dist/cjs/index.cjs +22 -0
- package/dist/cjs/index.native.js +25 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/prevent.cjs +26 -0
- package/dist/cjs/prevent.native.js +31 -0
- package/dist/cjs/prevent.native.js.map +1 -0
- package/dist/cjs/useCurrentColor.cjs +30 -0
- package/dist/cjs/useCurrentColor.native.js +36 -0
- package/dist/cjs/useCurrentColor.native.js.map +1 -0
- package/dist/cjs/useGetThemedIcon.cjs +47 -0
- package/dist/cjs/useGetThemedIcon.native.js +52 -0
- package/dist/cjs/useGetThemedIcon.native.js.map +1 -0
- package/dist/esm/getIcon.mjs +8 -0
- package/dist/esm/getIcon.mjs.map +1 -0
- package/dist/esm/getIcon.native.js +10 -0
- package/dist/esm/getIcon.native.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +6 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/prevent.mjs +3 -0
- package/dist/esm/prevent.mjs.map +1 -0
- package/dist/esm/prevent.native.js +5 -0
- package/dist/esm/prevent.native.js.map +1 -0
- package/dist/esm/useCurrentColor.mjs +7 -0
- package/dist/esm/useCurrentColor.mjs.map +1 -0
- package/dist/esm/useCurrentColor.native.js +10 -0
- package/dist/esm/useCurrentColor.native.js.map +1 -0
- package/dist/esm/useGetThemedIcon.mjs +13 -0
- package/dist/esm/useGetThemedIcon.mjs.map +1 -0
- package/dist/esm/useGetThemedIcon.native.js +15 -0
- package/dist/esm/useGetThemedIcon.native.js.map +1 -0
- package/package.json +50 -0
- package/src/getIcon.tsx +20 -0
- package/src/index.ts +5 -0
- package/src/prevent.tsx +1 -0
- package/src/useCurrentColor.tsx +18 -0
- package/src/useGetThemedIcon.tsx +19 -0
- package/types/getIcon.d.ts +6 -0
- package/types/getIcon.d.ts.map +1 -0
- package/types/index.d.ts +6 -0
- package/types/index.d.ts.map +1 -0
- package/types/prevent.d.ts +2 -0
- package/types/prevent.d.ts.map +1 -0
- package/types/useCurrentColor.d.ts +5 -0
- package/types/useCurrentColor.d.ts.map +1 -0
- package/types/useGetThemedIcon.d.ts +6 -0
- package/types/useGetThemedIcon.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.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a superset of @hanzogui/helpers with extra utilities used by `@hanzo/gui`
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var getIcon_exports = {};
|
|
33
|
+
__export(getIcon_exports, {
|
|
34
|
+
getIcon: () => getIcon
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(getIcon_exports);
|
|
37
|
+
var import_react = __toESM(require("react"), 1);
|
|
38
|
+
const getIcon = (el, props) => el && (import_react.default.isValidElement(el) ? import_react.default.cloneElement(el, {
|
|
39
|
+
...props,
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
...el.props
|
|
42
|
+
}) : import_react.default.createElement(el, props));
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
__copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: !0
|
|
30
|
+
}) : target, mod)),
|
|
31
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: !0
|
|
33
|
+
}), mod);
|
|
34
|
+
var getIcon_exports = {};
|
|
35
|
+
__export(getIcon_exports, {
|
|
36
|
+
getIcon: () => getIcon
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(getIcon_exports);
|
|
39
|
+
var import_react = __toESM(require("react"), 1),
|
|
40
|
+
getIcon = function (el, props) {
|
|
41
|
+
return el && (/* @__PURE__ */import_react.default.isValidElement(el) ? /* @__PURE__ */import_react.default.cloneElement(el, {
|
|
42
|
+
...props,
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
...el.props
|
|
45
|
+
}) : /* @__PURE__ */import_react.default.createElement(el, props));
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=getIcon.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getIcon_exports","__export","getIcon","module","exports","import_react","__toESM","require","el","props","default","isValidElement","cloneElement"],"sources":["../../src/getIcon.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,eAAA;AAAAC,QAAA,CAAAD,eAAA;EAAAE,OAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAkB,CAAAK,eAAA;AAEX,IAAAK,YAAgB,GACrBC,OACA,CAAAC,OAMK,QACD;EAAAL,OAAA,GAAM,SAAAA,CAAAM,EAAA,EAAAC,KAAiB;IAEvB,OAAGD,EAAA,oBAAAH,YAAA,CAAAK,OAAA,CAAAC,cAAA,CAAAH,EAAA,mBAAAH,YAAA,CAAAK,OAAA,CAAAE,YAAA,CAAAJ,EAAA;MAAA,GAAAC,KAAA;MAEH;MACD,GAEID,EAAA,CAAAC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
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("@hanzogui/helpers"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./prevent.cjs"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./useCurrentColor.cjs"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./useGetThemedIcon.cjs"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./getIcon.cjs"), module.exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
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("@hanzogui/helpers"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./prevent.native.js"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./useCurrentColor.native.js"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./useGetThemedIcon.native.js"), module.exports);
|
|
24
|
+
__reExport(index_exports, require("./getIcon.native.js"), module.exports);
|
|
25
|
+
//# 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,oBADd,GAAAH,MAAA,CAAAC,OAAA;AAEAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,yBAAAH,MAAA,CAAAC,OAFd;AAGAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,iCAAAH,MAHd,CAAAC,OAAA;AAIAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,+BAJd,GAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 prevent_exports = {};
|
|
22
|
+
__export(prevent_exports, {
|
|
23
|
+
prevent: () => prevent
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(prevent_exports);
|
|
26
|
+
const prevent = e => [e.preventDefault(), e.stopPropagation()];
|
|
@@ -0,0 +1,31 @@
|
|
|
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 prevent_exports = {};
|
|
24
|
+
__export(prevent_exports, {
|
|
25
|
+
prevent: () => prevent
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(prevent_exports);
|
|
28
|
+
var prevent = function (e) {
|
|
29
|
+
return [e.preventDefault(), e.stopPropagation()];
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=prevent.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","prevent_exports","__export","prevent","module","exports"],"sources":["../../src/prevent.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,eAAA;AAAAC,QAAA,CAAAD,eAAA;EAAAE,OAAA,EAAAA,CAAA,KAAAA;AAAA;AAAOC,MAAM,CAAAC,OAAA,GAAWT,YAAS,CAAAK,eAAkB,CAAE","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 useCurrentColor_exports = {};
|
|
22
|
+
__export(useCurrentColor_exports, {
|
|
23
|
+
useCurrentColor: () => useCurrentColor
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useCurrentColor_exports);
|
|
26
|
+
var import_web = require("@hanzogui/web");
|
|
27
|
+
const useCurrentColor = colorProp => {
|
|
28
|
+
const theme = (0, import_web.useTheme)();
|
|
29
|
+
return colorProp ? (0, import_web.getVariable)(colorProp) : theme[colorProp]?.get() || theme.color?.get();
|
|
30
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 useCurrentColor_exports = {};
|
|
24
|
+
__export(useCurrentColor_exports, {
|
|
25
|
+
useCurrentColor: () => useCurrentColor
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useCurrentColor_exports);
|
|
28
|
+
var import_web = require("@hanzogui/web"),
|
|
29
|
+
useCurrentColor = function (colorProp) {
|
|
30
|
+
var _theme_colorProp,
|
|
31
|
+
_theme_color,
|
|
32
|
+
theme = (0, import_web.useTheme)(),
|
|
33
|
+
out = colorProp ? (0, import_web.getVariable)(colorProp) : ((_theme_colorProp = theme[colorProp]) === null || _theme_colorProp === void 0 ? void 0 : _theme_colorProp.get()) || ((_theme_color = theme.color) === null || _theme_color === void 0 ? void 0 : _theme_color.get());
|
|
34
|
+
return out;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useCurrentColor.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useCurrentColor_exports","__export","useCurrentColor","module","exports","import_web","require","colorProp","_theme_colorProp","_theme_color","theme","useTheme","out","getVariable","get","color"],"sources":["../../src/useCurrentColor.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,eAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAsCT,YAAA,CAAAK,uBAAA;AAG/B,IAAAK,UAAM,GAAAC,OAAkB,CAAC,eAAyB;EAAAJ,eAAA,YAAAA,CAAAK,SAAA;IACvD,IAAAC,gBAAc;MAAAC,YAAA;MAAAC,KAAS,OAAAL,UAAA,CAAAM,QAAA;MAAAC,GAAA,GAAAL,SAAA,OAAAF,UAAA,CAAAQ,WAAA,EAAAN,SAAA,MAAAC,gBAAA,GAAAE,KAAA,CAAAH,SAAA,eAAAC,gBAAA,uBAAAA,gBAAA,CAAAM,GAAA,SAAAL,YAAA,GAAAC,KAAA,CAAAK,KAAA,cAAAN,YAAA,uBAAAA,YAAA,CAAAK,GAAA;IAIvB,OAHYF,GAAA;EAId","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var useGetThemedIcon_exports = {};
|
|
33
|
+
__export(useGetThemedIcon_exports, {
|
|
34
|
+
useGetThemedIcon: () => useGetThemedIcon
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(useGetThemedIcon_exports);
|
|
37
|
+
var import_react = __toESM(require("react"), 1),
|
|
38
|
+
import_useCurrentColor = require("./useCurrentColor.cjs");
|
|
39
|
+
const useGetThemedIcon = props => {
|
|
40
|
+
const color = (0, import_useCurrentColor.useCurrentColor)(props.color);
|
|
41
|
+
return el => el && (import_react.default.isValidElement(el) ? import_react.default.cloneElement(el, {
|
|
42
|
+
...props,
|
|
43
|
+
color,
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
...el.props
|
|
46
|
+
}) : import_react.default.createElement(el, props));
|
|
47
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
__copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: !0
|
|
30
|
+
}) : target, mod)),
|
|
31
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: !0
|
|
33
|
+
}), mod);
|
|
34
|
+
var useGetThemedIcon_exports = {};
|
|
35
|
+
__export(useGetThemedIcon_exports, {
|
|
36
|
+
useGetThemedIcon: () => useGetThemedIcon
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(useGetThemedIcon_exports);
|
|
39
|
+
var import_react = __toESM(require("react"), 1),
|
|
40
|
+
import_useCurrentColor = require("./useCurrentColor.native.js"),
|
|
41
|
+
useGetThemedIcon = function (props) {
|
|
42
|
+
var color = (0, import_useCurrentColor.useCurrentColor)(props.color);
|
|
43
|
+
return function (el) {
|
|
44
|
+
return el && (/* @__PURE__ */import_react.default.isValidElement(el) ? /* @__PURE__ */import_react.default.cloneElement(el, {
|
|
45
|
+
...props,
|
|
46
|
+
color,
|
|
47
|
+
// @ts-expect-error
|
|
48
|
+
...el.props
|
|
49
|
+
}) : /* @__PURE__ */import_react.default.createElement(el, props));
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=useGetThemedIcon.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useGetThemedIcon_exports","__export","useGetThemedIcon","module","exports","import_react","__toESM","require","import_useCurrentColor","props","color","useCurrentColor","el","default","isValidElement","cloneElement","createElement"],"sources":["../../src/useGetThemedIcon.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,wBAAA;AAAAC,QAAA,CAAAD,wBAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAkB,CAAAK,wBAElB;AAEO,IAAAK,YAAM,GAAAC,OAAoB,CAAAC,OAAA,QAA8C;EAAAC,sBAAA,GAAAD,OAAA;EAAAL,gBAAA,YAAAA,CAAAO,KAAA;IAC7E,IAAAC,KAAM,OAAAF,sBAAQ,CAAAG,eAAA,EAAAF,KAAgB,CAAAC,KAAM;IACpC,OAAO,UACAE,EAAA;MAGD,OAAGA,EAAA,oBAAAP,YAAA,CAAAQ,OAAA,CAAAC,cAAA,CAAAF,EAAA,mBAAAP,YAAA,CAAAQ,OAAA,CAAAE,YAAA,CAAAH,EAAA;QACH,GAAAH,KAAA;QAAAC,KAAA;QAEA;QACD,GAEIE,EAAA,CAAAH;MAEX,oBAAAJ,YAAA,CAAAQ,OAAA,CAAAG,aAAA,CAAAJ,EAAA,EAAAH,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
const getIcon = (el, props) => el && (React.isValidElement(el) ? React.cloneElement(el, {
|
|
3
|
+
...props,
|
|
4
|
+
// @ts-expect-error
|
|
5
|
+
...el.props
|
|
6
|
+
}) : React.createElement(el, props));
|
|
7
|
+
export { getIcon };
|
|
8
|
+
//# sourceMappingURL=getIcon.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","getIcon","el","props","isValidElement","cloneElement","createElement"],"sources":["../../src/getIcon.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAEX,MAAMC,OAAA,GAAUA,CACrBC,EAAA,EACAC,KAAA,KAMKD,EAAA,KACDF,KAAA,CAAMI,cAAA,CAAeF,EAAE,IAClBF,KAAA,CAAMK,YAAA,CAAaH,EAAA,EAAI;EAC5B,GAAGC,KAAA;EAAA;EAEH,GAAGD,EAAA,CAAGC;AACR,CAAC,IAEIH,KAAA,CAAMM,aAAA,CAAcJ,EAAA,EAAIC,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
var getIcon = function (el, props) {
|
|
3
|
+
return el && (/* @__PURE__ */React.isValidElement(el) ? /* @__PURE__ */React.cloneElement(el, {
|
|
4
|
+
...props,
|
|
5
|
+
// @ts-expect-error
|
|
6
|
+
...el.props
|
|
7
|
+
}) : /* @__PURE__ */React.createElement(el, props));
|
|
8
|
+
};
|
|
9
|
+
export { getIcon };
|
|
10
|
+
//# sourceMappingURL=getIcon.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","getIcon","el","props","isValidElement","cloneElement"],"sources":["../../src/getIcon.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAEX,IAAAC,OAAM,YAAAA,CAEXC,EAAA,EAAAC,KAMK;EAGD,OAAGD,EAAA,oBAAAF,KAAA,CAAAI,cAAA,CAAAF,EAAA,mBAAAF,KAAA,CAAAK,YAAA,CAAAH,EAAA;IAAA,GAAAC,KAAA;IAEH;IACD,GAEID,EAAA,CAAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["prevent","e","preventDefault","stopPropagation"],"sources":["../../src/prevent.tsx"],"sourcesContent":[null],"mappings":"AAAO,MAAMA,OAAA,GAAWC,CAAA,IAAM,CAACA,CAAA,CAAEC,cAAA,CAAe,GAAGD,CAAA,CAAEE,eAAA,CAAgB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["prevent","e"],"sources":["../../src/prevent.tsx"],"sourcesContent":[null],"mappings":"AAAO,IAAAA,OAAM,YAAAA,CAAiBC,CAAC,EAAE","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getVariable, useTheme } from "@hanzogui/web";
|
|
2
|
+
const useCurrentColor = colorProp => {
|
|
3
|
+
const theme = useTheme();
|
|
4
|
+
return colorProp ? getVariable(colorProp) : theme[colorProp]?.get() || theme.color?.get();
|
|
5
|
+
};
|
|
6
|
+
export { useCurrentColor };
|
|
7
|
+
//# sourceMappingURL=useCurrentColor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getVariable","useTheme","useCurrentColor","colorProp","theme","get","color"],"sources":["../../src/useCurrentColor.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,WAAA,EAAaC,QAAA,QAAgB;AAG/B,MAAMC,eAAA,GAAmBC,SAAA,IAAyB;EACvD,MAAMC,KAAA,GAAQH,QAAA,CAAS;EAIvB,OAHYE,SAAA,GACRH,WAAA,CAAYG,SAAS,IACrBC,KAAA,CAAMD,SAAgB,GAAGE,GAAA,CAAI,KAAKD,KAAA,CAAME,KAAA,EAAOD,GAAA,CAAI;AAEzD","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getVariable, useTheme } from "@hanzogui/web";
|
|
2
|
+
var useCurrentColor = function (colorProp) {
|
|
3
|
+
var _theme_colorProp,
|
|
4
|
+
_theme_color,
|
|
5
|
+
theme = useTheme(),
|
|
6
|
+
out = colorProp ? getVariable(colorProp) : ((_theme_colorProp = theme[colorProp]) === null || _theme_colorProp === void 0 ? void 0 : _theme_colorProp.get()) || ((_theme_color = theme.color) === null || _theme_color === void 0 ? void 0 : _theme_color.get());
|
|
7
|
+
return out;
|
|
8
|
+
};
|
|
9
|
+
export { useCurrentColor };
|
|
10
|
+
//# sourceMappingURL=useCurrentColor.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getVariable","useTheme","useCurrentColor","colorProp","_theme_colorProp","_theme_color","theme","out","get","color"],"sources":["../../src/useCurrentColor.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,WAAA,EAAaC,QAAA,QAAgB;AAG/B,IAAAC,eAAM,YAAAA,CAAmBC,SAAyB;EACvD,IAAAC,gBAAc;IAAAC,YAAS;IAAAC,KAAA,GAAAL,QAAA;IAAAM,GAAA,GAAAJ,SAAA,GAAAH,WAAA,CAAAG,SAAA,MAAAC,gBAAA,GAAAE,KAAA,CAAAH,SAAA,eAAAC,gBAAA,uBAAAA,gBAAA,CAAAI,GAAA,SAAAH,YAAA,GAAAC,KAAA,CAAAG,KAAA,cAAAJ,YAAA,uBAAAA,YAAA,CAAAG,GAAA;EAIvB,OAHYD,GAAA;AAId","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useCurrentColor } from "./useCurrentColor.mjs";
|
|
3
|
+
const useGetThemedIcon = props => {
|
|
4
|
+
const color = useCurrentColor(props.color);
|
|
5
|
+
return el => el && (React.isValidElement(el) ? React.cloneElement(el, {
|
|
6
|
+
...props,
|
|
7
|
+
color,
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
...el.props
|
|
10
|
+
}) : React.createElement(el, props));
|
|
11
|
+
};
|
|
12
|
+
export { useGetThemedIcon };
|
|
13
|
+
//# sourceMappingURL=useGetThemedIcon.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCurrentColor","useGetThemedIcon","props","color","el","isValidElement","cloneElement","createElement"],"sources":["../../src/useGetThemedIcon.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAElB,SAASC,eAAA,QAAuB;AAEzB,MAAMC,gBAAA,GAAoBC,KAAA,IAA8C;EAC7E,MAAMC,KAAA,GAAQH,eAAA,CAAgBE,KAAA,CAAMC,KAAK;EACzC,OAAQC,EAAA,IACDA,EAAA,KACDL,KAAA,CAAMM,cAAA,CAAeD,EAAE,IAClBL,KAAA,CAAMO,YAAA,CAAaF,EAAA,EAAI;IAC5B,GAAGF,KAAA;IACHC,KAAA;IAAA;IAEA,GAAGC,EAAA,CAAGF;EACR,CAAC,IAEIH,KAAA,CAAMQ,aAAA,CAAcH,EAAA,EAAIF,KAAK;AAExC","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useCurrentColor } from "./useCurrentColor.native.js";
|
|
3
|
+
var useGetThemedIcon = function (props) {
|
|
4
|
+
var color = useCurrentColor(props.color);
|
|
5
|
+
return function (el) {
|
|
6
|
+
return el && (/* @__PURE__ */React.isValidElement(el) ? /* @__PURE__ */React.cloneElement(el, {
|
|
7
|
+
...props,
|
|
8
|
+
color,
|
|
9
|
+
// @ts-expect-error
|
|
10
|
+
...el.props
|
|
11
|
+
}) : /* @__PURE__ */React.createElement(el, props));
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export { useGetThemedIcon };
|
|
15
|
+
//# sourceMappingURL=useGetThemedIcon.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCurrentColor","useGetThemedIcon","props","color","el","isValidElement","cloneElement","createElement"],"sources":["../../src/useGetThemedIcon.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAElB,SAASC,eAAA,QAAuB;AAEzB,IAAAC,gBAAM,YAAAA,CAAoBC,KAA8C;EAC7E,IAAAC,KAAM,GAAAH,eAAQ,CAAAE,KAAgB,CAAAC,KAAM;EACpC,OAAO,UACAC,EAAA;IAGD,OAAGA,EAAA,oBAAAL,KAAA,CAAAM,cAAA,CAAAD,EAAA,mBAAAL,KAAA,CAAAO,YAAA,CAAAF,EAAA;MACH,GAAAF,KAAA;MAAAC,KAAA;MAEA;MACD,GAEIC,EAAA,CAAAF;IAEX,oBAAAH,KAAA,CAAAQ,aAAA,CAAAH,EAAA,EAAAF,KAAA","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hanzogui/component-helpers",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"source": "src/index.ts",
|
|
5
|
+
"files": [
|
|
6
|
+
"src",
|
|
7
|
+
"types",
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"main": "dist/cjs",
|
|
13
|
+
"module": "dist/esm",
|
|
14
|
+
"types": "./types/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./package.json": "./package.json",
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./types/index.d.ts",
|
|
19
|
+
"react-native": "./dist/esm/index.native.js",
|
|
20
|
+
"browser": "./dist/esm/index.mjs",
|
|
21
|
+
"module": "./dist/esm/index.mjs",
|
|
22
|
+
"import": "./dist/esm/index.mjs",
|
|
23
|
+
"require": "./dist/cjs/index.cjs",
|
|
24
|
+
"default": "./dist/esm/index.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "hanzo-gui-build",
|
|
32
|
+
"watch": "hanzo-gui-build --watch",
|
|
33
|
+
"clean": "hanzo-gui-build clean",
|
|
34
|
+
"clean:build": "hanzo-gui-build clean:build"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@hanzogui/helpers": "workspace:*",
|
|
38
|
+
"@hanzogui/web": "workspace:*"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@hanzogui/build": "workspace:*",
|
|
42
|
+
"react": ">=19",
|
|
43
|
+
"react-native": "0.83.2",
|
|
44
|
+
"vitest": "4.0.4"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": ">=19",
|
|
48
|
+
"react-native": "*"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/getIcon.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export const getIcon = (
|
|
4
|
+
el: any,
|
|
5
|
+
props: {
|
|
6
|
+
size?: number
|
|
7
|
+
color?: string
|
|
8
|
+
style?: Record<string, any>
|
|
9
|
+
}
|
|
10
|
+
) => {
|
|
11
|
+
if (!el) return el
|
|
12
|
+
if (React.isValidElement(el)) {
|
|
13
|
+
return React.cloneElement(el, {
|
|
14
|
+
...props,
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
...el.props,
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
return React.createElement(el, props)
|
|
20
|
+
}
|
package/src/index.ts
ADDED
package/src/prevent.tsx
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const prevent = (e) => [e.preventDefault(), e.stopPropagation()]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ColorTokens, UnionableString, Variable } from '@hanzogui/web'
|
|
2
|
+
import { getVariable, useTheme } from '@hanzogui/web'
|
|
3
|
+
import type { TextStyle } from 'react-native'
|
|
4
|
+
|
|
5
|
+
export const useCurrentColor = (colorProp: ColorProp) => {
|
|
6
|
+
const theme = useTheme()
|
|
7
|
+
const out = colorProp
|
|
8
|
+
? getVariable(colorProp)
|
|
9
|
+
: theme[colorProp as any]?.get() || theme.color?.get()
|
|
10
|
+
return out
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ColorProp =
|
|
14
|
+
| UnionableString
|
|
15
|
+
| Variable
|
|
16
|
+
| ColorTokens
|
|
17
|
+
| TextStyle['color']
|
|
18
|
+
| undefined
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ColorProp } from './useCurrentColor'
|
|
3
|
+
import { useCurrentColor } from './useCurrentColor'
|
|
4
|
+
|
|
5
|
+
export const useGetThemedIcon = (props: { color: ColorProp; size: number }) => {
|
|
6
|
+
const color = useCurrentColor(props.color)
|
|
7
|
+
return (el: any) => {
|
|
8
|
+
if (!el) return el
|
|
9
|
+
if (React.isValidElement(el)) {
|
|
10
|
+
return React.cloneElement(el, {
|
|
11
|
+
...props,
|
|
12
|
+
color,
|
|
13
|
+
// @ts-expect-error
|
|
14
|
+
...el.props,
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
return React.createElement(el, props)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIcon.d.ts","sourceRoot":"","sources":["../src/getIcon.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,GAClB,IAAI,GAAG,EACP,OAAO;IACL,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B,QAWF,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,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prevent.d.ts","sourceRoot":"","sources":["../src/prevent.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,GAAI,MAAC,UAA8C,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ColorTokens, UnionableString, Variable } from '@hanzogui/web';
|
|
2
|
+
import type { TextStyle } from 'react-native';
|
|
3
|
+
export declare const useCurrentColor: (colorProp: ColorProp) => any;
|
|
4
|
+
export type ColorProp = UnionableString | Variable | ColorTokens | TextStyle['color'] | undefined;
|
|
5
|
+
//# sourceMappingURL=useCurrentColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentColor.d.ts","sourceRoot":"","sources":["../src/useCurrentColor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,eAAO,MAAM,eAAe,GAAI,WAAW,SAAS,QAMnD,CAAA;AAED,MAAM,MAAM,SAAS,GACjB,eAAe,GACf,QAAQ,GACR,WAAW,GACX,SAAS,CAAC,OAAO,CAAC,GAClB,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetThemedIcon.d.ts","sourceRoot":"","sources":["../src/useGetThemedIcon.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAGlD,eAAO,MAAM,gBAAgB,GAAI,OAAO;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,MAEhE,IAAI,GAAG,QAYhB,CAAA"}
|