@tamagui/core 1.0.1-beta.197 → 1.0.1-beta.198

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 (92) hide show
  1. package/dist/cjs/createComponent.js +19 -16
  2. package/dist/cjs/createComponent.js.map +2 -2
  3. package/dist/cjs/index.js +1 -0
  4. package/dist/cjs/index.js.map +2 -2
  5. package/dist/cjs/{injectStyles.js → inject-styles.js} +4 -4
  6. package/dist/cjs/{injectStyles.js.map → inject-styles.js.map} +1 -1
  7. package/dist/cjs/{helpers/startTransition.js → react-native.js} +3 -17
  8. package/dist/cjs/react-native.js.map +7 -0
  9. package/dist/cjs/{hooks/useUnmountEffect.js → setupReactNative.js} +14 -9
  10. package/dist/cjs/setupReactNative.js.map +7 -0
  11. package/dist/cjs/styled.js +23 -5
  12. package/dist/cjs/styled.js.map +2 -2
  13. package/dist/cjs/types.js.map +1 -1
  14. package/dist/cjs/views/Text.js +1 -0
  15. package/dist/cjs/views/Text.js.map +2 -2
  16. package/dist/esm/createComponent.js +19 -16
  17. package/dist/esm/createComponent.js.map +2 -2
  18. package/dist/esm/index.js +1 -0
  19. package/dist/esm/index.js.map +2 -2
  20. package/dist/esm/{injectStyles.js → inject-styles.js} +1 -1
  21. package/dist/esm/{injectStyles.js.map → inject-styles.js.map} +1 -1
  22. package/dist/esm/react-native.js +3 -0
  23. package/dist/esm/react-native.js.map +7 -0
  24. package/dist/esm/setupReactNative.js +12 -0
  25. package/dist/esm/setupReactNative.js.map +7 -0
  26. package/dist/esm/styled.js +23 -5
  27. package/dist/esm/styled.js.map +2 -2
  28. package/dist/esm/views/Text.js +1 -0
  29. package/dist/esm/views/Text.js.map +2 -2
  30. package/package.json +20 -16
  31. package/src/createComponent.tsx +20 -17
  32. package/src/index.ts +1 -0
  33. package/src/{injectStyles.ts → inject-styles.ts} +0 -0
  34. package/src/setupReactNative.ts +9 -0
  35. package/src/styled.tsx +28 -7
  36. package/src/types.tsx +0 -5
  37. package/src/views/Text.tsx +2 -0
  38. package/types/index.d.ts +1 -0
  39. package/types/inject-styles.d.ts +7 -0
  40. package/types/react-native.d.ts +8 -0
  41. package/types/setupReactNative.d.ts +3 -0
  42. package/types/types.d.ts +0 -4
  43. package/dist/cjs/helpers/assignNativePropsToWeb.js +0 -188
  44. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +0 -7
  45. package/dist/cjs/helpers/calc.js +0 -71
  46. package/dist/cjs/helpers/calc.js.map +0 -7
  47. package/dist/cjs/helpers/getFont.js +0 -66
  48. package/dist/cjs/helpers/getFont.js.map +0 -7
  49. package/dist/cjs/helpers/getStackSize.js +0 -46
  50. package/dist/cjs/helpers/getStackSize.js.map +0 -7
  51. package/dist/cjs/helpers/startTransition.js.map +0 -7
  52. package/dist/cjs/hooks/useConstant.js +0 -39
  53. package/dist/cjs/hooks/useConstant.js.map +0 -7
  54. package/dist/cjs/hooks/useIsMounted.js +0 -40
  55. package/dist/cjs/hooks/useIsMounted.js.map +0 -7
  56. package/dist/cjs/hooks/useMedia.test.js +0 -2
  57. package/dist/cjs/hooks/useMedia.test.js.map +0 -7
  58. package/dist/cjs/hooks/usePressable.js +0 -36
  59. package/dist/cjs/hooks/usePressable.js.map +0 -7
  60. package/dist/cjs/hooks/usePressablePressResponder.js +0 -370
  61. package/dist/cjs/hooks/usePressablePressResponder.js.map +0 -7
  62. package/dist/cjs/hooks/useUnmountEffect.js.map +0 -7
  63. package/dist/cjs/views/AbsoluteFill.js +0 -41
  64. package/dist/cjs/views/AbsoluteFill.js.map +0 -7
  65. package/dist/cjs/views/AbsoluteFill.native.js +0 -45
  66. package/dist/cjs/views/AbsoluteFill.native.js.map +0 -7
  67. package/dist/esm/helpers/assignNativePropsToWeb.js +0 -164
  68. package/dist/esm/helpers/assignNativePropsToWeb.js.map +0 -7
  69. package/dist/esm/helpers/calc.js +0 -47
  70. package/dist/esm/helpers/calc.js.map +0 -7
  71. package/dist/esm/helpers/getFont.js +0 -42
  72. package/dist/esm/helpers/getFont.js.map +0 -7
  73. package/dist/esm/helpers/getStackSize.js +0 -22
  74. package/dist/esm/helpers/getStackSize.js.map +0 -7
  75. package/dist/esm/helpers/startTransition.js +0 -6
  76. package/dist/esm/helpers/startTransition.js.map +0 -7
  77. package/dist/esm/hooks/useConstant.js +0 -15
  78. package/dist/esm/hooks/useConstant.js.map +0 -7
  79. package/dist/esm/hooks/useIsMounted.js +0 -16
  80. package/dist/esm/hooks/useIsMounted.js.map +0 -7
  81. package/dist/esm/hooks/useMedia.test.js +0 -1
  82. package/dist/esm/hooks/useMedia.test.js.map +0 -7
  83. package/dist/esm/hooks/usePressable.js +0 -12
  84. package/dist/esm/hooks/usePressable.js.map +0 -7
  85. package/dist/esm/hooks/usePressablePressResponder.js +0 -346
  86. package/dist/esm/hooks/usePressablePressResponder.js.map +0 -7
  87. package/dist/esm/hooks/useUnmountEffect.js +0 -8
  88. package/dist/esm/hooks/useUnmountEffect.js.map +0 -7
  89. package/dist/esm/views/AbsoluteFill.js +0 -17
  90. package/dist/esm/views/AbsoluteFill.js.map +0 -7
  91. package/dist/esm/views/AbsoluteFill.native.js +0 -21
  92. package/dist/esm/views/AbsoluteFill.native.js.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.0.1-beta.197",
