@tamagui/core 1.0.1-beta.88 → 1.0.1-beta.91

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 (70) 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 +5 -7
  6. package/dist/cjs/constants/rnw.js.map +2 -2
  7. package/dist/cjs/constants/rnw.native.js +28 -0
  8. package/dist/cjs/constants/rnw.native.js.map +7 -0
  9. package/dist/cjs/createComponent.js +52 -201
  10. package/dist/cjs/createComponent.js.map +2 -2
  11. package/dist/cjs/helpers/assignNativePropsToWeb.js +187 -0
  12. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
  13. package/dist/cjs/helpers/assignNativePropsToWeb.native.js +29 -0
  14. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
  15. package/dist/cjs/helpers/extendStaticConfig.js +3 -1
  16. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  17. package/dist/cjs/helpers/getSplitStyles.js +11 -11
  18. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  19. package/dist/cjs/hooks/useFeatures.js +2 -4
  20. package/dist/cjs/hooks/useFeatures.js.map +2 -2
  21. package/dist/cjs/static.js +13 -1
  22. package/dist/cjs/static.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 +2 -7
  31. package/dist/esm/constants/rnw.js.map +2 -2
  32. package/dist/esm/constants/rnw.native.js +5 -0
  33. package/dist/esm/constants/rnw.native.js.map +7 -0
  34. package/dist/esm/createComponent.js +49 -200
  35. package/dist/esm/createComponent.js.map +2 -2
  36. package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
  37. package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
  38. package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
  39. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
  40. package/dist/esm/helpers/extendStaticConfig.js +3 -1
  41. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  42. package/dist/esm/helpers/getSplitStyles.js +11 -11
  43. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  44. package/dist/esm/hooks/useFeatures.js +3 -5
  45. package/dist/esm/hooks/useFeatures.js.map +2 -2
  46. package/dist/esm/static.js +5 -1
  47. package/dist/esm/static.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/constants/rnw.native.d.ts +2 -0
  56. package/types/constants/rnw.native.d.ts.map +1 -0
  57. package/types/createComponent.d.ts +15 -1
  58. package/types/createComponent.d.ts.map +1 -1
  59. package/types/helpers/assignNativePropsToWeb.d.ts +2 -0
  60. package/types/helpers/assignNativePropsToWeb.d.ts.map +1 -0
  61. package/types/helpers/assignNativePropsToWeb.native.d.ts +2 -0
  62. package/types/helpers/assignNativePropsToWeb.native.d.ts.map +1 -0
  63. package/types/helpers/extendStaticConfig.d.ts.map +1 -1
  64. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  65. package/types/hooks/useFeatures.d.ts.map +1 -1
  66. package/types/static.d.ts +1 -1
  67. package/types/static.d.ts.map +1 -1
  68. package/types/styled.d.ts.map +1 -1
  69. package/types/types.d.ts +1 -3
  70. package/types/types.d.ts.map +1 -1
@@ -52,9 +52,10 @@ __export(createComponent_exports, {
52
52
  AbsoluteFill: () => AbsoluteFill,
53
53
  Spacer: () => Spacer,
54
54
  Unspaced: () => Unspaced,
55
- assignNativePropsToWeb: () => assignNativePropsToWeb,
55
+ accessibilityRoleToWebRole: () => accessibilityRoleToWebRole,
56
56
  createComponent: () => createComponent,
57
57
  mouseUps: () => mouseUps,
58
+ processIDRefList: () => processIDRefList,
58
59
  spacedChildren: () => spacedChildren
59
60
  });
60
61
  module.exports = __toCommonJS(createComponent_exports);
@@ -66,6 +67,7 @@ var import_conf = require("./conf");
66
67
  var import_constants = require("./constants/constants");
67
68
  var import_platform = require("./constants/platform");
68
69
  var import_rnw = require("./constants/rnw");
70
+ var import_assignNativePropsToWeb = require("./helpers/assignNativePropsToWeb");
69
71
  var import_createPropMapper = require("./helpers/createPropMapper");
70
72
  var import_createShallowUpdate = require("./helpers/createShallowUpdate");
71
73
  var import_extendStaticConfig = require("./helpers/extendStaticConfig");
@@ -394,7 +396,7 @@ function createComponent(configIn, ParentComponent) {
394
396
  "onLayout"
395
397
  ]);
