dn-react-router-toolkit 0.7.15 → 0.8.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/api/create_api_handler.d.mts +5 -4
- package/dist/api/create_api_handler.d.ts +5 -4
- package/dist/api/create_api_handler.js +0 -1
- package/dist/api/create_api_handler.mjs +0 -1
- package/dist/api/index.d.mts +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +0 -2
- package/dist/api/index.mjs +0 -2
- package/dist/api/item_api_handler.d.mts +5 -4
- package/dist/api/item_api_handler.d.ts +5 -4
- package/dist/api/item_api_handler.js +0 -1
- package/dist/api/item_api_handler.mjs +0 -1
- package/dist/crud/crud_loader.d.mts +6 -5
- package/dist/crud/crud_loader.d.ts +6 -5
- package/dist/crud/crud_loader.js +46 -34
- package/dist/crud/crud_loader.mjs +46 -34
- package/dist/crud/crud_page.d.mts +3 -2
- package/dist/crud/crud_page.d.ts +3 -2
- package/dist/crud/crud_page.js +225 -197
- package/dist/crud/crud_page.mjs +223 -201
- package/dist/crud/generate_handlers.d.mts +3 -2
- package/dist/crud/generate_handlers.d.ts +3 -2
- package/dist/crud/generate_pages.d.mts +2 -1
- package/dist/crud/generate_pages.d.ts +2 -1
- package/dist/crud/index.d.mts +5 -3
- package/dist/crud/index.d.ts +5 -3
- package/dist/crud/index.js +245 -205
- package/dist/crud/index.mjs +251 -217
- package/dist/post/index.js +65 -58
- package/dist/post/index.mjs +68 -67
- package/dist/post/post_form_page.js +65 -58
- package/dist/post/post_form_page.mjs +68 -67
- package/dist/table/index.d.mts +7 -3
- package/dist/table/index.d.ts +7 -3
- package/dist/table/index.js +153 -105
- package/dist/table/index.mjs +149 -110
- package/dist/table/item_loader.d.mts +5 -4
- package/dist/table/item_loader.d.ts +5 -4
- package/dist/table/load_table.d.mts +30 -0
- package/dist/table/load_table.d.ts +30 -0
- package/dist/table/load_table.js +67 -0
- package/dist/table/load_table.mjs +45 -0
- package/dist/table/loader.d.mts +7 -15
- package/dist/table/loader.d.ts +7 -15
- package/dist/table/loader.js +47 -31
- package/dist/table/loader.mjs +46 -32
- package/dist/table/page.d.mts +6 -16
- package/dist/table/page.d.ts +6 -16
- package/dist/table/page.js +193 -165
- package/dist/table/page.mjs +194 -172
- package/dist/table/repository.d.mts +13 -11
- package/dist/table/repository.d.ts +13 -11
- package/dist/table/repository.js +1 -1
- package/dist/table/repository.mjs +1 -1
- package/dist/table/table_form.d.mts +13 -0
- package/dist/table/table_form.d.ts +13 -0
- package/dist/table/table_form.js +295 -0
- package/dist/table/table_form.mjs +270 -0
- package/dist/table/use_table.d.mts +4 -0
- package/dist/table/use_table.d.ts +4 -0
- package/dist/table/use_table.js +43 -0
- package/dist/table/use_table.mjs +18 -0
- package/package.json +1 -1
package/dist/table/page.js
CHANGED
|
@@ -23,87 +23,17 @@ __export(page_exports, {
|
|
|
23
23
|
createTablePage: () => createTablePage
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(page_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_react_router5 = require("react-router");
|
|
27
|
+
|
|
28
|
+
// src/table/table_form.tsx
|
|
29
|
+
var import_react_router4 = require("react-router");
|
|
27
30
|
var import_go2 = require("react-icons/go");
|
|
28
31
|
|
|
29
|
-
// src/table/
|
|
32
|
+
// src/table/table.tsx
|
|
30
33
|
var import_utils = require("dn-react-toolkit/utils");
|
|
34
|
+
var import_go = require("react-icons/go");
|
|
31
35
|
var import_react_router = require("react-router");
|
|
32
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
function TablePageButtons({
|
|
34
|
-
MAX_PAGES_TO_SHOW,
|
|
35
|
-
total,
|
|
36
|
-
limit,
|
|
37
|
-
offset
|
|
38
|
-
}) {
|
|
39
|
-
const pages = Math.ceil(total / limit);
|
|
40
|
-
const { pathname } = (0, import_react_router.useLocation)();
|
|
41
|
-
const [searchParams] = (0, import_react_router.useSearchParams)();
|
|
42
|
-
const currentPage = Math.floor(offset / limit) + 1;
|
|
43
|
-
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
44
|
-
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
45
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: pages > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
46
|
-
startButton > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
47
|
-
import_react_router.Link,
|
|
48
|
-
{
|
|
49
|
-
to: (() => {
|
|
50
|
-
searchParams.set(
|
|
51
|
-
"offset",
|
|
52
|
-
String((startButton - 1) * limit)
|
|
53
|
-
);
|
|
54
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
55
|
-
})(),
|
|
56
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
57
|
-
children: "\uC774\uC804"
|
|
58
|
-
}
|
|
59
|
-
),
|
|
60
|
-
Array.from({
|
|
61
|
-
length: Math.min(
|
|
62
|
-
MAX_PAGES_TO_SHOW,
|
|
63
|
-
pages - startButton
|
|
64
|
-
)
|
|
65
|
-
}).map((_, index) => {
|
|
66
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
67
|
-
import_react_router.Link,
|
|
68
|
-
{
|
|
69
|
-
to: (() => {
|
|
70
|
-
searchParams.set(
|
|
71
|
-
"offset",
|
|
72
|
-
String((startButton + index) * limit)
|
|
73
|
-
);
|
|
74
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
75
|
-
})(),
|
|
76
|
-
className: (0, import_utils.cn)(
|
|
77
|
-
"w-6 block text-center transition-colors",
|
|
78
|
-
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
79
|
-
),
|
|
80
|
-
children: startButton + index + 1
|
|
81
|
-
},
|
|
82
|
-
index
|
|
83
|
-
);
|
|
84
|
-
}),
|
|
85
|
-
endButton < pages && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
-
import_react_router.Link,
|
|
87
|
-
{
|
|
88
|
-
to: (() => {
|
|
89
|
-
searchParams.set(
|
|
90
|
-
"offset",
|
|
91
|
-
String((endButton + 1) * limit)
|
|
92
|
-
);
|
|
93
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
94
|
-
})(),
|
|
95
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
96
|
-
children: "\uB2E4\uC74C"
|
|
97
|
-
}
|
|
98
|
-
)
|
|
99
|
-
] }) });
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// src/table/table.tsx
|
|
103
|
-
var import_utils2 = require("dn-react-toolkit/utils");
|
|
104
|
-
var import_go = require("react-icons/go");
|
|
105
|
-
var import_react_router2 = require("react-router");
|
|
106
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
107
37
|
function Table({
|
|
108
38
|
className = "min-w-full whitespace-nowrap",
|
|
109
39
|
data,
|
|
@@ -117,13 +47,13 @@ function Table({
|
|
|
117
47
|
}) {
|
|
118
48
|
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
119
49
|
const sortedArray = [...data];
|
|
120
|
-
const [_, setSearchParams] = (0,
|
|
121
|
-
return /* @__PURE__ */ (0,
|
|
50
|
+
const [_, setSearchParams] = (0, import_react_router.useSearchParams)();
|
|
51
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
122
52
|
"table",
|
|
123
53
|
{
|
|
124
|
-
className: (0,
|
|
54
|
+
className: (0, import_utils.cn)(className, "text-[15px] border-separate border-spacing-0"),
|
|
125
55
|
children: [
|
|
126
|
-
/* @__PURE__ */ (0,
|
|
56
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: keys.map((key) => {
|
|
127
57
|
const value = columns[key];
|
|
128
58
|
function getReactNode() {
|
|
129
59
|
if (value && typeof value === "object" && "label" in value) {
|
|
@@ -134,10 +64,10 @@ function Table({
|
|
|
134
64
|
function Head() {
|
|
135
65
|
const reactNode = getReactNode();
|
|
136
66
|
if (typeof reactNode === "string") {
|
|
137
|
-
return /* @__PURE__ */ (0,
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
138
68
|
"button",
|
|
139
69
|
{
|
|
140
|
-
className: (0,
|
|
70
|
+
className: (0, import_utils.cn)(
|
|
141
71
|
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
142
72
|
"px-4 h-14 flex items-center w-full"
|
|
143
73
|
),
|
|
@@ -153,17 +83,17 @@ function Table({
|
|
|
153
83
|
},
|
|
154
84
|
children: [
|
|
155
85
|
reactNode,
|
|
156
|
-
orderBy === key && /* @__PURE__ */ (0,
|
|
86
|
+
orderBy === key && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ml-0.5", children: direction === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_go.GoArrowUp, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_go.GoArrowDown, {}) })
|
|
157
87
|
]
|
|
158
88
|
}
|
|
159
89
|
);
|
|
160
90
|
}
|
|
161
|
-
return /* @__PURE__ */ (0,
|
|
91
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: reactNode });
|
|
162
92
|
}
|
|
163
|
-
return /* @__PURE__ */ (0,
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { className: (0, import_utils.cn)("border-y font-normal"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Head, {}) }, key);
|
|
164
94
|
}) }) }),
|
|
165
|
-
/* @__PURE__ */ (0,
|
|
166
|
-
sortedArray.length === 0 && /* @__PURE__ */ (0,
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [
|
|
96
|
+
sortedArray.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
97
|
"td",
|
|
168
98
|
{
|
|
169
99
|
colSpan: keys.length,
|
|
@@ -171,7 +101,7 @@ function Table({
|
|
|
171
101
|
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
172
102
|
}
|
|
173
103
|
) }),
|
|
174
|
-
sortedArray.map((item, i) => /* @__PURE__ */ (0,
|
|
104
|
+
sortedArray.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
|
|
175
105
|
const value = item[key];
|
|
176
106
|
function Content() {
|
|
177
107
|
if (key in columns) {
|
|
@@ -179,22 +109,22 @@ function Table({
|
|
|
179
109
|
if (column && typeof column === "object" && "mapper" in column) {
|
|
180
110
|
const mapper = column.mapper;
|
|
181
111
|
if (mapper) {
|
|
182
|
-
return /* @__PURE__ */ (0,
|
|
112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: mapper(item) });
|
|
183
113
|
}
|
|
184
114
|
}
|
|
185
115
|
}
|
|
186
|
-
return /* @__PURE__ */ (0,
|
|
116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: String(value) });
|
|
187
117
|
}
|
|
188
|
-
const linkedContent = getLink ? /* @__PURE__ */ (0,
|
|
189
|
-
|
|
118
|
+
const linkedContent = getLink ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
119
|
+
import_react_router.Link,
|
|
190
120
|
{
|
|
191
121
|
to: getLink(item),
|
|
192
122
|
className: "block content-center px-4 w-full h-full",
|
|
193
|
-
children: /* @__PURE__ */ (0,
|
|
123
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Content, {})
|
|
194
124
|
}
|
|
195
|
-
) : /* @__PURE__ */ (0,
|
|
196
|
-
const cell = Mapper ? /* @__PURE__ */ (0,
|
|
197
|
-
return /* @__PURE__ */ (0,
|
|
125
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Content, {});
|
|
126
|
+
const cell = Mapper ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
198
128
|
}) }, i))
|
|
199
129
|
] })
|
|
200
130
|
]
|
|
@@ -202,8 +132,169 @@ function Table({
|
|
|
202
132
|
);
|
|
203
133
|
}
|
|
204
134
|
|
|
205
|
-
// src/table/
|
|
135
|
+
// src/table/use_table.tsx
|
|
136
|
+
var import_react_router2 = require("react-router");
|
|
137
|
+
function useTable() {
|
|
138
|
+
const { table } = (0, import_react_router2.useLoaderData)();
|
|
139
|
+
const { items, total, limit, offset, orderBy, direction, searchKey } = table;
|
|
140
|
+
return {
|
|
141
|
+
items,
|
|
142
|
+
total,
|
|
143
|
+
limit,
|
|
144
|
+
offset,
|
|
145
|
+
orderBy,
|
|
146
|
+
direction,
|
|
147
|
+
searchKey
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/table/buttons.tsx
|
|
152
|
+
var import_utils2 = require("dn-react-toolkit/utils");
|
|
153
|
+
var import_react_router3 = require("react-router");
|
|
154
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
155
|
+
function TablePageButtons({
|
|
156
|
+
MAX_PAGES_TO_SHOW,
|
|
157
|
+
total,
|
|
158
|
+
limit,
|
|
159
|
+
offset
|
|
160
|
+
}) {
|
|
161
|
+
const pages = Math.ceil(total / limit);
|
|
162
|
+
const { pathname } = (0, import_react_router3.useLocation)();
|
|
163
|
+
const [searchParams] = (0, import_react_router3.useSearchParams)();
|
|
164
|
+
const currentPage = Math.floor(offset / limit) + 1;
|
|
165
|
+
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
166
|
+
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: pages > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
168
|
+
startButton > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
169
|
+
import_react_router3.Link,
|
|
170
|
+
{
|
|
171
|
+
to: (() => {
|
|
172
|
+
searchParams.set(
|
|
173
|
+
"offset",
|
|
174
|
+
String((startButton - 1) * limit)
|
|
175
|
+
);
|
|
176
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
177
|
+
})(),
|
|
178
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
179
|
+
children: "\uC774\uC804"
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
Array.from({
|
|
183
|
+
length: Math.min(
|
|
184
|
+
MAX_PAGES_TO_SHOW,
|
|
185
|
+
pages - startButton
|
|
186
|
+
)
|
|
187
|
+
}).map((_, index) => {
|
|
188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
189
|
+
import_react_router3.Link,
|
|
190
|
+
{
|
|
191
|
+
to: (() => {
|
|
192
|
+
searchParams.set(
|
|
193
|
+
"offset",
|
|
194
|
+
String((startButton + index) * limit)
|
|
195
|
+
);
|
|
196
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
197
|
+
})(),
|
|
198
|
+
className: (0, import_utils2.cn)(
|
|
199
|
+
"w-6 block text-center transition-colors",
|
|
200
|
+
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
201
|
+
),
|
|
202
|
+
children: startButton + index + 1
|
|
203
|
+
},
|
|
204
|
+
index
|
|
205
|
+
);
|
|
206
|
+
}),
|
|
207
|
+
endButton < pages && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
208
|
+
import_react_router3.Link,
|
|
209
|
+
{
|
|
210
|
+
to: (() => {
|
|
211
|
+
searchParams.set(
|
|
212
|
+
"offset",
|
|
213
|
+
String((endButton + 1) * limit)
|
|
214
|
+
);
|
|
215
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
216
|
+
})(),
|
|
217
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
218
|
+
children: "\uB2E4\uC74C"
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
] }) });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/table/table_form.tsx
|
|
206
225
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
226
|
+
function TableForm({
|
|
227
|
+
columns,
|
|
228
|
+
primaryKey = "id"
|
|
229
|
+
}) {
|
|
230
|
+
const { pathname } = (0, import_react_router4.useLocation)();
|
|
231
|
+
const { items, total, limit, offset, orderBy, direction, searchKey } = useTable();
|
|
232
|
+
const navigate = (0, import_react_router4.useNavigate)();
|
|
233
|
+
const search = (query) => {
|
|
234
|
+
const searchParams2 = new URLSearchParams(window.location.search);
|
|
235
|
+
searchParams2.set("query", query);
|
|
236
|
+
searchParams2.set("offset", "0");
|
|
237
|
+
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
238
|
+
};
|
|
239
|
+
const [searchParams] = (0, import_react_router4.useSearchParams)();
|
|
240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
241
|
+
searchKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
242
|
+
"form",
|
|
243
|
+
{
|
|
244
|
+
className: "h-18 px-4 flex items-center border-t",
|
|
245
|
+
onSubmit: (e) => {
|
|
246
|
+
e.preventDefault();
|
|
247
|
+
const formData = new FormData(e.currentTarget);
|
|
248
|
+
const query = formData.get("query");
|
|
249
|
+
search(query);
|
|
250
|
+
},
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
253
|
+
"button",
|
|
254
|
+
{
|
|
255
|
+
type: "submit",
|
|
256
|
+
className: "w-10 h-10 flex justify-center items-center",
|
|
257
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_go2.GoSearch, { className: "text-xl mr-4" })
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
261
|
+
"input",
|
|
262
|
+
{
|
|
263
|
+
className: "outline-none h-full flex-1",
|
|
264
|
+
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
265
|
+
name: "query",
|
|
266
|
+
defaultValue: searchParams.get("query") ?? ""
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
),
|
|
272
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
273
|
+
Table,
|
|
274
|
+
{
|
|
275
|
+
data: items,
|
|
276
|
+
columns,
|
|
277
|
+
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
278
|
+
limit,
|
|
279
|
+
offset,
|
|
280
|
+
orderBy,
|
|
281
|
+
direction
|
|
282
|
+
}
|
|
283
|
+
),
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
285
|
+
TablePageButtons,
|
|
286
|
+
{
|
|
287
|
+
total,
|
|
288
|
+
limit,
|
|
289
|
+
offset,
|
|
290
|
+
MAX_PAGES_TO_SHOW: 10
|
|
291
|
+
}
|
|
292
|
+
)
|
|
293
|
+
] });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/table/page.tsx
|
|
297
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
207
298
|
function createTablePage({
|
|
208
299
|
name,
|
|
209
300
|
columns,
|
|
@@ -212,82 +303,19 @@ function createTablePage({
|
|
|
212
303
|
return function TablePage({
|
|
213
304
|
header: Header
|
|
214
305
|
}) {
|
|
215
|
-
const { pathname } = (0,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const navigate = (0, import_react_router3.useNavigate)();
|
|
219
|
-
const search = (query) => {
|
|
220
|
-
const searchParams2 = new URLSearchParams(window.location.search);
|
|
221
|
-
searchParams2.set("query", query);
|
|
222
|
-
searchParams2.set("offset", "0");
|
|
223
|
-
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
224
|
-
};
|
|
225
|
-
const [searchParams] = (0, import_react_router3.useSearchParams)();
|
|
226
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
227
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
306
|
+
const { pathname } = (0, import_react_router5.useLocation)();
|
|
307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
308
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
228
309
|
Header,
|
|
229
310
|
{
|
|
230
311
|
title: name,
|
|
231
|
-
actions: /* @__PURE__ */ (0,
|
|
312
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_router5.Link, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
232
313
|
name,
|
|
233
314
|
" \uCD94\uAC00"
|
|
234
315
|
] })
|
|
235
316
|
}
|
|
236
317
|
),
|
|
237
|
-
/* @__PURE__ */ (0,
|
|
238
|
-
searchKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
239
|
-
"form",
|
|
240
|
-
{
|
|
241
|
-
className: "h-18 px-4 flex items-center border-t",
|
|
242
|
-
onSubmit: (e) => {
|
|
243
|
-
e.preventDefault();
|
|
244
|
-
const formData = new FormData(e.currentTarget);
|
|
245
|
-
const query = formData.get("query");
|
|
246
|
-
search(query);
|
|
247
|
-
},
|
|
248
|
-
children: [
|
|
249
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
250
|
-
"button",
|
|
251
|
-
{
|
|
252
|
-
type: "submit",
|
|
253
|
-
className: "w-10 h-10 flex justify-center items-center",
|
|
254
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_go2.GoSearch, { className: "text-xl mr-4" })
|
|
255
|
-
}
|
|
256
|
-
),
|
|
257
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
258
|
-
"input",
|
|
259
|
-
{
|
|
260
|
-
className: "outline-none h-full flex-1",
|
|
261
|
-
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
262
|
-
name: "query",
|
|
263
|
-
defaultValue: searchParams.get("query") ?? ""
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
]
|
|
267
|
-
}
|
|
268
|
-
),
|
|
269
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
270
|
-
Table,
|
|
271
|
-
{
|
|
272
|
-
data: items,
|
|
273
|
-
columns,
|
|
274
|
-
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
275
|
-
limit,
|
|
276
|
-
offset,
|
|
277
|
-
orderBy,
|
|
278
|
-
direction
|
|
279
|
-
}
|
|
280
|
-
),
|
|
281
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
282
|
-
TablePageButtons,
|
|
283
|
-
{
|
|
284
|
-
total,
|
|
285
|
-
limit,
|
|
286
|
-
offset,
|
|
287
|
-
MAX_PAGES_TO_SHOW: 10
|
|
288
|
-
}
|
|
289
|
-
)
|
|
290
|
-
] })
|
|
318
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "max-w-7xl mx-auto w-full overflow-auto", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TableForm, { columns, primaryKey }) })
|
|
291
319
|
] });
|
|
292
320
|
};
|
|
293
321
|
}
|