@tamagui/collection 1.89.26 → 1.89.27-1708113113238
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/Collection.native.js +85 -31
- package/dist/cjs/Collection.native.js.map +3 -3
- package/dist/cjs/index.native.js.map +2 -2
- package/dist/esm/Collection.native.js +84 -31
- package/dist/esm/Collection.native.js.map +3 -3
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/Collection.native.js +84 -31
- package/dist/jsx/Collection.native.js.map +3 -3
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +9 -9
|
@@ -26,52 +26,106 @@ __export(Collection_exports, {
|
|
|
26
26
|
createCollection: () => createCollection
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(Collection_exports);
|
|
29
|
-
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_react = __toESM(require("react"))
|
|
29
|
+
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_react = __toESM(require("react"));
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
32
|
+
value,
|
|
33
|
+
enumerable: !0,
|
|
34
|
+
configurable: !0,
|
|
35
|
+
writable: !0
|
|
36
|
+
}) : obj[key] = value, obj;
|
|
37
|
+
}
|
|
38
|
+
function _object_spread(target) {
|
|
39
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
40
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys = Object.keys(source);
|
|
41
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
42
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
43
|
+
}))), ownKeys.forEach(function(key) {
|
|
44
|
+
_define_property(target, key, source[key]);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return target;
|
|
48
|
+
}
|
|
49
|
+
function _object_without_properties(source, excluded) {
|
|
50
|
+
if (source == null)
|
|
51
|
+
return {};
|
|
52
|
+
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
53
|
+
if (Object.getOwnPropertySymbols) {
|
|
54
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
55
|
+
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
56
|
+
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
57
|
+
}
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
60
|
+
function _object_without_properties_loose(source, excluded) {
|
|
61
|
+
if (source == null)
|
|
62
|
+
return {};
|
|
63
|
+
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
64
|
+
for (i = 0; i < sourceKeys.length; i++)
|
|
65
|
+
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
66
|
+
return target;
|
|
67
|
+
}
|
|
30
68
|
function createCollection(name) {
|
|
31
|
-
|
|
32
|
-
collectionRef: {
|
|
69
|
+
var _createStyledContext = (0, import_core.createStyledContext)({
|
|
70
|
+
collectionRef: {
|
|
71
|
+
current: null
|
|
72
|
+
},
|
|
33
73
|
itemMap: /* @__PURE__ */ new Map()
|
|
34
|
-
}), CollectionProvider = (props)
|
|
35
|
-
|
|
36
|
-
return /* @__PURE__ */ (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
collectionRef: ref,
|
|
42
|
-
children
|
|
43
|
-
}
|
|
44
|
-
);
|
|
74
|
+
}), CollectionProviderImpl = _createStyledContext.Provider, useCollectionContext = _createStyledContext.useStyledContext, CollectionProvider = function(props) {
|
|
75
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, ref = import_react.default.useRef(null), itemMap = import_react.default.useRef(/* @__PURE__ */ new Map()).current;
|
|
76
|
+
return /* @__PURE__ */ import_react.default.createElement(CollectionProviderImpl, {
|
|
77
|
+
scope: __scopeCollection,
|
|
78
|
+
itemMap,
|
|
79
|
+
collectionRef: ref
|
|
80
|
+
}, children);
|
|
45
81
|
};
|
|
46
82
|
CollectionProvider.displayName = "CollectionProvider";
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return /* @__PURE__ */
|
|
83
|
+
var COLLECTION_SLOT_NAME = name + "CollectionSlot", CollectionSlot = /* @__PURE__ */ import_react.default.forwardRef(function(props, forwardedRef) {
|
|
84
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, context = useCollectionContext(__scopeCollection), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
|
|
85
|
+
return /* @__PURE__ */ import_react.default.createElement(import_core.Slot, {
|
|
86
|
+
ref: composedRefs
|
|
87
|
+
}, children);
|
|
50
88
|
});
|
|
51
89
|
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
90
|
+
var ITEM_SLOT_NAME = name + "CollectionItemSlot", ITEM_DATA_ATTR = "data-collection-item", CollectionItemSlot = /* @__PURE__ */ import_react.default.forwardRef(function(props, forwardedRef) {
|
|
91
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, itemData = _object_without_properties(props, [
|
|
92
|
+
"__scopeCollection",
|
|
93
|
+
"children"
|
|
94
|
+
]), ref = import_react.default.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref), context = useCollectionContext(__scopeCollection);
|
|
95
|
+
import_react.default.useEffect(function() {
|
|
96
|
+
return context.itemMap.set(ref, _object_spread({
|
|
97
|
+
ref
|
|
98
|
+
}, itemData)), function() {
|
|
99
|
+
return void context.itemMap.delete(ref);
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
var _obj;
|
|
103
|
+
return /* @__PURE__ */ import_react.default.createElement(import_core.Slot, (_obj = {}, _define_property(_obj, ITEM_DATA_ATTR, ""), _define_property(_obj, "ref", composedRefs), _obj), children);
|
|
55
104
|
});
|
|
56
105
|
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
57
106
|
function useCollection(__scopeCollection) {
|
|
58
|
-
|
|
59
|
-
return import_react.default.useCallback(() => {
|
|
107
|
+
var context = useCollectionContext(__scopeCollection), getItems = import_react.default.useCallback(function() {
|
|
60
108
|
if (!import_constants.isWeb)
|
|
61
109
|
return [];
|
|
62
|
-
|
|
110
|
+
var collectionNode = context.collectionRef.current;
|
|
63
111
|
if (!collectionNode)
|
|
64
112
|
return [];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
);
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
113
|
+
var orderedNodes = Array.from(collectionNode.querySelectorAll("[".concat(ITEM_DATA_ATTR, "]"))), items = Array.from(context.itemMap.values()), orderedItems = items.sort(function(a, b) {
|
|
114
|
+
return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);
|
|
115
|
+
});
|
|
116
|
+
return orderedItems;
|
|
117
|
+
}, [
|
|
118
|
+
context.collectionRef,
|
|
119
|
+
context.itemMap
|
|
120
|
+
]);
|
|
121
|
+
return getItems;
|
|
72
122
|
}
|
|
73
123
|
return [
|
|
74
|
-
{
|
|
124
|
+
{
|
|
125
|
+
Provider: CollectionProvider,
|
|
126
|
+
Slot: CollectionSlot,
|
|
127
|
+
ItemSlot: CollectionItemSlot
|
|
128
|
+
},
|
|
75
129
|
useCollection
|
|
76
130
|
];
|
|
77
131
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/Collection.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": ["React"]
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/packages/collection/src/Collection.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;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cR,GAAAA,GAC7CS,UAAUf,qBAAqBI,iBAAAA;AAErCG,iBAAAA,QAAMgB,UAAU,WAAA;AACdR,qBAAQnB,QAAQ4B,IAAIlB,KAAK,eAAA;QAAEA;SAASgB,QAAAA,CAAAA,GAC7B,WAAA;eAAM,KAAKP,QAAQnB,QAAQ6B,OAAOnB,GAAAA;;IAC3C,CAAA;;AAEA,WACE,6BAAAC,QAAA,cAACW,mBAAAA,OAAAA,CAAAA,GAAW,iBAAA,MAACE,gBAAiB,EAAA,GAAMd,iBAAAA,MAAAA,OAAKU,YAAAA,GAAAA,OACtCX,QAAAA;EAGP,CAAA;AAEAgB,qBAAmBX,cAAcS;AAMjC,WAASO,cAActB,mBAAsB;AAC3C,QAAMW,UAAUf,qBAAqBI,iBAAAA,GAE/BuB,WAAWpB,aAAAA,QAAMqB,YAAY,WAAA;AACjC,UAAI,CAACC;AACH,eAAO,CAAA;AAGT,UAAMC,iBAAiBf,QAAQrB,cAAcC;AAC7C,UAAI,CAACmC;AAAgB,eAAO,CAAA;AAC5B,UAAMC,eAAeC,MAAMC,KACzBH,eAAeI,iBAAkB,IAAkB,OAAfd,gBAAe,GAAA,CAAA,CAAA,GAE/Ce,QAAQH,MAAMC,KAAKlB,QAAQnB,QAAQwC,OAAM,CAAA,GACzCC,eAAeF,MAAMG,KACzB,SAACC,GAAGC,GAAAA;eACFT,aAAaU,QAAQF,EAAEjC,IAAIX,OAAO,IAClCoC,aAAaU,QAAQD,EAAElC,IAAIX,OAAO;;AAEtC,aAAO0C;IACT,GAAG;MAACtB,QAAQrB;MAAeqB,QAAQnB;KAAQ;AAE3C,WAAO+B;EACT;AAEA,SAAO;IACL;MAAE5B,UAAUG;MAAoBgB,MAAMN;MAAgB8B,UAAUrB;IAAmB;IACnFK;;AAEJ;",
|
|
5
|
+
"names": ["createCollection", "name", "createStyledContext", "collectionRef", "current", "itemMap", "Map", "CollectionProviderImpl", "Provider", "useCollectionContext", "useStyledContext", "CollectionProvider", "props", "__scopeCollection", "children", "ref", "React", "useRef", "scope", "displayName", "COLLECTION_SLOT_NAME", "CollectionSlot", "forwardRef", "forwardedRef", "context", "composedRefs", "useComposedRefs", "Slot", "ITEM_SLOT_NAME", "ITEM_DATA_ATTR", "CollectionItemSlot", "itemData", "useEffect", "set", "delete", "useCollection", "getItems", "useCallback", "isWeb", "collectionNode", "orderedNodes", "Array", "from", "querySelectorAll", "items", "values", "orderedItems", "sort", "a", "b", "indexOf", "ItemSlot"]
|
|
6
6
|
}
|
|
@@ -2,52 +2,105 @@ import { useComposedRefs } from "@tamagui/compose-refs";
|
|
|
2
2
|
import { isWeb } from "@tamagui/constants";
|
|
3
3
|
import { Slot, createStyledContext } from "@tamagui/core";
|
|
4
4
|
import React from "react";
|
|
5
|
-
|
|
5
|
+
function _define_property(obj, key, value) {
|
|
6
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
7
|
+
value,
|
|
8
|
+
enumerable: !0,
|
|
9
|
+
configurable: !0,
|
|
10
|
+
writable: !0
|
|
11
|
+
}) : obj[key] = value, obj;
|
|
12
|
+
}
|
|
13
|
+
function _object_spread(target) {
|
|
14
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys = Object.keys(source);
|
|
16
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
17
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
18
|
+
}))), ownKeys.forEach(function(key) {
|
|
19
|
+
_define_property(target, key, source[key]);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return target;
|
|
23
|
+
}
|
|
24
|
+
function _object_without_properties(source, excluded) {
|
|
25
|
+
if (source == null)
|
|
26
|
+
return {};
|
|
27
|
+
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
28
|
+
if (Object.getOwnPropertySymbols) {
|
|
29
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
30
|
+
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
31
|
+
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
}
|
|
35
|
+
function _object_without_properties_loose(source, excluded) {
|
|
36
|
+
if (source == null)
|
|
37
|
+
return {};
|
|
38
|
+
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
39
|
+
for (i = 0; i < sourceKeys.length; i++)
|
|
40
|
+
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
6
43
|
function createCollection(name) {
|
|
7
|
-
|
|
8
|
-
collectionRef: {
|
|
44
|
+
var _createStyledContext = createStyledContext({
|
|
45
|
+
collectionRef: {
|
|
46
|
+
current: null
|
|
47
|
+
},
|
|
9
48
|
itemMap: /* @__PURE__ */ new Map()
|
|
10
|
-
}), CollectionProvider = (props)
|
|
11
|
-
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
collectionRef: ref,
|
|
18
|
-
children
|
|
19
|
-
}
|
|
20
|
-
);
|
|
49
|
+
}), CollectionProviderImpl = _createStyledContext.Provider, useCollectionContext = _createStyledContext.useStyledContext, CollectionProvider = function(props) {
|
|
50
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, ref = React.useRef(null), itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
51
|
+
return /* @__PURE__ */ React.createElement(CollectionProviderImpl, {
|
|
52
|
+
scope: __scopeCollection,
|
|
53
|
+
itemMap,
|
|
54
|
+
collectionRef: ref
|
|
55
|
+
}, children);
|
|
21
56
|
};
|
|
22
57
|
CollectionProvider.displayName = "CollectionProvider";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return /* @__PURE__ */
|
|
58
|
+
var COLLECTION_SLOT_NAME = name + "CollectionSlot", CollectionSlot = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
59
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, context = useCollectionContext(__scopeCollection), composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
60
|
+
return /* @__PURE__ */ React.createElement(Slot, {
|
|
61
|
+
ref: composedRefs
|
|
62
|
+
}, children);
|
|
26
63
|
});
|
|
27
64
|
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
65
|
+
var ITEM_SLOT_NAME = name + "CollectionItemSlot", ITEM_DATA_ATTR = "data-collection-item", CollectionItemSlot = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
66
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, itemData = _object_without_properties(props, [
|
|
67
|
+
"__scopeCollection",
|
|
68
|
+
"children"
|
|
69
|
+
]), ref = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref), context = useCollectionContext(__scopeCollection);
|
|
70
|
+
React.useEffect(function() {
|
|
71
|
+
return context.itemMap.set(ref, _object_spread({
|
|
72
|
+
ref
|
|
73
|
+
}, itemData)), function() {
|
|
74
|
+
return void context.itemMap.delete(ref);
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
var _obj;
|
|
78
|
+
return /* @__PURE__ */ React.createElement(Slot, (_obj = {}, _define_property(_obj, ITEM_DATA_ATTR, ""), _define_property(_obj, "ref", composedRefs), _obj), children);
|
|
31
79
|
});
|
|
32
80
|
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
33
81
|
function useCollection(__scopeCollection) {
|
|
34
|
-
|
|
35
|
-
return React.useCallback(() => {
|
|
82
|
+
var context = useCollectionContext(__scopeCollection), getItems = React.useCallback(function() {
|
|
36
83
|
if (!isWeb)
|
|
37
84
|
return [];
|
|
38
|
-
|
|
85
|
+
var collectionNode = context.collectionRef.current;
|
|
39
86
|
if (!collectionNode)
|
|
40
87
|
return [];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
88
|
+
var orderedNodes = Array.from(collectionNode.querySelectorAll("[".concat(ITEM_DATA_ATTR, "]"))), items = Array.from(context.itemMap.values()), orderedItems = items.sort(function(a, b) {
|
|
89
|
+
return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);
|
|
90
|
+
});
|
|
91
|
+
return orderedItems;
|
|
92
|
+
}, [
|
|
93
|
+
context.collectionRef,
|
|
94
|
+
context.itemMap
|
|
95
|
+
]);
|
|
96
|
+
return getItems;
|
|
48
97
|
}
|
|
49
98
|
return [
|
|
50
|
-
{
|
|
99
|
+
{
|
|
100
|
+
Provider: CollectionProvider,
|
|
101
|
+
Slot: CollectionSlot,
|
|
102
|
+
ItemSlot: CollectionItemSlot
|
|
103
|
+
},
|
|
51
104
|
useCollection
|
|
52
105
|
];
|
|
53
106
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/Collection.tsx"],
|
|
4
|
-
"mappings": "AAAA,
|
|
5
|
-
"names": []
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/packages/collection/src/Collection.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AAEtB,SAASC,MAAMC,2BAA2B;AAC1C,OAAOC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWlB,SAASC,iBACPC,MAAY;AAoBZ,MACEH,uBAAAA,oBAAkC;IAChCI,eAAe;MAAEC,SAAS;IAAK;IAC/BC,SAAS,oBAAIC,IAAAA;EACf,CAAA,GAJgBC,yBAChBR,qBADMS,UAAoDC,uBAC1DV,qBADwCW,kBAMpCC,qBAGD,SAACC,OAAAA;AACJ,QAAQC,oB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mBT,cAAcO;AAMjC,WAASO,cAAcnB,mBAAsB;AAC3C,QAAMU,UAAUd,qBAAqBI,iBAAAA,GAE/BoB,WAAWjC,MAAMkC,YAAY,WAAA;AACjC,UAAI,CAACrC;AACH,eAAO,CAAA;AAGT,UAAMsC,iBAAiBZ,QAAQpB,cAAcC;AAC7C,UAAI,CAAC+B;AAAgB,eAAO,CAAA;AAC5B,UAAMC,eAAeC,MAAMC,KACzBH,eAAeI,iBAAkB,IAAkB,OAAfb,gBAAe,GAAA,CAAA,CAAA,GAE/Cc,QAAQH,MAAMC,KAAKf,QAAQlB,QAAQoC,OAAM,CAAA,GACzCC,eAAeF,MAAMG,KACzB,SAACC,GAAGC,GAAAA;eACFT,aAAaU,QAAQF,EAAE7B,IAAIX,OAAO,IAClCgC,aAAaU,QAAQD,EAAE9B,IAAIX,OAAO;;AAEtC,aAAOsC;IACT,GAAG;MAACnB,QAAQpB;MAAeoB,QAAQlB;KAAQ;AAE3C,WAAO4B;EACT;AAEA,SAAO;IACL;MAAEzB,UAAUG;MAAoBb,MAAMsB;MAAgB2B,UAAUpB;IAAmB;IACnFK;;AAEJ;",
|
|
5
|
+
"names": ["useComposedRefs", "isWeb", "Slot", "createStyledContext", "React", "createCollection", "name", "collectionRef", "current", "itemMap", "Map", "CollectionProviderImpl", "Provider", "useCollectionContext", "useStyledContext", "CollectionProvider", "props", "__scopeCollection", "children", "ref", "useRef", "scope", "displayName", "COLLECTION_SLOT_NAME", "CollectionSlot", "forwardRef", "forwardedRef", "context", "composedRefs", "ITEM_SLOT_NAME", "ITEM_DATA_ATTR", "CollectionItemSlot", "itemData", "useEffect", "set", "delete", "useCollection", "getItems", "useCallback", "collectionNode", "orderedNodes", "Array", "from", "querySelectorAll", "items", "values", "orderedItems", "sort", "a", "b", "indexOf", "ItemSlot"]
|
|
6
6
|
}
|
|
@@ -2,52 +2,105 @@ import { useComposedRefs } from "@tamagui/compose-refs";
|
|
|
2
2
|
import { isWeb } from "@tamagui/constants";
|
|
3
3
|
import { Slot, createStyledContext } from "@tamagui/core";
|
|
4
4
|
import React from "react";
|
|
5
|
-
|
|
5
|
+
function _define_property(obj, key, value) {
|
|
6
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
7
|
+
value,
|
|
8
|
+
enumerable: !0,
|
|
9
|
+
configurable: !0,
|
|
10
|
+
writable: !0
|
|
11
|
+
}) : obj[key] = value, obj;
|
|
12
|
+
}
|
|
13
|
+
function _object_spread(target) {
|
|
14
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys = Object.keys(source);
|
|
16
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
17
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
18
|
+
}))), ownKeys.forEach(function(key) {
|
|
19
|
+
_define_property(target, key, source[key]);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return target;
|
|
23
|
+
}
|
|
24
|
+
function _object_without_properties(source, excluded) {
|
|
25
|
+
if (source == null)
|
|
26
|
+
return {};
|
|
27
|
+
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
28
|
+
if (Object.getOwnPropertySymbols) {
|
|
29
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
30
|
+
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
31
|
+
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
}
|
|
35
|
+
function _object_without_properties_loose(source, excluded) {
|
|
36
|
+
if (source == null)
|
|
37
|
+
return {};
|
|
38
|
+
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
39
|
+
for (i = 0; i < sourceKeys.length; i++)
|
|
40
|
+
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
6
43
|
function createCollection(name) {
|
|
7
|
-
|
|
8
|
-
collectionRef: {
|
|
44
|
+
var _createStyledContext = createStyledContext({
|
|
45
|
+
collectionRef: {
|
|
46
|
+
current: null
|
|
47
|
+
},
|
|
9
48
|
itemMap: /* @__PURE__ */ new Map()
|
|
10
|
-
}), CollectionProvider = (props)
|
|
11
|
-
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
collectionRef: ref,
|
|
18
|
-
children
|
|
19
|
-
}
|
|
20
|
-
);
|
|
49
|
+
}), CollectionProviderImpl = _createStyledContext.Provider, useCollectionContext = _createStyledContext.useStyledContext, CollectionProvider = function(props) {
|
|
50
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, ref = React.useRef(null), itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
51
|
+
return /* @__PURE__ */ React.createElement(CollectionProviderImpl, {
|
|
52
|
+
scope: __scopeCollection,
|
|
53
|
+
itemMap,
|
|
54
|
+
collectionRef: ref
|
|
55
|
+
}, children);
|
|
21
56
|
};
|
|
22
57
|
CollectionProvider.displayName = "CollectionProvider";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return /* @__PURE__ */
|
|
58
|
+
var COLLECTION_SLOT_NAME = name + "CollectionSlot", CollectionSlot = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
59
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, context = useCollectionContext(__scopeCollection), composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
60
|
+
return /* @__PURE__ */ React.createElement(Slot, {
|
|
61
|
+
ref: composedRefs
|
|
62
|
+
}, children);
|
|
26
63
|
});
|
|
27
64
|
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
65
|
+
var ITEM_SLOT_NAME = name + "CollectionItemSlot", ITEM_DATA_ATTR = "data-collection-item", CollectionItemSlot = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
66
|
+
var __scopeCollection = props.__scopeCollection, children = props.children, itemData = _object_without_properties(props, [
|
|
67
|
+
"__scopeCollection",
|
|
68
|
+
"children"
|
|
69
|
+
]), ref = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref), context = useCollectionContext(__scopeCollection);
|
|
70
|
+
React.useEffect(function() {
|
|
71
|
+
return context.itemMap.set(ref, _object_spread({
|
|
72
|
+
ref
|
|
73
|
+
}, itemData)), function() {
|
|
74
|
+
return void context.itemMap.delete(ref);
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
var _obj;
|
|
78
|
+
return /* @__PURE__ */ React.createElement(Slot, (_obj = {}, _define_property(_obj, ITEM_DATA_ATTR, ""), _define_property(_obj, "ref", composedRefs), _obj), children);
|
|
31
79
|
});
|
|
32
80
|
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
33
81
|
function useCollection(__scopeCollection) {
|
|
34
|
-
|
|
35
|
-
return React.useCallback(() => {
|
|
82
|
+
var context = useCollectionContext(__scopeCollection), getItems = React.useCallback(function() {
|
|
36
83
|
if (!isWeb)
|
|
37
84
|
return [];
|
|
38
|
-
|
|
85
|
+
var collectionNode = context.collectionRef.current;
|
|
39
86
|
if (!collectionNode)
|
|
40
87
|
return [];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
88
|
+
var orderedNodes = Array.from(collectionNode.querySelectorAll("[".concat(ITEM_DATA_ATTR, "]"))), items = Array.from(context.itemMap.values()), orderedItems = items.sort(function(a, b) {
|
|
89
|
+
return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);
|
|
90
|
+
});
|
|
91
|
+
return orderedItems;
|
|
92
|
+
}, [
|
|
93
|
+
context.collectionRef,
|
|
94
|
+
context.itemMap
|
|
95
|
+
]);
|
|
96
|
+
return getItems;
|
|
48
97
|
}
|
|
49
98
|
return [
|
|
50
|
-
{
|
|
99
|
+
{
|
|
100
|
+
Provider: CollectionProvider,
|
|
101
|
+
Slot: CollectionSlot,
|
|
102
|
+
ItemSlot: CollectionItemSlot
|
|
103
|
+
},
|
|
51
104
|
useCollection
|
|
52
105
|
];
|
|
53
106
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/Collection.tsx"],
|
|
4
|
-
"mappings": "AAAA,
|
|
5
|
-
"names": []
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/packages/collection/src/Collection.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AAEtB,SAASC,MAAMC,2BAA2B;AAC1C,OAAOC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWlB,SAASC,iBACPC,MAAY;AAoBZ,MACEH,uBAAAA,oBAAkC;IAChCI,eAAe;MAAEC,SAAS;IAAK;IAC/BC,SAAS,oBAAIC,IAAAA;EACf,CAAA,GAJgBC,yBAChBR,qBADMS,UAAoDC,uBAC1DV,qBADwCW,kBAMpCC,qBAGD,SAACC,OAAAA;AACJ,QAAQC,oBAAgCD,MAAhCC,mBAAmBC,WAAaF,MAAbE,UACrBC,MAAMf,MAAMgB,OAA0B,IAAA,GACtCX,UAAUL,MAAMgB,OAAgC,oBAAIV,IAAAA,CAAAA,EAAOF;AACjE,WACE,sBAAA,cAACG,wBAAAA;MACCU,OAAOJ;MACPR;MACAF,eAAeY;OAEdD,QAAAA;EAGP;AAEAH,qBAAmBO,cAAc;AAMjC,MAAMC,uBAAuBjB,OAAO,kBAE9BkB,iBAAiBpB,sBAAMqB,WAG3B,SAACT,OAAOU,cAAAA;AACR,QAAQT,oBAAgCD,MAAhCC,mBAAmBC,WAAaF,MAAbE,UACrBS,UAAUd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,MAAMG,KACzB,SAACC,GAAGC,GAAAA;eACFT,aAAaU,QAAQF,EAAE7B,IAAIX,OAAO,IAClCgC,aAAaU,QAAQD,EAAE9B,IAAIX,OAAO;;AAEtC,aAAOsC;IACT,GAAG;MAACnB,QAAQpB;MAAeoB,QAAQlB;KAAQ;AAE3C,WAAO4B;EACT;AAEA,SAAO;IACL;MAAEzB,UAAUG;MAAoBb,MAAMsB;MAAgB2B,UAAUpB;IAAmB;IACnFK;;AAEJ;",
|
|
5
|
+
"names": ["useComposedRefs", "isWeb", "Slot", "createStyledContext", "React", "createCollection", "name", "collectionRef", "current", "itemMap", "Map", "CollectionProviderImpl", "Provider", "useCollectionContext", "useStyledContext", "CollectionProvider", "props", "__scopeCollection", "children", "ref", "useRef", "scope", "displayName", "COLLECTION_SLOT_NAME", "CollectionSlot", "forwardRef", "forwardedRef", "context", "composedRefs", "ITEM_SLOT_NAME", "ITEM_DATA_ATTR", "CollectionItemSlot", "itemData", "useEffect", "set", "delete", "useCollection", "getItems", "useCallback", "collectionNode", "orderedNodes", "Array", "from", "querySelectorAll", "items", "values", "orderedItems", "sort", "a", "b", "indexOf", "ItemSlot"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/collection",
|
|
3
|
-
"version": "1.89.
|
|
3
|
+
"version": "1.89.27-1708113113238",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tamagui/compose-refs": "1.89.
|
|
36
|
-
"@tamagui/constants": "1.89.
|
|
37
|
-
"@tamagui/core": "1.89.
|
|
38
|
-
"@tamagui/create-context": "1.89.
|
|
39
|
-
"@tamagui/polyfill-dev": "1.89.
|
|
40
|
-
"@tamagui/stacks": "1.89.
|
|
41
|
-
"@tamagui/use-controllable-state": "1.89.
|
|
35
|
+
"@tamagui/compose-refs": "1.89.27-1708113113238",
|
|
36
|
+
"@tamagui/constants": "1.89.27-1708113113238",
|
|
37
|
+
"@tamagui/core": "1.89.27-1708113113238",
|
|
38
|
+
"@tamagui/create-context": "1.89.27-1708113113238",
|
|
39
|
+
"@tamagui/polyfill-dev": "1.89.27-1708113113238",
|
|
40
|
+
"@tamagui/stacks": "1.89.27-1708113113238",
|
|
41
|
+
"@tamagui/use-controllable-state": "1.89.27-1708113113238"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": "*"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tamagui/build": "1.89.
|
|
47
|
+
"@tamagui/build": "1.89.27-1708113113238",
|
|
48
48
|
"react": "^18.2.0"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|