@tamagui/spacer 2.7.7 → 3.0.0-beta.643.1

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 (48) hide show
  1. package/dist/cjs/Spacer.cjs +47 -53
  2. package/dist/cjs/Spacer.native.cjs +64 -0
  3. package/dist/cjs/Spacer.native.js +49 -54
  4. package/dist/cjs/Spacer.native.js.map +1 -1
  5. package/dist/cjs/Unspaced.cjs +19 -20
  6. package/dist/cjs/Unspaced.native.cjs +37 -0
  7. package/dist/cjs/Unspaced.native.js +19 -19
  8. package/dist/cjs/Unspaced.native.js.map +1 -1
  9. package/dist/cjs/index.cjs +15 -18
  10. package/dist/cjs/index.native.cjs +30 -0
  11. package/dist/cjs/index.native.js +15 -17
  12. package/dist/cjs/index.native.js.map +1 -1
  13. package/dist/cjs/spacedChildren.cjs +99 -130
  14. package/dist/cjs/spacedChildren.native.cjs +142 -0
  15. package/dist/cjs/spacedChildren.native.js +119 -153
  16. package/dist/cjs/spacedChildren.native.js.map +1 -1
  17. package/dist/cjs/types.cjs +10 -11
  18. package/dist/cjs/types.native.cjs +19 -0
  19. package/dist/cjs/types.native.js +10 -10
  20. package/dist/cjs/types.native.js.map +1 -1
  21. package/dist/esm/Spacer.mjs +35 -36
  22. package/dist/esm/Spacer.mjs.map +1 -1
  23. package/dist/esm/Spacer.native.js +37 -38
  24. package/dist/esm/Spacer.native.js.map +1 -1
  25. package/dist/esm/Unspaced.mjs +4 -3
  26. package/dist/esm/Unspaced.mjs.map +1 -1
  27. package/dist/esm/Unspaced.native.js +4 -3
  28. package/dist/esm/Unspaced.native.js.map +1 -1
  29. package/dist/esm/index.js +6 -4
  30. package/dist/esm/index.mjs +6 -4
  31. package/dist/esm/index.native.js +6 -4
  32. package/dist/esm/spacedChildren.mjs +84 -105
  33. package/dist/esm/spacedChildren.mjs.map +1 -1
  34. package/dist/esm/spacedChildren.native.js +104 -129
  35. package/dist/esm/spacedChildren.native.js.map +1 -1
  36. package/dist/esm/types.mjs +0 -2
  37. package/dist/esm/types.native.js +0 -2
  38. package/package.json +5 -4
  39. package/src/Spacer.tsx +7 -5
  40. package/types/Spacer.d.ts +14 -5
  41. package/types/Spacer.d.ts.map +1 -1
  42. package/types/Unspaced.d.ts +2 -1
  43. package/types/Unspaced.d.ts.map +1 -1
  44. package/dist/esm/index.js.map +0 -1
  45. package/dist/esm/index.mjs.map +0 -1
  46. package/dist/esm/index.native.js.map +0 -1
  47. package/dist/esm/types.mjs.map +0 -1
  48. package/dist/esm/types.native.js.map +0 -1
@@ -1,3 +1,4 @@
1
+
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -5,36 +6,27 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
30
26
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
28
  var spacedChildren_exports = {};
35
- __export(spacedChildren_exports, {
36
- spacedChildren: () => spacedChildren
37
- });
29
+ __export(spacedChildren_exports, { spacedChildren: () => spacedChildren });
38
30
  module.exports = __toCommonJS(spacedChildren_exports);
39
31
  var import_web = require("@tamagui/web");
40
32
  var import_react = __toESM(require("react"), 1);
@@ -42,110 +34,87 @@ var import_Spacer = require("./Spacer.cjs");
42
34
  var import_Unspaced = require("./Unspaced.cjs");
43
35
  var import_jsx_runtime = require("react/jsx-runtime");
