@tamagui/collection 1.114.3 → 1.115.0

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,117 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var Collection_exports = {};
33
+ __export(Collection_exports, {
34
+ createCollection: () => createCollection
35
+ });
36
+ module.exports = __toCommonJS(Collection_exports);
37
+ var import_compose_refs = require("@tamagui/compose-refs"),
38
+ import_constants = require("@tamagui/constants"),
39
+ import_core = require("@tamagui/core"),
40
+ import_react = __toESM(require("react")),
41
+ import_jsx_runtime = require("react/jsx-runtime");
42
+ function createCollection(name) {
43
+ const {
44
+ Provider: CollectionProviderImpl,
45
+ useStyledContext: useCollectionContext
46
+ } = (0, import_core.createStyledContext)({
47
+ collectionRef: {
48
+ current: null
49
+ },
50
+ itemMap: /* @__PURE__ */new Map()
51
+ }),
52
+ CollectionProvider = props => {
53
+ const {
54
+ __scopeCollection,
55
+ children
56
+ } = props,
57
+ ref = import_react.default.useRef(null),
58
+ itemMap = import_react.default.useRef(/* @__PURE__ */new Map()).current;
59
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(CollectionProviderImpl, {
60
+ scope: __scopeCollection,
61
+ itemMap,
62
+ collectionRef: ref,
63
+ children
64
+ });
65
+ };
66
+ CollectionProvider.displayName = "CollectionProvider";
67
+ const COLLECTION_SLOT_NAME = name + "CollectionSlot",
68
+ CollectionSlot = import_react.default.forwardRef((props, forwardedRef) => {
69
+ const {
70
+ __scopeCollection,
71
+ children
72
+ } = props,
73
+ context = useCollectionContext(__scopeCollection),
74
+ composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
75
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Slot, {
76
+ ref: composedRefs,
77
+ children
78
+ });
79
+ });
80
+ CollectionSlot.displayName = COLLECTION_SLOT_NAME;
81
+ const ITEM_SLOT_NAME = name + "CollectionItemSlot",
82
+ ITEM_DATA_ATTR = "data-collection-item",
83
+ CollectionItemSlot = import_react.default.forwardRef((props, forwardedRef) => {
84
+ const {
85
+ __scopeCollection,
86
+ children,
87
+ ...itemData
88
+ } = props,
89
+ ref = import_react.default.useRef(null),
90
+ composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref),
91
+ context = useCollectionContext(__scopeCollection);
92
+ return import_react.default.useEffect(() => (context.itemMap.set(ref, {
93
+ ref,
94
+ ...itemData
95
+ }), () => void context.itemMap.delete(ref))), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Slot, {
96
+ [ITEM_DATA_ATTR]: "",
97
+ ref: composedRefs,
98
+ children
99
+ });
100
+ });
101
+ CollectionItemSlot.displayName = ITEM_SLOT_NAME;
102
+ function useCollection(__scopeCollection) {
103
+ const context = useCollectionContext(__scopeCollection);
104
+ return import_react.default.useCallback(() => {
105
+ if (!import_constants.isWeb) return [];
106
+ const collectionNode = context.collectionRef.current;
107
+ if (!collectionNode) return [];
108
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
109
+ return Array.from(context.itemMap.values()).sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));
110
+ }, [context.collectionRef, context.itemMap]);
111
+ }
112
+ return [{
113
+ Provider: CollectionProvider,
114
+ Slot: CollectionSlot,
115
+ ItemSlot: CollectionItemSlot
116
+ }, useCollection];
117
+ }
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./Collection.cjs"), module.exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/collection",
3
- "version": "1.114.3",
3
+ "version": "1.115.0",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -29,20 +29,21 @@
29
29
  "react-native": "./dist/cjs/index.native.js",
30
30
  "types": "./types/index.d.ts",
31
31
  "import": "./dist/esm/index.mjs",
32
- "require": "./dist/cjs/index.js"
32
+ "require": "./dist/cjs/index.cjs",
33
+ "default": "./dist/cjs/index.native.js"
33
34
  }
