@semigarden/synthetic-md-react 0.0.9 → 0.0.11
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.
- package/dist/index.cjs.js +20 -2
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.esm.js +21 -3
- package/package.json +5 -5
package/dist/index.cjs.js
CHANGED
|
@@ -28,11 +28,29 @@ module.exports = __toCommonJS(index_exports);
|
|
|
28
28
|
var import_react = require("react");
|
|
29
29
|
var import_synthetic_md = require("@semigarden/synthetic-md");
|
|
30
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
-
var SyntheticText = (0, import_react.forwardRef)(({ className, value, onChange }, ref) => {
|
|
31
|
+
var SyntheticText = (0, import_react.forwardRef)(({ className, value = "", onChange, autofocus = false }, ref) => {
|
|
32
|
+
const elementRef = (0, import_react.useRef)(null);
|
|
32
33
|
(0, import_react.useEffect)(() => {
|
|
33
34
|
(0, import_synthetic_md.defineElement)();
|
|
34
35
|
}, []);
|
|
35
|
-
|
|
36
|
+
console.log("autofocus react", autofocus);
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
38
|
+
"synthetic-text",
|
|
39
|
+
{
|
|
40
|
+
ref: (node) => {
|
|
41
|
+
elementRef.current = node;
|
|
42
|
+
if (typeof ref === "function") {
|
|
43
|
+
ref(node);
|
|
44
|
+
} else if (ref) {
|
|
45
|
+
ref.current = node;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
className,
|
|
49
|
+
value,
|
|
50
|
+
onChange,
|
|
51
|
+
autofocus
|
|
52
|
+
}
|
|
53
|
+
);
|
|
36
54
|
});
|
|
37
55
|
var SyntheticText_default = SyntheticText;
|
|
38
56
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
|
|
3
3
|
type Props = {
|
|
4
|
-
ref?: React.RefObject<HTMLTextAreaElement>;
|
|
4
|
+
ref?: React.RefObject<HTMLTextAreaElement | null>;
|
|
5
5
|
className?: string;
|
|
6
|
-
value
|
|
6
|
+
value?: string;
|
|
7
7
|
onChange: (e: Event) => void;
|
|
8
|
+
autofocus?: boolean;
|
|
8
9
|
};
|
|
9
|
-
declare const SyntheticText: react.ForwardRefExoticComponent<Omit<Props, "ref"> & react.RefAttributes<
|
|
10
|
+
declare const SyntheticText: react.ForwardRefExoticComponent<Omit<Props, "ref"> & react.RefAttributes<unknown>>;
|
|
10
11
|
|
|
11
12
|
export { SyntheticText };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
|
|
3
3
|
type Props = {
|
|
4
|
-
ref?: React.RefObject<HTMLTextAreaElement>;
|
|
4
|
+
ref?: React.RefObject<HTMLTextAreaElement | null>;
|
|
5
5
|
className?: string;
|
|
6
|
-
value
|
|
6
|
+
value?: string;
|
|
7
7
|
onChange: (e: Event) => void;
|
|
8
|
+
autofocus?: boolean;
|
|
8
9
|
};
|
|
9
|
-
declare const SyntheticText: react.ForwardRefExoticComponent<Omit<Props, "ref"> & react.RefAttributes<
|
|
10
|
+
declare const SyntheticText: react.ForwardRefExoticComponent<Omit<Props, "ref"> & react.RefAttributes<unknown>>;
|
|
10
11
|
|
|
11
12
|
export { SyntheticText };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
// src/SyntheticText.tsx
|
|
2
|
-
import { useEffect, forwardRef } from "react";
|
|
2
|
+
import { useEffect, forwardRef, useRef } from "react";
|
|
3
3
|
import { defineElement } from "@semigarden/synthetic-md";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
var SyntheticText = forwardRef(({ className, value, onChange }, ref) => {
|
|
5
|
+
var SyntheticText = forwardRef(({ className, value = "", onChange, autofocus = false }, ref) => {
|
|
6
|
+
const elementRef = useRef(null);
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
defineElement();
|
|
8
9
|
}, []);
|
|
9
|
-
|
|
10
|
+
console.log("autofocus react", autofocus);
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"synthetic-text",
|
|
13
|
+
{
|
|
14
|
+
ref: (node) => {
|
|
15
|
+
elementRef.current = node;
|
|
16
|
+
if (typeof ref === "function") {
|
|
17
|
+
ref(node);
|
|
18
|
+
} else if (ref) {
|
|
19
|
+
ref.current = node;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
className,
|
|
23
|
+
value,
|
|
24
|
+
onChange,
|
|
25
|
+
autofocus
|
|
26
|
+
}
|
|
27
|
+
);
|
|
10
28
|
});
|
|
11
29
|
var SyntheticText_default = SyntheticText;
|
|
12
30
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semigarden/synthetic-md-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "A UI primitive for unified Markdown editing and rendering",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
39
39
|
"dev": "tsup src/index.ts --watch --format esm,cjs --dts",
|
|
40
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
41
|
+
"lint": "eslint .",
|
|
40
42
|
"prepublishOnly": "npm run build"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
45
|
"@semigarden/synthetic-md": "*",
|
|
44
|
-
"react": "
|
|
45
|
-
"react-dom": ">=18.2.0"
|
|
46
|
+
"react": "^19.2.0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@types/react": "^19.2.9",
|
|
49
|
-
"react": "^
|
|
50
|
-
"react-dom": "^18.2.0",
|
|
50
|
+
"react": "^19.2.0",
|
|
51
51
|
"tsup": "^8.0.0",
|
|
52
52
|
"typescript": "^5.3.0"
|
|
53
53
|
}
|