@tamagui/spacer 3.0.0-beta.924.1 → 3.0.0
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 +3 -4
- package/dist/cjs/Spacer.native.cjs +3 -6
- package/dist/cjs/Spacer.native.js +3 -6
- package/dist/cjs/Spacer.native.js.map +1 -1
- package/dist/cjs/index.cjs +0 -9
- package/dist/cjs/index.native.cjs +0 -9
- package/dist/cjs/index.native.js +0 -9
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Spacer.mjs +3 -4
- package/dist/esm/Spacer.mjs.map +1 -1
- package/dist/esm/Spacer.native.js +3 -6
- package/dist/esm/Spacer.native.js.map +1 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.mjs +0 -6
- package/dist/esm/index.native.js +0 -6
- package/package.json +7 -6
- package/src/Spacer.tsx +14 -13
- package/src/index.ts +0 -3
- package/types/Spacer.d.ts +5 -5
- package/types/Spacer.d.ts.map +1 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/Unspaced.cjs +0 -34
- package/dist/cjs/Unspaced.native.cjs +0 -36
- package/dist/cjs/Unspaced.native.js +0 -38
- package/dist/cjs/Unspaced.native.js.map +0 -1
- package/dist/cjs/spacedChildren.cjs +0 -119
- package/dist/cjs/spacedChildren.native.cjs +0 -141
- package/dist/cjs/spacedChildren.native.js +0 -143
- package/dist/cjs/spacedChildren.native.js.map +0 -1
- package/dist/cjs/types.cjs +0 -16
- package/dist/cjs/types.native.cjs +0 -18
- package/dist/cjs/types.native.js +0 -20
- package/dist/cjs/types.native.js.map +0 -1
- package/dist/esm/Unspaced.mjs +0 -11
- package/dist/esm/Unspaced.mjs.map +0 -1
- package/dist/esm/Unspaced.native.js +0 -11
- package/dist/esm/Unspaced.native.js.map +0 -1
- package/dist/esm/spacedChildren.mjs +0 -94
- package/dist/esm/spacedChildren.mjs.map +0 -1
- package/dist/esm/spacedChildren.native.js +0 -114
- package/dist/esm/spacedChildren.native.js.map +0 -1
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/types.native.js +0 -0
- package/src/Unspaced.tsx +0 -11
- package/src/spacedChildren.tsx +0 -134
- package/src/types.ts +0 -21
- package/types/Unspaced.d.ts +0 -9
- package/types/Unspaced.d.ts.map +0 -1
- package/types/spacedChildren.d.ts +0 -4
- package/types/spacedChildren.d.ts.map +0 -1
- package/types/types.d.ts +0 -19
- package/types/types.d.ts.map +0 -1
package/src/spacedChildren.tsx
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { createComponent } from '@tamagui/web'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { Spacer } from './Spacer'
|
|
4
|
-
import { isUnspaced } from './Unspaced'
|
|
5
|
-
import type { SpacedChildrenProps } from './types'
|
|
6
|
-
|
|
7
|
-
export function spacedChildren(props: SpacedChildrenProps) {
|
|
8
|
-
const { isZStack, children, space, direction, spaceFlex, separator, ensureKeys } = props
|
|
9
|
-
const hasSpace = !!(space || spaceFlex)
|
|
10
|
-
const hasSeparator = !(separator === undefined || separator === null)
|
|
11
|
-
const areChildrenArray = Array.isArray(children)
|
|
12
|
-
|
|
13
|
-
if (!ensureKeys && !(hasSpace || hasSeparator || isZStack)) {
|
|
14
|
-
return children
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const childrenList = areChildrenArray
|
|
18
|
-
? (children as any[])
|
|
19
|
-
: React.Children.toArray(children)
|
|
20
|
-
|
|
21
|
-
const len = childrenList.length
|
|
22
|
-
if (len <= 1 && !isZStack && !childrenList[0]?.['type']?.['shouldForwardSpace']) {
|
|
23
|
-
return children
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const final: React.ReactNode[] = []
|
|
27
|
-
for (let [index, child] of childrenList.entries()) {
|
|
28
|
-
const isEmpty =
|
|
29
|
-
child === null ||
|
|
30
|
-
child === undefined ||
|
|
31
|
-
(Array.isArray(child) && child.length === 0)
|
|
32
|
-
|
|
33
|
-
// forward space
|
|
34
|
-
if (!isEmpty && React.isValidElement(child) && child.type?.['shouldForwardSpace']) {
|
|
35
|
-
child = React.cloneElement(child, {
|
|
36
|
-
space,
|
|
37
|
-
spaceFlex,
|
|
38
|
-
separator,
|
|
39
|
-
key: child.key,
|
|
40
|
-
} as any)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// push them all, but wrap some in Fragment
|
|
44
|
-
if (isEmpty || !child || (child['key'] && !isZStack)) {
|
|
45
|
-
final.push(child)
|
|
46
|
-
} else {
|
|
47
|
-
final.push(
|
|
48
|
-
<React.Fragment key={`${index}0t`}>
|
|
49
|
-
{isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}
|
|
50
|
-
</React.Fragment>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// first child unspaced avoid insert space
|
|
55
|
-
if (isUnspaced(child) && index === 0) continue
|
|
56
|
-
// no spacing on ZStack
|
|
57
|
-
if (isZStack) continue
|
|
58
|
-
|
|
59
|
-
const next = childrenList[index + 1]
|
|
60
|
-
|
|
61
|
-
if (next && !isEmpty && !isUnspaced(next)) {
|
|
62
|
-
if (separator) {
|
|
63
|
-
if (hasSpace) {
|
|
64
|
-
final.push(
|
|
65
|
-
createSpacer({
|
|
66
|
-
key: `_${index}_00t`,
|
|
67
|
-
direction,
|
|
68
|
-
space,
|
|
69
|
-
spaceFlex,
|
|
70
|
-
})
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
final.push(<React.Fragment key={`${index}03t`}>{separator}</React.Fragment>)
|
|
74
|
-
if (hasSpace) {
|
|
75
|
-
final.push(
|
|
76
|
-
createSpacer({
|
|
77
|
-
key: `_${index}01t`,
|
|
78
|
-
direction,
|
|
79
|
-
space,
|
|
80
|
-
spaceFlex,
|
|
81
|
-
})
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
final.push(
|
|
86
|
-
createSpacer({
|
|
87
|
-
key: `_${index}02t`,
|
|
88
|
-
direction,
|
|
89
|
-
space,
|
|
90
|
-
spaceFlex,
|
|
91
|
-
})
|
|
92
|
-
)
|
|
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
|
-
|
|
103
|
-
return final
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
type CreateSpacerProps = SpacedChildrenProps & { key: string }
|
|
107
|
-
|
|
108
|
-
function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
|
|
109
|
-
return (
|
|
110
|
-
<Spacer
|
|
111
|
-
key={key}
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
size={space}
|
|
114
|
-
// @ts-ignore
|
|
115
|
-
direction={direction}
|
|
116
|
-
{...(typeof spaceFlex !== 'undefined' && {
|
|
117
|
-
flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex,
|
|
118
|
-
})}
|
|
119
|
-
/>
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const AbsoluteFill: any = createComponent({
|
|
124
|
-
defaultProps: {
|
|
125
|
-
display: 'flex',
|
|
126
|
-
flexDirection: 'column',
|
|
127
|
-
position: 'absolute',
|
|
128
|
-
top: 0,
|
|
129
|
-
right: 0,
|
|
130
|
-
bottom: 0,
|
|
131
|
-
left: 0,
|
|
132
|
-
pointerEvents: 'box-none',
|
|
133
|
-
},
|
|
134
|
-
})
|
package/src/types.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { DebugProp, SpaceTokens, SpaceValue } from '@tamagui/web'
|
|
2
|
-
|
|
3
|
-
export type SpaceDirection = 'vertical' | 'horizontal' | 'both'
|
|
4
|
-
|
|
5
|
-
export type SpacedChildrenProps = {
|
|
6
|
-
isZStack?: boolean
|
|
7
|
-
children?: React.ReactNode
|
|
8
|
-
space?: SpaceValue
|
|
9
|
-
spaceFlex?: boolean | number
|
|
10
|
-
direction?: SpaceDirection
|
|
11
|
-
separator?: React.ReactNode
|
|
12
|
-
ensureKeys?: boolean
|
|
13
|
-
debug?: DebugProp
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type SpaceProps = {
|
|
17
|
-
space?: SpaceTokens | number
|
|
18
|
-
spaceDirection?: SpaceDirection
|
|
19
|
-
separator?: React.ReactNode
|
|
20
|
-
flex?: SpaceTokens | number | boolean
|
|
21
|
-
}
|
package/types/Unspaced.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function Unspaced(props: {
|
|
2
|
-
children?: any;
|
|
3
|
-
}): any;
|
|
4
|
-
export declare namespace Unspaced {
|
|
5
|
-
var _a: boolean;
|
|
6
|
-
export { _a as isUnspaced };
|
|
7
|
-
}
|
|
8
|
-
export declare function isUnspaced(child: React.ReactNode): any;
|
|
9
|
-
//# sourceMappingURL=Unspaced.d.ts.map
|
package/types/Unspaced.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Unspaced.d.ts","sourceRoot":"","sources":["../src/Unspaced.tsx"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,OAEjD;yBAFe,QAAQ;;;;AAMxB,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,OAGhD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spacedChildren.d.ts","sourceRoot":"","sources":["../src/spacedChildren.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,mBAiGxD"}
|
package/types/types.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DebugProp, SpaceTokens, SpaceValue } from '@tamagui/web';
|
|
2
|
-
export type SpaceDirection = 'vertical' | 'horizontal' | 'both';
|
|
3
|
-
export type SpacedChildrenProps = {
|
|
4
|
-
isZStack?: boolean;
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
space?: SpaceValue;
|
|
7
|
-
spaceFlex?: boolean | number;
|
|
8
|
-
direction?: SpaceDirection;
|
|
9
|
-
separator?: React.ReactNode;
|
|
10
|
-
ensureKeys?: boolean;
|
|
11
|
-
debug?: DebugProp;
|
|
12
|
-
};
|
|
13
|
-
export type SpaceProps = {
|
|
14
|
-
space?: SpaceTokens | number;
|
|
15
|
-
spaceDirection?: SpaceDirection;
|
|
16
|
-
separator?: React.ReactNode;
|
|
17
|
-
flex?: SpaceTokens | number | boolean;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=types.d.ts.map
|
package/types/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEtE,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,CAAA;AAE/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAA;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IAC5B,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAA;CACtC,CAAA"}
|