@tamagui/core 1.0.1-beta.185 → 1.0.1-beta.187
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/addTheme.js +2 -2
- package/dist/cjs/addTheme.js.map +2 -2
- package/dist/cjs/constants/constants.js +2 -2
- package/dist/cjs/constants/constants.js.map +2 -2
- package/dist/cjs/createComponent.js +25 -25
- package/dist/cjs/createComponent.js.map +3 -3
- package/dist/cjs/createTamagui.js +3 -3
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createVariable.js +3 -3
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/helpers/calc.js +2 -2
- package/dist/cjs/helpers/calc.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +5 -5
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/expandStyle.js +2 -2
- package/dist/cjs/helpers/expandStyle.js.map +2 -2
- package/dist/cjs/helpers/expandStyles.js +2 -2
- package/dist/cjs/helpers/expandStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +11 -11
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/hooks/useDidFinishSSR.js +60 -0
- package/dist/cjs/hooks/useDidFinishSSR.js.map +7 -0
- package/dist/cjs/hooks/useIsMounted.js +2 -2
- package/dist/cjs/hooks/useIsMounted.js.map +2 -2
- package/dist/cjs/hooks/useIsSSR.js +3 -3
- package/dist/cjs/hooks/useIsSSR.js.map +2 -2
- package/dist/cjs/hooks/useIsTouchDevice.js +4 -4
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +18 -5
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/useSafeRef.js +2 -2
- package/dist/cjs/hooks/useSafeRef.js.map +2 -2
- package/dist/cjs/hooks/useServerHooks.js +3 -3
- package/dist/cjs/hooks/useServerHooks.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +7 -7
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/views/Slot.js +2 -2
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/cjs/views/TamaguiProvider.js +6 -4
- package/dist/cjs/views/TamaguiProvider.js.map +2 -2
- package/dist/cjs/views/Text.js +5 -5
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/Theme.js +2 -2
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +2 -2
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +2 -2
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/addTheme.js +1 -1
- package/dist/esm/addTheme.js.map +2 -2
- package/dist/esm/constants/constants.js +1 -1
- package/dist/esm/constants/constants.js.map +1 -1
- package/dist/esm/createComponent.js +1 -1
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +1 -1
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createVariable.js +1 -1
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/helpers/calc.js +1 -1
- package/dist/esm/helpers/calc.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +1 -1
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/expandStyle.js +1 -1
- package/dist/esm/helpers/expandStyle.js.map +1 -1
- package/dist/esm/helpers/expandStyles.js +1 -1
- package/dist/esm/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +1 -1
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/hooks/useDidFinishSSR.js +35 -0
- package/dist/esm/hooks/useDidFinishSSR.js.map +7 -0
- package/dist/esm/hooks/useIsMounted.js +1 -1
- package/dist/esm/hooks/useIsMounted.js.map +2 -2
- package/dist/esm/hooks/useIsSSR.js +1 -1
- package/dist/esm/hooks/useIsSSR.js.map +2 -2
- package/dist/esm/hooks/useIsTouchDevice.js +1 -1
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +17 -4
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useSafeRef.js +1 -1
- package/dist/esm/hooks/useSafeRef.js.map +2 -2
- package/dist/esm/hooks/useServerHooks.js +1 -1
- package/dist/esm/hooks/useServerHooks.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +1 -1
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/views/Slot.js +1 -1
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/esm/views/TamaguiProvider.js +3 -1
- package/dist/esm/views/TamaguiProvider.js.map +2 -2
- package/dist/esm/views/Text.js +1 -1
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Theme.js +1 -1
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +1 -1
- package/dist/esm/views/ThemeInverse.js.map +2 -2
- package/dist/esm/views/ThemeReset.js +1 -1
- package/dist/esm/views/ThemeReset.js.map +2 -2
- package/package.json +11 -10
- package/src/addTheme.ts +2 -1
- package/src/constants/constants.ts +1 -1
- package/src/createComponent.tsx +1 -1
- package/src/createTamagui.ts +2 -1
- package/src/createVariable.ts +1 -1
- package/src/helpers/calc.ts +2 -1
- package/src/helpers/createPropMapper.ts +2 -1
- package/src/helpers/expandStyle.ts +1 -1
- package/src/helpers/expandStyles.ts +2 -1
- package/src/helpers/getSplitStyles.tsx +1 -1
- package/src/hooks/useIsMounted.ts +1 -2
- package/src/hooks/useIsSSR.tsx +1 -1
- package/src/hooks/useIsTouchDevice.tsx +1 -2
- package/src/hooks/useMedia.tsx +24 -6
- package/src/hooks/useSafeRef.ts +1 -2
- package/src/hooks/useServerHooks.tsx +1 -2
- package/src/hooks/useTheme.tsx +1 -1
- package/src/index.ts +2 -1
- package/src/views/Slot.tsx +1 -2
- package/src/views/TamaguiProvider.tsx +3 -1
- package/src/views/Text.tsx +1 -1
- package/src/views/Theme.tsx +1 -1
- package/src/views/ThemeInverse.tsx +1 -1
- package/src/views/ThemeReset.tsx +1 -1
- package/types/constants/platform.d.ts +2 -2
- package/types/hooks/useDidFinishSSR.d.ts +3 -0
- package/types/hooks/useMedia.d.ts +1 -1
- package/types/index.d.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useIsSSR.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AAEzB,
|
|
4
|
+
"sourcesContent": ["import { isServer, isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useState } from 'react'\n\nimport { startTransition } from '../helpers/startTransition'\n\n// because any change before first useEffect causes hydration / mismatch issues\n\nexport const useIsSSR = (props?: { immediate?: boolean }) => {\n const [val, setVal] = useState(true)\n\n if (isWeb && !isServer) {\n useIsomorphicLayoutEffect(() => {\n // could also have a global tamagui `config.immediateSSRTransition`\n if (props?.immediate) {\n setVal(false)\n } else {\n startTransition(() => {\n setVal(false)\n })\n }\n }, [])\n }\n\n return val\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2D;AAC3D,mBAAyB;AAEzB,6BAAgC;AAIzB,MAAM,WAAW,CAAC,UAAoC;AAC3D,QAAM,CAAC,KAAK,MAAM,QAAI,uBAAS,IAAI;AAEnC,MAAI,0BAAS,CAAC,2BAAU;AACtB,oDAA0B,MAAM;AAE9B,UAAI,+BAAO,WAAW;AACpB,eAAO,KAAK;AAAA,MACd,OAAO;AACL,oDAAgB,MAAM;AACpB,iBAAO,KAAK;AAAA,QACd,CAAC;AAAA,MACH;AAAA,IACF,GAAG,CAAC,CAAC;AAAA,EACP;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,13 +21,13 @@ __export(useIsTouchDevice_exports, {
|
|
|
21
21
|
useIsTouchDevice: () => useIsTouchDevice
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useIsTouchDevice_exports);
|
|
24
|
+
var import_constants = require("@tamagui/constants");
|
|
24
25
|
var import_react = require("react");
|
|
25
|
-
var import_platform = require("../constants/platform");
|
|
26
26
|
const useIsTouchDevice = () => {
|
|
27
27
|
const [touchOnly, setTouchOnly] = (0, import_react.useState)(false);
|
|
28
|
-
if (
|
|
29
|
-
(0,
|
|
30
|
-
if (
|
|
28
|
+
if (import_constants.isWeb && !import_constants.isServer) {
|
|
29
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
30
|
+
if (import_constants.isTouchable) {
|
|
31
31
|
setTouchOnly(true);
|
|
32
32
|
}
|
|
33
33
|
}, []);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useIsTouchDevice.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { isServer, isTouchable, isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useState } from 'react'\n\n// ssr friendly\n\nexport const useIsTouchDevice = () => {\n const [touchOnly, setTouchOnly] = useState(false)\n\n if (isWeb && !isServer) {\n // only ever false on web SSR (env), so run effect conditionally\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useIsomorphicLayoutEffect(() => {\n if (isTouchable) {\n setTouchOnly(true)\n }\n }, [])\n }\n\n return touchOnly\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwE;AACxE,mBAAyB;AAIlB,MAAM,mBAAmB,MAAM;AACpC,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAEhD,MAAI,0BAAS,CAAC,2BAAU;AAGtB,oDAA0B,MAAM;AAC9B,UAAI,8BAAa;AACf,qBAAa,IAAI;AAAA,MACnB;AAAA,IACF,GAAG,CAAC,CAAC;AAAA,EACP;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -31,10 +31,11 @@ __export(useMedia_exports, {
|
|
|
31
31
|
useMediaQueryListeners: () => useMediaQueryListeners
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(useMedia_exports);
|
|
34
|
+
var import_constants = require("@tamagui/constants");
|
|
34
35
|
var import_react = require("react");
|
|
35
|
-
var import_platform = require("../constants/platform");
|
|
36
36
|
var import_matchMedia = require("../helpers/matchMedia");
|
|
37
37
|
var import_useSafeRef = require("./useSafeRef");
|
|
38
|
+
var import__ = require("..");
|
|
38
39
|
const mediaState = process.env.NODE_ENV === "development" ? new Proxy(
|
|
39
40
|
{},
|
|
40
41
|
{
|
|
@@ -63,6 +64,15 @@ const mediaQueryConfig = {};
|
|
|
63
64
|
const getMedia = () => {
|
|
64
65
|
return mediaState;
|
|
65
66
|
};
|
|
67
|
+
let currentMediaState;
|
|
68
|
+
let initialMediaState;
|
|
69
|
+
let hasFinishedInitialRender = false;
|
|
70
|
+
const getCurrentMediaState = () => {
|
|
71
|
+
if ((0, import__.getConfig)().disableSSR || hasFinishedInitialRender) {
|
|
72
|
+
return currentMediaState || {};
|
|
73
|
+
}
|
|
74
|
+
return initialMediaState || {};
|
|
75
|
+
};
|
|
66
76
|
const dispose = /* @__PURE__ */ new Set();
|
|
67
77
|
const configureMedia = (config) => {
|
|
68
78
|
const { media, mediaQueryDefaultActive } = config;
|
|
@@ -73,12 +83,11 @@ const configureMedia = (config) => {
|
|
|
73
83
|
}
|
|
74
84
|
Object.assign(mediaQueryConfig, media);
|
|
75
85
|
currentMediaState = { ...mediaState };
|
|
86
|
+
initialMediaState = currentMediaState;
|
|
76
87
|
if (config.disableSSR) {
|
|
77
88
|
setupMediaListeners();
|
|
78
89
|
}
|
|
79
90
|
};
|
|
80
|
-
let currentMediaState;
|
|
81
|
-
const getCurrentMediaState = () => currentMediaState;
|
|
82
91
|
function unlisten() {
|
|
83
92
|
dispose.forEach((cb) => cb());
|
|
84
93
|
dispose.clear();
|
|
@@ -117,17 +126,21 @@ function setupMediaListeners() {
|
|
|
117
126
|
}
|
|
118
127
|
});
|
|
119
128
|
}
|
|
129
|
+
const onIdle = typeof requestIdleCallback === "undefined" ? (cb) => setTimeout(cb, 100) : requestIdleCallback;
|
|
120
130
|
function useMediaQueryListeners(config) {
|
|
121
131
|
if (config.disableSSR) {
|
|
122
132
|
return;
|
|
123
133
|
}
|
|
124
134
|
(0, import_react.useEffect)(() => {
|
|
125
135
|
setupMediaListeners();
|
|
136
|
+
onIdle(() => {
|
|
137
|
+
hasFinishedInitialRender = true;
|
|
138
|
+
});
|
|
126
139
|
return unlisten;
|
|
127
140
|
}, []);
|
|
128
141
|
}
|
|
129
142
|
function useMedia() {
|
|
130
|
-
const [state, setState] = (0, import_react.useState)(
|
|
143
|
+
const [state, setState] = (0, import_react.useState)(getCurrentMediaState());
|
|
131
144
|
const keys = (0, import_useSafeRef.useSafeRef)({});
|
|
132
145
|
function updateState() {
|
|
133
146
|
setState((prev) => {
|
|
@@ -139,7 +152,7 @@ function useMedia() {
|
|
|
139
152
|
return prev;
|
|
140
153
|
});
|
|
141
154
|
}
|
|
142
|
-
(0,
|
|
155
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
143
156
|
const disposes = Object.keys(keys.current).map(
|
|
144
157
|
(key) => addMediaQueryListener(key, updateState)
|
|
145
158
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useMedia.tsx"],
|
|
4
|
-
"sourcesContent": ["import { startTransition, useEffect, useMemo, useState } from 'react'\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8D;AAE9D,
|
|
4
|
+
"sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { startTransition, useEffect, useMemo, useState } from 'react'\n\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n MediaQueries,\n MediaQueryKey,\n MediaQueryObject,\n MediaQueryState,\n TamaguiInternalConfig,\n} from '../types'\nimport { useSafeRef } from './useSafeRef'\nimport { getConfig } from '..'\n\nexport const mediaState: MediaQueryState =\n // development time safeguard\n process.env.NODE_ENV === 'development'\n ? new Proxy(\n {},\n {\n get(target, key) {\n if (typeof key === 'string' && key[0] === '$') {\n throw new Error(`Access of mediaState should never include $`)\n }\n return Reflect.get(target, key)\n },\n }\n )\n : ({} as any)\n\ntype MediaListener = (next: boolean) => void\n\nconst mediaQueryListeners: { [key: string]: Set<MediaListener> } = {}\n\nexport function addMediaQueryListener(key: MediaQueryKey, cb: MediaListener) {\n if (process.env.NODE_ENV === 'development' && key[0] === '$') {\n // eslint-disable-next-line no-console\n console.warn(`Warning, listening to media queries shouldn't use the \"$\" prefix`)\n }\n mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()\n mediaQueryListeners[key].add(cb)\n return () => removeMediaQueryListener(key, cb)\n}\n\nexport function removeMediaQueryListener(key: MediaQueryKey, cb: MediaListener) {\n mediaQueryListeners[key]?.delete(cb)\n}\n\nexport const mediaQueryConfig: MediaQueries = {}\n\nexport const getMedia = () => {\n return mediaState\n}\n\n// for SSR capture it at time of startup\nlet currentMediaState: MediaQueryState | null\nlet initialMediaState: MediaQueryState | null\n// fairly concurrent mode sketchy but such an edge case ok for now\nlet hasFinishedInitialRender = false\nexport const getCurrentMediaState = () => {\n if (getConfig().disableSSR || hasFinishedInitialRender) {\n return currentMediaState || {}\n }\n return initialMediaState || {}\n}\n\nconst dispose = new Set<Function>()\n\nexport const configureMedia = (config: TamaguiInternalConfig) => {\n const { media, mediaQueryDefaultActive } = config\n if (!media) return\n for (const key in media) {\n mediaState[key] = mediaQueryDefaultActive?.[key] || false\n }\n Object.assign(mediaQueryConfig, media)\n currentMediaState = { ...mediaState }\n initialMediaState = currentMediaState\n if (config.disableSSR) {\n setupMediaListeners()\n }\n}\n\nfunction unlisten() {\n dispose.forEach((cb) => cb())\n dispose.clear()\n}\n\n/**\n * Note: This should *not* set the state on the first render!\n * Because to avoid hydration issues SSR must match the server\n * *and then* re-render with the actual media query state.\n */\nlet configuredKey = ''\nfunction setupMediaListeners() {\n // avoid setting up more than once per config\n const nextKey = JSON.stringify(mediaQueryConfig)\n if (nextKey === configuredKey) {\n return\n }\n configuredKey = nextKey\n\n // hmr, undo existing before re-binding\n unlisten()\n\n // theoretically this should make media reactions smoother but potentially delayed?\n // but i believe consistent, so that's a nicer default (we'll see)\n startTransition(() => {\n for (const key in mediaQueryConfig) {\n const str = mediaObjectToString(mediaQueryConfig[key])\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match) {\n throw new Error('\u26A0\uFE0F No match')\n }\n // react native needs these deprecated apis for now\n match.addListener(update)\n dispose.add(() => match.removeListener(update))\n\n update()\n\n function update() {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n currentMediaState = { ...mediaState }\n const listeners = mediaQueryListeners[key]\n if (listeners?.size) {\n listeners.forEach((cb) => cb(next))\n }\n }\n }\n })\n}\n\nconst onIdle =\n typeof requestIdleCallback === 'undefined' ? (cb) => setTimeout(cb, 100) : requestIdleCallback\n\nexport function useMediaQueryListeners(config: TamaguiInternalConfig) {\n if (config.disableSSR) {\n return\n }\n\n useEffect(() => {\n setupMediaListeners()\n\n onIdle(() => {\n hasFinishedInitialRender = true\n })\n\n return unlisten\n }, [])\n}\n\nexport function useMedia(): {\n [key in MediaQueryKey]: boolean\n} {\n const [state, setState] = useState(getCurrentMediaState())\n const keys = useSafeRef({} as Record<string, boolean>)\n\n function updateState() {\n setState((prev) => {\n for (const key in keys.current) {\n if (prev[key] !== mediaState[key]) {\n return { ...mediaState }\n }\n }\n return prev\n })\n }\n\n useIsomorphicLayoutEffect(() => {\n const disposes: Function[] = Object.keys(keys.current).map((key) =>\n addMediaQueryListener(key, updateState)\n )\n updateState()\n return () => {\n disposes.forEach((cb) => cb())\n }\n })\n\n return useMemo(\n () =>\n new Proxy(state, {\n get(_, key: string) {\n if (process.env.NODE_ENV === 'development') {\n if (!currentMediaState) {\n throw new Error(\n `To use useMedia() you must pass in media configuration to createTamagui, none was found.`\n )\n }\n }\n if (!keys.current[key]) {\n keys.current[key] = true\n }\n return Reflect.get(state, key)\n },\n }),\n [state, keys]\n )\n}\n\n/**\n * Useful for more complex components that need access to the currently active props,\n * accounting for the currently active media queries.\n *\n * Use sparingly, is will loop props and trigger re-render on all media queries.\n *\n * */\nexport function useMediaPropsActive<A extends Object>(\n props: A\n): {\n // remove all media\n [Key in keyof A extends `$${string}` ? never : keyof A]?: A[Key]\n} {\n const media = useMedia()\n\n return useMemo(() => {\n const evaluated = {} as A\n const lastSetImportanceForKey = {}\n const propNames = Object.keys(props)\n const mediaKeysOrdered = Object.keys(getMedia())\n\n function update(k: string, v: any, importance = 0) {\n if (lastSetImportanceForKey[k] > importance) {\n return\n }\n lastSetImportanceForKey[k] = importance\n evaluated[k] = v\n }\n\n for (let i = propNames.length - 1; i >= 0; i--) {\n const key = propNames[i]\n const val = props[key]\n if (key[0] === '$') {\n const shortKey = key.slice(1)\n if (!media[shortKey]) {\n continue\n }\n if (val && typeof val === 'object') {\n const subPropNames = Object.keys(val)\n const mediaImportance = mediaKeysOrdered.indexOf(shortKey)\n for (let j = subPropNames.length; j--; j >= 0) {\n const skey = subPropNames[j]\n update(skey, val[skey], mediaImportance)\n }\n }\n } else {\n update(key, val)\n }\n }\n\n return evaluated\n }, [media, props])\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAA8D;AAE9D,wBAA2B;AAQ3B,wBAA2B;AAC3B,eAA0B;AAEnB,MAAM,aAEX,QAAQ,IAAI,aAAa,gBACrB,IAAI;AAAA,EACF,CAAC;AAAA,EACD;AAAA,IACE,IAAI,QAAQ,KAAK;AACf,UAAI,OAAO,QAAQ,YAAY,IAAI,OAAO,KAAK;AAC7C,cAAM,IAAI,MAAM,6CAA6C;AAAA,MAC/D;AACA,aAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAChC;AAAA,EACF;AACF,IACC,CAAC;AAIR,MAAM,sBAA6D,CAAC;AAE7D,SAAS,sBAAsB,KAAoB,IAAmB;AAC3E,MAAI,QAAQ,IAAI,aAAa,iBAAiB,IAAI,OAAO,KAAK;AAE5D,YAAQ,KAAK,kEAAkE;AAAA,EACjF;AACA,sBAAoB,OAAO,oBAAoB,QAAQ,oBAAI,IAAI;AAC/D,sBAAoB,KAAK,IAAI,EAAE;AAC/B,SAAO,MAAM,yBAAyB,KAAK,EAAE;AAC/C;AAEO,SAA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AEA,SAAS,cAAc,KAAa;AAClC,SAAO,IAAI,QAAQ,UAAU,CAAC,MAAM,IAAI,EAAE,YAAY,GAAG,EAAE,YAAY;AACzE;AAEO,SAAS,oBAAoB,OAAkC;AACpE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,OAAO,QAAQ,KAAK,EACxB,IAAI,CAAC,CAAC,SAAS,KAAK,MAAM;AACzB,cAAU,cAAc,OAAO;AAC/B,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,IAAI,YAAY;AAAA,IACzB;AACA,QAAI,OAAO,UAAU,YAAY,kBAAkB,KAAK,OAAO,GAAG;AAChE,cAAQ,GAAG;AAAA,IACb;AACA,WAAO,IAAI,YAAY;AAAA,EACzB,CAAC,EACA,KAAK,OAAO;AACjB;",
|
|
6
6
|
"names": ["update"]
|
|
7
7
|
}
|
|
@@ -21,8 +21,8 @@ __export(useSafeRef_exports, {
|
|
|
21
21
|
useSafeRef: () => useSafeRef
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useSafeRef_exports);
|
|
24
|
+
var import_constants = require("@tamagui/constants");
|
|
24
25
|
var import_react = require("react");
|
|
25
|
-
var import_platform = require("../constants/platform");
|
|
26
26
|
const useSafeRef = (initialValue) => {
|
|
27
27
|
const rawRef = (0, import_react.useRef)();
|
|
28
28
|
const raw = rawRef.current ?? (rawRef.current = {
|
|
@@ -48,7 +48,7 @@ const useSafeRef = (initialValue) => {
|
|
|
48
48
|
raw.isRendering = true;
|
|
49
49
|
Promise.resolve().then(() => raw.isRendering = false);
|
|
50
50
|
raw.currentValue = raw.comittedValue;
|
|
51
|
-
(0,
|
|
51
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
52
52
|
raw.comittedValue = raw.currentValue;
|
|
53
53
|
});
|
|
54
54
|
return raw.ref;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useSafeRef.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useRef } from 'react'\n\n// dai-shi \uD83D\uDE4F\n// https://dev.to/uhyo_/a-concurrent-mode-safe-version-of-useref-1325\n\ntype Raw<T> = {\n isRendering: boolean\n comittedValue: T\n currentValue: T\n ref: { current: T }\n}\n\nexport const useSafeRef = <T>(initialValue: T) => {\n const rawRef = useRef<Raw<T>>()\n\n const raw: Raw<T> =\n rawRef.current ??\n (rawRef.current = {\n isRendering: true,\n comittedValue: initialValue,\n currentValue: initialValue,\n ref: {\n get current() {\n if (raw.isRendering) {\n return raw.currentValue\n } else {\n return raw.comittedValue\n }\n },\n set current(v) {\n if (!raw.isRendering) {\n raw.comittedValue = v\n }\n raw.currentValue = v\n },\n },\n })\n\n raw.isRendering = true\n Promise.resolve().then(() => (raw.isRendering = false))\n raw.currentValue = raw.comittedValue\n\n useIsomorphicLayoutEffect(() => {\n raw.comittedValue = raw.currentValue\n })\n\n return raw.ref\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAAuB;AAYhB,MAAM,aAAa,CAAI,iBAAoB;AAChD,QAAM,aAAS,qBAAe;AAE9B,QAAM,MACJ,OAAO,YACN,OAAO,UAAU;AAAA,IAChB,aAAa;AAAA,IACb,eAAe;AAAA,IACf,cAAc;AAAA,IACd,KAAK;AAAA,MACH,IAAI,UAAU;AACZ,YAAI,IAAI,aAAa;AACnB,iBAAO,IAAI;AAAA,QACb,OAAO;AACL,iBAAO,IAAI;AAAA,QACb;AAAA,MACF;AAAA,MACA,IAAI,QAAQ,GAAG;AACb,YAAI,CAAC,IAAI,aAAa;AACpB,cAAI,gBAAgB;AAAA,QACtB;AACA,YAAI,eAAe;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEF,MAAI,cAAc;AAClB,UAAQ,QAAQ,EAAE,KAAK,MAAO,IAAI,cAAc,KAAM;AACtD,MAAI,eAAe,IAAI;AAEvB,kDAA0B,MAAM;AAC9B,QAAI,gBAAgB,IAAI;AAAA,EAC1B,CAAC;AAED,SAAO,IAAI;AACb;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,10 +22,10 @@ __export(useServerHooks_exports, {
|
|
|
22
22
|
useServerState: () => useServerState
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(useServerHooks_exports);
|
|
25
|
+
var import_constants = require("@tamagui/constants");
|
|
25
26
|
var import_react = require("react");
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const useServerRef = import_platform.isRSC ? (val) => ({ current: val }) : import_react.useRef;
|
|
27
|
+
const useServerState = import_constants.isRSC ? (val) => [val, idFn] : import_react.useState;
|
|
28
|
+
const useServerRef = import_constants.isRSC ? (val) => ({ current: val }) : import_react.useRef;
|
|
29
29
|
const idFn = () => {
|
|
30
30
|
};
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useServerHooks.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { isRSC } from '@tamagui/constants'\nimport { useRef, useState } from 'react'\n\nexport const useServerState = isRSC\n ? (((val: any) => [val, idFn]) as unknown as typeof useState)\n : useState\n\nexport const useServerRef = isRSC\n ? (((val: any) => ({ current: val })) as unknown as typeof useRef)\n : useRef\n\nconst idFn = () => {}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,mBAAiC;AAE1B,MAAM,iBAAiB,yBACxB,CAAC,QAAa,CAAC,KAAK,IAAI,IAC1B;AAEG,MAAM,eAAe,yBACtB,CAAC,SAAc,EAAE,SAAS,IAAI,KAChC;AAEJ,MAAM,OAAO,MAAM;AAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -26,11 +26,11 @@ __export(useTheme_exports, {
|
|
|
26
26
|
useThemeName: () => useThemeName
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(useTheme_exports);
|
|
29
|
+
var import_constants = require("@tamagui/constants");
|
|
29
30
|
var import_use_force_update = require("@tamagui/use-force-update");
|
|
30
31
|
var import_react = require("react");
|
|
31
32
|
var import_config = require("../config");
|
|
32
33
|
var import_isDevTools = require("../constants/isDevTools");
|
|
33
|
-
var import_platform = require("../constants/platform");
|
|
34
34
|
var import_ThemeContext = require("../contexts/ThemeContext");
|
|
35
35
|
var import_areEqualSets = require("../helpers/areEqualSets");
|
|
36
36
|
var import_ThemeManager = require("../helpers/ThemeManager");
|
|
@@ -38,7 +38,7 @@ var import_getThemeUnwrapped = require("./getThemeUnwrapped");
|
|
|
38
38
|
var import_useConstant = require("./useConstant");
|
|
39
39
|
var import_useServerHooks = require("./useServerHooks");
|
|
40
40
|
const useTheme = (themeName, componentName, props, forceUpdate) => {
|
|
41
|
-
if (
|
|
41
|
+
if (import_constants.isRSC) {
|
|
42
42
|
const config = (0, import_config.getConfig)();
|
|
43
43
|
return getThemeProxied(config.themes[config.defaultTheme], config.defaultTheme);
|
|
44
44
|
}
|
|
@@ -68,7 +68,7 @@ const useTheme = (themeName, componentName, props, forceUpdate) => {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
state.current.isRendering = true;
|
|
71
|
-
(0,
|
|
71
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
72
72
|
const st = state.current;
|
|
73
73
|
st.isRendering = false;
|
|
74
74
|
const cur = themeManager == null ? void 0 : themeManager.keys.get(st.uuid);
|
|
@@ -136,13 +136,13 @@ const getThemeManager = (theme) => {
|
|
|
136
136
|
return theme[GetThemeManager];
|
|
137
137
|
};
|
|
138
138
|
const useThemeName = (opts) => {
|
|
139
|
-
if (
|
|
139
|
+
if (import_constants.isRSC) {
|
|
140
140
|
const config = (0, import_config.getConfig)();
|
|
141
141
|
return config.defaultTheme || "light";
|
|
142
142
|
}
|
|
143
143
|
const parent = (0, import_react.useContext)(import_ThemeManager.ThemeManagerContext);
|
|
144
144
|
const [name, setName] = (0, import_react.useState)((parent == null ? void 0 : parent.name) || "");
|
|
145
|
-
(0,
|
|
145
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
146
146
|
if (!parent)
|
|
147
147
|
return;
|
|
148
148
|
return parent.onChangeTheme((next, manager) => {
|
|
@@ -169,7 +169,7 @@ const useChangeThemeEffect = (name, componentName, props, forceUpdateProp, uuid)
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
const { themes } = config;
|
|
172
|
-
if (
|
|
172
|
+
if (import_constants.isRSC) {
|
|
173
173
|
const parentManager2 = new import_ThemeManager.ThemeManager("light", "light", themes.light);
|
|
174
174
|
const next2 = parentManager2.getNextTheme({
|
|
175
175
|
name,
|
|
@@ -206,7 +206,7 @@ const useChangeThemeEffect = (name, componentName, props, forceUpdateProp, uuid)
|
|
|
206
206
|
themeManager.update(next, false, false);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
if (!
|
|
209
|
+
if (!import_constants.isServer) {
|
|
210
210
|
(0, import_react.useLayoutEffect)(() => {
|
|
211
211
|
themeManager.update(next, didChange);
|
|
212
212
|
activeThemeManagers.add(themeManager);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA+B;AAC/B,mBAA8E;AAE9E,oBAA0B;AAC1B,wBAA2B;AAC3B,
|
|
4
|
+
"sourcesContent": ["import { isRSC, isServer, useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { ThemeContext } from '../contexts/ThemeContext'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport {\n GetNextThemeProps,\n ThemeManager,\n ThemeManagerContext,\n emptyManager,\n} from '../helpers/ThemeManager'\nimport { ThemeName, ThemeParsed } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useConstant } from './useConstant'\nimport { useServerRef } from './useServerHooks'\n\nexport interface ThemeProps {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n}\n\ninterface UseThemeState {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeParsed => {\n // TODO this can use useChangeThemeEffect almost ready\n if (isRSC) {\n const config = getConfig()\n // @ts-ignore\n return getThemeProxied(config.themes[config.defaultTheme], config.defaultTheme)\n }\n\n const state = useServerRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n\n const { name, theme, themes, themeManager, className } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate,\n state.current.uuid\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n // eslint-disable-next-line no-console\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { themeName, componentName, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n // eslint-disable-next-line no-console\n console.log(' ', key, logs[key])\n }\n // eslint-disable-next-line no-console\n console.groupEnd()\n }\n }\n\n // track usage\n state.current.isRendering = true\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n const debugProp = props && props['debug']\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('No theme with name', themeName)\n }\n return themes[getConfig().defaultTheme || 'light']\n }\n\n return useMemo(() => {\n return getThemeProxied(theme, name, className, themeManager, state, debugProp)\n }, [theme, name, className, themeManager, state, debugProp])\n}\n\nfunction getThemeProxied(\n theme: any,\n name: string,\n className?: string,\n themeManager?: ThemeManager | null,\n state?: React.MutableRefObject<UseThemeState>,\n debugProp?: boolean | 'verbose'\n) {\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string' && key[0] === '$') {\n key = key.slice(1)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (key === GetThemeManager) {\n return themeManager\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!name || key === '__proto__' || typeof key === 'symbol' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n if (!themeManager) {\n return theme[key]\n }\n if (state) {\n if (state.current.isRendering && !state.current.keys.has(key)) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {\n // eslint-disable-next-line no-console\n console.log(' \uD83D\uDD38 tracking theme', key)\n }\n }\n }\n return themeManager.getValue(key)\n },\n })\n}\n\nconst GetThemeManager = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined => {\n if (!theme) return\n return theme[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n if (isRSC) {\n const config = getConfig()\n return config.defaultTheme || 'light'\n }\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any,\n uuid?: Object\n): {\n themes: Record<string, ThemeParsed>\n themeManager: ThemeManager | null\n name: string\n theme: ThemeParsed | null\n className?: string\n} => {\n const config = getConfig()\n\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error(\n `Missing tamagui config, you either have a duplicate config, or haven't set it up. Be sure createTamagui is called before renderig.`\n )\n }\n }\n\n const { themes } = config\n\n if (isRSC) {\n // we need context working for this to work well\n const parentManager = new ThemeManager('light', 'light', themes.light)\n const next = parentManager.getNextTheme({\n name,\n componentName,\n themes,\n reset: props?.reset,\n })\n return {\n ...next,\n themes,\n themeManager: null,\n }\n }\n\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = {\n name,\n componentName,\n themes,\n reset,\n }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const forceUpdate = forceUpdateProp || useForceUpdate()\n\n const themeManager = useConstant(() => {\n return new ThemeManager(next.name, next.className, next.theme, parentManager, reset)\n })\n\n // not concurrent safe but fixes native (but breaks SSR and not needed on web (i think) so leave only on native)\n let didChange = false\n if (process.env.TAMAGUI_TARGET === 'native') {\n didChange = Boolean(\n next?.name !== themeManager.name || next?.className !== themeManager.className\n )\n if (didChange) {\n themeManager.update(next, false, false)\n }\n }\n\n if (!isServer) {\n useLayoutEffect(() => {\n themeManager.update(next, didChange)\n activeThemeManagers.add(themeManager)\n\n const disposeParentOnChange = parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n if (uuid && !themeManager.isTracking(uuid)) {\n // no need to re-render if not tracking any keys\n return\n }\n if (process.env.NODE_ENV === 'development' && debug) {\n // eslint-disable-next-line no-console\n console.log('Changed theme', componentName, next, { props })\n }\n forceUpdate()\n }\n })\n\n return () => {\n activeThemeManagers.delete(themeManager)\n disposeParentOnChange()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [didChange, themes, next?.name, next?.className, componentName, debug])\n }\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n className: next.className === parentManager.className ? undefined : next.className,\n themes,\n themeManager,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2D;AAC3D,8BAA+B;AAC/B,mBAA8E;AAE9E,oBAA0B;AAC1B,wBAA2B;AAC3B,0BAA6B;AAC7B,0BAA6B;AAC7B,0BAKO;AAEP,+BAAkC;AAClC,yBAA4B;AAC5B,4BAA6B;AAkBtB,MAAM,WAAW,CACtB,WACA,eACA,OACA,gBACgB;AAEhB,MAAI,wBAAO;AACT,UAAM,aAAS,yBAAU;AAEzB,WAAO,gBAAgB,OAAO,OAAO,OAAO,eAAe,OAAO,YAAY;AAAA,EAChF;AAEA,QAAM,YAAQ,oCAAa;AAC3B,MAAI,CAA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,7 +54,7 @@ __reExport(src_exports, require("./styled"), module.exports);
|
|
|
54
54
|
__reExport(src_exports, require("./types"), module.exports);
|
|
55
55
|
var import_config = require("./config");
|
|
56
56
|
__reExport(src_exports, require("./constants/constants"), module.exports);
|
|
57
|
-
__reExport(src_exports, require("
|
|
57
|
+
__reExport(src_exports, require("@tamagui/constants"), module.exports);
|
|
58
58
|
var import_rnw = require("@tamagui/rnw");
|
|
59
59
|
__reExport(src_exports, require("./helpers/calc"), module.exports);
|
|
60
60
|
__reExport(src_exports, require("./helpers/useShallowSetState"), module.exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './config'\n\nexport * from './constants/constants'\nexport * from '
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,sBAAd;AACA,wBAAc,8BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,4BAJd;AAKA,wBAAc,yBALd;AAMA,wBAAc,2BANd;AAOA,wBAAc,6BAPd;AAQA,wBAAc,8BARd;AASA,wBAAc,yBATd;AAUA,wBAAc,uBAVd;AAWA,wBAAc,0BAXd;AAYA,wBAAc,qBAZd;AAaA,wBAAc,oBAbd;AAiBA,oBAAoF;AAEpF,wBAAc,kCAnBd;AAoBA,wBAAc
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './config'\n\nexport * from './constants/constants'\nexport * from '@tamagui/constants'\nexport { createDOMProps } from '@tamagui/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/useShallowSetState'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getAnimationDriver'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/getFont'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/startTransition'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n addMediaQueryListener,\n removeMediaQueryListener,\n mediaQueryConfig,\n} from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useIsSSR'\nexport * from './hooks/useUnmountEffect'\nexport * from './hooks/useSafeRef'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport { TextAncestorProvider, TextAncestorContext } from './contexts/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\nexport * from './views/FontLanguage'\nexport * from './views/TamaguiProvider'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,sBAAd;AACA,wBAAc,8BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,4BAJd;AAKA,wBAAc,yBALd;AAMA,wBAAc,2BANd;AAOA,wBAAc,6BAPd;AAQA,wBAAc,8BARd;AASA,wBAAc,yBATd;AAUA,wBAAc,uBAVd;AAWA,wBAAc,0BAXd;AAYA,wBAAc,qBAZd;AAaA,wBAAc,oBAbd;AAiBA,oBAAoF;AAEpF,wBAAc,kCAnBd;AAoBA,wBAAc,+BApBd;AAqBA,iBAA+B;AAE/B,wBAAc,2BAvBd;AAwBA,wBAAc,yCAxBd;AAyBA,wBAAc,mCAzBd;AA0BA,wBAAc,uCA1Bd;AA2BA,wBAAc,yCA3Bd;AA4BA,wBAAc,4CA5Bd;AA6BA,wBAAc,8BA7Bd;AA8BA,wBAAc,qCA9Bd;AA+BA,wBAAc,sCA/Bd;AAgCA,wBAAc,wCAhCd;AAiCA,wBAAc,iCAjCd;AAkCA,wBAAc,mCAlCd;AAmCA,wBAAc,8BAnCd;AAoCA,wBAAc,4BApCd;AAqCA,wBAAc,uCArCd;AAsCA,wBAAc,yCAtCd;AAuCA,wBAAc,iCAvCd;AAwCA,wBAAc,sCAxCd;AAyCA,wBAAc,gCAzCd;AA0CA,wBAAc,2CA1Cd;AA4CA,wBAAc,iDA5Cd;AA8CA,wBAAc,gCA9Cd;AA+CA,wBAAc,0BA/Cd;AAgDA,wBAAc,iCAhDd;AAiDA,wBAAc,qCAjDd;AAmDA,sBAUO;AACP,wBAAc,iCA9Dd;AA+DA,wBAAc,6BA/Dd;AAgEA,wBAAc,6BAhEd;AAiEA,wBAAc,qCAjEd;AAkEA,wBAAc,+BAlEd;AAoEA,wBAAc,yBApEd;AAqEA,wBAAc,0BArEd;AAsEA,wBAAc,yBAtEd;AAuEA,iCAA0D;AAC1D,wBAAc,0BAxEd;AAyEA,wBAAc,iCAzEd;AA0EA,wBAAc,kCA1Ed;AA2EA,wBAAc,+BA3Ed;AA4EA,wBAAc,iCA5Ed;AA6EA,wBAAc,oCA7Ed;AA+EA,wBAAc,sCA/Ed;AAgFA,wBAAc,+BAhFd;AAiFA,wBAAc,6BAjFd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/views/Slot.js
CHANGED
|
@@ -31,8 +31,8 @@ __export(Slot_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(Slot_exports);
|
|
32
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
33
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
34
|
+
var import_constants = require("@tamagui/constants");
|
|
34
35
|
var React = __toESM(require("react"));
|
|
35
|
-
var import_platform = require("../constants/platform");
|
|
36
36
|
const Slot = React.forwardRef((props, forwardedRef) => {
|
|
37
37
|
const { children, ...slotProps } = props;
|
|
38
38
|
const childrenArray = React.Children.toArray(children);
|
|
@@ -81,7 +81,7 @@ const Slottable = ({ children }) => {
|
|
|
81
81
|
function isSlottable(child) {
|
|
82
82
|
return React.isValidElement(child) && child.type === Slottable;
|
|
83
83
|
}
|
|
84
|
-
const pressMap =
|
|
84
|
+
const pressMap = import_constants.isWeb ? {
|
|
85
85
|
onPress: "onClick",
|
|
86
86
|
onPressOut: "onMouseUp",
|
|
87
87
|
onPressIn: "onMouseDown"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Slot.tsx"],
|
|
4
|
-
"sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport { isWeb } from '@tamagui/constants'\nimport * as React from 'react'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n const childrenArray = React.Children.toArray(children)\n const slottable = childrenArray.find(isSlottable)\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children as React.ReactNode\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null)\n return React.isValidElement(newElement)\n ? (newElement.props.children as React.ReactNode)\n : null\n } else {\n return child\n }\n })\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n )\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n const childProps = {\n ...mergeSlotProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n }\n return React.cloneElement(children, childProps)\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n return React.isValidElement(child) && child.type === Slottable\n}\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeSlotProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = handleRegex.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = mergeEvent(childPropValue, slotPropValue)\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n\nconst handleRegex = /^on[A-Z]/\n\nexport function mergeEvent(a?: Function, b?: Function) {\n return (...args: unknown[]) => {\n a?.(...args)\n b?.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ACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -28,8 +28,9 @@ __export(TamaguiProvider_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(TamaguiProvider_exports);
|
|
30
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_constants = require("@tamagui/constants");
|
|
32
|
+
var import_use_did_finish_ssr = require("@tamagui/use-did-finish-ssr");
|
|
31
33
|
var React = __toESM(require("react"));
|
|
32
|
-
var import_platform = require("../constants/platform");
|
|
33
34
|
var import_ButtonInsideButtonContext = require("../contexts/ButtonInsideButtonContext");
|
|
34
35
|
var import_TextAncestorContext = require("../contexts/TextAncestorContext");
|
|
35
36
|
var import_useMedia = require("../hooks/useMedia");
|
|
@@ -40,17 +41,18 @@ function TamaguiProvider({
|
|
|
40
41
|
config,
|
|
41
42
|
...themePropsProvider
|
|
42
43
|
}) {
|
|
43
|
-
if (
|
|
44
|
+
if (import_constants.isRSC) {
|
|
44
45
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
45
46
|
style: { display: "contents" },
|
|
46
47
|
className: `t_${config.defaultTheme || "light"}`,
|
|
47
48
|
children
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
if (!
|
|
51
|
+
if (!import_constants.isServer) {
|
|
52
|
+
(0, import_use_did_finish_ssr.useSetupHasSSRRendered)();
|
|
51
53
|
(0, import_useMedia.useMediaQueryListeners)(config);
|
|
52
54
|
}
|
|
53
|
-
if (
|
|
55
|
+
if (import_constants.isClient) {
|
|
54
56
|
React.useLayoutEffect(() => {
|
|
55
57
|
if (disableInjectCSS)
|
|
56
58
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/TamaguiProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { isClient, isRSC, isServer } from '@tamagui/constants'\nimport { useSetupHasSSRRendered } from '@tamagui/use-did-finish-ssr'\nimport * as React from 'react'\n\nimport { ButtonInsideButtonContext } from '../contexts/ButtonInsideButtonContext'\nimport { TextAncestorProvider } from '../contexts/TextAncestorContext'\nimport { useMediaQueryListeners } from '../hooks/useMedia'\nimport type { TamaguiProviderProps } from '../types'\nimport { ThemeProvider } from './ThemeProvider'\n\nexport function TamaguiProvider({\n children,\n disableInjectCSS,\n config,\n ...themePropsProvider\n}: TamaguiProviderProps) {\n if (isRSC) {\n return (\n <span style={{ display: 'contents' }} className={`t_${config.defaultTheme || 'light'}`}>\n {children}\n </span>\n )\n }\n\n if (!isServer) {\n useSetupHasSSRRendered()\n useMediaQueryListeners(config)\n }\n\n if (isClient) {\n // inject CSS if asked to (not SSR compliant)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useLayoutEffect(() => {\n if (disableInjectCSS) return\n const style = document.createElement('style')\n style.appendChild(document.createTextNode(config.getCSS()))\n document.head.appendChild(style)\n return () => {\n document.head.removeChild(style)\n }\n }, [config, disableInjectCSS])\n }\n\n return (\n <ButtonInsideButtonContext.Provider value={false}>\n <TextAncestorProvider>\n <ThemeProvider\n defaultTheme={config.defaultTheme || 'light'}\n themeClassNameOnRoot={config.themeClassNameOnRoot}\n disableRootThemeClass={config.disableRootThemeClass}\n {...themePropsProvider}\n >\n {children}\n </ThemeProvider>\n </TextAncestorProvider>\n </ButtonInsideButtonContext.Provider>\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBM;AAlBN,uBAA0C;AAC1C,gCAAuC;AACvC,YAAuB;AAEvB,uCAA0C;AAC1C,iCAAqC;AACrC,sBAAuC;AAEvC,2BAA8B;AAEvB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,KACG;AACL,GAAyB;AACvB,MAAI,wBAAO;AACT,WACE,4CAAC;AAAA,MAAK,OAAO,EAAE,SAAS,WAAW;AAAA,MAAG,WAAW,KAAK,OAAO,gBAAgB;AAAA,MAC1E;AAAA,KACH;AAAA,EAEJ;AAEA,MAAI,CAAC,2BAAU;AACb,0DAAuB;AACvB,gDAAuB,MAAM;AAAA,EAC/B;AAEA,MAAI,2BAAU;AAGZ,UAAM,gBAAgB,MAAM;AAC1B,UAAI;AAAkB;AACtB,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,YAAY,SAAS,eAAe,OAAO,OAAO,CAAC,CAAC;AAC1D,eAAS,KAAK,YAAY,KAAK;AAC/B,aAAO,MAAM;AACX,iBAAS,KAAK,YAAY,KAAK;AAAA,MACjC;AAAA,IACF,GAAG,CAAC,QAAQ,gBAAgB,CAAC;AAAA,EAC/B;AAEA,SACE,4CAAC,2DAA0B,UAA1B;AAAA,IAAmC,OAAO;AAAA,IACzC,sDAAC;AAAA,MACC,sDAAC;AAAA,QACC,cAAc,OAAO,gBAAgB;AAAA,QACrC,sBAAsB,OAAO;AAAA,QAC7B,uBAAuB,OAAO;AAAA,QAC7B,GAAG;AAAA,QAEH;AAAA,OACH;AAAA,KACF;AAAA,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/views/Text.js
CHANGED
|
@@ -21,8 +21,8 @@ __export(Text_exports, {
|
|
|
21
21
|
Text: () => Text
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(Text_exports);
|
|
24
|
+
var import_constants = require("@tamagui/constants");
|
|
24
25
|
var import_helpers = require("@tamagui/helpers");
|
|
25
|
-
var import_platform = require("../constants/platform");
|
|
26
26
|
var import_createComponent = require("../createComponent");
|
|
27
27
|
const ellipseStyle = {
|
|
28
28
|
maxWidth: "100%",
|
|
@@ -36,14 +36,14 @@ const Text = (0, import_createComponent.createComponent)({
|
|
|
36
36
|
defaultProps: {
|
|
37
37
|
display: "flex",
|
|
38
38
|
fontFamily: "System",
|
|
39
|
-
...
|
|
39
|
+
...import_constants.isWeb && {
|
|
40
40
|
display: "inline",
|
|
41
41
|
boxSizing: "border-box",
|
|
42
42
|
wordWrap: "break-word"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
variants: {
|
|
46
|
-
...
|
|
46
|
+
...import_constants.isWeb && {
|
|
47
47
|
numberOfLines: {
|
|
48
48
|
1: ellipseStyle,
|
|
49
49
|
":number": (numberOfLines) => numberOfLines >= 1 ? {
|
|
@@ -70,13 +70,13 @@ const Text = (0, import_createComponent.createComponent)({
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
ellipse: {
|
|
73
|
-
true:
|
|
73
|
+
true: import_constants.isWeb ? ellipseStyle : {
|
|
74
74
|
numberOfLines: 1,
|
|
75
75
|
lineBreakMode: "clip"
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
|
-
deoptProps: new Set(
|
|
79
|
+
deoptProps: new Set(import_constants.isWeb ? [] : ["ellipse"]),
|
|
80
80
|
validStyles: {
|
|
81
81
|
...import_helpers.validStyles,
|
|
82
82
|
...import_helpers.stylePropsTextOnly
|