@tamagui/core 1.0.1-beta.86 → 1.0.1-beta.89

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 (75) hide show
  1. package/dist/cjs/assignNativePropsToWeb.js +187 -0
  2. package/dist/cjs/assignNativePropsToWeb.js.map +7 -0
  3. package/dist/cjs/constants/platform.js +2 -2
  4. package/dist/cjs/constants/platform.js.map +2 -2
  5. package/dist/cjs/constants/rnw.js +7 -5
  6. package/dist/cjs/constants/rnw.js.map +2 -2
  7. package/dist/cjs/createComponent.js +61 -205
  8. package/dist/cjs/createComponent.js.map +2 -2
  9. package/dist/cjs/helpers/assignNativePropsToWeb.js +187 -0
  10. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
  11. package/dist/cjs/helpers/assignNativePropsToWeb.native.js +29 -0
  12. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
  13. package/dist/cjs/helpers/createPropMapper.js +6 -1
  14. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  15. package/dist/cjs/helpers/extendStaticConfig.js +4 -2
  16. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  17. package/dist/cjs/helpers/getSplitStyles.js +15 -14
  18. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  19. package/dist/cjs/helpers/getStylesAtomic.js +4 -5
  20. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  21. package/dist/cjs/helpers/mergeProps.js +14 -4
  22. package/dist/cjs/helpers/mergeProps.js.map +2 -2
  23. package/dist/cjs/styled.js +0 -5
  24. package/dist/cjs/styled.js.map +2 -2
  25. package/dist/cjs/types.js.map +1 -1
  26. package/dist/esm/assignNativePropsToWeb.js +164 -0
  27. package/dist/esm/assignNativePropsToWeb.js.map +7 -0
  28. package/dist/esm/constants/platform.js +2 -2
  29. package/dist/esm/constants/platform.js.map +2 -2
  30. package/dist/esm/constants/rnw.js +7 -2
  31. package/dist/esm/constants/rnw.js.map +2 -2
  32. package/dist/esm/createComponent.js +58 -203
  33. package/dist/esm/createComponent.js.map +2 -2
  34. package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
  35. package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
  36. package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
  37. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
  38. package/dist/esm/helpers/createPropMapper.js +6 -1
  39. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  40. package/dist/esm/helpers/extendStaticConfig.js +4 -2
  41. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  42. package/dist/esm/helpers/getSplitStyles.js +15 -14
  43. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  44. package/dist/esm/helpers/getStylesAtomic.js +4 -5
  45. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  46. package/dist/esm/helpers/mergeProps.js +14 -4
  47. package/dist/esm/helpers/mergeProps.js.map +2 -2
  48. package/dist/esm/styled.js +0 -5
  49. package/dist/esm/styled.js.map +2 -2
  50. package/package.json +6 -6
  51. package/types/assignNativePropsToWeb.d.ts +2 -0
  52. package/types/assignNativePropsToWeb.d.ts.map +1 -0
  53. package/types/constants/platform.d.ts.map +1 -1
  54. package/types/constants/rnw.d.ts.map +1 -1
  55. package/types/createComponent.d.ts +15 -1
  56. package/types/createComponent.d.ts.map +1 -1
  57. package/types/helpers/assignNativePropsToWeb.d.ts +2 -0
  58. package/types/helpers/assignNativePropsToWeb.d.ts.map +1 -0
  59. package/types/helpers/assignNativePropsToWeb.native.d.ts +2 -0
  60. package/types/helpers/assignNativePropsToWeb.native.d.ts.map +1 -0
  61. package/types/helpers/createPropMapper.d.ts.map +1 -1
  62. package/types/helpers/extendStaticConfig.d.ts.map +1 -1
  63. package/types/helpers/getSplitStyles.d.ts +1 -4
  64. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  65. package/types/helpers/getStylesAtomic.d.ts +2 -6
  66. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  67. package/types/helpers/mergeProps.d.ts +1 -1
  68. package/types/helpers/mergeProps.d.ts.map +1 -1
  69. package/types/styled.d.ts.map +1 -1
  70. package/types/types.d.ts +3 -1
  71. package/types/types.d.ts.map +1 -1
  72. package/types/views/ThemeInverse.d.ts +1 -0
  73. package/types/views/ThemeInverse.d.ts.map +1 -1
  74. package/types/views/ThemeProvider.d.ts +1 -0
  75. package/types/views/ThemeProvider.d.ts.map +1 -1
