@tamagui/helpers-tamagui 1.2.9 → 1.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,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 || "$true")) + sizeUpOrDownBy)];
6
+ return spaces[key] || spaces["$true"];
7
+ };
8
+ export {
9
+ getSpace
10
+ };
11
+ //# sourceMappingURL=getSpace.mjs.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\n const spaceNames = Object.keys(spaces)\n const key =\n spaceNames[Math.max(0, spaceNames.indexOf(String(token || '$true')) + sizeUpOrDownBy)]\n return (spaces[key] || spaces['$true']) as SpaceTokens\n}\n"],
5
+ "mappings": "AAAA,SAAsB,iBAAiB;AAEhC,MAAM,WAAW,CAAC,OAAiC,iBAAiB,MAAM;AAC/E,QAAM,SAAS,UAAU,EAAE;AAC3B,QAAM,aAAa,OAAO,KAAK,MAAM;AACrC,QAAM,MACJ,WAAW,KAAK,IAAI,GAAG,WAAW,QAAQ,OAAO,SAAS,OAAO,CAAC,IAAI,cAAc,CAAC;AACvF,SAAQ,OAAO,GAAG,KAAK,OAAO,OAAO;AACvC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ export * from "@tamagui/helpers";
2
+ export * from "./prevent";
3
+ export * from "./getSpace";
4
+ export * from "./useCurrentColor";
5
+ export * from "./useGetThemedIcon";
6
+ //# sourceMappingURL=index.mjs.map
@@ -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,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ const prevent = (e) => [e.preventDefault(), e.stopPropagation()];
2
+ export {
3
+ prevent
4
+ };
5
+ //# sourceMappingURL=prevent.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/prevent.tsx"],
4
+ "sourcesContent": ["export const prevent = (e) => [e.preventDefault(), e.stopPropagation()]\n"],
5
+ "mappings": "AAAO,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,EAAE,gBAAgB,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ import {
2
+ useTheme,
3
+ variableToString
4
+ } from "@tamagui/core";
5
+ const useCurrentColor = (colorProp) => {
6
+ const theme = useTheme();
7
+ return variableToString(theme[colorProp] || colorProp || theme.color);
8
+ };
9
+ export {
10
+ useCurrentColor
11
+ };
12
+ //# sourceMappingURL=useCurrentColor.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useCurrentColor.tsx"],
4
+ "sourcesContent": ["import {\n ColorTokens,\n UnionableString,\n Variable,\n useTheme,\n variableToString,\n} from '@tamagui/core'\nimport type { TextStyle } from 'react-native'\n\nexport const useCurrentColor = (colorProp: ColorProp) => {\n const theme = useTheme()\n return variableToString(theme[colorProp as any] || colorProp || theme.color)\n}\n\nexport type ColorProp =\n | UnionableString\n | Variable\n | ColorTokens\n | TextStyle['color']\n | undefined\n"],
5
+ "mappings": "AAAA;AAAA,EAIE;AAAA,EACA;AAAA,OACK;AAGA,MAAM,kBAAkB,CAAC,cAAyB;AACvD,QAAM,QAAQ,SAAS;AACvB,SAAO,iBAAiB,MAAM,SAAgB,KAAK,aAAa,MAAM,KAAK;AAC7E;",
6
+ "names": []
7
+ }
@@ -0,0 +1,21 @@
1
+ import { cloneElement, createElement, 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
+ return el;
8
+ if (isValidElement(el)) {
9
+ return cloneElement(el, {
10
+ ...props,
11
+ // @ts-expect-error
12
+ ...el.props
13
+ });
14
+ }
15
+ return createElement(el, props);
16
+ };
17
+ };
18
+ export {
19
+ useGetThemedIcon
20
+ };
21
+ //# sourceMappingURL=useGetThemedIcon.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useGetThemedIcon.tsx"],
4
+ "sourcesContent": ["import { cloneElement, createElement, 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) return el\n if (isValidElement(el)) {\n return cloneElement(el, {\n ...props,\n // @ts-expect-error\n ...el.props,\n })\n }\n return createElement(el, props)\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,cAAc,eAAe,sBAAsB;AAE5D,SAAoB,uBAAuB;AAEpC,MAAM,mBAAmB,CAAC,UAA8C;AAC7E,QAAM,QAAQ,gBAAgB,MAAM,KAAK;AACzC,SAAO,CAAC,OAAY;AAClB,QAAI,CAAC;AAAI,aAAO;AAChB,QAAI,eAAe,EAAE,GAAG;AACtB,aAAO,aAAa,IAAI;AAAA,QACtB,GAAG;AAAA;AAAA,QAEH,GAAG,GAAG;AAAA,MACR,CAAC;AAAA,IACH;AACA,WAAO,cAAc,IAAI,KAAK;AAAA,EAChC;AACF;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/helpers-tamagui",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -19,11 +19,11 @@
19
19
  "clean:build": "tamagui-build clean:build"
20
20
  },
21
21
  "dependencies": {
22
- "@tamagui/core": "^1.2.9",
23
- "@tamagui/helpers": "^1.2.9"
22
+ "@tamagui/core": "^1.2.11",
23
+ "@tamagui/helpers": "^1.2.11"
24
24
  },
25
25
  "devDependencies": {
26
- "@tamagui/build": "^1.2.9",
26
+ "@tamagui/build": "^1.2.11",
27
27
  "react": "^18.2.0",
28
28
  "react-native": "*",
29
29
  "vitest": "^0.26.3"