@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.
- package/dist/cjs/Spacer.cjs +47 -53
- package/dist/cjs/Spacer.native.cjs +64 -0
- package/dist/cjs/Spacer.native.js +49 -54
- package/dist/cjs/Spacer.native.js.map +1 -1
- package/dist/cjs/Unspaced.cjs +19 -20
- package/dist/cjs/Unspaced.native.cjs +37 -0
- package/dist/cjs/Unspaced.native.js +19 -19
- package/dist/cjs/Unspaced.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -18
- package/dist/cjs/index.native.cjs +30 -0
- package/dist/cjs/index.native.js +15 -17
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/spacedChildren.cjs +99 -130
- package/dist/cjs/spacedChildren.native.cjs +142 -0
- package/dist/cjs/spacedChildren.native.js +119 -153
- package/dist/cjs/spacedChildren.native.js.map +1 -1
- package/dist/cjs/types.cjs +10 -11
- package/dist/cjs/types.native.cjs +19 -0
- package/dist/cjs/types.native.js +10 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Spacer.mjs +35 -36
- package/dist/esm/Spacer.mjs.map +1 -1
- package/dist/esm/Spacer.native.js +37 -38
- package/dist/esm/Spacer.native.js.map +1 -1
- package/dist/esm/Unspaced.mjs +4 -3
- package/dist/esm/Unspaced.mjs.map +1 -1
- package/dist/esm/Unspaced.native.js +4 -3
- package/dist/esm/Unspaced.native.js.map +1 -1
- package/dist/esm/index.js +6 -4
- package/dist/esm/index.mjs +6 -4
- package/dist/esm/index.native.js +6 -4
- package/dist/esm/spacedChildren.mjs +84 -105
- package/dist/esm/spacedChildren.mjs.map +1 -1
- package/dist/esm/spacedChildren.native.js +104 -129
- package/dist/esm/spacedChildren.native.js.map +1 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/package.json +5 -4
- package/src/Spacer.tsx +7 -5
- package/types/Spacer.d.ts +14 -5
- package/types/Spacer.d.ts.map +1 -1
- package/types/Unspaced.d.ts +2 -1
- package/types/Unspaced.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
+
} });
|