dn-react-router-toolkit 0.6.8 → 0.7.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.
- package/dist/client/editor.d.mts +12 -0
- package/dist/client/editor.d.ts +12 -0
- package/dist/client/editor.js +57 -0
- package/dist/client/editor.mjs +32 -0
- package/dist/client/index.d.mts +3 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +52 -5
- package/dist/client/index.mjs +52 -6
- package/dist/client/store_text_editor.d.mts +1 -1
- package/dist/client/store_text_editor.d.ts +1 -1
- package/dist/client/store_text_editor.js +20 -5
- package/dist/client/store_text_editor.mjs +21 -6
- package/dist/crud/crud_form.js +23 -5
- package/dist/crud/crud_form.mjs +24 -6
- package/dist/crud/crud_form_provider.d.mts +4 -3
- package/dist/crud/crud_form_provider.d.ts +4 -3
- package/dist/crud/crud_form_provider.js +14 -12
- package/dist/crud/crud_form_provider.mjs +14 -12
- package/dist/crud/crud_page.d.mts +4 -2
- package/dist/crud/crud_page.d.ts +4 -2
- package/dist/crud/crud_page.js +44 -18
- package/dist/crud/crud_page.mjs +45 -19
- package/dist/crud/index.d.mts +1 -1
- package/dist/crud/index.d.ts +1 -1
- package/dist/crud/index.js +44 -18
- package/dist/crud/index.mjs +45 -19
- package/dist/post/editor_toolbar.d.mts +9 -0
- package/dist/post/editor_toolbar.d.ts +9 -0
- package/dist/post/editor_toolbar.js +343 -0
- package/dist/post/editor_toolbar.mjs +310 -0
- package/dist/post/index.d.mts +7 -2
- package/dist/post/index.d.ts +7 -2
- package/dist/post/index.js +8246 -0
- package/dist/post/index.mjs +8280 -0
- package/dist/post/post_form_page.d.mts +27 -0
- package/dist/post/post_form_page.d.ts +27 -0
- package/dist/post/post_form_page.js +8275 -0
- package/dist/post/post_form_page.mjs +8284 -0
- package/dist/post/thumbnail_picker.d.mts +3 -9
- package/dist/post/thumbnail_picker.d.ts +3 -9
- package/dist/post/thumbnail_picker.js +14 -11
- package/dist/post/thumbnail_picker.mjs +10 -11
- package/package.json +3 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FileUploader } from 'dn-react-toolkit/file/client';
|
|
2
|
+
import { AttachFileOptions } from 'dn-react-text-editor';
|
|
3
|
+
import { CDN } from 'dn-react-toolkit/file';
|
|
4
|
+
|
|
5
|
+
declare function createAttachFileOptions<TFile extends {
|
|
6
|
+
key: string;
|
|
7
|
+
}>({ cdn, fileUploader, }: {
|
|
8
|
+
cdn: CDN;
|
|
9
|
+
fileUploader: FileUploader<TFile>;
|
|
10
|
+
}): Omit<AttachFileOptions, "schema">;
|
|
11
|
+
|
|
12
|
+
export { createAttachFileOptions };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FileUploader } from 'dn-react-toolkit/file/client';
|
|
2
|
+
import { AttachFileOptions } from 'dn-react-text-editor';
|
|
3
|
+
import { CDN } from 'dn-react-toolkit/file';
|
|
4
|
+
|
|
5
|
+
declare function createAttachFileOptions<TFile extends {
|
|
6
|
+
key: string;
|
|
7
|
+
}>({ cdn, fileUploader, }: {
|
|
8
|
+
cdn: CDN;
|
|
9
|
+
fileUploader: FileUploader<TFile>;
|
|
10
|
+
}): Omit<AttachFileOptions, "schema">;
|
|
11
|
+
|
|
12
|
+
export { createAttachFileOptions };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client/editor.tsx
|
|
21
|
+
var editor_exports = {};
|
|
22
|
+
__export(editor_exports, {
|
|
23
|
+
createAttachFileOptions: () => createAttachFileOptions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(editor_exports);
|
|
26
|
+
var import_client = require("dn-react-toolkit/file/client");
|
|
27
|
+
function createAttachFileOptions({
|
|
28
|
+
cdn,
|
|
29
|
+
fileUploader
|
|
30
|
+
}) {
|
|
31
|
+
return {
|
|
32
|
+
uploadFile: async (file) => {
|
|
33
|
+
const result = await fileUploader.uploadFile(file, {
|
|
34
|
+
convertToWebp: true
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
alt: file.name,
|
|
38
|
+
src: cdn(result.key)
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
generateMetadata: (file) => (0, import_client.generateMetadata)(file, {
|
|
42
|
+
uploadBlob: async (blob) => {
|
|
43
|
+
const result = await fileUploader.uploadBlob(blob, "file", {
|
|
44
|
+
convertToWebp: true
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
alt: file.name,
|
|
48
|
+
src: cdn(result.key)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
createAttachFileOptions
|
|
57
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/client/editor.tsx
|
|
2
|
+
import { generateMetadata } from "dn-react-toolkit/file/client";
|
|
3
|
+
function createAttachFileOptions({
|
|
4
|
+
cdn,
|
|
5
|
+
fileUploader
|
|
6
|
+
}) {
|
|
7
|
+
return {
|
|
8
|
+
uploadFile: async (file) => {
|
|
9
|
+
const result = await fileUploader.uploadFile(file, {
|
|
10
|
+
convertToWebp: true
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
alt: file.name,
|
|
14
|
+
src: cdn(result.key)
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
generateMetadata: (file) => generateMetadata(file, {
|
|
18
|
+
uploadBlob: async (blob) => {
|
|
19
|
+
const result = await fileUploader.uploadBlob(blob, "file", {
|
|
20
|
+
convertToWebp: true
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
alt: file.name,
|
|
24
|
+
src: cdn(result.key)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
createAttachFileOptions
|
|
32
|
+
};
|
package/dist/client/index.d.mts
CHANGED
|
@@ -3,6 +3,9 @@ export { EnvLoader } from './env_loader.mjs';
|
|
|
3
3
|
export { FileInput } from './file_input.mjs';
|
|
4
4
|
export { useUserAgent } from './use_user_agent.mjs';
|
|
5
5
|
export { StoreTextEditor } from './store_text_editor.mjs';
|
|
6
|
+
export { createAttachFileOptions } from './editor.mjs';
|
|
6
7
|
import 'react';
|
|
7
8
|
import 'dn-react-text-editor';
|
|
8
9
|
import 'react-store-input';
|
|
10
|
+
import 'dn-react-toolkit/file/client';
|
|
11
|
+
import 'dn-react-toolkit/file';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export { EnvLoader } from './env_loader.js';
|
|
|
3
3
|
export { FileInput } from './file_input.js';
|
|
4
4
|
export { useUserAgent } from './use_user_agent.js';
|
|
5
5
|
export { StoreTextEditor } from './store_text_editor.js';
|
|
6
|
+
export { createAttachFileOptions } from './editor.js';
|
|
6
7
|
import 'react';
|
|
7
8
|
import 'dn-react-text-editor';
|
|
8
9
|
import 'react-store-input';
|
|
10
|
+
import 'dn-react-toolkit/file/client';
|
|
11
|
+
import 'dn-react-toolkit/file';
|
package/dist/client/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(client_exports, {
|
|
|
33
33
|
EnvLoader: () => EnvLoader,
|
|
34
34
|
FileInput: () => FileInput,
|
|
35
35
|
StoreTextEditor: () => StoreTextEditor,
|
|
36
|
+
createAttachFileOptions: () => createAttachFileOptions,
|
|
36
37
|
env: () => env,
|
|
37
38
|
useUserAgent: () => useUserAgent
|
|
38
39
|
});
|
|
@@ -128,22 +129,37 @@ function StoreTextEditor({
|
|
|
128
129
|
getter,
|
|
129
130
|
setter,
|
|
130
131
|
defaultValue,
|
|
132
|
+
ref,
|
|
131
133
|
...props
|
|
132
134
|
}) {
|
|
133
|
-
const
|
|
135
|
+
const controllerRef = (0, import_react4.useRef)(null);
|
|
136
|
+
(0, import_react4.useImperativeHandle)(
|
|
137
|
+
ref,
|
|
138
|
+
() => controllerRef.current,
|
|
139
|
+
[]
|
|
140
|
+
);
|
|
134
141
|
const { dispatch } = (0, import_react_store_input.useStoreController)(store, {
|
|
135
142
|
onSubscribe: (state) => {
|
|
136
|
-
const controller =
|
|
143
|
+
const controller = controllerRef.current;
|
|
137
144
|
if (!controller) {
|
|
138
145
|
return;
|
|
139
146
|
}
|
|
140
|
-
const
|
|
147
|
+
const getResult = () => {
|
|
148
|
+
if (getter) {
|
|
149
|
+
return getter(state);
|
|
150
|
+
}
|
|
151
|
+
if (name) {
|
|
152
|
+
return state[name];
|
|
153
|
+
}
|
|
154
|
+
return "";
|
|
155
|
+
};
|
|
156
|
+
const result = getResult();
|
|
141
157
|
if (controller.value !== result) {
|
|
142
158
|
controller.value = result;
|
|
143
159
|
}
|
|
144
160
|
},
|
|
145
161
|
onDispatch: (state) => {
|
|
146
|
-
const controller =
|
|
162
|
+
const controller = controllerRef.current;
|
|
147
163
|
if (!controller) {
|
|
148
164
|
return;
|
|
149
165
|
}
|
|
@@ -169,7 +185,7 @@ function StoreTextEditor({
|
|
|
169
185
|
import_dn_react_text_editor.TextEditor,
|
|
170
186
|
{
|
|
171
187
|
...props,
|
|
172
|
-
ref,
|
|
188
|
+
ref: controllerRef,
|
|
173
189
|
defaultValue: defaultValue ?? getDefaultValue(),
|
|
174
190
|
onChange: (e) => {
|
|
175
191
|
dispatch();
|
|
@@ -178,11 +194,42 @@ function StoreTextEditor({
|
|
|
178
194
|
}
|
|
179
195
|
);
|
|
180
196
|
}
|
|
197
|
+
|
|
198
|
+
// src/client/editor.tsx
|
|
199
|
+
var import_client = require("dn-react-toolkit/file/client");
|
|
200
|
+
function createAttachFileOptions({
|
|
201
|
+
cdn,
|
|
202
|
+
fileUploader
|
|
203
|
+
}) {
|
|
204
|
+
return {
|
|
205
|
+
uploadFile: async (file) => {
|
|
206
|
+
const result = await fileUploader.uploadFile(file, {
|
|
207
|
+
convertToWebp: true
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
alt: file.name,
|
|
211
|
+
src: cdn(result.key)
|
|
212
|
+
};
|
|
213
|
+
},
|
|
214
|
+
generateMetadata: (file) => (0, import_client.generateMetadata)(file, {
|
|
215
|
+
uploadBlob: async (blob) => {
|
|
216
|
+
const result = await fileUploader.uploadBlob(blob, "file", {
|
|
217
|
+
convertToWebp: true
|
|
218
|
+
});
|
|
219
|
+
return {
|
|
220
|
+
alt: file.name,
|
|
221
|
+
src: cdn(result.key)
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
};
|
|
226
|
+
}
|
|
181
227
|
// Annotate the CommonJS export names for ESM import in node:
|
|
182
228
|
0 && (module.exports = {
|
|
183
229
|
EnvLoader,
|
|
184
230
|
FileInput,
|
|
185
231
|
StoreTextEditor,
|
|
232
|
+
createAttachFileOptions,
|
|
186
233
|
env,
|
|
187
234
|
useUserAgent
|
|
188
235
|
});
|
package/dist/client/index.mjs
CHANGED
|
@@ -83,29 +83,44 @@ import {
|
|
|
83
83
|
TextEditor
|
|
84
84
|
} from "dn-react-text-editor";
|
|
85
85
|
import { useStoreController } from "react-store-input";
|
|
86
|
-
import React3, { useRef } from "react";
|
|
86
|
+
import React3, { useImperativeHandle, useRef } from "react";
|
|
87
87
|
function StoreTextEditor({
|
|
88
88
|
store,
|
|
89
89
|
name,
|
|
90
90
|
getter,
|
|
91
91
|
setter,
|
|
92
92
|
defaultValue,
|
|
93
|
+
ref,
|
|
93
94
|
...props
|
|
94
95
|
}) {
|
|
95
|
-
const
|
|
96
|
+
const controllerRef = useRef(null);
|
|
97
|
+
useImperativeHandle(
|
|
98
|
+
ref,
|
|
99
|
+
() => controllerRef.current,
|
|
100
|
+
[]
|
|
101
|
+
);
|
|
96
102
|
const { dispatch } = useStoreController(store, {
|
|
97
103
|
onSubscribe: (state) => {
|
|
98
|
-
const controller =
|
|
104
|
+
const controller = controllerRef.current;
|
|
99
105
|
if (!controller) {
|
|
100
106
|
return;
|
|
101
107
|
}
|
|
102
|
-
const
|
|
108
|
+
const getResult = () => {
|
|
109
|
+
if (getter) {
|
|
110
|
+
return getter(state);
|
|
111
|
+
}
|
|
112
|
+
if (name) {
|
|
113
|
+
return state[name];
|
|
114
|
+
}
|
|
115
|
+
return "";
|
|
116
|
+
};
|
|
117
|
+
const result = getResult();
|
|
103
118
|
if (controller.value !== result) {
|
|
104
119
|
controller.value = result;
|
|
105
120
|
}
|
|
106
121
|
},
|
|
107
122
|
onDispatch: (state) => {
|
|
108
|
-
const controller =
|
|
123
|
+
const controller = controllerRef.current;
|
|
109
124
|
if (!controller) {
|
|
110
125
|
return;
|
|
111
126
|
}
|
|
@@ -131,7 +146,7 @@ function StoreTextEditor({
|
|
|
131
146
|
TextEditor,
|
|
132
147
|
{
|
|
133
148
|
...props,
|
|
134
|
-
ref,
|
|
149
|
+
ref: controllerRef,
|
|
135
150
|
defaultValue: defaultValue ?? getDefaultValue(),
|
|
136
151
|
onChange: (e) => {
|
|
137
152
|
dispatch();
|
|
@@ -140,10 +155,41 @@ function StoreTextEditor({
|
|
|
140
155
|
}
|
|
141
156
|
);
|
|
142
157
|
}
|
|
158
|
+
|
|
159
|
+
// src/client/editor.tsx
|
|
160
|
+
import { generateMetadata } from "dn-react-toolkit/file/client";
|
|
161
|
+
function createAttachFileOptions({
|
|
162
|
+
cdn,
|
|
163
|
+
fileUploader
|
|
164
|
+
}) {
|
|
165
|
+
return {
|
|
166
|
+
uploadFile: async (file) => {
|
|
167
|
+
const result = await fileUploader.uploadFile(file, {
|
|
168
|
+
convertToWebp: true
|
|
169
|
+
});
|
|
170
|
+
return {
|
|
171
|
+
alt: file.name,
|
|
172
|
+
src: cdn(result.key)
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
generateMetadata: (file) => generateMetadata(file, {
|
|
176
|
+
uploadBlob: async (blob) => {
|
|
177
|
+
const result = await fileUploader.uploadBlob(blob, "file", {
|
|
178
|
+
convertToWebp: true
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
alt: file.name,
|
|
182
|
+
src: cdn(result.key)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
};
|
|
187
|
+
}
|
|
143
188
|
export {
|
|
144
189
|
EnvLoader,
|
|
145
190
|
FileInput,
|
|
146
191
|
StoreTextEditor,
|
|
192
|
+
createAttachFileOptions,
|
|
147
193
|
env,
|
|
148
194
|
useUserAgent
|
|
149
195
|
};
|
|
@@ -8,6 +8,6 @@ type Props<TState> = {
|
|
|
8
8
|
getter?: (state: TState) => string;
|
|
9
9
|
setter?: (state: TState, value: string) => void;
|
|
10
10
|
} & TextEditorProps;
|
|
11
|
-
declare function StoreTextEditor<TState>({ store, name, getter, setter, defaultValue, ...props }: Props<TState>): React__default.JSX.Element;
|
|
11
|
+
declare function StoreTextEditor<TState>({ store, name, getter, setter, defaultValue, ref, ...props }: Props<TState>): React__default.JSX.Element;
|
|
12
12
|
|
|
13
13
|
export { StoreTextEditor };
|
|
@@ -8,6 +8,6 @@ type Props<TState> = {
|
|
|
8
8
|
getter?: (state: TState) => string;
|
|
9
9
|
setter?: (state: TState, value: string) => void;
|
|
10
10
|
} & TextEditorProps;
|
|
11
|
-
declare function StoreTextEditor<TState>({ store, name, getter, setter, defaultValue, ...props }: Props<TState>): React__default.JSX.Element;
|
|
11
|
+
declare function StoreTextEditor<TState>({ store, name, getter, setter, defaultValue, ref, ...props }: Props<TState>): React__default.JSX.Element;
|
|
12
12
|
|
|
13
13
|
export { StoreTextEditor };
|
|
@@ -42,22 +42,37 @@ function StoreTextEditor({
|
|
|
42
42
|
getter,
|
|
43
43
|
setter,
|
|
44
44
|
defaultValue,
|
|
45
|
+
ref,
|
|
45
46
|
...props
|
|
46
47
|
}) {
|
|
47
|
-
const
|
|
48
|
+
const controllerRef = (0, import_react.useRef)(null);
|
|
49
|
+
(0, import_react.useImperativeHandle)(
|
|
50
|
+
ref,
|
|
51
|
+
() => controllerRef.current,
|
|
52
|
+
[]
|
|
53
|
+
);
|
|
48
54
|
const { dispatch } = (0, import_react_store_input.useStoreController)(store, {
|
|
49
55
|
onSubscribe: (state) => {
|
|
50
|
-
const controller =
|
|
56
|
+
const controller = controllerRef.current;
|
|
51
57
|
if (!controller) {
|
|
52
58
|
return;
|
|
53
59
|
}
|
|
54
|
-
const
|
|
60
|
+
const getResult = () => {
|
|
61
|
+
if (getter) {
|
|
62
|
+
return getter(state);
|
|
63
|
+
}
|
|
64
|
+
if (name) {
|
|
65
|
+
return state[name];
|
|
66
|
+
}
|
|
67
|
+
return "";
|
|
68
|
+
};
|
|
69
|
+
const result = getResult();
|
|
55
70
|
if (controller.value !== result) {
|
|
56
71
|
controller.value = result;
|
|
57
72
|
}
|
|
58
73
|
},
|
|
59
74
|
onDispatch: (state) => {
|
|
60
|
-
const controller =
|
|
75
|
+
const controller = controllerRef.current;
|
|
61
76
|
if (!controller) {
|
|
62
77
|
return;
|
|
63
78
|
}
|
|
@@ -83,7 +98,7 @@ function StoreTextEditor({
|
|
|
83
98
|
import_dn_react_text_editor.TextEditor,
|
|
84
99
|
{
|
|
85
100
|
...props,
|
|
86
|
-
ref,
|
|
101
|
+
ref: controllerRef,
|
|
87
102
|
defaultValue: defaultValue ?? getDefaultValue(),
|
|
88
103
|
onChange: (e) => {
|
|
89
104
|
dispatch();
|
|
@@ -3,29 +3,44 @@ import {
|
|
|
3
3
|
TextEditor
|
|
4
4
|
} from "dn-react-text-editor";
|
|
5
5
|
import { useStoreController } from "react-store-input";
|
|
6
|
-
import React, { useRef } from "react";
|
|
6
|
+
import React, { useImperativeHandle, useRef } from "react";
|
|
7
7
|
function StoreTextEditor({
|
|
8
8
|
store,
|
|
9
9
|
name,
|
|
10
10
|
getter,
|
|
11
11
|
setter,
|
|
12
12
|
defaultValue,
|
|
13
|
+
ref,
|
|
13
14
|
...props
|
|
14
15
|
}) {
|
|
15
|
-
const
|
|
16
|
+
const controllerRef = useRef(null);
|
|
17
|
+
useImperativeHandle(
|
|
18
|
+
ref,
|
|
19
|
+
() => controllerRef.current,
|
|
20
|
+
[]
|
|
21
|
+
);
|
|
16
22
|
const { dispatch } = useStoreController(store, {
|
|
17
23
|
onSubscribe: (state) => {
|
|
18
|
-
const controller =
|
|
24
|
+
const controller = controllerRef.current;
|
|
19
25
|
if (!controller) {
|
|
20
26
|
return;
|
|
21
27
|
}
|
|
22
|
-
const
|
|
28
|
+
const getResult = () => {
|
|
29
|
+
if (getter) {
|
|
30
|
+
return getter(state);
|
|
31
|
+
}
|
|
32
|
+
if (name) {
|
|
33
|
+
return state[name];
|
|
34
|
+
}
|
|
35
|
+
return "";
|
|
36
|
+
};
|
|
37
|
+
const result = getResult();
|
|
23
38
|
if (controller.value !== result) {
|
|
24
39
|
controller.value = result;
|
|
25
40
|
}
|
|
26
41
|
},
|
|
27
42
|
onDispatch: (state) => {
|
|
28
|
-
const controller =
|
|
43
|
+
const controller = controllerRef.current;
|
|
29
44
|
if (!controller) {
|
|
30
45
|
return;
|
|
31
46
|
}
|
|
@@ -51,7 +66,7 @@ function StoreTextEditor({
|
|
|
51
66
|
TextEditor,
|
|
52
67
|
{
|
|
53
68
|
...props,
|
|
54
|
-
ref,
|
|
69
|
+
ref: controllerRef,
|
|
55
70
|
defaultValue: defaultValue ?? getDefaultValue(),
|
|
56
71
|
onChange: (e) => {
|
|
57
72
|
dispatch();
|
package/dist/crud/crud_form.js
CHANGED
|
@@ -92,22 +92,37 @@ function StoreTextEditor({
|
|
|
92
92
|
getter,
|
|
93
93
|
setter,
|
|
94
94
|
defaultValue,
|
|
95
|
+
ref,
|
|
95
96
|
...props
|
|
96
97
|
}) {
|
|
97
|
-
const
|
|
98
|
+
const controllerRef = (0, import_react7.useRef)(null);
|
|
99
|
+
(0, import_react7.useImperativeHandle)(
|
|
100
|
+
ref,
|
|
101
|
+
() => controllerRef.current,
|
|
102
|
+
[]
|
|
103
|
+
);
|
|
98
104
|
const { dispatch } = (0, import_react_store_input2.useStoreController)(store, {
|
|
99
105
|
onSubscribe: (state) => {
|
|
100
|
-
const controller =
|
|
106
|
+
const controller = controllerRef.current;
|
|
101
107
|
if (!controller) {
|
|
102
108
|
return;
|
|
103
109
|
}
|
|
104
|
-
const
|
|
110
|
+
const getResult = () => {
|
|
111
|
+
if (getter) {
|
|
112
|
+
return getter(state);
|
|
113
|
+
}
|
|
114
|
+
if (name) {
|
|
115
|
+
return state[name];
|
|
116
|
+
}
|
|
117
|
+
return "";
|
|
118
|
+
};
|
|
119
|
+
const result = getResult();
|
|
105
120
|
if (controller.value !== result) {
|
|
106
121
|
controller.value = result;
|
|
107
122
|
}
|
|
108
123
|
},
|
|
109
124
|
onDispatch: (state) => {
|
|
110
|
-
const controller =
|
|
125
|
+
const controller = controllerRef.current;
|
|
111
126
|
if (!controller) {
|
|
112
127
|
return;
|
|
113
128
|
}
|
|
@@ -133,7 +148,7 @@ function StoreTextEditor({
|
|
|
133
148
|
import_dn_react_text_editor.TextEditor,
|
|
134
149
|
{
|
|
135
150
|
...props,
|
|
136
|
-
ref,
|
|
151
|
+
ref: controllerRef,
|
|
137
152
|
defaultValue: defaultValue ?? getDefaultValue(),
|
|
138
153
|
onChange: (e) => {
|
|
139
154
|
dispatch();
|
|
@@ -143,6 +158,9 @@ function StoreTextEditor({
|
|
|
143
158
|
);
|
|
144
159
|
}
|
|
145
160
|
|
|
161
|
+
// src/client/editor.tsx
|
|
162
|
+
var import_client = require("dn-react-toolkit/file/client");
|
|
163
|
+
|
|
146
164
|
// src/crud/crud_form.tsx
|
|
147
165
|
function CrudForm({
|
|
148
166
|
AdminHeader
|
package/dist/crud/crud_form.mjs
CHANGED
|
@@ -51,29 +51,44 @@ import {
|
|
|
51
51
|
TextEditor
|
|
52
52
|
} from "dn-react-text-editor";
|
|
53
53
|
import { useStoreController } from "react-store-input";
|
|
54
|
-
import React5, { useRef } from "react";
|
|
54
|
+
import React5, { useImperativeHandle, useRef } from "react";
|
|
55
55
|
function StoreTextEditor({
|
|
56
56
|
store,
|
|
57
57
|
name,
|
|
58
58
|
getter,
|
|
59
59
|
setter,
|
|
60
60
|
defaultValue,
|
|
61
|
+
ref,
|
|
61
62
|
...props
|
|
62
63
|
}) {
|
|
63
|
-
const
|
|
64
|
+
const controllerRef = useRef(null);
|
|
65
|
+
useImperativeHandle(
|
|
66
|
+
ref,
|
|
67
|
+
() => controllerRef.current,
|
|
68
|
+
[]
|
|
69
|
+
);
|
|
64
70
|
const { dispatch } = useStoreController(store, {
|
|
65
71
|
onSubscribe: (state) => {
|
|
66
|
-
const controller =
|
|
72
|
+
const controller = controllerRef.current;
|
|
67
73
|
if (!controller) {
|
|
68
74
|
return;
|
|
69
75
|
}
|
|
70
|
-
const
|
|
76
|
+
const getResult = () => {
|
|
77
|
+
if (getter) {
|
|
78
|
+
return getter(state);
|
|
79
|
+
}
|
|
80
|
+
if (name) {
|
|
81
|
+
return state[name];
|
|
82
|
+
}
|
|
83
|
+
return "";
|
|
84
|
+
};
|
|
85
|
+
const result = getResult();
|
|
71
86
|
if (controller.value !== result) {
|
|
72
87
|
controller.value = result;
|
|
73
88
|
}
|
|
74
89
|
},
|
|
75
90
|
onDispatch: (state) => {
|
|
76
|
-
const controller =
|
|
91
|
+
const controller = controllerRef.current;
|
|
77
92
|
if (!controller) {
|
|
78
93
|
return;
|
|
79
94
|
}
|
|
@@ -99,7 +114,7 @@ function StoreTextEditor({
|
|
|
99
114
|
TextEditor,
|
|
100
115
|
{
|
|
101
116
|
...props,
|
|
102
|
-
ref,
|
|
117
|
+
ref: controllerRef,
|
|
103
118
|
defaultValue: defaultValue ?? getDefaultValue(),
|
|
104
119
|
onChange: (e) => {
|
|
105
120
|
dispatch();
|
|
@@ -109,6 +124,9 @@ function StoreTextEditor({
|
|
|
109
124
|
);
|
|
110
125
|
}
|
|
111
126
|
|
|
127
|
+
// src/client/editor.tsx
|
|
128
|
+
import { generateMetadata } from "dn-react-toolkit/file/client";
|
|
129
|
+
|
|
112
130
|
// src/crud/crud_form.tsx
|
|
113
131
|
function CrudForm({
|
|
114
132
|
AdminHeader
|
|
@@ -14,8 +14,7 @@ type FormColumnValue<TModel> = {
|
|
|
14
14
|
type FormColumns<TModel> = Partial<{
|
|
15
15
|
[K in keyof TModel]: FormColumnValue<TModel>;
|
|
16
16
|
}>;
|
|
17
|
-
|
|
18
|
-
declare function useFormContext<TModel>(): {
|
|
17
|
+
type FormContextProps<TModel> = {
|
|
19
18
|
name: string;
|
|
20
19
|
item?: TModel;
|
|
21
20
|
store: Store<TModel>;
|
|
@@ -23,6 +22,8 @@ declare function useFormContext<TModel>(): {
|
|
|
23
22
|
delete: () => Promise<void>;
|
|
24
23
|
columns: FormColumns<TModel>;
|
|
25
24
|
};
|
|
25
|
+
declare const FormContext: React__default.Context<{}>;
|
|
26
|
+
declare function useFormContext<TModel>(): FormContextProps<TModel>;
|
|
26
27
|
type CrudFormProps<TModel> = {
|
|
27
28
|
primaryKey: keyof TModel;
|
|
28
29
|
name: string;
|
|
@@ -33,4 +34,4 @@ type CrudFormProps<TModel> = {
|
|
|
33
34
|
};
|
|
34
35
|
declare function CrudFormProvider<TModel>({ primaryKey, name, prefix, item, columns, children, }: CrudFormProps<TModel>): React__default.JSX.Element;
|
|
35
36
|
|
|
36
|
-
export { type CrudFormProps, type FormColumnValue, type FormColumns, FormContext, CrudFormProvider as default, useFormContext };
|
|
37
|
+
export { type CrudFormProps, type FormColumnValue, type FormColumns, FormContext, type FormContextProps, CrudFormProvider as default, useFormContext };
|
|
@@ -14,8 +14,7 @@ type FormColumnValue<TModel> = {
|
|
|
14
14
|
type FormColumns<TModel> = Partial<{
|
|
15
15
|
[K in keyof TModel]: FormColumnValue<TModel>;
|
|
16
16
|
}>;
|
|
17
|
-
|
|
18
|
-
declare function useFormContext<TModel>(): {
|
|
17
|
+
type FormContextProps<TModel> = {
|
|
19
18
|
name: string;
|
|
20
19
|
item?: TModel;
|
|
21
20
|
store: Store<TModel>;
|
|
@@ -23,6 +22,8 @@ declare function useFormContext<TModel>(): {
|
|
|
23
22
|
delete: () => Promise<void>;
|
|
24
23
|
columns: FormColumns<TModel>;
|
|
25
24
|
};
|
|
25
|
+
declare const FormContext: React__default.Context<{}>;
|
|
26
|
+
declare function useFormContext<TModel>(): FormContextProps<TModel>;
|
|
26
27
|
type CrudFormProps<TModel> = {
|
|
27
28
|
primaryKey: keyof TModel;
|
|
28
29
|
name: string;
|
|
@@ -33,4 +34,4 @@ type CrudFormProps<TModel> = {
|
|
|
33
34
|
};
|
|
34
35
|
declare function CrudFormProvider<TModel>({ primaryKey, name, prefix, item, columns, children, }: CrudFormProps<TModel>): React__default.JSX.Element;
|
|
35
36
|
|
|
36
|
-
export { type CrudFormProps, type FormColumnValue, type FormColumns, FormContext, CrudFormProvider as default, useFormContext };
|
|
37
|
+
export { type CrudFormProps, type FormColumnValue, type FormColumns, FormContext, type FormContextProps, CrudFormProvider as default, useFormContext };
|