dn-react-router-toolkit 0.5.8 → 0.5.9

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.
@@ -119,7 +119,7 @@ function CrudForm({ AdminLayout }) {
119
119
  if (value.type === "textarea") {
120
120
  const Editor = (0, import_store2.useSyncTextEditor)(textarea);
121
121
  return /* @__PURE__ */ import_react3.default.createElement(
122
- Editor.SyncTextEditor,
122
+ Editor.Component,
123
123
  {
124
124
  store: form.store,
125
125
  property: key
@@ -88,7 +88,7 @@ function CrudForm({ AdminLayout }) {
88
88
  if (value.type === "textarea") {
89
89
  const Editor = useSyncTextEditor(textarea);
90
90
  return /* @__PURE__ */ React2.createElement(
91
- Editor.SyncTextEditor,
91
+ Editor.Component,
92
92
  {
93
93
  store: form.store,
94
94
  property: key
@@ -635,7 +635,7 @@ function CrudForm({ AdminLayout }) {
635
635
  if (value.type === "textarea") {
636
636
  const Editor = (0, import_store2.useSyncTextEditor)(textarea);
637
637
  return /* @__PURE__ */ import_react8.default.createElement(
638
- Editor.SyncTextEditor,
638
+ Editor.Component,
639
639
  {
640
640
  store: form.store,
641
641
  property: key
@@ -612,7 +612,7 @@ function CrudForm({ AdminLayout }) {
612
612
  if (value.type === "textarea") {
613
613
  const Editor = useSyncTextEditor(textarea);
614
614
  return /* @__PURE__ */ React7.createElement(
615
- Editor.SyncTextEditor,
615
+ Editor.Component,
616
616
  {
617
617
  store: form.store,
618
618
  property: key
@@ -233,7 +233,7 @@ function CrudForm({ AdminLayout }) {
233
233
  if (value.type === "textarea") {
234
234
  const Editor = (0, import_store2.useSyncTextEditor)(textarea);
235
235
  return /* @__PURE__ */ import_react3.default.createElement(
236
- Editor.SyncTextEditor,
236
+ Editor.Component,
237
237
  {
238
238
  store: form.store,
239
239
  property: key
@@ -196,7 +196,7 @@ function CrudForm({ AdminLayout }) {
196
196
  if (value.type === "textarea") {
197
197
  const Editor = useSyncTextEditor(textarea);
198
198
  return /* @__PURE__ */ React2.createElement(
199
- Editor.SyncTextEditor,
199
+ Editor.Component,
200
200
  {
201
201
  store: form.store,
202
202
  property: key
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // src/post/index.ts
27
+ var post_exports = {};
28
+ module.exports = __toCommonJS(post_exports);
29
+
30
+ // src/post/thumbnail_picker.tsx
31
+ var import_utils = require("dn-react-toolkit/utils");
32
+ var import_react = __toESM(require("react"));
@@ -0,0 +1,3 @@
1
+ // src/post/thumbnail_picker.tsx
2
+ import { cn } from "dn-react-toolkit/utils";
3
+ import React, { useEffect, useState } from "react";
@@ -0,0 +1,17 @@
1
+ import { RxStore, useSyncTextEditor } from 'dn-react-toolkit/store';
2
+ import React from 'react';
3
+
4
+ declare function PostThumbnailPicker<T extends {
5
+ thumbnail: string | null;
6
+ }>({ store, textEditor, ResponsiveImage, }: {
7
+ store: RxStore<T>;
8
+ textEditor: ReturnType<typeof useSyncTextEditor>["textEditor"];
9
+ ResponsiveImage: React.FC<{
10
+ src: string;
11
+ alt: string;
12
+ className?: string;
13
+ sizes?: string;
14
+ }>;
15
+ }): React.JSX.Element;
16
+
17
+ export { PostThumbnailPicker as default };
@@ -0,0 +1,17 @@
1
+ import { RxStore, useSyncTextEditor } from 'dn-react-toolkit/store';
2
+ import React from 'react';
3
+
4
+ declare function PostThumbnailPicker<T extends {
5
+ thumbnail: string | null;
6
+ }>({ store, textEditor, ResponsiveImage, }: {
7
+ store: RxStore<T>;
8
+ textEditor: ReturnType<typeof useSyncTextEditor>["textEditor"];
9
+ ResponsiveImage: React.FC<{
10
+ src: string;
11
+ alt: string;
12
+ className?: string;
13
+ sizes?: string;
14
+ }>;
15
+ }): React.JSX.Element;
16
+
17
+ export { PostThumbnailPicker as default };
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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(
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", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/post/thumbnail_picker.tsx
31
+ var thumbnail_picker_exports = {};
32
+ __export(thumbnail_picker_exports, {
33
+ default: () => PostThumbnailPicker
34
+ });
35
+ module.exports = __toCommonJS(thumbnail_picker_exports);
36
+ var import_utils = require("dn-react-toolkit/utils");
37
+ var import_react = __toESM(require("react"));
38
+ function PostThumbnailPicker({
39
+ store,
40
+ textEditor,
41
+ ResponsiveImage
42
+ }) {
43
+ const thumbnail = store.useSelector((state) => state.thumbnail);
44
+ const [thumbnails, setThumbnails] = (0, import_react.useState)([]);
45
+ (0, import_react.useEffect)(() => {
46
+ const update = () => {
47
+ const html = textEditor.commands.serialize();
48
+ if (!html) {
49
+ return;
50
+ }
51
+ const parser = new DOMParser();
52
+ const docHtml = parser.parseFromString(html, "text/html");
53
+ const images = docHtml.querySelectorAll("img");
54
+ const thumbnails2 = Array.from(images).map((img) => img.src);
55
+ setThumbnails(thumbnails2);
56
+ if (thumbnails2.length > 0 && !store.state.thumbnail) {
57
+ store.dispatch((state) => {
58
+ state.thumbnail = thumbnails2[0];
59
+ });
60
+ }
61
+ };
62
+ const sub = textEditor.subject.subscribe((tr) => {
63
+ update();
64
+ });
65
+ setTimeout(() => {
66
+ update();
67
+ }, 0);
68
+ return () => {
69
+ sub.unsubscribe();
70
+ };
71
+ }, []);
72
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "grid grid-cols-2 gap-1" }, thumbnails.map((url, index) => /* @__PURE__ */ import_react.default.createElement(
73
+ "button",
74
+ {
75
+ key: index,
76
+ type: "button",
77
+ className: (0, import_utils.cn)(
78
+ "border border-neutral-200 rounded-lg overflow-hidden aspect-4/3",
79
+ thumbnail === url && "border-transparent ring-2 ring-primary"
80
+ ),
81
+ onClick: () => {
82
+ store.dispatch((state) => {
83
+ state.thumbnail = url;
84
+ });
85
+ }
86
+ },
87
+ /* @__PURE__ */ import_react.default.createElement(
88
+ ResponsiveImage,
89
+ {
90
+ src: url,
91
+ alt: `Thumbnail ${index + 1}`,
92
+ className: "w-full h-full object-cover",
93
+ sizes: "200px"
94
+ }
95
+ )
96
+ )));
97
+ }
@@ -0,0 +1,66 @@
1
+ // src/post/thumbnail_picker.tsx
2
+ import { cn } from "dn-react-toolkit/utils";
3
+ import React, { useEffect, useState } from "react";
4
+ function PostThumbnailPicker({
5
+ store,
6
+ textEditor,
7
+ ResponsiveImage
8
+ }) {
9
+ const thumbnail = store.useSelector((state) => state.thumbnail);
10
+ const [thumbnails, setThumbnails] = useState([]);
11
+ useEffect(() => {
12
+ const update = () => {
13
+ const html = textEditor.commands.serialize();
14
+ if (!html) {
15
+ return;
16
+ }
17
+ const parser = new DOMParser();
18
+ const docHtml = parser.parseFromString(html, "text/html");
19
+ const images = docHtml.querySelectorAll("img");
20
+ const thumbnails2 = Array.from(images).map((img) => img.src);
21
+ setThumbnails(thumbnails2);
22
+ if (thumbnails2.length > 0 && !store.state.thumbnail) {
23
+ store.dispatch((state) => {
24
+ state.thumbnail = thumbnails2[0];
25
+ });
26
+ }
27
+ };
28
+ const sub = textEditor.subject.subscribe((tr) => {
29
+ update();
30
+ });
31
+ setTimeout(() => {
32
+ update();
33
+ }, 0);
34
+ return () => {
35
+ sub.unsubscribe();
36
+ };
37
+ }, []);
38
+ return /* @__PURE__ */ React.createElement("div", { className: "grid grid-cols-2 gap-1" }, thumbnails.map((url, index) => /* @__PURE__ */ React.createElement(
39
+ "button",
40
+ {
41
+ key: index,
42
+ type: "button",
43
+ className: cn(
44
+ "border border-neutral-200 rounded-lg overflow-hidden aspect-4/3",
45
+ thumbnail === url && "border-transparent ring-2 ring-primary"
46
+ ),
47
+ onClick: () => {
48
+ store.dispatch((state) => {
49
+ state.thumbnail = url;
50
+ });
51
+ }
52
+ },
53
+ /* @__PURE__ */ React.createElement(
54
+ ResponsiveImage,
55
+ {
56
+ src: url,
57
+ alt: `Thumbnail ${index + 1}`,
58
+ className: "w-full h-full object-cover",
59
+ sizes: "200px"
60
+ }
61
+ )
62
+ )));
63
+ }
64
+ export {
65
+ PostThumbnailPicker as default
66
+ };
package/package.json CHANGED
@@ -1,89 +1,94 @@
1
1
  {
2
- "name": "dn-react-router-toolkit",
3
- "version": "0.5.8",
4
- "types": "./dist/index.d.ts",
5
- "main": "./dist/index.mjs",
6
- "module": "./dist/index.js",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.mjs",
11
- "require": "./dist/index.js"
2
+ "name": "dn-react-router-toolkit",
3
+ "version": "0.5.9",
4
+ "types": "./dist/index.d.ts",
5
+ "main": "./dist/index.mjs",
6
+ "module": "./dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
12
+ },
13
+ "./auth": {
14
+ "types": "./dist/auth/index.d.ts",
15
+ "import": "./dist/auth/index.mjs",
16
+ "require": "./dist/auth/index.js"
17
+ },
18
+ "./api": {
19
+ "types": "./dist/api/index.d.ts",
20
+ "import": "./dist/api/index.mjs",
21
+ "require": "./dist/api/index.js"
22
+ },
23
+ "./client": {
24
+ "types": "./dist/client/index.d.ts",
25
+ "import": "./dist/client/index.mjs",
26
+ "require": "./dist/client/index.js"
27
+ },
28
+ "./seo": {
29
+ "types": "./dist/seo/index.d.ts",
30
+ "import": "./dist/seo/index.mjs",
31
+ "require": "./dist/seo/index.js"
32
+ },
33
+ "./db": {
34
+ "types": "./dist/db/index.d.ts",
35
+ "import": "./dist/db/index.mjs",
36
+ "require": "./dist/db/index.js"
37
+ },
38
+ "./db/backup": {
39
+ "types": "./dist/db/backup/index.d.ts",
40
+ "import": "./dist/db/backup/index.mjs",
41
+ "require": "./dist/db/backup/index.js"
42
+ },
43
+ "./table": {
44
+ "types": "./dist/table/index.d.ts",
45
+ "import": "./dist/table/index.mjs",
46
+ "require": "./dist/table/index.js"
47
+ },
48
+ "./crud": {
49
+ "types": "./dist/crud/index.d.ts",
50
+ "import": "./dist/crud/index.mjs",
51
+ "require": "./dist/crud/index.js"
52
+ },
53
+ "./post": {
54
+ "types": "./dist/post/index.d.ts",
55
+ "import": "./dist/post/index.mjs",
56
+ "require": "./dist/post/index.js"
57
+ }
12
58
  },
13
- "./auth": {
14
- "types": "./dist/auth/index.d.ts",
15
- "import": "./dist/auth/index.mjs",
16
- "require": "./dist/auth/index.js"
59
+ "scripts": {
60
+ "build": "tsup",
61
+ "dev": "tsup --watch"
17
62
  },
18
- "./api": {
19
- "types": "./dist/api/index.d.ts",
20
- "import": "./dist/api/index.mjs",
21
- "require": "./dist/api/index.js"
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/dndnsoft/dn-react-router-toolkit.git"
22
66
  },
23
- "./client": {
24
- "types": "./dist/client/index.d.ts",
25
- "import": "./dist/client/index.mjs",
26
- "require": "./dist/client/index.js"
67
+ "author": "",
68
+ "license": "MIT",
69
+ "bugs": {
70
+ "url": "https://github.com/dndnsoft/dn-react-router-toolkit/issues"
27
71
  },
28
- "./seo": {
29
- "types": "./dist/seo/index.d.ts",
30
- "import": "./dist/seo/index.mjs",
31
- "require": "./dist/seo/index.js"
72
+ "homepage": "https://github.com/dndnsoft/dn-react-router-toolkit#readme",
73
+ "description": "",
74
+ "devDependencies": {
75
+ "@types/node": "^24.10.1",
76
+ "@types/react": "^19",
77
+ "@types/react-dom": "^19",
78
+ "schema-dts": "^1.1.5",
79
+ "tsup": "^8.5.1",
80
+ "typescript": "^5.7.3"
32
81
  },
33
- "./db": {
34
- "types": "./dist/db/index.d.ts",
35
- "import": "./dist/db/index.mjs",
36
- "require": "./dist/db/index.js"
82
+ "dependencies": {
83
+ "@react-router/dev": "^7.11.0",
84
+ "pg": "^8.16.3",
85
+ "uuid": "^13.0.0"
37
86
  },
38
- "./db/backup": {
39
- "types": "./dist/db/backup/index.d.ts",
40
- "import": "./dist/db/backup/index.mjs",
41
- "require": "./dist/db/backup/index.js"
42
- },
43
- "./table": {
44
- "types": "./dist/table/index.d.ts",
45
- "import": "./dist/table/index.mjs",
46
- "require": "./dist/table/index.js"
47
- },
48
- "./crud": {
49
- "types": "./dist/crud/index.d.ts",
50
- "import": "./dist/crud/index.mjs",
51
- "require": "./dist/crud/index.js"
87
+ "peerDependencies": {
88
+ "dn-react-toolkit": "^0.2.46",
89
+ "drizzle-orm": "^0.45.1",
90
+ "react": "^19",
91
+ "react-dom": "^19",
92
+ "react-router": "^7"
52
93
  }
53
- },
54
- "scripts": {
55
- "build": "tsup",
56
- "dev": "tsup --watch"
57
- },
58
- "repository": {
59
- "type": "git",
60
- "url": "git+https://github.com/dndnsoft/dn-react-router-toolkit.git"
61
- },
62
- "author": "",
63
- "license": "MIT",
64
- "bugs": {
65
- "url": "https://github.com/dndnsoft/dn-react-router-toolkit/issues"
66
- },
67
- "homepage": "https://github.com/dndnsoft/dn-react-router-toolkit#readme",
68
- "description": "",
69
- "devDependencies": {
70
- "@types/node": "^24.10.1",
71
- "@types/react": "^19",
72
- "@types/react-dom": "^19",
73
- "schema-dts": "^1.1.5",
74
- "tsup": "^8.5.1",
75
- "typescript": "^5.7.3"
76
- },
77
- "dependencies": {
78
- "@react-router/dev": "^7.11.0",
79
- "pg": "^8.16.3",
80
- "uuid": "^13.0.0"
81
- },
82
- "peerDependencies": {
83
- "dn-react-toolkit": "^0.2.43",
84
- "drizzle-orm": "^0.45.1",
85
- "react": "^19",
86
- "react-dom": "^19",
87
- "react-router": "^7"
88
- }
89
94
  }