396
398
  viewProps = webProps;
397
- assignNativePropsToWeb(elementType, viewProps, nonTamaguiProps);
399
+ (0, import_assignNativePropsToWeb.assignNativePropsToWeb)(elementType, viewProps, nonTamaguiProps);
398
400
  if (!asChild) {
399
401
  import_rnw.rnw.useElementLayout(hostRef, onLayout);
400
402
  import_rnw.rnw.useResponderEvents(hostRef, {
@@ -478,10 +480,8 @@ function createComponent(configIn, ParentComponent) {
478
480
  }
479
481
  (0, import_platform.useIsomorphicLayoutEffect)(() => {
480
482
  if (typeof window !== "undefined" && (hasEnterStyle || props.animation)) {
481
- (0, import_react.startTransition)(() => {
482
- setStateShallow({
483
- mounted: true
484
- });
483
+ setStateShallow({
484
+ mounted: true
485
485
  });
486
486
  }
487
487
  internal.current.isMounted = true;
@@ -743,9 +743,11 @@ function createComponent(configIn, ParentComponent) {
743
743
  }
744
744
  return content;
745
745
  });
746
- component.displayName = staticConfig.componentName;
746
+ if (staticConfig.componentName) {
747
+ component.displayName = staticConfig.componentName;
748
+ }
747
749
  (0, import_conf.onConfiguredOnce)((conf) => {
748
- var _a, _b, _c, _d;
750
+ var _a, _b, _c;
749
751
  if (process.env.IS_STATIC === "is_static") {
750
752
  return;
751
753
  }
@@ -756,38 +758,14 @@ function createComponent(configIn, ParentComponent) {
756
758
  AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
757
759
  initialTheme = initialTheme || (0, import_proxyThemeVariables.proxyThemeVariables)(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
758
760
  const config = (0, import_conf.getConfig)();
759
- let defaultPropsIn = staticConfig.defaultProps;
761
+ let defaultPropsIn = staticConfig.defaultProps || {};
760
762
  const parentNames = [...staticConfig.parentNames || [], staticConfig.componentName];
761
- if (config.defaultProps && parentNames) {
762
- const len = parentNames.length;
763
- let prev;
764
- for (let i = 0; i < len; i++) {
765
- const n = parentNames[i];
766
- if (!n)
767
- continue;
768
- if (DefaultProps.has(n)) {
769
- prev = DefaultProps.get(n);
770
- continue;
771
- }
772
- const props = config.defaultProps[n];
773
- if (!props) {
774
- if (prev) {
775
- DefaultProps.set(n, prev);
776
- }
777
- continue;
778
- }
779
- prev = (0, import_mergeProps.mergeProps)(prev || {}, props)[0];
780
- DefaultProps.set(n, prev);
781
- }
782
- const ourDefaultsMerged = DefaultProps.get(staticConfig.componentName);
783
- if (ourDefaultsMerged) {
784
- defaultPropsIn = (0, import_mergeProps.mergeProps)(defaultPropsIn, ourDefaultsMerged)[0];
785
- }
763
+ if (config.defaultProps && parentNames && staticConfig.componentName) {
764
+ defaultPropsIn = mergeConfigDefaultProps(staticConfig.componentName, defaultPropsIn, config.defaultProps, parentNames);
786
765
  }
787
- if (process.env.NODE_ENV === "development") {
788
- if (defaultPropsIn["debug"] === "break") {
789
- debugger;
790
- }
766
+ const debug = process.env.NODE_ENV === "development" ? defaultPropsIn["debug"] : false;
767
+ if (process.env.NODE_ENV === "development" && debug === "break") {
768
+ debugger;
791
769
  }
792
770
  const [parentProps, parentClassNames] = (0, import_mergeProps.mergeProps)(defaultPropsIn, {}, true);
793
771
  initialSplitStyles = (0, import_getSplitStyles.insertSplitStyles)(parentProps, staticConfig, initialTheme, {
@@ -798,8 +776,11 @@ function createComponent(configIn, ParentComponent) {
798
776
  focus: false,
799
777
  resolveVariablesAs: "both",
800
778
  keepVariantsAsProps: true
801
- }, void 0, staticConfig.defaultProps["debug"]);
779
+ }, void 0, debug);
802
780
  const [defaults, defaultsClassnames] = (0, import_mergeProps.mergeProps)(component.defaultProps, initialSplitStyles.viewProps, true);
781
+ if (debug) {
782
+ console.warn(defaults, component.defaultProps, initialSplitStyles);
783
+ }
803
784
  initialSplitStyles.classNames = __spreadValues(__spreadValues(__spreadValues({}, parentClassNames), defaultsClassnames), initialSplitStyles.classNames);
804
785
  defaultNativeStyle = {};
805
786
  const validStyles2 = staticConfig.validStyles || import_helpers.stylePropsView;
@@ -819,7 +800,7 @@ function createComponent(configIn, ParentComponent) {
819
800
  if (Object.keys(defaults).length) {
820
801
  tamaguiDefaultProps = defaults;
821
802
  }
822
- if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
803
+ if (process.env.NODE_ENV === "development" && debug) {
823
804
  if (process.env.IS_STATIC !== "is_static") {
824
805
  console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
825
806
  staticConfig,
@@ -851,7 +832,6 @@ function createComponent(configIn, ParentComponent) {
851
832
  };
852
833
  return res;
853
834
  }
854
- const DefaultProps = /* @__PURE__ */ new Map();
855
835
  const Unspaced = (props) => {
856
836
  return props.children;
857
837
  };
@@ -998,165 +978,6 @@ const accessibilityRoleToWebRole = {
998
978
  summary: "region",
999
979
  text: null
1000
980
  };
1001
- function assignNativePropsToWeb(elementType, viewProps, nativeProps) {
1002
- if (!viewProps.role && nativeProps.accessibilityRole) {
1003
- if (nativeProps.accessibilityRole === "none") {
1004
- viewProps.role = "presentation";
1005
- } else {
1006
- const webRole = accessibilityRoleToWebRole[nativeProps.accessibilityRole];
1007
- if (webRole != null) {
1008
- viewProps.role = webRole || nativeProps.accessibilityRole;
1009
- }
1010
- }
1011
- }
1012
- if (nativeProps.accessibilityActiveDescendant != null) {
1013
- viewProps["aria-activedescendant"] = nativeProps.accessibilityActiveDescendant;
1014
- }
1015
- if (nativeProps.accessibilityAtomic != null) {
1016
- viewProps["aria-atomic"] = nativeProps.accessibilityAtomic;
1017
- }
1018
- if (nativeProps.accessibilityAutoComplete != null) {
1019
- viewProps["aria-autocomplete"] = nativeProps.accessibilityAutoComplete;
1020
- }
1021
- if (nativeProps.accessibilityBusy != null) {
1022
- viewProps["aria-busy"] = nativeProps.accessibilityBusy;
1023
- }
1024
- if (nativeProps.accessibilityChecked != null) {
1025
- viewProps["aria-checked"] = nativeProps.accessibilityChecked;
1026
- }
1027
- if (nativeProps.accessibilityColumnCount != null) {
1028
- viewProps["aria-colcount"] = nativeProps.accessibilityColumnCount;
1029
- }
1030
- if (nativeProps.accessibilityColumnIndex != null) {
1031
- viewProps["aria-colindex"] = nativeProps.accessibilityColumnIndex;
1032
- }
1033
- if (nativeProps.accessibilityColumnSpan != null) {
1034
- viewProps["aria-colspan"] = nativeProps.accessibilityColumnSpan;
1035
- }
1036
- if (nativeProps.accessibilityControls != null) {
1037
- viewProps["aria-controls"] = processIDRefList(nativeProps.accessibilityControls);
1038
- }
1039
- if (nativeProps.accessibilityCurrent != null) {
1040
- viewProps["aria-current"] = nativeProps.accessibilityCurrent;
1041
- }
1042
- if (nativeProps.accessibilityDescribedBy != null) {
1043
- viewProps["aria-describedby"] = processIDRefList(nativeProps.accessibilityDescribedBy);
1044
- }
1045
- if (nativeProps.accessibilityDetails != null) {
1046
- viewProps["aria-details"] = nativeProps.accessibilityDetails;
1047
- }
1048
- if (nativeProps.disabled === true) {
1049
- viewProps["aria-disabled"] = true;
1050
- if (elementType === "button" || elementType === "form" || elementType === "input" || elementType === "select" || elementType === "textarea") {
1051
- viewProps.disabled = true;
1052
- }
1053
- }
1054
- if (nativeProps.accessibilityErrorMessage != null) {
1055
- viewProps["aria-errormessage"] = nativeProps.accessibilityErrorMessage;
1056
- }
1057
- if (nativeProps.accessibilityExpanded != null) {
1058
- viewProps["aria-expanded"] = nativeProps.accessibilityExpanded;
1059
- }
1060
- if (nativeProps.accessibilityFlowTo != null) {
1061
- viewProps["aria-flowto"] = processIDRefList(nativeProps.accessibilityFlowTo);
1062
- }
1063
- if (nativeProps.accessibilityHasPopup != null) {
1064
- viewProps["aria-haspopup"] = nativeProps.accessibilityHasPopup;
1065
- }
1066
- if (nativeProps.accessibilityHidden === true) {
1067
- viewProps["aria-hidden"] = nativeProps.accessibilityHidden;
1068
- }
1069
- if (nativeProps.accessibilityInvalid != null) {
1070
- viewProps["aria-invalid"] = nativeProps.accessibilityInvalid;
1071
- }
1072
- if (nativeProps.accessibilityKeyShortcuts != null && Array.isArray(nativeProps.accessibilityKeyShortcuts)) {
1073
- viewProps["aria-keyshortcuts"] = nativeProps.accessibilityKeyShortcuts.join(" ");
1074
- }
1075
- if (nativeProps.accessibilityLabel != null) {
1076
- viewProps["aria-label"] = nativeProps.accessibilityLabel;
1077
- }
1078
- if (nativeProps.accessibilityLabelledBy != null) {
1079
- viewProps["aria-labelledby"] = processIDRefList(nativeProps.accessibilityLabelledBy);
1080
- }
1081
- if (nativeProps.accessibilityLevel != null) {
1082
- viewProps["aria-level"] = nativeProps.accessibilityLevel;
1083
- }
1084
- if (nativeProps.accessibilityLiveRegion != null) {
1085
- viewProps["aria-live"] = nativeProps.accessibilityLiveRegion === "none" ? "off" : nativeProps.accessibilityLiveRegion;
1086
- }
1087
- if (nativeProps.accessibilityModal != null) {
1088
- viewProps["aria-modal"] = nativeProps.accessibilityModal;
1089
- }
1090
- if (nativeProps.accessibilityMultiline != null) {
1091
- viewProps["aria-multiline"] = nativeProps.accessibilityMultiline;
1092
- }
1093
- if (nativeProps.accessibilityMultiSelectable != null) {
1094
- viewProps["aria-multiselectable"] = nativeProps.accessibilityMultiSelectable;
1095
- }
1096
- if (nativeProps.accessibilityOrientation != null) {
1097
- viewProps["aria-orientation"] = nativeProps.accessibilityOrientation;
1098
- }
1099
- if (nativeProps.accessibilityOwns != null) {
1100
- viewProps["aria-owns"] = processIDRefList(nativeProps.accessibilityOwns);
1101
- }
1102
- if (nativeProps.accessibilityPlaceholder != null) {
1103
- viewProps["aria-placeholder"] = nativeProps.accessibilityPlaceholder;
1104
- }
1105
- if (nativeProps.accessibilityPosInSet != null) {
1106
- viewProps["aria-posinset"] = nativeProps.accessibilityPosInSet;
1107
- }
1108
- if (nativeProps.accessibilityPressed != null) {
1109
- viewProps["aria-pressed"] = nativeProps.accessibilityPressed;
1110
- }
1111
- if (nativeProps.accessibilityReadOnly != null) {
1112
- viewProps["aria-readonly"] = nativeProps.accessibilityReadOnly;
1113
- if (elementType === "input" || elementType === "select" || elementType === "textarea") {
1114
- viewProps.readOnly = true;
1115
- }
1116
- }
1117
- if (nativeProps.accessibilityRequired != null) {
1118
- viewProps["aria-required"] = nativeProps.accessibilityRequired;
1119
- if (elementType === "input" || elementType === "select" || elementType === "textarea") {
1120
- viewProps.required = true;
1121
- }
1122
- }
1123
- if (nativeProps.accessibilityRoleDescription != null) {
1124
- viewProps["aria-roledescription"] = nativeProps.accessibilityRoleDescription;
1125
- }
1126
- if (nativeProps.accessibilityRowCount != null) {
1127
- viewProps["aria-rowcount"] = nativeProps.accessibilityRowCount;
1128
- }
1129
- if (nativeProps.accessibilityRowIndex != null) {
1130
- viewProps["aria-rowindex"] = nativeProps.accessibilityRowIndex;
1131
- }
1132
- if (nativeProps.accessibilityRowSpan != null) {
1133
- viewProps["aria-rowspan"] = nativeProps.accessibilityRowSpan;
1134
- }
1135
- if (nativeProps.accessibilitySelected != null) {
1136
- viewProps["aria-selected"] = nativeProps.accessibilitySelected;
1137
- }
1138
- if (nativeProps.accessibilitySetSize != null) {
1139
- viewProps["aria-setsize"] = nativeProps.accessibilitySetSize;
1140
- }
1141
- if (nativeProps.accessibilitySort != null) {
1142
- viewProps["aria-sort"] = nativeProps.accessibilitySort;
1143
- }
1144
- if (nativeProps.accessibilityValueMax != null) {
1145
- viewProps["aria-valuemax"] = nativeProps.accessibilityValueMax;
1146
- }
1147
- if (nativeProps.accessibilityValueMin != null) {
1148
- viewProps["aria-valuemin"] = nativeProps.accessibilityValueMin;
1149
- }
1150
- if (nativeProps.accessibilityValueNow != null) {
1151
- viewProps["aria-valuenow"] = nativeProps.accessibilityValueNow;
1152
- }
1153
- if (nativeProps.accessibilityValueText != null) {
1154
- viewProps["aria-valuetext"] = nativeProps.accessibilityValueText;
1155
- }
1156
- if (nativeProps.nativeID) {
1157
- viewProps.id = nativeProps.nativeID;
1158
- }
1159
- }
1160
981
  function addPseudoToStyles(styles, initialPseudos, pseudos, name, force = false) {
1161
982
  const pseudoStyle = pseudos[name];
1162
983
  const shouldNestObject = import_platform.isWeb && name !== "enterStyle" && name !== "exitStyle";
@@ -1166,14 +987,44 @@ function addPseudoToStyles(styles, initialPseudos, pseudos, name, force = false)
1166
987
  styles.push(shouldNestObject && !force ? { [name]: style } : style);
1167
988
  }
1168
989
  }
990
+ const DefaultProps = /* @__PURE__ */ new Map();
991
+ function mergeConfigDefaultProps(name, props, configDefaults, parentNames) {
992
+ const len = parentNames.length;
993
+ let prev;
994
+ for (let i = 0; i < len; i++) {
995
+ const n = parentNames[i];
996
+ if (!n)
997
+ continue;
998
+ if (DefaultProps.has(n)) {
999
+ prev = DefaultProps.get(n);
1000
+ continue;
1001
+ }
1002
+ const props2 = configDefaults[n];
1003
+ if (!props2) {
1004
+ if (prev) {
1005
+ DefaultProps.set(n, prev);
1006
+ }
1007
+ continue;
1008
+ }
1009
+ prev = (0, import_mergeProps.mergeProps)(prev || {}, props2)[0];
1010
+ console.log("set prev", prev);
1011
+ DefaultProps.set(n, prev);
1012
+ }
1013
+ const ourDefaultsMerged = DefaultProps.get(name);
1014
+ if (ourDefaultsMerged) {
1015
+ return (0, import_mergeProps.mergeProps)(props, ourDefaultsMerged)[0];
1016
+ }
1017
+ return props;
1018
+ }
1169
1019
  // Annotate the CommonJS export names for ESM import in node:
1170
1020
  0 && (module.exports = {
1171
1021
  AbsoluteFill,
1172
1022
  Spacer,
1173
1023
  Unspaced,
1174
- assignNativePropsToWeb,
1024
+ accessibilityRoleToWebRole,
1175
1025
  createComponent,
1176
1026
  mouseUps,
1027
+ processIDRefList,
1177
1028
  spacedChildren
1178
1029
  });
1179
1030
  //# sourceMappingURL=createComponent.js.map