@tamagui/core 1.0.0-beta.0.210 → 1.0.0-beta.10

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 (88) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/createComponent.js +35 -9
  3. package/dist/cjs/createComponent.js.map +2 -2
  4. package/dist/cjs/helpers/createPropMapper.js +34 -3
  5. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  6. package/dist/cjs/helpers/getButtonSize.js +45 -0
  7. package/dist/cjs/helpers/getButtonSize.js.map +7 -0
  8. package/dist/cjs/helpers/getSplitStyles.js +36 -13
  9. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  10. package/dist/cjs/helpers/getTextSize.js +56 -0
  11. package/dist/cjs/helpers/getTextSize.js.map +7 -0
  12. package/dist/cjs/helpers/insertStyleRule.js +1 -0
  13. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  14. package/dist/cjs/hooks/useId.js +59 -0
  15. package/dist/cjs/hooks/useId.js.map +7 -0
  16. package/dist/cjs/hooks/useIsTouchDevice.js +4 -4
  17. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  18. package/dist/cjs/hooks/useMedia.js +0 -1
  19. package/dist/cjs/hooks/useMedia.js.map +2 -2
  20. package/dist/cjs/hooks/useTheme.js.map +2 -2
  21. package/dist/cjs/index.js +9 -6
  22. package/dist/cjs/index.js.map +2 -2
  23. package/dist/cjs/styled.js +4 -1
  24. package/dist/cjs/styled.js.map +2 -2
  25. package/dist/cjs/types.js.map +1 -1
  26. package/dist/cjs/views/Slot.js +115 -0
  27. package/dist/cjs/views/Slot.js.map +7 -0
  28. package/dist/esm/createComponent.js +36 -11
  29. package/dist/esm/createComponent.js.map +2 -2
  30. package/dist/esm/helpers/createPropMapper.js +35 -3
  31. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  32. package/dist/esm/helpers/getButtonSize.js +24 -0
  33. package/dist/esm/helpers/getButtonSize.js.map +7 -0
  34. package/dist/esm/helpers/getSplitStyles.js +40 -15
  35. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  36. package/dist/esm/helpers/getTextSize.js +34 -0
  37. package/dist/esm/helpers/getTextSize.js.map +7 -0
  38. package/dist/esm/helpers/insertStyleRule.js +1 -0
  39. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  40. package/dist/esm/hooks/useId.js +35 -0
  41. package/dist/esm/hooks/useId.js.map +7 -0
  42. package/dist/esm/hooks/useIsTouchDevice.js +6 -6
  43. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  44. package/dist/esm/hooks/useMedia.js +0 -1
  45. package/dist/esm/hooks/useMedia.js.map +2 -2
  46. package/dist/esm/hooks/useTheme.js.map +2 -2
  47. package/dist/esm/index.js +9 -6
  48. package/dist/esm/index.js.map +2 -2
  49. package/dist/esm/styled.js +4 -1
  50. package/dist/esm/styled.js.map +2 -2
  51. package/dist/esm/views/Slot.js +63 -0
  52. package/dist/esm/views/Slot.js.map +7 -0
  53. package/dist/jsx/createComponent.js +36 -11
  54. package/dist/jsx/helpers/createPropMapper.js +35 -3
  55. package/dist/jsx/helpers/getButtonSize.js +23 -0
  56. package/dist/jsx/helpers/getSplitStyles.js +40 -15
  57. package/dist/jsx/helpers/getTextSize.js +33 -0
  58. package/dist/jsx/helpers/insertStyleRule.js +1 -0
  59. package/dist/jsx/hooks/useId.js +34 -0
  60. package/dist/jsx/hooks/useIsTouchDevice.js +6 -6
  61. package/dist/jsx/hooks/useMedia.js +0 -1
  62. package/dist/jsx/index.js +9 -6
  63. package/dist/jsx/styled.js +4 -1
  64. package/dist/jsx/views/Slot.js +56 -0
  65. package/package.json +6 -6
  66. package/types/createComponent.d.ts.map +1 -1
  67. package/types/helpers/createPropMapper.d.ts +1 -1
  68. package/types/helpers/createPropMapper.d.ts.map +1 -1
  69. package/types/helpers/getButtonSize.d.ts +8 -0
  70. package/types/helpers/getButtonSize.d.ts.map +1 -0
  71. package/types/helpers/getSplitStyles.d.ts +10 -5
  72. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  73. package/types/helpers/getTextSize.d.ts +3 -0
  74. package/types/helpers/getTextSize.d.ts.map +1 -0
  75. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  76. package/types/hooks/useId.d.ts +9 -0
  77. package/types/hooks/useId.d.ts.map +1 -0
  78. package/types/hooks/useMedia.d.ts +3 -7
  79. package/types/hooks/useMedia.d.ts.map +1 -1
  80. package/types/hooks/useTheme.d.ts.map +1 -1
  81. package/types/index.d.ts +9 -6
  82. package/types/index.d.ts.map +1 -1
  83. package/types/styled.d.ts.map +1 -1
  84. package/types/types.d.ts +23 -8
  85. package/types/types.d.ts.map +1 -1
  86. package/types/views/Slot.d.ts +9 -0
  87. package/types/views/Slot.d.ts.map +1 -0
  88. package/LICENSE +0 -21