3
+ "version": "1.0.1-beta.198",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -28,16 +28,16 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@expo/match-media": "^0.3.0",
31
- "@tamagui/compose-refs": "^1.0.1-beta.197",
32
- "@tamagui/constants": "^1.0.1-beta.197",
33
- "@tamagui/helpers": "^1.0.1-beta.197",
34
- "@tamagui/normalize-css-color-lite": "^1.0.1-beta.197",
35
- "@tamagui/react-native-use-pressable": "^1.0.1-beta.197",
36
- "@tamagui/react-native-use-responder-events": "^1.0.1-beta.197",
37
- "@tamagui/types-react-native": "^1.0.1-beta.197",
38
- "@tamagui/use-did-finish-ssr": "^1.0.1-beta.197",
39
- "@tamagui/use-event": "^1.0.1-beta.197",
40
- "@tamagui/use-force-update": "^1.0.1-beta.197",
31
+ "@tamagui/compose-refs": "^1.0.1-beta.198",
32
+ "@tamagui/constants": "^1.0.1-beta.198",
33
+ "@tamagui/helpers": "^1.0.1-beta.198",
34
+ "@tamagui/normalize-css-color-lite": "^1.0.1-beta.198",
35
+ "@tamagui/react-native-use-pressable": "^1.0.1-beta.198",
36
+ "@tamagui/react-native-use-responder-events": "^1.0.1-beta.198",
37
+ "@tamagui/types-react-native": "^1.0.1-beta.198",
38
+ "@tamagui/use-did-finish-ssr": "^1.0.1-beta.198",
39
+ "@tamagui/use-event": "^1.0.1-beta.198",
40
+ "@tamagui/use-force-update": "^1.0.1-beta.198",
41
41
  "ts-toolbelt": "^9.6.0"
42
42
  },
43
43
  "peerDependencies": {
@@ -45,7 +45,7 @@
45
45
  "react-dom": "*"
46
46
  },
47
47
  "devDependencies": {
48
- "@tamagui/build": "^1.0.1-beta.197",
48
+ "@tamagui/build": "^1.0.1-beta.198",
49
49
  "@types/node": "^16.11.9",
50
50
  "@types/react": "^18.0.15",
51
51
  "@types/react-native": "^0.69.2",
@@ -54,7 +54,7 @@
54
54
  "react": "*",
55
55
  "react-dom": "*",
56
56
  "typescript": "^4.7.4",
57
- "vitest": "^0.20.3"
57
+ "vitest": "^0.24.3"
58
58
  },
59
59
  "exports": {
60
60
  "./package.json": "./package.json",
@@ -63,9 +63,13 @@
63
63
  "import": "./dist/esm/index.js",
64
64
  "require": "./dist/cjs/index.js"
65
65
  },
66
- "./injectStyles": {
67
- "import": "./dist/esm/injectStyles.js",
68
- "require": "./dist/cjs/injectStyles.js"
66
+ "./inject-styles": {
67
+ "import": "./dist/esm/inject-styles.js",
68
+ "require": "./dist/cjs/inject-styles.js"
69
+ },
70
+ "./react-native": {
71
+ "import": "./dist/esm/react-native.js",
72
+ "require": "./dist/cjs/react-native.js"
69
73
  }
70
74
  },
71
75
  "repository": {
@@ -618,15 +618,15 @@ export function createComponent<
618
618
  }
619
619
  const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : ''
620
620
 
