@tamagui/collection 2.7.7 → 3.0.0-beta.643.1
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.cjs +88 -112
- package/dist/cjs/Collection.native.cjs +112 -0
- package/dist/cjs/Collection.native.js +92 -113
- package/dist/cjs/Collection.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Collection.mjs +71 -86
- package/dist/esm/Collection.mjs.map +1 -1
- package/dist/esm/Collection.native.js +76 -89
- package/dist/esm/Collection.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/dist/jsx/Collection.mjs +71 -86
- package/dist/jsx/Collection.mjs.map +1 -1
- package/dist/jsx/Collection.native.cjs +112 -0
- package/dist/jsx/Collection.native.js +92 -113
- package/dist/jsx/Collection.native.js.map +1 -1
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.native.cjs +21 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +9 -9
- package/src/Collection.tsx +3 -2
- package/types/Collection.d.ts +4 -4
- package/types/Collection.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
package/dist/jsx/Collection.mjs
CHANGED
|
@@ -1,94 +1,79 @@
|
|
|
1
|
+
import { Slot, createRefComponent, createStyledContext } from "@tamagui/core";
|
|
1
2
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
2
3
|
import { isWeb } from "@tamagui/constants";
|
|
3
|
-
import { Slot, createStyledContext } from "@tamagui/core";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
6
7
|
function createCollection(name) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!isWeb) {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
const collectionNode = context.collectionRef.current;
|
|
79
|
-
if (!collectionNode) return [];
|
|
80
|
-
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
81
|
-
const items = Array.from(context.itemMap.values());
|
|
82
|
-
const orderedItems = items.sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));
|
|
83
|
-
return orderedItems;
|
|
84
|
-
}, [context.collectionRef, context.itemMap]);
|
|
85
|
-
return getItems;
|
|
86
|
-
}
|
|
87
|
-
return [{
|
|
88
|
-
Provider: CollectionProvider,
|
|
89
|
-
Slot: CollectionSlot,
|
|
90
|
-
ItemSlot: CollectionItemSlot
|
|
91
|
-
}, useCollection];
|
|
8
|
+
const { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = createStyledContext({
|
|
9
|
+
collectionRef: { current: void 0 },
|
|
10
|
+
itemMap: /* @__PURE__ */ new Map()
|
|
11
|
+
}, "Toast");
|
|
12
|
+
const CollectionProvider = (props) => {
|
|
13
|
+
const { scope, children } = props;
|
|
14
|
+
const ref = React.useRef(void 0);
|
|
15
|
+
const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
16
|
+
return /* @__PURE__ */ jsx(CollectionProviderImpl, {
|
|
17
|
+
scope,
|
|
18
|
+
itemMap,
|
|
19
|
+
collectionRef: ref,
|
|
20
|
+
children
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
CollectionProvider.displayName = "CollectionProvider";
|
|
24
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
25
|
+
const CollectionSlot = createRefComponent((props, forwardedRef) => {
|
|
26
|
+
const { scope, children } = props;
|
|
27
|
+
const context = useCollectionContext(scope);
|
|
28
|
+
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
29
|
+
return /* @__PURE__ */ jsx(Slot, {
|
|
30
|
+
ref: composedRefs,
|
|
31
|
+
children
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
35
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
36
|
+
const ITEM_DATA_ATTR = "data-collection-item";
|
|
37
|
+
const CollectionItemSlot = createRefComponent((props, forwardedRef) => {
|
|
38
|
+
const { scope, children, ...itemData } = props;
|
|
39
|
+
const ref = React.useRef(void 0);
|
|
40
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
41
|
+
const context = useCollectionContext(scope);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
context.itemMap.set(ref, {
|
|
44
|
+
ref,
|
|
45
|
+
...itemData
|
|
46
|
+
});
|
|
47
|
+
return () => void context.itemMap.delete(ref);
|
|
48
|
+
});
|
|
49
|
+
return /* @__PURE__ */ jsx(Slot, {
|
|
50
|
+
...{ [ITEM_DATA_ATTR]: "" },
|
|
51
|
+
ref: composedRefs,
|
|
52
|
+
children
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
56
|
+
function useCollection(scope) {
|
|
57
|
+
const context = useCollectionContext(scope);
|
|
58
|
+
const getItems = React.useCallback(() => {
|
|
59
|
+
if (!isWeb) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const collectionNode = context.collectionRef.current;
|
|
63
|
+
if (!collectionNode) return [];
|
|
64
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
65
|
+
const items = Array.from(context.itemMap.values());
|
|
66
|
+
const orderedItems = items.sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));
|
|
67
|
+
return orderedItems;
|
|
68
|
+
}, [context.collectionRef, context.itemMap]);
|
|
69
|
+
return getItems;
|
|
70
|
+
}
|
|
71
|
+
return [{
|
|
72
|
+
Provider: CollectionProvider,
|
|
73
|
+
Slot: CollectionSlot,
|
|
74
|
+
ItemSlot: CollectionItemSlot
|
|
75
|
+
}, useCollection];
|
|
92
76
|
}
|
|
77
|
+
|
|
93
78
|
export { createCollection };
|
|
94
79
|
//# sourceMappingURL=Collection.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Collection.js","names":[],"sources":["jsx/Collection.js"],"sourcesContent":["import { createRefComponent } from \"@tamagui/core\";\nimport { useComposedRefs } from \"@tamagui/compose-refs\";\nimport { isWeb } from \"@tamagui/constants\";\nimport { Slot, createStyledContext } from \"@tamagui/core\";\nimport React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction createCollection(name) {\n const { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = createStyledContext(\n {\n collectionRef: { current: void 0 },\n itemMap: /* @__PURE__ */ new Map()\n },\n \"Toast\"\n );\n const CollectionProvider = (props) => {\n const { scope, children } = props;\n const ref = React.useRef(void 0);\n const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;\n return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });\n };\n CollectionProvider.displayName = \"CollectionProvider\";\n const COLLECTION_SLOT_NAME = name + \"CollectionSlot\";\n const CollectionSlot = createRefComponent((props, forwardedRef) => {\n const { scope, children } = props;\n const context = useCollectionContext(scope);\n const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);\n return /* @__PURE__ */ jsx(Slot, { ref: composedRefs, children });\n });\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n const ITEM_SLOT_NAME = name + \"CollectionItemSlot\";\n const ITEM_DATA_ATTR = \"data-collection-item\";\n const CollectionItemSlot = createRefComponent((props, forwardedRef) => {\n const { scope, children, ...itemData } = props;\n const ref = React.useRef(void 0);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const context = useCollectionContext(scope);\n React.useEffect(() => {\n context.itemMap.set(ref, { ref, ...itemData });\n return () => void context.itemMap.delete(ref);\n });\n return /* @__PURE__ */ jsx(Slot, { ...{ [ITEM_DATA_ATTR]: \"\" }, ref: composedRefs, children });\n });\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n function useCollection(scope) {\n const context = useCollectionContext(scope);\n const getItems = React.useCallback(() => {\n if (!isWeb) {\n return [];\n }\n const collectionNode = context.collectionRef.current;\n if (!collectionNode) return [];\n const orderedNodes = Array.from(\n collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`)\n );\n const items = Array.from(context.itemMap.values());\n const orderedItems = items.sort(\n (a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)\n );\n return orderedItems;\n }, [context.collectionRef, context.itemMap]);\n return getItems;\n }\n return [\n { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n useCollection\n ];\n}\nexport {\n createCollection\n};\n//# sourceMappingURL=Collection.js.map\n"],"mappings":";;;;;;;AAMA,SAAS,iBAAiB,MAAM;CAC9B,MAAM,EAAE,UAAU,wBAAwB,kBAAkB,yBAAyB,oBACnF;EACE,eAAe,EAAE,SAAS,KAAK,EAAE;EACjC,yBAAyB,IAAI,IAAI;CACnC,GACA,OACF;CACA,MAAM,sBAAsB,UAAU;EACpC,MAAM,EAAE,OAAO,aAAa;EAC5B,MAAM,MAAM,MAAM,OAAO,KAAK,CAAC;EAC/B,MAAM,UAAU,MAAM,uBAAuB,IAAI,IAAI,CAAC,EAAE;EACxD,OAAuB,oBAAI,wBAAwB;GAAE;GAAO;GAAS,eAAe;GAAK;EAAS,CAAC;CACrG;CACA,mBAAmB,cAAc;CACjC,MAAM,uBAAuB,OAAO;CACpC,MAAM,iBAAiB,oBAAoB,OAAO,iBAAiB;EACjE,MAAM,EAAE,OAAO,aAAa;EAC5B,MAAM,UAAU,qBAAqB,KAAK;EAC1C,MAAM,eAAe,gBAAgB,cAAc,QAAQ,aAAa;EACxE,OAAuB,oBAAI,MAAM;GAAE,KAAK;GAAc;EAAS,CAAC;CAClE,CAAC;CACD,eAAe,cAAc;CAC7B,MAAM,iBAAiB,OAAO;CAC9B,MAAM,iBAAiB;CACvB,MAAM,qBAAqB,oBAAoB,OAAO,iBAAiB;EACrE,MAAM,EAAE,OAAO,UAAU,GAAG,aAAa;EACzC,MAAM,MAAM,MAAM,OAAO,KAAK,CAAC;EAC/B,MAAM,eAAe,gBAAgB,cAAc,GAAG;EACtD,MAAM,UAAU,qBAAqB,KAAK;EAC1C,MAAM,gBAAgB;GACpB,QAAQ,QAAQ,IAAI,KAAK;IAAE;IAAK,GAAG;GAAS,CAAC;GAC7C,aAAa,KAAK,QAAQ,QAAQ,OAAO,GAAG;EAC9C,CAAC;EACD,OAAuB,oBAAI,MAAM;GAAE,GAAG,GAAG,iBAAiB,GAAG;GAAG,KAAK;GAAc;EAAS,CAAC;CAC/F,CAAC;CACD,mBAAmB,cAAc;CACjC,SAAS,cAAc,OAAO;EAC5B,MAAM,UAAU,qBAAqB,KAAK;EAC1C,MAAM,WAAW,MAAM,kBAAkB;GACvC,IAAI,CAAC,OAAO;IACV,OAAO,CAAC;GACV;GACA,MAAM,iBAAiB,QAAQ,cAAc;GAC7C,IAAI,CAAC,gBAAgB,OAAO,CAAC;GAC7B,MAAM,eAAe,MAAM,KACzB,eAAe,iBAAiB,IAAI,eAAe,EAAE,CACvD;GACA,MAAM,QAAQ,MAAM,KAAK,QAAQ,QAAQ,OAAO,CAAC;GACjD,MAAM,eAAe,MAAM,MACxB,GAAG,MAAM,aAAa,QAAQ,EAAE,IAAI,OAAO,IAAI,aAAa,QAAQ,EAAE,IAAI,OAAO,CACpF;GACA,OAAO;EACT,GAAG,CAAC,QAAQ,eAAe,QAAQ,OAAO,CAAC;EAC3C,OAAO;CACT;CACA,OAAO,CACL;EAAE,UAAU;EAAoB,MAAM;EAAgB,UAAU;CAAmB,GACnF,aACF;AACF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var Collection_exports = {};
|
|
31
|
+
__export(Collection_exports, { createCollection: () => createCollection });
|
|
32
|
+
module.exports = __toCommonJS(Collection_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_core = require("@tamagui/core");
|
|
35
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
36
|
+
var import_constants = require("@tamagui/constants");
|
|
37
|
+
var import_core2 = require("@tamagui/core");
|
|
38
|
+
var import_react = __toESM(require("react"), 1);
|
|
39
|
+
function createCollection(name) {
|
|
40
|
+
var { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = (0, import_core2.createStyledContext)({
|
|
41
|
+
collectionRef: { current: void 0 },
|
|
42
|
+
itemMap: /* @__PURE__ */ new Map()
|
|
43
|
+
}, "Toast");
|
|
44
|
+
var CollectionProvider = function(props) {
|
|
45
|
+
var { scope, children } = props;
|
|
46
|
+
var ref = import_react.default.useRef(void 0);
|
|
47
|
+
var itemMap = import_react.default.useRef(/* @__PURE__ */ new Map()).current;
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollectionProviderImpl, {
|
|
49
|
+
scope,
|
|
50
|
+
itemMap,
|
|
51
|
+
collectionRef: ref,
|
|
52
|
+
children
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
CollectionProvider.displayName = "CollectionProvider";
|
|
56
|
+
var COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
57
|
+
var CollectionSlot = (0, import_core.createRefComponent)(function(props, forwardedRef) {
|
|
58
|
+
var { scope, children } = props;
|
|
59
|
+
var context = useCollectionContext(scope);
|
|
60
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slot, {
|
|
62
|
+
ref: composedRefs,
|
|
63
|
+
children
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
67
|
+
var ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
68
|
+
var ITEM_DATA_ATTR = "data-collection-item";
|
|
69
|
+
var CollectionItemSlot = (0, import_core.createRefComponent)(function(props, forwardedRef) {
|
|
70
|
+
var { scope, children, ...itemData } = props;
|
|
71
|
+
var ref = import_react.default.useRef(void 0);
|
|
72
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
73
|
+
var context = useCollectionContext(scope);
|
|
74
|
+
import_react.default.useEffect(function() {
|
|
75
|
+
context.itemMap.set(ref, {
|
|
76
|
+
ref,
|
|
77
|
+
...itemData
|
|
78
|
+
});
|
|
79
|
+
return function() {
|
|
80
|
+
return void context.itemMap.delete(ref);
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slot, {
|
|
84
|
+
[ITEM_DATA_ATTR]: "",
|
|
85
|
+
ref: composedRefs,
|
|
86
|
+
children
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
90
|
+
function useCollection(scope) {
|
|
91
|
+
var context = useCollectionContext(scope);
|
|
92
|
+
var getItems = import_react.default.useCallback(function() {
|
|
93
|
+
if (!import_constants.isWeb) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
var collectionNode = context.collectionRef.current;
|
|
97
|
+
if (!collectionNode) return [];
|
|
98
|
+
var orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
99
|
+
var items = Array.from(context.itemMap.values());
|
|
100
|
+
var orderedItems = items.sort(function(a, b) {
|
|
101
|
+
return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);
|
|
102
|
+
});
|
|
103
|
+
return orderedItems;
|
|
104
|
+
}, [context.collectionRef, context.itemMap]);
|
|
105
|
+
return getItems;
|
|
106
|
+
}
|
|
107
|
+
return [{
|
|
108
|
+
Provider: CollectionProvider,
|
|
109
|
+
Slot: CollectionSlot,
|
|
110
|
+
ItemSlot: CollectionItemSlot
|
|
111
|
+
}, useCollection];
|
|
112
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,129 +8,107 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
10
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
14
15
|
};
|
|
15
16
|
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
23
24
|
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
32
28
|
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
}), mod);
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
30
|
var Collection_exports = {};
|
|
37
|
-
__export(Collection_exports, {
|
|
38
|
-
createCollection: () => createCollection
|
|
39
|
-
});
|
|
31
|
+
__export(Collection_exports, { createCollection: () => createCollection });
|
|
40
32
|
module.exports = __toCommonJS(Collection_exports);
|
|
41
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_core = require("@tamagui/core");
|
|
42
35
|
var import_compose_refs = require("@tamagui/compose-refs");
|
|
43
36
|
var import_constants = require("@tamagui/constants");
|
|
44
|
-
var
|
|
37
|
+
var import_core2 = require("@tamagui/core");
|
|
45
38
|
var import_react = __toESM(require("react"), 1);
|
|
46
39
|
function createCollection(name) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!collectionNode) return [];
|
|
120
|
-
var orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
121
|
-
var items = Array.from(context.itemMap.values());
|
|
122
|
-
var orderedItems = items.sort(function (a, b) {
|
|
123
|
-
return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);
|
|
124
|
-
});
|
|
125
|
-
return orderedItems;
|
|
126
|
-
}, [context.collectionRef, context.itemMap]);
|
|
127
|
-
return getItems;
|
|
128
|
-
}
|
|
129
|
-
return [{
|
|
130
|
-
Provider: CollectionProvider,
|
|
131
|
-
Slot: CollectionSlot,
|
|
132
|
-
ItemSlot: CollectionItemSlot
|
|
133
|
-
}, useCollection];
|
|
40
|
+
var { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = (0, import_core2.createStyledContext)({
|
|
41
|
+
collectionRef: { current: void 0 },
|
|
42
|
+
itemMap: /* @__PURE__ */ new Map()
|
|
43
|
+
}, "Toast");
|
|
44
|
+
var CollectionProvider = function(props) {
|
|
45
|
+
var { scope, children } = props;
|
|
46
|
+
var ref = import_react.default.useRef(void 0);
|
|
47
|
+
var itemMap = import_react.default.useRef(/* @__PURE__ */ new Map()).current;
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollectionProviderImpl, {
|
|
49
|
+
scope,
|
|
50
|
+
itemMap,
|
|
51
|
+
collectionRef: ref,
|
|
52
|
+
children
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
CollectionProvider.displayName = "CollectionProvider";
|
|
56
|
+
var COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
57
|
+
var CollectionSlot = (0, import_core.createRefComponent)(function(props, forwardedRef) {
|
|
58
|
+
var { scope, children } = props;
|
|
59
|
+
var context = useCollectionContext(scope);
|
|
60
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slot, {
|
|
62
|
+
ref: composedRefs,
|
|
63
|
+
children
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
67
|
+
var ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
68
|
+
var ITEM_DATA_ATTR = "data-collection-item";
|
|
69
|
+
var CollectionItemSlot = (0, import_core.createRefComponent)(function(props, forwardedRef) {
|
|
70
|
+
var { scope, children, ...itemData } = props;
|
|
71
|
+
var ref = import_react.default.useRef(void 0);
|
|
72
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
73
|
+
var context = useCollectionContext(scope);
|
|
74
|
+
import_react.default.useEffect(function() {
|
|
75
|
+
context.itemMap.set(ref, {
|
|
76
|
+
ref,
|
|
77
|
+
...itemData
|
|
78
|
+
});
|
|
79
|
+
return function() {
|
|
80
|
+
return void context.itemMap.delete(ref);
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slot, {
|
|
84
|
+
[ITEM_DATA_ATTR]: "",
|
|
85
|
+
ref: composedRefs,
|
|
86
|
+
children
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
90
|
+
function useCollection(scope) {
|
|
91
|
+
var context = useCollectionContext(scope);
|
|
92
|
+
var getItems = import_react.default.useCallback(function() {
|
|
93
|
+
if (!import_constants.isWeb) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
var collectionNode = context.collectionRef.current;
|
|
97
|
+
if (!collectionNode) return [];
|
|
98
|
+
var orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
99
|
+
var items = Array.from(context.itemMap.values());
|
|
100
|
+
var orderedItems = items.sort(function(a, b) {
|
|
101
|
+
return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);
|
|
102
|
+
});
|
|
103
|
+
return orderedItems;
|
|
104
|
+
}, [context.collectionRef, context.itemMap]);
|
|
105
|
+
return getItems;
|
|
106
|
+
}
|
|
107
|
+
return [{
|
|
108
|
+
Provider: CollectionProvider,
|
|
109
|
+
Slot: CollectionSlot,
|
|
110
|
+
ItemSlot: CollectionItemSlot
|
|
111
|
+
}, useCollection];
|
|
134
112
|
}
|
|
113
|
+
|
|
135
114
|
//# sourceMappingURL=Collection.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Collection.native.js","names":[],"sources":["jsx/Collection.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar Collection_exports = {};\n__export(Collection_exports, {\n createCollection: () => createCollection\n});\nmodule.exports = __toCommonJS(Collection_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_core = require(\"@tamagui/core\");\nvar import_compose_refs = require(\"@tamagui/compose-refs\");\nvar import_constants = require(\"@tamagui/constants\");\nvar import_core2 = require(\"@tamagui/core\");\nvar import_react = __toESM(require(\"react\"), 1);\nfunction createCollection(name) {\n var { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = (0, import_core2.createStyledContext)({\n collectionRef: {\n current: void 0\n },\n itemMap: /* @__PURE__ */ new Map()\n }, \"Toast\");\n var CollectionProvider = function(props) {\n var { scope, children } = props;\n var ref = import_react.default.useRef(void 0);\n var itemMap = import_react.default.useRef(/* @__PURE__ */ new Map()).current;\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollectionProviderImpl, {\n scope,\n itemMap,\n collectionRef: ref,\n children\n });\n };\n CollectionProvider.displayName = \"CollectionProvider\";\n var COLLECTION_SLOT_NAME = name + \"CollectionSlot\";\n var CollectionSlot = (0, import_core.createRefComponent)(function(props, forwardedRef) {\n var { scope, children } = props;\n var context = useCollectionContext(scope);\n var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slot, {\n ref: composedRefs,\n children\n });\n });\n CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n var ITEM_SLOT_NAME = name + \"CollectionItemSlot\";\n var ITEM_DATA_ATTR = \"data-collection-item\";\n var CollectionItemSlot = (0, import_core.createRefComponent)(function(props, forwardedRef) {\n var { scope, children, ...itemData } = props;\n var ref = import_react.default.useRef(void 0);\n var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);\n var context = useCollectionContext(scope);\n import_react.default.useEffect(function() {\n context.itemMap.set(ref, {\n ref,\n ...itemData\n });\n return function() {\n return void context.itemMap.delete(ref);\n };\n });\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slot, {\n [ITEM_DATA_ATTR]: \"\",\n ref: composedRefs,\n children\n });\n });\n CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n function useCollection(scope) {\n var context = useCollectionContext(scope);\n var getItems = import_react.default.useCallback(function() {\n if (!import_constants.isWeb) {\n return [];\n }\n var collectionNode = context.collectionRef.current;\n if (!collectionNode) return [];\n var orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));\n var items = Array.from(context.itemMap.values());\n var orderedItems = items.sort(function(a, b) {\n return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);\n });\n return orderedItems;\n }, [\n context.collectionRef,\n context.itemMap\n ]);\n return getItems;\n }\n return [\n {\n Provider: CollectionProvider,\n Slot: CollectionSlot,\n ItemSlot: CollectionItemSlot\n },\n useCollection\n ];\n}\n//# sourceMappingURL=Collection.js.map\n"],"mappings":";;;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAA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
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./Collection.mjs"
|
package/dist/jsx/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./Collection.mjs"
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from "./Collection.mjs"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(index_exports);
|
|
21
|
+
__reExport(index_exports, require("./Collection.native.js"), module.exports);
|