dn-react-router-toolkit 0.7.7 → 0.7.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.
- package/dist/api/create_api_handler.d.mts +5 -5
- package/dist/api/create_api_handler.d.ts +5 -5
- package/dist/client/env_loader.d.mts +2 -2
- package/dist/client/env_loader.d.ts +2 -2
- package/dist/client/env_loader.js +2 -12
- package/dist/client/env_loader.mjs +2 -2
- package/dist/client/file_input.d.mts +3 -2
- package/dist/client/file_input.d.ts +3 -2
- package/dist/client/file_input.js +30 -37
- package/dist/client/file_input.mjs +33 -28
- package/dist/client/index.d.mts +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +38 -44
- package/dist/client/index.mjs +39 -33
- package/dist/client/store_text_editor.d.mts +2 -2
- package/dist/client/store_text_editor.d.ts +2 -2
- package/dist/client/store_text_editor.js +3 -12
- package/dist/client/store_text_editor.mjs +3 -2
- package/dist/crud/crud_form.d.mts +5 -4
- package/dist/crud/crud_form.d.ts +5 -4
- package/dist/crud/crud_form.js +83 -72
- package/dist/crud/crud_form.mjs +88 -62
- package/dist/crud/crud_form_provider.d.mts +10 -8
- package/dist/crud/crud_form_provider.d.ts +10 -8
- package/dist/crud/crud_form_provider.js +2 -12
- package/dist/crud/crud_form_provider.mjs +6 -3
- package/dist/crud/crud_loader.d.mts +1 -1
- package/dist/crud/crud_loader.d.ts +1 -1
- package/dist/crud/crud_page.d.mts +10 -6
- package/dist/crud/crud_page.d.ts +10 -6
- package/dist/crud/crud_page.js +281 -409
- package/dist/crud/crud_page.mjs +286 -399
- package/dist/crud/generate_pages.d.mts +10 -2
- package/dist/crud/generate_pages.d.ts +10 -2
- package/dist/crud/generate_pages.js +17 -14
- package/dist/crud/generate_pages.mjs +17 -4
- package/dist/crud/index.d.mts +2 -1
- package/dist/crud/index.d.ts +2 -1
- package/dist/crud/index.js +299 -404
- package/dist/crud/index.mjs +304 -404
- package/dist/form/create_form_component.d.mts +3 -2
- package/dist/form/create_form_component.d.ts +3 -2
- package/dist/form/create_form_component.js +3 -12
- package/dist/form/create_form_component.mjs +3 -2
- package/dist/form/form_components.d.mts +5 -4
- package/dist/form/form_components.d.ts +5 -4
- package/dist/form/form_components.js +3 -12
- package/dist/form/form_components.mjs +3 -2
- package/dist/form/index.d.mts +1 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.js +3 -12
- package/dist/form/index.mjs +3 -2
- package/dist/post/editor_toolbar.d.mts +4 -3
- package/dist/post/editor_toolbar.d.ts +4 -3
- package/dist/post/editor_toolbar.js +116 -273
- package/dist/post/editor_toolbar.mjs +123 -263
- package/dist/post/index.d.mts +1 -0
- package/dist/post/index.d.ts +1 -0
- package/dist/post/index.js +329 -411
- package/dist/post/index.mjs +337 -409
- package/dist/post/post_form_page.d.mts +5 -4
- package/dist/post/post_form_page.d.ts +5 -4
- package/dist/post/post_form_page.js +331 -413
- package/dist/post/post_form_page.mjs +337 -409
- package/dist/post/thumbnail_picker.d.mts +3 -2
- package/dist/post/thumbnail_picker.d.ts +3 -2
- package/dist/post/thumbnail_picker.js +14 -23
- package/dist/post/thumbnail_picker.mjs +14 -13
- package/dist/seo/index.d.mts +1 -1
- package/dist/seo/index.d.ts +1 -1
- package/dist/seo/index.js +2 -2
- package/dist/seo/index.mjs +2 -2
- package/dist/seo/seo.d.mts +2 -2
- package/dist/seo/seo.d.ts +2 -2
- package/dist/seo/seo.js +2 -2
- package/dist/seo/seo.mjs +2 -2
- package/dist/table/buttons.d.mts +2 -2
- package/dist/table/buttons.d.ts +2 -2
- package/dist/table/buttons.js +42 -57
- package/dist/table/buttons.mjs +42 -47
- package/dist/table/index.d.mts +1 -0
- package/dist/table/index.d.ts +1 -0
- package/dist/table/index.js +185 -338
- package/dist/table/index.mjs +185 -328
- package/dist/table/page.d.mts +5 -4
- package/dist/table/page.d.ts +5 -4
- package/dist/table/page.js +185 -338
- package/dist/table/page.mjs +185 -328
- package/dist/table/table.d.mts +5 -4
- package/dist/table/table.d.ts +5 -4
- package/dist/table/table.js +77 -237
- package/dist/table/table.mjs +77 -227
- package/package.json +7 -5
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/client/store_text_editor.tsx
|
|
@@ -35,7 +25,8 @@ __export(store_text_editor_exports, {
|
|
|
35
25
|
module.exports = __toCommonJS(store_text_editor_exports);
|
|
36
26
|
var import_dn_react_text_editor = require("dn-react-text-editor");
|
|
37
27
|
var import_react_store_input = require("react-store-input");
|
|
38
|
-
var import_react =
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
30
|
function StoreTextEditor({
|
|
40
31
|
store,
|
|
41
32
|
name,
|
|
@@ -94,7 +85,7 @@ function StoreTextEditor({
|
|
|
94
85
|
}
|
|
95
86
|
return void 0;
|
|
96
87
|
};
|
|
97
|
-
return /* @__PURE__ */
|
|
88
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
89
|
import_dn_react_text_editor.TextEditor,
|
|
99
90
|
{
|
|
100
91
|
...props,
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
TextEditor
|
|
4
4
|
} from "dn-react-text-editor";
|
|
5
5
|
import { useStoreController } from "react-store-input";
|
|
6
|
-
import
|
|
6
|
+
import { useImperativeHandle, useRef } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
function StoreTextEditor({
|
|
8
9
|
store,
|
|
9
10
|
name,
|
|
@@ -62,7 +63,7 @@ function StoreTextEditor({
|
|
|
62
63
|
}
|
|
63
64
|
return void 0;
|
|
64
65
|
};
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
66
67
|
TextEditor,
|
|
67
68
|
{
|
|
68
69
|
...props,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
type Props = {
|
|
4
|
-
AdminHeader:
|
|
5
|
+
AdminHeader: FC<{
|
|
5
6
|
title: string;
|
|
6
|
-
actions?:
|
|
7
|
+
actions?: ReactNode;
|
|
7
8
|
}>;
|
|
8
9
|
};
|
|
9
|
-
declare function CrudForm<TModel extends Record<string, unknown>>({ AdminHeader, }: Props):
|
|
10
|
+
declare function CrudForm<TModel extends Record<string, unknown>>({ AdminHeader, }: Props): react_jsx_runtime.JSX.Element;
|
|
10
11
|
|
|
11
12
|
export { CrudForm as default };
|
package/dist/crud/crud_form.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
type Props = {
|
|
4
|
-
AdminHeader:
|
|
5
|
+
AdminHeader: FC<{
|
|
5
6
|
title: string;
|
|
6
|
-
actions?:
|
|
7
|
+
actions?: ReactNode;
|
|
7
8
|
}>;
|
|
8
9
|
};
|
|
9
|
-
declare function CrudForm<TModel extends Record<string, unknown>>({ AdminHeader, }: Props):
|
|
10
|
+
declare function CrudForm<TModel extends Record<string, unknown>>({ AdminHeader, }: Props): react_jsx_runtime.JSX.Element;
|
|
10
11
|
|
|
11
12
|
export { CrudForm as default };
|
package/dist/crud/crud_form.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/crud/crud_form.tsx
|
|
@@ -38,22 +28,20 @@ module.exports = __toCommonJS(crud_form_exports);
|
|
|
38
28
|
var import_react_router = require("react-router");
|
|
39
29
|
var import_react_store_input = require("react-store-input");
|
|
40
30
|
var import_react = require("react");
|
|
41
|
-
var
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
32
|
var FormContext = (0, import_react.createContext)({});
|
|
43
33
|
function useFormContext() {
|
|
44
34
|
return (0, import_react.useContext)(FormContext);
|
|
45
35
|
}
|
|
46
36
|
|
|
47
|
-
// src/crud/crud_form.tsx
|
|
48
|
-
var import_react8 = __toESM(require("react"));
|
|
49
|
-
|
|
50
37
|
// src/form/create_form_component.tsx
|
|
51
38
|
var import_utils = require("dn-react-toolkit/utils");
|
|
52
|
-
var
|
|
39
|
+
var import_react2 = require("react");
|
|
40
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
53
41
|
function createComponent(tag, options) {
|
|
54
42
|
return function FormComponent({ className, ...props }) {
|
|
55
43
|
const Tag = tag;
|
|
56
|
-
return /* @__PURE__ */
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Tag, { ...props, className: (0, import_utils.cn)(options.className, className) });
|
|
57
45
|
};
|
|
58
46
|
}
|
|
59
47
|
|
|
@@ -72,12 +60,12 @@ var FormLabel = createComponent("label", {
|
|
|
72
60
|
var import_react_store_input3 = require("react-store-input");
|
|
73
61
|
|
|
74
62
|
// src/client/env_loader.tsx
|
|
75
|
-
var import_react4 = __toESM(require("react"));
|
|
76
63
|
var import_react_router2 = require("react-router");
|
|
64
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
77
65
|
|
|
78
66
|
// src/client/file_input.tsx
|
|
79
|
-
var
|
|
80
|
-
var
|
|
67
|
+
var import_react3 = require("react");
|
|
68
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
81
69
|
|
|
82
70
|
// src/client/use_user_agent.tsx
|
|
83
71
|
var import_react_router3 = require("react-router");
|
|
@@ -85,7 +73,8 @@ var import_react_router3 = require("react-router");
|
|
|
85
73
|
// src/client/store_text_editor.tsx
|
|
86
74
|
var import_dn_react_text_editor = require("dn-react-text-editor");
|
|
87
75
|
var import_react_store_input2 = require("react-store-input");
|
|
88
|
-
var
|
|
76
|
+
var import_react4 = require("react");
|
|
77
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
89
78
|
function StoreTextEditor({
|
|
90
79
|
store,
|
|
91
80
|
name,
|
|
@@ -95,8 +84,8 @@ function StoreTextEditor({
|
|
|
95
84
|
ref,
|
|
96
85
|
...props
|
|
97
86
|
}) {
|
|
98
|
-
const controllerRef = (0,
|
|
99
|
-
(0,
|
|
87
|
+
const controllerRef = (0, import_react4.useRef)(null);
|
|
88
|
+
(0, import_react4.useImperativeHandle)(
|
|
100
89
|
ref,
|
|
101
90
|
() => controllerRef.current,
|
|
102
91
|
[]
|
|
@@ -144,7 +133,7 @@ function StoreTextEditor({
|
|
|
144
133
|
}
|
|
145
134
|
return void 0;
|
|
146
135
|
};
|
|
147
|
-
return /* @__PURE__ */
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
148
137
|
import_dn_react_text_editor.TextEditor,
|
|
149
138
|
{
|
|
150
139
|
...props,
|
|
@@ -162,65 +151,87 @@ function StoreTextEditor({
|
|
|
162
151
|
var import_client = require("dn-react-toolkit/file/client");
|
|
163
152
|
|
|
164
153
|
// src/crud/crud_form.tsx
|
|
154
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
165
155
|
function CrudForm({
|
|
166
156
|
AdminHeader
|
|
167
157
|
}) {
|
|
168
158
|
const form = useFormContext();
|
|
169
159
|
const component = (0, import_react_store_input3.useStoreComponent)(form.store);
|
|
170
|
-
return /* @__PURE__ */
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
162
|
+
AdminHeader,
|
|
163
|
+
{
|
|
164
|
+
title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
|
|
165
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
166
|
+
form.item && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
167
|
+
"button",
|
|
168
|
+
{
|
|
169
|
+
type: "button",
|
|
170
|
+
className: "button-outline",
|
|
171
|
+
onClick: () => {
|
|
172
|
+
form.delete();
|
|
173
|
+
},
|
|
174
|
+
children: "\uC0AD\uC81C\uD558\uAE30"
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
178
|
+
"button",
|
|
179
|
+
{
|
|
180
|
+
type: "button",
|
|
181
|
+
className: "button-primary",
|
|
182
|
+
onClick: form.submit,
|
|
183
|
+
children: "\uC800\uC7A5\uD558\uAE30"
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] })
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: Object.entries(form.columns).map(
|
|
190
|
+
([name, value]) => {
|
|
191
|
+
function InputComponent() {
|
|
192
|
+
if (value.component) {
|
|
193
|
+
const Component = value.component;
|
|
194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component, { store: form.store, name });
|
|
181
195
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
if (value.type === "textarea") {
|
|
197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
198
|
+
StoreTextEditor,
|
|
199
|
+
{
|
|
200
|
+
store: form.store,
|
|
201
|
+
name,
|
|
202
|
+
editor: {
|
|
203
|
+
attributes: {
|
|
204
|
+
class: "text-editor-form"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
if (value.options) {
|
|
211
|
+
const Component = value.options;
|
|
212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(component.select, { name, className: "select-form", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component, {}) });
|
|
213
|
+
}
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
215
|
+
component.input,
|
|
200
216
|
{
|
|
201
|
-
|
|
202
|
-
|
|
217
|
+
name,
|
|
218
|
+
type: value.type,
|
|
219
|
+
className: "input-form"
|
|
203
220
|
}
|
|
204
221
|
);
|
|
205
222
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return /* @__PURE__ */
|
|
223
|
+
const v = form.store.state[name];
|
|
224
|
+
if (typeof v === "boolean") {
|
|
225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex", children: [
|
|
226
|
+
value.label,
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ml-auto", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InputComponent, {}) })
|
|
228
|
+
] });
|
|
209
229
|
}
|
|
210
|
-
return /* @__PURE__ */
|
|
211
|
-
|
|
212
|
-
{
|
|
213
|
-
|
|
214
|
-
type: value.type,
|
|
215
|
-
className: "input-form"
|
|
216
|
-
}
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
const v = form.store.state[name];
|
|
220
|
-
if (typeof v === "boolean") {
|
|
221
|
-
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "flex" }, value.label, /* @__PURE__ */ import_react8.default.createElement("div", { className: "ml-auto" }, /* @__PURE__ */ import_react8.default.createElement(InputComponent, null)));
|
|
230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormRow, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(FormEntry, { children: [
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormLabel, { children: value.label }, name),
|
|
232
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InputComponent, {})
|
|
233
|
+
] }) });
|
|
222
234
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
))));
|
|
235
|
+
) }) })
|
|
236
|
+
] });
|
|
226
237
|
}
|
package/dist/crud/crud_form.mjs
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
// src/crud/crud_form_provider.tsx
|
|
2
2
|
import { useNavigate } from "react-router";
|
|
3
3
|
import { useStore } from "react-store-input";
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useContext
|
|
7
|
+
} from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
9
|
var FormContext = createContext({});
|
|
7
10
|
function useFormContext() {
|
|
8
11
|
return useContext(FormContext);
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
// src/crud/crud_form.tsx
|
|
12
|
-
import React6 from "react";
|
|
13
|
-
|
|
14
14
|
// src/form/create_form_component.tsx
|
|
15
15
|
import { cn } from "dn-react-toolkit/utils";
|
|
16
|
-
import
|
|
16
|
+
import "react";
|
|
17
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
17
18
|
function createComponent(tag, options) {
|
|
18
19
|
return function FormComponent({ className, ...props }) {
|
|
19
20
|
const Tag = tag;
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ jsx2(Tag, { ...props, className: cn(options.className, className) });
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -36,12 +37,14 @@ var FormLabel = createComponent("label", {
|
|
|
36
37
|
import { useStoreComponent } from "react-store-input";
|
|
37
38
|
|
|
38
39
|
// src/client/env_loader.tsx
|
|
39
|
-
import React3 from "react";
|
|
40
40
|
import { useRouteLoaderData } from "react-router";
|
|
41
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
41
42
|
|
|
42
43
|
// src/client/file_input.tsx
|
|
43
|
-
import
|
|
44
|
-
|
|
44
|
+
import {
|
|
45
|
+
useRef
|
|
46
|
+
} from "react";
|
|
47
|
+
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
45
48
|
|
|
46
49
|
// src/client/use_user_agent.tsx
|
|
47
50
|
import { useRouteLoaderData as useRouteLoaderData2 } from "react-router";
|
|
@@ -51,7 +54,8 @@ import {
|
|
|
51
54
|
TextEditor
|
|
52
55
|
} from "dn-react-text-editor";
|
|
53
56
|
import { useStoreController } from "react-store-input";
|
|
54
|
-
import
|
|
57
|
+
import { useImperativeHandle, useRef as useRef2 } from "react";
|
|
58
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
55
59
|
function StoreTextEditor({
|
|
56
60
|
store,
|
|
57
61
|
name,
|
|
@@ -61,7 +65,7 @@ function StoreTextEditor({
|
|
|
61
65
|
ref,
|
|
62
66
|
...props
|
|
63
67
|
}) {
|
|
64
|
-
const controllerRef =
|
|
68
|
+
const controllerRef = useRef2(null);
|
|
65
69
|
useImperativeHandle(
|
|
66
70
|
ref,
|
|
67
71
|
() => controllerRef.current,
|
|
@@ -110,7 +114,7 @@ function StoreTextEditor({
|
|
|
110
114
|
}
|
|
111
115
|
return void 0;
|
|
112
116
|
};
|
|
113
|
-
return /* @__PURE__ */
|
|
117
|
+
return /* @__PURE__ */ jsx5(
|
|
114
118
|
TextEditor,
|
|
115
119
|
{
|
|
116
120
|
...props,
|
|
@@ -128,67 +132,89 @@ function StoreTextEditor({
|
|
|
128
132
|
import { generateMetadata } from "dn-react-toolkit/file/client";
|
|
129
133
|
|
|
130
134
|
// src/crud/crud_form.tsx
|
|
135
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
131
136
|
function CrudForm({
|
|
132
137
|
AdminHeader
|
|
133
138
|
}) {
|
|
134
139
|
const form = useFormContext();
|
|
135
140
|
const component = useStoreComponent(form.store);
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
142
|
+
/* @__PURE__ */ jsx6(
|
|
143
|
+
AdminHeader,
|
|
144
|
+
{
|
|
145
|
+
title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
|
|
146
|
+
actions: /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
147
|
+
form.item && /* @__PURE__ */ jsx6(
|
|
148
|
+
"button",
|
|
149
|
+
{
|
|
150
|
+
type: "button",
|
|
151
|
+
className: "button-outline",
|
|
152
|
+
onClick: () => {
|
|
153
|
+
form.delete();
|
|
154
|
+
},
|
|
155
|
+
children: "\uC0AD\uC81C\uD558\uAE30"
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ jsx6(
|
|
159
|
+
"button",
|
|
160
|
+
{
|
|
161
|
+
type: "button",
|
|
162
|
+
className: "button-primary",
|
|
163
|
+
onClick: form.submit,
|
|
164
|
+
children: "\uC800\uC7A5\uD558\uAE30"
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] })
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
/* @__PURE__ */ jsx6("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ jsx6(Fragment2, { children: Object.entries(form.columns).map(
|
|
171
|
+
([name, value]) => {
|
|
172
|
+
function InputComponent() {
|
|
173
|
+
if (value.component) {
|
|
174
|
+
const Component = value.component;
|
|
175
|
+
return /* @__PURE__ */ jsx6(Component, { store: form.store, name });
|
|
147
176
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
177
|
+
if (value.type === "textarea") {
|
|
178
|
+
return /* @__PURE__ */ jsx6(
|
|
179
|
+
StoreTextEditor,
|
|
180
|
+
{
|
|
181
|
+
store: form.store,
|
|
182
|
+
name,
|
|
183
|
+
editor: {
|
|
184
|
+
attributes: {
|
|
185
|
+
class: "text-editor-form"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
if (value.options) {
|
|
192
|
+
const Component = value.options;
|
|
193
|
+
return /* @__PURE__ */ jsx6(component.select, { name, className: "select-form", children: /* @__PURE__ */ jsx6(Component, {}) });
|
|
194
|
+
}
|
|
195
|
+
return /* @__PURE__ */ jsx6(
|
|
196
|
+
component.input,
|
|
166
197
|
{
|
|
167
|
-
|
|
168
|
-
|
|
198
|
+
name,
|
|
199
|
+
type: value.type,
|
|
200
|
+
className: "input-form"
|
|
169
201
|
}
|
|
170
202
|
);
|
|
171
203
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return /* @__PURE__ */
|
|
204
|
+
const v = form.store.state[name];
|
|
205
|
+
if (typeof v === "boolean") {
|
|
206
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex", children: [
|
|
207
|
+
value.label,
|
|
208
|
+
/* @__PURE__ */ jsx6("div", { className: "ml-auto", children: /* @__PURE__ */ jsx6(InputComponent, {}) })
|
|
209
|
+
] });
|
|
175
210
|
}
|
|
176
|
-
return /* @__PURE__ */
|
|
177
|
-
|
|
178
|
-
{
|
|
179
|
-
|
|
180
|
-
type: value.type,
|
|
181
|
-
className: "input-form"
|
|
182
|
-
}
|
|
183
|
-
);
|
|
211
|
+
return /* @__PURE__ */ jsx6(FormRow, { children: /* @__PURE__ */ jsxs2(FormEntry, { children: [
|
|
212
|
+
/* @__PURE__ */ jsx6(FormLabel, { children: value.label }, name),
|
|
213
|
+
/* @__PURE__ */ jsx6(InputComponent, {})
|
|
214
|
+
] }) });
|
|
184
215
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return /* @__PURE__ */ React6.createElement("div", { className: "flex" }, value.label, /* @__PURE__ */ React6.createElement("div", { className: "ml-auto" }, /* @__PURE__ */ React6.createElement(InputComponent, null)));
|
|
188
|
-
}
|
|
189
|
-
return /* @__PURE__ */ React6.createElement(FormRow, null, /* @__PURE__ */ React6.createElement(FormEntry, null, /* @__PURE__ */ React6.createElement(FormLabel, { key: name }, value.label), /* @__PURE__ */ React6.createElement(InputComponent, null)));
|
|
190
|
-
}
|
|
191
|
-
))));
|
|
216
|
+
) }) })
|
|
217
|
+
] });
|
|
192
218
|
}
|
|
193
219
|
export {
|
|
194
220
|
CrudForm as default
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { HTMLInputTypeAttribute, FC, ReactNode } from 'react';
|
|
1
4
|
import { Store } from 'react-store-input';
|
|
2
|
-
import React__default from 'react';
|
|
3
5
|
|
|
4
6
|
type FormColumnValue<TModel> = {
|
|
5
7
|
label?: string;
|
|
6
|
-
type?:
|
|
8
|
+
type?: HTMLInputTypeAttribute | "textarea";
|
|
7
9
|
defaultValue?: TModel[keyof TModel];
|
|
8
|
-
component?:
|
|
10
|
+
component?: FC<{
|
|
9
11
|
store: Store<TModel>;
|
|
10
|
-
|
|
12
|
+
name: string;
|
|
11
13
|
}>;
|
|
12
|
-
options?:
|
|
14
|
+
options?: FC;
|
|
13
15
|
};
|
|
14
16
|
type FormColumns<TModel> = Partial<{
|
|
15
17
|
[K in keyof TModel]: FormColumnValue<TModel>;
|
|
@@ -22,7 +24,7 @@ type FormContextProps<TModel> = {
|
|
|
22
24
|
delete: () => Promise<void>;
|
|
23
25
|
columns: FormColumns<TModel>;
|
|
24
26
|
};
|
|
25
|
-
declare const FormContext:
|
|
27
|
+
declare const FormContext: react.Context<{}>;
|
|
26
28
|
declare function useFormContext<TModel>(): FormContextProps<TModel>;
|
|
27
29
|
type CrudFormProps<TModel> = {
|
|
28
30
|
primaryKey?: keyof TModel;
|
|
@@ -30,8 +32,8 @@ type CrudFormProps<TModel> = {
|
|
|
30
32
|
prefix: string;
|
|
31
33
|
item?: TModel;
|
|
32
34
|
columns?: FormColumns<TModel>;
|
|
33
|
-
children?:
|
|
35
|
+
children?: ReactNode;
|
|
34
36
|
};
|
|
35
|
-
declare function CrudFormProvider<TModel>({ primaryKey, name, prefix, item, columns, children, }: CrudFormProps<TModel>):
|
|
37
|
+
declare function CrudFormProvider<TModel>({ primaryKey, name, prefix, item, columns, children, }: CrudFormProps<TModel>): react_jsx_runtime.JSX.Element;
|
|
36
38
|
|
|
37
39
|
export { type CrudFormProps, type FormColumnValue, type FormColumns, FormContext, type FormContextProps, CrudFormProvider as default, useFormContext };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { HTMLInputTypeAttribute, FC, ReactNode } from 'react';
|
|
1
4
|
import { Store } from 'react-store-input';
|
|
2
|
-
import React__default from 'react';
|
|
3
5
|
|
|
4
6
|
type FormColumnValue<TModel> = {
|
|
5
7
|
label?: string;
|
|
6
|
-
type?:
|
|
8
|
+
type?: HTMLInputTypeAttribute | "textarea";
|
|
7
9
|
defaultValue?: TModel[keyof TModel];
|
|
8
|
-
component?:
|
|
10
|
+
component?: FC<{
|
|
9
11
|
store: Store<TModel>;
|
|
10
|
-
|
|
12
|
+
name: string;
|
|
11
13
|
}>;
|
|
12
|
-
options?:
|
|
14
|
+
options?: FC;
|
|
13
15
|
};
|
|
14
16
|
type FormColumns<TModel> = Partial<{
|
|
15
17
|
[K in keyof TModel]: FormColumnValue<TModel>;
|
|
@@ -22,7 +24,7 @@ type FormContextProps<TModel> = {
|
|
|
22
24
|
delete: () => Promise<void>;
|
|
23
25
|
columns: FormColumns<TModel>;
|
|
24
26
|
};
|
|
25
|
-
declare const FormContext:
|
|
27
|
+
declare const FormContext: react.Context<{}>;
|
|
26
28
|
declare function useFormContext<TModel>(): FormContextProps<TModel>;
|
|
27
29
|
type CrudFormProps<TModel> = {
|
|
28
30
|
primaryKey?: keyof TModel;
|
|
@@ -30,8 +32,8 @@ type CrudFormProps<TModel> = {
|
|
|
30
32
|
prefix: string;
|
|
31
33
|
item?: TModel;
|
|
32
34
|
columns?: FormColumns<TModel>;
|
|
33
|
-
children?:
|
|
35
|
+
children?: ReactNode;
|
|
34
36
|
};
|
|
35
|
-
declare function CrudFormProvider<TModel>({ primaryKey, name, prefix, item, columns, children, }: CrudFormProps<TModel>):
|
|
37
|
+
declare function CrudFormProvider<TModel>({ primaryKey, name, prefix, item, columns, children, }: CrudFormProps<TModel>): react_jsx_runtime.JSX.Element;
|
|
36
38
|
|
|
37
39
|
export { type CrudFormProps, type FormColumnValue, type FormColumns, FormContext, type FormContextProps, CrudFormProvider as default, useFormContext };
|