621
+ const classList = [
622
+ componentName ? componentClassName : '',
623
+ fontFamilyClassName,
624
+ theme.className,
625
+ classNames ? Object.values(classNames).join(' ') : '',
626
+ ]
627
+ const className = classList.join(' ')
628
+
621
629
  if (process.env.TAMAGUI_TARGET === 'web') {
622
- const classList = [
623
- componentName ? componentClassName : '',
624
- fontFamilyClassName,
625
- theme.className,
626
- classNames ? Object.values(classNames).join(' ') : '',
627
- ]
628
-
629
- const className = classList.join(' ')
630
630
  const style = animationStyles ?? splitStyles.style
631
631
 
632
632
  if (isAnimatedReactNativeWeb) {
@@ -884,17 +884,20 @@ export function createComponent<
884
884
  content = createElement(elementType, viewProps, childEls)
885
885
 
886
886
  if (process.env.TAMAGUI_TARGET === 'web') {
887
- if (events) {
887
+ if (events || isAnimatedReactNativeWeb) {
888
888
  content = (
889
889
  <span
890
890
  style={styleDisplayContents}
891
- onMouseEnter={events.onMouseEnter}
892
- onMouseLeave={events.onMouseLeave}
893
- onClick={events.onPress}
894
- onMouseDown={events.onPressIn}
895
- onMouseUp={events.onPressOut}
896
- onTouchStart={events.onPressIn}
897
- onTouchEnd={events.onPressOut}
891
+ className={isAnimatedReactNativeWeb ? className : undefined}
892
+ {...(events && {
893
+ onMouseEnter: events.onMouseEnter,
894
+ onMouseLeave: events.onMouseLeave,
895
+ onClick: events.onPress,
896
+ onMouseDown: events.onPressIn,
897
+ onMouseUp: events.onPressOut,
898
+ onTouchStart: events.onPressIn,
899
+ onTouchEnd: events.onPressOut,
900
+ })}
898
901
  >
899
902
  {content}
900
903
  </span>
@@ -928,7 +931,7 @@ export function createComponent<
928
931
  if (typeof window !== 'undefined') {
929
932
  // prettier-ignore
930
933
  // eslint-disable-next-line no-console
931
- console.log({ state, shouldProvideThemeManager, tamaguiDefaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: props.className?.split(' '), classNamesOut: viewProps.className?.split(' '), events, shouldAttach, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses: avoidClassesWhileAnimating, animation: props.animation, style: splitStylesStyle, defaultNativeStyle, initialSplitStyles, ...(typeof window !== 'undefined' ? { theme, themeClassName: theme.className, staticConfig, tamaguiConfig, events, shouldAvoidClasses, shouldForcePseudo, classNames: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) } : null) })
934
+ console.log({ state, shouldProvideThemeManager, isAnimated, isAnimatedReactNativeWeb, tamaguiDefaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: props.className?.split(' '), classNamesOut: viewProps.className?.split(' '), events, shouldAttach, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses: avoidClassesWhileAnimating, animation: props.animation, style: splitStylesStyle, defaultNativeStyle, initialSplitStyles, ...(typeof window !== 'undefined' ? { theme, themeClassName: theme.className, staticConfig, tamaguiConfig, events, shouldAvoidClasses, shouldForcePseudo, classNames: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) } : null) })
932
935
  }
933
936
  // eslint-disable-next-line no-console
934
937
  console.groupEnd()
package/src/index.ts CHANGED
@@ -12,6 +12,7 @@ export * from './addTheme'
12
12
  export * from './updateTheme'
13
13
  export * from './styled'
14
14
  export * from './types'
15
+ export * from './setupReactNative'
15
16
 
16
17
  // for type portability
17
18
  export type { RNWTextProps, RNWViewProps } from './types-rnw'
File without changes
@@ -0,0 +1,9 @@
1
+ let rn
2
+
3
+ export function getReactNative() {
4
+ return rn
5
+ }
6
+
7
+ export function setupReactNative(_) {
8
+ rn = _
9
+ }
package/src/styled.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getConfig } from './config'
2
2
  import { createComponent } from './createComponent'
3
+ import { getReactNative } from './setupReactNative'
3
4
  import {
4
5
  GetProps,
5
6
  GetVariantValues,
@@ -34,6 +35,8 @@ type GetVariantProps<A extends StylableComponent> =
34
35
  // :
35
36
  A extends TamaguiComponent<any, any, any, infer V> ? V : {}
36
37
 
38
+ let RNComponentConfigs: WeakMap<any, Partial<StaticConfig>> | null = null
39
+
37
40
  export function styled<
38
41
  ParentComponent extends StylableComponent,
39
42
  Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void
@@ -59,6 +62,21 @@ export function styled<
59
62
  // }
60
63
  // }
61
64
 
65
+ const RN = getReactNative()
66
+ if (RN && typeof RN === 'object' && !RNComponentConfigs) {
67
+ RNComponentConfigs = new WeakMap()
68
+ for (const key in RN) {
69
+ const val = RN[key]
70
+ if (!val) continue
71
+ if (key[0].toLowerCase() === key[0]) continue
72
+ RNComponentConfigs.set(val, {
73
+ isReactNative: true,
74
+ isText: key === 'Text' || key === 'TextInput',
75
+ inlineProps: key === 'Image' ? new Set(['src', 'width', 'height']) : undefined,
76
+ })
77
+ }
78
+ }
79
+
62
80
  const staticConfigProps = (() => {
63
81
  const parentStaticConfig =
64
82
  'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null
@@ -87,13 +105,17 @@ export function styled<
87
105
  Object.assign(defaultProps, defaultVariants)
88
106
  }
89
107
  const isReactNative = Boolean(
90
- parentStaticConfig?.isReactNative || staticExtractionOptions?.isReactNative
108
+ (RNComponentConfigs &&
109
+ (RNComponentConfigs.has(Component) ||
110
+ RNComponentConfigs.has(parentStaticConfig?.Component))) ||
111
+ parentStaticConfig?.isReactNative ||
112
+ staticExtractionOptions?.isReactNative
91
113
  )
92
- const reactNativeWebComponent = isReactNative
93
- ? parentStaticConfig?.reactNativeWebComponent || Component
94
- : null
95
114
  const isTamagui = !isReactNative && !!parentStaticConfig
96
- const Comp = reactNativeWebComponent || (Component as any)
115
+
116
+ const Comp = isReactNative ? parentStaticConfig?.Component || Component : (Component as any)
117
+ const nativeConf = (isReactNative && RNComponentConfigs?.get(Comp)) || null
118
+
97
119
  const isText = Boolean(staticExtractionOptions?.isText || parentStaticConfig?.isText)
98
120
  const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative)
99
121
 
@@ -109,10 +131,9 @@ export function styled<
109
131
  defaultVariants,
110
132
  componentName: name,
111
133
  isReactNative,
112
- // for nesting multiple levels of rnw styled() need keep use the OG component
113
- reactNativeWebComponent,
114
134
  isText,
115
135
  acceptsClassName,
136
+ ...nativeConf,
116
137
  }
117
138
 
118
139
  // TODO compiler doesn't have logic to include children, de-opt (see EnsureFlexed for test usage)
package/src/types.tsx CHANGED
@@ -794,11 +794,6 @@ export type StaticConfig = StaticConfigPublic & {
794
794
  */
795
795
  defaultVariants?: { [key: string]: any }
796
796
 
797
- /**
798
- * Used internally to keep reference to the original rnw component
799
- */
800
- reactNativeWebComponent?: any
801
-
802
797
  /**
803
798
  * Memoize the component
804
799
  */
@@ -26,6 +26,8 @@ export const Text = createComponent<TextProps, TextView, TextPropsBase>({
26
26
  }),
27
27
  },
28
28
 
29
+ inlineWhenUnflattened: new Set(['fontFamily']),
30
+
29
31
  variants: {
30
32
  ...(isWeb && {
31
33
  numberOfLines: {
package/types/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from './addTheme';
12
12
  export * from './updateTheme';
13
13
  export * from './styled';
14
14
  export * from './types';
15
+ export * from './setupReactNative';
15
16
  export type { RNWTextProps, RNWViewProps } from './types-rnw';
16
17
  export { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './config';
17
18
  export * from './constants/constants';
@@ -0,0 +1,7 @@
1
+ interface InjectStylesOptions {
2
+ filePath: string;
3
+ css: string;
4
+ }
5
+ export declare const injectStyles: ({ filePath, css }: InjectStylesOptions) => void;
6
+ export {};
7
+ //# sourceMappingURL=inject-styles.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `@tamagui/core/react-native`
3
+ *
4
+ * Only import for easier React Native detection
5
+ *
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=react-native.d.ts.map
@@ -0,0 +1,3 @@
1
+ export declare function getReactNative(): any;
2
+ export declare function setupReactNative(_: any): void;
3
+ //# sourceMappingURL=setupReactNative.d.ts.map
package/types/types.d.ts CHANGED
@@ -468,10 +468,6 @@ export declare type StaticConfig = StaticConfigPublic & {
468
468
  defaultVariants?: {
469
469
  [key: string]: any;
470
470
  };
471
- /**
472
- * Used internally to keep reference to the original rnw component
473
- */
474
- reactNativeWebComponent?: any;
475
471
  /**
476
472
  * Memoize the component
477
473
  */
@@ -1,188 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var assignNativePropsToWeb_exports = {};
20
- __export(assignNativePropsToWeb_exports, {
21
- assignNativePropsToWeb: () => assignNativePropsToWeb
22
- });
23
- module.exports = __toCommonJS(assignNativePropsToWeb_exports);
24
- var import_createComponent = require("../createComponent");
25
- function assignNativePropsToWeb(elementType, viewProps, nativeProps) {
26
- if (!viewProps.role && nativeProps.accessibilityRole) {
27
- if (nativeProps.accessibilityRole === "none") {
28
- viewProps.role = "presentation";
29
- } else {
30
- const webRole = import_createComponent.accessibilityRoleToWebRole[nativeProps.accessibilityRole];
31
- if (webRole != null) {
32
- viewProps.role = webRole || nativeProps.accessibilityRole;
33
- }
34
- }
35
- }
36
- if (nativeProps.accessibilityActiveDescendant != null) {
37
- viewProps["aria-activedescendant"] = nativeProps.accessibilityActiveDescendant;
38
- }
39
- if (nativeProps.accessibilityAtomic != null) {
40
- viewProps["aria-atomic"] = nativeProps.accessibilityAtomic;
41
- }
42
- if (nativeProps.accessibilityAutoComplete != null) {
43
- viewProps["aria-autocomplete"] = nativeProps.accessibilityAutoComplete;
44
- }
45
- if (nativeProps.accessibilityBusy != null) {
46
- viewProps["aria-busy"] = nativeProps.accessibilityBusy;
47
- }
48
- if (nativeProps.accessibilityChecked != null) {
49
- viewProps["aria-checked"] = nativeProps.accessibilityChecked;
50
- }
51
- if (nativeProps.accessibilityColumnCount != null) {
52
- viewProps["aria-colcount"] = nativeProps.accessibilityColumnCount;
53
- }
54
- if (nativeProps.accessibilityColumnIndex != null) {
55
- viewProps["aria-colindex"] = nativeProps.accessibilityColumnIndex;
56
- }
57
- if (nativeProps.accessibilityColumnSpan != null) {
58
- viewProps["aria-colspan"] = nativeProps.accessibilityColumnSpan;
59
- }
60
- if (nativeProps.accessibilityControls != null) {
61
- viewProps["aria-controls"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityControls);
62
- }
63
- if (nativeProps.accessibilityCurrent != null) {
64
- viewProps["aria-current"] = nativeProps.accessibilityCurrent;
65
- }
66
- if (nativeProps.accessibilityDescribedBy != null) {
67
- viewProps["aria-describedby"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityDescribedBy);
68
- }
69
- if (nativeProps.accessibilityDetails != null) {
70
- viewProps["aria-details"] = nativeProps.accessibilityDetails;
71
- }
72
- if (nativeProps.disabled === true) {
73
- viewProps["aria-disabled"] = true;
74
- if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
75
- viewProps.disabled = true;
76
- }
77
- }
78
- if (nativeProps.accessibilityErrorMessage != null) {
79
- viewProps["aria-errormessage"] = nativeProps.accessibilityErrorMessage;
80
- }
81
- if (nativeProps.accessibilityExpanded != null) {
82
- viewProps["aria-expanded"] = nativeProps.accessibilityExpanded;
83
- }
84
- if (nativeProps.accessibilityFlowTo != null) {
85
- viewProps["aria-flowto"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityFlowTo);
86
- }
87
- if (nativeProps.accessibilityHasPopup != null) {
88
- viewProps["aria-haspopup"] = nativeProps.accessibilityHasPopup;
89
- }
90
- if (nativeProps.accessibilityHidden === true) {
91
- viewProps["aria-hidden"] = nativeProps.accessibilityHidden;
92
- }
93
- if (nativeProps.accessibilityInvalid != null) {
94
- viewProps["aria-invalid"] = nativeProps.accessibilityInvalid;
95
- }
96
- if (nativeProps.accessibilityKeyShortcuts != null && Array.isArray(nativeProps.accessibilityKeyShortcuts)) {
97
- viewProps["aria-keyshortcuts"] = nativeProps.accessibilityKeyShortcuts.join(" ");
98
- }
99
- if (nativeProps.accessibilityLabel != null) {
100
- viewProps["aria-label"] = nativeProps.accessibilityLabel;
101
- }
102
- if (nativeProps.accessibilityLabelledBy != null) {
103
- viewProps["aria-labelledby"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityLabelledBy);
104
- }
105
- if (nativeProps.accessibilityLevel != null) {
106
- viewProps["aria-level"] = nativeProps.accessibilityLevel;
107
- }
108
- if (nativeProps.accessibilityLiveRegion != null) {
109
- viewProps["aria-live"] = nativeProps.accessibilityLiveRegion === "none" ? "off" : nativeProps.accessibilityLiveRegion;
110
- }
111
- if (nativeProps.accessibilityModal != null) {
112
- viewProps["aria-modal"] = nativeProps.accessibilityModal;
113
- }
114
- if (nativeProps.accessibilityMultiline != null) {
115
- viewProps["aria-multiline"] = nativeProps.accessibilityMultiline;
116
- }
117
- if (nativeProps.accessibilityMultiSelectable != null) {
118
- viewProps["aria-multiselectable"] = nativeProps.accessibilityMultiSelectable;
119
- }
120
- if (nativeProps.accessibilityOrientation != null) {
121
- viewProps["aria-orientation"] = nativeProps.accessibilityOrientation;
122
- }
123
- if (nativeProps.accessibilityOwns != null) {
124
- viewProps["aria-owns"] = (0, import_createComponent.processIDRefList)(nativeProps.accessibilityOwns);
125
- }
126
- if (nativeProps.accessibilityPlaceholder != null) {
127
- viewProps["aria-placeholder"] = nativeProps.accessibilityPlaceholder;
128
- }
129
- if (nativeProps.accessibilityPosInSet != null) {
130
- viewProps["aria-posinset"] = nativeProps.accessibilityPosInSet;
131
- }
132
- if (nativeProps.accessibilityPressed != null) {
133
- viewProps["aria-pressed"] = nativeProps.accessibilityPressed;
134
- }
135
- if (nativeProps.accessibilityReadOnly != null) {
136
- viewProps["aria-readonly"] = nativeProps.accessibilityReadOnly;
137
- if (elementType === "input" || elementType === "select" || elementType === "textarea") {
138
- viewProps.readOnly = true;
139
- }
140
- }
141
- if (nativeProps.accessibilityRequired != null) {
142
- viewProps["aria-required"] = nativeProps.accessibilityRequired;
143
- if (elementType === "input" || elementType === "select" || elementType === "textarea") {
144
- viewProps.required = true;
145
- }
146
- }
147
- if (nativeProps.accessibilityRoleDescription != null) {
148
- viewProps["aria-roledescription"] = nativeProps.accessibilityRoleDescription;
149
- }
150
- if (nativeProps.accessibilityRowCount != null) {
151
- viewProps["aria-rowcount"] = nativeProps.accessibilityRowCount;
152
- }
153
- if (nativeProps.accessibilityRowIndex != null) {
154
- viewProps["aria-rowindex"] = nativeProps.accessibilityRowIndex;
155
- }
156
- if (nativeProps.accessibilityRowSpan != null) {
157
- viewProps["aria-rowspan"] = nativeProps.accessibilityRowSpan;
158
- }
159
- if (nativeProps.accessibilitySelected != null) {
160
- viewProps["aria-selected"] = nativeProps.accessibilitySelected;
161
- }
162
- if (nativeProps.accessibilitySetSize != null) {
163
- viewProps["aria-setsize"] = nativeProps.accessibilitySetSize;
164
- }
165
- if (nativeProps.accessibilitySort != null) {
166
- viewProps["aria-sort"] = nativeProps.accessibilitySort;
167
- }
168
- if (nativeProps.accessibilityValueMax != null) {
169
- viewProps["aria-valuemax"] = nativeProps.accessibilityValueMax;
170
- }
171
- if (nativeProps.accessibilityValueMin != null) {
172
- viewProps["aria-valuemin"] = nativeProps.accessibilityValueMin;
173
- }
174
- if (nativeProps.accessibilityValueNow != null) {
175
- viewProps["aria-valuenow"] = nativeProps.accessibilityValueNow;
176
- }
177
- if (nativeProps.accessibilityValueText != null) {
178
- viewProps["aria-valuetext"] = nativeProps.accessibilityValueText;
179
- }
180
- if (nativeProps.nativeID) {
181
- viewProps.id = nativeProps.nativeID;
182
- }
183
- }
184
- // Annotate the CommonJS export names for ESM import in node:
185
- 0 && (module.exports = {
186
- assignNativePropsToWeb
187
- });
188
- //# sourceMappingURL=assignNativePropsToWeb.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/assignNativePropsToWeb.tsx"],
4
- "sourcesContent": ["import { accessibilityRoleToWebRole, processIDRefList } from '../createComponent'\n\n// adapted from react-native-web\n\nexport function assignNativePropsToWeb(elementType: string, viewProps: any, nativeProps: any) {\n if (!viewProps.role && nativeProps.accessibilityRole) {\n if (nativeProps.accessibilityRole === 'none') {\n viewProps.role = 'presentation'\n } else {\n const webRole = accessibilityRoleToWebRole[nativeProps.accessibilityRole]\n if (webRole != null) {\n viewProps.role = webRole || nativeProps.accessibilityRole\n }\n }\n }\n\n if (nativeProps.accessibilityActiveDescendant != null) {\n viewProps['aria-activedescendant'] = nativeProps.accessibilityActiveDescendant\n }\n if (nativeProps.accessibilityAtomic != null) {\n viewProps['aria-atomic'] = nativeProps.accessibilityAtomic\n }\n if (nativeProps.accessibilityAutoComplete != null) {\n viewProps['aria-autocomplete'] = nativeProps.accessibilityAutoComplete\n }\n if (nativeProps.accessibilityBusy != null) {\n viewProps['aria-busy'] = nativeProps.accessibilityBusy\n }\n if (nativeProps.accessibilityChecked != null) {\n viewProps['aria-checked'] = nativeProps.accessibilityChecked\n }\n if (nativeProps.accessibilityColumnCount != null) {\n viewProps['aria-colcount'] = nativeProps.accessibilityColumnCount\n }\n if (nativeProps.accessibilityColumnIndex != null) {\n viewProps['aria-colindex'] = nativeProps.accessibilityColumnIndex\n }\n if (nativeProps.accessibilityColumnSpan != null) {\n viewProps['aria-colspan'] = nativeProps.accessibilityColumnSpan\n }\n if (nativeProps.accessibilityControls != null) {\n viewProps['aria-controls'] = processIDRefList(nativeProps.accessibilityControls)\n }\n if (nativeProps.accessibilityCurrent != null) {\n viewProps['aria-current'] = nativeProps.accessibilityCurrent\n }\n if (nativeProps.accessibilityDescribedBy != null) {\n viewProps['aria-describedby'] = processIDRefList(nativeProps.accessibilityDescribedBy)\n }\n if (nativeProps.accessibilityDetails != null) {\n viewProps['aria-details'] = nativeProps.accessibilityDetails\n }\n if (nativeProps.disabled === true) {\n viewProps['aria-disabled'] = true\n // Enhance with native semantics\n if (\n elementType === 'button' ||\n elementType === 'form' ||\n elementType === 'input' ||\n elementType === 'select' ||\n elementType === 'textarea'\n ) {\n viewProps.disabled = true\n }\n }\n if (nativeProps.accessibilityErrorMessage != null) {\n viewProps['aria-errormessage'] = nativeProps.accessibilityErrorMessage\n }\n if (nativeProps.accessibilityExpanded != null) {\n viewProps['aria-expanded'] = nativeProps.accessibilityExpanded\n }\n if (nativeProps.accessibilityFlowTo != null) {\n viewProps['aria-flowto'] = processIDRefList(nativeProps.accessibilityFlowTo)\n }\n if (nativeProps.accessibilityHasPopup != null) {\n viewProps['aria-haspopup'] = nativeProps.accessibilityHasPopup\n }\n if (nativeProps.accessibilityHidden === true) {\n viewProps['aria-hidden'] = nativeProps.accessibilityHidden\n }\n if (nativeProps.accessibilityInvalid != null) {\n viewProps['aria-invalid'] = nativeProps.accessibilityInvalid\n }\n if (\n nativeProps.accessibilityKeyShortcuts != null &&\n Array.isArray(nativeProps.accessibilityKeyShortcuts)\n ) {\n viewProps['aria-keyshortcuts'] = nativeProps.accessibilityKeyShortcuts.join(' ')\n }\n if (nativeProps.accessibilityLabel != null) {\n viewProps['aria-label'] = nativeProps.accessibilityLabel\n }\n if (nativeProps.accessibilityLabelledBy != null) {\n viewProps['aria-labelledby'] = processIDRefList(nativeProps.accessibilityLabelledBy)\n }\n if (nativeProps.accessibilityLevel != null) {\n viewProps['aria-level'] = nativeProps.accessibilityLevel\n }\n if (nativeProps.accessibilityLiveRegion != null) {\n viewProps['aria-live'] =\n nativeProps.accessibilityLiveRegion === 'none' ? 'off' : nativeProps.accessibilityLiveRegion\n }\n if (nativeProps.accessibilityModal != null) {\n viewProps['aria-modal'] = nativeProps.accessibilityModal\n }\n if (nativeProps.accessibilityMultiline != null) {\n viewProps['aria-multiline'] = nativeProps.accessibilityMultiline\n }\n if (nativeProps.accessibilityMultiSelectable != null) {\n viewProps['aria-multiselectable'] = nativeProps.accessibilityMultiSelectable\n }\n if (nativeProps.accessibilityOrientation != null) {\n viewProps['aria-orientation'] = nativeProps.accessibilityOrientation\n }\n if (nativeProps.accessibilityOwns != null) {\n viewProps['aria-owns'] = processIDRefList(nativeProps.accessibilityOwns)\n }\n if (nativeProps.accessibilityPlaceholder != null) {\n viewProps['aria-placeholder'] = nativeProps.accessibilityPlaceholder\n }\n if (nativeProps.accessibilityPosInSet != null) {\n viewProps['aria-posinset'] = nativeProps.accessibilityPosInSet\n }\n if (nativeProps.accessibilityPressed != null) {\n viewProps['aria-pressed'] = nativeProps.accessibilityPressed\n }\n if (nativeProps.accessibilityReadOnly != null) {\n viewProps['aria-readonly'] = nativeProps.accessibilityReadOnly\n // Enhance with native semantics\n if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {\n viewProps.readOnly = true\n }\n }\n if (nativeProps.accessibilityRequired != null) {\n viewProps['aria-required'] = nativeProps.accessibilityRequired\n // Enhance with native semantics\n if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {\n viewProps.required = true\n }\n }\n if (nativeProps.accessibilityRoleDescription != null) {\n viewProps['aria-roledescription'] = nativeProps.accessibilityRoleDescription\n }\n if (nativeProps.accessibilityRowCount != null) {\n viewProps['aria-rowcount'] = nativeProps.accessibilityRowCount\n }\n if (nativeProps.accessibilityRowIndex != null) {\n viewProps['aria-rowindex'] = nativeProps.accessibilityRowIndex\n }\n if (nativeProps.accessibilityRowSpan != null) {\n viewProps['aria-rowspan'] = nativeProps.accessibilityRowSpan\n }\n if (nativeProps.accessibilitySelected != null) {\n viewProps['aria-selected'] = nativeProps.accessibilitySelected\n }\n if (nativeProps.accessibilitySetSize != null) {\n viewProps['aria-setsize'] = nativeProps.accessibilitySetSize\n }\n if (nativeProps.accessibilitySort != null) {\n viewProps['aria-sort'] = nativeProps.accessibilitySort\n }\n if (nativeProps.accessibilityValueMax != null) {\n viewProps['aria-valuemax'] = nativeProps.accessibilityValueMax\n }\n if (nativeProps.accessibilityValueMin != null) {\n viewProps['aria-valuemin'] = nativeProps.accessibilityValueMin\n }\n if (nativeProps.accessibilityValueNow != null) {\n viewProps['aria-valuenow'] = nativeProps.accessibilityValueNow\n }\n if (nativeProps.accessibilityValueText != null) {\n viewProps['aria-valuetext'] = nativeProps.accessibilityValueText\n }\n\n if (nativeProps.nativeID) {\n viewProps.id = nativeProps.nativeID\n }\n}\n"],
5
- "mappings": "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",
6
- "names": []
7
- }
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var calc_exports = {};
20
- __export(calc_exports, {
21
- calc: () => calc
22
- });
23
- module.exports = __toCommonJS(calc_exports);
24
- var import_constants = require("@tamagui/constants");
25
- var import_createVariable = require("../createVariable");
26
- const operators = {
27
- "+": (a, b) => a + b,
28
- "-": (a, b) => a - b,
29
- "/": (a, b) => a / b,
30
- "*": (a, b) => a * b
31
- };
32
- const calc = (...valuesAndOperators) => {
33
- if (import_constants.isWeb) {
34
- let res2 = "calc(";
35
- for (const cur of valuesAndOperators) {
36
- if (operators[cur]) {
37
- res2 += " " + cur + " ";
38
- } else {
39
- res2 += convertToVariableOrNumber(cur);
40
- }
41
- }
42
- return res2 + ")";
43
- }
44
- let res = 0;
45
- let nextOp = null;
46
- for (const cur of valuesAndOperators) {
47
- if (operators[cur]) {
48
- nextOp = operators[cur];
49
- } else {
50
- if (nextOp) {
51
- res = nextOp(res, cur);
52
- nextOp = null;
53
- } else {
54
- res = +cur;
55
- }
56
- }
57
- }
58
- return res;
59
- };
60
- const convertToVariableOrNumber = (v) => {
61
- const varOrVal = (0, import_createVariable.getVariableVariable)(v);
62
- if (typeof varOrVal === "number") {
63
- return `${varOrVal}px`;
64
- }
65
- return varOrVal;
66
- };
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- calc
70
- });
71
- //# sourceMappingURL=calc.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/helpers/calc.ts"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\n\nimport { getVariableVariable } from '../createVariable'\nimport { FontLineHeightTokens, FontSizeTokens, SizeTokens, SpaceTokens } from '../types'\n\n// unused code - not exported\n\n/**\n * Simple calc() that handles native + web\n * on web: outputs a calc() string\n * on native: outputs a plain number\n */\n\nexport type CalcVal =\n | string\n | number\n | SizeTokens\n | SpaceTokens\n | FontSizeTokens\n | FontLineHeightTokens\n\nconst operators = {\n '+': (a: number, b: number) => a + b,\n '-': (a: number, b: number) => a - b,\n '/': (a: number, b: number) => a / b,\n '*': (a: number, b: number) => a * b,\n}\n\ntype Operator = keyof typeof operators\n\nexport const calc = (...valuesAndOperators: (CalcVal | Operator)[]) => {\n if (isWeb) {\n let res = 'calc('\n for (const cur of valuesAndOperators) {\n if (operators[cur as any]) {\n // spaces are significant\n res += ' ' + cur + ' '\n } else {\n res += convertToVariableOrNumber(cur)\n }\n }\n return res + ')'\n }\n\n let res = 0\n let nextOp: any = null\n for (const cur of valuesAndOperators) {\n if (operators[cur as any]) {\n nextOp = operators[cur as any]\n } else {\n if (nextOp) {\n res = nextOp(res, cur)\n nextOp = null\n } else {\n res = +cur\n }\n }\n }\n return res\n}\n\nconst convertToVariableOrNumber = (v: any) => {\n const varOrVal = getVariableVariable(v)\n if (typeof varOrVal === 'number') {\n return `${varOrVal}px`\n }\n return varOrVal\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AAEtB,4BAAoC;AAmBpC,MAAM,YAAY;AAAA,EAChB,KAAK,CAAC,GAAW,MAAc,IAAI;AAAA,EACnC,KAAK,CAAC,GAAW,MAAc,IAAI;AAAA,EACnC,KAAK,CAAC,GAAW,MAAc,IAAI;AAAA,EACnC,KAAK,CAAC,GAAW,MAAc,IAAI;AACrC;AAIO,MAAM,OAAO,IAAI,uBAA+C;AACrE,MAAI,wBAAO;AACT,QAAIA,OAAM;AACV,eAAW,OAAO,oBAAoB;AACpC,UAAI,UAAU,MAAa;AAEzB,QAAAA,QAAO,MAAM,MAAM;AAAA,MACrB,OAAO;AACL,QAAAA,QAAO,0BAA0B,GAAG;AAAA,MACtC;AAAA,IACF;AACA,WAAOA,OAAM;AAAA,EACf;AAEA,MAAI,MAAM;AACV,MAAI,SAAc;AAClB,aAAW,OAAO,oBAAoB;AACpC,QAAI,UAAU,MAAa;AACzB,eAAS,UAAU;AAAA,IACrB,OAAO;AACL,UAAI,QAAQ;AACV,cAAM,OAAO,KAAK,GAAG;AACrB,iBAAS;AAAA,MACX,OAAO;AACL,cAAM,CAAC;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,4BAA4B,CAAC,MAAW;AAC5C,QAAM,eAAW,2CAAoB,CAAC;AACtC,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO,GAAG;AAAA,EACZ;AACA,SAAO;AACT;",
6
- "names": ["res"]
7
- }