@tamagui/core 1.1.2 → 1.1.4
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/createComponent.js +1 -1
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +3 -1
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/helpers/useShallowSetState.js +15 -14
- package/dist/cjs/helpers/useShallowSetState.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/createComponent.js +1 -1
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +3 -1
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/helpers/useShallowSetState.js +15 -14
- package/dist/esm/helpers/useShallowSetState.js.map +2 -2
- package/package.json +11 -11
- package/src/createComponent.tsx +1 -1
- package/src/createTamagui.ts +3 -1
- package/src/helpers/useShallowSetState.tsx +18 -16
- package/src/types.tsx +1 -1
- package/types/helpers/useShallowSetState.d.ts +2 -1
- package/types/types.d.ts +1 -1
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import { startTransition, useCallback } from "react";
|
|
2
|
-
function useShallowSetState(setter,
|
|
2
|
+
function useShallowSetState(setter, debug, debugName) {
|
|
3
3
|
return useCallback(
|
|
4
4
|
(next) => {
|
|
5
|
-
const
|
|
5
|
+
const shouldTransition = Object.keys(next).every(
|
|
6
|
+
(k) => transitionKeys.has(k)
|
|
7
|
+
);
|
|
8
|
+
const run = shouldTransition ? startTransition : (_) => _();
|
|
9
|
+
run(() => {
|
|
6
10
|
setter((prev) => {
|
|
7
11
|
for (const key in next) {
|
|
8
12
|
if (prev[key] !== next[key]) {
|
|
9
|
-
if (process.env.NODE_ENV === "development") {
|
|
10
|
-
|
|
11
|
-
console.log(` \u25B2 setState ${debugName}`, next);
|
|
12
|
-
}
|
|
13
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
14
|
+
console.log(` \u25B2 setState ${debugName}`, next);
|
|
13
15
|
}
|
|
14
16
|
return { ...prev, ...next };
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
return prev;
|
|
18
20
|
});
|
|
19
|
-
};
|
|
20
|
-
if (transition) {
|
|
21
|
-
startTransition(() => {
|
|
22
|
-
run();
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
run();
|
|
26
|
-
}
|
|
21
|
+
});
|
|
27
22
|
},
|
|
28
23
|
[setter]
|
|
29
24
|
);
|
|
30
25
|
}
|
|
26
|
+
const transitionKeys = /* @__PURE__ */ new Set([
|
|
27
|
+
"press",
|
|
28
|
+
"pressIn",
|
|
29
|
+
"focus",
|
|
30
|
+
"unmounted"
|
|
31
|
+
]);
|
|
31
32
|
export {
|
|
32
33
|
useShallowSetState
|
|
33
34
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/useShallowSetState.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { startTransition, useCallback } from 'react'\n\nimport { DebugProp } from '../types'\n\nexport function useShallowSetState<State extends
|
|
5
|
-
"mappings": "AAAA,SAAgB,iBAAiB,mBAAmB;
|
|
4
|
+
"sourcesContent": ["import React, { startTransition, useCallback } from 'react'\n\nimport { DebugProp } from '../types'\nimport { TamaguiComponentState } from '..'\n\nexport function useShallowSetState<State extends TamaguiComponentState>(\n setter: React.Dispatch<React.SetStateAction<State>>,\n debug?: DebugProp,\n debugName?: string\n) {\n return useCallback(\n (next: Partial<State>) => {\n const shouldTransition = Object.keys(next).every((k) =>\n transitionKeys.has(k as any)\n )\n const run = shouldTransition ? startTransition : (_) => _()\n run(() => {\n setter((prev) => {\n for (const key in next) {\n if (prev[key] !== next[key]) {\n if (process.env.NODE_ENV === 'development' && debug === 'verbose') {\n // eslint-disable-next-line no-console\n console.log(` \u25B2 setState ${debugName}`, next)\n }\n return { ...prev, ...next }\n }\n }\n return prev\n })\n })\n },\n [setter]\n )\n}\n\nconst transitionKeys = new Set<keyof TamaguiComponentState>([\n 'press',\n 'pressIn',\n 'focus',\n 'unmounted',\n])\n"],
|
|
5
|
+
"mappings": "AAAA,SAAgB,iBAAiB,mBAAmB;AAK7C,SAAS,mBACd,QACA,OACA,WACA;AACA,SAAO;AAAA,IACL,CAAC,SAAyB;AACxB,YAAM,mBAAmB,OAAO,KAAK,IAAI,EAAE;AAAA,QAAM,CAAC,MAChD,eAAe,IAAI,CAAQ;AAAA,MAC7B;AACA,YAAM,MAAM,mBAAmB,kBAAkB,CAAC,MAAM,EAAE;AAC1D,UAAI,MAAM;AACR,eAAO,CAAC,SAAS;AACf,qBAAW,OAAO,MAAM;AACtB,gBAAI,KAAK,SAAS,KAAK,MAAM;AAC3B,kBAAI,QAAQ,IAAI,aAAa,iBAAiB,UAAU,WAAW;AAEjE,wBAAQ,IAAI,oBAAe,aAAa,IAAI;AAAA,cAC9C;AACA,qBAAO,EAAE,GAAG,MAAM,GAAG,KAAK;AAAA,YAC5B;AAAA,UACF;AACA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACF;AAEA,MAAM,iBAAiB,oBAAI,IAAiC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -30,22 +30,22 @@
|
|
|
30
30
|
"reset.css"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@tamagui/compose-refs": "^1.1.
|
|
34
|
-
"@tamagui/constants": "^1.1.
|
|
35
|
-
"@tamagui/helpers": "^1.1.
|
|
36
|
-
"@tamagui/normalize-css-color": "^1.1.
|
|
37
|
-
"@tamagui/react-native-use-pressable": "^1.1.
|
|
38
|
-
"@tamagui/react-native-use-responder-events": "^1.1.
|
|
39
|
-
"@tamagui/use-did-finish-ssr": "^1.1.
|
|
40
|
-
"@tamagui/use-event": "^1.1.
|
|
41
|
-
"@tamagui/use-force-update": "^1.1.
|
|
33
|
+
"@tamagui/compose-refs": "^1.1.4",
|
|
34
|
+
"@tamagui/constants": "^1.1.4",
|
|
35
|
+
"@tamagui/helpers": "^1.1.4",
|
|
36
|
+
"@tamagui/normalize-css-color": "^1.1.4",
|
|
37
|
+
"@tamagui/react-native-use-pressable": "^1.1.4",
|
|
38
|
+
"@tamagui/react-native-use-responder-events": "^1.1.4",
|
|
39
|
+
"@tamagui/use-did-finish-ssr": "^1.1.4",
|
|
40
|
+
"@tamagui/use-event": "^1.1.4",
|
|
41
|
+
"@tamagui/use-force-update": "^1.1.4"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": "*",
|
|
45
45
|
"react-dom": "*"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@tamagui/build": "^1.1.
|
|
48
|
+
"@tamagui/build": "^1.1.4",
|
|
49
49
|
"@testing-library/react": "^13.4.0",
|
|
50
50
|
"csstype": "^3.0.10",
|
|
51
51
|
"react": "^18.2.0",
|
package/src/createComponent.tsx
CHANGED
|
@@ -200,7 +200,7 @@ export function createComponent<
|
|
|
200
200
|
? { ...states[0], [propsIn.forceStyle]: true }
|
|
201
201
|
: states[0]
|
|
202
202
|
const setState = states[1]
|
|
203
|
-
const setStateShallow = useShallowSetState(setState,
|
|
203
|
+
const setStateShallow = useShallowSetState(setState, debugProp, componentName)
|
|
204
204
|
|
|
205
205
|
// conditional but if ever true stays true
|
|
206
206
|
// [animated, inversed]
|
package/src/createTamagui.ts
CHANGED
|
@@ -215,7 +215,9 @@ export function createTamagui<Conf extends CreateTamaguiProps>(
|
|
|
215
215
|
tokensParsed,
|
|
216
216
|
parsed: true,
|
|
217
217
|
getCSS: (separator = '\n') => {
|
|
218
|
-
return
|
|
218
|
+
return `
|
|
219
|
+
._ovs-contain {overscroll-behavior:contain;}
|
|
220
|
+
.t_unmounted .t_will-mount {opacity:0;visibility:hidden;}
|
|
219
221
|
.is_Text .is_Text {display:inline-flex;}
|
|
220
222
|
._dsp_contents {display:contents;}
|
|
221
223
|
${themeConfig.cssRuleSets.join(separator)}
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
import React, { startTransition, useCallback } from 'react'
|
|
2
2
|
|
|
3
3
|
import { DebugProp } from '../types'
|
|
4
|
+
import { TamaguiComponentState } from '..'
|
|
4
5
|
|
|
5
|
-
export function useShallowSetState<State extends
|
|
6
|
+
export function useShallowSetState<State extends TamaguiComponentState>(
|
|
6
7
|
setter: React.Dispatch<React.SetStateAction<State>>,
|
|
7
|
-
transition?: boolean,
|
|
8
8
|
debug?: DebugProp,
|
|
9
9
|
debugName?: string
|
|
10
10
|
) {
|
|
11
11
|
return useCallback(
|
|
12
12
|
(next: Partial<State>) => {
|
|
13
|
-
const
|
|
13
|
+
const shouldTransition = Object.keys(next).every((k) =>
|
|
14
|
+
transitionKeys.has(k as any)
|
|
15
|
+
)
|
|
16
|
+
const run = shouldTransition ? startTransition : (_) => _()
|
|
17
|
+
run(() => {
|
|
14
18
|
setter((prev) => {
|
|
15
19
|
for (const key in next) {
|
|
16
20
|
if (prev[key] !== next[key]) {
|
|
17
|
-
if (process.env.NODE_ENV === 'development') {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
console.log(` ▲ setState ${debugName}`, next)
|
|
21
|
-
}
|
|
21
|
+
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.log(` ▲ setState ${debugName}`, next)
|
|
22
24
|
}
|
|
23
25
|
return { ...prev, ...next }
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
return prev
|
|
27
29
|
})
|
|
28
|
-
}
|
|
29
|
-
if (transition) {
|
|
30
|
-
startTransition(() => {
|
|
31
|
-
run()
|
|
32
|
-
})
|
|
33
|
-
} else {
|
|
34
|
-
run()
|
|
35
|
-
}
|
|
30
|
+
})
|
|
36
31
|
},
|
|
37
32
|
[setter]
|
|
38
33
|
)
|
|
39
34
|
}
|
|
35
|
+
|
|
36
|
+
const transitionKeys = new Set<keyof TamaguiComponentState>([
|
|
37
|
+
'press',
|
|
38
|
+
'pressIn',
|
|
39
|
+
'focus',
|
|
40
|
+
'unmounted',
|
|
41
|
+
])
|
package/src/types.tsx
CHANGED
|
@@ -103,7 +103,7 @@ type Tokenify<A extends GenericTokens> = {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
type TokenifyRecord<A extends CreateTokens[keyof CreateTokens]> = {
|
|
106
|
-
[Key in keyof A]: Variable<A[Key]>
|
|
106
|
+
[Key in keyof A]: A[Key] extends Variable ? A[Key] : Variable<A[Key]>
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
export type TamaguiBaseTheme = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DebugProp } from '../types';
|
|
3
|
-
|
|
3
|
+
import { TamaguiComponentState } from '..';
|
|
4
|
+
export declare function useShallowSetState<State extends TamaguiComponentState>(setter: React.Dispatch<React.SetStateAction<State>>, debug?: DebugProp, debugName?: string): (next: Partial<State>) => void;
|
|
4
5
|
//# sourceMappingURL=useShallowSetState.d.ts.map
|
package/types/types.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ type Tokenify<A extends GenericTokens> = {
|
|
|
74
74
|
zIndex: TokenifyRecord<A['zIndex']>;
|
|
75
75
|
};
|
|
76
76
|
type TokenifyRecord<A extends CreateTokens[keyof CreateTokens]> = {
|
|
77
|
-
[Key in keyof A]: Variable<A[Key]>;
|
|
77
|
+
[Key in keyof A]: A[Key] extends Variable ? A[Key] : Variable<A[Key]>;
|
|
78
78
|
};
|
|
79
79
|
export type TamaguiBaseTheme = {
|
|
80
80
|
background: VariableColorVal;
|