@tooltify/integration-shared 0.1.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,10 @@
1
+ import * as react from 'react';
2
+ export { Fragment } from 'react/jsx-runtime';
3
+
4
+ declare function jsxDEV(type: any, props: any, key: any, isStaticChildren: boolean, source?: {
5
+ fileName?: string;
6
+ lineNumber?: number;
7
+ columnNumber?: number;
8
+ }): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
9
+
10
+ export { jsxDEV };
@@ -0,0 +1,31 @@
1
+ // source-transformers/react.source-transformer.ts
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment } from "react/jsx-runtime";
3
+ var SOURCE_PROPERTY_NAME = "tooltify_source";
4
+ var SymbolForwardRef = /* @__PURE__ */ Symbol.for("react.forward_ref");
5
+ var isForwardRef = (type) => (
6
+ /**
7
+ * Este check solo sera aplicado apartir de react < 16.3
8
+ */
9
+ typeof type === "object" && type !== null && type?.["$$typeof"] === SymbolForwardRef
10
+ );
11
+ function jsxDEV(type, props, key, isStaticChildren, source) {
12
+ if ((typeof type === "string" || isForwardRef(type)) && source?.fileName) {
13
+ const idx = source.fileName.indexOf(__TOOLTIFY_PACKAGES_DIR__);
14
+ if (idx >= 0) {
15
+ const relative = source.fileName.slice(idx + __TOOLTIFY_PACKAGES_DIR__.length);
16
+ const sourceValue = `${relative}:${source.lineNumber ?? 0}`;
17
+ const originalRef = props.ref;
18
+ props.ref = (el) => {
19
+ if (el) el.setAttribute(SOURCE_PROPERTY_NAME, sourceValue);
20
+ if (typeof originalRef === "function") originalRef(el);
21
+ else if (originalRef && "current" in originalRef) originalRef.current = el;
22
+ };
23
+ }
24
+ }
25
+ const fn = isStaticChildren ? _jsxs : _jsx;
26
+ return fn(type, props, key);
27
+ }
28
+ export {
29
+ Fragment,
30
+ jsxDEV
31
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@tooltify/integration-shared",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "types": "./dist/index.d.ts",
6
+ "exports": {
7
+ "./source-transformers/react": {
8
+ "types": "./dist/source-transformers/react.d.ts",
9
+ "import": "./dist/source-transformers/react.js"
10
+ }
11
+ },
12
+ "scripts": {
13
+ "build": "tsup",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "peerDependencies": {
17
+ "react": "*"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "tooltify",
24
+ "integration",
25
+ "shared"
26
+ ],
27
+ "author": "Franco Werner",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/franwerner/tooltify.git",
32
+ "directory": "integrations/shared"
33
+ }
34
+ }