@tamagui/core 1.0.0-beta.179 → 1.0.0-beta.200
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/constants/pseudos.js +37 -0
- package/dist/cjs/constants/pseudos.js.map +7 -0
- package/dist/cjs/createComponent.js +22 -19
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createShallowUpdate.js +1 -0
- package/dist/cjs/createShallowUpdate.js.map +7 -0
- package/dist/cjs/devtools.js +32 -0
- package/dist/cjs/devtools.js.map +7 -0
- package/dist/cjs/helpers/RNComponents.js +34 -0
- package/dist/cjs/helpers/RNComponents.js.map +7 -0
- package/dist/cjs/helpers/createMediaStyle.js +3 -6
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createShallowUpdate.js +51 -0
- package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
- package/dist/cjs/helpers/createTamaguiProvider.js +1 -5
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +0 -4
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/hooks/useFeatures.js +1 -0
- package/dist/cjs/hooks/useFeatures.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +5 -31
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/styled.js +2 -12
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/tamagui-base.css +8 -0
- package/dist/cjs/tamagui-base.css.map +7 -0
- package/dist/cjs/types-rnw.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Stack.js.map +2 -2
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/Theme.js +4 -16
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/esm/constants/pseudos.js +18 -0
- package/dist/esm/constants/pseudos.js.map +7 -0
- package/dist/esm/createComponent.js +22 -19
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createShallowUpdate.js +1 -0
- package/dist/esm/createShallowUpdate.js.map +7 -0
- package/dist/esm/devtools.js +14 -0
- package/dist/esm/devtools.js.map +7 -0
- package/dist/esm/helpers/RNComponents.js +12 -0
- package/dist/esm/helpers/RNComponents.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +3 -6
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createShallowUpdate.js +19 -0
- package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
- package/dist/esm/helpers/createTamaguiProvider.js +1 -4
- package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +0 -4
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/hooks/useFeatures.js +1 -0
- package/dist/esm/hooks/useFeatures.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +5 -31
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/styled.js +1 -8
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/tamagui-base.css +8 -0
- package/dist/esm/tamagui-base.css.map +7 -0
- package/dist/esm/views/Stack.js.map +2 -2
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Theme.js +4 -16
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/jsx/constants/pseudos.js +17 -0
- package/dist/jsx/createComponent.js +18 -15
- package/dist/jsx/createShallowUpdate.js +0 -0
- package/dist/jsx/devtools.js +13 -0
- package/dist/jsx/helpers/RNComponents.js +11 -0
- package/dist/jsx/helpers/createMediaStyle.js +3 -6
- package/dist/jsx/helpers/createShallowUpdate.js +18 -0
- package/dist/jsx/helpers/createTamaguiProvider.js +1 -2
- package/dist/jsx/helpers/getSplitStyles.js +0 -4
- package/dist/jsx/hooks/useFeatures.js +1 -0
- package/dist/jsx/hooks/useMedia.js +5 -31
- package/dist/jsx/styled.js +1 -8
- package/dist/jsx/tamagui-base.css +7 -0
- package/dist/jsx/views/Theme.js +4 -16
- package/package.json +6 -6
- package/types/createComponent.d.ts +5 -6
- package/types/createComponent.d.ts.map +1 -1
- package/types/defaultComponentState.d.ts +0 -12
- package/types/defaultComponentState.d.ts.map +1 -1
- package/types/helpers/RNComponents.d.ts +2 -0
- package/types/helpers/RNComponents.d.ts.map +1 -0
- package/types/helpers/createMediaStyle.d.ts +1 -1
- package/types/helpers/createMediaStyle.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +2 -2
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/createShallowUpdate.d.ts +4 -0
- package/types/helpers/createShallowUpdate.d.ts.map +1 -0
- package/types/helpers/createTamaguiProvider.d.ts +1 -1
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +3 -14
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/hooks/useFeatures.d.ts +7 -5
- package/types/hooks/useFeatures.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/styled.d.ts +3 -7
- package/types/styled.d.ts.map +1 -1
- package/types/types-rnw.d.ts +0 -5
- package/types/types-rnw.d.ts.map +1 -1
- package/types/types.d.ts +77 -64
- package/types/types.d.ts.map +1 -1
- package/types/views/Stack.d.ts +2 -2
- package/types/views/Stack.d.ts.map +1 -1
- package/types/views/Text.d.ts +2 -2
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useFeatures.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\nimport { ViewStyle } from 'react-native'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { ComponentState } from '../defaultComponentState'\nimport { PseudoStyles } from '../static'\nimport { UseAnimationHook } from '../types'\nimport { addMediaQueryListener, mediaState, removeMediaQueryListener } from './useMedia'\n\ntype FeatureDefinition = {\n isEnabled: (props: any) => boolean\n Component: any\n}\n\ntype FeatureUtils = {\n forceUpdate: Function\n state: ComponentState\n setStateShallow: (next: Partial<ComponentState>) => void\n useAnimations?: UseAnimationHook\n pseudos: PseudoStyles\n style: ViewStyle | null | undefined\n}\n\nconst createDefinition = ({\n Component,\n propNames,\n}: {\n Component: (props: { _utils: FeatureUtils; [key: string]: any }) => void\n propNames: string[]\n}): FeatureDefinition => ({\n isEnabled: (props: any) => propNames.some((name) => !!props[name]),\n Component,\n})\n\nlet featureDefinitions: Record<string, FeatureDefinition> | null = null\n\nexport const useFeatures = (props: any, utils?: FeatureUtils) => {\n if (!featureDefinitions) {\n featureDefinitions = loadFeatures()\n }\n const features: JSX.Element[] = []\n for (const name in featureDefinitions) {\n const { isEnabled, Component } = featureDefinitions[name]\n if (isEnabled(props) && Component) {\n features.push(<Component key={name} {...props} _utils={utils} />)\n }\n }\n return features\n}\n\nfunction loadFeatures(): Record<string, FeatureDefinition> {\n return {\n // loads animations and sets state with the results\n animation: loadAnimationFeature(),\n\n // will update the parent whenever media query changes\n // no need on web, media queries are inserted and run in css\n ...(!isWeb && {\n mediaQuery: loadMediaQueryFeature(),\n }),\n }\n}\n\nfunction loadAnimationFeature() {\n return createDefinition({\n Component: ({ _utils, ...props }) => {\n const { state, useAnimations, pseudos, style, setStateShallow } = _utils\n\n if (!useAnimations) {\n console.error('no useAnimations hook provided')\n return null\n }\n\n const animatedStyleIn = {\n ...style,\n ...(state.hover && pseudos.hoverStyle),\n ...(state.focus && pseudos.focusStyle),\n ...(state.press && pseudos.pressStyle),\n }\n\n const res = useAnimations(props as any, {\n isMounted: state.mounted,\n style: animatedStyleIn,\n exitStyle: pseudos?.exitStyle,\n // onDidAnimate, delay\n })\n\n useIsomorphicLayoutEffect(() => {\n setStateShallow({\n animation: res,\n })\n }, [JSON.stringify(style)])\n\n return null\n },\n propNames: ['animation'],\n })\n}\n\nfunction loadMediaQueryFeature() {\n const mediaPropNames = Object.keys(mediaState)\n\n return createDefinition({\n Component: (props: any) => {\n const keys = mediaPropNames.flatMap((x) => (x in props ? x.slice(1) : []))\n\n useIsomorphicLayoutEffect(() => {\n for (const key of keys) {\n addMediaQueryListener(key, props._utils.forceUpdate)\n }\n return () => {\n for (const key of keys) {\n removeMediaQueryListener(key, props._utils.forceUpdate)\n }\n }\n }, [keys.join(',')])\n\n return null\n },\n propNames: mediaPropNames,\n })\n}\n\n// TODO\n// measureLayout: createDefinition({\n// Component: (props) => {\n// console.log('measure', props)\n// return null\n// },\n// propNames: ['onLayout'],\n// }),\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAGA;AAIA;AAgBA,MAAM,mBAAmB,wBAAC;AAAA,EACxB;AAAA,EACA;AAAA,MAIwB;AAAA,EACxB,WAAW,CAAC,UAAe,UAAU,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK;AAAA,EACjE;AACF,IATyB;AAWzB,IAAI,qBAA+D;AAE5D,MAAM,cAAc,wBAAC,OAAY,UAAyB;AAC/D,MAAI,CAAC,oBAAoB;AACvB,yBAAqB,aAAa;AAAA,EACpC;AACA,QAAM,WAA0B,CAAC;AACjC,aAAW,QAAQ,oBAAoB;AACrC,UAAM,EAAE,WAAW,cAAc,mBAAmB;AACpD,QAAI,UAAU,KAAK,KAAK,WAAW;AACjC,eAAS,KAAK,oCAAC;AAAA,QAAU,KAAK;AAAA,WAAU;AAAA,QAAO,QAAQ;AAAA,OAAO,CAAE;AAAA,IAClE;AAAA,EACF;AACA,SAAO;AACT,GAZ2B;AAc3B,wBAA2D;AACzD,SAAO;AAAA,IAEL,WAAW,qBAAqB;AAAA,OAI5B,CAAC,SAAS;AAAA,MACZ,YAAY,sBAAsB;AAAA,IACpC;AAAA,EACF;AACF;AAXS;AAaT,gCAAgC;AAC9B,SAAO,iBAAiB;AAAA,IACtB,WAAW,CAAC,EAAE,WAAW,YAAY;AACnC,YAAM,EAAE,OAAO,eAAe,SAAS,OAAO,oBAAoB;AAElE,UAAI,CAAC,eAAe;AAClB,gBAAQ,MAAM,gCAAgC;AAC9C,eAAO;AAAA,MACT;AAEA,YAAM,kBAAkB;AAAA,WACnB;AAAA,WACC,MAAM,SAAS,QAAQ;AAAA,WACvB,MAAM,SAAS,QAAQ;AAAA,WACvB,MAAM,SAAS,QAAQ;AAAA,MAC7B;AAEA,YAAM,MAAM,cAAc,OAAc;AAAA,QACtC,WAAW,MAAM;AAAA,QACjB,OAAO;AAAA,QACP,WAAW,mCAAS;AAAA,MAEtB,CAAC;AAED,gCAA0B,MAAM;AAC9B,wBAAgB;AAAA,UACd,WAAW;AAAA,QACb,CAAC;AAAA,MACH,GAAG,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAE1B,aAAO;AAAA,IACT;AAAA,IACA,WAAW,CAAC,WAAW;AAAA,EACzB,CAAC;AACH;
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport { ViewStyle } from 'react-native'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { ComponentState } from '../defaultComponentState'\nimport { PseudoStyles } from '../static'\nimport { UseAnimationHook } from '../types'\nimport { addMediaQueryListener, mediaState, removeMediaQueryListener } from './useMedia'\n\ntype FeatureDefinition = {\n isEnabled: (props: any) => boolean\n Component: any\n}\n\ntype FeatureUtils = {\n forceUpdate: Function\n state: ComponentState\n setStateShallow: (next: Partial<ComponentState>) => void\n useAnimations?: UseAnimationHook\n pseudos: PseudoStyles\n style: ViewStyle | null | undefined\n}\n\nconst createDefinition = ({\n Component,\n propNames,\n}: {\n Component: (props: { _utils: FeatureUtils; [key: string]: any }) => void\n propNames: string[]\n}): FeatureDefinition => ({\n isEnabled: (props: any) => propNames.some((name) => !!props[name]),\n Component,\n})\n\nlet featureDefinitions: Record<string, FeatureDefinition> | null = null\n\nexport const useFeatures = (props: any, utils?: FeatureUtils) => {\n if (!featureDefinitions) {\n featureDefinitions = loadFeatures()\n }\n const features: JSX.Element[] = []\n for (const name in featureDefinitions) {\n const { isEnabled, Component } = featureDefinitions[name]\n if (isEnabled(props) && Component) {\n features.push(<Component key={name} {...props} _utils={utils} />)\n }\n }\n return features\n}\n\nfunction loadFeatures(): Record<string, FeatureDefinition> {\n return {\n // loads animations and sets state with the results\n animation: loadAnimationFeature(),\n\n // will update the parent whenever media query changes\n // no need on web, media queries are inserted and run in css\n ...(!isWeb && {\n mediaQuery: loadMediaQueryFeature(),\n }),\n }\n}\n\nfunction loadAnimationFeature() {\n return createDefinition({\n Component: ({ _utils, ...props }) => {\n const { state, useAnimations, pseudos, style, setStateShallow } = _utils\n\n if (!useAnimations) {\n console.error('no useAnimations hook provided')\n return null\n }\n\n const animatedStyleIn = {\n ...style,\n ...(state.hover && pseudos.hoverStyle),\n ...(state.focus && pseudos.focusStyle),\n ...(state.press && pseudos.pressStyle),\n }\n\n const res = useAnimations(props as any, {\n isMounted: state.mounted,\n style: animatedStyleIn,\n exitStyle: pseudos?.exitStyle,\n // onDidAnimate, delay\n })\n\n useIsomorphicLayoutEffect(() => {\n console.log('setting', res, JSON.stringify(style))\n setStateShallow({\n animation: res,\n })\n }, [JSON.stringify(style)])\n\n return null\n },\n propNames: ['animation'],\n })\n}\n\nfunction loadMediaQueryFeature() {\n const mediaPropNames = Object.keys(mediaState)\n\n return createDefinition({\n Component: (props: any) => {\n const keys = mediaPropNames.flatMap((x) => (x in props ? x.slice(1) : []))\n\n useIsomorphicLayoutEffect(() => {\n for (const key of keys) {\n addMediaQueryListener(key, props._utils.forceUpdate)\n }\n return () => {\n for (const key of keys) {\n removeMediaQueryListener(key, props._utils.forceUpdate)\n }\n }\n }, [keys.join(',')])\n\n return null\n },\n propNames: mediaPropNames,\n })\n}\n\n// TODO\n// measureLayout: createDefinition({\n// Component: (props) => {\n// console.log('measure', props)\n// return null\n// },\n// propNames: ['onLayout'],\n// }),\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGA;AAIA;AAgBA,MAAM,mBAAmB,wBAAC;AAAA,EACxB;AAAA,EACA;AAAA,MAIwB;AAAA,EACxB,WAAW,CAAC,UAAe,UAAU,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK;AAAA,EACjE;AACF,IATyB;AAWzB,IAAI,qBAA+D;AAE5D,MAAM,cAAc,wBAAC,OAAY,UAAyB;AAC/D,MAAI,CAAC,oBAAoB;AACvB,yBAAqB,aAAa;AAAA,EACpC;AACA,QAAM,WAA0B,CAAC;AACjC,aAAW,QAAQ,oBAAoB;AACrC,UAAM,EAAE,WAAW,cAAc,mBAAmB;AACpD,QAAI,UAAU,KAAK,KAAK,WAAW;AACjC,eAAS,KAAK,oCAAC;AAAA,QAAU,KAAK;AAAA,WAAU;AAAA,QAAO,QAAQ;AAAA,OAAO,CAAE;AAAA,IAClE;AAAA,EACF;AACA,SAAO;AACT,GAZ2B;AAc3B,wBAA2D;AACzD,SAAO;AAAA,IAEL,WAAW,qBAAqB;AAAA,OAI5B,CAAC,SAAS;AAAA,MACZ,YAAY,sBAAsB;AAAA,IACpC;AAAA,EACF;AACF;AAXS;AAaT,gCAAgC;AAC9B,SAAO,iBAAiB;AAAA,IACtB,WAAW,CAAC,EAAE,WAAW,YAAY;AACnC,YAAM,EAAE,OAAO,eAAe,SAAS,OAAO,oBAAoB;AAElE,UAAI,CAAC,eAAe;AAClB,gBAAQ,MAAM,gCAAgC;AAC9C,eAAO;AAAA,MACT;AAEA,YAAM,kBAAkB;AAAA,WACnB;AAAA,WACC,MAAM,SAAS,QAAQ;AAAA,WACvB,MAAM,SAAS,QAAQ;AAAA,WACvB,MAAM,SAAS,QAAQ;AAAA,MAC7B;AAEA,YAAM,MAAM,cAAc,OAAc;AAAA,QACtC,WAAW,MAAM;AAAA,QACjB,OAAO;AAAA,QACP,WAAW,mCAAS;AAAA,MAEtB,CAAC;AAED,gCAA0B,MAAM;AAC9B,gBAAQ,IAAI,WAAW,KAAK,KAAK,UAAU,KAAK,CAAC;AACjD,wBAAgB;AAAA,UACd,WAAW;AAAA,QACb,CAAC;AAAA,MACH,GAAG,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAE1B,aAAO;AAAA,IACT;AAAA,IACA,WAAW,CAAC,WAAW;AAAA,EACzB,CAAC;AACH;AAnCS;AAqCT,iCAAiC;AAC/B,QAAM,iBAAiB,OAAO,KAAK,UAAU;AAE7C,SAAO,iBAAiB;AAAA,IACtB,WAAW,CAAC,UAAe;AACzB,YAAM,OAAO,eAAe,QAAQ,CAAC,MAAO,KAAK,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAE;AAEzE,gCAA0B,MAAM;AAC9B,mBAAW,OAAO,MAAM;AACtB,gCAAsB,KAAK,MAAM,OAAO,WAAW;AAAA,QACrD;AACA,eAAO,MAAM;AACX,qBAAW,OAAO,MAAM;AACtB,qCAAyB,KAAK,MAAM,OAAO,WAAW;AAAA,UACxD;AAAA,QACF;AAAA,MACF,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC;AAEnB,aAAO;AAAA,IACT;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AACH;AAtBS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,36 +15,9 @@ const removeMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
|
15
15
|
var _a;
|
|
16
16
|
(_a = mediaQueryListeners[key]) == null ? void 0 : _a.delete(cb);
|
|
17
17
|
}, "removeMediaQueryListener");
|
|
18
|
-
let
|
|
19
|
-
const mediaQueryConfig =
|
|
20
|
-
get(target, key) {
|
|
21
|
-
if (key === "$$typeof") {
|
|
22
|
-
return Reflect.get(target, key);
|
|
23
|
-
}
|
|
24
|
-
if (!conf) {
|
|
25
|
-
console.warn("Tamagui: accessing media query before init");
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return Reflect.get(conf, key);
|
|
29
|
-
},
|
|
30
|
-
ownKeys() {
|
|
31
|
-
if (!conf) {
|
|
32
|
-
console.warn("Tamagui: accessing media query before init");
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
return Object.keys(conf);
|
|
36
|
-
},
|
|
37
|
-
getOwnPropertyDescriptor() {
|
|
38
|
-
return {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
});
|
|
18
|
+
let hasConfigured = false;
|
|
19
|
+
const mediaQueryConfig = {};
|
|
44
20
|
const getMedia = /* @__PURE__ */ __name(() => {
|
|
45
|
-
if (!conf) {
|
|
46
|
-
throw new Error(`not configured yet`);
|
|
47
|
-
}
|
|
48
21
|
return mediaState;
|
|
49
22
|
}, "getMedia");
|
|
50
23
|
const configureMedia = /* @__PURE__ */ __name(({
|
|
@@ -52,11 +25,12 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
52
25
|
defaultActive = ["sm", "xs"]
|
|
53
26
|
} = {}) => {
|
|
54
27
|
var _a;
|
|
55
|
-
if (
|
|
28
|
+
if (hasConfigured) {
|
|
56
29
|
console.warn(`Already configured mediaQueries once (you may have called getMedia() before configureMedia())`);
|
|
57
30
|
}
|
|
58
31
|
if (queries) {
|
|
59
|
-
|
|
32
|
+
Object.assign(mediaQueryConfig, queries);
|
|
33
|
+
hasConfigured = true;
|
|
60
34
|
}
|
|
61
35
|
for (const key in queries) {
|
|
62
36
|
const str = mediaObjectToString(queries[key]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useMedia.tsx"],
|
|
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 MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useConstant } from './useConstant'\n\nexport const mediaState: { [key in keyof MediaQueryState]: boolean } = {} 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
|
|
5
|
-
"mappings": ";;AAAA;AACA;AAEA;AACA;AAOA;AAEO,MAAM,aAA0D,CAAC;AACxE,MAAM,sBAAwD,CAAC;AAExD,MAAM,wBAAwB,wBAAC,KAAa,OAAY;AAC7D,sBAAoB,OAAO,oBAAoB,QAAQ,oBAAI,IAAI;AAC/D,sBAAoB,KAAK,IAAI,EAAE;AACjC,GAHqC;AAK9B,MAAM,2BAA2B,wBAAC,KAAa,OAAY;AArBlE;AAsBE,4BAAoB,SAApB,mBAA0B,OAAO;AACnC,GAFwC;AAIxC,IAAI,
|
|
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 MediaQueryObject,\n MediaQueryState,\n} from '../types'\nimport { useConstant } from './useConstant'\n\nexport const mediaState: { [key in keyof MediaQueryState]: boolean } = {} 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 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[key] = !!match.matches\n match.addListener(() => {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n mediaState[key] = next\n const listeners = mediaQueryListeners[key]\n if (listeners?.size) {\n for (const cb of [...listeners]) {\n cb()\n }\n }\n })\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[key] = 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(mediaState, {\n get(target, key: string) {\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\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;AACA;AAEA;AACA;AAOA;AAEO,MAAM,aAA0D,CAAC;AACxE,MAAM,sBAAwD,CAAC;AAExD,MAAM,wBAAwB,wBAAC,KAAa,OAAY;AAC7D,sBAAoB,OAAO,oBAAoB,QAAQ,oBAAI,IAAI;AAC/D,sBAAoB,KAAK,IAAI,EAAE;AACjC,GAHqC;AAK9B,MAAM,2BAA2B,wBAAC,KAAa,OAAY;AArBlE;AAsBE,4BAAoB,SAApB,mBAA0B,OAAO;AACnC,GAFwC;AAIxC,IAAI,gBAAgB;AACb,MAAM,mBAAiC,CAAC;AAExC,MAAM,WAAW,6BAAM;AAC5B,SAAO;AACT,GAFwB;AAIjB,MAAM,iBAAiB,wBAAC;AAAA,EAC7B;AAAA,EACA,gBAAgB,CAAC,MAAM,IAAI;AAAA,IACG,CAAC,MAAM;AAnCvC;AAoCE,MAAI,eAAe;AACjB,YAAQ,KACN,+FACF;AAAA,EACF;AAEA,MAAI,SAAS;AACX,WAAO,OAAO,kBAAkB,OAAO;AACvC,oBAAgB;AAAA,EAClB;AAGA,aAAW,OAAO,SAAS;AACzB,UAAM,MAAM,oBAAoB,QAAQ,IAAI;AAC5C,QAAI;AACF,YAAM,WAAW,6BAAM,WAAW,GAAG,GAApB;AACjB,YAAM,QAAQ,SAAS;AACvB,UAAI,CAAC,SAAS,OAAO,MAAM,gBAAgB,YAAY;AAErD,cAAM,IAAI,MAAM,qDAA2C;AAAA,MAC7D;AACA,iBAAW,OAAO,CAAC,CAAC,MAAM;AAC1B,YAAM,YAAY,MAAM;AACtB,cAAM,OAAO,CAAC,CAAC,SAAS,EAAE;AAC1B,YAAI,SAAS,WAAW;AAAM;AAC9B,mBAAW,OAAO;AAClB,cAAM,YAAY,oBAAoB;AACtC,YAAI,uCAAW,MAAM;AACnB,qBAAW,MAAM,CAAC,GAAG,SAAS,GAAG;AAC/B,eAAG;AAAA,UACL;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,SAAS,KAAP;AACA,cAAQ,MAAM,6BAA6B,KAAK,IAAI,SAAS,IAAI,KAAK;AACtE,YAAM,kBAAkB,qDAAe,SAAS,SAAxB,YAAuC;AAC/D,iBAAW,OAAO;AAAA,IACpB;AAAA,EACF;AACF,GA3C8B;AAoDvB,MAAM,WAAW,6BAAM;AAC5B,QAAM,cAAc,eAAe;AACnC,QAAM,QAAQ,OAAO;AACrB,MAAI,CAAC,MAAM,SAAS;AAClB,UAAM,UAAU;AAAA,MACd,YAAY,CAAC;AAAA,MACb,gBAAgB,CAAC;AAAA,MACjB,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAAA,EACF;AACA,QAAM,QAAQ,cAAc;AAG5B,4BAA0B,MAAM;AAC9B,UAAM,KAAK,MAAM;AACjB,OAAG,cAAc;AAEjB,eAAW,OAAO,GAAG,YAAY;AAC/B,UAAI,CAAE,QAAO,GAAG,iBAAiB;AAC/B,iCAAyB,KAAK,WAAW;AAAA,MAC3C;AAAA,IACF;AAEA,eAAW,OAAO,GAAG,gBAAgB;AACnC,UAAI,CAAE,QAAO,GAAG,aAAa;AAC3B,8BAAsB,KAAK,WAAW;AAAA,MACxC;AAAA,IACF;AAAA,EACF,CAAC;AAGD,4BAA0B,MAAM;AAC9B,WAAO,MAAM;AACX,YAAM,KAAK,MAAM;AACjB,SAAG,cAAc;AACjB,YAAM,UAAU;AAAA,WACX,GAAG;AAAA,WACH,GAAG;AAAA,MACR;AACA,iBAAW,OAAO,SAAS;AACzB,iCAAyB,KAAK,WAAW;AAAA,MAC3C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,YAAY,MAAM;AACvB,UAAM,KAAK,MAAM;AACjB,WAAO,IAAI,MAAM,YAAY;AAAA,MAC3B,IAAI,QAAQ,KAAa;AACvB,YAAI,CAAE,QAAO,aAAa;AACxB,iBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,QAChC;AACA,YAAI,CAAC,GAAG,aAAa;AACnB,cAAI,GAAG,aAAa;AAClB,eAAG,eAAe,OAAO;AAAA,UAC3B;AAAA,QACF;AACA,YAAI,OAAO,YAAY;AACrB,iBAAO,WAAW;AAAA,QACpB;AACA,eAAO,QAAQ,IAAI,YAAY,GAAG;AAAA,MACpC;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH,GAjEwB;AAmExB,uBAAuB,KAAa;AAClC,SAAO,IAAI,QAAQ,UAAU,CAAC,MAAM,IAAI,EAAE,YAAY,GAAG,EAAE,YAAY;AACzE;AAFS;AAIF,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;AAhBgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/styled.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as ReactNative from "react-native";
|
|
4
3
|
import { Image, Text, TextInput } from "react-native";
|
|
5
4
|
import { createComponent } from "./createComponent";
|
|
6
5
|
import { extendStaticConfig } from "./helpers/extendStaticConfig";
|
|
7
|
-
|
|
8
|
-
for (const key of ["Image", "TextInput", "Text", "View"]) {
|
|
9
|
-
const val = ReactNative[key];
|
|
10
|
-
if (val && typeof val === "object") {
|
|
11
|
-
RNComponents.set(val, true);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
6
|
+
import { RNComponents } from "./helpers/RNComponents";
|
|
14
7
|
function styled(Component, options, staticExtractionOptions) {
|
|
15
8
|
const staticConfigProps = (() => {
|
|
16
9
|
if (options) {
|
package/dist/esm/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;AAAA;
|
|
4
|
+
"sourcesContent": ["import { Image, Text, TextInput } from 'react-native'\n\nimport { createComponent } from './createComponent'\nimport { extendStaticConfig } from './helpers/extendStaticConfig'\nimport { RNComponents } from './helpers/RNComponents'\nimport {\n GetProps,\n GetVariantProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n VariantDefinitions,\n} from './types'\n\nexport function styled<\n ParentComponent extends StylableComponent,\n // = VariantDefinitions<GetProps<ParentComponent>> gives type inference to variants: { true: { ... } }\n // but causes \"Type instantiation is excessively deep and possibly infinite.\"...\n Variants extends VariantDefinitions<{}> = {}\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 defaultVariants?: Variants extends Object ? GetVariantProps<Variants> : never\n },\n staticExtractionOptions?: StaticConfig\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 = RNComponents.has(Component)\n const isTamagui = !isReactNativeWeb && 'staticConfig' in Component\n const Comp = 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 const conf: 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 componentName: name,\n isReactNativeWeb,\n isInput,\n isText,\n isImage,\n }\n return conf\n }\n return {}\n })()\n const config = extendStaticConfig(Component, staticConfigProps)\n const component = createComponent(config!) // error is good here its on init\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>\n ? V\n : Object\n\n // sprinkle in our variants\n type OurVariants = Variants extends Object\n ? {\n [Key in keyof Variants]?: GetVariantValues<keyof Variants[Key]>\n }\n : {}\n\n type VariantProps = ParentVariants & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void | symbol\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<OurPropsBase> &\n // add in pseudos\n PseudoProps<OurPropsBase>\n\n return component as TamaguiComponent<\n Props,\n // TODO infer ref\n any,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n}\n\n// type Merge<A, B> = Omit<A, keyof B> & B\n// import { Stack } from './views/Stack'\n// export const SizableText = styled(Stack, {\n// name: 'SizableText',\n// backgroundColor: 'red',\n// variants: {\n// size: {\n// '...fontSize': (val, { props }) => {\n// return {\n// backgroundColor: '',\n// }\n// },\n// },\n// },\n// })\n// export const Paragraph = styled(SizableText, {\n// name: 'Paragraph',\n// tag: 'p',\n// // variants: {\n// // another: {\n// // true: {}\n// // }\n// // }\n// })\n// export const Paragraph2 = styled(Paragraph, {\n// name: 'Paragraph',\n// tag: 'p',\n// variants: {\n// another: {\n// true: {\n// color: 'red'\n// },\n// }\n// }\n// })\n// const a = <SizableText size=\"$10\" />\n// const y = <Paragraph2 size=\"$10\" another />\n// export const SizableText2 = styled(SizableText, {\n// })\n// const xx = <SizableText2 abc />\n// export const Paragraph = styled(SizableText, {\n// name: 'Paragraph',\n// })\n// export const Heading = styled(Paragraph, {\n// tag: 'span',\n// margin: 0,\n// })\n// export const H2 = styled(Heading, {\n// name: 'H2',\n// })\n// const x = <H2 color=\"red\" />\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AAaO,gBAML,WAEA,SAKA,yBACA;AACA,QAAM,oBAAqB,OAAM;AAC/B,QAAI,SAAS;AACX,YAAM,EAAE,UAAU,MAAM,oBAAoB,iBAAiB;AAC7D,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,mBAAmB,aAAa,IAAI,SAAS;AACnD,YAAM,YAAY,CAAC,oBAAoB,kBAAkB;AACzD,YAAM,OAAO;AACb,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;AAClF,YAAM,OAAqB;AAAA,WACtB;AAAA,WACC,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QACA;AAAA,QAGA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AACH,QAAM,SAAS,mBAAmB,WAAW,iBAAiB;AAC9D,QAAM,YAAY,gBAAgB,MAAO;AA6BzC,SAAO;AAOT;AApFgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Stack.tsx"],
|
|
4
|
-
"sourcesContent": ["import { View } from 'react-native'\n\nimport { stackDefaultStyles } from '../constants/constants'\nimport { createComponent } from '../createComponent'\nimport { StackProps } from '../types'\n\nexport const Stack = createComponent<StackProps, View>({\n defaultProps: {\n ...stackDefaultStyles,\n flexDirection: 'column',\n },\n})\n\n// test types\n// export const YStack = styled(Stack, {\n// flexDirection: 'column',\n// })\n// // test types\n// const x00 = <Stack missing={0} /> // should err\n// const x0 = <YStack missing={0} /> // should err\n// const x1 = (props: StackProps) => <YStack {...props} />\n// type ys = typeof YStack\n// type ysv = ys extends StaticComponent<any, infer V> ? V : unknown\n"],
|
|
5
|
-
"mappings": "AAEA;AACA;AAGO,MAAM,QAAQ,
|
|
4
|
+
"sourcesContent": ["import { View } from 'react-native'\n\nimport { stackDefaultStyles } from '../constants/constants'\nimport { createComponent } from '../createComponent'\nimport { StackProps, StackPropsBase } from '../types'\n\nexport const Stack = createComponent<StackProps, View, StackPropsBase>({\n defaultProps: {\n ...stackDefaultStyles,\n flexDirection: 'column',\n },\n})\n\n// test types\n// export const YStack = styled(Stack, {\n// flexDirection: 'column',\n// })\n// // test types\n// const x00 = <Stack missing={0} /> // should err\n// const x0 = <YStack missing={0} /> // should err\n// const x1 = (props: StackProps) => <YStack {...props} />\n// type ys = typeof YStack\n// type ysv = ys extends StaticComponent<any, infer V> ? V : unknown\n"],
|
|
5
|
+
"mappings": "AAEA;AACA;AAGO,MAAM,QAAQ,gBAAkD;AAAA,EACrE,cAAc;AAAA,OACT;AAAA,IACH,eAAe;AAAA,EACjB;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Text.tsx"],
|
|
4
|
-
"sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView>({\n isText: true,\n defaultProps: {\n display: isWeb ? 'inline' : 'flex',\n boxSizing: 'border-box',\n fontFamily: 'System',\n wordWrap: 'break-word',\n },\n variants: {\n numberOfLines: {\n 1: ellipseStyle,\n // TODO imply fn, test 1, could do types `>1` `<2`\n ':number': (lines) => (lines > 1 ? { WebkitLineClamp: 1 } : null),\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n ...(isWeb && {\n userSelect: true,\n textOverflow: true,\n whiteSpace: true,\n wordWrap: true,\n selectable: true,\n cursor: true,\n }),\n },\n})\n"],
|
|
5
|
-
"mappings": "AAAA;AAGA;AACA;AAGA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,
|
|
4
|
+
"sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n isText: true,\n defaultProps: {\n display: isWeb ? 'inline' : 'flex',\n boxSizing: 'border-box',\n fontFamily: 'System',\n wordWrap: 'break-word',\n },\n variants: {\n numberOfLines: {\n 1: ellipseStyle,\n // TODO imply fn, test 1, could do types `>1` `<2`\n ':number': (lines) => (lines > 1 ? { WebkitLineClamp: 1 } : null),\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n ...(isWeb && {\n userSelect: true,\n textOverflow: true,\n whiteSpace: true,\n wordWrap: true,\n selectable: true,\n cursor: true,\n }),\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA;AAGA;AACA;AAGA,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,gBAAoD;AAAA,EACtE,QAAQ;AAAA,EACR,cAAc;AAAA,IACZ,SAAS,QAAQ,WAAW;AAAA,IAC5B,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,UAAU;AAAA,IACR,eAAe;AAAA,MACb,GAAG;AAAA,MAEH,WAAW,CAAC,UAAW,QAAQ,IAAI,EAAE,iBAAiB,EAAE,IAAI;AAAA,IAC9D;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACT,MAAM;AAAA,QACJ,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEA,SAAS;AAAA,MACP,MAAM,QACF,eACA;AAAA,QACE,eAAe;AAAA,QACf,eAAe;AAAA,MACjB;AAAA,IACN;AAAA,EACF;AAAA,EACA,YAAY,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;AAAA,EAC5C,aAAa;AAAA,OACR;AAAA,OACA;AAAA,OACC,SAAS;AAAA,MACX,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,IACV;AAAA,EACF;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Theme.js
CHANGED
|
@@ -8,28 +8,16 @@ React["createElement"];
|
|
|
8
8
|
const Theme = memo(/* @__PURE__ */ __name(function Theme2(props) {
|
|
9
9
|
var _a, _b;
|
|
10
10
|
const { name, theme, themeManager, themes, className } = useChangeThemeEffect(props.name, void 0, props);
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
return props.children;
|
|
14
|
-
}
|
|
15
|
-
return wrapThemeManagerContext(props.children, themeManager);
|
|
16
|
-
}, [props.children, themeManager]);
|
|
17
|
-
if (!themes) {
|
|
18
|
-
console.warn("Error, no themes in context", props);
|
|
19
|
-
return props.children;
|
|
20
|
-
}
|
|
21
|
-
if (!name || !theme) {
|
|
22
|
-
if (process.env.NODE_ENV === "development" && name && !theme) {
|
|
11
|
+
if (!themes || !name || !theme) {
|
|
12
|
+
if (name && !theme && process.env.NODE_ENV === "development") {
|
|
23
13
|
console.warn(`No theme found by name ${name}`);
|
|
24
14
|
}
|
|
25
15
|
return props.children;
|
|
26
16
|
}
|
|
17
|
+
const contents = useMemo(() => wrapThemeManagerContext(props.children, themeManager), [props.children, themeManager]);
|
|
27
18
|
if (isWeb) {
|
|
28
|
-
if (props.disableThemeClass) {
|
|
29
|
-
return contents;
|
|
30
|
-
}
|
|
31
19
|
return /* @__PURE__ */ React.createElement("div", {
|
|
32
|
-
className: props.className ? `${className || ""} ${props.className || ""}` : className || "",
|
|
20
|
+
className: props.disableThemeClass ? "" : props.className ? `${className || ""} ${props.className || ""}` : className || "",
|
|
33
21
|
style: {
|
|
34
22
|
display: "contents",
|
|
35
23
|
color: (_b = (_a = themes[name]) == null ? void 0 : _a.color) == null ? void 0 : _b.toString()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Theme.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../static'\nimport { ThemeName } from '../types'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n children?: any\n debug?: boolean\n}\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n undefined,\n props\n )\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(
|
|
5
|
-
"mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM;AAUC,MAAM,QAAQ,KAAK,uCAAe,OAAmB;AAlB5D;AAmBE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,QACA,KACF;
|
|
4
|
+
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../static'\nimport { ThemeName } from '../types'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n children?: any\n debug?: boolean\n}\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n undefined,\n props\n )\n\n if (!themes || !name || !theme) {\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 // 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 () => wrapThemeManagerContext(props.children, themeManager),\n [props.children, themeManager]\n )\n\n if (isWeb) {\n return (\n <div\n className={\n props.disableThemeClass\n ? ''\n : props.className\n ? `${className || ''} ${props.className || ''}`\n : className || ''\n }\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 </div>\n )\n }\n\n return contents\n})\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAEA;AACA;AACA;AAIA,MAAM;AAUC,MAAM,QAAQ,KAAK,uCAAe,OAAmB;AAlB5D;AAmBE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,qBACvD,MAAM,MACN,QACA,KACF;AAEA,MAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO;AAC9B,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAIA,QAAM,WAAW,QACf,MAAM,wBAAwB,MAAM,UAAU,YAAY,GAC1D,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,OAAO;AACT,WACE,oCAAC;AAAA,MACC,WACE,MAAM,oBACF,KACA,MAAM,YACN,GAAG,aAAa,MAAM,MAAM,aAAa,OACzC,aAAa;AAAA,MAEnB,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,GA3C0B,QA2CzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -63,7 +63,7 @@ function createComponent(configIn) {
|
|
|
63
63
|
let tamaguiConfig;
|
|
64
64
|
let AnimatedText;
|
|
65
65
|
let AnimatedView;
|
|
66
|
-
let avoidClasses =
|
|
66
|
+
let avoidClasses = true;
|
|
67
67
|
let defaultPseudos = {};
|
|
68
68
|
let defaultNativeStyle;
|
|
69
69
|
let defaultNativeStyleSheet = null;
|
|
@@ -99,7 +99,8 @@ function createComponent(configIn) {
|
|
|
99
99
|
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitInfo;
|
|
100
100
|
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
101
101
|
const isAnimated = !!(useAnimations && props.animation);
|
|
102
|
-
const
|
|
102
|
+
const hasEnterStyle = !!props.enterStyle;
|
|
103
|
+
const styleWithPseudos = props.animation ? merge({ ...defaultNativeStyle, ...style }, state.hover && pseudos.hoverStyle, state.press && pseudos.pressStyle, state.focus && pseudos.focusStyle, hasEnterStyle && !state.mounted && pseudos.enterStyle, ...Object.values(medias)) : null;
|
|
103
104
|
const features = useFeatures(props, {
|
|
104
105
|
forceUpdate,
|
|
105
106
|
setStateShallow,
|
|
@@ -160,7 +161,6 @@ function createComponent(configIn) {
|
|
|
160
161
|
}
|
|
161
162
|
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
162
163
|
const hostRef = useRef(null);
|
|
163
|
-
const hasEnterStyle = !!props.enterStyle;
|
|
164
164
|
const internal = useRef();
|
|
165
165
|
if (!internal.current) {
|
|
166
166
|
internal.current = {
|
|
@@ -258,6 +258,7 @@ function createComponent(configIn) {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
viewProps.className = className;
|
|
261
|
+
viewProps.style = animationStyles;
|
|
261
262
|
} else {
|
|
262
263
|
viewProps.style = styles;
|
|
263
264
|
}
|
|
@@ -307,6 +308,7 @@ function createComponent(configIn) {
|
|
|
307
308
|
pressIn: false
|
|
308
309
|
});
|
|
309
310
|
}, []);
|
|
311
|
+
console.log("attachHover, attachHover", attachHover, pseudos && pseudos.hoverStyle);
|
|
310
312
|
const events = shouldAttach ? {
|
|
311
313
|
...!isWeb && {
|
|
312
314
|
onPressOut: (e) => {
|
|
@@ -377,18 +379,6 @@ function createComponent(configIn) {
|
|
|
377
379
|
} : {
|
|
378
380
|
disabled: true
|
|
379
381
|
});
|
|
380
|
-
if (events) {
|
|
381
|
-
if (!isStringElement) {
|
|
382
|
-
Object.assign(viewProps, pressProps);
|
|
383
|
-
} else {
|
|
384
|
-
Object.assign(viewProps, events);
|
|
385
|
-
}
|
|
386
|
-
if (isWeb && isHoverable) {
|
|
387
|
-
childEls = <span style={{
|
|
388
|
-
display: "contents"
|
|
389
|
-
}} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{children}</span>;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
382
|
let content;
|
|
393
383
|
if (isWeb) {
|
|
394
384
|
if (staticConfig.isReactNativeWeb) {
|
|
@@ -405,7 +395,20 @@ function createComponent(configIn) {
|
|
|
405
395
|
}
|
|
406
396
|
}
|
|
407
397
|
}
|
|
398
|
+
if (events) {
|
|
399
|
+
if (!isStringElement) {
|
|
400
|
+
Object.assign(viewProps, pressProps);
|
|
401
|
+
} else {
|
|
402
|
+
Object.assign(viewProps, events);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
408
405
|
content = createElement(ViewComponent, viewProps, childEls);
|
|
406
|
+
console.log("should", attachHover);
|
|
407
|
+
if (isWeb && events && attachHover) {
|
|
408
|
+
content = <span style={{
|
|
409
|
+
display: "contents"
|
|
410
|
+
}} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{content}</span>;
|
|
411
|
+
}
|
|
409
412
|
if (process.env.NODE_ENV === "development") {
|
|
410
413
|
if (props["debug"]) {
|
|
411
414
|
viewProps["debug"] = true;
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { onConfiguredOnce } from "./conf";
|
|
2
|
+
import { insertedSelectors } from "./helpers/insertStyleRule";
|
|
3
|
+
onConfiguredOnce((conf) => {
|
|
4
|
+
if (globalThis["Tamagui"]) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
globalThis["Tamagui"] = {
|
|
8
|
+
...conf,
|
|
9
|
+
get insertedCSS() {
|
|
10
|
+
return insertedSelectors;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ReactNative from "react-native";
|
|
2
|
+
const RNComponents = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
for (const key of ["Image", "TextInput", "Text", "View"]) {
|
|
4
|
+
const val = ReactNative[key];
|
|
5
|
+
if (val && typeof val === "object") {
|
|
6
|
+
RNComponents.set(val, true);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
RNComponents
|
|
11
|
+
};
|
|
@@ -2,19 +2,16 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { mediaObjectToString } from "../hooks/useMedia";
|
|
4
4
|
const MEDIA_SEP = "_";
|
|
5
|
-
const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey, mediaQueries, negate, importance
|
|
5
|
+
const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey, mediaQueries, negate, importance) => {
|
|
6
6
|
const mediaKeys = Object.keys(mediaQueries);
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
return acc;
|
|
10
|
-
}, {});
|
|
7
|
+
const importance_ = Math.max(0, importance == void 0 ? mediaKeys.indexOf(mediaKey) : importance || 0);
|
|
8
|
+
const precendencePrefix = new Array(importance_ + 1).fill(":root").join("");
|
|
11
9
|
const negKey = negate ? "0" : "";
|
|
12
10
|
const ogPrefix = identifier.slice(0, identifier.indexOf("-") + 1);
|
|
13
11
|
const nextIdentifier = `${identifier.replace(ogPrefix, `${ogPrefix}${MEDIA_SEP}${mediaKey}${negKey}${MEDIA_SEP}`)}`;
|
|
14
12
|
const screenStr = negate ? "not all" : "screen";
|
|
15
13
|
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
16
14
|
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
17
|
-
const precendencePrefix = mediaKeyPrecendence[mediaKey];
|
|
18
15
|
const styleInner = rules[0].replace(identifier, nextIdentifier);
|
|
19
16
|
let styleRule = "";
|
|
20
17
|
if (styleInner.includes("@media")) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
function createShallowUpdate(setter) {
|
|
4
|
+
return (next) => {
|
|
5
|
+
setter((prev) => {
|
|
6
|
+
for (const key in next) {
|
|
7
|
+
if (prev[key] !== next[key]) {
|
|
8
|
+
return { ...prev, ...next };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return prev;
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
__name(createShallowUpdate, "createShallowUpdate");
|
|
16
|
+
export {
|
|
17
|
+
createShallowUpdate
|
|
18
|
+
};
|
|
@@ -10,7 +10,6 @@ function createTamaguiProvider({
|
|
|
10
10
|
}) {
|
|
11
11
|
return /* @__PURE__ */ __name(function TamaguiProvider({
|
|
12
12
|
injectCSS,
|
|
13
|
-
fallback,
|
|
14
13
|
children,
|
|
15
14
|
...themePropsProvider
|
|
16
15
|
}) {
|
|
@@ -26,7 +25,7 @@ function createTamaguiProvider({
|
|
|
26
25
|
};
|
|
27
26
|
}, []);
|
|
28
27
|
}
|
|
29
|
-
return <ButtonInsideButtonContext.Provider value={false}><TextAncestorProvider><ThemeProvider {...themeProps} {...themePropsProvider}
|
|
28
|
+
return <ButtonInsideButtonContext.Provider value={false}><TextAncestorProvider><ThemeProvider {...themeProps} {...themePropsProvider}>{children}</ThemeProvider></TextAncestorProvider></ButtonInsideButtonContext.Provider>;
|
|
30
29
|
}, "TamaguiProvider");
|
|
31
30
|
}
|
|
32
31
|
__name(createTamaguiProvider, "createTamaguiProvider");
|
|
@@ -34,7 +34,6 @@ function normalizeStyleObject(style) {
|
|
|
34
34
|
}
|
|
35
35
|
__name(normalizeStyleObject, "normalizeStyleObject");
|
|
36
36
|
const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state, defaultClassNames) => {
|
|
37
|
-
var _a, _b, _c;
|
|
38
37
|
const validStyleProps = staticConfig.isText ? stylePropsText : validStyles;
|
|
39
38
|
const viewProps = {};
|
|
40
39
|
const style = {};
|
|
@@ -134,9 +133,6 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
|
|
|
134
133
|
pseudos[key] = getSubStyle(val, staticConfig, theme, props, state.resolveVariablesAs, true);
|
|
135
134
|
if (isWeb && !state.noClassNames) {
|
|
136
135
|
const pseudoStyles = getStylesAtomic({ [key]: pseudos[key] });
|
|
137
|
-
if ((_b = (_a = pseudoStyles[0]) == null ? void 0 : _a.identifier) == null ? void 0 : _b.includes("undefined")) {
|
|
138
|
-
console.warn("undefined bug?", (_c = pseudoStyles[0]) == null ? void 0 : _c.identifier);
|
|
139
|
-
}
|
|
140
136
|
for (const style2 of pseudoStyles) {
|
|
141
137
|
mergeClassName(`${style2.property}-${key}`, style2.identifier);
|
|
142
138
|
insertStyleRule(style2.identifier, style2.rules[0]);
|
|
@@ -15,36 +15,9 @@ const removeMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
|
15
15
|
var _a;
|
|
16
16
|
(_a = mediaQueryListeners[key]) == null ? void 0 : _a.delete(cb);
|
|
17
17
|
}, "removeMediaQueryListener");
|
|
18
|
-
let
|
|
19
|
-
const mediaQueryConfig =
|
|
20
|
-
get(target, key) {
|
|
21
|
-
if (key === "$$typeof") {
|
|
22
|
-
return Reflect.get(target, key);
|
|
23
|
-
}
|
|
24
|
-
if (!conf) {
|
|
25
|
-
console.warn("Tamagui: accessing media query before init");
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return Reflect.get(conf, key);
|
|
29
|
-
},
|
|
30
|
-
ownKeys() {
|
|
31
|
-
if (!conf) {
|
|
32
|
-
console.warn("Tamagui: accessing media query before init");
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
return Object.keys(conf);
|
|
36
|
-
},
|
|
37
|
-
getOwnPropertyDescriptor() {
|
|
38
|
-
return {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
});
|
|
18
|
+
let hasConfigured = false;
|
|
19
|
+
const mediaQueryConfig = {};
|
|
44
20
|
const getMedia = /* @__PURE__ */ __name(() => {
|
|
45
|
-
if (!conf) {
|
|
46
|
-
throw new Error(`not configured yet`);
|
|
47
|
-
}
|
|
48
21
|
return mediaState;
|
|
49
22
|
}, "getMedia");
|
|
50
23
|
const configureMedia = /* @__PURE__ */ __name(({
|
|
@@ -52,11 +25,12 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
52
25
|
defaultActive = ["sm", "xs"]
|
|
53
26
|
} = {}) => {
|
|
54
27
|
var _a;
|
|
55
|
-
if (
|
|
28
|
+
if (hasConfigured) {
|
|
56
29
|
console.warn(`Already configured mediaQueries once (you may have called getMedia() before configureMedia())`);
|
|
57
30
|
}
|
|
58
31
|
if (queries) {
|
|
59
|
-
|
|
32
|
+
Object.assign(mediaQueryConfig, queries);
|
|
33
|
+
hasConfigured = true;
|
|
60
34
|
}
|
|
61
35
|
for (const key in queries) {
|
|
62
36
|
const str = mediaObjectToString(queries[key]);
|
package/dist/jsx/styled.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import * as ReactNative from "react-native";
|
|
4
3
|
import { Image, Text, TextInput } from "react-native";
|
|
5
4
|
import { createComponent } from "./createComponent";
|
|
6
5
|
import { extendStaticConfig } from "./helpers/extendStaticConfig";
|
|
7
|
-
|
|
8
|
-
for (const key of ["Image", "TextInput", "Text", "View"]) {
|
|
9
|
-
const val = ReactNative[key];
|
|
10
|
-
if (val && typeof val === "object") {
|
|
11
|
-
RNComponents.set(val, true);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
6
|
+
import { RNComponents } from "./helpers/RNComponents";
|
|
14
7
|
function styled(Component, options, staticExtractionOptions) {
|
|
15
8
|
const staticConfigProps = (() => {
|
|
16
9
|
if (options) {
|