@tamagui/group 2.0.0-rc.9 → 2.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/Group.cjs +112 -96
- package/dist/cjs/Group.native.js +111 -101
- package/dist/cjs/Group.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useIndexedChildren.cjs +40 -36
- package/dist/cjs/useIndexedChildren.native.js +42 -38
- package/dist/cjs/useIndexedChildren.native.js.map +1 -1
- package/dist/esm/Group.mjs +81 -67
- package/dist/esm/Group.mjs.map +1 -1
- package/dist/esm/Group.native.js +80 -72
- package/dist/esm/Group.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useIndexedChildren.mjs +14 -12
- package/dist/esm/useIndexedChildren.mjs.map +1 -1
- package/dist/esm/useIndexedChildren.native.js +16 -14
- package/dist/esm/useIndexedChildren.native.js.map +1 -1
- package/dist/jsx/Group.mjs +81 -67
- package/dist/jsx/Group.mjs.map +1 -1
- package/dist/jsx/Group.native.js +111 -101
- package/dist/jsx/Group.native.js.map +1 -1
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/useIndexedChildren.mjs +14 -12
- package/dist/jsx/useIndexedChildren.mjs.map +1 -1
- package/dist/jsx/useIndexedChildren.native.js +42 -38
- package/dist/jsx/useIndexedChildren.native.js.map +1 -1
- package/package.json +12 -12
- package/dist/cjs/Group.js +0 -108
- package/dist/cjs/Group.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/useIndexedChildren.js +0 -70
- package/dist/cjs/useIndexedChildren.js.map +0 -6
- package/dist/esm/Group.js +0 -90
- package/dist/esm/Group.js.map +0 -6
- package/dist/esm/useIndexedChildren.js +0 -47
- package/dist/esm/useIndexedChildren.js.map +0 -6
- package/dist/jsx/Group.js +0 -90
- package/dist/jsx/Group.js.map +0 -6
- package/dist/jsx/useIndexedChildren.js +0 -47
- package/dist/jsx/useIndexedChildren.js.map +0 -6
package/dist/esm/Group.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { mergeSlotStyleProps, styled } from "@tamagui/core";
|
|
2
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
3
|
-
import { withStaticProperties } from "@tamagui/helpers";
|
|
4
|
-
import { YStack } from "@tamagui/stacks";
|
|
5
|
-
import React from "react";
|
|
6
|
-
import { useIndex, useIndexedChildren } from "./useIndexedChildren";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
const GROUP_NAME = "Group", [createGroupContext, createGroupScope] = createContextScope(GROUP_NAME), [GroupProvider, useGroupContext] = createGroupContext(GROUP_NAME), GroupFrame = styled(YStack, {
|
|
9
|
-
name: "GroupFrame",
|
|
10
|
-
variants: {
|
|
11
|
-
unstyled: {
|
|
12
|
-
false: {
|
|
13
|
-
size: "$true"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
size: (val, { tokens }) => ({
|
|
17
|
-
borderRadius: tokens.radius[val] ?? val ?? tokens.radius.$true
|
|
18
|
-
})
|
|
19
|
-
},
|
|
20
|
-
defaultVariants: {
|
|
21
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
function createGroup(verticalDefault) {
|
|
25
|
-
return withStaticProperties(
|
|
26
|
-
GroupFrame.styleable((props, ref) => {
|
|
27
|
-
const {
|
|
28
|
-
__scopeGroup,
|
|
29
|
-
children: childrenProp,
|
|
30
|
-
orientation = verticalDefault ? "vertical" : "horizontal",
|
|
31
|
-
disabled,
|
|
32
|
-
...restProps
|
|
33
|
-
} = props, vertical = orientation === "vertical", indexedChildren = useIndexedChildren(React.Children.toArray(childrenProp));
|
|
34
|
-
return /* @__PURE__ */ jsx(GroupProvider, { vertical, disabled, scope: __scopeGroup, children: /* @__PURE__ */ jsx(
|
|
35
|
-
GroupFrame,
|
|
36
|
-
{
|
|
37
|
-
ref,
|
|
38
|
-
flexDirection: vertical ? "column" : "row",
|
|
39
|
-
...restProps,
|
|
40
|
-
children: indexedChildren
|
|
41
|
-
}
|
|
42
|
-
) });
|
|
43
|
-
}),
|
|
44
|
-
{
|
|
45
|
-
Item: GroupItem
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
function GroupItem(props) {
|
|
50
|
-
const { __scopeGroup, children, forcePlacement, ...forwardedProps } = props, context = useGroupContext("GroupItem", __scopeGroup), treeIndex = useIndex();
|
|
51
|
-
if (!treeIndex)
|
|
52
|
-
throw Error("<Group.Item/> should only be used within a <Group/>");
|
|
53
|
-
if (!React.isValidElement(children))
|
|
54
|
-
return children;
|
|
55
|
-
const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0, isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex, radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical), groupProps = {
|
|
56
|
-
...forwardedProps,
|
|
57
|
-
...radiusStyles
|
|
58
|
-
};
|
|
59
|
-
context.disabled != null && (groupProps.disabled = children.props.disabled ?? context.disabled);
|
|
60
|
-
const mergedProps = mergeSlotStyleProps(groupProps, children.props);
|
|
61
|
-
return React.cloneElement(children, mergedProps);
|
|
62
|
-
}
|
|
63
|
-
const useGroupItem = (childrenProps, forcePlacement, __scopeGroup) => {
|
|
64
|
-
const treeIndex = useIndex(), context = useGroupContext("GroupItem", __scopeGroup);
|
|
65
|
-
if (!treeIndex)
|
|
66
|
-
throw Error("useGroupItem should only be used within a <Group/>");
|
|
67
|
-
const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0, isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex, radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
|
|
68
|
-
return {
|
|
69
|
-
disabled: childrenProps.disabled ?? context.disabled,
|
|
70
|
-
...radiusStyles
|
|
71
|
-
};
|
|
72
|
-
}, Group = createGroup(!0), YGroup = Group, XGroup = createGroup(!1);
|
|
73
|
-
function getZeroedRadius(isFirst, isLast, vertical) {
|
|
74
|
-
return vertical ? {
|
|
75
|
-
...isFirst ? null : { borderTopLeftRadius: 0, borderTopRightRadius: 0 },
|
|
76
|
-
...isLast ? null : { borderBottomLeftRadius: 0, borderBottomRightRadius: 0 }
|
|
77
|
-
} : {
|
|
78
|
-
...isFirst ? null : { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 },
|
|
79
|
-
...isLast ? null : { borderTopRightRadius: 0, borderBottomRightRadius: 0 }
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export {
|
|
83
|
-
Group,
|
|
84
|
-
GroupFrame,
|
|
85
|
-
XGroup,
|
|
86
|
-
YGroup,
|
|
87
|
-
createGroupScope,
|
|
88
|
-
useGroupItem
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=Group.js.map
|
package/dist/esm/Group.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Group.tsx"],
|
|
4
|
-
"mappings": "AACA,SAAS,qBAAqB,cAAc;AAE5C,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,SAAS,UAAU,0BAA0B;AA2DnC;AApDV,MAAM,aAAa,SAGb,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,UAAU,GACtE,CAAC,eAAe,eAAe,IAAI,mBAAsC,UAAU,GAE5E,aAAa,OAAO,QAAQ;AAAA,EACvC,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IAC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AY,SAAS,MAAc,YAAY,QAAQ;AAIpE,QAAM,cAAc,oBAAoB,YAAY,SAAS,KAAY;AAEzE,SAAO,MAAM,aAAa,UAAU,WAAW;AACjD;AAEO,MAAM,eAAe,CAC1B,eACA,gBACA,iBACG;AACH,QAAM,YAAY,SAAS,GACrB,UAAU,gBAAgB,aAAa,YAAY;AAEzD,MAAI,CAAC;AACH,UAAM,MAAM,oDAAoD;AAGlE,QAAM,UACJ,mBAAmB,WAAY,mBAAmB,UAAU,UAAU,UAAU,GAC5E,SACJ,mBAAmB,UAClB,mBAAmB,WAAW,UAAU,UAAU,UAAU,UAEzD,eAAe,gBAAgB,SAAS,QAAQ,QAAQ,QAAQ;AAEtE,SAAO;AAAA,IACL,UAAU,cAAc,YAAY,QAAQ;AAAA,IAC5C,GAAG;AAAA,EACL;AACF,GAEa,QAAQ,YAAY,EAAI,GACxB,SAAS,OACT,SAAS,YAAY,EAAK;AAMvC,SAAS,gBAAgB,SAAkB,QAAiB,UAAmB;AAC7E,SAAI,WAEK;AAAA,IACL,GAAI,UAAU,OAAO,EAAE,qBAAqB,GAAG,sBAAsB,EAAE;AAAA,IACvE,GAAI,SAAS,OAAO,EAAE,wBAAwB,GAAG,yBAAyB,EAAE;AAAA,EAC9E,IAGK;AAAA,IACL,GAAI,UAAU,OAAO,EAAE,qBAAqB,GAAG,wBAAwB,EAAE;AAAA,IACzE,GAAI,SAAS,OAAO,EAAE,sBAAsB,GAAG,yBAAyB,EAAE;AAAA,EAC5E;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
const MaxIndexContext = React.createContext([]), IndexContext = React.createContext(null);
|
|
4
|
-
function useIndex() {
|
|
5
|
-
const maxIndexPath = React.useContext(MaxIndexContext), indexPathString = React.useContext(IndexContext);
|
|
6
|
-
return React.useMemo(() => {
|
|
7
|
-
if (indexPathString === null)
|
|
8
|
-
return null;
|
|
9
|
-
const indexPath = parseIndexPath(indexPathString), maxIndex = maxIndexPath[maxIndexPath.length - 1], index = indexPath[indexPath.length - 1];
|
|
10
|
-
return {
|
|
11
|
-
maxIndex,
|
|
12
|
-
maxIndexPath,
|
|
13
|
-
index,
|
|
14
|
-
indexPath,
|
|
15
|
-
indexPathString,
|
|
16
|
-
isFirst: index === 0,
|
|
17
|
-
isLast: index === maxIndex,
|
|
18
|
-
isEven: index % 2 === 0,
|
|
19
|
-
isOdd: Math.abs(index % 2) === 1
|
|
20
|
-
};
|
|
21
|
-
}, [maxIndexPath, indexPathString]);
|
|
22
|
-
}
|
|
23
|
-
function useIndexedChildren(children) {
|
|
24
|
-
const parentMaxIndexPath = React.useContext(MaxIndexContext), indexPathString = React.useContext(IndexContext), childrenCount = React.Children.count(children), maxIndexPath = React.useMemo(
|
|
25
|
-
() => parentMaxIndexPath.concat(childrenCount - 1),
|
|
26
|
-
[childrenCount]
|
|
27
|
-
);
|
|
28
|
-
return /* @__PURE__ */ jsx(MaxIndexContext.Provider, { value: maxIndexPath, children: React.Children.map(
|
|
29
|
-
children,
|
|
30
|
-
(child, index) => React.isValidElement(child) ? /* @__PURE__ */ jsx(
|
|
31
|
-
IndexContext.Provider,
|
|
32
|
-
{
|
|
33
|
-
value: indexPathString ? `${indexPathString}.${index.toString()}` : index.toString(),
|
|
34
|
-
children: child
|
|
35
|
-
},
|
|
36
|
-
child.key
|
|
37
|
-
) : child
|
|
38
|
-
) });
|
|
39
|
-
}
|
|
40
|
-
function parseIndexPath(indexPathString) {
|
|
41
|
-
return indexPathString.split(".").map((index) => Number.parseInt(index, 10));
|
|
42
|
-
}
|
|
43
|
-
export {
|
|
44
|
-
useIndex,
|
|
45
|
-
useIndexedChildren
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=useIndexedChildren.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
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;AAQA,SAAS,eAAe,iBAAyB;AAC/C,SAAO,gBAAgB,MAAM,GAAG,EAAE,IAAI,CAAC,UAAU,OAAO,SAAS,OAAO,EAAE,CAAC;AAC7E;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/jsx/Group.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { mergeSlotStyleProps, styled } from "@tamagui/core";
|
|
2
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
3
|
-
import { withStaticProperties } from "@tamagui/helpers";
|
|
4
|
-
import { YStack } from "@tamagui/stacks";
|
|
5
|
-
import React from "react";
|
|
6
|
-
import { useIndex, useIndexedChildren } from "./useIndexedChildren";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
const GROUP_NAME = "Group", [createGroupContext, createGroupScope] = createContextScope(GROUP_NAME), [GroupProvider, useGroupContext] = createGroupContext(GROUP_NAME), GroupFrame = styled(YStack, {
|
|
9
|
-
name: "GroupFrame",
|
|
10
|
-
variants: {
|
|
11
|
-
unstyled: {
|
|
12
|
-
false: {
|
|
13
|
-
size: "$true"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
size: (val, { tokens }) => ({
|
|
17
|
-
borderRadius: tokens.radius[val] ?? val ?? tokens.radius.$true
|
|
18
|
-
})
|
|
19
|
-
},
|
|
20
|
-
defaultVariants: {
|
|
21
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
function createGroup(verticalDefault) {
|
|
25
|
-
return withStaticProperties(
|
|
26
|
-
GroupFrame.styleable((props, ref) => {
|
|
27
|
-
const {
|
|
28
|
-
__scopeGroup,
|
|
29
|
-
children: childrenProp,
|
|
30
|
-
orientation = verticalDefault ? "vertical" : "horizontal",
|
|
31
|
-
disabled,
|
|
32
|
-
...restProps
|
|
33
|
-
} = props, vertical = orientation === "vertical", indexedChildren = useIndexedChildren(React.Children.toArray(childrenProp));
|
|
34
|
-
return /* @__PURE__ */ jsx(GroupProvider, { vertical, disabled, scope: __scopeGroup, children: /* @__PURE__ */ jsx(
|
|
35
|
-
GroupFrame,
|
|
36
|
-
{
|
|
37
|
-
ref,
|
|
38
|
-
flexDirection: vertical ? "column" : "row",
|
|
39
|
-
...restProps,
|
|
40
|
-
children: indexedChildren
|
|
41
|
-
}
|
|
42
|
-
) });
|
|
43
|
-
}),
|
|
44
|
-
{
|
|
45
|
-
Item: GroupItem
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
function GroupItem(props) {
|
|
50
|
-
const { __scopeGroup, children, forcePlacement, ...forwardedProps } = props, context = useGroupContext("GroupItem", __scopeGroup), treeIndex = useIndex();
|
|
51
|
-
if (!treeIndex)
|
|
52
|
-
throw Error("<Group.Item/> should only be used within a <Group/>");
|
|
53
|
-
if (!React.isValidElement(children))
|
|
54
|
-
return children;
|
|
55
|
-
const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0, isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex, radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical), groupProps = {
|
|
56
|
-
...forwardedProps,
|
|
57
|
-
...radiusStyles
|
|
58
|
-
};
|
|
59
|
-
context.disabled != null && (groupProps.disabled = children.props.disabled ?? context.disabled);
|
|
60
|
-
const mergedProps = mergeSlotStyleProps(groupProps, children.props);
|
|
61
|
-
return React.cloneElement(children, mergedProps);
|
|
62
|
-
}
|
|
63
|
-
const useGroupItem = (childrenProps, forcePlacement, __scopeGroup) => {
|
|
64
|
-
const treeIndex = useIndex(), context = useGroupContext("GroupItem", __scopeGroup);
|
|
65
|
-
if (!treeIndex)
|
|
66
|
-
throw Error("useGroupItem should only be used within a <Group/>");
|
|
67
|
-
const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0, isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex, radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
|
|
68
|
-
return {
|
|
69
|
-
disabled: childrenProps.disabled ?? context.disabled,
|
|
70
|
-
...radiusStyles
|
|
71
|
-
};
|
|
72
|
-
}, Group = createGroup(!0), YGroup = Group, XGroup = createGroup(!1);
|
|
73
|
-
function getZeroedRadius(isFirst, isLast, vertical) {
|
|
74
|
-
return vertical ? {
|
|
75
|
-
...isFirst ? null : { borderTopLeftRadius: 0, borderTopRightRadius: 0 },
|
|
76
|
-
...isLast ? null : { borderBottomLeftRadius: 0, borderBottomRightRadius: 0 }
|
|
77
|
-
} : {
|
|
78
|
-
...isFirst ? null : { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 },
|
|
79
|
-
...isLast ? null : { borderTopRightRadius: 0, borderBottomRightRadius: 0 }
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export {
|
|
83
|
-
Group,
|
|
84
|
-
GroupFrame,
|
|
85
|
-
XGroup,
|
|
86
|
-
YGroup,
|
|
87
|
-
createGroupScope,
|
|
88
|
-
useGroupItem
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=Group.js.map
|
package/dist/jsx/Group.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Group.tsx"],
|
|
4
|
-
"mappings": "AACA,SAAS,qBAAqB,cAAc;AAE5C,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,SAAS,UAAU,0BAA0B;AA2DnC;AApDV,MAAM,aAAa,SAGb,CAAC,oBAAoB,gBAAgB,IAAI,mBAAmB,UAAU,GACtE,CAAC,eAAe,eAAe,IAAI,mBAAsC,UAAU,GAE5E,aAAa,OAAO,QAAQ;AAAA,EACvC,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,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WAAY,SAAS,MAAc,YAAY,QAAQ;AAIpE,QAAM,cAAc,oBAAoB,YAAY,SAAS,KAAY;AAEzE,SAAO,MAAM,aAAa,UAAU,WAAW;AACjD;AAEO,MAAM,eAAe,CAC1B,eACA,gBACA,iBACG;AACH,QAAM,YAAY,SAAS,GACrB,UAAU,gBAAgB,aAAa,YAAY;AAEzD,MAAI,CAAC;AACH,UAAM,MAAM,oDAAoD;AAGlE,QAAM,UACJ,mBAAmB,WAAY,mBAAmB,UAAU,UAAU,UAAU,GAC5E,SACJ,mBAAmB,UAClB,mBAAmB,WAAW,UAAU,UAAU,UAAU,UAEzD,eAAe,gBAAgB,SAAS,QAAQ,QAAQ,QAAQ;AAEtE,SAAO;AAAA,IACL,UAAU,cAAc,YAAY,QAAQ;AAAA,IAC5C,GAAG;AAAA,EACL;AACF,GAEa,QAAQ,YAAY,EAAI,GACxB,SAAS,OACT,SAAS,YAAY,EAAK;AAMvC,SAAS,gBAAgB,SAAkB,QAAiB,UAAmB;AAC7E,SAAI,WAEK;AAAA,IACL,GAAI,UAAU,OAAO,EAAE,qBAAqB,GAAG,sBAAsB,EAAE;AAAA,IACvE,GAAI,SAAS,OAAO,EAAE,wBAAwB,GAAG,yBAAyB,EAAE;AAAA,EAC9E,IAGK;AAAA,IACL,GAAI,UAAU,OAAO,EAAE,qBAAqB,GAAG,wBAAwB,EAAE;AAAA,IACzE,GAAI,SAAS,OAAO,EAAE,sBAAsB,GAAG,yBAAyB,EAAE;AAAA,EAC5E;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
const MaxIndexContext = React.createContext([]), IndexContext = React.createContext(null);
|
|
4
|
-
function useIndex() {
|
|
5
|
-
const maxIndexPath = React.useContext(MaxIndexContext), indexPathString = React.useContext(IndexContext);
|
|
6
|
-
return React.useMemo(() => {
|
|
7
|
-
if (indexPathString === null)
|
|
8
|
-
return null;
|
|
9
|
-
const indexPath = parseIndexPath(indexPathString), maxIndex = maxIndexPath[maxIndexPath.length - 1], index = indexPath[indexPath.length - 1];
|
|
10
|
-
return {
|
|
11
|
-
maxIndex,
|
|
12
|
-
maxIndexPath,
|
|
13
|
-
index,
|
|
14
|
-
indexPath,
|
|
15
|
-
indexPathString,
|
|
16
|
-
isFirst: index === 0,
|
|
17
|
-
isLast: index === maxIndex,
|
|
18
|
-
isEven: index % 2 === 0,
|
|
19
|
-
isOdd: Math.abs(index % 2) === 1
|
|
20
|
-
};
|
|
21
|
-
}, [maxIndexPath, indexPathString]);
|
|
22
|
-
}
|
|
23
|
-
function useIndexedChildren(children) {
|
|
24
|
-
const parentMaxIndexPath = React.useContext(MaxIndexContext), indexPathString = React.useContext(IndexContext), childrenCount = React.Children.count(children), maxIndexPath = React.useMemo(
|
|
25
|
-
() => parentMaxIndexPath.concat(childrenCount - 1),
|
|
26
|
-
[childrenCount]
|
|
27
|
-
);
|
|
28
|
-
return /* @__PURE__ */ jsx(MaxIndexContext.Provider, { value: maxIndexPath, children: React.Children.map(
|
|
29
|
-
children,
|
|
30
|
-
(child, index) => React.isValidElement(child) ? /* @__PURE__ */ jsx(
|
|
31
|
-
IndexContext.Provider,
|
|
32
|
-
{
|
|
33
|
-
value: indexPathString ? `${indexPathString}.${index.toString()}` : index.toString(),
|
|
34
|
-
children: child
|
|
35
|
-
},
|
|
36
|
-
child.key
|
|
37
|
-
) : child
|
|
38
|
-
) });
|
|
39
|
-
}
|
|
40
|
-
function parseIndexPath(indexPathString) {
|
|
41
|
-
return indexPathString.split(".").map((index) => Number.parseInt(index, 10));
|
|
42
|
-
}
|
|
43
|
-
export {
|
|
44
|
-
useIndex,
|
|
45
|
-
useIndexedChildren
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=useIndexedChildren.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
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