@tamagui/helpers-tamagui 1.0.1-rc.8 → 1.0.1
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/dist/cjs/types.js +16 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/jsx/getSpace.js +11 -0
- package/dist/jsx/getSpace.js.map +7 -0
- package/dist/jsx/index.js +6 -0
- package/dist/jsx/index.js.map +7 -0
- package/dist/jsx/prevent.js +5 -0
- package/dist/jsx/prevent.js.map +7 -0
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/types.js.map +7 -0
- package/dist/jsx/useCurrentColor.js +17 -0
- package/dist/jsx/useCurrentColor.js.map +7 -0
- package/dist/jsx/useGetThemedIcon.js +25 -0
- package/dist/jsx/useGetThemedIcon.js.map +7 -0
- package/package.json +6 -6
|
@@ -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") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["import { SizableTextProps } from '@tamagui/text'\n\nexport type TextParentStyles = {\n color?: SizableTextProps['color']\n fontWeight?: SizableTextProps['fontWeight']\n fontSize?: SizableTextProps['fontSize']\n fontFamily?: SizableTextProps['fontFamily']\n letterSpacing?: SizableTextProps['letterSpacing']\n textAlign?: SizableTextProps['textAlign']\n // all the other text controls\n textProps?: Partial<SizableTextProps>\n noTextWrap?: boolean\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getTokens } from "@tamagui/core";
|
|
2
|
+
const getSpace = (token, sizeUpOrDownBy = 0) => {
|
|
3
|
+
const spaces = getTokens().space;
|
|
4
|
+
const spaceNames = Object.keys(spaces);
|
|
5
|
+
const key = spaceNames[Math.max(0, spaceNames.indexOf(String(token || "$4")) + sizeUpOrDownBy)];
|
|
6
|
+
return spaces[key] || spaces["$4"];
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
getSpace
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=getSpace.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/getSpace.tsx"],
|
|
4
|
+
"sourcesContent": ["import { SpaceTokens, getTokens } from '@tamagui/core'\n\nexport const getSpace = (token?: SpaceTokens | undefined, sizeUpOrDownBy = 0) => {\n const spaces = getTokens().space as any as SpaceTokens\n const spaceNames = Object.keys(spaces)\n const key = spaceNames[Math.max(0, spaceNames.indexOf(String(token || '$4')) + sizeUpOrDownBy)]\n return (spaces[key] || spaces['$4']) as SpaceTokens\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAEO,MAAM,WAAW,CAAC,OAAiC,iBAAiB,MAAM;AAC/E,QAAM,SAAS,UAAU,EAAE;AAC3B,QAAM,aAAa,OAAO,KAAK,MAAM;AACrC,QAAM,MAAM,WAAW,KAAK,IAAI,GAAG,WAAW,QAAQ,OAAO,SAAS,IAAI,CAAC,IAAI,cAAc;AAC7F,SAAQ,OAAO,QAAQ,OAAO;AAChC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from '@tamagui/helpers'\nexport * from './prevent'\nexport * from './getSpace'\nexport * from './useCurrentColor'\nexport * from './useGetThemedIcon'\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AACA;AACA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useTheme } from "@tamagui/core";
|
|
2
|
+
const useCurrentColor = (colorProp) => {
|
|
3
|
+
const theme = useTheme();
|
|
4
|
+
let color;
|
|
5
|
+
if (theme && colorProp && colorProp in theme) {
|
|
6
|
+
color = theme[colorProp];
|
|
7
|
+
} else if (colorProp) {
|
|
8
|
+
color = colorProp;
|
|
9
|
+
} else {
|
|
10
|
+
color = theme == null ? void 0 : theme.color;
|
|
11
|
+
}
|
|
12
|
+
return (color == null ? void 0 : color.toString()) || "";
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
useCurrentColor
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useCurrentColor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useCurrentColor.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ColorTokens, ThemeValueFallback, useTheme } from '@tamagui/core'\nimport type { TextStyle } from 'react-native'\n\nexport const useCurrentColor = (colorProp: ColorProp) => {\n const theme = useTheme()\n // get color from prop or theme\n let color: any\n // @ts-expect-error\n if (theme && colorProp && colorProp in theme) {\n // @ts-expect-error\n color = theme[colorProp]\n } else if (colorProp) {\n color = colorProp\n } else {\n color = theme?.color\n }\n return color?.toString() || ('' as string)\n}\n\nexport type ColorProp = ThemeValueFallback | ColorTokens | TextStyle['color'] | undefined\n"],
|
|
5
|
+
"mappings": "AAAA;AAGO,MAAM,kBAAkB,CAAC,cAAyB;AACvD,QAAM,QAAQ,SAAS;AAEvB,MAAI;AAEJ,MAAI,SAAS,aAAa,aAAa,OAAO;AAE5C,YAAQ,MAAM;AAAA,EAChB,WAAW,WAAW;AACpB,YAAQ;AAAA,EACV,OAAO;AACL,YAAQ,+BAAO;AAAA,EACjB;AACA,SAAO,gCAAO,eAAe;AAC/B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { isValidElement } from "react";
|
|
2
|
+
import { useCurrentColor } from "./useCurrentColor";
|
|
3
|
+
const useGetThemedIcon = (props) => {
|
|
4
|
+
const color = useCurrentColor(props.color);
|
|
5
|
+
return (el) => {
|
|
6
|
+
if (el) {
|
|
7
|
+
if (isValidElement(el)) {
|
|
8
|
+
return React.cloneElement(el, {
|
|
9
|
+
...props,
|
|
10
|
+
color,
|
|
11
|
+
...el.props
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return React.createElement(el, {
|
|
15
|
+
...props,
|
|
16
|
+
color
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return el;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
useGetThemedIcon
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useGetThemedIcon.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/useGetThemedIcon.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { isValidElement } from 'react'\n\nimport { ColorProp, useCurrentColor } from './useCurrentColor'\n\nexport const useGetThemedIcon = (props: { color: ColorProp; size: number }) => {\n const color = useCurrentColor(props.color)\n return (el: any) => {\n if (el) {\n if (isValidElement(el)) {\n return React.cloneElement(el as any, {\n ...props,\n color,\n // @ts-ignore\n ...el.props,\n })\n }\n return React.createElement(el, {\n ...props,\n color,\n })\n }\n return el\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAEA;AAEO,MAAM,mBAAmB,CAAC,UAA8C;AAC7E,QAAM,QAAQ,gBAAgB,MAAM,KAAK;AACzC,SAAO,CAAC,OAAY;AAClB,QAAI,IAAI;AACN,UAAI,eAAe,EAAE,GAAG;AACtB,eAAO,MAAM,aAAa,IAAW;AAAA,UACnC,GAAG;AAAA,UACH;AAAA,UAEA,GAAG,GAAG;AAAA,QACR,CAAC;AAAA,MACH;AACA,aAAO,MAAM,cAAc,IAAI;AAAA,QAC7B,GAAG;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/helpers-tamagui",
|
|
3
|
-
"version": "1.0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
"clean:build": "tamagui-build clean:build"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@tamagui/core": "^1.0.1
|
|
23
|
-
"@tamagui/helpers": "^1.0.1
|
|
22
|
+
"@tamagui/core": "^1.0.1",
|
|
23
|
+
"@tamagui/helpers": "^1.0.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@tamagui/build": "^1.0.1
|
|
26
|
+
"@tamagui/build": "^1.0.1",
|
|
27
27
|
"react": "^18.2.0",
|
|
28
28
|
"react-native": "*",
|
|
29
|
-
"vitest": "^0.
|
|
29
|
+
"vitest": "^0.26.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"react": "
|
|
32
|
+
"react": "*",
|
|
33
33
|
"react-native": "*"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|