@tamagui/compose-refs 1.0.0-beta.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,51 @@
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
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], 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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var compose_refs_exports = {};
23
+ __export(compose_refs_exports, {
24
+ composeRefs: () => composeRefs,
25
+ useComposedRefs: () => useComposedRefs
26
+ });
27
+ module.exports = __toCommonJS(compose_refs_exports);
28
+ var React = __toESM(require("react"));
29
+ function setRef(ref, value) {
30
+ if (typeof ref === "function") {
31
+ ref(value);
32
+ } else if (ref !== null && ref !== void 0) {
33
+ ;
34
+ ref.current = value;
35
+ }
36
+ }
37
+ __name(setRef, "setRef");
38
+ function composeRefs(...refs) {
39
+ return (node) => refs.forEach((ref) => setRef(ref, node));
40
+ }
41
+ __name(composeRefs, "composeRefs");
42
+ function useComposedRefs(...refs) {
43
+ return React.useCallback(composeRefs(...refs), refs);
44
+ }
45
+ __name(useComposedRefs, "useComposedRefs");
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ composeRefs,
49
+ useComposedRefs
50
+ });
51
+ //# sourceMappingURL=compose-refs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/compose-refs.tsx"],
4
+ "sourcesContent": ["// from radix\n// https://raw.githubusercontent.com/radix-ui/primitives/main/packages/react/compose-refs/src/composeRefs.tsx\n\nimport * as React from 'react'\n\ntype PossibleRef<T> = React.Ref<T> | undefined\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value)\n } else if (ref !== null && ref !== undefined) {\n ;(ref as React.MutableRefObject<T>).current = value\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node))\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs)\n}\n\nexport { composeRefs, useComposedRefs }\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAQvB,gBAAmB,KAAqB,OAAU;AAChD,MAAI,OAAO,QAAQ,YAAY;AAC7B,QAAI,KAAK;AAAA,EACX,WAAW,QAAQ,QAAQ,QAAQ,QAAW;AAC5C;AAAC,IAAC,IAAkC,UAAU;AAAA,EAChD;AACF;AANS;AAYT,wBAA2B,MAAwB;AACjD,SAAO,CAAC,SAAY,KAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAC7D;AAFS;AAQT,4BAA+B,MAAwB;AAErD,SAAO,MAAM,YAAY,YAAY,GAAG,IAAI,GAAG,IAAI;AACrD;AAHS;",
6
+ "names": []
7
+ }
@@ -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") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./compose-refs"), module.exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './compose-refs'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,2BAAd;",
6
+ "names": []
7
+ }
@@ -0,0 +1,25 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import * as React from "react";
4
+ function setRef(ref, value) {
5
+ if (typeof ref === "function") {
6
+ ref(value);
7
+ } else if (ref !== null && ref !== void 0) {
8
+ ;
9
+ ref.current = value;
10
+ }
11
+ }
12
+ __name(setRef, "setRef");
13
+ function composeRefs(...refs) {
14
+ return (node) => refs.forEach((ref) => setRef(ref, node));
15
+ }
16
+ __name(composeRefs, "composeRefs");
17
+ function useComposedRefs(...refs) {
18
+ return React.useCallback(composeRefs(...refs), refs);
19
+ }
20
+ __name(useComposedRefs, "useComposedRefs");
21
+ export {
22
+ composeRefs,
23
+ useComposedRefs
24
+ };
25
+ //# sourceMappingURL=compose-refs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/compose-refs.tsx"],
4
+ "sourcesContent": ["// from radix\n// https://raw.githubusercontent.com/radix-ui/primitives/main/packages/react/compose-refs/src/composeRefs.tsx\n\nimport * as React from 'react'\n\ntype PossibleRef<T> = React.Ref<T> | undefined\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value)\n } else if (ref !== null && ref !== undefined) {\n ;(ref as React.MutableRefObject<T>).current = value\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node))\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs)\n}\n\nexport { composeRefs, useComposedRefs }\n"],
5
+ "mappings": ";;AAGA;AAQA,gBAAmB,KAAqB,OAAU;AAChD,MAAI,OAAO,QAAQ,YAAY;AAC7B,QAAI,KAAK;AAAA,EACX,WAAW,QAAQ,QAAQ,QAAQ,QAAW;AAC5C;AAAC,IAAC,IAAkC,UAAU;AAAA,EAChD;AACF;AANS;AAYT,wBAA2B,MAAwB;AACjD,SAAO,CAAC,SAAY,KAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAC7D;AAFS;AAQT,4BAA+B,MAAwB;AAErD,SAAO,MAAM,YAAY,YAAY,GAAG,IAAI,GAAG,IAAI;AACrD;AAHS;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./compose-refs";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './compose-refs'\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,24 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import * as React from "react";
4
+ function setRef(ref, value) {
5
+ if (typeof ref === "function") {
6
+ ref(value);
7
+ } else if (ref !== null && ref !== void 0) {
8
+ ;
9
+ ref.current = value;
10
+ }
11
+ }
12
+ __name(setRef, "setRef");
13
+ function composeRefs(...refs) {
14
+ return (node) => refs.forEach((ref) => setRef(ref, node));
15
+ }
16
+ __name(composeRefs, "composeRefs");
17
+ function useComposedRefs(...refs) {
18
+ return React.useCallback(composeRefs(...refs), refs);
19
+ }
20
+ __name(useComposedRefs, "useComposedRefs");
21
+ export {
22
+ composeRefs,
23
+ useComposedRefs
24
+ };
@@ -0,0 +1 @@
1
+ export * from "./compose-refs";
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@tamagui/compose-refs",
3
+ "version": "1.0.0-beta.0",
4
+ "sideEffects": false,
5
+ "source": "src/index.ts",
6
+ "typings": "types",
7
+ "main": "dist/cjs",
8
+ "module": "dist/esm",
9
+ "module:jsx": "dist/jsx",
10
+ "files": [
11
+ "types",
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "tamagui-build",
16
+ "watch": "tamagui-build --watch"
17
+ },
18
+ "peerDependencies": {
19
+ "react": "*"
20
+ },
21
+ "devDependencies": {
22
+ "@tamagui/build": "^1.0.0-beta.0",
23
+ "react": "*"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
29
+ }
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ declare type PossibleRef<T> = React.Ref<T> | undefined;
3
+ declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
4
+ declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
5
+ export { composeRefs, useComposedRefs };
6
+ //# sourceMappingURL=compose-refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-refs.d.ts","sourceRoot":"","sources":["../src/compose-refs.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,aAAK,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;AAkB9C,iBAAS,WAAW,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,UACjC,CAAC,UAChB;AAMD,iBAAS,eAAe,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,qBAGpD;AAED,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './compose-refs';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}