@tamagui/core 1.0.1-beta.71 → 1.0.1-beta.74
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/Tamagui.js +4 -6
- package/dist/cjs/Tamagui.js.map +1 -1
- package/dist/cjs/ThemeManager.js +3 -5
- package/dist/cjs/ThemeManager.js.map +1 -1
- package/dist/cjs/conf.js +11 -11
- package/dist/cjs/conf.js.map +2 -2
- package/dist/cjs/constants/rnw.js +1 -2
- package/dist/cjs/constants/rnw.js.map +1 -1
- package/dist/cjs/createComponent.js +16 -23
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createFont.js +2 -3
- package/dist/cjs/createFont.js.map +1 -1
- package/dist/cjs/createShorthands.js +0 -2
- package/dist/cjs/createShorthands.js.map +1 -1
- package/dist/cjs/createTamagui.js +4 -7
- package/dist/cjs/createTamagui.js.map +1 -1
- package/dist/cjs/createTheme.js +2 -3
- package/dist/cjs/createTheme.js.map +1 -1
- package/dist/cjs/createTokens.js +0 -2
- package/dist/cjs/createTokens.js.map +1 -1
- package/dist/cjs/createVariable.js +4 -10
- package/dist/cjs/createVariable.js.map +1 -1
- package/dist/cjs/createVariables.js +2 -3
- package/dist/cjs/createVariables.js.map +1 -1
- package/dist/cjs/helpers/areEqualSets.js +2 -3
- package/dist/cjs/helpers/areEqualSets.js.map +1 -1
- package/dist/cjs/helpers/calc.js +4 -5
- package/dist/cjs/helpers/calc.js.map +1 -1
- package/dist/cjs/helpers/createMediaStyle.js +2 -3
- package/dist/cjs/helpers/createMediaStyle.js.map +1 -1
- package/dist/cjs/helpers/createPropMapper.js +12 -15
- package/dist/cjs/helpers/createPropMapper.js.map +1 -1
- package/dist/cjs/helpers/createShallowUpdate.js +0 -2
- package/dist/cjs/helpers/createShallowUpdate.js.map +1 -1
- package/dist/cjs/helpers/createTamaguiProvider.js +2 -4
- package/dist/cjs/helpers/createTamaguiProvider.js.map +1 -1
- package/dist/cjs/helpers/extendStaticConfig.js +2 -4
- package/dist/cjs/helpers/extendStaticConfig.js.map +1 -1
- package/dist/cjs/helpers/fixNativeShadow.js +2 -3
- package/dist/cjs/helpers/fixNativeShadow.js.map +1 -1
- package/dist/cjs/helpers/fixNativeShadow.native.js +0 -2
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +1 -1
- package/dist/cjs/helpers/generateAtomicStyles.js +11 -21
- package/dist/cjs/helpers/generateAtomicStyles.js.map +1 -1
- package/dist/cjs/helpers/getExpandedShorthands.js +0 -2
- package/dist/cjs/helpers/getExpandedShorthands.js.map +1 -1
- package/dist/cjs/helpers/getSize.js +4 -5
- package/dist/cjs/helpers/getSize.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.js +8 -12
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getStackSize.js +2 -3
- package/dist/cjs/helpers/getStackSize.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.js +0 -3
- package/dist/cjs/helpers/getStylesAtomic.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.native.js +0 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/cjs/helpers/getTextSize.js +2 -3
- package/dist/cjs/helpers/getTextSize.js.map +1 -1
- package/dist/cjs/helpers/getVariantExtras.js +0 -2
- package/dist/cjs/helpers/getVariantExtras.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.js +3 -8
- package/dist/cjs/helpers/insertStyleRule.js.map +1 -1
- package/dist/cjs/helpers/isObj.js +1 -2
- package/dist/cjs/helpers/isObj.js.map +1 -1
- package/dist/cjs/helpers/isTamaguiComponent.js +0 -2
- package/dist/cjs/helpers/isTamaguiComponent.js.map +1 -1
- package/dist/cjs/helpers/isTamaguiElement.js +2 -3
- package/dist/cjs/helpers/isTamaguiElement.js.map +1 -1
- package/dist/cjs/helpers/matchMedia.js +2 -3
- package/dist/cjs/helpers/matchMedia.js.map +1 -1
- package/dist/cjs/helpers/matchMedia.native.js +1 -2
- package/dist/cjs/helpers/matchMedia.native.js.map +1 -1
- package/dist/cjs/helpers/mergeProps.js +2 -3
- package/dist/cjs/helpers/mergeProps.js.map +1 -1
- package/dist/cjs/helpers/mergeTransform.js +2 -3
- package/dist/cjs/helpers/mergeTransform.js.map +1 -1
- package/dist/cjs/helpers/proxyThemeVariables.js +1 -3
- package/dist/cjs/helpers/proxyThemeVariables.js.map +1 -1
- package/dist/cjs/helpers/registerCSSVariable.js +2 -3
- package/dist/cjs/helpers/registerCSSVariable.js.map +1 -1
- package/dist/cjs/helpers/themeable.js +2 -4
- package/dist/cjs/helpers/themeable.js.map +1 -1
- package/dist/cjs/helpers/validate.js +6 -7
- package/dist/cjs/helpers/validate.js.map +1 -1
- package/dist/cjs/helpers/withStaticProperties.js +2 -3
- package/dist/cjs/helpers/withStaticProperties.js.map +1 -1
- package/dist/cjs/helpers/wrapThemeManagerContext.js +0 -2
- package/dist/cjs/helpers/wrapThemeManagerContext.js.map +1 -1
- package/dist/cjs/hooks/useConstant.js +0 -2
- package/dist/cjs/hooks/useConstant.js.map +1 -1
- package/dist/cjs/hooks/useFeatures.js +7 -13
- package/dist/cjs/hooks/useFeatures.js.map +2 -2
- package/dist/cjs/hooks/useId.js +0 -3
- package/dist/cjs/hooks/useId.js.map +1 -1
- package/dist/cjs/hooks/useIsMounted.js +0 -2
- package/dist/cjs/hooks/useIsMounted.js.map +1 -1
- package/dist/cjs/hooks/useIsTouchDevice.js +2 -3
- package/dist/cjs/hooks/useIsTouchDevice.js.map +1 -1
- package/dist/cjs/hooks/useMedia.js +11 -15
- package/dist/cjs/hooks/useMedia.js.map +1 -1
- package/dist/cjs/hooks/usePressable.js +2 -3
- package/dist/cjs/hooks/usePressable.js.map +1 -1
- package/dist/cjs/hooks/useTheme.js +10 -11
- package/dist/cjs/hooks/useTheme.js.map +1 -1
- package/dist/cjs/hooks/useUnmountEffect.js +0 -2
- package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
- package/dist/cjs/insertFont.js +1 -5
- package/dist/cjs/insertFont.js.map +2 -2
- package/dist/cjs/styled.js +0 -2
- package/dist/cjs/styled.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Slot.js +2 -5
- package/dist/cjs/views/Slot.js.map +1 -1
- package/dist/cjs/views/TextAncestorContext.js +2 -3
- package/dist/cjs/views/TextAncestorContext.js.map +1 -1
- package/dist/cjs/views/Theme.js +2 -3
- package/dist/cjs/views/Theme.js.map +1 -1
- package/dist/cjs/views/ThemeInverse.js +2 -4
- package/dist/cjs/views/ThemeInverse.js.map +1 -1
- package/dist/cjs/views/ThemeProvider.js +2 -3
- package/dist/cjs/views/ThemeProvider.js.map +1 -1
- package/dist/cjs/views/ThemeReset.js +2 -3
- package/dist/cjs/views/ThemeReset.js.map +1 -1
- package/dist/esm/Tamagui.js +4 -7
- package/dist/esm/Tamagui.js.map +1 -1
- package/dist/esm/ThemeManager.js +3 -6
- package/dist/esm/ThemeManager.js.map +1 -1
- package/dist/esm/conf.js +11 -12
- package/dist/esm/conf.js.map +2 -2
- package/dist/esm/constants/rnw.js +1 -3
- package/dist/esm/constants/rnw.js.map +1 -1
- package/dist/esm/createComponent.js +15 -24
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createFont.js +2 -4
- package/dist/esm/createFont.js.map +1 -1
- package/dist/esm/createShorthands.js +0 -3
- package/dist/esm/createShorthands.js.map +1 -1
- package/dist/esm/createTamagui.js +4 -8
- package/dist/esm/createTamagui.js.map +1 -1
- package/dist/esm/createTheme.js +2 -4
- package/dist/esm/createTheme.js.map +1 -1
- package/dist/esm/createTokens.js +0 -3
- package/dist/esm/createTokens.js.map +1 -1
- package/dist/esm/createVariable.js +4 -11
- package/dist/esm/createVariable.js.map +1 -1
- package/dist/esm/createVariables.js +2 -4
- package/dist/esm/createVariables.js.map +1 -1
- package/dist/esm/helpers/areEqualSets.js +2 -4
- package/dist/esm/helpers/areEqualSets.js.map +1 -1
- package/dist/esm/helpers/calc.js +4 -6
- package/dist/esm/helpers/calc.js.map +1 -1
- package/dist/esm/helpers/createMediaStyle.js +2 -4
- package/dist/esm/helpers/createMediaStyle.js.map +1 -1
- package/dist/esm/helpers/createPropMapper.js +12 -16
- package/dist/esm/helpers/createPropMapper.js.map +1 -1
- package/dist/esm/helpers/createShallowUpdate.js +0 -3
- package/dist/esm/helpers/createShallowUpdate.js.map +1 -1
- package/dist/esm/helpers/createTamaguiProvider.js +2 -5
- package/dist/esm/helpers/createTamaguiProvider.js.map +1 -1
- package/dist/esm/helpers/extendStaticConfig.js +2 -5
- package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
- package/dist/esm/helpers/fixNativeShadow.js +2 -4
- package/dist/esm/helpers/fixNativeShadow.js.map +1 -1
- package/dist/esm/helpers/fixNativeShadow.native.js +0 -3
- package/dist/esm/helpers/fixNativeShadow.native.js.map +1 -1
- package/dist/esm/helpers/generateAtomicStyles.js +11 -22
- package/dist/esm/helpers/generateAtomicStyles.js.map +1 -1
- package/dist/esm/helpers/getExpandedShorthands.js +0 -3
- package/dist/esm/helpers/getExpandedShorthands.js.map +1 -1
- package/dist/esm/helpers/getSize.js +4 -6
- package/dist/esm/helpers/getSize.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +8 -13
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getStackSize.js +2 -4
- package/dist/esm/helpers/getStackSize.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +0 -4
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.native.js +0 -3
- package/dist/esm/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/esm/helpers/getTextSize.js +2 -4
- package/dist/esm/helpers/getTextSize.js.map +1 -1
- package/dist/esm/helpers/getVariantExtras.js +0 -3
- package/dist/esm/helpers/getVariantExtras.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.js +3 -9
- package/dist/esm/helpers/insertStyleRule.js.map +1 -1
- package/dist/esm/helpers/isObj.js +1 -3
- package/dist/esm/helpers/isObj.js.map +1 -1
- package/dist/esm/helpers/isTamaguiComponent.js +0 -3
- package/dist/esm/helpers/isTamaguiComponent.js.map +1 -1
- package/dist/esm/helpers/isTamaguiElement.js +2 -4
- package/dist/esm/helpers/isTamaguiElement.js.map +1 -1
- package/dist/esm/helpers/matchMedia.js +2 -4
- package/dist/esm/helpers/matchMedia.js.map +1 -1
- package/dist/esm/helpers/matchMedia.native.js +1 -3
- package/dist/esm/helpers/matchMedia.native.js.map +1 -1
- package/dist/esm/helpers/mergeProps.js +2 -4
- package/dist/esm/helpers/mergeProps.js.map +1 -1
- package/dist/esm/helpers/mergeTransform.js +2 -4
- package/dist/esm/helpers/mergeTransform.js.map +1 -1
- package/dist/esm/helpers/proxyThemeVariables.js +1 -4
- package/dist/esm/helpers/proxyThemeVariables.js.map +1 -1
- package/dist/esm/helpers/registerCSSVariable.js +2 -4
- package/dist/esm/helpers/registerCSSVariable.js.map +1 -1
- package/dist/esm/helpers/themeable.js +2 -5
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/helpers/validate.js +6 -8
- package/dist/esm/helpers/validate.js.map +1 -1
- package/dist/esm/helpers/withStaticProperties.js +2 -4
- package/dist/esm/helpers/withStaticProperties.js.map +1 -1
- package/dist/esm/helpers/wrapThemeManagerContext.js +0 -3
- package/dist/esm/helpers/wrapThemeManagerContext.js.map +1 -1
- package/dist/esm/hooks/useConstant.js +0 -3
- package/dist/esm/hooks/useConstant.js.map +1 -1
- package/dist/esm/hooks/useFeatures.js +7 -14
- package/dist/esm/hooks/useFeatures.js.map +2 -2
- package/dist/esm/hooks/useId.js +0 -4
- package/dist/esm/hooks/useId.js.map +1 -1
- package/dist/esm/hooks/useIsMounted.js +0 -3
- package/dist/esm/hooks/useIsMounted.js.map +1 -1
- package/dist/esm/hooks/useIsTouchDevice.js +2 -4
- package/dist/esm/hooks/useIsTouchDevice.js.map +1 -1
- package/dist/esm/hooks/useMedia.js +11 -16
- package/dist/esm/hooks/useMedia.js.map +1 -1
- package/dist/esm/hooks/usePressable.js +2 -4
- package/dist/esm/hooks/usePressable.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +10 -12
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/hooks/useUnmountEffect.js +0 -3
- package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
- package/dist/esm/insertFont.js +1 -6
- package/dist/esm/insertFont.js.map +2 -2
- package/dist/esm/styled.js +0 -3
- package/dist/esm/styled.js.map +1 -1
- package/dist/esm/views/Slot.js +2 -6
- package/dist/esm/views/Slot.js.map +1 -1
- package/dist/esm/views/TextAncestorContext.js +2 -4
- package/dist/esm/views/TextAncestorContext.js.map +1 -1
- package/dist/esm/views/Theme.js +2 -4
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/ThemeInverse.js +2 -5
- package/dist/esm/views/ThemeInverse.js.map +1 -1
- package/dist/esm/views/ThemeProvider.js +2 -4
- package/dist/esm/views/ThemeProvider.js.map +1 -1
- package/dist/esm/views/ThemeReset.js +2 -4
- package/dist/esm/views/ThemeReset.js.map +1 -1
- package/dist/jsx/Tamagui.js +4 -7
- package/dist/jsx/ThemeManager.js +3 -6
- package/dist/jsx/conf.js +11 -12
- package/dist/jsx/constants/rnw.js +1 -3
- package/dist/jsx/createComponent.js +15 -24
- package/dist/jsx/createFont.js +2 -4
- package/dist/jsx/createShorthands.js +0 -3
- package/dist/jsx/createTamagui.js +4 -8
- package/dist/jsx/createTheme.js +2 -4
- package/dist/jsx/createTokens.js +0 -3
- package/dist/jsx/createVariable.js +4 -11
- package/dist/jsx/createVariables.js +2 -4
- package/dist/jsx/helpers/areEqualSets.js +2 -4
- package/dist/jsx/helpers/calc.js +4 -6
- package/dist/jsx/helpers/createMediaStyle.js +2 -4
- package/dist/jsx/helpers/createPropMapper.js +12 -16
- package/dist/jsx/helpers/createShallowUpdate.js +0 -3
- package/dist/jsx/helpers/createTamaguiProvider.js +2 -5
- package/dist/jsx/helpers/extendStaticConfig.js +2 -5
- package/dist/jsx/helpers/fixNativeShadow.js +2 -4
- package/dist/jsx/helpers/fixNativeShadow.native.js +0 -3
- package/dist/jsx/helpers/generateAtomicStyles.js +11 -22
- package/dist/jsx/helpers/getExpandedShorthands.js +0 -3
- package/dist/jsx/helpers/getSize.js +4 -6
- package/dist/jsx/helpers/getSplitStyles.js +8 -13
- package/dist/jsx/helpers/getStackSize.js +2 -4
- package/dist/jsx/helpers/getStylesAtomic.js +0 -4
- package/dist/jsx/helpers/getStylesAtomic.native.js +0 -3
- package/dist/jsx/helpers/getTextSize.js +2 -4
- package/dist/jsx/helpers/getVariantExtras.js +0 -3
- package/dist/jsx/helpers/insertStyleRule.js +3 -9
- package/dist/jsx/helpers/isObj.js +1 -3
- package/dist/jsx/helpers/isTamaguiComponent.js +0 -3
- package/dist/jsx/helpers/isTamaguiElement.js +2 -4
- package/dist/jsx/helpers/matchMedia.js +2 -4
- package/dist/jsx/helpers/matchMedia.native.js +1 -3
- package/dist/jsx/helpers/mergeProps.js +2 -4
- package/dist/jsx/helpers/mergeTransform.js +2 -4
- package/dist/jsx/helpers/proxyThemeVariables.js +1 -4
- package/dist/jsx/helpers/registerCSSVariable.js +2 -4
- package/dist/jsx/helpers/themeable.js +2 -5
- package/dist/jsx/helpers/validate.js +6 -8
- package/dist/jsx/helpers/withStaticProperties.js +2 -4
- package/dist/jsx/helpers/wrapThemeManagerContext.js +0 -3
- package/dist/jsx/hooks/useConstant.js +0 -3
- package/dist/jsx/hooks/useFeatures.js +7 -14
- package/dist/jsx/hooks/useId.js +0 -4
- package/dist/jsx/hooks/useIsMounted.js +0 -3
- package/dist/jsx/hooks/useIsTouchDevice.js +2 -4
- package/dist/jsx/hooks/useMedia.js +11 -16
- package/dist/jsx/hooks/usePressable.js +2 -4
- package/dist/jsx/hooks/useTheme.js +10 -12
- package/dist/jsx/hooks/useUnmountEffect.js +0 -3
- package/dist/jsx/insertFont.js +1 -6
- package/dist/jsx/styled.js +0 -3
- package/dist/jsx/views/Slot.js +2 -6
- package/dist/jsx/views/TextAncestorContext.js +2 -4
- package/dist/jsx/views/Theme.js +2 -4
- package/dist/jsx/views/ThemeInverse.js +2 -5
- package/dist/jsx/views/ThemeProvider.js +2 -4
- package/dist/jsx/views/ThemeReset.js +2 -4
- package/package.json +6 -6
- package/types/conf.d.ts +1 -1
- package/types/conf.d.ts.map +1 -1
- package/types/types.d.ts +1 -0
- package/types/types.d.ts.map +1 -1
package/dist/esm/hooks/useId.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as React from "react";
|
|
4
2
|
import { isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
|
|
5
3
|
let serverHandoffComplete = false;
|
|
@@ -7,7 +5,6 @@ let id = 0;
|
|
|
7
5
|
function genId() {
|
|
8
6
|
return ++id;
|
|
9
7
|
}
|
|
10
|
-
__name(genId, "genId");
|
|
11
8
|
function useId(providedId) {
|
|
12
9
|
var _a;
|
|
13
10
|
if (isWeb) {
|
|
@@ -30,7 +27,6 @@ function useId(providedId) {
|
|
|
30
27
|
}, []);
|
|
31
28
|
return (_a = providedId != null ? providedId : id2) != null ? _a : void 0;
|
|
32
29
|
}
|
|
33
|
-
__name(useId, "useId");
|
|
34
30
|
export {
|
|
35
31
|
useId
|
|
36
32
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useId.tsx"],
|
|
4
4
|
"sourcesContent": ["/*\n * Welcome to @reach/auto-id!\n\n * Let's see if we can make sense of why this hook exists and its\n * implementation.\n *\n * Some background:\n * 1. Accessibility APIs rely heavily on element IDs\n * 2. Requiring developers to put IDs on every element in Reach UI is both\n * cumbersome and error-prone\n * 3. With a component model, we can generate IDs for them!\n *\n * Solution 1: Generate random IDs.\n *\n * This works great as long as you don't server render your app. When React (in\n * the client) tries to reuse the markup from the server, the IDs won't match\n * and React will then recreate the entire DOM tree.\n *\n * Solution 2: Increment an integer\n *\n * This sounds great. Since we're rendering the exact same tree on the server\n * and client, we can increment a counter and get a deterministic result between\n * client and server. Also, JS integers can go up to nine-quadrillion. I'm\n * pretty sure the tab will be closed before an app never needs\n * 10 quadrillion IDs!\n *\n * Problem solved, right?\n *\n * Ah, but there's a catch! React's concurrent rendering makes this approach\n * non-deterministic. While the client and server will end up with the same\n * elements in the end, depending on suspense boundaries (and possibly some user\n * input during the initial render) the incrementing integers won't always match\n * up.\n *\n * Solution 3: Don't use IDs at all on the server; patch after first render.\n *\n * What we've done here is solution 2 with some tricks. With this approach, the\n * ID returned is an empty string on the first render. This way the server and\n * client have the same markup no matter how wild the concurrent rendering may\n * have gotten.\n *\n * After the render, we patch up the components with an incremented ID. This\n * causes a double render on any components with `useId`. Shouldn't be a problem\n * since the components using this hook should be small, and we're only updating\n * the ID attribute on the DOM, nothing big is happening.\n *\n * It doesn't have to be an incremented number, though--we could do generate\n * random strings instead, but incrementing a number is probably the cheapest\n * thing we can do.\n *\n * Additionally, we only do this patchup on the very first client render ever.\n * Any calls to `useId` that happen dynamically in the client will be\n * populated immediately with a value. So, we only get the double render after\n * server hydration and never again, SO BACK OFF ALRIGHT?\n */\n\nimport * as React from 'react'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\n\nlet serverHandoffComplete = false\nlet id = 0\nfunction genId() {\n return ++id\n}\n\n/* eslint-disable react-hooks/rules-of-hooks */\n\n/**\n * useId\n *\n * Autogenerate IDs to facilitate WAI-ARIA and server rendering.\n *\n * Note: The returned ID will initially be `null` and will update after a\n * component mounts. Users may need to supply their own ID if they need\n * consistent values for SSR.\n *\n * @see Docs https://reach.tech/auto-id\n */\nfunction useId(idFromProps: string): string\nfunction useId(idFromProps: number): number\nfunction useId(idFromProps: string | number): string | number\nfunction useId(idFromProps: string | undefined | null): string | undefined\nfunction useId(idFromProps: number | undefined | null): number | undefined\nfunction useId(idFromProps: string | number | undefined | null): string | number | undefined\nfunction useId(): string | undefined\n\nfunction useId(providedId?: number | string | undefined | null) {\n // TODO: Remove error flag when updating internal deps to React 18. None of\n // our tricks will play well with concurrent rendering anyway.\n\n // native doesn't support until next react-native version, need to remove eventually\n if (isWeb) {\n // @ts-expect-error\n if (typeof React.useId === 'function') {\n // @ts-expect-error\n let id = React.useId(providedId)\n return providedId != null ? providedId : id\n }\n }\n\n // If this instance isn't part of the initial render, we don't have to do the\n // double render/patch-up dance. We can just generate the ID and return it.\n let initialId = providedId ?? (serverHandoffComplete ? genId() : null)\n let [id, setId] = React.useState(initialId)\n\n useIsomorphicLayoutEffect(() => {\n if (id === null) {\n // Patch the ID after render. We do this in `useLayoutEffect` to avoid any\n // rendering flicker, though it'll make the first render slower (unlikely\n // to matter, but you're welcome to measure your app and let us know if\n // it's a problem).\n setId(genId())\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n React.useEffect(() => {\n if (serverHandoffComplete === false) {\n // Flag all future uses of `useId` to skip the update dance. This is in\n // `useEffect` because it goes after `useLayoutEffect`, ensuring we don't\n // accidentally bail out of the patch-up dance prematurely.\n serverHandoffComplete = true\n }\n }, [])\n\n return providedId ?? id ?? undefined\n}\n\nexport { useId }\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAwDA;AAEA;AAEA,IAAI,wBAAwB;AAC5B,IAAI,KAAK;AACT,iBAAiB;AACf,SAAO,EAAE;AACX;AAuBA,eAAe,YAAiD;AAvFhE;AA4FE,MAAI,OAAO;AAET,QAAI,OAAO,MAAM,UAAU,YAAY;AAErC,UAAI,MAAK,MAAM,MAAM,UAAU;AAC/B,aAAO,cAAc,OAAO,aAAa;AAAA,IAC3C;AAAA,EACF;AAIA,MAAI,YAAY,kCAAe,wBAAwB,MAAM,IAAI;AACjE,MAAI,CAAC,KAAI,SAAS,MAAM,SAAS,SAAS;AAE1C,4BAA0B,MAAM;AAC9B,QAAI,QAAO,MAAM;AAKf,YAAM,MAAM,CAAC;AAAA,IACf;AAAA,EAEF,GAAG,CAAC,CAAC;AAEL,QAAM,UAAU,MAAM;AACpB,QAAI,0BAA0B,OAAO;AAInC,8BAAwB;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,wCAAc,QAAd,YAAoB;AAC7B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { useRef } from "react";
|
|
4
2
|
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
5
3
|
function useIsMounted() {
|
|
@@ -12,7 +10,6 @@ function useIsMounted() {
|
|
|
12
10
|
}, []);
|
|
13
11
|
return isMounted;
|
|
14
12
|
}
|
|
15
|
-
__name(useIsMounted, "useIsMounted");
|
|
16
13
|
export {
|
|
17
14
|
useIsMounted
|
|
18
15
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useIsMounted.ts"],
|
|
4
4
|
"sourcesContent": ["import { useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\n\nexport function useIsMounted() {\n const isMounted = useRef(false)\n\n useIsomorphicLayoutEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n return isMounted\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAEA;AAEO,wBAAwB;AAC7B,QAAM,YAAY,OAAO,KAAK;AAE9B,4BAA0B,MAAM;AAC9B,cAAU,UAAU;AAEpB,WAAO,MAAM;AACX,gBAAU,UAAU;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { useState } from "react";
|
|
4
2
|
import { isTouchable, useIsomorphicLayoutEffect } from "../constants/platform";
|
|
5
|
-
const useIsTouchDevice =
|
|
3
|
+
const useIsTouchDevice = () => {
|
|
6
4
|
const [touchOnly, setTouchOnly] = useState(false);
|
|
7
5
|
useIsomorphicLayoutEffect(() => {
|
|
8
6
|
if (isTouchable) {
|
|
@@ -10,7 +8,7 @@ const useIsTouchDevice = /* @__PURE__ */ __name(() => {
|
|
|
10
8
|
}
|
|
11
9
|
}, []);
|
|
12
10
|
return touchOnly;
|
|
13
|
-
}
|
|
11
|
+
};
|
|
14
12
|
export {
|
|
15
13
|
useIsTouchDevice
|
|
16
14
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useIsTouchDevice.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useState } from 'react'\n\nimport { isTouchable, useIsomorphicLayoutEffect } from '../constants/platform'\n\n// ssr friendly\n\nexport const useIsTouchDevice = () => {\n const [touchOnly, setTouchOnly] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n if (isTouchable) {\n setTouchOnly(true)\n }\n }, [])\n\n return touchOnly\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAEA;AAIO,MAAM,mBAAmB,MAAM;AACpC,QAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;AAEhD,4BAA0B,MAAM;AAC9B,QAAI,aAAa;AACf,mBAAa,IAAI;AAAA,IACnB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
4
2
|
import { useRef } from "react";
|
|
5
3
|
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
@@ -7,20 +5,20 @@ import { matchMedia } from "../helpers/matchMedia";
|
|
|
7
5
|
import { useConstant } from "./useConstant";
|
|
8
6
|
const mediaState = {};
|
|
9
7
|
const mediaQueryListeners = {};
|
|
10
|
-
const addMediaQueryListener =
|
|
8
|
+
const addMediaQueryListener = (key, cb) => {
|
|
11
9
|
mediaQueryListeners[key] = mediaQueryListeners[key] || /* @__PURE__ */ new Set();
|
|
12
10
|
mediaQueryListeners[key].add(cb);
|
|
13
|
-
}
|
|
14
|
-
const removeMediaQueryListener =
|
|
11
|
+
};
|
|
12
|
+
const removeMediaQueryListener = (key, cb) => {
|
|
15
13
|
var _a;
|
|
16
14
|
(_a = mediaQueryListeners[key]) == null ? void 0 : _a.delete(cb);
|
|
17
|
-
}
|
|
15
|
+
};
|
|
18
16
|
let hasConfigured = false;
|
|
19
17
|
const mediaQueryConfig = {};
|
|
20
|
-
const getMedia =
|
|
18
|
+
const getMedia = () => {
|
|
21
19
|
return mediaState;
|
|
22
|
-
}
|
|
23
|
-
const configureMedia =
|
|
20
|
+
};
|
|
21
|
+
const configureMedia = ({
|
|
24
22
|
queries,
|
|
25
23
|
defaultActive = ["sm", "xs"]
|
|
26
24
|
} = {}) => {
|
|
@@ -48,8 +46,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
};
|
|
51
|
-
|
|
52
|
-
const getMatch = /* @__PURE__ */ __name(() => matchMedia(str), "getMatch");
|
|
49
|
+
const getMatch = () => matchMedia(str);
|
|
53
50
|
const match = getMatch();
|
|
54
51
|
if (!match || typeof match.addListener !== "function") {
|
|
55
52
|
throw new Error("\u26A0\uFE0F No match (seeing this in RN sometimes)");
|
|
@@ -63,8 +60,8 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
63
60
|
mediaState[propKey] = isDefaultActive;
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
|
-
}
|
|
67
|
-
const useMedia =
|
|
63
|
+
};
|
|
64
|
+
const useMedia = () => {
|
|
68
65
|
const forceUpdate = useForceUpdate();
|
|
69
66
|
const state = useRef();
|
|
70
67
|
if (!state.current) {
|
|
@@ -125,11 +122,10 @@ const useMedia = /* @__PURE__ */ __name(() => {
|
|
|
125
122
|
}
|
|
126
123
|
});
|
|
127
124
|
});
|
|
128
|
-
}
|
|
125
|
+
};
|
|
129
126
|
function camelToHyphen(str) {
|
|
130
127
|
return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase();
|
|
131
128
|
}
|
|
132
|
-
__name(camelToHyphen, "camelToHyphen");
|
|
133
129
|
function mediaObjectToString(query) {
|
|
134
130
|
if (typeof query === "string") {
|
|
135
131
|
return query;
|
|
@@ -145,7 +141,6 @@ function mediaObjectToString(query) {
|
|
|
145
141
|
return `(${feature}: ${value})`;
|
|
146
142
|
}).join(" and ");
|
|
147
143
|
}
|
|
148
|
-
__name(mediaObjectToString, "mediaObjectToString");
|
|
149
144
|
export {
|
|
150
145
|
addMediaQueryListener,
|
|
151
146
|
configureMedia,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useMedia.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport { useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { matchMedia } from '../helpers/matchMedia'\nimport {\n ConfigureMediaQueryOptions,\n MediaQueries,\n MediaQueryKey,\n MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useConstant } from './useConstant'\n\nexport const mediaState: MediaQueryState = {} as any\nconst mediaQueryListeners: { [key: string]: Set<Function> } = {}\n\nexport const addMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key] = mediaQueryListeners[key] || new Set()\n mediaQueryListeners[key].add(cb)\n}\n\nexport const removeMediaQueryListener = (key: string, cb: any) => {\n mediaQueryListeners[key]?.delete(cb)\n}\n\nlet hasConfigured = false\nexport const mediaQueryConfig: MediaQueries = {}\n\nexport const getMedia = () => {\n return mediaState\n}\n\nexport const configureMedia = ({\n queries,\n defaultActive = ['sm', 'xs'],\n}: ConfigureMediaQueryOptions = {}) => {\n if (hasConfigured) {\n console.warn(\n `Already configured mediaQueries once (you may have called getMedia() before configureMedia())`\n )\n }\n\n if (queries) {\n Object.assign(mediaQueryConfig, queries)\n hasConfigured = true\n }\n\n // setup\n for (const key in queries) {\n const str = mediaObjectToString(queries[key])\n const propKey = `$${key}`\n try {\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match || typeof match.addListener !== 'function') {\n // caught below\n throw new Error('\u26A0\uFE0F No match (seeing this in RN sometimes)')\n }\n mediaState[propKey] = !!match.matches\n match.addListener(update)\n\n function update() {\n const next = !!getMatch().matches\n if (next === mediaState[propKey]) return\n mediaState[propKey] = next\n const listeners = mediaQueryListeners[propKey]\n if (listeners?.size) {\n for (const cb of [...listeners]) {\n cb()\n }\n }\n }\n\n update()\n } catch (err: any) {\n console.error('Error running media query', str, err.message, err.stack)\n const isDefaultActive = defaultActive?.includes(key as any) ?? true\n mediaState[propKey] = isDefaultActive\n }\n }\n}\n\ntype UseMediaState = {\n selections: { [key: string]: boolean }\n nextSelections: { [key: string]: boolean }\n isRendering: boolean\n isUnmounted: boolean\n}\n\nexport const useMedia = () => {\n const forceUpdate = useForceUpdate()\n const state = useRef() as React.MutableRefObject<UseMediaState>\n if (!state.current) {\n state.current = {\n selections: {},\n nextSelections: {},\n isUnmounted: false,\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n // delete old\n for (const key in st.selections) {\n if (!(key in st.nextSelections)) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n // add new\n for (const key in st.nextSelections) {\n if (!(key in st.selections)) {\n addMediaQueryListener(key, forceUpdate)\n }\n }\n })\n\n // unmount\n useIsomorphicLayoutEffect(() => {\n return () => {\n const st = state.current\n st.isUnmounted = true\n const allKeys = {\n ...st.selections,\n ...st.nextSelections,\n }\n for (const key in allKeys) {\n removeMediaQueryListener(key, forceUpdate)\n }\n }\n }, [])\n\n return useConstant(() => {\n const st = state.current\n return new Proxy(\n mediaState as {\n [key in MediaQueryKey]: boolean\n },\n {\n get(target, key: string) {\n if (key[0] !== '$') {\n key = `$${key}`\n }\n if (!(key in mediaState)) {\n return Reflect.get(target, key)\n }\n if (!st.isUnmounted) {\n if (st.isRendering) {\n st.nextSelections[key] = true\n }\n }\n if (key in mediaState) {\n return mediaState[key]\n }\n return Reflect.get(mediaState, key)\n },\n }\n )\n })\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": "
|
|
5
|
+
"mappings": "AAAA;AACA;AAEA;AACA;AAQA;AAEO,MAAM,aAA8B,CAAC;AAC5C,MAAM,sBAAwD,CAAC;AAExD,MAAM,wBAAwB,CAAC,KAAa,OAAY;AAC7D,sBAAoB,OAAO,oBAAoB,QAAQ,oBAAI,IAAI;AAC/D,sBAAoB,KAAK,IAAI,EAAE;AACjC;AAEO,MAAM,2BAA2B,CAAC,KAAa,OAAY;AAtBlE;AAuBE,4BAAoB,SAApB,mBAA0B,OAAO;AACnC;AAEA,IAAI,gBAAgB;AACb,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E,YAAY,GAAG,EAAE,YAAY;AACzE;AAEO,6BAA6B,OAAkC;AACpE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,OAAO,QAAQ,KAAK,EACxB,IAAI,CAAC,CAAC,SAAS,WAAW;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": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
var _a, _b;
|
|
4
2
|
import { Pressable } from "react-native";
|
|
5
3
|
const getPressable = (_b = (_a = Pressable) == null ? void 0 : _a["type"]) == null ? void 0 : _b["render"];
|
|
6
|
-
const usePressable =
|
|
4
|
+
const usePressable = (props) => {
|
|
7
5
|
const out = getPressable(props);
|
|
8
6
|
const { children, style, ...pressableProps } = out.props;
|
|
9
7
|
return [pressableProps, style];
|
|
10
|
-
}
|
|
8
|
+
};
|
|
11
9
|
export {
|
|
12
10
|
usePressable
|
|
13
11
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/usePressable.tsx"],
|
|
4
4
|
"sourcesContent": ["import { Pressable, PressableProps } from 'react-native'\n\nconst getPressable = Pressable?.['type']?.['render']\n\nexport const usePressable = (props: PressableProps) => {\n const out = getPressable(props)\n const { children, style, ...pressableProps } = out.props\n return [pressableProps, style] as const\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAAA;AAEA,MAAM,eAAe,6CAAY,YAAZ,mBAAsB;AAEpC,MAAM,eAAe,CAAC,UAA0B;AACrD,QAAM,MAAM,aAAa,KAAK;AAC9B,QAAM,EAAE,UAAU,UAAU,mBAAmB,IAAI;AACnD,SAAO,CAAC,gBAAgB,KAAK;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
4
2
|
import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
3
|
import { getConfig } from "../conf";
|
|
@@ -8,7 +6,7 @@ import { areEqualSets } from "../helpers/areEqualSets";
|
|
|
8
6
|
import { ThemeContext } from "../ThemeContext";
|
|
9
7
|
import { ThemeManager, ThemeManagerContext, emptyManager } from "../ThemeManager";
|
|
10
8
|
import { useConstant } from "./useConstant";
|
|
11
|
-
const useTheme =
|
|
9
|
+
const useTheme = (themeName, componentName, props, forceUpdate) => {
|
|
12
10
|
const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(themeName, componentName, props, forceUpdate);
|
|
13
11
|
if (process.env.NODE_ENV === "development") {
|
|
14
12
|
if ((props == null ? void 0 : props.debug) === "verbose") {
|
|
@@ -91,12 +89,12 @@ const useTheme = /* @__PURE__ */ __name((themeName, componentName, props, forceU
|
|
|
91
89
|
}
|
|
92
90
|
});
|
|
93
91
|
}, [name, theme, className, didChangeTheme]);
|
|
94
|
-
}
|
|
92
|
+
};
|
|
95
93
|
const GetThemeManager = Symbol("GetThemeManager");
|
|
96
|
-
const getThemeManagerIfChanged =
|
|
94
|
+
const getThemeManagerIfChanged = (theme) => {
|
|
97
95
|
return theme == null ? void 0 : theme[GetThemeManager];
|
|
98
|
-
}
|
|
99
|
-
const useThemeName =
|
|
96
|
+
};
|
|
97
|
+
const useThemeName = (opts) => {
|
|
100
98
|
const parent = useContext(ThemeManagerContext);
|
|
101
99
|
const [name, setName] = useState((parent == null ? void 0 : parent.name) || "");
|
|
102
100
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -110,12 +108,12 @@ const useThemeName = /* @__PURE__ */ __name((opts) => {
|
|
|
110
108
|
});
|
|
111
109
|
}, [parent]);
|
|
112
110
|
return name;
|
|
113
|
-
}
|
|
114
|
-
const useDefaultThemeName =
|
|
111
|
+
};
|
|
112
|
+
const useDefaultThemeName = () => {
|
|
115
113
|
var _a;
|
|
116
114
|
return (_a = useContext(ThemeContext)) == null ? void 0 : _a.defaultTheme;
|
|
117
|
-
}
|
|
118
|
-
const useChangeThemeEffect =
|
|
115
|
+
};
|
|
116
|
+
const useChangeThemeEffect = (name, componentName, props, forceUpdateProp) => {
|
|
119
117
|
const debug = props && props["debug"];
|
|
120
118
|
const parentManager = useContext(ThemeManagerContext) || emptyManager;
|
|
121
119
|
const { themes } = useContext(ThemeContext);
|
|
@@ -156,7 +154,7 @@ const useChangeThemeEffect = /* @__PURE__ */ __name((name, componentName, props,
|
|
|
156
154
|
themes,
|
|
157
155
|
themeManager
|
|
158
156
|
};
|
|
159
|
-
}
|
|
157
|
+
};
|
|
160
158
|
export {
|
|
161
159
|
getThemeManagerIfChanged,
|
|
162
160
|
useChangeThemeEffect,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
4
|
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport { ThemeContext } from '../ThemeContext'\nimport { GetNextThemeProps, ThemeManager, ThemeManagerContext, emptyManager } from '../ThemeManager'\nimport { ThemeName, ThemeObject } from '../types'\nimport { useConstant } from './useConstant'\n\nexport type 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\ntype 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): ThemeObject => {\n const { name, theme, themes, themeManager, className, didChangeTheme } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n console.log(' \u00BB useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\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 return useMemo(() => {\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || 'light' || Object.keys(themes)[0]]\n }\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (!name || key === '__proto__' || typeof key === 'symbol') {\n // TODO make this pattern better\n if (key === GetThemeManager) {\n if (process.env.NODE_ENV === 'development' && props?.debug) {\n console.log('>>', { themeName, didChangeTheme, name, componentName }, themeManager)\n }\n if (!didChangeTheme) return null\n return themeManager\n }\n return Reflect.get(_, key)\n }\n if (typeof key !== 'string' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n const val = themeManager.getValue(key)\n if (val) {\n if (state.current.isRendering) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development') {\n if (props?.['debug'] === 'verbose') {\n console.log(' \u00BB tracking theme key', key)\n }\n }\n }\n return val\n }\n },\n })\n }, [name, theme, className, didChangeTheme])\n}\n\nconst GetThemeManager = Symbol('GetThemeManager')\n\nexport const getThemeManagerIfChanged = (theme: any) => {\n return theme?.[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\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 useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = { name, componentName, themes, reset }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n const forceUpdate = forceUpdateProp || useForceUpdate()\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) return null\n return new ThemeManager(next.name, next.theme, parentManager, reset)\n })\n\n if (!isWeb || typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (next?.name) {\n themeManager.update(next)\n }\n return parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n }, [themes, name, componentName, debug, next?.name])\n }\n\n const didChangeTheme = next && parentManager && next.name !== parentManager.fullName\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n didChangeTheme,\n themes,\n themeManager,\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAkBO,MAAM,WAAW,CACtB,WACA,eACA,OACA,gBACgB;AAChB,QAAM,EAAE,MAAM,OAAO,QAAQ,cAAc,WAAW,mBAAmB,qBACvE,WACA,eACA,OACA,WACF;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,gCAAO,WAAU,WAAW;AAC9B,cAAQ,IAAI,mBAAgB,EAAE,WAAW,eAAe,MAAM,UAAU,CAAC;AAAA,IAC3E;AAAA,EACF;AAEA,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,MAAM,CAAC;AAAA,MACP,MAAM,oBAAI,IAAI;AAAA,MACd,aAAa;AAAA,IACf;AAAA,EACF;AACA,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AACjB,UAAM,MAAM,6CAAc,KAAK,IAAI,GAAG;AACtC,QAAI,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,GAAG,GAAG;AACvC,mDAAc,MAAM,GAAG,MAAM,GAAG;AAAA,IAClC;AAAA,EACF,CAAC;AAED,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC,OAAO;AACV,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,gBAAQ,KAAK,YAAY,EAAE,WAAW,OAAO,eAAe,UAAU,CAAC;AAAA,MACzE;AACA,aAAO,OAAO,UAAU,EAAE,gBAAgB;AAAA,IAC5C;AACA,WAAO,IAAI,MAAM,OAAO;AAAA,MACtB,IAAI,GAAG,KAAK;AACV,YAAI,OAAO,QAAQ,UAAU;AAC3B,cAAI,IAAI,OAAO,KAAK;AAClB,kBAAM,IAAI,MAAM,CAAC;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;AAAA,MACF,CAAC;AAAA,IACH,GAAG,CAAC,QAAQ,MAAM,eAAe,OAAO,6BAAM,IAAI,CAAC;AAAA,EACrD;AAEA,QAAM,iBAAiB,QAAQ,iBAAiB,KAAK,SAAS,cAAc;AAE5E,SAAO;AAAA,IACL,GAAI,iBAAiB;AAAA,MACnB,MAAM,cAAc;AAAA,MACpB,OAAO,cAAc;AAAA,IACvB;AAAA,IACA,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { useEffect } from "react";
|
|
4
2
|
function useUnmountEffect(callback) {
|
|
5
3
|
return useEffect(() => () => callback(), []);
|
|
6
4
|
}
|
|
7
|
-
__name(useUnmountEffect, "useUnmountEffect");
|
|
8
5
|
export {
|
|
9
6
|
useUnmountEffect
|
|
10
7
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useUnmountEffect.ts"],
|
|
4
4
|
"sourcesContent": ["import { useEffect } from 'react'\n\nexport function useUnmountEffect(callback: () => void) {\n return useEffect(() => () => callback(), [])\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAEO,0BAA0B,UAAsB;AACrD,SAAO,UAAU,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC;AAC7C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/insertFont.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { setConfigFont } from "./conf";
|
|
4
2
|
import { createFont } from "./createFont";
|
|
5
3
|
import { createVariables } from "./createVariables";
|
|
@@ -9,10 +7,9 @@ function insertFont(name, fontIn) {
|
|
|
9
7
|
const tokened = createVariables(font, name);
|
|
10
8
|
const parsed = parseFont(tokened);
|
|
11
9
|
registerFontVariables(parsed);
|
|
12
|
-
setConfigFont(name, parsed);
|
|
10
|
+
setConfigFont(name, tokened, parsed);
|
|
13
11
|
return parsed;
|
|
14
12
|
}
|
|
15
|
-
__name(insertFont, "insertFont");
|
|
16
13
|
function parseFont(definition) {
|
|
17
14
|
const parsed = {};
|
|
18
15
|
for (const attrKey in definition) {
|
|
@@ -32,7 +29,6 @@ function parseFont(definition) {
|
|
|
32
29
|
}
|
|
33
30
|
return parsed;
|
|
34
31
|
}
|
|
35
|
-
__name(parseFont, "parseFont");
|
|
36
32
|
function registerFontVariables(parsedFont) {
|
|
37
33
|
for (const fkey in parsedFont) {
|
|
38
34
|
if (fkey === "family") {
|
|
@@ -48,7 +44,6 @@ function registerFontVariables(parsedFont) {
|
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
|
-
__name(registerFontVariables, "registerFontVariables");
|
|
52
47
|
export {
|
|
53
48
|
insertFont,
|
|
54
49
|
parseFont,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/insertFont.ts"],
|
|
4
|
-
"sourcesContent": ["import { setConfigFont } from './conf'\nimport { createFont } from './createFont'\nimport { Variable } from './createVariable'\nimport { DeepVariableObject, createVariables } from './createVariables'\nimport { registerCSSVariable } from './helpers/registerCSSVariable'\nimport { GenericFont } from './types'\n\nexport function insertFont<A extends GenericFont>(name: string, fontIn: A): DeepVariableObject<A> {\n const font = createFont(fontIn)\n const tokened = createVariables(font, name) as GenericFont\n const parsed = parseFont(tokened) as DeepVariableObject<A>\n registerFontVariables(parsed)\n setConfigFont(name, parsed)\n return parsed\n}\n\nexport function parseFont<A extends GenericFont>(definition: A): DeepVariableObject<A> {\n const parsed: any = {}\n for (const attrKey in definition) {\n const attr = definition[attrKey]\n if (attrKey === 'family') {\n parsed[attrKey] = attr\n continue\n }\n parsed[attrKey] = {}\n for (const key in attr) {\n let val = attr[key] as any as Variable\n // is a theme reference\n if (val.val[0] === '$') {\n val = val.val\n }\n parsed[attrKey][`$${key}`] = val\n }\n }\n return parsed\n}\n\nexport function registerFontVariables(parsedFont: any) {\n for (const fkey in parsedFont) {\n if (fkey === 'family') {\n registerCSSVariable(parsedFont[fkey])\n } else {\n for (const fskey in parsedFont[fkey]) {\n const fval = parsedFont[fkey][fskey]\n if (typeof fval === 'string') {\n // no need to add its a theme reference\n // tokenRules.add(`--var()`)\n } else {\n registerCSSVariable(parsedFont[fkey][fskey])\n }\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { setConfigFont } from './conf'\nimport { createFont } from './createFont'\nimport { Variable } from './createVariable'\nimport { DeepVariableObject, createVariables } from './createVariables'\nimport { registerCSSVariable } from './helpers/registerCSSVariable'\nimport { GenericFont } from './types'\n\nexport function insertFont<A extends GenericFont>(name: string, fontIn: A): DeepVariableObject<A> {\n const font = createFont(fontIn)\n const tokened = createVariables(font, name) as GenericFont\n const parsed = parseFont(tokened) as DeepVariableObject<A>\n registerFontVariables(parsed)\n setConfigFont(name, tokened, parsed)\n return parsed\n}\n\nexport function parseFont<A extends GenericFont>(definition: A): DeepVariableObject<A> {\n const parsed: any = {}\n for (const attrKey in definition) {\n const attr = definition[attrKey]\n if (attrKey === 'family') {\n parsed[attrKey] = attr\n continue\n }\n parsed[attrKey] = {}\n for (const key in attr) {\n let val = attr[key] as any as Variable\n // is a theme reference\n if (val.val[0] === '$') {\n val = val.val\n }\n parsed[attrKey][`$${key}`] = val\n }\n }\n return parsed\n}\n\nexport function registerFontVariables(parsedFont: any) {\n for (const fkey in parsedFont) {\n if (fkey === 'family') {\n registerCSSVariable(parsedFont[fkey])\n } else {\n for (const fskey in parsedFont[fkey]) {\n const fval = parsedFont[fkey][fskey]\n if (typeof fval === 'string') {\n // no need to add its a theme reference\n // tokenRules.add(`--var()`)\n } else {\n registerCSSVariable(parsedFont[fkey][fskey])\n }\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AAEA;AACA;AAGO,oBAA2C,MAAc,QAAkC;AAChG,QAAM,OAAO,WAAW,MAAM;AAC9B,QAAM,UAAU,gBAAgB,MAAM,IAAI;AAC1C,QAAM,SAAS,UAAU,OAAO;AAChC,wBAAsB,MAAM;AAC5B,gBAAc,MAAM,SAAS,MAAM;AACnC,SAAO;AACT;AAEO,mBAA0C,YAAsC;AACrF,QAAM,SAAc,CAAC;AACrB,aAAW,WAAW,YAAY;AAChC,UAAM,OAAO,WAAW;AACxB,QAAI,YAAY,UAAU;AACxB,aAAO,WAAW;AAClB;AAAA,IACF;AACA,WAAO,WAAW,CAAC;AACnB,eAAW,OAAO,MAAM;AACtB,UAAI,MAAM,KAAK;AAEf,UAAI,IAAI,IAAI,OAAO,KAAK;AACtB,cAAM,IAAI;AAAA,MACZ;AACA,aAAO,SAAS,IAAI,SAAS;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;AAEO,+BAA+B,YAAiB;AACrD,aAAW,QAAQ,YAAY;AAC7B,QAAI,SAAS,UAAU;AACrB,0BAAoB,WAAW,KAAK;AAAA,IACtC,OAAO;AACL,iBAAW,SAAS,WAAW,OAAO;AACpC,cAAM,OAAO,WAAW,MAAM;AAC9B,YAAI,OAAO,SAAS,UAAU;AAAA,QAG9B,OAAO;AACL,8BAAoB,WAAW,MAAM,MAAM;AAAA,QAC7C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/styled.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { Image, Text, TextInput } from "react-native";
|
|
4
2
|
import { createComponent } from "./createComponent";
|
|
5
3
|
import { RNComponents } from "./helpers/RNComponents";
|
|
@@ -46,7 +44,6 @@ function styled(Component, options, staticExtractionOptions) {
|
|
|
46
44
|
const component = createComponent(staticConfigProps, Component);
|
|
47
45
|
return component;
|
|
48
46
|
}
|
|
49
|
-
__name(styled, "styled");
|
|
50
47
|
export {
|
|
51
48
|
styled
|
|
52
49
|
};
|
package/dist/esm/styled.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.tsx"],
|
|
4
4
|
"sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // for now wrapping a styled() around an extractable() HOC (like Button) isn't allowed\n if (process.env.NODE_ENV === 'development') {\n if (Component['staticConfig'] && Component['staticConfig'].isExtractable) {\n console.warn(\n `Warning: Wrapping styled() around an extractable HOC component isn't allowed yet. Support for this is on the roadmap, see: https://github.com/tamagui/tamagui/issues/88.`\n )\n // return (props) => {\n // // @ts-ignore\n // return <Component {...options} {...props} />\n // }\n }\n }\n\n const staticConfigProps = (() => {\n if (options) {\n const { variants, name, defaultVariants, ...defaultProps } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNativeWeb =\n 'staticConfig' in Component\n ? Component.staticConfig.isReactNativeWeb\n : RNComponents.has(Component)\n const reactNativeWebComponent = isReactNativeWeb\n ? Component['staticConfig']?.reactNativeWebComponent || Component\n : null\n const isTamagui = !isReactNativeWeb && 'staticConfig' in Component\n const Comp = reactNativeWebComponent || (Component as any)\n const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false))\n const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false))\n const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false))\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n isTamagui,\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNativeWeb,\n // for nesting multiple levels of rnw styled() need keep use the OG component\n reactNativeWebComponent,\n isInput,\n isText,\n isImage,\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = ParentComponent extends TamaguiComponent<any, any, infer P>\n ? P\n : GetProps<ParentComponent>\n type ParentVariants = ParentComponent extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n return component as TamaguiComponent<\n Props,\n // TODO infer ref\n any,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// breaking...\n// TODO see core/types.ts bug\n\n// export const XStack = styled(Stack, {\n// variants: {\n// horizontal: {\n// true: {\n// // flexDirection: 'row',\n// width: 0,\n// },\n// },\n// },\n// })\n\n// const Separator = styled(Stack, {\n// variants: {\n// vertical: {\n// true: {\n// flexDirection: 'row',\n// },\n// },\n// },\n// <--- have to add as const to get working???\n// })\n\n// type props = GetProps<typeof XStack>\n// type variants = typeof XStack extends TamaguiComponent<any, infer Variants> ? Variants : never\n// type variants2 = typeof Separator extends TamaguiComponent<any, infer Variants> ? Variants : never\n\n// const x = <XStack horizontal />\n// const x2 = <Separator vertical />\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAEA;AACA;AAoBO,gBAIL,WAEA,SAMA,yBACA;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,UAAU,mBAAmB,UAAU,gBAAgB,eAAe;AACxE,cAAQ,KACN,0KACF;AAAA,IAKF;AAAA,EACF;AAEA,QAAM,oBAAqB,OAAM;AAlDnC;AAmDI,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,iBAAiB;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,mBACJ,kBAAkB,YACd,UAAU,aAAa,mBACvB,aAAa,IAAI,SAAS;AAChC,YAAM,0BAA0B,mBAC5B,iBAAU,oBAAV,mBAA2B,4BAA2B,YACtD;AACJ,YAAM,YAAY,CAAC,oBAAoB,kBAAkB;AACzD,YAAM,OAAO,2BAA4B;AACzC,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,QAAQ;AAC1E,YAAM,UAAU,CAAC,CAAE,cAAa,WAAY,EAAC,YAAY,SAAS,YAAY;AAC9E,YAAM,SAAS,CAAC,CAAE,cAAa,UAAW,EAAC,YAAY,WAAW,SAAS,OAAO;AAElF,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AA4B9D,SAAO;AAOT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Slot.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { composeRefs } from "@tamagui/compose-refs";
|
|
4
2
|
import * as React from "react";
|
|
5
3
|
import { isWeb } from "../constants/platform";
|
|
@@ -23,9 +21,9 @@ const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
|
23
21
|
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
24
22
|
});
|
|
25
23
|
SlotClone.displayName = "SlotClone";
|
|
26
|
-
const Slottable =
|
|
24
|
+
const Slottable = ({ children }) => {
|
|
27
25
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
28
|
-
}
|
|
26
|
+
};
|
|
29
27
|
const pressMap = isWeb ? {
|
|
30
28
|
onPress: "onClick",
|
|
31
29
|
onPressOut: "onMouseUp",
|
|
@@ -61,7 +59,6 @@ function mergeProps(child, slotProps) {
|
|
|
61
59
|
}
|
|
62
60
|
return { ...slotProps, ...overrideProps };
|
|
63
61
|
}
|
|
64
|
-
__name(mergeProps, "mergeProps");
|
|
65
62
|
const handleRegex = /^on[A-Z]/;
|
|
66
63
|
function mergeEvent(a, b) {
|
|
67
64
|
return (...args) => {
|
|
@@ -69,7 +66,6 @@ function mergeEvent(a, b) {
|
|
|
69
66
|
b == null ? void 0 : b(...args);
|
|
70
67
|
};
|
|
71
68
|
}
|
|
72
|
-
__name(mergeEvent, "mergeEvent");
|
|
73
69
|
export {
|
|
74
70
|
Slot,
|
|
75
71
|
Slottable,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Slot.tsx"],
|
|
4
4
|
"sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\nimport { isWeb } from '../constants/platform'\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 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 ...mergeProps(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\n// function isSlottable(child: React.ReactNode): child is React.ReactElement {\n// return React.isValidElement(child)\n// }\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeProps(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?.(...args)\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAEA;AACA;AAEA;AAUO,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAM,EAAE,aAAa,cAAc;AACnC,SACE,oCAAC;AAAA,IAAW,GAAG;AAAA,IAAW,KAAK;AAAA,KAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAAM,WAAgC,CAAC,OAAO,iBAAiB;AAC/E,QAAM,EAAE,aAAa,cAAc;AAEnC,MAAI,MAAM,eAAe,QAAQ,GAAG;AAClC,UAAM,aAAa;AAAA,MACjB,GAAG,WAAW,UAAU,SAAS;AAAA,MACj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,GAAG;AACP,2BAAI,GAAG;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
var _a, _b;
|
|
4
2
|
import React, { createContext } from "react";
|
|
5
3
|
import { rnw } from "../constants/rnw";
|
|
6
4
|
const FallbackNativeContext = createContext(false);
|
|
7
5
|
const TextAncestorContext = (_b = (_a = rnw) == null ? void 0 : _a.TextAncestorContext) != null ? _b : FallbackNativeContext;
|
|
8
|
-
const TextAncestorProvider =
|
|
6
|
+
const TextAncestorProvider = (props) => {
|
|
9
7
|
return /* @__PURE__ */ React.createElement(TextAncestorContext.Provider, {
|
|
10
8
|
value: false
|
|
11
9
|
}, props.children);
|
|
12
|
-
}
|
|
10
|
+
};
|
|
13
11
|
export {
|
|
14
12
|
FallbackNativeContext,
|
|
15
13
|
TextAncestorContext,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/TextAncestorContext.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { createContext } from 'react'\n\nimport { rnw } from '../constants/rnw'\n\nexport const FallbackNativeContext = createContext(false)\n\nexport const TextAncestorContext = rnw?.TextAncestorContext ?? FallbackNativeContext\n\nexport const TextAncestorProvider = (props) => {\n return <TextAncestorContext.Provider value={false}>{props.children}</TextAncestorContext.Provider>\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAAA;AAEA;AAEO,MAAM,wBAAwB,cAAc,KAAK;AAEjD,MAAM,sBAAsB,uCAAK,wBAAL,YAA4B;AAExD,MAAM,uBAAuB,CAAC,UAAU;AAC7C,SAAO,oCAAC,oBAAoB,UAApB;AAAA,IAA6B,OAAO;AAAA,KAAQ,MAAM,QAAS;AACrE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Theme.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import React, { memo, useMemo } from "react";
|
|
4
2
|
import { isWeb } from "../constants/platform";
|
|
5
3
|
import { wrapThemeManagerContext } from "../helpers/wrapThemeManagerContext";
|
|
6
4
|
import { useChangeThemeEffect } from "../hooks/useTheme";
|
|
7
5
|
React["createElement"];
|
|
8
|
-
const Theme = memo(
|
|
6
|
+
const Theme = memo(function Theme2(props) {
|
|
9
7
|
var _a, _b;
|
|
10
8
|
const { name, theme, themeManager, themes, className } = useChangeThemeEffect(props.name, props.componentName, props);
|
|
11
9
|
const missingTheme = !themes || !name || !theme;
|
|
@@ -26,7 +24,7 @@ const Theme = memo(/* @__PURE__ */ __name(function Theme2(props) {
|
|
|
26
24
|
}, contents);
|
|
27
25
|
}
|
|
28
26
|
return contents;
|
|
29
|
-
}
|
|
27
|
+
});
|
|
30
28
|
export {
|
|
31
29
|
Theme
|
|
32
30
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Theme.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../hooks/useTheme'\nimport { ThemeProps } from '../hooks/useTheme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n props.componentName,\n props\n )\n\n const missingTheme = !themes || !name || !theme\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => (missingTheme ? null : wrapThemeManagerContext(props.children, themeManager)),\n [props.children, themeManager]\n )\n\n if (missingTheme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n if (isWeb) {\n return (\n <span\n className={(!props.disableThemeClass\n ? [props.className, className].filter(Boolean)\n : []\n ).join(' ')}\n style={{\n display: 'contents',\n // in order to provide currentColor, set color by default\n color: themes[name]?.color?.toString(),\n }}\n >\n {contents}\n </span>\n )\n }\n\n return contents\n})\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAEA;AACA;AACA;AAIA,MAAM;AAEC,MAAM,QAAQ,KAAK,gBAAe,OAAmB;AAV5D;AAWE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,MAAM,eACN,KACF;AAEA,QAAM,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC;AAI1C,QAAM,WAAW,QACf,MAAO,eAAe,OAAO,wBAAwB,MAAM,UAAU,YAAY,GACjF,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,cAAc;AAChB,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,OAAO;AACT,WACE,oCAAC;AAAA,MACC,WAAY,EAAC,MAAM,oBACf,CAAC,MAAM,WAAW,SAAS,EAAE,OAAO,OAAO,IAC3C,CAAC,GACH,KAAK,GAAG;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import React, { useState } from "react";
|
|
4
2
|
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
5
3
|
import { useDefaultThemeName, useThemeName } from "../hooks/useTheme";
|
|
@@ -11,8 +9,7 @@ let inversions = {
|
|
|
11
9
|
function setThemeInversions(next) {
|
|
12
10
|
inversions = next;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
const ThemeInverse = /* @__PURE__ */ __name((props) => {
|
|
12
|
+
const ThemeInverse = (props) => {
|
|
16
13
|
const themeName = useThemeName();
|
|
17
14
|
const defaultTheme = useDefaultThemeName();
|
|
18
15
|
const [name, setName] = useState(null);
|
|
@@ -22,7 +19,7 @@ const ThemeInverse = /* @__PURE__ */ __name((props) => {
|
|
|
22
19
|
return /* @__PURE__ */ React.createElement(Theme, {
|
|
23
20
|
name
|
|
24
21
|
}, props.children);
|
|
25
|
-
}
|
|
22
|
+
};
|
|
26
23
|
export {
|
|
27
24
|
ThemeInverse,
|
|
28
25
|
setThemeInversions
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeInverse.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { useState } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { useDefaultThemeName, useThemeName } from '../hooks/useTheme'\nimport { Theme } from './Theme'\n\ntype StringRecord = { [key: string]: string }\n\nlet inversions: StringRecord = {\n light: 'dark',\n dark: 'light',\n}\n\nexport function setThemeInversions(next: StringRecord) {\n inversions = next\n}\n\nexport const ThemeInverse = (props: { children: any }) => {\n const themeName = useThemeName()\n const defaultTheme = useDefaultThemeName()\n const [name, setName] = useState<null | string>(null)\n\n // ssr\n useIsomorphicLayoutEffect(() => {\n setName(inversions[themeName] || inversions[defaultTheme || ''] || null)\n }, [defaultTheme, themeName])\n\n return <Theme name={name}>{props.children}</Theme>\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAEA;AACA;AACA;AAIA,IAAI,aAA2B;AAAA,EAC7B,OAAO;AAAA,EACP,MAAM;AACR;AAEO,4BAA4B,MAAoB;AACrD,eAAa;AACf;AAEO,MAAM,eAAe,CAAC,UAA6B;AACxD,QAAM,YAAY,aAAa;AAC/B,QAAM,eAAe,oBAAoB;AACzC,QAAM,CAAC,MAAM,WAAW,SAAwB,IAAI;AAGpD,4BAA0B,MAAM;AAC9B,YAAQ,WAAW,cAAc,WAAW,gBAAgB,OAAO,IAAI;AAAA,EACzE,GAAG,CAAC,cAAc,SAAS,CAAC;AAE5B,SAAO,oCAAC;AAAA,IAAM;AAAA,KAAa,MAAM,QAAS;AAC5C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|