@@ -49,6 +49,7 @@ import { getConfig, onConfiguredOnce } from "./conf";
49
49
  import { stackDefaultStyles } from "./constants/constants";
50
50
  import { isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
51
51
  import { rnw } from "./constants/rnw";
52
+ import { assignNativePropsToWeb } from "./helpers/assignNativePropsToWeb";
52
53
  import { getReturnVariablesAs } from "./helpers/createPropMapper";
53
54
  import { createShallowUpdate } from "./helpers/createShallowUpdate";
54
55
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
@@ -117,14 +118,14 @@ function createComponent(configIn, ParentComponent) {
117
118
  var _a, _d, _e, _f;
118
119
  let props;
119
120
  if (tamaguiDefaultProps && !propsIn.asChild) {
120
- props = mergeProps(tamaguiDefaultProps, propsIn);
121
+ props = mergeProps(tamaguiDefaultProps, propsIn)[0];
121
122
  } else {
122
123
  props = propsIn;
123
124
  }
124
125
  const { Component, isText, isZStack } = staticConfig;
125
126
  const componentName = props.componentName || staticConfig.componentName;
126
127
  const componentClassName = props.asChild ? "" : props.componentName ? `is_${props.componentName}` : defaultComponentClassName;
127
- if (true) {
128
+ if (process.env.NODE_ENV === "development") {
128
129
  if (props["debug"]) {
129
130
  console.log("\u26A0\uFE0F", componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
130
131
  console.log("props in:", {
@@ -132,8 +133,9 @@ function createComponent(configIn, ParentComponent) {
132
133
  props,
133
134
  ordered: Object.keys(props)
134
135
  });
135
- if (props["debug"] === "break")
136
+ if (props["debug"] === "break") {
136
137
  debugger;
138
+ }
137
139
  }
138
140
  }
139
141
  const forceUpdate = useForceUpdate();
@@ -421,9 +423,6 @@ function createComponent(configIn, ParentComponent) {
421
423
  }
422
424
  const _focusable = focusable != void 0 ? focusable : accessible;
423
425
  const role = viewProps.role;
424
- if (props["debug"]) {
425
- console.log("_focusable", focusable);
426
- }
427
426
  if (_focusable === false) {
428
427
  viewProps.tabIndex = "-1";
429
428
  }
@@ -445,7 +444,7 @@ function createComponent(configIn, ParentComponent) {
445
444
  viewProps.ref = forwardedRef;
446
445
  }
447
446
  }
448
- if (props["debug"]) {
447
+ if (process.env.NODE_ENV === "development" && props["debug"]) {
449
448
  console.log("viewProps", elementType, viewProps.role, viewProps.tabIndex);
450
449
  }
451
450
  if (!isText && isWeb) {
@@ -728,9 +727,11 @@ function createComponent(configIn, ParentComponent) {
728
727
  }
729
728
  return content;
730
729
  });
731
- component.displayName = staticConfig.componentName;
730
+ if (staticConfig.componentName) {
731
+ component.displayName = staticConfig.componentName;
732
+ }
732
733
  onConfiguredOnce((conf) => {
733
- var _a, _b, _c, _d;
734
+ var _a, _b, _c;
734
735
  if (process.env.IS_STATIC === "is_static") {
735
736
  return;
736
737
  }
@@ -741,38 +742,17 @@ function createComponent(configIn, ParentComponent) {
741
742
  AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
742
743
  initialTheme = initialTheme || proxyThemeVariables(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
743
744
  const config = getConfig();
744
- let defaultPropsIn = staticConfig.defaultProps;
745
+ let defaultPropsIn = staticConfig.defaultProps || {};
745
746
  const parentNames = [...staticConfig.parentNames || [], staticConfig.componentName];
746
- if (config.defaultProps && parentNames) {
747
- const len = parentNames.length;
748
- let prev;
749
- for (let i = 0; i < len; i++) {
750
- const n = parentNames[i];
751
- if (!n)
752
- continue;
753
- if (DefaultProps.has(n)) {
754
- prev = DefaultProps.get(n);
755
- continue;
756
- }
757
- const props = config.defaultProps[n];
758
- if (!props) {
759
- if (prev) {
760
- DefaultProps.set(n, prev);
761
- }
762
- continue;
763
- }
764
- prev = mergeProps(prev || {}, props);
765
- DefaultProps.set(n, prev);
766
- }
767
- const ourDefaultsMerged = DefaultProps.get(staticConfig.componentName);
768
- if (ourDefaultsMerged) {
769
- defaultPropsIn = mergeProps(defaultPropsIn, ourDefaultsMerged);
770
- }
747
+ if (config.defaultProps && parentNames && staticConfig.componentName) {
748
+ defaultPropsIn = mergeConfigDefaultProps(staticConfig.componentName, defaultPropsIn, config.defaultProps, parentNames);
771
749
  }
772
- if (process.env.NODE_ENV === "development" && defaultPropsIn["debug"] === "break") {
750
+ const debug = process.env.NODE_ENV === "development" ? defaultPropsIn["debug"] : false;
751
+ if (process.env.NODE_ENV === "development" && debug === "break") {
773
752
  debugger;
774
753
  }
775
- initialSplitStyles = insertSplitStyles(defaultPropsIn, staticConfig, initialTheme, {
754
+ const [parentProps, parentClassNames] = mergeProps(defaultPropsIn, {}, true);
755
+ initialSplitStyles = insertSplitStyles(parentProps, staticConfig, initialTheme, {
776
756
  mounted: true,
777
757
  hover: false,
778
758
  press: false,
@@ -780,14 +760,18 @@ function createComponent(configIn, ParentComponent) {
780
760
  focus: false,
781
761
  resolveVariablesAs: "both",
782
762
  keepVariantsAsProps: true
783
- }, void 0, staticConfig.defaultProps["debug"]);
784
- const defaults = mergeProps(component.defaultProps, initialSplitStyles.viewProps);
763
+ }, void 0, debug);
764
+ const [defaults, defaultsClassnames] = mergeProps(component.defaultProps, initialSplitStyles.viewProps, true);
765
+ if (debug) {
766
+ console.warn(defaults, component.defaultProps, initialSplitStyles);
767
+ }
768
+ initialSplitStyles.classNames = __spreadValues(__spreadValues(__spreadValues({}, parentClassNames), defaultsClassnames), initialSplitStyles.classNames);
785
769
  defaultNativeStyle = {};
786
770
  const validStyles2 = staticConfig.validStyles || stylePropsView;
787
771
  if (!isWeb) {
788
772
  for (const key in staticConfig.defaultProps) {
789
773
  const val = staticConfig.defaultProps[key];
790
- if (typeof val === "string" && val[0] === "$" || !validStyles2[key] || val[0] === "_") {
774
+ if (typeof val === "string" && val[0] === "$" || !validStyles2[key]) {
791
775
  defaults[key] = val;
792
776
  } else {
793
777
  defaultNativeStyle[key] = val;
@@ -800,14 +784,15 @@ function createComponent(configIn, ParentComponent) {
800
784
  if (Object.keys(defaults).length) {
801
785
  tamaguiDefaultProps = defaults;
802
786
  }
803
- if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
787
+ if (process.env.NODE_ENV === "development" && debug) {
804
788
  if (process.env.IS_STATIC !== "is_static") {
805
789
  console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
806
790
  staticConfig,
807
791
  initialSplitStyles,
808
792
  tamaguiDefaultProps,
809
793
  defaultNativeStyle,
810
- defaults
794
+ defaults,
795
+ defaultPropsIn
811
796
  });
812
797
  }
813
798
  }
@@ -831,7 +816,6 @@ function createComponent(configIn, ParentComponent) {
831
816
  };
832
817
  return res;
833
818
  }
834
- const DefaultProps = /* @__PURE__ */ new Map();
835
819
  const Unspaced = (props) => {
836
820
  return props.children;
837
821
  };
@@ -978,165 +962,6 @@ const accessibilityRoleToWebRole = {
978
962
  summary: "region",
979
963
  text: null
980
964
  };
981
- function assignNativePropsToWeb(elementType, viewProps, nativeProps) {
982
- if (!viewProps.role && nativeProps.accessibilityRole) {
983
- if (nativeProps.accessibilityRole === "none") {
984
- viewProps.role = "presentation";
985
- } else {
986
- const webRole = accessibilityRoleToWebRole[nativeProps.accessibilityRole];
987
- if (webRole != null) {
988
- viewProps.role = webRole || nativeProps.accessibilityRole;
989
- }
990
- }
991
- }
992
- if (nativeProps.accessibilityActiveDescendant != null) {
993
- viewProps["aria-activedescendant"] = nativeProps.accessibilityActiveDescendant;
994
- }
995
- if (nativeProps.accessibilityAtomic != null) {
996
- viewProps["aria-atomic"] = nativeProps.accessibilityAtomic;
997
- }
998
- if (nativeProps.accessibilityAutoComplete != null) {
999
- viewProps["aria-autocomplete"] = nativeProps.accessibilityAutoComplete;
1000
- }
1001
- if (nativeProps.accessibilityBusy != null) {
1002
- viewProps["aria-busy"] = nativeProps.accessibilityBusy;
1003
- }
1004
- if (nativeProps.accessibilityChecked != null) {
1005
- viewProps["aria-checked"] = nativeProps.accessibilityChecked;
1006
- }
1007
- if (nativeProps.accessibilityColumnCount != null) {
1008
- viewProps["aria-colcount"] = nativeProps.accessibilityColumnCount;
1009
- }
1010
- if (nativeProps.accessibilityColumnIndex != null) {
1011
- viewProps["aria-colindex"] = nativeProps.accessibilityColumnIndex;
1012
- }
1013
- if (nativeProps.accessibilityColumnSpan != null) {
1014
- viewProps["aria-colspan"] = nativeProps.accessibilityColumnSpan;
1015
- }
1016
- if (nativeProps.accessibilityControls != null) {
1017
- viewProps["aria-controls"] = processIDRefList(nativeProps.accessibilityControls);
1018
- }
1019
- if (nativeProps.accessibilityCurrent != null) {
1020
- viewProps["aria-current"] = nativeProps.accessibilityCurrent;
1021
- }
1022
- if (nativeProps.accessibilityDescribedBy != null) {
1023
- viewProps["aria-describedby"] = processIDRefList(nativeProps.accessibilityDescribedBy);
1024
- }
1025
- if (nativeProps.accessibilityDetails != null) {
1026
- viewProps["aria-details"] = nativeProps.accessibilityDetails;
1027
- }
1028
- if (nativeProps.disabled === true) {
1029
- viewProps["aria-disabled"] = true;
1030
- if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
1031
- viewProps.disabled = true;
1032
- }
1033
- }
1034
- if (nativeProps.accessibilityErrorMessage != null) {
1035
- viewProps["aria-errormessage"] = nativeProps.accessibilityErrorMessage;
1036
- }
1037
- if (nativeProps.accessibilityExpanded != null) {
1038
- viewProps["aria-expanded"] = nativeProps.accessibilityExpanded;
1039
- }
1040
- if (nativeProps.accessibilityFlowTo != null) {
1041
- viewProps["aria-flowto"] = processIDRefList(nativeProps.accessibilityFlowTo);
1042
- }
1043
- if (nativeProps.accessibilityHasPopup != null) {
1044
- viewProps["aria-haspopup"] = nativeProps.accessibilityHasPopup;
1045
- }
1046
- if (nativeProps.accessibilityHidden === true) {
1047
- viewProps["aria-hidden"] = nativeProps.accessibilityHidden;
1048
- }
1049
- if (nativeProps.accessibilityInvalid != null) {
1050
- viewProps["aria-invalid"] = nativeProps.accessibilityInvalid;
1051
- }
1052
- if (nativeProps.accessibilityKeyShortcuts != null && Array.isArray(nativeProps.accessibilityKeyShortcuts)) {
1053
- viewProps["aria-keyshortcuts"] = nativeProps.accessibilityKeyShortcuts.join(" ");
1054
- }
1055
- if (nativeProps.accessibilityLabel != null) {
1056
- viewProps["aria-label"] = nativeProps.accessibilityLabel;
1057
- }
1058
- if (nativeProps.accessibilityLabelledBy != null) {
1059
- viewProps["aria-labelledby"] = processIDRefList(nativeProps.accessibilityLabelledBy);
1060
- }
1061
- if (nativeProps.accessibilityLevel != null) {
1062
- viewProps["aria-level"] = nativeProps.accessibilityLevel;
1063
- }
1064
- if (nativeProps.accessibilityLiveRegion != null) {
1065
- viewProps["aria-live"] = nativeProps.accessibilityLiveRegion === "none" ? "off" : nativeProps.accessibilityLiveRegion;
1066
- }
1067
- if (nativeProps.accessibilityModal != null) {
1068
- viewProps["aria-modal"] = nativeProps.accessibilityModal;
1069
- }
1070
- if (nativeProps.accessibilityMultiline != null) {
1071
- viewProps["aria-multiline"] = nativeProps.accessibilityMultiline;
1072
- }
1073
- if (nativeProps.accessibilityMultiSelectable != null) {
1074
- viewProps["aria-multiselectable"] = nativeProps.accessibilityMultiSelectable;
1075
- }
1076
- if (nativeProps.accessibilityOrientation != null) {
1077
- viewProps["aria-orientation"] = nativeProps.accessibilityOrientation;
1078
- }
1079
- if (nativeProps.accessibilityOwns != null) {
1080
- viewProps["aria-owns"] = processIDRefList(nativeProps.accessibilityOwns);
1081
- }
1082
- if (nativeProps.accessibilityPlaceholder != null) {
1083
- viewProps["aria-placeholder"] = nativeProps.accessibilityPlaceholder;
1084
- }
1085
- if (nativeProps.accessibilityPosInSet != null) {
1086
- viewProps["aria-posinset"] = nativeProps.accessibilityPosInSet;
1087
- }
1088
- if (nativeProps.accessibilityPressed != null) {
1089
- viewProps["aria-pressed"] = nativeProps.accessibilityPressed;
1090
- }
1091
- if (nativeProps.accessibilityReadOnly != null) {
1092
- viewProps["aria-readonly"] = nativeProps.accessibilityReadOnly;
1093
- if (elementType === "input" || elementType === "select" || elementType === "textarea") {
1094
- viewProps.readOnly = true;
1095
- }
1096
- }
1097
- if (nativeProps.accessibilityRequired != null) {
1098
- viewProps["aria-required"] = nativeProps.accessibilityRequired;
1099
- if (elementType === "input" || elementType === "select" || elementType === "textarea") {
1100
- viewProps.required = true;
1101
- }
1102
- }
1103
- if (nativeProps.accessibilityRoleDescription != null) {
1104
- viewProps["aria-roledescription"] = nativeProps.accessibilityRoleDescription;
1105
- }
1106
- if (nativeProps.accessibilityRowCount != null) {
1107
- viewProps["aria-rowcount"] = nativeProps.accessibilityRowCount;
1108
- }
1109
- if (nativeProps.accessibilityRowIndex != null) {
1110
- viewProps["aria-rowindex"] = nativeProps.accessibilityRowIndex;
1111
- }
1112
- if (nativeProps.accessibilityRowSpan != null) {
1113
- viewProps["aria-rowspan"] = nativeProps.accessibilityRowSpan;
1114
- }
1115
- if (nativeProps.accessibilitySelected != null) {
1116
- viewProps["aria-selected"] = nativeProps.accessibilitySelected;
1117
- }
1118
- if (nativeProps.accessibilitySetSize != null) {
1119
- viewProps["aria-setsize"] = nativeProps.accessibilitySetSize;
1120
- }
1121
- if (nativeProps.accessibilitySort != null) {
1122
- viewProps["aria-sort"] = nativeProps.accessibilitySort;
1123
- }
1124
- if (nativeProps.accessibilityValueMax != null) {
1125
- viewProps["aria-valuemax"] = nativeProps.accessibilityValueMax;
1126
- }
1127
- if (nativeProps.accessibilityValueMin != null) {
1128
- viewProps["aria-valuemin"] = nativeProps.accessibilityValueMin;
1129
- }
1130
- if (nativeProps.accessibilityValueNow != null) {
1131
- viewProps["aria-valuenow"] = nativeProps.accessibilityValueNow;
1132
- }
1133
- if (nativeProps.accessibilityValueText != null) {
1134
- viewProps["aria-valuetext"] = nativeProps.accessibilityValueText;
1135
- }
1136
- if (nativeProps.nativeID) {
1137
- viewProps.id = nativeProps.nativeID;
1138
- }
1139
- }
1140
965
  function addPseudoToStyles(styles, initialPseudos, pseudos, name, force = false) {
1141
966
  const pseudoStyle = pseudos[name];
1142
967
  const shouldNestObject = isWeb && name !== "enterStyle" && name !== "exitStyle";
@@ -1146,13 +971,43 @@ function addPseudoToStyles(styles, initialPseudos, pseudos, name, force = false)
1146
971
  styles.push(shouldNestObject && !force ? { [name]: style } : style);
1147
972
  }
1148
973
  }
974
+ const DefaultProps = /* @__PURE__ */ new Map();
975
+ function mergeConfigDefaultProps(name, props, configDefaults, parentNames) {
976
+ const len = parentNames.length;
977
+ let prev;
978
+ for (let i = 0; i < len; i++) {
979
+ const n = parentNames[i];
980
+ if (!n)
981
+ continue;
982
+ if (DefaultProps.has(n)) {
983
+ prev = DefaultProps.get(n);
984
+ continue;
985
+ }
986
+ const props2 = configDefaults[n];
987
+ if (!props2) {
988
+ if (prev) {
989
+ DefaultProps.set(n, prev);
990
+ }
991
+ continue;
992
+ }
993
+ prev = mergeProps(prev || {}, props2)[0];
994
+ console.log("set prev", prev);
995
+ DefaultProps.set(n, prev);
996
+ }
997
+ const ourDefaultsMerged = DefaultProps.get(name);
998
+ if (ourDefaultsMerged) {
999
+ return mergeProps(props, ourDefaultsMerged)[0];
1000
+ }
1001
+ return props;
1002
+ }
1149
1003
  export {
1150
1004
  AbsoluteFill,
1151
1005
  Spacer,
1152
1006
  Unspaced,
1153
- assignNativePropsToWeb,
1007
+ accessibilityRoleToWebRole,
1154
1008
  createComponent,
1155
1009
  mouseUps,
1010
+ processIDRefList,
1156
1011
  spacedChildren
1157
1012
  };
1158
1013
  //# sourceMappingURL=createComponent.js.map