44
36
  function spacedChildren(props) {
45
- const {
46
- isZStack,
47
- children,
48
- space,
49
- direction,
50
- spaceFlex,
51
- separator,
52
- ensureKeys
53
- } = props;
54
- const hasSpace = !!(space || spaceFlex);
55
- const hasSeparator = !(separator === void 0 || separator === null);
56
- const areChildrenArray = Array.isArray(children);
57
- if (!ensureKeys && !(hasSpace || hasSeparator || isZStack)) {
58
- return children;
59
- }
60
- const childrenList = areChildrenArray ? children : import_react.default.Children.toArray(children);
61
- const len = childrenList.length;
62
- if (len <= 1 && !isZStack && !childrenList[0]?.["type"]?.["shouldForwardSpace"]) {
63
- return children;
64
- }
65
- const final = [];
66
- for (let [index, child] of childrenList.entries()) {
67
- const isEmpty = child === null || child === void 0 || Array.isArray(child) && child.length === 0;
68
- if (!isEmpty && import_react.default.isValidElement(child) && child.type?.["shouldForwardSpace"]) {
69
- child = import_react.default.cloneElement(child, {
70
- space,
71
- spaceFlex,
72
- separator,
73
- key: child.key
74
- });
75
- }
76
- if (isEmpty || !child || child["key"] && !isZStack) {
77
- final.push(child);
78
- } else {
79
- final.push(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react.default.Fragment, {
80
- children: isZStack ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(AbsoluteFill, {
81
- children: child
82
- }) : child
83
- }, `${index}0t`));
84
- }
85
- if ((0, import_Unspaced.isUnspaced)(child) && index === 0) continue;
86
- if (isZStack) continue;
87
- const next = childrenList[index + 1];
88
- if (next && !isEmpty && !(0, import_Unspaced.isUnspaced)(next)) {
89
- if (separator) {
90
- if (hasSpace) {
91
- final.push(createSpacer({
92
- key: `_${index}_00t`,
93
- direction,
94
- space,
95
- spaceFlex
96
- }));
97
- }
98
- final.push(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react.default.Fragment, {
99
- children: separator
100
- }, `${index}03t`));
101
- if (hasSpace) {
102
- final.push(createSpacer({
103
- key: `_${index}01t`,
104
- direction,
105
- space,
106
- spaceFlex
107
- }));
108
- }
109
- } else {
110
- final.push(createSpacer({
111
- key: `_${index}02t`,
112
- direction,
113
- space,
114
- spaceFlex
115
- }));
116
- }
117
- }
118
- }
119
- if (process.env.NODE_ENV === "development") {
120
- if (props.debug) {
121
- console.info(` Spaced children`, final, props);
122
- }
123
- }
124
- return final;
37
+ const { isZStack, children, space, direction, spaceFlex, separator, ensureKeys } = props;
38
+ const hasSpace = !!(space || spaceFlex);
39
+ const hasSeparator = !(separator === void 0 || separator === null);
40
+ const areChildrenArray = Array.isArray(children);
41
+ if (!ensureKeys && !(hasSpace || hasSeparator || isZStack)) {
42
+ return children;
43
+ }
44
+ const childrenList = areChildrenArray ? children : import_react.default.Children.toArray(children);
45
+ const len = childrenList.length;
46
+ if (len <= 1 && !isZStack && !childrenList[0]?.["type"]?.["shouldForwardSpace"]) {
47
+ return children;
48
+ }
49
+ const final = [];
50
+ for (let [index, child] of childrenList.entries()) {
51
+ const isEmpty = child === null || child === void 0 || Array.isArray(child) && child.length === 0;
52
+ if (!isEmpty && import_react.default.isValidElement(child) && child.type?.["shouldForwardSpace"]) {
53
+ child = import_react.default.cloneElement(child, {
54
+ space,
55
+ spaceFlex,
56
+ separator,
57
+ key: child.key
58
+ });
59
+ }
60
+ if (isEmpty || !child || child["key"] && !isZStack) {
61
+ final.push(child);
62
+ } else {
63
+ final.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: isZStack ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AbsoluteFill, { children: child }) : child }, `${index}0t`));
64
+ }
65
+ if ((0, import_Unspaced.isUnspaced)(child) && index === 0) continue;
66
+ if (isZStack) continue;
67
+ const next = childrenList[index + 1];
68
+ if (next && !isEmpty && !(0, import_Unspaced.isUnspaced)(next)) {
69
+ if (separator) {
70
+ if (hasSpace) {
71
+ final.push(createSpacer({
72
+ key: `_${index}_00t`,
73
+ direction,
74
+ space,
75
+ spaceFlex
76
+ }));
77
+ }
78
+ final.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: separator }, `${index}03t`));
79
+ if (hasSpace) {
80
+ final.push(createSpacer({
81
+ key: `_${index}01t`,
82
+ direction,
83
+ space,
84
+ spaceFlex
85
+ }));
86
+ }
87
+ } else {
88
+ final.push(createSpacer({
89
+ key: `_${index}02t`,
90
+ direction,
91
+ space,
92
+ spaceFlex
93
+ }));
94
+ }
95
+ }
96
+ }
97
+ if (process.env.NODE_ENV === "development") {
98
+ if (props.debug) {
99
+ console.info(` Spaced children`, final, props);
100
+ }
101
+ }
102
+ return final;
125
103
  }
126
- function createSpacer({
127
- key,
128
- direction,
129
- space,
130
- spaceFlex
131
- }) {
132
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Spacer.Spacer, {
133
- size: space,
134
- direction,
135
- ...(typeof spaceFlex !== "undefined" && {
136
- flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex
137
- })
138
- }, key);
104
+ function createSpacer({ key, direction, space, spaceFlex }) {
105
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Spacer.Spacer, {
106
+ size: space,
107
+ direction,
108
+ ...typeof spaceFlex !== "undefined" && { flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex }
109
+ }, key);
139
110
  }
