dn-react-router-toolkit 0.5.3 → 0.5.5
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/crud/crud_form.js +62 -18
- package/dist/crud/crud_form.mjs +68 -19
- package/dist/crud/crud_form_provider.d.mts +11 -7
- package/dist/crud/crud_form_provider.d.ts +11 -7
- package/dist/crud/crud_form_provider.js +50 -52
- package/dist/crud/crud_form_provider.mjs +50 -52
- package/dist/crud/crud_page.d.mts +0 -1
- package/dist/crud/crud_page.d.ts +0 -1
- package/dist/crud/crud_page.js +112 -70
- package/dist/crud/crud_page.mjs +118 -71
- package/dist/crud/generate_pages.d.mts +0 -1
- package/dist/crud/generate_pages.d.ts +0 -1
- package/dist/crud/index.d.mts +1 -1
- package/dist/crud/index.d.ts +1 -1
- package/dist/crud/index.js +118 -76
- package/dist/crud/index.mjs +118 -71
- package/package.json +1 -1
package/dist/crud/index.js
CHANGED
|
@@ -69,58 +69,56 @@ function CrudFormProvider({
|
|
|
69
69
|
"Content-Type": "application/json"
|
|
70
70
|
},
|
|
71
71
|
body: JSON.stringify(
|
|
72
|
-
Object.entries(store.state).reduce(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
{}
|
|
123
|
-
)
|
|
72
|
+
Object.entries(store.state).reduce(function reducer(acc, [key, value]) {
|
|
73
|
+
const converter = (value2) => {
|
|
74
|
+
if (value2 === void 0) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
if (value2 === null) {
|
|
78
|
+
return {
|
|
79
|
+
type: "null",
|
|
80
|
+
value: null
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (typeof value2 === "string") {
|
|
84
|
+
return {
|
|
85
|
+
type: "string",
|
|
86
|
+
value: value2
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (typeof value2 === "number") {
|
|
90
|
+
return {
|
|
91
|
+
type: "number",
|
|
92
|
+
value: value2
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (typeof value2 === "boolean") {
|
|
96
|
+
return {
|
|
97
|
+
type: "boolean",
|
|
98
|
+
value: value2
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (value2 instanceof Date) {
|
|
102
|
+
return {
|
|
103
|
+
type: "date",
|
|
104
|
+
value: value2.toISOString()
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (Array.isArray(value2)) {
|
|
108
|
+
return value2.map((v) => converter(v));
|
|
109
|
+
}
|
|
110
|
+
if (typeof value2 === "object") {
|
|
111
|
+
return Object.entries(value2).reduce(
|
|
112
|
+
reducer,
|
|
113
|
+
{}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return {
|
|
118
|
+
...acc,
|
|
119
|
+
[key]: converter(value)
|
|
120
|
+
};
|
|
121
|
+
}, {})
|
|
124
122
|
)
|
|
125
123
|
});
|
|
126
124
|
if (!res.ok) {
|
|
@@ -163,33 +161,77 @@ function CrudFormProvider({
|
|
|
163
161
|
// src/crud/crud_form.tsx
|
|
164
162
|
var import_store2 = require("dn-react-toolkit/store");
|
|
165
163
|
var import_react3 = __toESM(require("react"));
|
|
164
|
+
var import_utils = require("dn-react-toolkit/utils");
|
|
165
|
+
var import_text_editor = require("dn-react-toolkit/text_editor");
|
|
166
|
+
var textarea = (0, import_text_editor.createTextEditor)();
|
|
166
167
|
function CrudForm({ AdminLayout }) {
|
|
167
168
|
const form = useFormContext();
|
|
168
169
|
return /* @__PURE__ */ import_react3.default.createElement(
|
|
169
170
|
AdminLayout,
|
|
170
171
|
{
|
|
171
172
|
title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
|
|
172
|
-
actions: /* @__PURE__ */ import_react3.default.createElement(
|
|
173
|
-
"button",
|
|
174
|
-
{
|
|
175
|
-
type: "button",
|
|
176
|
-
className: "button-primary",
|
|
177
|
-
onClick: form.submit
|
|
178
|
-
},
|
|
179
|
-
"\uC800\uC7A5\uD558\uAE30"
|
|
180
|
-
),
|
|
173
|
+
actions: /* @__PURE__ */ import_react3.default.createElement("button", { type: "button", className: "button-primary", onClick: form.submit }, "\uC800\uC7A5\uD558\uAE30"),
|
|
181
174
|
className: "max-w-3xl mx-auto"
|
|
182
175
|
},
|
|
183
|
-
Object.keys(form.columns).length > 0 && /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, Object.entries(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
property: key
|
|
189
|
-
|
|
176
|
+
Object.keys(form.columns).length > 0 && /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, Object.entries(
|
|
177
|
+
form.columns
|
|
178
|
+
).map(([key, value]) => {
|
|
179
|
+
const createComponent = () => {
|
|
180
|
+
if (value.component) {
|
|
181
|
+
return /* @__PURE__ */ import_react3.default.createElement(value.component, { store: form.store, property: key });
|
|
182
|
+
}
|
|
183
|
+
if (value.type === "checkbox") {
|
|
184
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_store2.SyncSwitch, { store: form.store, property: key });
|
|
185
|
+
}
|
|
186
|
+
if (value.type === "datetime") {
|
|
187
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
188
|
+
import_store2.SyncInput,
|
|
189
|
+
{
|
|
190
|
+
store: form.store,
|
|
191
|
+
property: key,
|
|
192
|
+
className: "input-form",
|
|
193
|
+
type: "datetime-local",
|
|
194
|
+
serializer: (value2) => {
|
|
195
|
+
if (value2 instanceof Date) {
|
|
196
|
+
return (0, import_utils.moment)(value2).toISOString(true).slice(0, 16);
|
|
197
|
+
}
|
|
198
|
+
return String(value2);
|
|
199
|
+
},
|
|
200
|
+
deserializer: (value2) => {
|
|
201
|
+
if (!value2) {
|
|
202
|
+
return void 0;
|
|
203
|
+
}
|
|
204
|
+
return (0, import_utils.moment)(value2).toDate();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
if (value.type === "textarea") {
|
|
210
|
+
const Editor = (0, import_store2.useSyncTextEditor)(textarea);
|
|
211
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
212
|
+
Editor.SyncTextEditor,
|
|
213
|
+
{
|
|
214
|
+
store: form.store,
|
|
215
|
+
property: key
|
|
216
|
+
}
|
|
217
|
+
);
|
|
190
218
|
}
|
|
191
|
-
|
|
192
|
-
|
|
219
|
+
if (value.options) {
|
|
220
|
+
const Component = value.options;
|
|
221
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_store2.SyncSelect, { store: form.store, property: key }, /* @__PURE__ */ import_react3.default.createElement(Component, null));
|
|
222
|
+
}
|
|
223
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
224
|
+
import_store2.SyncInput,
|
|
225
|
+
{
|
|
226
|
+
store: form.store,
|
|
227
|
+
property: key,
|
|
228
|
+
type: value.type,
|
|
229
|
+
className: "input-form"
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
};
|
|
233
|
+
return /* @__PURE__ */ import_react3.default.createElement("label", { key }, value.label, createComponent());
|
|
234
|
+
})),
|
|
193
235
|
form.item && /* @__PURE__ */ import_react3.default.createElement(
|
|
194
236
|
"button",
|
|
195
237
|
{
|
|
@@ -632,7 +674,7 @@ function GoSearch(props) {
|
|
|
632
674
|
}
|
|
633
675
|
|
|
634
676
|
// src/table/buttons.tsx
|
|
635
|
-
var
|
|
677
|
+
var import_utils2 = require("dn-react-toolkit/utils");
|
|
636
678
|
var import_react_router4 = require("react-router");
|
|
637
679
|
var import_react6 = __toESM(require("react"));
|
|
638
680
|
function TablePageButtons({
|
|
@@ -677,7 +719,7 @@ function TablePageButtons({
|
|
|
677
719
|
);
|
|
678
720
|
return `${pathname}?${searchParams.toString()}`;
|
|
679
721
|
})(),
|
|
680
|
-
className: (0,
|
|
722
|
+
className: (0, import_utils2.cn)(
|
|
681
723
|
"w-6 block text-center transition-colors",
|
|
682
724
|
currentPage === startButton + index2 + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
683
725
|
)
|
|
@@ -701,7 +743,7 @@ function TablePageButtons({
|
|
|
701
743
|
}
|
|
702
744
|
|
|
703
745
|
// src/table/table.tsx
|
|
704
|
-
var
|
|
746
|
+
var import_utils3 = require("dn-react-toolkit/utils");
|
|
705
747
|
var import_react_router5 = require("react-router");
|
|
706
748
|
var import_react7 = __toESM(require("react"));
|
|
707
749
|
function Table({
|
|
@@ -721,7 +763,7 @@ function Table({
|
|
|
721
763
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
722
764
|
"table",
|
|
723
765
|
{
|
|
724
|
-
className: (0,
|
|
766
|
+
className: (0, import_utils3.cn)(
|
|
725
767
|
className,
|
|
726
768
|
"text-[15px] border-separate border-spacing-0"
|
|
727
769
|
)
|
|
@@ -740,7 +782,7 @@ function Table({
|
|
|
740
782
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
741
783
|
"button",
|
|
742
784
|
{
|
|
743
|
-
className: (0,
|
|
785
|
+
className: (0, import_utils3.cn)(
|
|
744
786
|
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
745
787
|
"px-4 h-14 flex items-center w-full"
|
|
746
788
|
),
|
|
@@ -765,7 +807,7 @@ function Table({
|
|
|
765
807
|
"th",
|
|
766
808
|
{
|
|
767
809
|
key,
|
|
768
|
-
className: (0,
|
|
810
|
+
className: (0, import_utils3.cn)("border-y font-normal")
|
|
769
811
|
},
|
|
770
812
|
/* @__PURE__ */ import_react7.default.createElement(Head, null)
|
|
771
813
|
);
|
package/dist/crud/index.mjs
CHANGED
|
@@ -27,58 +27,56 @@ function CrudFormProvider({
|
|
|
27
27
|
"Content-Type": "application/json"
|
|
28
28
|
},
|
|
29
29
|
body: JSON.stringify(
|
|
30
|
-
Object.entries(store.state).reduce(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{}
|
|
81
|
-
)
|
|
30
|
+
Object.entries(store.state).reduce(function reducer(acc, [key, value]) {
|
|
31
|
+
const converter = (value2) => {
|
|
32
|
+
if (value2 === void 0) {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
if (value2 === null) {
|
|
36
|
+
return {
|
|
37
|
+
type: "null",
|
|
38
|
+
value: null
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (typeof value2 === "string") {
|
|
42
|
+
return {
|
|
43
|
+
type: "string",
|
|
44
|
+
value: value2
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (typeof value2 === "number") {
|
|
48
|
+
return {
|
|
49
|
+
type: "number",
|
|
50
|
+
value: value2
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (typeof value2 === "boolean") {
|
|
54
|
+
return {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
value: value2
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (value2 instanceof Date) {
|
|
60
|
+
return {
|
|
61
|
+
type: "date",
|
|
62
|
+
value: value2.toISOString()
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (Array.isArray(value2)) {
|
|
66
|
+
return value2.map((v) => converter(v));
|
|
67
|
+
}
|
|
68
|
+
if (typeof value2 === "object") {
|
|
69
|
+
return Object.entries(value2).reduce(
|
|
70
|
+
reducer,
|
|
71
|
+
{}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
...acc,
|
|
77
|
+
[key]: converter(value)
|
|
78
|
+
};
|
|
79
|
+
}, {})
|
|
82
80
|
)
|
|
83
81
|
});
|
|
84
82
|
if (!res.ok) {
|
|
@@ -119,35 +117,84 @@ function CrudFormProvider({
|
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
// src/crud/crud_form.tsx
|
|
122
|
-
import {
|
|
120
|
+
import {
|
|
121
|
+
SyncInput,
|
|
122
|
+
SyncSelect,
|
|
123
|
+
SyncSwitch,
|
|
124
|
+
useSyncTextEditor
|
|
125
|
+
} from "dn-react-toolkit/store";
|
|
123
126
|
import React2 from "react";
|
|
127
|
+
import { moment } from "dn-react-toolkit/utils";
|
|
128
|
+
import { createTextEditor } from "dn-react-toolkit/text_editor";
|
|
129
|
+
var textarea = createTextEditor();
|
|
124
130
|
function CrudForm({ AdminLayout }) {
|
|
125
131
|
const form = useFormContext();
|
|
126
132
|
return /* @__PURE__ */ React2.createElement(
|
|
127
133
|
AdminLayout,
|
|
128
134
|
{
|
|
129
135
|
title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
|
|
130
|
-
actions: /* @__PURE__ */ React2.createElement(
|
|
131
|
-
"button",
|
|
132
|
-
{
|
|
133
|
-
type: "button",
|
|
134
|
-
className: "button-primary",
|
|
135
|
-
onClick: form.submit
|
|
136
|
-
},
|
|
137
|
-
"\uC800\uC7A5\uD558\uAE30"
|
|
138
|
-
),
|
|
136
|
+
actions: /* @__PURE__ */ React2.createElement("button", { type: "button", className: "button-primary", onClick: form.submit }, "\uC800\uC7A5\uD558\uAE30"),
|
|
139
137
|
className: "max-w-3xl mx-auto"
|
|
140
138
|
},
|
|
141
|
-
Object.keys(form.columns).length > 0 && /* @__PURE__ */ React2.createElement(React2.Fragment, null, Object.entries(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
property: key
|
|
147
|
-
|
|
139
|
+
Object.keys(form.columns).length > 0 && /* @__PURE__ */ React2.createElement(React2.Fragment, null, Object.entries(
|
|
140
|
+
form.columns
|
|
141
|
+
).map(([key, value]) => {
|
|
142
|
+
const createComponent = () => {
|
|
143
|
+
if (value.component) {
|
|
144
|
+
return /* @__PURE__ */ React2.createElement(value.component, { store: form.store, property: key });
|
|
145
|
+
}
|
|
146
|
+
if (value.type === "checkbox") {
|
|
147
|
+
return /* @__PURE__ */ React2.createElement(SyncSwitch, { store: form.store, property: key });
|
|
148
|
+
}
|
|
149
|
+
if (value.type === "datetime") {
|
|
150
|
+
return /* @__PURE__ */ React2.createElement(
|
|
151
|
+
SyncInput,
|
|
152
|
+
{
|
|
153
|
+
store: form.store,
|
|
154
|
+
property: key,
|
|
155
|
+
className: "input-form",
|
|
156
|
+
type: "datetime-local",
|
|
157
|
+
serializer: (value2) => {
|
|
158
|
+
if (value2 instanceof Date) {
|
|
159
|
+
return moment(value2).toISOString(true).slice(0, 16);
|
|
160
|
+
}
|
|
161
|
+
return String(value2);
|
|
162
|
+
},
|
|
163
|
+
deserializer: (value2) => {
|
|
164
|
+
if (!value2) {
|
|
165
|
+
return void 0;
|
|
166
|
+
}
|
|
167
|
+
return moment(value2).toDate();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
);
|
|
148
171
|
}
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
if (value.type === "textarea") {
|
|
173
|
+
const Editor = useSyncTextEditor(textarea);
|
|
174
|
+
return /* @__PURE__ */ React2.createElement(
|
|
175
|
+
Editor.SyncTextEditor,
|
|
176
|
+
{
|
|
177
|
+
store: form.store,
|
|
178
|
+
property: key
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
if (value.options) {
|
|
183
|
+
const Component = value.options;
|
|
184
|
+
return /* @__PURE__ */ React2.createElement(SyncSelect, { store: form.store, property: key }, /* @__PURE__ */ React2.createElement(Component, null));
|
|
185
|
+
}
|
|
186
|
+
return /* @__PURE__ */ React2.createElement(
|
|
187
|
+
SyncInput,
|
|
188
|
+
{
|
|
189
|
+
store: form.store,
|
|
190
|
+
property: key,
|
|
191
|
+
type: value.type,
|
|
192
|
+
className: "input-form"
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
return /* @__PURE__ */ React2.createElement("label", { key }, value.label, createComponent());
|
|
197
|
+
})),
|
|
151
198
|
form.item && /* @__PURE__ */ React2.createElement(
|
|
152
199
|
"button",
|
|
153
200
|
{
|