@tamagui/core 1.0.0-alpha.0 → 1.0.0-alpha.5

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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/dist/constants/platform.js +1 -1
  3. package/dist/constants/platform.js.map +2 -2
  4. package/dist/createComponent.js +1 -1
  5. package/dist/createComponent.js.map +2 -2
  6. package/dist/hooks/useMedia.js +1 -1
  7. package/dist/hooks/useMedia.js.map +2 -2
  8. package/dist/hooks/useTheme.js +1 -1
  9. package/dist/hooks/useTheme.js.map +2 -2
  10. package/dist/index.cjs +57 -79
  11. package/dist/index.cjs.map +3 -3
  12. package/dist/index.js +0 -1
  13. package/dist/index.js.map +2 -2
  14. package/package.json +12 -4
  15. package/src/constants/platform.ts +1 -1
  16. package/src/createComponent.tsx +2 -1
  17. package/src/hooks/useMedia.tsx +1 -1
  18. package/src/hooks/useTheme.tsx +1 -1
  19. package/src/index.ts +0 -1
  20. package/types.d.ts +0 -1
  21. package/.ultra.cache.json +0 -1
  22. package/_/constants/constants.js +0 -14
  23. package/_/constants/constants.js.map +0 -7
  24. package/_/constants/platform.js +0 -20
  25. package/_/constants/platform.js.map +0 -7
  26. package/_/constants/pseudos.js +0 -18
  27. package/_/constants/pseudos.js.map +0 -7
  28. package/_/constants/rnw.js +0 -22
  29. package/_/constants/rnw.js.map +0 -7
  30. package/_/createComponent.js +0 -427
  31. package/_/createComponent.js.map +0 -7
  32. package/_/createShorthands.js +0 -10
  33. package/_/createShorthands.js.map +0 -7
  34. package/_/createTamagui.js +0 -122
  35. package/_/createTamagui.js.map +0 -7
  36. package/_/createTheme.js +0 -20
  37. package/_/createTheme.js.map +0 -7
  38. package/_/createTokens.js +0 -29
  39. package/_/createTokens.js.map +0 -7
  40. package/_/createVariable.js +0 -22
  41. package/_/createVariable.js.map +0 -7
  42. package/_/helpers/addStylesUsingClassname.js +0 -32
  43. package/_/helpers/addStylesUsingClassname.js.map +0 -7
  44. package/_/helpers/createMediaStyle.js +0 -34
  45. package/_/helpers/createMediaStyle.js.map +0 -7
  46. package/_/helpers/createTamaguiProvider.js +0 -42
  47. package/_/helpers/createTamaguiProvider.js.map +0 -7
  48. package/_/helpers/extendStaticConfig.js +0 -176
  49. package/_/helpers/extendStaticConfig.js.map +0 -7
  50. package/_/helpers/fixNativeShadow.js +0 -8
  51. package/_/helpers/fixNativeShadow.js.map +0 -7
  52. package/_/helpers/fixNativeShadow.native.js +0 -30
  53. package/_/helpers/fixNativeShadow.native.js.map +0 -7
  54. package/_/helpers/getSplitStyles.js +0 -160
  55. package/_/helpers/getSplitStyles.js.map +0 -7
  56. package/_/helpers/getStylesAtomic.js +0 -84
  57. package/_/helpers/getStylesAtomic.js.map +0 -7
  58. package/_/helpers/getStylesAtomic.native.js +0 -10
  59. package/_/helpers/getStylesAtomic.native.js.map +0 -7
  60. package/_/helpers/insertStyleRule.js +0 -24
  61. package/_/helpers/insertStyleRule.js.map +0 -7
  62. package/_/helpers/matchMedia.js +0 -15
  63. package/_/helpers/matchMedia.js.map +0 -7
  64. package/_/helpers/matchMedia.native.js +0 -8
  65. package/_/helpers/matchMedia.native.js.map +0 -7
  66. package/_/helpers/themeable.js +0 -26
  67. package/_/helpers/themeable.js.map +0 -7
  68. package/_/hooks/useConstant.js +0 -15
  69. package/_/hooks/useConstant.js.map +0 -7
  70. package/_/hooks/useFeatures.js +0 -75
  71. package/_/hooks/useFeatures.js.map +0 -7
  72. package/_/hooks/useForceUpdate.js +0 -28
  73. package/_/hooks/useForceUpdate.js.map +0 -7
  74. package/_/hooks/useMedia.js +0 -173
  75. package/_/hooks/useMedia.js.map +0 -7
  76. package/_/hooks/usePressable.js +0 -14
  77. package/_/hooks/usePressable.js.map +0 -7
  78. package/_/hooks/useTheme.js +0 -94
  79. package/_/hooks/useTheme.js.map +0 -7
  80. package/_/index.js +0 -30
  81. package/_/index.js.map +0 -7
  82. package/_/static/postProcessStyles.js +0 -18
  83. package/_/static/postProcessStyles.js.map +0 -7
  84. package/_/static.js +0 -12
  85. package/_/static.js.map +0 -7
  86. package/_/styled.js +0 -21
  87. package/_/styled.js.map +0 -7
  88. package/_/types.js +0 -1
  89. package/_/types.js.map +0 -7
  90. package/_/views/Animated.js +0 -79
  91. package/_/views/Animated.js.map +0 -7
  92. package/_/views/Stack.js +0 -12
  93. package/_/views/Stack.js.map +0 -7
  94. package/_/views/Text.js +0 -60
  95. package/_/views/Text.js.map +0 -7
  96. package/_/views/TextAncestorContext.js +0 -19
  97. package/_/views/TextAncestorContext.js.map +0 -7
  98. package/_/views/Theme.js +0 -57
  99. package/_/views/Theme.js.map +0 -7
  100. package/_/views/ThemeContext.js +0 -6
  101. package/_/views/ThemeContext.js.map +0 -7
  102. package/_/views/ThemeInverse.js +0 -27
  103. package/_/views/ThemeInverse.js.map +0 -7
  104. package/_/views/ThemeManagerContext.js +0 -56
  105. package/_/views/ThemeManagerContext.js.map +0 -7
  106. package/_/views/ThemeProvider.js +0 -45
  107. package/_/views/ThemeProvider.js.map +0 -7
  108. package/src/hooks/useForceUpdate.tsx +0 -26
  109. package/tsconfig.json +0 -8
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/getSplitStyles.tsx"],
4
- "sourcesContent": ["import {\n AllRules,\n stylePropsText,\n stylePropsTransform,\n validStyles,\n validStylesPseudo,\n} from '@tamagui/helpers'\nimport { ViewStyle } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { mediaQueryConfig } from '../hooks/useMedia'\nimport { StaticConfigParsed, ThemeObject } from '../types'\nimport { createMediaStyle } from './createMediaStyle'\nimport { fixNativeShadow } from './fixNativeShadow'\nimport { getStylesAtomic } from './getStylesAtomic'\nimport { insertStyleRule } from './insertStyleRule'\n\nexport type SplitStyles = ReturnType<typeof getSplitStyles>\n\n// TODO run over this, should be able to cut it down quite a bit\n\nexport const getSplitStyles = (\n props: { [key: string]: any },\n staticConfig: StaticConfigParsed,\n theme: ThemeObject,\n isSplittingDefaultProps?: boolean\n) => {\n const validStyleProps = staticConfig.isText ? stylePropsText : validStyles\n const viewProps: Record<string, any> = {}\n const style: any[] = []\n const blacklistProps = isSplittingDefaultProps ? blacklistDefaultProps : blacklistFinalProps\n\n let pseudos: { hoverStyle?: ViewStyle; pressStyle?: ViewStyle } | null = null\n let cur: ViewStyle | null = null\n let classNames: string[] | null = null\n\n for (const keyInit in props) {\n // be sure to sync next few lines below to getSubStyle (*1)\n const valInit = props[keyInit]\n\n // media\n if (keyInit[0] === '$') {\n const mediaKey = keyInit.slice(1)\n\n if (!mediaQueryConfig[mediaKey]) {\n // this isn't a media key, pass through\n viewProps[keyInit] = valInit\n continue\n }\n\n // dont check if media is active, we just apply *all* media styles\n // we combine the media props on top regular props, could proxy this\n // TODO test proxy here instead of merge\n const mediaProps = { ...props, ...valInit }\n // TODO media + hover\n const mediaStyle = getSubStyle(valInit, staticConfig, theme)\n const mediaStyles = getStylesAtomic(mediaStyle)\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n console.log('mediaStyles', keyInit, { mediaProps, mediaStyle, mediaStyles })\n }\n }\n for (const style of mediaStyles) {\n if (isWeb) {\n const out = createMediaStyle(style, mediaKey, mediaQueryConfig)\n classNames = classNames || []\n classNames.push(out.identifier)\n AllRules.add(out.styleRule)\n insertStyleRule(out.styleRule)\n if (process.env.NODE_ENV === 'development' && props['debug']) {\n console.log('mediaProp', style.identifier, out, mediaProps, mediaStyle, mediaStyles)\n }\n } else {\n console.log('TODO native media style logic')\n }\n }\n continue\n }\n\n // pseudo\n if (validStylesPseudo[keyInit]) {\n if (!valInit) continue\n pseudos = pseudos || {}\n pseudos[keyInit] = getSubStyle(valInit, staticConfig, theme)\n continue\n }\n\n const out = staticConfig.propMapper(keyInit, valInit, theme)\n const expanded = out === true || !out ? [[keyInit, valInit]] : Object.entries(out)\n for (const [key, val] of expanded) {\n // const val = valueMap(valInit) ?? valInit\n const keyFirstChar = key[0]\n if (key === 'style' || (keyFirstChar === '_' && key.startsWith('_style'))) {\n if (cur) {\n // process last\n fixNativeShadow(cur)\n style.push(cur)\n cur = null\n }\n fixNativeShadow(val)\n style.push(val)\n continue\n }\n // expand flex so it merged with flexShrink etc properly\n // TODO this shouldn't be here...\n if (key === 'flex') {\n cur = cur || {}\n // see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex\n // TODO this fixed a behavior but need to find / document / test\n Object.assign(cur, {\n flexGrow: val,\n flexShrink: 1,\n })\n continue\n }\n if (!isWeb && key === 'pointerEvents') {\n viewProps[key] = val\n continue\n }\n if (validStyleProps[key]) {\n // transforms\n if (key in stylePropsTransform) {\n cur = cur || {}\n mergeTransform(cur, key, val)\n continue\n }\n cur = cur || {}\n cur[key] = val\n continue\n }\n // TODO this blacklist should be configurable + better set up\n if (!blacklistProps[key]) {\n viewProps[key] = val\n }\n }\n }\n // push last style\n if (cur) {\n fixNativeShadow(cur)\n style.push(cur)\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n console.log(' \uD83E\uDD5A splitProps:', { props, viewProps, style })\n }\n }\n\n return {\n viewProps,\n style,\n pseudos,\n classNames,\n }\n}\n\nconst getSubStyle = (\n styleIn: Object,\n staticConfig: StaticConfigParsed,\n theme: ThemeObject\n): ViewStyle => {\n const styleOut: ViewStyle = {}\n for (const key in styleIn) {\n // be sure to sync next few lines below to loop above (*1)\n const val = styleIn[key]\n const out = staticConfig.propMapper(key, val, theme)\n const expanded = out === true || !out ? [[key, val]] : Object.entries(out)\n for (const [skey, sval] of expanded) {\n // const sval = valueMap(valInit)\n if (skey in stylePropsTransform) {\n mergeTransform(styleOut, skey, sval)\n } else {\n styleOut[skey] = sval\n }\n }\n }\n fixNativeShadow(styleOut)\n return styleOut\n}\n\nconst blacklistDefaultProps = {\n ...validStyles,\n ...stylePropsText,\n}\n\nconst blacklistFinalProps = {\n ...blacklistDefaultProps,\n tag: true,\n debug: true,\n space: true,\n hitSlop: true,\n}\n\nconst mapTransformKeys = {\n x: 'translateX',\n y: 'translateY',\n}\n\nconst mergeTransform = (obj: ViewStyle, key: string, val: any) => {\n const transform: any[] = obj.transform\n ? Array.isArray(obj.transform)\n ? obj.transform\n : [obj.transform]\n : []\n transform.push({ [mapTransformKeys[key] || key]: val })\n obj.transform = transform\n}\n"],
5
- "mappings": ";;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA;AACA;AAEA;AACA;AACA;AACA;AAMO,MAAM,iBAAiB,wBAC5B,OACA,cACA,OACA,4BACG;AACH,QAAM,kBAAkB,aAAa,SAAS,iBAAiB;AAC/D,QAAM,YAAiC;AACvC,QAAM,QAAe;AACrB,QAAM,iBAAiB,0BAA0B,wBAAwB;AAEzE,MAAI,UAAqE;AACzE,MAAI,MAAwB;AAC5B,MAAI,aAA8B;AAElC,aAAW,WAAW,OAAO;AAE3B,UAAM,UAAU,MAAM;AAGtB,QAAI,QAAQ,OAAO,KAAK;AACtB,YAAM,WAAW,QAAQ,MAAM;AAE/B,UAAI,CAAC,iBAAiB,WAAW;AAE/B,kBAAU,WAAW;AACrB;AAAA;AAMF,YAAM,aAAa,KAAK,UAAU;AAElC,YAAM,aAAa,YAAY,SAAS,cAAc;AACtD,YAAM,cAAc,gBAAgB;AACpC,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAI,MAAM,UAAU;AAClB,kBAAQ,IAAI,eAAe,SAAS,EAAE,YAAY,YAAY;AAAA;AAAA;AAGlE,iBAAW,UAAS,aAAa;AAC/B,YAAI,OAAO;AACT,gBAAM,OAAM,iBAAiB,QAAO,UAAU;AAC9C,uBAAa,cAAc;AAC3B,qBAAW,KAAK,KAAI;AACpB,mBAAS,IAAI,KAAI;AACjB,0BAAgB,KAAI;AACpB,cAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,UAAU;AAC5D,oBAAQ,IAAI,aAAa,OAAM,YAAY,MAAK,YAAY,YAAY;AAAA;AAAA,eAErE;AACL,kBAAQ,IAAI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AAC5B,aAAW,OAAO,SAAS;AAEzB,UAAM,MAAM,QAAQ;AACpB,UAAM,MAAM,aAAa,WAAW,KAAK,KAAK;AAC9C,UAAM,WAAW,QAAQ,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,QAAQ,OAAO,QAAQ;AACtE,eAAW,CAAC,MAAM,SAAS,UAAU;AAEnC,UAAI,QAAQ,qBAAqB;AAC/B,uBAAe,UAAU,MAAM;AAAA,aAC1B;AACL,iBAAS,QAAQ;AAAA;AAAA;AAAA;AAIvB,kBAAgB;AAChB,SAAO;AAAA,GArBW;AAwBpB,MAAM,wBAAwB;AAAA,KACzB;AAAA,KACA;AAAA;AAGL,MAAM,sBAAsB;AAAA,KACvB;AAAA,EACH,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO;AAAA,EACP,SAAS;AAAA;AAGX,MAAM,mBAAmB;AAAA,EACvB,GAAG;AAAA,EACH,GAAG;AAAA;AAGL,MAAM,iBAAiB,wBAAC,KAAgB,KAAa,QAAa;AAChE,QAAM,YAAmB,IAAI,YACzB,MAAM,QAAQ,IAAI,aAChB,IAAI,YACJ,CAAC,IAAI,aACP;AACJ,YAAU,KAAK,GAAG,iBAAiB,QAAQ,MAAM;AACjD,MAAI,YAAY;AAAA,GAPK;",
6
- "names": []
7
- }
@@ -1,84 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { AllRules } from "@tamagui/helpers";
4
- import { pseudos } from "../constants/pseudos";
5
- import { rnw } from "../constants/rnw";
6
- const generateStyle = /* @__PURE__ */ __name((style) => {
7
- const { atomic, createCompileableStyle, createReactDOMStyle, i18Style } = rnw;
8
- return {
9
- ...atomic(createCompileableStyle(createReactDOMStyle(i18Style(style))))
10
- };
11
- }, "generateStyle");
12
- const borderDefaults = {
13
- borderWidth: "borderStyle",
14
- borderBottomWidth: "borderBottomStyle",
15
- borderTopWidth: "borderTopStyle",
16
- borderLeftWidth: "borderLeftStyle",
17
- borderRightWidth: "borderRightStyle"
18
- };
19
- function getStylesAtomic(style, avoidCollection = false) {
20
- const styles = {
21
- base: {}
22
- };
23
- for (const key in style) {
24
- if (!!pseudos[key]) {
25
- styles[key] = style[key];
26
- } else {
27
- styles.base[key] = style[key];
28
- }
29
- }
30
- return Object.keys(styles).map((key) => {
31
- return getAtomicStyle(styles[key], pseudos[key], avoidCollection);
32
- }).flat();
33
- }
34
- __name(getStylesAtomic, "getStylesAtomic");
35
- const importantRegex = /\!important*/g;
36
- function getAtomicStyle(style, pseudo, avoidCollection) {
37
- var _a;
38
- if (style == null || typeof style !== "object") {
39
- throw new Error(`Wrong style type: "${typeof style}": ${style}`);
40
- }
41
- for (const key in borderDefaults) {
42
- if (key in style) {
43
- style[borderDefaults[key]] = (_a = style[borderDefaults[key]]) != null ? _a : "solid";
44
- }
45
- }
46
- const all = generateStyle(style);
47
- return Object.keys(all).map((key) => {
48
- const val = all[key];
49
- const hash = val.identifier.slice(`${val.identifier}`.lastIndexOf("-") + 1);
50
- const psuedoPrefix = pseudo ? `-${pseudo.name}-` : "";
51
- const identifier = `_${val.property}-${psuedoPrefix}${hash}`;
52
- const className = `.${identifier}`;
53
- const rules = val.rules.map((rule) => {
54
- if (pseudo) {
55
- const psuedoPrefixSelect = [...Array(pseudo.priority)].map(() => ":root").join("") + " ";
56
- let res = rule.replace(`.${val.identifier}`, `${psuedoPrefixSelect} ${className}`).replace("{", `:${pseudo.name}{`);
57
- if (pseudo.name === "hover") {
58
- res = `@media not all and (hover: none) { ${res} }`;
59
- }
60
- return res;
61
- }
62
- return rule.replace(`.${val.identifier}`, className).replace(importantRegex, "");
63
- });
64
- if (!avoidCollection) {
65
- if (rules.length > 1) {
66
- console.warn("have never seen more than one, verifying");
67
- }
68
- AllRules.add(rules[0]);
69
- }
70
- const result = {
71
- property: val.property,
72
- value: val.value,
73
- identifier,
74
- className,
75
- rules
76
- };
77
- return result;
78
- });
79
- }
80
- __name(getAtomicStyle, "getAtomicStyle");
81
- export {
82
- getStylesAtomic
83
- };
84
- //# sourceMappingURL=getStylesAtomic.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/getStylesAtomic.ts"],
4
- "sourcesContent": ["import { AllRules, StyleObject } from '@tamagui/helpers'\nimport { ViewStyle } from 'react-native'\n\nimport { pseudos } from '../constants/pseudos'\nimport { rnw } from '../constants/rnw'\n\nconst generateStyle = (style: any) => {\n const { atomic, createCompileableStyle, createReactDOMStyle, i18Style } = rnw\n return {\n ...atomic(createCompileableStyle(createReactDOMStyle(i18Style(style)))),\n }\n}\n\nconst borderDefaults = {\n borderWidth: 'borderStyle',\n borderBottomWidth: 'borderBottomStyle',\n borderTopWidth: 'borderTopStyle',\n borderLeftWidth: 'borderLeftStyle',\n borderRightWidth: 'borderRightStyle',\n}\n\nexport function getStylesAtomic(style: any, avoidCollection = false) {\n const styles: { [key: string]: ViewStyle } = {\n base: {},\n }\n // split pseudos\n for (const key in style) {\n if (!!pseudos[key]) {\n styles[key] = style[key]\n } else {\n styles.base[key] = style[key]\n }\n }\n return Object.keys(styles)\n .map((key) => {\n return getAtomicStyle(styles[key], pseudos[key], avoidCollection)\n })\n .flat()\n}\n\nconst importantRegex = /\\!important*/g\n\nfunction getAtomicStyle(\n style: ViewStyle,\n pseudo?: { name: string; priority: number },\n avoidCollection?: boolean\n): StyleObject[] {\n if (style == null || typeof style !== 'object') {\n throw new Error(`Wrong style type: \"${typeof style}\": ${style}`)\n }\n\n // why is this diff from react-native-web!? need to figure out\n for (const key in borderDefaults) {\n if (key in style) {\n style[borderDefaults[key]] = style[borderDefaults[key]] ?? 'solid'\n }\n }\n\n const all = generateStyle(style)\n return Object.keys(all).map((key) => {\n const val = all[key]\n const hash = val.identifier.slice(`${val.identifier}`.lastIndexOf('-') + 1)\n // pseudos have a `--` to be easier to find with concatClassNames\n const psuedoPrefix = pseudo ? `-${pseudo.name}-` : ''\n const identifier = `_${val.property}-${psuedoPrefix}${hash}`\n const className = `.${identifier}`\n const rules = val.rules.map((rule) => {\n if (pseudo) {\n const psuedoPrefixSelect = [...Array(pseudo.priority)].map(() => ':root').join('') + ' '\n let res = rule\n .replace(`.${val.identifier}`, `${psuedoPrefixSelect} ${className}`)\n .replace('{', `:${pseudo.name}{`)\n\n if (pseudo.name === 'hover') {\n // hover styles need to be conditional\n // perhaps this can be generalized but for now lets just shortcut\n // and hardcode for hover styles, if we need to later we can\n // WEIRD SYNTAX, SEE:\n // https://stackoverflow.com/questions/40532204/media-query-for-devices-supporting-hover\n res = `@media not all and (hover: none) { ${res} }`\n }\n return res\n }\n return rule.replace(`.${val.identifier}`, className).replace(importantRegex, '')\n })\n\n if (!avoidCollection) {\n if (rules.length > 1) {\n console.warn('have never seen more than one, verifying')\n }\n AllRules.add(rules[0])\n }\n\n const result: StyleObject = {\n property: val.property,\n value: val.value,\n identifier,\n className,\n rules,\n }\n return result\n })\n}\n"],
5
- "mappings": ";;AAAA;AAGA;AACA;AAEA,MAAM,gBAAgB,wBAAC,UAAe;AACpC,QAAM,EAAE,QAAQ,wBAAwB,qBAAqB,aAAa;AAC1E,SAAO;AAAA,OACF,OAAO,uBAAuB,oBAAoB,SAAS;AAAA;AAAA,GAH5C;AAOtB,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA;AAGb,yBAAyB,OAAY,kBAAkB,OAAO;AACnE,QAAM,SAAuC;AAAA,IAC3C,MAAM;AAAA;AAGR,aAAW,OAAO,OAAO;AACvB,QAAI,CAAC,CAAC,QAAQ,MAAM;AAClB,aAAO,OAAO,MAAM;AAAA,WACf;AACL,aAAO,KAAK,OAAO,MAAM;AAAA;AAAA;AAG7B,SAAO,OAAO,KAAK,QAChB,IAAI,CAAC,QAAQ;AACZ,WAAO,eAAe,OAAO,MAAM,QAAQ,MAAM;AAAA,KAElD;AAAA;AAhBW;AAmB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= Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- function getStylesAtomic() {
4
- console.warn("no-op native");
5
- }
6
- __name(getStylesAtomic, "getStylesAtomic");
7
- export {
8
- getStylesAtomic
9
- };
10
- //# sourceMappingURL=getStylesAtomic.native.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/getStylesAtomic.native.ts"],
4
- "sourcesContent": ["export function getStylesAtomic() {\n console.warn('no-op native')\n}\n"],
5
- "mappings": ";;AAAO,2BAA2B;AAChC,UAAQ,KAAK;AAAA;AADC;",
6
- "names": []
7
- }
@@ -1,24 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { isWeb } from "../constants/platform";
4
- function insertStyleRule(rule) {
5
- if (typeof window === "undefined") {
6
- return;
7
- }
8
- if (process.env.NODE_ENV === "development") {
9
- if (!isWeb) {
10
- console.warn("non web platform, dont use this");
11
- return;
12
- }
13
- }
14
- const sheet = window.document.styleSheets[0];
15
- if (!sheet) {
16
- return;
17
- }
18
- sheet.insertRule(rule, sheet.cssRules.length);
19
- }
20
- __name(insertStyleRule, "insertStyleRule");
21
- export {
22
- insertStyleRule
23
- };
24
- //# sourceMappingURL=insertStyleRule.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/insertStyleRule.tsx"],
4
- "sourcesContent": ["import { isWeb } from '../constants/platform'\n\nexport function insertStyleRule(rule: string) {\n if (typeof window === 'undefined') {\n return\n }\n if (process.env.NODE_ENV === 'development') {\n if (!isWeb) {\n console.warn('non web platform, dont use this')\n return\n }\n }\n const sheet = window.document.styleSheets[0]\n if (!sheet) {\n return\n }\n sheet.insertRule(rule, sheet.cssRules.length)\n}\n"],
5
- "mappings": ";;AAAA;AAEO,yBAAyB,MAAc;AAC5C,MAAI,OAAO,WAAW,aAAa;AACjC;AAAA;AAEF,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,OAAO;AACV,cAAQ,KAAK;AACb;AAAA;AAAA;AAGJ,QAAM,QAAQ,OAAO,SAAS,YAAY;AAC1C,MAAI,CAAC,OAAO;AACV;AAAA;AAEF,QAAM,WAAW,MAAM,MAAM,SAAS;AAAA;AAdxB;",
6
- "names": []
7
- }
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const matchMedia = typeof window !== "undefined" && window.matchMedia || /* @__PURE__ */ __name(function matchMediaFallback(query) {
4
- return {
5
- addListener() {
6
- },
7
- removeListener() {
8
- },
9
- matches: false
10
- };
11
- }, "matchMediaFallback");
12
- export {
13
- matchMedia
14
- };
15
- //# sourceMappingURL=matchMedia.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/matchMedia.ts"],
4
- "sourcesContent": ["export const matchMedia =\n (typeof window !== 'undefined' && window.matchMedia) ||\n (function matchMediaFallback(query: string) {\n return {\n addListener() {},\n removeListener() {},\n matches: false,\n }\n } as any)\n"],
5
- "mappings": ";;AAAO,MAAM,aACV,OAAO,WAAW,eAAe,OAAO,cACxC,mDAA4B,OAAe;AAC1C,SAAO;AAAA,IACL,cAAc;AAAA;AAAA,IACd,iBAAiB;AAAA;AAAA,IACjB,SAAS;AAAA;AAAA,GAJZ;",
6
- "names": []
7
- }
@@ -1,8 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import MediaQueryList from "@expo/match-media/build/MediaQueryList.js";
4
- const matchMedia = /* @__PURE__ */ __name((media) => new MediaQueryList(media), "matchMedia");
5
- export {
6
- matchMedia
7
- };
8
- //# sourceMappingURL=matchMedia.native.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/matchMedia.native.ts"],
4
- "sourcesContent": ["import MediaQueryList from '@expo/match-media/build/MediaQueryList.js'\n\nexport const matchMedia = (media: string) => new MediaQueryList(media)\n"],
5
- "mappings": ";;AAAA;AAEO,MAAM,aAAa,wBAAC,UAAkB,IAAI,eAAe,QAAtC;",
6
- "names": []
7
- }
@@ -1,26 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import React, { forwardRef } from "react";
4
- import { Theme } from "../views/Theme";
5
- import { ThemeInverse } from "../views/ThemeInverse";
6
- const themeable = /* @__PURE__ */ __name(function graphql(component) {
7
- const withThemeComponent = forwardRef(/* @__PURE__ */ __name(function WithTheme({ themeInverse, ...rest }, ref) {
8
- const el = React.createElement(component, { ...rest, ref });
9
- if (themeInverse) {
10
- return /* @__PURE__ */ React.createElement(ThemeInverse, null, el);
11
- }
12
- if (rest.theme) {
13
- return /* @__PURE__ */ React.createElement(Theme, {
14
- name: rest.theme || null
15
- }, el);
16
- }
17
- return el;
18
- }, "WithTheme"));
19
- const withTheme = withThemeComponent;
20
- withTheme.displayName = `Themed(${(component == null ? void 0 : component.displayName) || (component == null ? void 0 : component.name) || "Anonymous"})`;
21
- return withTheme;
22
- }, "graphql");
23
- export {
24
- themeable
25
- };
26
- //# sourceMappingURL=themeable.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/themeable.tsx"],
4
- "sourcesContent": ["import React, { ReactElement, forwardRef } from 'react'\n\nimport { Theme } from '../views/Theme'\nimport { ThemeInverse } from '../views/ThemeInverse'\n\nexport type ThemeableProps = {\n theme?: string | null\n themeInverse?: boolean\n}\n\nexport const themeable: ThemeableHOC = function graphql<\n R extends ReactElement<any, any> | null,\n P extends ThemeableProps = {}\n>(component: (props: P) => R) {\n const withThemeComponent = forwardRef(function WithTheme({ themeInverse, ...rest }: P, ref) {\n const el = React.createElement(component, { ...rest, ref } as any) as R\n if (themeInverse) {\n return (<ThemeInverse>{el}</ThemeInverse>) as R\n }\n if (rest.theme) {\n return (<Theme name={rest.theme || null}>{el}</Theme>) as R\n }\n return el\n })\n\n const withTheme: {\n (props: P): R\n displayName: string\n } = withThemeComponent as any\n\n withTheme.displayName = `Themed(${\n (component as any)?.displayName || (component as any)?.name || 'Anonymous'\n })`\n\n return withTheme\n}\n\nexport interface ThemeableHOC {\n <R extends ReactElement<any, any> | null, P extends ThemeableProps = {}>(\n component: (props: P) => R\n ): (props: P) => R\n}\n"],
5
- "mappings": ";;AAAA;AAEA;AACA;AAOO,MAAM,YAA0B,wCAGrC,WAA4B;AAC5B,QAAM,qBAAqB,WAAW,0CAAmB,EAAE,iBAAiB,QAAW,KAAK;AAC1F,UAAM,KAAK,MAAM,cAAc,WAAW,KAAK,MAAM;AACrD,QAAI,cAAc;AAChB,aAAQ,oCAAC,cAAD,MAAe;AAAA;AAEzB,QAAI,KAAK,OAAO;AACd,aAAQ,oCAAC,OAAD;AAAA,QAAO,MAAM,KAAK,SAAS;AAAA,SAAO;AAAA;AAE5C,WAAO;AAAA,KAR6B;AAWtC,QAAM,YAGF;AAEJ,YAAU,cAAc,UACrB,wCAAmB,gBAAgB,wCAAmB,SAAQ;AAGjE,SAAO;AAAA,GAxB8B;",
6
- "names": []
7
- }
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useRef } from "react";
4
- function useConstant(fn) {
5
- const ref = useRef();
6
- if (!ref.current) {
7
- ref.current = { v: fn() };
8
- }
9
- return ref.current.v;
10
- }
11
- __name(useConstant, "useConstant");
12
- export {
13
- useConstant
14
- };
15
- //# sourceMappingURL=useConstant.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/useConstant.tsx"],
4
- "sourcesContent": ["import { useRef } from 'react'\n\ntype ResultBox<T> = { v: T }\nexport function useConstant<T>(fn: () => T): T {\n const ref = useRef<ResultBox<T>>()\n if (!ref.current) {\n ref.current = { v: fn() }\n }\n return ref.current.v\n}\n"],
5
- "mappings": ";;AAAA;AAGO,qBAAwB,IAAgB;AAC7C,QAAM,MAAM;AACZ,MAAI,CAAC,IAAI,SAAS;AAChB,QAAI,UAAU,EAAE,GAAG;AAAA;AAErB,SAAO,IAAI,QAAQ;AAAA;AALL;",
6
- "names": []
7
- }
@@ -1,75 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import React from "react";
4
- import { isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
5
- import { addMediaQueryListener, removeMediaQueryListener } from "./useMedia";
6
- const createDefinition = /* @__PURE__ */ __name(({ Component, propNames }) => ({
7
- isEnabled: (props) => propNames.some((name) => !!props[name]),
8
- Component
9
- }), "createDefinition");
10
- const mediaQueryPropNames = [
11
- "$xs",
12
- "$sm",
13
- "$md",
14
- "$lg",
15
- "$xl",
16
- "$xxl",
17
- "$pointerCoarse",
18
- "$hoverNone",
19
- "$tall",
20
- "$short",
21
- "$gtSm",
22
- "$notXs",
23
- "$gtMd",
24
- "$gtLg"
25
- ];
26
- const featureDefinitions = {
27
- measureLayout: createDefinition({
28
- Component: (props) => {
29
- console.log("measure", props);
30
- return null;
31
- },
32
- propNames: ["onLayout"]
33
- }),
34
- mediaQuery: createDefinition({
35
- Component: (props) => {
36
- if (isWeb) {
37
- return;
38
- }
39
- const keys = mediaQueryPropNames.flatMap((x) => x in props ? x.slice(1) : []);
40
- useIsomorphicLayoutEffect(() => {
41
- for (const key of keys) {
42
- addMediaQueryListener(key, props._utils.forceUpdate);
43
- }
44
- return () => {
45
- for (const key of keys) {
46
- removeMediaQueryListener(key, props._utils.forceUpdate);
47
- }
48
- };
49
- }, [keys.join(",")]);
50
- return null;
51
- },
52
- propNames: mediaQueryPropNames
53
- })
54
- };
55
- const featureNames = Object.keys(featureDefinitions);
56
- const numFeatures = featureNames.length;
57
- const useFeatures = /* @__PURE__ */ __name((props, utils) => {
58
- const features = [];
59
- for (let i = 0; i < numFeatures; i++) {
60
- const name = featureNames[i];
61
- const { isEnabled, Component } = featureDefinitions[name];
62
- if (isEnabled(props) && Component) {
63
- features.push(/* @__PURE__ */ React.createElement(Component, {
64
- key: name,
65
- ...props,
66
- _utils: utils
67
- }));
68
- }
69
- }
70
- return features;
71
- }, "useFeatures");
72
- export {
73
- useFeatures
74
- };
75
- //# sourceMappingURL=useFeatures.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/useFeatures.tsx"],
4
- "sourcesContent": ["import React from 'react'\n\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { addMediaQueryListener, removeMediaQueryListener } from './useMedia'\n\n// only needed on native\n// dynamic loading of features to avoid heavy views\n\nconst createDefinition = ({ Component, propNames }: { Component; propNames: string[] }) => ({\n isEnabled: (props: any) => propNames.some((name) => !!props[name]),\n Component,\n})\n\nconst mediaQueryPropNames = [\n '$xs',\n '$sm',\n '$md',\n '$lg',\n '$xl',\n '$xxl',\n '$pointerCoarse',\n '$hoverNone',\n '$tall',\n '$short',\n '$gtSm',\n '$notXs',\n '$gtMd',\n '$gtLg',\n]\n\nconst featureDefinitions = {\n measureLayout: createDefinition({\n Component: (props) => {\n console.log('measure', props)\n return null\n },\n propNames: ['onLayout'],\n }),\n\n // will update the parent whenever media query changes\n mediaQuery: createDefinition({\n Component: (props) => {\n if (isWeb) {\n // no need for media queries are inserted and run in css\n return\n }\n\n const keys = mediaQueryPropNames.flatMap((x) => (x in props ? x.slice(1) : []))\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 return null\n },\n propNames: mediaQueryPropNames,\n }),\n}\n\nconst featureNames = Object.keys(featureDefinitions)\nconst numFeatures = featureNames.length\n\nexport const useFeatures = (props: any, utils?: { forceUpdate?: Function }) => {\n const features: JSX.Element[] = []\n for (let i = 0; i < numFeatures; i++) {\n const name = featureNames[i]\n const { isEnabled, Component } = featureDefinitions[name] as any //FeatureDefinition\n if (isEnabled(props) && Component) {\n features.push(<Component key={name} {...props} _utils={utils} />)\n }\n }\n return features\n}\n"],
5
- "mappings": ";;AAAA;AAEA;AACA;AAKA,MAAM,mBAAmB,wBAAC,EAAE,WAAW,gBAAqD;AAAA,EAC1F,WAAW,CAAC,UAAe,UAAU,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM;AAAA,EAC5D;AAAA,IAFuB;AAKzB,MAAM,sBAAsB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAGF,MAAM,qBAAqB;AAAA,EACzB,eAAe,iBAAiB;AAAA,IAC9B,WAAW,CAAC,UAAU;AACpB,cAAQ,IAAI,WAAW;AACvB,aAAO;AAAA;AAAA,IAET,WAAW,CAAC;AAAA;AAAA,EAId,YAAY,iBAAiB;AAAA,IAC3B,WAAW,CAAC,UAAU;AACpB,UAAI,OAAO;AAET;AAAA;AAGF,YAAM,OAAO,oBAAoB,QAAQ,CAAC,MAAO,KAAK,QAAQ,EAAE,MAAM,KAAK;AAC3E,gCAA0B,MAAM;AAC9B,mBAAW,OAAO,MAAM;AACtB,gCAAsB,KAAK,MAAM,OAAO;AAAA;AAE1C,eAAO,MAAM;AACX,qBAAW,OAAO,MAAM;AACtB,qCAAyB,KAAK,MAAM,OAAO;AAAA;AAAA;AAAA,SAG9C,CAAC,KAAK,KAAK;AACd,aAAO;AAAA;AAAA,IAET,WAAW;AAAA;AAAA;AAIf,MAAM,eAAe,OAAO,KAAK;AACjC,MAAM,cAAc,aAAa;AAE1B,MAAM,cAAc,wBAAC,OAAY,UAAuC;AAC7E,QAAM,WAA0B;AAChC,WAAS,IAAI,GAAG,IAAI,aAAa,KAAK;AACpC,UAAM,OAAO,aAAa;AAC1B,UAAM,EAAE,WAAW,cAAc,mBAAmB;AACpD,QAAI,UAAU,UAAU,WAAW;AACjC,eAAS,KAAK,oCAAC,WAAD;AAAA,QAAW,KAAK;AAAA,WAAU;AAAA,QAAO,QAAQ;AAAA;AAAA;AAAA;AAG3D,SAAO;AAAA,GATkB;",
6
- "names": []
7
- }
@@ -1,28 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useEffect, useRef, useState } from "react";
4
- function useForceUpdate() {
5
- const setState = useState(0)[1];
6
- const internal = useRef();
7
- if (!internal.current) {
8
- internal.current = {
9
- isMounted: true,
10
- update: () => {
11
- if (internal.current.isMounted) {
12
- setState(Math.random());
13
- }
14
- }
15
- };
16
- }
17
- useEffect(() => {
18
- return () => {
19
- internal.current.isMounted = false;
20
- };
21
- }, []);
22
- return internal.current.update;
23
- }
24
- __name(useForceUpdate, "useForceUpdate");
25
- export {
26
- useForceUpdate
27
- };
28
- //# sourceMappingURL=useForceUpdate.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/useForceUpdate.tsx"],
4
- "sourcesContent": ["import { useEffect, useRef, useState } from 'react'\n\n// ensures no updates after unmount\n\nexport function useForceUpdate() {\n const setState = useState(0)[1]\n const internal = useRef<{ update: Function; isMounted: boolean }>()\n if (!internal.current) {\n internal.current = {\n isMounted: true,\n update: () => {\n if (internal.current!.isMounted) {\n setState(Math.random())\n }\n },\n }\n }\n\n useEffect(() => {\n return () => {\n internal.current!.isMounted = false\n }\n }, [])\n\n return internal.current.update\n}\n"],
5
- "mappings": ";;AAAA;AAIO,0BAA0B;AAC/B,QAAM,WAAW,SAAS,GAAG;AAC7B,QAAM,WAAW;AACjB,MAAI,CAAC,SAAS,SAAS;AACrB,aAAS,UAAU;AAAA,MACjB,WAAW;AAAA,MACX,QAAQ,MAAM;AACZ,YAAI,SAAS,QAAS,WAAW;AAC/B,mBAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAMtB,YAAU,MAAM;AACd,WAAO,MAAM;AACX,eAAS,QAAS,YAAY;AAAA;AAAA,KAE/B;AAEH,SAAO,SAAS,QAAQ;AAAA;AApBV;",
6
- "names": []
7
- }
@@ -1,173 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useRef } from "react";
4
- import { useIsomorphicLayoutEffect } from "../constants/platform";
5
- import { matchMedia } from "../helpers/matchMedia";
6
- import { useConstant } from "./useConstant";
7
- import { useForceUpdate } from "./useForceUpdate";
8
- const mediaState = {};
9
- const mediaQueryListeners = {};
10
- const addMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
11
- mediaQueryListeners[key] = mediaQueryListeners[key] || new Set();
12
- mediaQueryListeners[key].add(cb);
13
- }, "addMediaQueryListener");
14
- const removeMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
15
- mediaQueryListeners[key].delete(cb);
16
- }, "removeMediaQueryListener");
17
- let conf = null;
18
- const mediaQueryConfig = new Proxy({}, {
19
- get(target, key) {
20
- if (!conf) {
21
- throw new Error(`Be sure to run configureMedia before accessing mediaQueryConfig`);
22
- }
23
- return Reflect.get(conf, key);
24
- },
25
- ownKeys() {
26
- if (!conf) {
27
- throw new Error(`Be sure to run configureMedia before accessing mediaQueryConfig`);
28
- }
29
- return Object.keys(conf);
30
- },
31
- getOwnPropertyDescriptor() {
32
- return {
33
- enumerable: true,
34
- configurable: true
35
- };
36
- }
37
- });
38
- const getMedia = /* @__PURE__ */ __name(() => {
39
- if (!conf) {
40
- throw new Error(`not configured yet`);
41
- }
42
- return mediaState;
43
- }, "getMedia");
44
- const configureMedia = /* @__PURE__ */ __name(({
45
- queries,
46
- defaultActive = ["sm", "xs"]
47
- } = {}) => {
48
- var _a;
49
- if (conf) {
50
- console.warn(`Already configured mediaQueries once (you may have called getMedia() before configureMedia())`);
51
- return;
52
- }
53
- if (queries) {
54
- conf = queries;
55
- }
56
- for (const key in queries) {
57
- const str = mediaObjectToString(queries[key]);
58
- try {
59
- const getMatch = /* @__PURE__ */ __name(() => matchMedia(str), "getMatch");
60
- const match = getMatch();
61
- if (!match || typeof match.addListener !== "function") {
62
- throw new Error("\u26A0\uFE0F No match (seeing this in RN sometimes)");
63
- }
64
- mediaState[key] = !!match.matches;
65
- match.addListener(() => {
66
- const next = !!getMatch().matches;
67
- if (next === mediaState[key])
68
- return;
69
- mediaState[key] = next;
70
- const listeners = mediaQueryListeners[key];
71
- if (listeners == null ? void 0 : listeners.size) {
72
- for (const cb of [...listeners]) {
73
- cb();
74
- }
75
- }
76
- });
77
- } catch (err) {
78
- console.error("Error running media query", str, err.message, err.stack);
79
- const isDefaultActive = (_a = defaultActive == null ? void 0 : defaultActive.includes(key)) != null ? _a : true;
80
- mediaState[key] = isDefaultActive;
81
- }
82
- }
83
- }, "configureMedia");
84
- const useMedia = /* @__PURE__ */ __name(() => {
85
- const forceUpdate = useForceUpdate();
86
- const state = useRef();
87
- if (!state.current) {
88
- state.current = {
89
- selections: {},
90
- nextSelections: {},
91
- isUnmounted: false,
92
- isRendering: true
93
- };
94
- }
95
- state.current.isRendering = true;
96
- useIsomorphicLayoutEffect(() => {
97
- const st = state.current;
98
- st.isRendering = false;
99
- for (const key in st.selections) {
100
- if (!(key in st.nextSelections)) {
101
- removeMediaQueryListener(key, forceUpdate);
102
- }
103
- }
104
- for (const key in st.nextSelections) {
105
- if (!(key in st.selections)) {
106
- addMediaQueryListener(key, forceUpdate);
107
- }
108
- }
109
- });
110
- useIsomorphicLayoutEffect(() => {
111
- return () => {
112
- const st = state.current;
113
- st.isUnmounted = true;
114
- const allKeys = {
115
- ...st.selections,
116
- ...st.nextSelections
117
- };
118
- for (const key in allKeys) {
119
- removeMediaQueryListener(key, forceUpdate);
120
- }
121
- };
122
- }, []);
123
- return useConstant(() => {
124
- const st = state.current;
125
- return new Proxy(mediaState, {
126
- get(target, key) {
127
- if (!(key in mediaState)) {
128
- return Reflect.get(target, key);
129
- }
130
- if (!st.isUnmounted) {
131
- if (st.isRendering) {
132
- st.nextSelections[key] = true;
133
- }
134
- }
135
- if (key in mediaState) {
136
- return mediaState[key];
137
- }
138
- return Reflect.get(mediaState, key);
139
- }
140
- });
141
- });
142
- }, "useMedia");
143
- function camelToHyphen(str) {
144
- return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase();
145
- }
146
- __name(camelToHyphen, "camelToHyphen");
147
- function mediaObjectToString(query) {
148
- if (typeof query === "string") {
149
- return query;
150
- }
151
- return Object.entries(query).map(([feature, value]) => {
152
- feature = camelToHyphen(feature);
153
- if (typeof value === "string") {
154
- return `(${feature}: ${value})`;
155
- }
156
- if (typeof value === "number" && /[height|width]$/.test(feature)) {
157
- value = `${value}px`;
158
- }
159
- return `(${feature}: ${value})`;
160
- }).join(" and ");
161
- }
162
- __name(mediaObjectToString, "mediaObjectToString");
163
- export {
164
- addMediaQueryListener,
165
- configureMedia,
166
- getMedia,
167
- mediaObjectToString,
168
- mediaQueryConfig,
169
- mediaState,
170
- removeMediaQueryListener,
171
- useMedia
172
- };
173
- //# sourceMappingURL=useMedia.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/useMedia.tsx"],
4
- "sourcesContent": ["import { 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'\nimport { useForceUpdate } from './useForceUpdate'\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 conf: MediaQueries | null = null\n\nexport const mediaQueryConfig = new Proxy<MediaQueries>({} as any, {\n get(target, key) {\n if (!conf) {\n throw new Error(`Be sure to run configureMedia before accessing mediaQueryConfig`)\n }\n return Reflect.get(conf, key)\n },\n ownKeys() {\n if (!conf) {\n throw new Error(`Be sure to run configureMedia before accessing mediaQueryConfig`)\n }\n return Object.keys(conf)\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n})\n\nexport const getMedia = () => {\n if (!conf) {\n throw new Error(`not configured yet`)\n }\n return mediaState\n}\n\nexport const configureMedia = ({\n queries,\n defaultActive = ['sm', 'xs'],\n}: ConfigureMediaQueryOptions = {}) => {\n if (conf) {\n console.warn(\n `Already configured mediaQueries once (you may have called getMedia() before configureMedia())`\n )\n return\n }\n\n if (queries) {\n conf = queries\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;AAEA;AACA;AAOA;AACA;AAEO,MAAM,aAA0D;AACvE,MAAM,sBAAwD;AAEvD,MAAM,wBAAwB,wBAAC,KAAa,OAAY;AAC7D,sBAAoB,OAAO,oBAAoB,QAAQ,IAAI;AAC3D,sBAAoB,KAAK,IAAI;AAAA,GAFM;AAK9B,MAAM,2BAA2B,wBAAC,KAAa,OAAY;AAChE,sBAAoB,KAAK,OAAO;AAAA,GADM;A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AiB;AAAA;AADpD;AAIF,6BAA6B,OAAkC;AACpE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA;AAET,SAAO,OAAO,QAAQ,OACnB,IAAI,CAAC,CAAC,SAAS,WAAW;AACzB,cAAU,cAAc;AACxB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,IAAI,YAAY;AAAA;AAEzB,QAAI,OAAO,UAAU,YAAY,kBAAkB,KAAK,UAAU;AAChE,cAAQ,GAAG;AAAA;AAEb,WAAO,IAAI,YAAY;AAAA,KAExB,KAAK;AAAA;AAfM;",
6
- "names": []
7
- }
@@ -1,14 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- var _a, _b;
4
- import { Pressable } from "react-native";
5
- const getPressable = (_b = (_a = Pressable) == null ? void 0 : _a["type"]) == null ? void 0 : _b["render"];
6
- const usePressable = /* @__PURE__ */ __name((props) => {
7
- const out = getPressable(props);
8
- const { children, style, ...pressableProps } = out.props;
9
- return [pressableProps, style];
10
- }, "usePressable");
11
- export {
12
- usePressable
13
- };
14
- //# sourceMappingURL=usePressable.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/hooks/usePressable.tsx"],
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": ";;AAAA;AAAA;AAEA,MAAM,eAAe,6CAAY,YAAZ,mBAAsB;AAEpC,MAAM,eAAe,wBAAC,UAA0B;AACrD,QAAM,MAAM,aAAa;AACzB,QAAM,EAAE,UAAU,UAAU,mBAAmB,IAAI;AACnD,SAAO,CAAC,gBAAgB;AAAA,GAHE;",
6
- "names": []
7
- }