@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.
@@ -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);
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") {
9
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
- get: () => from[key],
11
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
- });
13
- }
14
- return to;
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;
15
16
  };
16
17
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
- value: true
19
- }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var index_exports = {};
21
20
  module.exports = __toCommonJS(index_exports);
22
21
  __reExport(index_exports, require("./Collection.native.js"), module.exports);
22
+
23
23
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./Collection\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,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,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,wBAAc,GAAG,OAAO,OAAO"}
@@ -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
- const {
8
- Provider: CollectionProviderImpl,
9
- useStyledContext: useCollectionContext
10
- } = createStyledContext({
11
- collectionRef: {
12
- current: void 0
13
- },
14
- itemMap: /* @__PURE__ */new Map()
15
- }, "Toast");
16
- const CollectionProvider = props => {
17
- const {
18
- scope,
19
- children
20
- } = props;
21
- const ref = React.useRef(void 0);
22
- const itemMap = React.useRef(/* @__PURE__ */new Map()).current;
23
- return /* @__PURE__ */jsx(CollectionProviderImpl, {
24
- scope,
25
- itemMap,
26
- collectionRef: ref,
27
- children
28
- });
29
- };
30
- CollectionProvider.displayName = "CollectionProvider";
31
- const COLLECTION_SLOT_NAME = name + "CollectionSlot";
32
- const CollectionSlot = React.forwardRef((props, forwardedRef) => {
33
- const {
34
- scope,
35
- children
36
- } = props;
37
- const context = useCollectionContext(scope);
38
- const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
39
- return /* @__PURE__ */jsx(Slot, {
40
- ref: composedRefs,
41
- children
42
- });
43
- });
44
- CollectionSlot.displayName = COLLECTION_SLOT_NAME;
45
- const ITEM_SLOT_NAME = name + "CollectionItemSlot";
46
- const ITEM_DATA_ATTR = "data-collection-item";
47
- const CollectionItemSlot = React.forwardRef((props, forwardedRef) => {
48
- const {
49
- scope,
50
- children,
51
- ...itemData
52
- } = props;
53
- const ref = React.useRef(void 0);
54
- const composedRefs = useComposedRefs(forwardedRef, ref);
55
- const context = useCollectionContext(scope);
56
- React.useEffect(() => {
57
- context.itemMap.set(ref, {
58
- ref,
59
- ...itemData
60
- });
61
- return () => void context.itemMap.delete(ref);
62
- });
63
- return /* @__PURE__ */jsx(Slot, {
64
- ...{
65
- [ITEM_DATA_ATTR]: ""
66
- },
67
- ref: composedRefs,
68
- children
69
- });
70
- });
71
- CollectionItemSlot.displayName = ITEM_SLOT_NAME;
72
- function useCollection(scope) {
73
- const context = useCollectionContext(scope);
74
- const getItems = React.useCallback(() => {
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,"names":["useComposedRefs","isWeb","Slot","createStyledContext","React","jsx","createCollection","name","Provider","CollectionProviderImpl","useStyledContext","useCollectionContext","collectionRef","current","itemMap","Map","CollectionProvider","props","scope","children","ref","useRef","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"],"sources":["../../src/Collection.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAA,QAAuB;AAChC,SAASC,KAAA,QAAa;AAEtB,SAASC,IAAA,EAAMC,mBAAA,QAA2B;AAC1C,OAAOC,KAAA,MAAW;AAkDZ,SAAAC,GAAA;AAvCN,SAASC,iBACPC,IAAA,EACA;EAmBA,MAAM;IAAEC,QAAA,EAAUC,sBAAA;IAAwBC,gBAAA,EAAkBC;EAAqB,IAC/ER,mBAAA,CACE;I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E7B,GAAA,CAAIP,OAAuB,CACtD;MACA,OAAOiC,YAAA;IACT,GAAG,CAACnB,OAAA,CAAQf,aAAA,EAAee,OAAA,CAAQb,OAAO,CAAC;IAE3C,OAAOuB,QAAA;EACT;EAEA,OAAO,CACL;IAAE7B,QAAA,EAAUQ,kBAAA;IAAoBd,IAAA,EAAMsB,cAAA;IAAgB2B,QAAA,EAAUpB;EAAmB,GACnFK,aAAA,CACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"Collection.js","names":[],"sources":["esm/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,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"}
@@ -1,96 +1,83 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Slot, createRefComponent, createStyledContext } from "@tamagui/core";
2
3
  import { useComposedRefs } from "@tamagui/compose-refs";
3
4
  import { isWeb } from "@tamagui/constants";
4
- import { Slot, createStyledContext } from "@tamagui/core";
5
5
  import React from "react";
6
+
6
7
  function createCollection(name) {
7
- var {
8
- Provider: CollectionProviderImpl,
9
- useStyledContext: useCollectionContext
10
- } = createStyledContext({
11
- collectionRef: {
12
- current: void 0
13
- },
14
- itemMap: /* @__PURE__ */new Map()
15
- }, "Toast");
16
- var CollectionProvider = function (props) {
17
- var {
18
- scope,
19
- children
20
- } = props;
21
- var ref = React.useRef(void 0);
22
- var itemMap = React.useRef(/* @__PURE__ */new Map()).current;
23
- return /* @__PURE__ */_jsx(CollectionProviderImpl, {
24
- scope,
25
- itemMap,
26
- collectionRef: ref,
27
- children
28
- });
29
- };
30
- CollectionProvider.displayName = "CollectionProvider";
31
- var COLLECTION_SLOT_NAME = name + "CollectionSlot";
32
- var CollectionSlot = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
33
- var {
34
- scope,
35
- children
36
- } = props;
37
- var context = useCollectionContext(scope);
38
- var composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
39
- return /* @__PURE__ */_jsx(Slot, {
40
- ref: composedRefs,
41
- children
42
- });
43
- });
44
- CollectionSlot.displayName = COLLECTION_SLOT_NAME;
45
- var ITEM_SLOT_NAME = name + "CollectionItemSlot";
46
- var ITEM_DATA_ATTR = "data-collection-item";
47
- var CollectionItemSlot = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
48
- var {
49
- scope,
50
- children,
51
- ...itemData
52
- } = props;
53
- var ref = React.useRef(void 0);
54
- var composedRefs = useComposedRefs(forwardedRef, ref);
55
- var context = useCollectionContext(scope);
56
- React.useEffect(function () {
57
- context.itemMap.set(ref, {
58
- ref,
59
- ...itemData
60
- });
61
- return function () {
62
- return void context.itemMap.delete(ref);
63
- };
64
- });
65
- return /* @__PURE__ */_jsx(Slot, {
66
- [ITEM_DATA_ATTR]: "",
67
- ref: composedRefs,
68
- children
69
- });
70
- });
71
- CollectionItemSlot.displayName = ITEM_SLOT_NAME;
72
- function useCollection(scope) {
73
- var context = useCollectionContext(scope);
74
- var getItems = React.useCallback(function () {
75
- if (!isWeb) {
76
- return [];
77
- }
78
- var collectionNode = context.collectionRef.current;
79
- if (!collectionNode) return [];
80
- var orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
81
- var items = Array.from(context.itemMap.values());
82
- var orderedItems = items.sort(function (a, b) {
83
- return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);
84
- });
85
- return orderedItems;
86
- }, [context.collectionRef, context.itemMap]);
87
- return getItems;
88
- }
89
- return [{
90
- Provider: CollectionProvider,
91
- Slot: CollectionSlot,
92
- ItemSlot: CollectionItemSlot
93
- }, useCollection];
8
+ var { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = createStyledContext({
9
+ collectionRef: { current: void 0 },
10
+ itemMap: /* @__PURE__ */ new Map()
11
+ }, "Toast");
12
+ var CollectionProvider = function(props) {
13
+ var { scope, children } = props;
14
+ var ref = React.useRef(void 0);
15
+ var 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
+ var COLLECTION_SLOT_NAME = name + "CollectionSlot";
25
+ var CollectionSlot = createRefComponent(function(props, forwardedRef) {
26
+ var { scope, children } = props;
27
+ var context = useCollectionContext(scope);
28
+ var composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
29
+ return /* @__PURE__ */ jsx(Slot, {
30
+ ref: composedRefs,
31
+ children
32
+ });
33
+ });
34
+ CollectionSlot.displayName = COLLECTION_SLOT_NAME;
35
+ var ITEM_SLOT_NAME = name + "CollectionItemSlot";
36
+ var ITEM_DATA_ATTR = "data-collection-item";
37
+ var CollectionItemSlot = createRefComponent(function(props, forwardedRef) {
38
+ var { scope, children, ...itemData } = props;
39
+ var ref = React.useRef(void 0);
40
+ var composedRefs = useComposedRefs(forwardedRef, ref);
41
+ var context = useCollectionContext(scope);
42
+ React.useEffect(function() {
43
+ context.itemMap.set(ref, {
44
+ ref,
45
+ ...itemData
46
+ });
47
+ return function() {
48
+ return void context.itemMap.delete(ref);
49
+ };
50
+ });
51
+ return /* @__PURE__ */ jsx(Slot, {
52
+ [ITEM_DATA_ATTR]: "",
53
+ ref: composedRefs,
54
+ children
55
+ });
56
+ });
57
+ CollectionItemSlot.displayName = ITEM_SLOT_NAME;
58
+ function useCollection(scope) {
59
+ var context = useCollectionContext(scope);
60
+ var getItems = React.useCallback(function() {
61
+ if (!isWeb) {
62
+ return [];
63
+ }
64
+ var collectionNode = context.collectionRef.current;
65
+ if (!collectionNode) return [];
66
+ var orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
67
+ var items = Array.from(context.itemMap.values());
68
+ var orderedItems = items.sort(function(a, b) {
69
+ return orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current);
70
+ });
71
+ return orderedItems;
72
+ }, [context.collectionRef, context.itemMap]);
73
+ return getItems;
74
+ }
75
+ return [{
76
+ Provider: CollectionProvider,
77
+ Slot: CollectionSlot,
78
+ ItemSlot: CollectionItemSlot
79
+ }, useCollection];
94
80
  }