34
35
  },
35
36
  "dependencies": {
36
- "@tamagui/compose-refs": "1.114.3",
37
- "@tamagui/constants": "1.114.3",
38
- "@tamagui/core": "1.114.3",
39
- "@tamagui/create-context": "1.114.3",
40
- "@tamagui/polyfill-dev": "1.114.3",
41
- "@tamagui/stacks": "1.114.3",
42
- "@tamagui/use-controllable-state": "1.114.3"
37
+ "@tamagui/compose-refs": "1.115.0",
38
+ "@tamagui/constants": "1.115.0",
39
+ "@tamagui/core": "1.115.0",
40
+ "@tamagui/create-context": "1.115.0",
41
+ "@tamagui/polyfill-dev": "1.115.0",
42
+ "@tamagui/stacks": "1.115.0",
43
+ "@tamagui/use-controllable-state": "1.115.0"
43
44
  },
44
45
  "devDependencies": {
45
- "@tamagui/build": "1.114.3",
46
+ "@tamagui/build": "1.115.0",
46
47
  "react": "^18.2.0 || ^19.0.0"
47
48
  },
48
49
  "publishConfig": {
@@ -1,76 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var Collection_exports = {};
24
- __export(Collection_exports, {
25
- createCollection: () => createCollection
26
- });
27
- module.exports = __toCommonJS(Collection_exports);
28
- var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_react = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
29
- function createCollection(name) {
30
- const { Provider: CollectionProviderImpl, useStyledContext: useCollectionContext } = (0, import_core.createStyledContext)({
31
- collectionRef: { current: null },
32
- itemMap: /* @__PURE__ */ new Map()
33
- }), CollectionProvider = (props) => {
34
- const { __scopeCollection, children } = props, ref = import_react.default.useRef(null), itemMap = import_react.default.useRef(/* @__PURE__ */ new Map()).current;
35
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
36
- CollectionProviderImpl,
37
- {
38
- scope: __scopeCollection,
39
- itemMap,
40
- collectionRef: ref,
41
- children
42
- }
43
- );
44
- };
45
- CollectionProvider.displayName = "CollectionProvider";
46
- const COLLECTION_SLOT_NAME = name + "CollectionSlot", CollectionSlot = import_react.default.forwardRef((props, forwardedRef) => {
47
- const { __scopeCollection, children } = props, context = useCollectionContext(__scopeCollection), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.collectionRef);
48
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Slot, { ref: composedRefs, children });
49
- });
50
- CollectionSlot.displayName = COLLECTION_SLOT_NAME;
51
- const ITEM_SLOT_NAME = name + "CollectionItemSlot", ITEM_DATA_ATTR = "data-collection-item", CollectionItemSlot = import_react.default.forwardRef((props, forwardedRef) => {
52
- const { __scopeCollection, children, ...itemData } = props, ref = import_react.default.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref), context = useCollectionContext(__scopeCollection);
53
- return import_react.default.useEffect(() => (context.itemMap.set(ref, { ref, ...itemData }), () => void context.itemMap.delete(ref))), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Slot, { [ITEM_DATA_ATTR]: "", ref: composedRefs, children });
54
- });
55
- CollectionItemSlot.displayName = ITEM_SLOT_NAME;
56
- function useCollection(__scopeCollection) {
57
- const context = useCollectionContext(__scopeCollection);
58
- return import_react.default.useCallback(() => {
59
- if (!import_constants.isWeb)
60
- return [];
61
- const collectionNode = context.collectionRef.current;
62
- if (!collectionNode) return [];
63
- const orderedNodes = Array.from(
64
- collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`)
65
- );
66
- return Array.from(context.itemMap.values()).sort(
67
- (a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
68
- );
69
- }, [context.collectionRef, context.itemMap]);
70
- }
71
- return [
72
- { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
73
- useCollection
74
- ];
75
- }
76
- //# sourceMappingURL=Collection.js.map
package/dist/cjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- __reExport(src_exports, require("./Collection"), module.exports);
15
- //# sourceMappingURL=index.js.map
File without changes