@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.
@@ -1,3 +1,4 @@
1
+
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -5,126 +6,101 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
30
26
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
28
  var Collection_exports = {};
35
- __export(Collection_exports, {
36
- createCollection: () => createCollection
37
- });
29
+ __export(Collection_exports, { createCollection: () => createCollection });
38
30
  module.exports = __toCommonJS(Collection_exports);
31
+ var import_core = require("@tamagui/core");
39
32
  var import_compose_refs = require("@tamagui/compose-refs");
40
33
  var import_constants = require("@tamagui/constants");
41
- var import_core = require("@tamagui/core");
34
+ var import_core2 = require("@tamagui/core");
42
35
  var import_react = __toESM(require("react"), 1);
43
36
  var import_jsx_runtime = require("react/jsx-runtime");
44
37
  function createCollection(name) {
45
- const {
46
- Provider: CollectionProviderImpl,
47
- useStyledContext: useCollectionContext
48
- } = (0, import_core.createStyledContext)({
49
- collectionRef: {
50
- current: void 0
51
- },
52
- itemMap: /* @__PURE__ */new Map()
53
- }, "Toast");
54
- const CollectionProvider = props => {
55
- const {
56
- scope,
57
- children
58
- } = props;
59
- const ref = import_react.default.useRef(void 0);
60
- const itemMap = import_react.default.useRef(/* @__PURE__ */new Map()).current;
61
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(CollectionProviderImpl, {
62
- scope,
63
- itemMap,
64
- collectionRef: ref,
65
- children
66
- });
67
- };
68
- CollectionProvider.displayName = "CollectionProvider";
69
- const COLLECTION_SLOT_NAME = name + "CollectionSlot";
70
- const CollectionSlot = import_react.default.forwardRef((props, forwardedRef) => {
71
- const {
72
- scope,
73
- children
74
- } = props;
75
- const context = useCollectionContext(scope);
76
- const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
77
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Slot, {
78
- ref: composedRefs,
79
- children
80
- });
81
- });
82
- CollectionSlot.displayName = COLLECTION_SLOT_NAME;
83
- const ITEM_SLOT_NAME = name + "CollectionItemSlot";
84
- const ITEM_DATA_ATTR = "data-collection-item";
85
- const CollectionItemSlot = import_react.default.forwardRef((props, forwardedRef) => {
86
- const {
87
- scope,
88
- children,
89
- ...itemData
90
- } = props;
91
- const ref = import_react.default.useRef(void 0);
92
- const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
93
- const context = useCollectionContext(scope);
94
- import_react.default.useEffect(() => {
95
- context.itemMap.set(ref, {
96
- ref,
97
- ...itemData
98
- });
99
- return () => void context.itemMap.delete(ref);
100
- });
101
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Slot, {
102
- ...{
103
- [ITEM_DATA_ATTR]: ""
104
- },
105
- ref: composedRefs,
106
- children
107
- });
108
- });
109
- CollectionItemSlot.displayName = ITEM_SLOT_NAME;
110
- function useCollection(scope) {
111
- const context = useCollectionContext(scope);
112
- const getItems = import_react.default.useCallback(() => {
113
- if (!import_constants.isWeb) {
114
- return [];
115
- }
116
- const collectionNode = context.collectionRef.current;
117
- if (!collectionNode) return [];
118
- const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
119
- const items = Array.from(context.itemMap.values());
120
- const orderedItems = items.sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));
121
- return orderedItems;
122
- }, [context.collectionRef, context.itemMap]);
123
- return getItems;
124
- }
125
- return [{
126
- Provider: CollectionProvider,
127
- Slot: CollectionSlot,
128
- ItemSlot: CollectionItemSlot
129
- }, useCollection];
130
- }
38
+ const { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = (0, import_core2.createStyledContext)({
39
+ collectionRef: { current: void 0 },
40
+ itemMap: /* @__PURE__ */ new Map()
41
+ }, "Toast");
42
+ const CollectionProvider = (props) => {
43
+ const { scope, children } = props;
44
+ const ref = import_react.default.useRef(void 0);
45
+ const itemMap = import_react.default.useRef(/* @__PURE__ */ new Map()).current;
46
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollectionProviderImpl, {
47
+ scope,
48
+ itemMap,
49
+ collectionRef: ref,
50
+ children
51
+ });
52
+ };
53
+ CollectionProvider.displayName = "CollectionProvider";
54
+ const COLLECTION_SLOT_NAME = name + "CollectionSlot";
55
+ const CollectionSlot = (0, import_core.createRefComponent)((props, forwardedRef) => {
56
+ const { scope, children } = props;
57
+ const context = useCollectionContext(scope);
58
+ const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
59
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slot, {
60
+ ref: composedRefs,
61
+ children
62
+ });
63
+ });
64
+ CollectionSlot.displayName = COLLECTION_SLOT_NAME;
65
+ const ITEM_SLOT_NAME = name + "CollectionItemSlot";
66
+ const ITEM_DATA_ATTR = "data-collection-item";
67
+ const CollectionItemSlot = (0, import_core.createRefComponent)((props, forwardedRef) => {
68
+ const { scope, children, ...itemData } = props;
69
+ const ref = import_react.default.useRef(void 0);
70
+ const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
71
+ const context = useCollectionContext(scope);
72
+ import_react.default.useEffect(() => {
73
+ context.itemMap.set(ref, {
74
+ ref,
75
+ ...itemData
76
+ });
77
+ return () => void context.itemMap.delete(ref);
78
+ });
79
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core2.Slot, {
80
+ ...{ [ITEM_DATA_ATTR]: "" },
81
+ ref: composedRefs,
82
+ children
83
+ });
84
+ });
85
+ CollectionItemSlot.displayName = ITEM_SLOT_NAME;
86
+ function useCollection(scope) {
87
+ const context = useCollectionContext(scope);
88
+ const getItems = import_react.default.useCallback(() => {
89
+ if (!import_constants.isWeb) {
90
+ return [];
91
+ }
92
+ const collectionNode = context.collectionRef.current;
93
+ if (!collectionNode) return [];
94
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
95
+ const items = Array.from(context.itemMap.values());
96
+ const orderedItems = items.sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));
97
+ return orderedItems;
98
+ }, [context.collectionRef, context.itemMap]);
99
+ return getItems;
100
+ }
101
+ return [{
102
+ Provider: CollectionProvider,
103
+ Slot: CollectionSlot,
104
+ ItemSlot: CollectionItemSlot
105
+ }, useCollection];
106
+ }
@@ -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
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
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
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
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
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
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 import_core = require("@tamagui/core");
37
+ var import_core2 = require("@tamagui/core");
45
38
  var import_react = __toESM(require("react"), 1);