140
- const AbsoluteFill = (0, import_web.createComponent)({
141
- defaultProps: {
142
- display: "flex",
143
- flexDirection: "column",
144
- position: "absolute",
145
- top: 0,
146
- right: 0,
147
- bottom: 0,
148
- left: 0,
149
- pointerEvents: "box-none"
150
- }
151
- });
111
+ const AbsoluteFill = (0, import_web.createComponent)({ defaultProps: {
112
+ display: "flex",
113
+ flexDirection: "column",
114
+ position: "absolute",
115
+ top: 0,
116
+ right: 0,
117
+ bottom: 0,
118
+ left: 0,
119
+ pointerEvents: "box-none"
120
+ } });
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+
3
+
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var spacedChildren_exports = {};
31
+ __export(spacedChildren_exports, { spacedChildren: () => spacedChildren });
32
+ module.exports = __toCommonJS(spacedChildren_exports);
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var import_web = require("@tamagui/web");
35
+ var import_react = __toESM(require("react"), 1);
36
+ var import_Spacer = require("./Spacer.native.js");
37
+ var import_Unspaced = require("./Unspaced.native.js");
38
+ function spacedChildren(props) {
39
+ var _childrenList__type, _childrenList_;
40
+ var { isZStack, children, space, direction, spaceFlex, separator, ensureKeys } = props;
41
+ var hasSpace = !!(space || spaceFlex);
42
+ var hasSeparator = !(separator === void 0 || separator === null);
43
+ var areChildrenArray = Array.isArray(children);
44
+ if (!ensureKeys && !(hasSpace || hasSeparator || isZStack)) {
45
+ return children;
46
+ }
47
+ var childrenList = areChildrenArray ? children : import_react.default.Children.toArray(children);
48
+ var len = childrenList.length;
49
+ if (len <= 1 && !isZStack && !((_childrenList_ = childrenList[0]) === null || _childrenList_ === void 0 ? void 0 : (_childrenList__type = _childrenList_["type"]) === null || _childrenList__type === void 0 ? void 0 : _childrenList__type["shouldForwardSpace"])) {
50
+ return children;
51
+ }
52
+ var final = [];
53
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
54
+ try {
55
+ for (var _iterator = childrenList.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
56
+ var [index, child] = _step.value;
57
+ var _child_type;
58
+ var isEmpty = child === null || child === void 0 || Array.isArray(child) && child.length === 0;
59
+ if (!isEmpty && /* @__PURE__ */ import_react.default.isValidElement(child) && ((_child_type = child.type) === null || _child_type === void 0 ? void 0 : _child_type["shouldForwardSpace"])) {
60
+ child = /* @__PURE__ */ import_react.default.cloneElement(child, {
61
+ space,
62
+ spaceFlex,
63
+ separator,
64
+ key: child.key
65
+ });
66
+ }
67
+ if (isEmpty || !child || child["key"] && !isZStack) {
68
+ final.push(child);
69
+ } else {
70
+ final.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: isZStack ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AbsoluteFill, { children: child }) : child }, `${index}0t`));
71
+ }
72
+ if ((0, import_Unspaced.isUnspaced)(child) && index === 0) continue;
73
+ if (isZStack) continue;
74
+ var next = childrenList[index + 1];
75
+ if (next && !isEmpty && !(0, import_Unspaced.isUnspaced)(next)) {
76
+ if (separator) {
77
+ if (hasSpace) {
78
+ final.push(createSpacer({
79
+ key: `_${index}_00t`,
80
+ direction,
81
+ space,
82
+ spaceFlex
83
+ }));
84
+ }
85
+ final.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Fragment, { children: separator }, `${index}03t`));
86
+ if (hasSpace) {
87
+ final.push(createSpacer({
88
+ key: `_${index}01t`,
89
+ direction,
90
+ space,
91
+ spaceFlex
92
+ }));
93
+ }
94
+ } else {
95
+ final.push(createSpacer({
96
+ key: `_${index}02t`,
97
+ direction,
98
+ space,
99
+ spaceFlex
100
+ }));
101
+ }
102
+ }
103
+ }
104
+ } catch (err) {
105
+ _didIteratorError = true;
106
+ _iteratorError = err;
107
+ } finally {
108
+ try {
109
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
110
+ _iterator.return();
111
+ }
112
+ } finally {
113
+ if (_didIteratorError) {
114
+ throw _iteratorError;
115
+ }
116
+ }
117
+ }
118
+ if (process.env.NODE_ENV === "development") {
119
+ if (props.debug) {
120
+ console.info(` Spaced children`, final, props);
121
+ }
122
+ }
123
+ return final;
124
+ }
125
+ function createSpacer(param) {
126
+ var { key, direction, space, spaceFlex } = param;
127
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Spacer.Spacer, {
128
+ size: space,
129
+ direction,
130
+ ...typeof spaceFlex !== "undefined" && { flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex }
131
+ }, key);
132
+ }
133
+ var AbsoluteFill = (0, import_web.createComponent)({ defaultProps: {
134
+ display: "flex",
135
+ flexDirection: "column",
136
+ position: "absolute",
137
+ top: 0,
138
+ right: 0,
139
+ bottom: 0,
140
+ left: 0,
141
+ pointerEvents: "box-none"
142
+ } });