81
+
95
82
  export { createCollection };
96
83
  //# sourceMappingURL=Collection.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["jsx","_jsx","useComposedRefs","isWeb","Slot","createStyledContext","React","createCollection","name","Provider","CollectionProviderImpl","useStyledContext","useCollectionContext","collectionRef","current","itemMap","Map","CollectionProvider","props","scope","children","ref","useRef","displayName","COLLECTION_SLOT_NAME","CollectionSlot","forwardRef","forwardedRef","context","composedRefs","ITEM_SLOT_NAME","ITEM_DATA_ATTR","CollectionItemSlot","itemData","useEffect","set","delete","useCollection","getItems","useCallback","collectionNode"],"sources":["../../src/Collection.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,2BAAuB;AAChC,SAASC,eAAa;AAEtB,SAASC,KAAA,QAAM,oBAA2B;AAC1C,SAAOC,IAAA,EAAAC,mBAAW;AAkDZ,OAAAC,KAAA;AAvCN,SAASC,iBACPC,IAAA,EACA;EAmBA;IAAMC,QAAE,EAAAC,sBAAU;IAAAC,gBAAwB,EAAAC;EAAkB,IAAqBP,mBAC/E;IACEQ,aAAA;MACEC,OAAA;IAAoC;IAEtCC,OAAA,qBAAAC,GAAA;EAAA,GACA;EACF,IAAAC,kBAAA,YAAAA,CAAAC,KAAA;IAEF,IAAM;MAAAC,KAAA;MAAAC;IAAA,IAIDF,KAAA;IACH,IAAAG,GAAM,GAAEf,KAAO,CAAAgB,MAAA,MAAa;IAC5B,IAAAP,OAAM,GAAMT,KAAM,CAAAgB,MAA0B,gBAAS,IAAAN,GAAA,IAAAF,OAAA;IACrD,OAAM,eAAgBb,IAAA,CAAAS,sBAAoC;MAC1DS,KACE;MAIJJ,OAAA;MAEAF,aAAA,EAAmBQ,GAAA;MAMnBD;IAEA;EAIE;EACAH,kBAAgB,CAAAM,WAAA,uBAA0B;EAC1C,IAAAC,oBAAqB,GAAAhB,IAAA,mBAAgB;EACrC,IAAAiB,cAAO,kBAAMnB,KAAK,CAAAoB,UAAA,WAAeR,KAAS,EAAAS,YAAA;IAC3C;MAAAR,KAAA;MAAAC;IAAA,IAAAF,KAAA;IAED,IAAAU,OAAA,GAAehB,oBAAc,CAAAO,KAAA;IAM7B,IAAMU,YAAA,GAAA3B,eAAwB,CAAAyB,YAAA,EAAAC,OAAA,CAAAf,aAAA;IAC9B,OAAM,eAAiBZ,IAAA,CAAAG,IAAA;MAMvBiB,GAAM,EAAAQ,YAAA;MAIJT;IACA;EACA;EACAK,cAAM,CAAAF,WAAU,GAAAC,oBAA0B;EAE1C,IAAAM,cAAgB,GAAAtB,IAAM;EACpB,IAAAuB,cAAQ,GAAQ,sBAAoB;EACpC,IAAAC,kBAAkB,kBAAgB1B,KAAO,CAAAoB,UAAG,WAAAR,KAAA,EAAAS,YAAA;IAC9C,IAAC;MAAAR,KAAA;MAAAC,QAAA;MAAA,GAAAa;IAAA,IAAAf,KAAA;IAED,IAAAG,GACE,GAAAf,KAAA,CAAAgB,MAAA,MAAC;IAIJ,IAAAO,YAAA,GAAA3B,eAAA,CAAAyB,YAAA,EAAAN,GAAA;IAED,IAAAO,OAAA,GAAAhB,oBAAiC,CAAAO,KAAA;IAMjCb,KAAA,CAAA4B,SAAS,aAAc;MACrBN,OAAM,CAAAb,OAAU,CAAAoB,GAAA,CAAAd,GAAA;QAEhBA,GAAM;QACJ,GAAKY;MACH;MACF;QAEA,OAAM,KAAAL,OAAA,CAAAb,OAAiB,CAAAqB,MAAQ,CAAAf,GAAA;MAC/B;IACA;IAA2B,OACzB,eAAepB,IAAA,CAAAG,IAAA;MACjB,CAAA2B,cAAA;MACAV,GAAA,EAAAQ,YAAc;MACdT;IAA2B;EAG2B;EAEtDY,kBAAO,CAAAT,WAAA,GAAAO,cAAA;EAAA,SACLO,aAAQA,CAAAlB,KAAA,EAAe;IAE3B,IAAAS,OAAO,GAAAhB,oBAAA,CAAAO,KAAA;IACT,IAAAmB,QAAA,GAAAhC,KAAA,CAAAiC,WAAA;MAEA,IAAO,CAAApC,KAAA;QACH,SAAU;MACZ;MACF,IAAAqC,cAAA,GAAAZ,OAAA,CAAAf,aAAA,CAAAC,OAAA;MACF,KAAA0B,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"Collection.native.js","names":[],"sources":["esm/Collection.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { 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\";\nfunction createCollection(name) {\n var { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = 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 = React.useRef(void 0);\n var itemMap = React.useRef(/* @__PURE__ */ new Map()).current;\n return /* @__PURE__ */ _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 = createRefComponent(function(props, forwardedRef) {\n var { scope, children } = props;\n var context = useCollectionContext(scope);\n var composedRefs = useComposedRefs(forwardedRef, context.collectionRef);\n return /* @__PURE__ */ _jsx(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 = createRefComponent(function(props, forwardedRef) {\n var { scope, children, ...itemData } = props;\n var ref = React.useRef(void 0);\n var composedRefs = useComposedRefs(forwardedRef, ref);\n var context = useCollectionContext(scope);\n React.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__ */ _jsx(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 = React.useCallback(function() {\n if (!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}\nexport {\n createCollection\n};\n//# sourceMappingURL=Collection.js.map\n"],"mappings":";;;;;;;AAMA,SAAS,iBAAiB,MAAM;CAC9B,IAAI,EAAE,UAAU,wBAAwB,kBAAkB,yBAAyB,oBAAoB;EACrG,eAAe,EACb,SAAS,KAAK,EAChB;EACA,yBAAyB,IAAI,IAAI;CACnC,GAAG,OAAO;CACV,IAAI,qBAAqB,SAAS,OAAO;EACvC,IAAI,EAAE,OAAO,aAAa;EAC1B,IAAI,MAAM,MAAM,OAAO,KAAK,CAAC;EAC7B,IAAI,UAAU,MAAM,uBAAuB,IAAI,IAAI,CAAC,EAAE;EACtD,OAAuB,oBAAK,wBAAwB;GAClD;GACA;GACA,eAAe;GACf;EACF,CAAC;CACH;CACA,mBAAmB,cAAc;CACjC,IAAI,uBAAuB,OAAO;CAClC,IAAI,iBAAiB,mBAAmB,SAAS,OAAO,cAAc;EACpE,IAAI,EAAE,OAAO,aAAa;EAC1B,IAAI,UAAU,qBAAqB,KAAK;EACxC,IAAI,eAAe,gBAAgB,cAAc,QAAQ,aAAa;EACtE,OAAuB,oBAAK,MAAM;GAChC,KAAK;GACL;EACF,CAAC;CACH,CAAC;CACD,eAAe,cAAc;CAC7B,IAAI,iBAAiB,OAAO;CAC5B,IAAI,iBAAiB;CACrB,IAAI,qBAAqB,mBAAmB,SAAS,OAAO,cAAc;EACxE,IAAI,EAAE,OAAO,UAAU,GAAG,aAAa;EACvC,IAAI,MAAM,MAAM,OAAO,KAAK,CAAC;EAC7B,IAAI,eAAe,gBAAgB,cAAc,GAAG;EACpD,IAAI,UAAU,qBAAqB,KAAK;EACxC,MAAM,UAAU,WAAW;GACzB,QAAQ,QAAQ,IAAI,KAAK;IACvB;IACA,GAAG;GACL,CAAC;GACD,OAAO,WAAW;IAChB,OAAO,KAAK,QAAQ,QAAQ,OAAO,GAAG;GACxC;EACF,CAAC;EACD,OAAuB,oBAAK,MAAM;IAC/B,iBAAiB;GAClB,KAAK;GACL;EACF,CAAC;CACH,CAAC;CACD,mBAAmB,cAAc;CACjC,SAAS,cAAc,OAAO;EAC5B,IAAI,UAAU,qBAAqB,KAAK;EACxC,IAAI,WAAW,MAAM,YAAY,WAAW;GAC1C,IAAI,CAAC,OAAO;IACV,OAAO,CAAC;GACV;GACA,IAAI,iBAAiB,QAAQ,cAAc;GAC3C,IAAI,CAAC,gBAAgB,OAAO,CAAC;GAC7B,IAAI,eAAe,MAAM,KAAK,eAAe,iBAAiB,IAAI,eAAe,EAAE,CAAC;GACpF,IAAI,QAAQ,MAAM,KAAK,QAAQ,QAAQ,OAAO,CAAC;GAC/C,IAAI,eAAe,MAAM,KAAK,SAAS,GAAG,GAAG;IAC3C,OAAO,aAAa,QAAQ,EAAE,IAAI,OAAO,IAAI,aAAa,QAAQ,EAAE,IAAI,OAAO;GACjF,CAAC;GACD,OAAO;EACT,GAAG,CACD,QAAQ,eACR,QAAQ,OACV,CAAC;EACD,OAAO;CACT;CACA,OAAO,CACL;EACE,UAAU;EACV,MAAM;EACN,UAAU;CACZ,GACA,aACF;AACF"}
package/dist/esm/index.js CHANGED
@@ -1,2 +1 @@
1
- export * from "./Collection.mjs";
2
- //# sourceMappingURL=index.js.map
1
+ export * from "./Collection.mjs"
@@ -1,2 +1 @@
1
- export * from "./Collection.mjs";
2
- //# sourceMappingURL=index.mjs.map
1
+ export * from "./Collection.mjs"
@@ -1,2 +1 @@
1
- export * from "./Collection.native.js";
2
- //# sourceMappingURL=index.native.js.map
1
+ export * from "./Collection.native.js"