dn-react-router-toolkit 0.5.3 → 0.5.4
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 +50 -18
- package/dist/crud/crud_form.mjs +51 -19
- package/dist/crud/crud_form_provider.d.mts +10 -6
- package/dist/crud/crud_form_provider.d.ts +10 -6
- 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 +100 -70
- package/dist/crud/crud_page.mjs +101 -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 +106 -76
- package/dist/crud/index.mjs +101 -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,65 @@ 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");
|
|
166
165
|
function CrudForm({ AdminLayout }) {
|
|
167
166
|
const form = useFormContext();
|
|
168
167
|
return /* @__PURE__ */ import_react3.default.createElement(
|
|
169
168
|
AdminLayout,
|
|
170
169
|
{
|
|
171
170
|
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
|
-
),
|
|
171
|
+
actions: /* @__PURE__ */ import_react3.default.createElement("button", { type: "button", className: "button-primary", onClick: form.submit }, "\uC800\uC7A5\uD558\uAE30"),
|
|
181
172
|
className: "max-w-3xl mx-auto"
|
|
182
173
|
},
|
|
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
|
-
|
|
174
|
+
Object.keys(form.columns).length > 0 && /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, Object.entries(
|
|
175
|
+
form.columns
|
|
176
|
+
).map(([key, value]) => {
|
|
177
|
+
const createComponent = () => {
|
|
178
|
+
if (value.component) {
|
|
179
|
+
return /* @__PURE__ */ import_react3.default.createElement(value.component, { store: form.store, property: key });
|
|
180
|
+
}
|
|
181
|
+
if (value.type === "checkbox") {
|
|
182
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_store2.SyncSwitch, { store: form.store, property: key });
|
|
183
|
+
}
|
|
184
|
+
if (value.type === "datetime") {
|
|
185
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
186
|
+
import_store2.SyncInput,
|
|
187
|
+
{
|
|
188
|
+
store: form.store,
|
|
189
|
+
property: key,
|
|
190
|
+
className: "input-form",
|
|
191
|
+
type: "datetime-local",
|
|
192
|
+
serializer: (value2) => {
|
|
193
|
+
if (value2 instanceof Date) {
|
|
194
|
+
return (0, import_utils.moment)(value2).toISOString(true).slice(0, 16);
|
|
195
|
+
}
|
|
196
|
+
return String(value2);
|
|
197
|
+
},
|
|
198
|
+
deserializer: (value2) => {
|
|
199
|
+
if (!value2) {
|
|
200
|
+
return void 0;
|
|
201
|
+
}
|
|
202
|
+
return (0, import_utils.moment)(value2).toDate();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
if (value.options) {
|
|
208
|
+
const Component = value.options;
|
|
209
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_store2.SyncSelect, { store: form.store, property: key }, /* @__PURE__ */ import_react3.default.createElement(Component, null));
|
|
190
210
|
}
|
|
191
|
-
|
|
192
|
-
|
|
211
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
212
|
+
import_store2.SyncInput,
|
|
213
|
+
{
|
|
214
|
+
store: form.store,
|
|
215
|
+
property: key,
|
|
216
|
+
type: value.type,
|
|
217
|
+
className: "input-form"
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
};
|
|
221
|
+
return /* @__PURE__ */ import_react3.default.createElement("label", { key }, value.label, createComponent());
|
|
222
|
+
})),
|
|
193
223
|
form.item && /* @__PURE__ */ import_react3.default.createElement(
|
|
194
224
|
"button",
|
|
195
225
|
{
|
|
@@ -632,7 +662,7 @@ function GoSearch(props) {
|
|
|
632
662
|
}
|
|
633
663
|
|
|
634
664
|
// src/table/buttons.tsx
|
|
635
|
-
var
|
|
665
|
+
var import_utils2 = require("dn-react-toolkit/utils");
|
|
636
666
|
var import_react_router4 = require("react-router");
|
|
637
667
|
var import_react6 = __toESM(require("react"));
|
|
638
668
|
function TablePageButtons({
|
|
@@ -677,7 +707,7 @@ function TablePageButtons({
|
|
|
677
707
|
);
|
|
678
708
|
return `${pathname}?${searchParams.toString()}`;
|
|
679
709
|
})(),
|
|
680
|
-
className: (0,
|
|
710
|
+
className: (0, import_utils2.cn)(
|
|
681
711
|
"w-6 block text-center transition-colors",
|
|
682
712
|
currentPage === startButton + index2 + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
683
713
|
)
|
|
@@ -701,7 +731,7 @@ function TablePageButtons({
|
|
|
701
731
|
}
|
|
702
732
|
|
|
703
733
|
// src/table/table.tsx
|
|
704
|
-
var
|
|
734
|
+
var import_utils3 = require("dn-react-toolkit/utils");
|
|
705
735
|
var import_react_router5 = require("react-router");
|
|
706
736
|
var import_react7 = __toESM(require("react"));
|
|
707
737
|
function Table({
|
|
@@ -721,7 +751,7 @@ function Table({
|
|
|
721
751
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
722
752
|
"table",
|
|
723
753
|
{
|
|
724
|
-
className: (0,
|
|
754
|
+
className: (0, import_utils3.cn)(
|
|
725
755
|
className,
|
|
726
756
|
"text-[15px] border-separate border-spacing-0"
|
|
727
757
|
)
|
|
@@ -740,7 +770,7 @@ function Table({
|
|
|
740
770
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
741
771
|
"button",
|
|
742
772
|
{
|
|
743
|
-
className: (0,
|
|
773
|
+
className: (0, import_utils3.cn)(
|
|
744
774
|
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
745
775
|
"px-4 h-14 flex items-center w-full"
|
|
746
776
|
),
|
|
@@ -765,7 +795,7 @@ function Table({
|
|
|
765
795
|
"th",
|
|
766
796
|
{
|
|
767
797
|
key,
|
|
768
|
-
className: (0,
|
|
798
|
+
className: (0, import_utils3.cn)("border-y font-normal")
|
|
769
799
|
},
|
|
770
800
|
/* @__PURE__ */ import_react7.default.createElement(Head, null)
|
|
771
801
|
);
|
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,67 @@ function CrudFormProvider({
|
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
// src/crud/crud_form.tsx
|
|
122
|
-
import { SyncInput } from "dn-react-toolkit/store";
|
|
120
|
+
import { SyncInput, SyncSelect, SyncSwitch } from "dn-react-toolkit/store";
|
|
123
121
|
import React2 from "react";
|
|
122
|
+
import { moment } from "dn-react-toolkit/utils";
|
|
124
123
|
function CrudForm({ AdminLayout }) {
|
|
125
124
|
const form = useFormContext();
|
|
126
125
|
return /* @__PURE__ */ React2.createElement(
|
|
127
126
|
AdminLayout,
|
|
128
127
|
{
|
|
129
128
|
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
|
-
),
|
|
129
|
+
actions: /* @__PURE__ */ React2.createElement("button", { type: "button", className: "button-primary", onClick: form.submit }, "\uC800\uC7A5\uD558\uAE30"),
|
|
139
130
|
className: "max-w-3xl mx-auto"
|
|
140
131
|
},
|
|
141
|
-
Object.keys(form.columns).length > 0 && /* @__PURE__ */ React2.createElement(React2.Fragment, null, Object.entries(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
property: key
|
|
147
|
-
className: "input-form"
|
|
132
|
+
Object.keys(form.columns).length > 0 && /* @__PURE__ */ React2.createElement(React2.Fragment, null, Object.entries(
|
|
133
|
+
form.columns
|
|
134
|
+
).map(([key, value]) => {
|
|
135
|
+
const createComponent = () => {
|
|
136
|
+
if (value.component) {
|
|
137
|
+
return /* @__PURE__ */ React2.createElement(value.component, { store: form.store, property: key });
|
|
148
138
|
}
|
|
149
|
-
|
|
150
|
-
|
|
139
|
+
if (value.type === "checkbox") {
|
|
140
|
+
return /* @__PURE__ */ React2.createElement(SyncSwitch, { store: form.store, property: key });
|
|
141
|
+
}
|
|
142
|
+
if (value.type === "datetime") {
|
|
143
|
+
return /* @__PURE__ */ React2.createElement(
|
|
144
|
+
SyncInput,
|
|
145
|
+
{
|
|
146
|
+
store: form.store,
|
|
147
|
+
property: key,
|
|
148
|
+
className: "input-form",
|
|
149
|
+
type: "datetime-local",
|
|
150
|
+
serializer: (value2) => {
|
|
151
|
+
if (value2 instanceof Date) {
|
|
152
|
+
return moment(value2).toISOString(true).slice(0, 16);
|
|
153
|
+
}
|
|
154
|
+
return String(value2);
|
|
155
|
+
},
|
|
156
|
+
deserializer: (value2) => {
|
|
157
|
+
if (!value2) {
|
|
158
|
+
return void 0;
|
|
159
|
+
}
|
|
160
|
+
return moment(value2).toDate();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
if (value.options) {
|
|
166
|
+
const Component = value.options;
|
|
167
|
+
return /* @__PURE__ */ React2.createElement(SyncSelect, { store: form.store, property: key }, /* @__PURE__ */ React2.createElement(Component, null));
|
|
168
|
+
}
|
|
169
|
+
return /* @__PURE__ */ React2.createElement(
|
|
170
|
+
SyncInput,
|
|
171
|
+
{
|
|
172
|
+
store: form.store,
|
|
173
|
+
property: key,
|
|
174
|
+
type: value.type,
|
|
175
|
+
className: "input-form"
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
return /* @__PURE__ */ React2.createElement("label", { key }, value.label, createComponent());
|
|
180
|
+
})),
|
|
151
181
|
form.item && /* @__PURE__ */ React2.createElement(
|
|
152
182
|
"button",
|
|
153
183
|
{
|