@@ -16,18 +16,20 @@ import React, {
16
16
  import { StyleSheet, Text, View } from "react-native";
17
17
  import { onConfiguredOnce } from "./conf";
18
18
  import { stackDefaultStyles } from "./constants/constants";
19
- import { isAndroid, isTouchDevice, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
19
+ import { isAndroid, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
20
20
  import { rnw } from "./constants/rnw";
21
21
  import { isVariable } from "./createVariable";
22
22
  import { createShallowUpdate } from "./helpers/createShallowUpdate";
23
23
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
24
- import { getSplitStyles } from "./helpers/getSplitStyles";
24
+ import { insertSplitStyles, useSplitStyles } from "./helpers/getSplitStyles";
25
25
  import { getAllSelectors } from "./helpers/insertStyleRule";
26
26
  import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
27
27
  import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
28
28
  import { useFeatures } from "./hooks/useFeatures";
29
+ import { useIsTouchDevice } from "./hooks/useIsTouchDevice";
29
30
  import { usePressable } from "./hooks/usePressable";
30
31
  import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
32
+ import { Slot } from "./views/Slot";
31
33
  import { TextAncestorContext } from "./views/TextAncestorContext";
32
34
  React["keep"];
33
35
  const defaultComponentState = {
@@ -44,6 +46,14 @@ if (typeof document !== "undefined") {
44
46
  mouseUps.forEach((x) => x());
45
47
  mouseUps.clear();
46
48
  });
49
+ document.addEventListener("touchend", () => {
50
+ mouseUps.forEach((x) => x());
51
+ mouseUps.clear();
52
+ });
53
+ document.addEventListener("touchcancel", () => {
54
+ mouseUps.forEach((x) => x());
55
+ mouseUps.clear();
56
+ });
47
57
  }
48
58
  function mergeShorthands({ defaultProps }, { shorthands }) {
49
59
  for (const key in defaultProps) {
@@ -68,6 +78,7 @@ function createComponent(configIn, ParentComponent) {
68
78
  let avoidClasses = true;
69
79
  let defaultNativeStyle;
70
80
  let defaultNativeStyleSheet;
81
+ let tamaguiDefaultProps;
71
82
  let initialSplitStyles;
72
83
  function addPseudoToStyles(styles, name, pseudos) {
73
84
  const pseudoStyle = pseudos[name];
@@ -83,11 +94,12 @@ function createComponent(configIn, ParentComponent) {
83
94
  __name(addPseudoToStyles, "addPseudoToStyles");
84
95
  const component = forwardRef((props, forwardedRef) => {
85
96
  var _a, _b, _c, _d;
97
+ props = tamaguiDefaultProps && !props.asChild ? { ...tamaguiDefaultProps, ...props } : props;
86
98
  const { Component, componentName, isText, isZStack } = staticConfig;
87
99
  if (process.env.NODE_ENV === "development") {
88
100
  if (props["debug"]) {
89
101
  console.warn(staticConfig.componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
90
- console.log("props in:", props);
102
+ console.log("props in:", props, Object.keys(props));
91
103
  if (props["debug"] === "break")
92
104
  debugger;
93
105
  }
@@ -97,7 +109,7 @@ function createComponent(configIn, ParentComponent) {
97
109
  const [state, set_] = useState(defaultComponentState);
98
110
  const setStateShallow = createShallowUpdate(set_);
99
111
  const shouldAvoidClasses = !!(props.animation && avoidClasses);
100
- const splitStyles = getSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses ? null : initialSplitStyles.classNames);
112
+ const splitStyles = useSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames);
101
113
  const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
102
114
  const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
103
115
  const isAnimated = !!(useAnimations && props.animation);
@@ -116,6 +128,7 @@ function createComponent(configIn, ParentComponent) {
116
128
  const {
117
129
  tag,
118
130
  hitSlop,
131
+ asChild,
119
132
  children,
120
133
  pointerEvents,
121
134
  onPress,
@@ -199,7 +212,7 @@ function createComponent(configIn, ParentComponent) {
199
212
  if (accessibilityRole)
200
213
  viewProps.accessibilityRole = accessibilityRole;
201
214
  }
202
- if (isWeb) {
215
+ if (isWeb && !asChild) {
203
216
  rnw.useResponderEvents(hostRef, {
204
217
  onMoveShouldSetResponder,
205
218
  onMoveShouldSetResponderCapture,
@@ -303,10 +316,11 @@ function createComponent(configIn, ParentComponent) {
303
316
  }
304
317
  const initialPseudos = initialSplitStyles.pseudos;
305
318
  const attachPress = !!(pseudos && pseudos.pressStyle || initialPseudos && initialPseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
306
- const isHoverable = isWeb && !isTouchDevice;
319
+ const isTouch = useIsTouchDevice();
320
+ const isHoverable = isWeb && !isTouch;
307
321
  const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
308
322
  const pressEventKey = isStringElement ? "onClick" : "onPress";
309
- const shouldAttach = attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props);
323
+ const shouldAttach = !asChild && (attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props));
310
324
  const unPress = useCallback(() => {
311
325
  if (!internal.current.isMounted)
312
326
  return;
@@ -361,15 +375,18 @@ function createComponent(configIn, ParentComponent) {
361
375
  });
362
376
  onPressIn == null ? void 0 : onPressIn(e);
363
377
  onMouseDown == null ? void 0 : onMouseDown(e);
378
+ if (isWeb) {
379
+ mouseUps.add(unPress);
380
+ }
364
381
  } : null,
365
382
  [pressEventKey]: attachPress ? (e) => {
383
+ onClick == null ? void 0 : onClick(e);
366
384
  onPress == null ? void 0 : onPress(e);
367
385
  unPress();
368
386
  onPressOut == null ? void 0 : onPressOut(e);
369
- onClick == null ? void 0 : onClick(e);
370
387
  } : null
371
388
  } : null;
372
- let childEls = !children ? children : wrapThemeManagerContext(spacedChildren({
389
+ const childEls = !children || asChild ? children : wrapThemeManagerContext(spacedChildren({
373
390
  children,
374
391
  space,
375
392
  flexDirection: props.flexDirection || ((_b = staticConfig.defaultProps) == null ? void 0 : _b.flexDirection),
@@ -409,6 +426,11 @@ function createComponent(configIn, ParentComponent) {
409
426
  Object.assign(viewProps, events);
410
427
  }
411
428
  }
429
+ if (asChild) {
430
+ ViewComponent = Slot;
431
+ const onlyChild = React.Children.only(children);
432
+ Object.assign(viewProps, onlyChild.props);
433
+ }
412
434
  content = createElement(ViewComponent, viewProps, childEls);
413
435
  if (isWeb && events && attachHover) {
414
436
  content = <span className="tui_Hoverable" style={{
@@ -441,7 +463,7 @@ function createComponent(configIn, ParentComponent) {
441
463
  AnimatedText = (_b = tamaguiConfig.animations) == null ? void 0 : _b.Text;
442
464
  AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
443
465
  initialTheme = initialTheme || proxyThemeVariables(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
444
- initialSplitStyles = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
466
+ initialSplitStyles = insertSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
445
467
  mounted: true,
446
468
  hover: false,
447
469
  press: false,
@@ -459,10 +481,13 @@ function createComponent(configIn, ParentComponent) {
459
481
  defaultNativeStyleSheet = StyleSheet.create({
460
482
  base: defaultNativeStyle
461
483
  });
462
- component.defaultProps = {
484
+ const defaults = {
463
485
  ...viewProps,
464
486
  ...component.defaultProps
465
487
  };
488
+ if (Object.keys(defaults).length) {
489
+ tamaguiDefaultProps = defaults;
490
+ }
466
491
  if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
467
492
  if (process.env.IS_STATIC !== "is_static") {
468
493
  console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
@@ -63,7 +63,7 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
63
63
  if (isObj(variantValue)) {
64
64
  variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
65
65
  }
66
- return variantValue;
66
+ return expansions(variantValue);
67
67
  }
68
68
  }
69
69
  let shouldReturn = false;
@@ -80,9 +80,9 @@ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
80
80
  }
81
81
  }
82
82
  if (shouldReturn) {
83
- return {
83
+ return expansions({
84
84
  [key]: value
85
- };
85
+ });
86
86
  }
87
87
  };
88
88
  }, "createPropMapper");
@@ -200,6 +200,38 @@ const tokenCategories = {
200
200
  borderRightColor: true
201
201
  }
202
202
  };
203
+ const sidesX = ["Left", "Right"];
204
+ const sidesY = ["Top", "Bottom"];
205
+ const sidesXY = [...sidesX, ...sidesY];
206
+ const expand = {
207
+ padding: sidesXY.map((x) => `padding${x}`),
208
+ paddingHorizontal: sidesX.map((x) => `padding${x}`),
209
+ paddingVertical: sidesY.map((x) => `padding${x}`),
210
+ margin: sidesXY.map((x) => `margin${x}`),
211
+ marginHorizontal: sidesX.map((x) => `margin${x}`),
212
+ marginVertical: sidesY.map((x) => `margin${x}`),
213
+ borderWidth: sidesXY.map((x) => `border${x}Width`)
214
+ };
215
+ function expansions(styleObj) {
216
+ var _a, _b;
217
+ for (const key in expand) {
218
+ if (key in styleObj) {
219
+ for (const expandKey of expand[key]) {
220
+ styleObj[expandKey] = styleObj[key];
221
+ }
222
+ delete styleObj[key];
223
+ }
224
+ }
225
+ if ("flex" in styleObj) {
226
+ if (typeof styleObj.flex === "number") {
227
+ styleObj.flexGrow = (_a = styleObj.flexGrow) != null ? _a : styleObj.flex;
228
+ styleObj.flexShrink = (_b = styleObj.flexShrink) != null ? _b : 1;
229
+ delete styleObj.flex;
230
+ }
231
+ }
232
+ return styleObj;
233
+ }
234
+ __name(expansions, "expansions");
203
235
  export {
204
236
  createPropMapper
205
237
  };
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { getVariableValue, isVariable } from "@tamagui/core";
4
+ const getButtonSize = /* @__PURE__ */ __name((sizeX = 0.9, sizeY = 0.333) => (val, { tokens, props, fonts }) => {
5
+ var _a, _b, _c, _d, _e, _f, _g;
6
+ const size = (_c = (_b = (_a = tokens.size[val]) != null ? _a : tokens.size["$4"]) != null ? _b : val) != null ? _c : 14;
7
+ const radius = (_e = (_d = tokens.radius[val]) != null ? _d : tokens.radius["$4"]) != null ? _e : size;
8
+ const px = Math.round(+(isVariable(size) ? size.val : size) * sizeX);
9
+ const py = Math.round(+(isVariable(size) ? size.val : size) * sizeY);
10
+ const font = fonts[props.fontFamily] || fonts["$body"];
11
+ const lineHeights = font.lineHeight;
12
+ const lineHeight = (_f = lineHeights[val]) != null ? _f : lineHeights["$4"];
13
+ const minHeight = Math.round(getVariableValue(lineHeight) + py * 2);
14
+ return {
15
+ minHeight,
16
+ paddingHorizontal: props.circular ? 0 : px,
17
+ paddingVertical: props.circular ? 0 : py,
18
+ borderRadius: props.circular ? 1e5 : (_g = props.borderRadius) != null ? _g : radius
19
+ };
20
+ }, "getButtonSize");
21
+ export {
22
+ getButtonSize
23
+ };
@@ -7,13 +7,19 @@ import {
7
7
  validPseudoKeys,
8
8
  validStyles
9
9
  } from "@tamagui/helpers";
10
+ import { useInsertionEffect } from "react";
10
11
  import { getConfig } from "../conf";
11
- import { isClient, isWeb } from "../constants/platform";
12
+ import { isClient, isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
12
13
  import { mediaQueryConfig, mediaState } from "../hooks/useMedia";
13
14
  import { createMediaStyle } from "./createMediaStyle";
14
15
  import { fixNativeShadow } from "./fixNativeShadow";
15
16
  import { getStylesAtomic } from "./getStylesAtomic";
16
- import { insertStyleRule, insertedTransforms, updateInserted } from "./insertStyleRule";
17
+ import {
18
+ insertStyleRule,
19
+ insertedTransforms,
20
+ updateInserted,
21
+ updateInsertedCache
22
+ } from "./insertStyleRule";
17
23
  const skipProps = {
18
24
  animation: true,
19
25
  animateOnly: true,
@@ -34,6 +40,12 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
34
40
  };
35
41
  const pseudos = {};
36
42
  const medias = {};
43
+ const rulesToInsert = [];
44
+ function addStyle(prop, rule) {
45
+ rulesToInsert.push([prop, rule]);
46
+ updateInsertedCache(prop, rule);
47
+ }
48
+ __name(addStyle, "addStyle");
37
49
  let cur = null;
38
50
  let transforms = {};
39
51
  function mergeClassName(key, val) {
@@ -89,7 +101,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
89
101
  const atomic = getStylesAtomic(cur);
90
102
  for (const atomicStyle of atomic) {
91
103
  if (!state.noClassNames) {
92
- insertStyleRule(atomicStyle.identifier, atomicStyle.rules[0]);
104
+ addStyle(atomicStyle.identifier, atomicStyle.rules[0]);
93
105
  mergeClassName(atomicStyle.property, atomicStyle.identifier);
94
106
  } else {
95
107
  style[atomicStyle.property] = atomicStyle.value;
@@ -162,7 +174,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
162
174
  if (isWeb && !state.noClassNames) {
163
175
  const pseudoStyles = getStylesAtomic({ [key]: pseudos[key] });
164
176
  for (const style2 of pseudoStyles) {
165
- insertStyleRule(style2.identifier, style2.rules[0]);
177
+ addStyle(style2.identifier, style2.rules[0]);
166
178
  mergeClassName(`${style2.property}-${key}`, style2.identifier);
167
179
  }
168
180
  }
@@ -184,7 +196,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
184
196
  const mediaStyles = getStylesAtomic(mediaStyle);
185
197
  for (const style2 of mediaStyles) {
186
198
  const out2 = createMediaStyle(style2, mediaKeyShort, mediaQueryConfig);
187
- insertStyleRule(out2.identifier, out2.styleRule);
199
+ addStyle(out2.identifier, out2.styleRule);
188
200
  mergeClassName(`${out2.identifier}-${mediaKey}`, out2.identifier);
189
201
  }
190
202
  } else {
@@ -223,7 +235,7 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
223
235
  if (isClient) {
224
236
  if (!insertedTransforms[identifier]) {
225
237
  const rule = `.${identifier} { transform: ${val}; }`;
226
- insertStyleRule(identifier, rule);
238
+ addStyle(identifier, rule);
227
239
  }
228
240
  }
229
241
  classNames[namespace] = identifier;
@@ -237,9 +249,27 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
237
249
  style,
238
250
  medias,
239
251
  pseudos,
240
- classNames
252
+ classNames,
253
+ rulesToInsert
241
254
  };
242
255
  }, "getSplitStyles");
256
+ const insertSplitStyles = /* @__PURE__ */ __name((...args) => {
257
+ const res = getSplitStyles(...args);
258
+ for (const [prop, rule] of res.rulesToInsert) {
259
+ insertStyleRule(prop, rule);
260
+ }
261
+ return res;
262
+ }, "insertSplitStyles");
263
+ const effect = useInsertionEffect || useIsomorphicLayoutEffect;
264
+ const useSplitStyles = /* @__PURE__ */ __name((...args) => {
265
+ const res = getSplitStyles(...args);
266
+ effect(() => {
267
+ for (const [prop, rule] of res.rulesToInsert) {
268
+ insertStyleRule(prop, rule);
269
+ }
270
+ });
271
+ return res;
272
+ }, "useSplitStyles");
243
273
  const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props, state, avoidDefaultProps) => {
244
274
  const styleOut = {};
245
275
  for (const key in styleIn) {
@@ -258,13 +288,6 @@ const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props,
258
288
  return styleOut;
259
289
  }, "getSubStyle");
260
290
  function normalizeStyleObject(style) {
261
- var _a, _b;
262
- if (typeof style.flex === "number") {
263
- const val = style.flex;
264
- delete style.flex;
265
- style.flexGrow = (_a = style.flexGrow) != null ? _a : val;
266
- style.flexShrink = (_b = style.flexShrink) != null ? _b : 1;
267
- }
268
291
  if (!isWeb) {
269
292
  fixNativeShadow(style);
270
293
  }
@@ -273,5 +296,7 @@ __name(normalizeStyleObject, "normalizeStyleObject");
273
296
  export {
274
297
  getSplitStyles,
275
298
  getSubStyle,
276
- normalizeStyleObject
299
+ insertSplitStyles,
300
+ normalizeStyleObject,
301
+ useSplitStyles
277
302
  };
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { getVariableValue } from "../createVariable";
4
+ const getTextSize = /* @__PURE__ */ __name((val = "$4", { fonts, theme, props }) => {
5
+ var _a, _b, _c;
6
+ const family = getVariableValue(props.fontFamily) || "$body";
7
+ const font = fonts[family] || fonts["$body"];
8
+ if (!font) {
9
+ console.warn("\u26A0\uFE0F no font found", { family, fontTokens: Object.keys(fonts), val });
10
+ return;
11
+ }
12
+ const fontFamily = font.family;
13
+ const fontSize = props.fontSize || font.size[val];
14
+ const lineHeight = props.lineHeight || font.lineHeight[val];
15
+ const fontWeight = props.fontWeight || font.weight[val];
16
+ const letterSpacing = props.letterSpacing || font.letterSpacing[val];
17
+ const fontStyle = props.fontStyle || ((_a = font.style) == null ? void 0 : _a[val]);
18
+ const textTransform = props.textTransform || ((_b = font.transform) == null ? void 0 : _b[val]);
19
+ const color = props.color || ((_c = font.color) == null ? void 0 : _c[val]) || theme.color;
20
+ return {
21
+ color,
22
+ fontStyle,
23
+ textTransform,
24
+ fontFamily,
25
+ fontWeight,
26
+ letterSpacing,
27
+ fontSize,
28
+ lineHeight
29
+ };
30
+ }, "getTextSize");
31
+ export {
32
+ getTextSize
33
+ };
@@ -79,6 +79,7 @@ function insertStyleRule(identifier, rule) {
79
79
  return;
80
80
  hasInsertedSinceUpdate = true;
81
81
  updateInsertedCache(identifier, rule);
82
+ allSelectors[identifier] = process.env.NODE_ENV === "development" ? rule : true;
82
83
  sheet == null ? void 0 : sheet.insertRule(rule, sheet.cssRules.length);
83
84
  }
84
85
  __name(insertStyleRule, "insertStyleRule");
@@ -0,0 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import * as React from "react";
4
+ import { useIsomorphicLayoutEffect } from "../constants/platform";
5
+ let serverHandoffComplete = false;
6
+ let id = 0;
7
+ function genId() {
8
+ return ++id;
9
+ }
10
+ __name(genId, "genId");
11
+ function useId(providedId) {
12
+ var _a;
13
+ if (typeof React.useId === "function") {
14
+ let id3 = React.useId(providedId);
15
+ return providedId != null ? providedId : id3;
16
+ }
17
+ let initialId = providedId != null ? providedId : serverHandoffComplete ? genId() : null;
18
+ let [id2, setId] = React.useState(initialId);
19
+ useIsomorphicLayoutEffect(() => {
20
+ if (id2 === null) {
21
+ setId(genId());
22
+ }
23
+ }, []);
24
+ React.useEffect(() => {
25
+ if (serverHandoffComplete === false) {
26
+ serverHandoffComplete = true;
27
+ }
28
+ }, []);
29
+ return (_a = providedId != null ? providedId : id2) != null ? _a : void 0;
30
+ }
31
+ __name(useId, "useId");
32
+ export {
33
+ useId
34
+ };
@@ -1,14 +1,14 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useEffect, useState } from "react";
4
- import { isTouchDevice } from "../constants/platform";
3
+ import { useState } from "react";
4
+ import { isTouchDevice, useIsomorphicLayoutEffect } from "../constants/platform";
5
5
  const useIsTouchDevice = /* @__PURE__ */ __name(() => {
6
6
  const [touchOnly, setTouchOnly] = useState(false);
7
- if (isTouchDevice) {
8
- useEffect(() => {
7
+ useIsomorphicLayoutEffect(() => {
8
+ if (isTouchDevice) {
9
9
  setTouchOnly(true);
10
- }, []);
11
- }
10
+ }
11
+ }, []);
12
12
  return touchOnly;
13
13
  }, "useIsTouchDevice");
14
14
  export {
@@ -86,7 +86,6 @@ const useMedia = /* @__PURE__ */ __name(() => {
86
86
  }
87
87
  for (const key in st.nextSelections) {
88
88
  if (!(key in st.selections)) {
89
- console.log("lsiten", key);
90
89
  addMediaQueryListener(key, forceUpdate);
91
90
  }
92
91
  }
package/dist/jsx/index.js CHANGED
@@ -13,31 +13,34 @@ import { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } f
13
13
  export * from "./constants/constants";
14
14
  export * from "./constants/platform";
15
15
  export * from "./constants/rnw";
16
+ export * from "./helpers/getButtonSize";
16
17
  export * from "./helpers/getExpandedShorthands";
17
18
  export * from "./helpers/getSize";
18
19
  export * from "./helpers/getSplitStyles";
19
20
  export * from "./helpers/getStylesAtomic";
21
+ export * from "./helpers/getTextSize";
20
22
  export * from "./helpers/isObj";
21
23
  export * from "./helpers/isTamaguiElement";
22
24
  export * from "./helpers/matchMedia";
23
25
  export * from "./helpers/themeable";
24
26
  export * from "./helpers/withStaticProperties";
25
27
  export * from "./contexts/ButtonInsideButtonContext";
26
- export * from "./hooks/useIsTouchDevice";
27
28
  export * from "./hooks/useConstant";
28
- export * from "./hooks/usePressable";
29
+ export * from "./hooks/useId";
30
+ export * from "./hooks/useIsMounted";
31
+ export * from "./hooks/useIsTouchDevice";
29
32
  export * from "./hooks/useMedia";
33
+ export * from "./hooks/usePressable";
30
34
  export * from "./hooks/useTheme";
31
- export * from "./hooks/useIsMounted";
32
35
  export * from "./hooks/useUnmountEffect";
33
- export * from "@tamagui/use-force-update";
34
36
  export * from "./views/Stack";
35
37
  export * from "./views/Text";
38
+ export * from "./views/TextAncestorContext";
36
39
  export * from "./views/Theme";
37
- export * from "./views/ThemeReset";
38
40
  export * from "./views/ThemeInverse";
39
41
  export * from "./views/ThemeProvider";
40
- export * from "./views/TextAncestorContext";
42
+ export * from "./views/ThemeReset";
43
+ export * from "@tamagui/use-force-update";
41
44
  export * from "@tamagui/helpers";
42
45
  export {
43
46
  RNWTextProps,
@@ -5,14 +5,16 @@ import { createComponent } from "./createComponent";
5
5
  import { RNComponents } from "./helpers/RNComponents";
6
6
  function styled(Component, options, staticExtractionOptions) {
7
7
  const staticConfigProps = (() => {
8
+ var _a;
8
9
  if (options) {
9
10
  const { variants, name, defaultVariants, ...defaultProps } = options;
10
11
  if (defaultVariants) {
11
12
  Object.assign(defaultProps, defaultVariants);
12
13
  }
13
14
  const isReactNativeWeb = "staticConfig" in Component ? Component.staticConfig.isReactNativeWeb : RNComponents.has(Component);
15
+ const reactNativeWebComponent = isReactNativeWeb ? ((_a = Component["staticConfig"]) == null ? void 0 : _a.reactNativeWebComponent) || Component : null;
14
16
  const isTamagui = !isReactNativeWeb && "staticConfig" in Component;
15
- const Comp = Component;
17
+ const Comp = reactNativeWebComponent || Component;
16
18
  const isImage = !!(defaultProps.isImage || (!isTamagui ? Comp === Image : false));
17
19
  const isInput = !!(defaultProps.isInput || (!isTamagui ? Comp === TextInput : false));
18
20
  const isText = !!(defaultProps.isText || (!isTamagui ? isInput || Comp === Text : false));
@@ -27,6 +29,7 @@ function styled(Component, options, staticExtractionOptions) {
27
29
  defaultVariants,
28
30
  componentName: name,
29
31
  isReactNativeWeb,
32
+ reactNativeWebComponent,
30
33
  isInput,
31
34
  isText,
32
35
  isImage
@@ -0,0 +1,56 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { composeRefs } from "@tamagui/compose-refs";
4
+ import * as React from "react";
5
+ const Slot = React.forwardRef((props, forwardedRef) => {
6
+ const { children, ...slotProps } = props;
7
+ if (React.Children.toArray(children).some(isSlottable)) {
8
+ return <>{React.Children.map(children, (child) => {
9
+ return isSlottable(child) ? <SlotClone {...slotProps} ref={forwardedRef}>{child.props.children}</SlotClone> : child;
10
+ })}</>;
11
+ }
12
+ return <SlotClone {...slotProps} ref={forwardedRef}>{children}</SlotClone>;
13
+ });
14
+ Slot.displayName = "Slot";
15
+ const SlotClone = React.forwardRef((props, forwardedRef) => {
16
+ const { children, ...slotProps } = props;
17
+ if (React.isValidElement(children)) {
18
+ return React.cloneElement(children, {
19
+ ...mergeProps(slotProps, children.props),
20
+ ref: composeRefs(forwardedRef, children.ref)
21
+ });
22
+ }
23
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
24
+ });
25
+ SlotClone.displayName = "SlotClone";
26
+ const Slottable = /* @__PURE__ */ __name(({ children }) => {
27
+ return <>{children}</>;
28
+ }, "Slottable");
29
+ function isSlottable(child) {
30
+ return React.isValidElement(child);
31
+ }
32
+ __name(isSlottable, "isSlottable");
33
+ function mergeProps(slotProps, childProps) {
34
+ const overrideProps = { ...childProps };
35
+ for (const propName in childProps) {
36
+ const slotPropValue = slotProps[propName];
37
+ const childPropValue = childProps[propName];
38
+ const isHandler = /^on[A-Z]/.test(propName);
39
+ if (isHandler) {
40
+ overrideProps[propName] = (...args) => {
41
+ childPropValue == null ? void 0 : childPropValue(...args);
42
+ slotPropValue == null ? void 0 : slotPropValue(...args);
43
+ };
44
+ } else if (propName === "style") {
45
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
46
+ } else if (propName === "className") {
47
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
48
+ }
49
+ }
50
+ return { ...slotProps, ...overrideProps };
51
+ }
52
+ __name(mergeProps, "mergeProps");
53
+ export {
54
+ Slot,
55
+ Slottable
56
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.0.0-beta.0.210+65505f90",
3
+ "version": "1.0.0-beta.10",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -19,10 +19,10 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@tamagui/helpers": "^1.0.0-beta.0.210+65505f90",
22
+ "@tamagui/helpers": "^1.0.0-beta.10",
23
23
  "@tamagui/ow": "^0.28.1",
24
- "@tamagui/use-debounce": "^1.0.0-beta.0.210+65505f90",
25
- "@tamagui/use-force-update": "^1.0.0-beta.0.210+65505f90",
24
+ "@tamagui/use-debounce": "^1.0.0-beta.10",
25
+ "@tamagui/use-force-update": "^1.0.0-beta.10",
26
26
  "react": "*",
27
27
  "react-dom": "*"
28
28
  },
@@ -30,7 +30,7 @@
30
30
  "react-native-web": "*"
31
31
  },
32
32
  "devDependencies": {
33
- "@tamagui/build": "^1.0.0-beta.0.210+65505f90",
33
+ "@tamagui/build": "^1.0.0-beta.10",
34
34
  "@types/react": "^17.0.35",
35
35
  "csstype": "^3.0.10",
36
36
  "esbuild": "^0.14.36",
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "65505f906d14f6cdb78d2a59683f6f1ce0ae292a"
43
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
44
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAoB,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAgBhE,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAKjB,MAAM,SAAS,CAAA;AAehB,eAAO,MAAM,QAAQ,eAAsB,CAAA;AAkB3C,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,GAAG,EAAE,EACtC,GAAG,GAAG,IAAI,EACV,SAAS,GAAG,KAAK,EACjB,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,EAAE,eAAe,CAAC,EAAE,iBAAiB,4DA2mB1F;AAKD,eAAO,MAAM,MAAM;;;;mBA4CjB,CAAA;AAEF,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,aAAa,EACb,SAAS,GACV,EAAE;IACD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,GAAG,CAAA;IACb,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,aAAa,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,CAAA;CAC3C,SA2CA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,eAkBtC"}
1
+ {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAoB,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAiBhE,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAKjB,MAAM,SAAS,CAAA;AAgBhB,eAAO,MAAM,QAAQ,eAAsB,CAAA;AA0B3C,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,GAAG,EAAE,EACtC,GAAG,GAAG,IAAI,EACV,SAAS,GAAG,KAAK,EACjB,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,EAAE,eAAe,CAAC,EAAE,iBAAiB,4DAsoB1F;AAKD,eAAO,MAAM,MAAM;;;;mBA4CjB,CAAA;AAEF,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,aAAa,EACb,SAAS,GACV,EAAE;IACD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,GAAG,CAAA;IACb,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,aAAa,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,CAAA;CAC3C,SA2CA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,eAkBtC"}
@@ -1,4 +1,4 @@
1
1
  import { StaticConfig } from '../types';
2
2
  export declare type ResolveVariableTypes = 'auto' | 'value' | 'variable' | 'both';
3
- export declare const createPropMapper: (staticConfig: Partial<StaticConfig>) => (key: string, value: any, theme: any, props: any, returnVariablesAs?: ResolveVariableTypes, avoidDefaultProps?: boolean) => any;
3
+ export declare const createPropMapper: (staticConfig: Partial<StaticConfig>) => (key: string, value: any, theme: any, props: any, returnVariablesAs?: ResolveVariableTypes, avoidDefaultProps?: boolean) => Record<string, any> | undefined;
4
4
  //# sourceMappingURL=createPropMapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createPropMapper.d.ts","sourceRoot":"","sources":["../../src/helpers/createPropMapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAgD,MAAM,UAAU,CAAA;AAGrF,oBAAY,oBAAoB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAA;AA4BzE,eAAO,MAAM,gBAAgB,iBAAkB,QAAQ,YAAY,CAAC,WAK3D,MAAM,SACJ,GAAG,SACH,GAAG,SACH,GAAG,sBACS,oBAAoB,qCAyE1C,CAAA"}
1
+ {"version":3,"file":"createPropMapper.d.ts","sourceRoot":"","sources":["../../src/helpers/createPropMapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAgD,MAAM,UAAU,CAAA;AAGrF,oBAAY,oBAAoB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAA;AA4BzE,eAAO,MAAM,gBAAgB,iBAAkB,QAAQ,YAAY,CAAC,WAK3D,MAAM,SACJ,GAAG,SACH,GAAG,SACH,GAAG,sBACS,oBAAoB,iEAyE1C,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { VariantSpreadExtras } from '@tamagui/core';
2
+ export declare const getButtonSize: (sizeX?: number, sizeY?: number) => (val: any, { tokens, props, fonts }: VariantSpreadExtras<any>) => {
3
+ minHeight: number;
4
+ paddingHorizontal: number;
5
+ paddingVertical: number;
6
+ borderRadius: any;
7
+ };
8
+ //# sourceMappingURL=getButtonSize.d.ts.map