@tamagui/collection 1.74.8 → 1.74.9
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/package.json +8 -8
- package/dist/esm/Collection.mjs +0 -54
- package/dist/esm/Collection.mjs.map +0 -6
- package/dist/esm/index.mjs +0 -2
- package/dist/esm/index.mjs.map +0 -6
- package/dist/jsx/Collection.mjs +0 -74
- package/dist/jsx/Collection.mjs.map +0 -6
- package/dist/jsx/index.mjs +0 -2
- package/dist/jsx/index.mjs.map +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/collection",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.9",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/compose-refs": "1.74.
|
|
35
|
-
"@tamagui/core": "1.74.
|
|
36
|
-
"@tamagui/create-context": "1.74.
|
|
37
|
-
"@tamagui/polyfill-dev": "1.74.
|
|
38
|
-
"@tamagui/stacks": "1.74.
|
|
39
|
-
"@tamagui/use-controllable-state": "1.74.
|
|
34
|
+
"@tamagui/compose-refs": "1.74.9",
|
|
35
|
+
"@tamagui/core": "1.74.9",
|
|
36
|
+
"@tamagui/create-context": "1.74.9",
|
|
37
|
+
"@tamagui/polyfill-dev": "1.74.9",
|
|
38
|
+
"@tamagui/stacks": "1.74.9",
|
|
39
|
+
"@tamagui/use-controllable-state": "1.74.9"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": "*"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@tamagui/build": "1.74.
|
|
45
|
+
"@tamagui/build": "1.74.9",
|
|
46
46
|
"react": "^18.2.0"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
package/dist/esm/Collection.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
2
|
-
import { Slot, isWeb } from "@tamagui/core";
|
|
3
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
function createCollection(name) {
|
|
7
|
-
const PROVIDER_NAME = name + "CollectionProvider", [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME), [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
|
|
8
|
-
collectionRef: { current: null },
|
|
9
|
-
itemMap: /* @__PURE__ */ new Map()
|
|
10
|
-
}), CollectionProvider = (props) => {
|
|
11
|
-
const { scope, children } = props, ref = React.useRef(null), itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
12
|
-
return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
13
|
-
};
|
|
14
|
-
CollectionProvider.displayName = PROVIDER_NAME;
|
|
15
|
-
const COLLECTION_SLOT_NAME = name + "CollectionSlot", CollectionSlot = React.forwardRef(
|
|
16
|
-
(props, forwardedRef) => {
|
|
17
|
-
const { scope, children } = props, context = useCollectionContext(COLLECTION_SLOT_NAME, scope), composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
18
|
-
return /* @__PURE__ */ jsx(Slot, { ref: composedRefs, children });
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
22
|
-
const ITEM_SLOT_NAME = name + "CollectionItemSlot", ITEM_DATA_ATTR = "data-collection-item", CollectionItemSlot = React.forwardRef(
|
|
23
|
-
(props, forwardedRef) => {
|
|
24
|
-
const { scope, children, ...itemData } = props, ref = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref), context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
25
|
-
return React.useEffect(() => (context.itemMap.set(ref, { ref, ...itemData }), () => void context.itemMap.delete(ref))), /* @__PURE__ */ jsx(Slot, { [ITEM_DATA_ATTR]: "", ref: composedRefs, children });
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
29
|
-
function useCollection(scope) {
|
|
30
|
-
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
31
|
-
return React.useCallback(() => {
|
|
32
|
-
if (!isWeb)
|
|
33
|
-
return [];
|
|
34
|
-
const collectionNode = context.collectionRef.current;
|
|
35
|
-
if (!collectionNode)
|
|
36
|
-
return [];
|
|
37
|
-
const orderedNodes = Array.from(
|
|
38
|
-
collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`)
|
|
39
|
-
);
|
|
40
|
-
return Array.from(context.itemMap.values()).sort(
|
|
41
|
-
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
42
|
-
);
|
|
43
|
-
}, [context.collectionRef, context.itemMap]);
|
|
44
|
-
}
|
|
45
|
-
return [
|
|
46
|
-
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
47
|
-
useCollection,
|
|
48
|
-
createCollectionScope
|
|
49
|
-
];
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
createCollection
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=Collection.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Collection.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,MAAsB,aAAa;AAC5C,SAAS,0BAA0B;AACnC,OAAO,WAAW;AA6CZ;AAhCN,SAAS,iBACP,MACA;AAKA,QAAM,gBAAgB,OAAO,sBACvB,CAAC,yBAAyB,qBAAqB,IACnD,mBAA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WAnBiB,MAAM,YAAY,MAAM;AACvC,UAAI,CAAC;AACH,eAAO,CAAC;AAGV,YAAM,iBAAiB,QAAQ,cAAc;AAC7C,UAAI,CAAC;AAAgB,eAAO,CAAC;AAC7B,YAAM,eAAe,MAAM;AAAA,QACzB,eAAe,iBAAiB,IAAI,cAAc,GAAG;AAAA,MACvD;AAOA,aANc,MAAM,KAAK,QAAQ,QAAQ,OAAO,CAAC,EACtB;AAAA,QACzB,CAAC,GAAG,MACF,aAAa,QAAQ,EAAE,IAAI,OAAuB,IAClD,aAAa,QAAQ,EAAE,IAAI,OAAuB;AAAA,MACtD;AAAA,IAEF,GAAG,CAAC,QAAQ,eAAe,QAAQ,OAAO,CAAC;AAAA,EAG7C;AAEA,SAAO;AAAA,IACL,EAAE,UAAU,oBAAoB,MAAM,gBAAgB,UAAU,mBAAmB;AAAA,IACnF;AAAA,IACA;AAAA,EACF;AACF;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/index.mjs
DELETED
package/dist/esm/index.mjs.map
DELETED
package/dist/jsx/Collection.mjs
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
2
|
-
import { Slot, isWeb } from "@tamagui/core";
|
|
3
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
4
|
-
import React from "react";
|
|
5
|
-
function createCollection(name) {
|
|
6
|
-
const PROVIDER_NAME = name + "CollectionProvider";
|
|
7
|
-
const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
|
|
8
|
-
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
|
|
9
|
-
collectionRef: { current: null },
|
|
10
|
-
itemMap: /* @__PURE__ */ new Map()
|
|
11
|
-
});
|
|
12
|
-
const CollectionProvider = (props) => {
|
|
13
|
-
const { scope, children } = props;
|
|
14
|
-
const ref = React.useRef(null);
|
|
15
|
-
const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
16
|
-
return <CollectionProviderImpl scope={scope} itemMap={itemMap} collectionRef={ref}>{children}</CollectionProviderImpl>;
|
|
17
|
-
};
|
|
18
|
-
CollectionProvider.displayName = PROVIDER_NAME;
|
|
19
|
-
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
20
|
-
const CollectionSlot = React.forwardRef(
|
|
21
|
-
(props, forwardedRef) => {
|
|
22
|
-
const { scope, children } = props;
|
|
23
|
-
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
24
|
-
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
25
|
-
return <Slot ref={composedRefs}>{children}</Slot>;
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
29
|
-
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
30
|
-
const ITEM_DATA_ATTR = "data-collection-item";
|
|
31
|
-
const CollectionItemSlot = React.forwardRef(
|
|
32
|
-
(props, forwardedRef) => {
|
|
33
|
-
const { scope, children, ...itemData } = props;
|
|
34
|
-
const ref = React.useRef(null);
|
|
35
|
-
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
36
|
-
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
37
|
-
React.useEffect(() => {
|
|
38
|
-
context.itemMap.set(ref, { ref, ...itemData });
|
|
39
|
-
return () => void context.itemMap.delete(ref);
|
|
40
|
-
});
|
|
41
|
-
return <Slot {...{ [ITEM_DATA_ATTR]: "" }} ref={composedRefs}>{children}</Slot>;
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
45
|
-
function useCollection(scope) {
|
|
46
|
-
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
47
|
-
const getItems = React.useCallback(() => {
|
|
48
|
-
if (!isWeb) {
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
const collectionNode = context.collectionRef.current;
|
|
52
|
-
if (!collectionNode)
|
|
53
|
-
return [];
|
|
54
|
-
const orderedNodes = Array.from(
|
|
55
|
-
collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`)
|
|
56
|
-
);
|
|
57
|
-
const items = Array.from(context.itemMap.values());
|
|
58
|
-
const orderedItems = items.sort(
|
|
59
|
-
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
60
|
-
);
|
|
61
|
-
return orderedItems;
|
|
62
|
-
}, [context.collectionRef, context.itemMap]);
|
|
63
|
-
return getItems;
|
|
64
|
-
}
|
|
65
|
-
return [
|
|
66
|
-
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
67
|
-
useCollection,
|
|
68
|
-
createCollectionScope
|
|
69
|
-
];
|
|
70
|
-
}
|
|
71
|
-
export {
|
|
72
|
-
createCollection
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=Collection.mjs.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Collection.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,MAAsB,aAAa;AAC5C,SAAS,0BAA0B;AACnC,OAAO,WAAW;AAalB,SAAS,iBACP,MACA;AAKA,QAAM,gBAAgB,OAAO;AAC7B,QAAM,CAAC,yBAAyB,qBAAqB,IACnD,mBAAmB,aAAa;AAUlC,QAAM,CAAC,wBAAwB,oBAAoB,IACjD,wBAAsC,eAAe;AAAA,IACnD,eAAe,EAAE,SAAS,KAAK;AAAA,IAC/B,SAAS,oBAAI,IAAI;AAAA,EACnB,CAAC;AAEH,QAAM,qBAA2E,CAC/E,UACG;AACH,UAAM,EAAE,OAAO,SAAS,IAAI;AAC5B,UAAM,MAAM,MAAM,OAA0B,IAAI;AAChD,UAAM,UAAU,MAAM,OAAgC,oBAAI,IAAI,CAAC,EAAE;AACjE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