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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -56,7 +56,6 @@ var __toModule = (module2) => {
56
56
  __export(exports, {
57
57
  AnimatedStack: () => AnimatedStack,
58
58
  GET_DEFAULT_THEME: () => GET_DEFAULT_THEME,
59
- SafeAreaProvider: () => SafeAreaProvider,
60
59
  Spacer: () => Spacer,
61
60
  Stack: () => Stack,
62
61
  Text: () => Text2,
@@ -83,6 +82,7 @@ __export(exports, {
83
82
  isChrome: () => isChrome,
84
83
  isObj: () => isObj,
85
84
  isSSR: () => isSSR,
85
+ isTamaguiElement: () => isTamaguiElement,
86
86
  isTouchDevice: () => isTouchDevice,
87
87
  isVariable: () => isVariable,
88
88
  isWeb: () => isWeb,
@@ -166,6 +166,9 @@ var Variable = class {
166
166
  this.name = name;
167
167
  this.variable = isWeb ? `var(--${name})` : this.val;
168
168
  }
169
+ toString() {
170
+ return isWeb ? this.variable : this.val;
171
+ }
169
172
  };
170
173
  __name(Variable, "Variable");
171
174
  var createVariable = /* @__PURE__ */ __name((props) => new Variable(props), "createVariable");
@@ -273,8 +276,12 @@ var Theme = /* @__PURE__ */ __name((props) => {
273
276
  return props.children;
274
277
  }
275
278
  const name = props.name;
276
- const theme = themes[name] || themes[`${name}-${parentName}`];
279
+ const activeName = !name ? null : name in themes ? name : `${name}-${parentName}`;
280
+ const theme = activeName ? themes[activeName] : null;
277
281
  const themeManager = useConstant(() => {
282
+ if (!theme) {
283
+ return null;
284
+ }
278
285
  const manager = new ThemeManager();
279
286
  if (name) {
280
287
  manager.setActiveTheme(name, themes[name]);
@@ -282,15 +289,18 @@ var Theme = /* @__PURE__ */ __name((props) => {
282
289
  return manager;
283
290
  });
284
291
  useIsomorphicLayoutEffect(() => {
285
- themeManager.setActiveTheme(name, theme);
292
+ if (!themeManager) {
293
+ return;
294
+ }
295
+ themeManager.setActiveTheme(activeName, theme);
286
296
  return parent.onChangeTheme((next) => {
287
297
  if (next) {
288
298
  themeManager.setActiveTheme(next, themes[next]);
289
299
  setParentName(next);
290
300
  }
291
301
  });
292
- }, [themes, name]);
293
- if (!name) {
302
+ }, [themes, activeName]);
303
+ if (!name || !theme) {
294
304
  return props.children;
295
305
  }
296
306
  const contents = themeManager ? /* @__PURE__ */ import_react6.default.createElement(ThemeManagerContext.Provider, {
@@ -1067,7 +1077,6 @@ var getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, isSplit
1067
1077
  const validStyleProps = staticConfig.isText ? import_helpers3.stylePropsText : import_helpers3.validStyles;
1068
1078
  const viewProps = {};
1069
1079
  const style = [];
1070
- const blacklistProps = isSplittingDefaultProps ? blacklistDefaultProps : blacklistFinalProps;
1071
1080
  let pseudos2 = null;
1072
1081
  let cur = null;
1073
1082
  let classNames = null;
@@ -1146,7 +1155,7 @@ var getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, isSplit
1146
1155
  cur[key] = val;
1147
1156
  continue;
1148
1157
  }
1149
- if (!blacklistProps[key]) {
1158
+ if (!staticConfig.variants || !(key in staticConfig.variants)) {
1150
1159
  viewProps[key] = val;
1151
1160
  }
1152
1161
  }
@@ -1184,13 +1193,6 @@ var getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props) =
1184
1193
  fixNativeShadow(styleOut);
1185
1194
  return styleOut;
1186
1195
  }, "getSubStyle");
1187
- var blacklistDefaultProps = __spreadValues(__spreadValues({}, import_helpers3.validStyles), import_helpers3.stylePropsText);
1188
- var blacklistFinalProps = __spreadProps(__spreadValues({}, blacklistDefaultProps), {
1189
- tag: true,
1190
- debug: true,
1191
- space: true,
1192
- hitSlop: true
1193
- });
1194
1196
  var mapTransformKeys = {
1195
1197
  x: "translateX",
1196
1198
  y: "translateY"
@@ -1303,8 +1305,40 @@ function createComponent(configIn) {
1303
1305
  let defaultsClassName = "";
1304
1306
  let initialTheme;
1305
1307
  const component = (0, import_react11.forwardRef)((props, forwardedRef) => {
1306
- var _a4;
1308
+ var _b2;
1309
+ const forceUpdate = (0, import_use_force_update2.useForceUpdate)();
1310
+ const features = useFeatures(props, { forceUpdate });
1311
+ const manager = (0, import_react11.useContext)(ThemeManagerContext);
1312
+ const [state, set_] = (0, import_react11.useState)(() => ({
1313
+ hover: false,
1314
+ press: false,
1315
+ pressIn: false,
1316
+ theme: manager.name
1317
+ }));
1318
+ const set = /* @__PURE__ */ __name((next) => set_((prev) => {
1319
+ for (const key in next) {
1320
+ if (prev[key] !== next[key]) {
1321
+ return __spreadValues(__spreadValues({}, prev), next);
1322
+ }
1323
+ }
1324
+ return prev;
1325
+ }), "set");
1326
+ if (process.env.NODE_ENV === "development" && !isText && isWeb) {
1327
+ import_react11.Children.toArray(props.children).forEach((item) => {
1328
+ if (typeof item === "string") {
1329
+ console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
1330
+ }
1331
+ });
1332
+ }
1333
+ const hasTextAncestor = isWeb ? (0, import_react11.useContext)(TextAncestorContext) : false;
1334
+ const hostRef = (0, import_react11.useRef)(null);
1307
1335
  const {
1336
+ viewProps: viewPropsIn,
1337
+ pseudos: pseudos2,
1338
+ style,
1339
+ classNames
1340
+ } = getSplitStyles(props, staticConfig, manager.theme || initialTheme);
1341
+ const _a4 = viewPropsIn, {
1308
1342
  tag,
1309
1343
  hitSlop,
1310
1344
  children,
@@ -1337,34 +1371,52 @@ function createComponent(configIn) {
1337
1371
  onStartShouldSetResponderCapture,
1338
1372
  onMouseDown,
1339
1373
  onClick,
1374
+ accessible,
1375
+ accessibilityRole,
1340
1376
  onLayout
1341
- } = props;
1342
- const forceUpdate = (0, import_use_force_update2.useForceUpdate)();
1343
- const features = useFeatures(props, { forceUpdate });
1344
- const manager = (0, import_react11.useContext)(ThemeManagerContext);
1345
- const [state, set_] = (0, import_react11.useState)(() => ({
1346
- hover: false,
1347
- press: false,
1348
- pressIn: false,
1349
- theme: manager.name
1350
- }));
1351
- const set = /* @__PURE__ */ __name((next) => set_((prev) => {
1352
- for (const key in next) {
1353
- if (prev[key] !== next[key]) {
1354
- return __spreadValues(__spreadValues({}, prev), next);
1355
- }
1356
- }
1357
- return prev;
1358
- }), "set");
1359
- if (process.env.NODE_ENV === "development" && !isText && isWeb) {
1360
- import_react11.Children.toArray(props.children).forEach((item) => {
1361
- if (typeof item === "string") {
1362
- console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
1363
- }
1364
- });
1377
+ } = _a4, viewProps = __objRest(_a4, [
1378
+ "tag",
1379
+ "hitSlop",
1380
+ "children",
1381
+ "pointerEvents",
1382
+ "onPress",
1383
+ "onPressIn",
1384
+ "onPressOut",
1385
+ "onHoverIn",
1386
+ "onHoverOut",
1387
+ "space",
1388
+ "disabled",
1389
+ "onMouseEnter",
1390
+ "onMouseLeave",
1391
+ "hrefAttrs",
1392
+ "onMoveShouldSetResponder",
1393
+ "onMoveShouldSetResponderCapture",
1394
+ "onResponderEnd",
1395
+ "onResponderGrant",
1396
+ "onResponderMove",
1397
+ "onResponderReject",
1398
+ "onResponderRelease",
1399
+ "onResponderStart",
1400
+ "onResponderTerminate",
1401
+ "onResponderTerminationRequest",
1402
+ "onScrollShouldSetResponder",
1403
+ "onScrollShouldSetResponderCapture",
1404
+ "onSelectionChangeShouldSetResponder",
1405
+ "onSelectionChangeShouldSetResponderCapture",
1406
+ "onStartShouldSetResponder",
1407
+ "onStartShouldSetResponderCapture",
1408
+ "onMouseDown",
1409
+ "onClick",
1410
+ "accessible",
1411
+ "accessibilityRole",
1412
+ "onLayout"
1413
+ ]);
1414
+ if (!isWeb) {
1415
+ if (accessible)
1416
+ viewProps.accessible = accessible;
1417
+ if (accessibilityRole)
1418
+ viewProps.accessibilityRole = accessibilityRole;
1365
1419
  }
1366
- const hasTextAncestor = isWeb ? (0, import_react11.useContext)(TextAncestorContext) : false;
1367
- const hostRef = (0, import_react11.useRef)(null);
1368
1420
  if (isWeb) {
1369
1421
  rnw.useResponderEvents(hostRef, {
1370
1422
  onMoveShouldSetResponder,
@@ -1386,7 +1438,6 @@ function createComponent(configIn) {
1386
1438
  });
1387
1439
  }
1388
1440
  const isTracking = (0, import_react11.useRef)(false);
1389
- const { viewProps, pseudos: pseudos2, style, classNames } = getSplitStyles(props, staticConfig, manager.theme || initialTheme);
1390
1441
  const internal = (0, import_react11.useRef)();
1391
1442
  if (!internal.current) {
1392
1443
  internal.current = {
@@ -1565,7 +1616,7 @@ function createComponent(configIn) {
1565
1616
  viewProps["debug"] = true;
1566
1617
  console.log("\u{1F95A} props in:", props);
1567
1618
  console.log("\u{1F95A} props out:", viewProps);
1568
- console.log((_a4 = props.onClick) == null ? void 0 : _a4.toString());
1619
+ console.log((_b2 = props.onClick) == null ? void 0 : _b2.toString());
1569
1620
  console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos: pseudos2, content, childEls });
1570
1621
  if (isWeb) {
1571
1622
  console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
@@ -1869,7 +1920,6 @@ var ThemeInverse = /* @__PURE__ */ __name((props) => {
1869
1920
  const themeName = useThemeName();
1870
1921
  const defaultTheme = useDefaultThemeName();
1871
1922
  const name = inversions[themeName] || inversions[defaultTheme] || null;
1872
- console.log("todo fixme invert", { themeName, defaultTheme, next: name });
1873
1923
  return /* @__PURE__ */ import_react13.default.createElement(Theme, {
1874
1924
  name
1875
1925
  }, props.children);
@@ -1895,8 +1945,15 @@ var themeable = /* @__PURE__ */ __name(function graphql(component) {
1895
1945
  return withTheme;
1896
1946
  }, "graphql");
1897
1947
 
1898
- // src/views/Animated.tsx
1948
+ // src/helpers/isTamaguiElement.tsx
1899
1949
  var import_react15 = __toModule(require("react"));
1950
+ var isTamaguiElement = /* @__PURE__ */ __name((child) => {
1951
+ var _a4;
1952
+ return (0, import_react15.isValidElement)(child) && !!((_a4 = child.type["staticConfig"]) == null ? void 0 : _a4.parsed);
1953
+ }, "isTamaguiElement");
1954
+
1955
+ // src/views/Animated.tsx
1956
+ var import_react16 = __toModule(require("react"));
1900
1957
  var import_react_native4 = __toModule(require("react-native"));
1901
1958
 
1902
1959
  // src/views/Stack.tsx
@@ -1939,7 +1996,7 @@ var AnimatedStack = /* @__PURE__ */ __name((_a4) => {
1939
1996
  const driver = useConstant(() => {
1940
1997
  return new import_react_native4.Animated.Value(0);
1941
1998
  });
1942
- const animatedProps = (0, import_react15.useMemo)(() => {
1999
+ const animatedProps = (0, import_react16.useMemo)(() => {
1943
2000
  if (!animated) {
1944
2001
  return null;
1945
2002
  }
@@ -1972,8 +2029,8 @@ var AnimatedStack = /* @__PURE__ */ __name((_a4) => {
1972
2029
  toValue: animateState === "in" ? 1 : 0
1973
2030
  }).start();
1974
2031
  }, [animated, animateState]);
1975
- const childrenMemo = (0, import_react15.useMemo)(() => children, [children]);
1976
- return /* @__PURE__ */ import_react15.default.createElement(Stack, __spreadValues(__spreadValues({
2032
+ const childrenMemo = (0, import_react16.useMemo)(() => children, [children]);
2033
+ return /* @__PURE__ */ import_react16.default.createElement(Stack, __spreadValues(__spreadValues({
1977
2034
  animated
1978
2035
  }, props), animatedProps), childrenMemo);
1979
2036
  }, "AnimatedStack");
@@ -2077,27 +2134,4 @@ var Text2 = createComponent({
2077
2134
  cursor: true
2078
2135
  })
2079
2136
  });
2080
-
2081
- // src/views/SafeAreaProvider.tsx
2082
- var import_react16 = __toModule(require("react"));
2083
- var import_react_native5 = __toModule(require("react-native"));
2084
- var import_react_native_safe_area_context = __toModule(require("react-native-safe-area-context"));
2085
- var defaultMetrics = null;
2086
- var SafeAreaProvider = /* @__PURE__ */ __name(({
2087
- initialWindowMetrics,
2088
- children
2089
- }) => {
2090
- if (!initialWindowMetrics && !defaultMetrics) {
2091
- defaultMetrics = import_react_native5.Platform.select({
2092
- web: {
2093
- frame: { x: 0, y: 0, width: 0, height: 0 },
2094
- insets: { top: 0, left: 0, right: 0, bottom: 0 }
2095
- },
2096
- default: import_react_native_safe_area_context.initialWindowMetrics
2097
- });
2098
- }
2099
- return /* @__PURE__ */ import_react16.default.createElement(import_react_native_safe_area_context.SafeAreaProvider, {
2100
- initialMetrics: initialWindowMetrics ?? defaultMetrics
2101
- }, children);
2102
- }, "SafeAreaProvider");
2103
2137
  //# sourceMappingURL=index.cjs.map