46
39
  function createCollection(name) {
47
- var {
48
- Provider: CollectionProviderImpl,
49
- useStyledContext: useCollectionContext
50
- } = (0, import_core.createStyledContext)({
51
- collectionRef: {
52
- current: void 0
53
- },
54
- itemMap: /* @__PURE__ */new Map()
55
- }, "Toast");
56
- var CollectionProvider = function (props) {
57
- var {
58
- scope,
59
- children
60
- } = props;
61
- var ref = import_react.default.useRef(void 0);
62
- var itemMap = import_react.default.useRef(/* @__PURE__ */new Map()).current;
63
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(CollectionProviderImpl, {
64
- scope,
65
- itemMap,
66
- collectionRef: ref,
67
- children
68
- });
69
- };
70
- CollectionProvider.displayName = "CollectionProvider";
71
- var COLLECTION_SLOT_NAME = name + "CollectionSlot";
72
- var CollectionSlot = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
73
- var {
74
- scope,
75
- children
76
- } = props;
77
- var context = useCollectionContext(scope);
78
- var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
79
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Slot, {
80
- ref: composedRefs,
81
- children
82
- });
83
- });
84
- CollectionSlot.displayName = COLLECTION_SLOT_NAME;
85
- var ITEM_SLOT_NAME = name + "CollectionItemSlot";
86
- var ITEM_DATA_ATTR = "data-collection-item";
87
- var CollectionItemSlot = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
88
- var {
89
- scope,
90
- children,
91
- ...itemData
92
- } = props;
93
- var ref = import_react.default.useRef(void 0);
94
- var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
95
- var context = useCollectionContext(scope);
96
- import_react.default.useEffect(function () {
97
- context.itemMap.set(ref, {
98
- ref,
99
- ...itemData
100
- });
101
- return function () {
102
- return void context.itemMap.delete(ref);
103
- };
104
- });
105
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Slot, {
106
- [ITEM_DATA_ATTR]: "",
107
- ref: composedRefs,
108
- children
109
- });
110
- });
111
- CollectionItemSlot.displayName = ITEM_SLOT_NAME;
112
- function useCollection(scope) {
113
- var context = useCollectionContext(scope);
114
- var getItems = import_react.default.useCallback(function () {
115
- if (!import_constants.isWeb) {
116
- return [];
117
- }
118
- var collectionNode = context.collectionRef.current;
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,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Collection_exports","__export","createCollection","module","exports","import_jsx_runtime","require","import_compose_refs","import_constants","import_core","import_react","__toESM","name","Provider","CollectionProviderImpl","useStyledContext","useCollectionContext","createStyledContext","collectionRef","current","itemMap","Map","CollectionProvider","props","scope","children","ref","default","useRef","jsx","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"],"sources":["../../src/Collection.t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AA,GAAAnB,oBAAA,CAAAQ,KAAA;IAEA,IAAAuB,QAAO,GAAArC,YAAA,CAAAiB,OAAA,CAAAqB,WAAA;MACH,KAAAxC,gBAAU,CAAAyC,KAAA;QACZ;MACF;MACF,IAAAC,cAAA,GAAAf,OAAA,CAAAjB,aAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"Collection.native.js","names":[],"sources":["cjs/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,IAA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p = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
6
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
- get: () => from[key],
9
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
- });
11
- }
12
- return to;
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ }
13
+ return to;
13
14
  };
14
15
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
- value: true
17
- }), mod);
16
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
17
  var index_exports = {};
19
18
  module.exports = __toCommonJS(index_exports);
20
- __reExport(index_exports, require("./Collection.cjs"), module.exports);
19
+ __reExport(index_exports, require("./Collection.cjs"), module.exports);