@tamagui/group 2.0.0-rc.3 → 2.0.0-rc.31
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/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/package.json +12 -15
- 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/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./Group";
|
|
1
|
+
export * from "./Group.mjs";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
package/dist/jsx/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./Group";
|
|
1
|
+
export * from "./Group.mjs";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/jsx/index.js.map
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/group",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.31",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -19,15 +19,12 @@
|
|
|
19
19
|
"./package.json": "./package.json",
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./types/index.d.ts",
|
|
22
|
-
"react-native":
|
|
23
|
-
|
|
24
|
-
"import": "./dist/esm/index.native.js",
|
|
25
|
-
"require": "./dist/cjs/index.native.js"
|
|
26
|
-
},
|
|
22
|
+
"react-native": "./dist/esm/index.native.js",
|
|
23
|
+
"browser": "./dist/esm/index.mjs",
|
|
27
24
|
"module": "./dist/esm/index.mjs",
|
|
28
25
|
"import": "./dist/esm/index.mjs",
|
|
29
26
|
"require": "./dist/cjs/index.cjs",
|
|
30
|
-
"default": "./dist/
|
|
27
|
+
"default": "./dist/esm/index.mjs"
|
|
31
28
|
}
|
|
32
29
|
},
|
|
33
30
|
"publishConfig": {
|
|
@@ -40,17 +37,17 @@
|
|
|
40
37
|
"clean:build": "tamagui-build clean:build"
|
|
41
38
|
},
|
|
42
39
|
"dependencies": {
|
|
43
|
-
"@tamagui/core": "2.0.0-rc.
|
|
44
|
-
"@tamagui/create-context": "2.0.0-rc.
|
|
45
|
-
"@tamagui/helpers": "2.0.0-rc.
|
|
46
|
-
"@tamagui/spacer": "2.0.0-rc.
|
|
47
|
-
"@tamagui/stacks": "2.0.0-rc.
|
|
48
|
-
"@tamagui/use-controllable-state": "2.0.0-rc.
|
|
40
|
+
"@tamagui/core": "2.0.0-rc.31",
|
|
41
|
+
"@tamagui/create-context": "2.0.0-rc.31",
|
|
42
|
+
"@tamagui/helpers": "2.0.0-rc.31",
|
|
43
|
+
"@tamagui/spacer": "2.0.0-rc.31",
|
|
44
|
+
"@tamagui/stacks": "2.0.0-rc.31",
|
|
45
|
+
"@tamagui/use-controllable-state": "2.0.0-rc.31"
|
|
49
46
|
},
|
|
50
47
|
"devDependencies": {
|
|
51
|
-
"@tamagui/build": "2.0.0-rc.
|
|
48
|
+
"@tamagui/build": "2.0.0-rc.31",
|
|
52
49
|
"react": ">=19",
|
|
53
|
-
"react-native": "0.
|
|
50
|
+
"react-native": "0.83.2"
|
|
54
51
|
},
|
|
55
52
|
"peerDependencies": {
|
|
56
53
|
"react": ">=19",
|
package/dist/cjs/Group.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var Group_exports = {};
|
|
24
|
-
__export(Group_exports, {
|
|
25
|
-
Group: () => Group,
|
|
26
|
-
GroupFrame: () => GroupFrame,
|
|
27
|
-
XGroup: () => XGroup,
|
|
28
|
-
YGroup: () => YGroup,
|
|
29
|
-
createGroupScope: () => createGroupScope,
|
|
30
|
-
useGroupItem: () => useGroupItem
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(Group_exports);
|
|
33
|
-
var import_core = require("@tamagui/core"), import_create_context = require("@tamagui/create-context"), import_helpers = require("@tamagui/helpers"), import_stacks = require("@tamagui/stacks"), import_react = __toESM(require("react"), 1), import_useIndexedChildren = require("./useIndexedChildren"), import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
-
const GROUP_NAME = "Group", [createGroupContext, createGroupScope] = (0, import_create_context.createContextScope)(GROUP_NAME), [GroupProvider, useGroupContext] = createGroupContext(GROUP_NAME), GroupFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
35
|
-
name: "GroupFrame",
|
|
36
|
-
variants: {
|
|
37
|
-
unstyled: {
|
|
38
|
-
false: {
|
|
39
|
-
size: "$true"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
size: (val, { tokens }) => ({
|
|
43
|
-
borderRadius: tokens.radius[val] ?? val ?? tokens.radius.$true
|
|
44
|
-
})
|
|
45
|
-
},
|
|
46
|
-
defaultVariants: {
|
|
47
|
-
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
function createGroup(verticalDefault) {
|
|
51
|
-
return (0, import_helpers.withStaticProperties)(
|
|
52
|
-
GroupFrame.styleable((props, ref) => {
|
|
53
|
-
const {
|
|
54
|
-
__scopeGroup,
|
|
55
|
-
children: childrenProp,
|
|
56
|
-
orientation = verticalDefault ? "vertical" : "horizontal",
|
|
57
|
-
disabled,
|
|
58
|
-
...restProps
|
|
59
|
-
} = props, vertical = orientation === "vertical", indexedChildren = (0, import_useIndexedChildren.useIndexedChildren)(import_react.default.Children.toArray(childrenProp));
|
|
60
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupProvider, { vertical, disabled, scope: __scopeGroup, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
61
|
-
GroupFrame,
|
|
62
|
-
{
|
|
63
|
-
ref,
|
|
64
|
-
flexDirection: vertical ? "column" : "row",
|
|
65
|
-
...restProps,
|
|
66
|
-
children: indexedChildren
|
|
67
|
-
}
|
|
68
|
-
) });
|
|
69
|
-
}),
|
|
70
|
-
{
|
|
71
|
-
Item: GroupItem
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
function GroupItem(props) {
|
|
76
|
-
const { __scopeGroup, children, forcePlacement, ...forwardedProps } = props, context = useGroupContext("GroupItem", __scopeGroup), treeIndex = (0, import_useIndexedChildren.useIndex)();
|
|
77
|
-
if (!treeIndex)
|
|
78
|
-
throw Error("<Group.Item/> should only be used within a <Group/>");
|
|
79
|
-
if (!import_react.default.isValidElement(children))
|
|
80
|
-
return children;
|
|
81
|
-
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 = {
|
|
82
|
-
...forwardedProps,
|
|
83
|
-
...radiusStyles
|
|
84
|
-
};
|
|
85
|
-
context.disabled != null && (groupProps.disabled = children.props.disabled ?? context.disabled);
|
|
86
|
-
const mergedProps = (0, import_core.mergeSlotStyleProps)(groupProps, children.props);
|
|
87
|
-
return import_react.default.cloneElement(children, mergedProps);
|
|
88
|
-
}
|
|
89
|
-
const useGroupItem = (childrenProps, forcePlacement, __scopeGroup) => {
|
|
90
|
-
const treeIndex = (0, import_useIndexedChildren.useIndex)(), context = useGroupContext("GroupItem", __scopeGroup);
|
|
91
|
-
if (!treeIndex)
|
|
92
|
-
throw Error("useGroupItem should only be used within a <Group/>");
|
|
93
|
-
const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0, isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex, radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
|
|
94
|
-
return {
|
|
95
|
-
disabled: childrenProps.disabled ?? context.disabled,
|
|
96
|
-
...radiusStyles
|
|
97
|
-
};
|
|
98
|
-
}, Group = createGroup(!0), YGroup = Group, XGroup = createGroup(!1);
|
|
99
|
-
function getZeroedRadius(isFirst, isLast, vertical) {
|
|
100
|
-
return vertical ? {
|
|
101
|
-
...isFirst ? null : { borderTopLeftRadius: 0, borderTopRightRadius: 0 },
|
|
102
|
-
...isLast ? null : { borderBottomLeftRadius: 0, borderBottomRightRadius: 0 }
|
|
103
|
-
} : {
|
|
104
|
-
...isFirst ? null : { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 },
|
|
105
|
-
...isLast ? null : { borderTopRightRadius: 0, borderBottomRightRadius: 0 }
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=Group.js.map
|
package/dist/cjs/Group.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Group.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA4C,0BAE5C,wBAAmC,oCACnC,iBAAqC,6BACrC,gBAAuB,4BACvB,eAAkB,8BAClB,4BAA6C,iCA2DnC;AApDV,MAAM,aAAa,SAGb,CAAC,oBAAoB,gBAAgB,QAAI,0CAAmB,UAAU,GACtE,CAAC,eAAe,eAAe,IAAI,mBAAsC,UAAU,GAE5E,iBAAa,oBAAO,sBAAQ;AAAA,EACvC,MAAM;AAAA,EAEN,UAAU;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IAEA,MAAM,CAAC,KAAK,EAAE,OAAO,OAEZ;AAAA,MACL,cAFmB,OAAO,OAAO,GAAG,KAAK,OAAO,OAAO,OAAO;AAAA,IAGhE;AAAA,EAEJ;AAAA,EAEA,iBAAiB;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e,CAC1B,eACA,gBACA,iBACG;AACH,QAAM,gBAAY,oCAAS,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": ["React"]
|
|
6
|
-
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var index_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(index_exports);
|
|
14
|
-
__reExport(index_exports, require("./Group"), module.exports);
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var useIndexedChildren_exports = {};
|
|
24
|
-
__export(useIndexedChildren_exports, {
|
|
25
|
-
useIndex: () => useIndex,
|
|
26
|
-
useIndexedChildren: () => useIndexedChildren
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(useIndexedChildren_exports);
|
|
29
|
-
var React = __toESM(require("react"), 1), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
-
const MaxIndexContext = React.createContext([]), IndexContext = React.createContext(null);
|
|
31
|
-
function useIndex() {
|
|
32
|
-
const maxIndexPath = React.useContext(MaxIndexContext), indexPathString = React.useContext(IndexContext);
|
|
33
|
-
return React.useMemo(() => {
|
|
34
|
-
if (indexPathString === null)
|
|
35
|
-
return null;
|
|
36
|
-
const indexPath = parseIndexPath(indexPathString), maxIndex = maxIndexPath[maxIndexPath.length - 1], index = indexPath[indexPath.length - 1];
|
|
37
|
-
return {
|
|
38
|
-
maxIndex,
|
|
39
|
-
maxIndexPath,
|
|
40
|
-
index,
|
|
41
|
-
indexPath,
|
|
42
|
-
indexPathString,
|
|
43
|
-
isFirst: index === 0,
|
|
44
|
-
isLast: index === maxIndex,
|
|
45
|
-
isEven: index % 2 === 0,
|
|
46
|
-
isOdd: Math.abs(index % 2) === 1
|
|
47
|
-
};
|
|
48
|
-
}, [maxIndexPath, indexPathString]);
|
|
49
|
-
}
|
|
50
|
-
function useIndexedChildren(children) {
|
|
51
|
-
const parentMaxIndexPath = React.useContext(MaxIndexContext), indexPathString = React.useContext(IndexContext), childrenCount = React.Children.count(children), maxIndexPath = React.useMemo(
|
|
52
|
-
() => parentMaxIndexPath.concat(childrenCount - 1),
|
|
53
|
-
[childrenCount]
|
|
54
|
-
);
|
|
55
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MaxIndexContext.Provider, { value: maxIndexPath, children: React.Children.map(
|
|
56
|
-
children,
|
|
57
|
-
(child, index) => React.isValidElement(child) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
|
-
IndexContext.Provider,
|
|
59
|
-
{
|
|
60
|
-
value: indexPathString ? `${indexPathString}.${index.toString()}` : index.toString(),
|
|
61
|
-
children: child
|
|
62
|
-
},
|
|
63
|
-
child.key
|
|
64
|
-
) : child
|
|
65
|
-
) });
|
|
66
|
-
}
|
|
67
|
-
function parseIndexPath(indexPathString) {
|
|
68
|
-
return indexPathString.split(".").map((index) => Number.parseInt(index, 10));
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=useIndexedChildren.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/useIndexedChildren.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBA,YAAuB,8BA+Cb;AA7CV,MAAM,kBAAkB,MAAM,cAAwB,CAAC,CAAC,GAClD,eAAe,MAAM,cAA6B,IAAI;AAGrD,SAAS,WAAW;AACzB,QAAM,eAAe,MAAM,WAAW,eAAe,GAC/C,kBAAkB,MAAM,WAAW,YAAY;AAErD,SAAO,MAAM,QAAQ,MAAM;AACzB,QAAI,oBAAoB;AACtB,aAAO;AAGT,UAAM,YAAY,eAAe,eAAe,GAC1C,WAAW,aAAa,aAAa,SAAS,CAAC,GAC/C,QAAQ,UAAU,UAAU,SAAS,CAAC;AAE5C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,UAAU;AAAA,MACnB,QAAQ,UAAU;AAAA,MAClB,QAAQ,QAAQ,MAAM;AAAA,MACtB,OAAO,KAAK,IAAI,QAAQ,CAAC,MAAM;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,cAAc,eAAe,CAAC;AACpC;AAGO,SAAS,mBAAmB,UAA2B;AAC5D,QAAM,qBAAqB,MAAM,WAAW,eAAe,GACrD,kBAAkB,MAAM,WAAW,YAAY,GAC/C,gBAAgB,MAAM,SAAS,MAAM,QAAQ,GAC7C,eAAe,MAAM;AAAA,IACzB,MAAM,mBAAmB,OAAO,gBAAgB,CAAC;AAAA,IACjD,CAAC,aAAa;AAAA,EAChB;AAEA,SACE,4CAAC,gBAAgB,UAAhB,EAAyB,OAAO,cAC9B,gBAAM,SAAS;AAAA,IAAI;AAAA,IAAU,CAAC,OAAO,UACpC,MAAM,eAAe,KAAK,IACxB;AAAA,MAAC,aAAa;AAAA,MAAb;AAAA,QAEC,OACE,kBACI,GAAG,eAAe,IAAI,MAAM,SAAS,CAAC,KACtC,MAAM,SAAS;AAAA,QAGpB;AAAA;AAAA,MAPI,MAAM;AAAA,IAQb,IAEA;AAAA,EAEJ,GACF;AAEJ;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/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
|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,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
|
-
"sources": ["../../src/useIndexedChildren.tsx"],
|
|
4
|
-
"mappings": "AAyBA,YAAY,WAAW;AA+Cb;AA7CV,MAAM,kBAAkB,MAAM,cAAwB,CAAC,CAAC,GAClD,eAAe,MAAM,cAA6B,IAAI;AAGrD,SAAS,WAAW;AACzB,QAAM,eAAe,MAAM,WAAW,eAAe,GAC/C,kBAAkB,MAAM,WAAW,YAAY;AAErD,SAAO,MAAM,QAAQ,MAAM;AACzB,QAAI,oBAAoB;AACtB,aAAO;AAGT,UAAM,YAAY,eAAe,eAAe,GAC1C,WAAW,aAAa,aAAa,SAAS,CAAC,GAC/C,QAAQ,UAAU,UAAU,SAAS,CAAC;AAE5C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,UAAU;AAAA,MACnB,QAAQ,UAAU;AAAA,MAClB,QAAQ,QAAQ,MAAM;AAAA,MACtB,OAAO,KAAK,IAAI,QAAQ,CAAC,MAAM;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,cAAc,eAAe,CAAC;AACpC;AAGO,SAAS,mBAAmB,UAA2B;AAC5D,QAAM,qBAAqB,MAAM,WAAW,eAAe,GACrD,kBAAkB,MAAM,WAAW,YAAY,GAC/C,gBAAgB,MAAM,SAAS,MAAM,QAAQ,GAC7C,eAAe,MAAM;AAAA,IACzB,MAAM,mBAAmB,OAAO,gBAAgB,CAAC;AAAA,IACjD,CAAC,aAAa;AAAA,EAChB;AAEA,SACE,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,cAC9B,gBAAM,SAAS;AAAA,IAAI;AAAA,IAAU,CAAC,OAAO,UACpC,MAAM,eAAe,KAAK,IACxB;AAAA,MAAC,aAAa;AAAA,MAAb;AAAA,QAEC,OACE,kBACI,GAAG,eAAe,IAAI,MAAM,SAAS,CAAC,KACtC,MAAM,SAAS;AAAA,QAGpB;AAAA;AAAA,MAPI,MAAM;AAAA,IAQb,IAEA;AAAA,EAEJ,GACF;AAEJ;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
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AG,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
|
-
"sources": ["../../src/useIndexedChildren.tsx"],
|
|
4
|
-
"mappings": "AAyBA,YAAY,WAAW;AA+Cb;AA7CV,MAAM,kBAAkB,MAAM,cAAwB,CAAC,CAAC,GAClD,eAAe,MAAM,cAA6B,IAAI;AAGrD,SAAS,WAAW;AACzB,QAAM,eAAe,MAAM,WAAW,eAAe,GAC/C,kBAAkB,MAAM,WAAW,YAAY;AAErD,SAAO,MAAM,QAAQ,MAAM;AACzB,QAAI,oBAAoB;AACtB,aAAO;AAGT,UAAM,YAAY,eAAe,eAAe,GAC1C,WAAW,aAAa,aAAa,SAAS,CAAC,GAC/C,QAAQ,UAAU,UAAU,SAAS,CAAC;AAE5C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,UAAU;AAAA,MACnB,QAAQ,UAAU;AAAA,MAClB,QAAQ,QAAQ,MAAM;AAAA,MACtB,OAAO,KAAK,IAAI,QAAQ,CAAC,MAAM;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,cAAc,eAAe,CAAC;AACpC;AAGO,SAAS,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