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/crud/crud_page.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(crud_page_exports, {
|
|
|
23
23
|
crudPage: () => crudPage
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(crud_page_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_react_router9 = require("react-router");
|
|
27
27
|
|
|
28
28
|
// src/crud/crud_form_provider.tsx
|
|
29
29
|
var import_react_router = require("react-router");
|
|
@@ -175,87 +175,17 @@ function CrudFormProvider({
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
// src/table/page.tsx
|
|
178
|
-
var
|
|
178
|
+
var import_react_router6 = require("react-router");
|
|
179
|
+
|
|
180
|
+
// src/table/table_form.tsx
|
|
181
|
+
var import_react_router5 = require("react-router");
|
|
179
182
|
var import_go2 = require("react-icons/go");
|
|
180
183
|
|
|
181
|
-
// src/table/
|
|
184
|
+
// src/table/table.tsx
|
|
182
185
|
var import_utils2 = require("dn-react-toolkit/utils");
|
|
186
|
+
var import_go = require("react-icons/go");
|
|
183
187
|
var import_react_router2 = require("react-router");
|
|
184
188
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
185
|
-
function TablePageButtons({
|
|
186
|
-
MAX_PAGES_TO_SHOW,
|
|
187
|
-
total,
|
|
188
|
-
limit,
|
|
189
|
-
offset
|
|
190
|
-
}) {
|
|
191
|
-
const pages = Math.ceil(total / limit);
|
|
192
|
-
const { pathname } = (0, import_react_router2.useLocation)();
|
|
193
|
-
const [searchParams] = (0, import_react_router2.useSearchParams)();
|
|
194
|
-
const currentPage = Math.floor(offset / limit) + 1;
|
|
195
|
-
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
196
|
-
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
197
|
-
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: [
|
|
198
|
-
startButton > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
199
|
-
import_react_router2.Link,
|
|
200
|
-
{
|
|
201
|
-
to: (() => {
|
|
202
|
-
searchParams.set(
|
|
203
|
-
"offset",
|
|
204
|
-
String((startButton - 1) * limit)
|
|
205
|
-
);
|
|
206
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
207
|
-
})(),
|
|
208
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
209
|
-
children: "\uC774\uC804"
|
|
210
|
-
}
|
|
211
|
-
),
|
|
212
|
-
Array.from({
|
|
213
|
-
length: Math.min(
|
|
214
|
-
MAX_PAGES_TO_SHOW,
|
|
215
|
-
pages - startButton
|
|
216
|
-
)
|
|
217
|
-
}).map((_, index) => {
|
|
218
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
219
|
-
import_react_router2.Link,
|
|
220
|
-
{
|
|
221
|
-
to: (() => {
|
|
222
|
-
searchParams.set(
|
|
223
|
-
"offset",
|
|
224
|
-
String((startButton + index) * limit)
|
|
225
|
-
);
|
|
226
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
227
|
-
})(),
|
|
228
|
-
className: (0, import_utils2.cn)(
|
|
229
|
-
"w-6 block text-center transition-colors",
|
|
230
|
-
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
231
|
-
),
|
|
232
|
-
children: startButton + index + 1
|
|
233
|
-
},
|
|
234
|
-
index
|
|
235
|
-
);
|
|
236
|
-
}),
|
|
237
|
-
endButton < pages && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
238
|
-
import_react_router2.Link,
|
|
239
|
-
{
|
|
240
|
-
to: (() => {
|
|
241
|
-
searchParams.set(
|
|
242
|
-
"offset",
|
|
243
|
-
String((endButton + 1) * limit)
|
|
244
|
-
);
|
|
245
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
246
|
-
})(),
|
|
247
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
248
|
-
children: "\uB2E4\uC74C"
|
|
249
|
-
}
|
|
250
|
-
)
|
|
251
|
-
] }) });
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// src/table/table.tsx
|
|
255
|
-
var import_utils3 = require("dn-react-toolkit/utils");
|
|
256
|
-
var import_go = require("react-icons/go");
|
|
257
|
-
var import_react_router3 = require("react-router");
|
|
258
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
259
189
|
function Table({
|
|
260
190
|
className = "min-w-full whitespace-nowrap",
|
|
261
191
|
data,
|
|
@@ -269,13 +199,13 @@ function Table({
|
|
|
269
199
|
}) {
|
|
270
200
|
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
271
201
|
const sortedArray = [...data];
|
|
272
|
-
const [_, setSearchParams] = (0,
|
|
273
|
-
return /* @__PURE__ */ (0,
|
|
202
|
+
const [_, setSearchParams] = (0, import_react_router2.useSearchParams)();
|
|
203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
274
204
|
"table",
|
|
275
205
|
{
|
|
276
|
-
className: (0,
|
|
206
|
+
className: (0, import_utils2.cn)(className, "text-[15px] border-separate border-spacing-0"),
|
|
277
207
|
children: [
|
|
278
|
-
/* @__PURE__ */ (0,
|
|
208
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: keys.map((key) => {
|
|
279
209
|
const value = columns[key];
|
|
280
210
|
function getReactNode() {
|
|
281
211
|
if (value && typeof value === "object" && "label" in value) {
|
|
@@ -286,10 +216,10 @@ function Table({
|
|
|
286
216
|
function Head() {
|
|
287
217
|
const reactNode = getReactNode();
|
|
288
218
|
if (typeof reactNode === "string") {
|
|
289
|
-
return /* @__PURE__ */ (0,
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
290
220
|
"button",
|
|
291
221
|
{
|
|
292
|
-
className: (0,
|
|
222
|
+
className: (0, import_utils2.cn)(
|
|
293
223
|
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
294
224
|
"px-4 h-14 flex items-center w-full"
|
|
295
225
|
),
|
|
@@ -305,17 +235,17 @@ function Table({
|
|
|
305
235
|
},
|
|
306
236
|
children: [
|
|
307
237
|
reactNode,
|
|
308
|
-
orderBy === key && /* @__PURE__ */ (0,
|
|
238
|
+
orderBy === key && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ml-0.5", children: direction === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_go.GoArrowUp, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_go.GoArrowDown, {}) })
|
|
309
239
|
]
|
|
310
240
|
}
|
|
311
241
|
);
|
|
312
242
|
}
|
|
313
|
-
return /* @__PURE__ */ (0,
|
|
243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: reactNode });
|
|
314
244
|
}
|
|
315
|
-
return /* @__PURE__ */ (0,
|
|
245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: (0, import_utils2.cn)("border-y font-normal"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Head, {}) }, key);
|
|
316
246
|
}) }) }),
|
|
317
|
-
/* @__PURE__ */ (0,
|
|
318
|
-
sortedArray.length === 0 && /* @__PURE__ */ (0,
|
|
247
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tbody", { children: [
|
|
248
|
+
sortedArray.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
319
249
|
"td",
|
|
320
250
|
{
|
|
321
251
|
colSpan: keys.length,
|
|
@@ -323,7 +253,7 @@ function Table({
|
|
|
323
253
|
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
324
254
|
}
|
|
325
255
|
) }),
|
|
326
|
-
sortedArray.map((item, i) => /* @__PURE__ */ (0,
|
|
256
|
+
sortedArray.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
|
|
327
257
|
const value = item[key];
|
|
328
258
|
function Content() {
|
|
329
259
|
if (key in columns) {
|
|
@@ -331,22 +261,22 @@ function Table({
|
|
|
331
261
|
if (column && typeof column === "object" && "mapper" in column) {
|
|
332
262
|
const mapper = column.mapper;
|
|
333
263
|
if (mapper) {
|
|
334
|
-
return /* @__PURE__ */ (0,
|
|
264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: mapper(item) });
|
|
335
265
|
}
|
|
336
266
|
}
|
|
337
267
|
}
|
|
338
|
-
return /* @__PURE__ */ (0,
|
|
268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: String(value) });
|
|
339
269
|
}
|
|
340
|
-
const linkedContent = getLink ? /* @__PURE__ */ (0,
|
|
341
|
-
|
|
270
|
+
const linkedContent = getLink ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
271
|
+
import_react_router2.Link,
|
|
342
272
|
{
|
|
343
273
|
to: getLink(item),
|
|
344
274
|
className: "block content-center px-4 w-full h-full",
|
|
345
|
-
children: /* @__PURE__ */ (0,
|
|
275
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, {})
|
|
346
276
|
}
|
|
347
|
-
) : /* @__PURE__ */ (0,
|
|
348
|
-
const cell = Mapper ? /* @__PURE__ */ (0,
|
|
349
|
-
return /* @__PURE__ */ (0,
|
|
277
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, {});
|
|
278
|
+
const cell = Mapper ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
350
280
|
}) }, i))
|
|
351
281
|
] })
|
|
352
282
|
]
|
|
@@ -354,8 +284,169 @@ function Table({
|
|
|
354
284
|
);
|
|
355
285
|
}
|
|
356
286
|
|
|
357
|
-
// src/table/
|
|
287
|
+
// src/table/use_table.tsx
|
|
288
|
+
var import_react_router3 = require("react-router");
|
|
289
|
+
function useTable() {
|
|
290
|
+
const { table } = (0, import_react_router3.useLoaderData)();
|
|
291
|
+
const { items, total, limit, offset, orderBy, direction, searchKey } = table;
|
|
292
|
+
return {
|
|
293
|
+
items,
|
|
294
|
+
total,
|
|
295
|
+
limit,
|
|
296
|
+
offset,
|
|
297
|
+
orderBy,
|
|
298
|
+
direction,
|
|
299
|
+
searchKey
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/table/buttons.tsx
|
|
304
|
+
var import_utils3 = require("dn-react-toolkit/utils");
|
|
305
|
+
var import_react_router4 = require("react-router");
|
|
306
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
307
|
+
function TablePageButtons({
|
|
308
|
+
MAX_PAGES_TO_SHOW,
|
|
309
|
+
total,
|
|
310
|
+
limit,
|
|
311
|
+
offset
|
|
312
|
+
}) {
|
|
313
|
+
const pages = Math.ceil(total / limit);
|
|
314
|
+
const { pathname } = (0, import_react_router4.useLocation)();
|
|
315
|
+
const [searchParams] = (0, import_react_router4.useSearchParams)();
|
|
316
|
+
const currentPage = Math.floor(offset / limit) + 1;
|
|
317
|
+
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
318
|
+
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: pages > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
320
|
+
startButton > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
321
|
+
import_react_router4.Link,
|
|
322
|
+
{
|
|
323
|
+
to: (() => {
|
|
324
|
+
searchParams.set(
|
|
325
|
+
"offset",
|
|
326
|
+
String((startButton - 1) * limit)
|
|
327
|
+
);
|
|
328
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
329
|
+
})(),
|
|
330
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
331
|
+
children: "\uC774\uC804"
|
|
332
|
+
}
|
|
333
|
+
),
|
|
334
|
+
Array.from({
|
|
335
|
+
length: Math.min(
|
|
336
|
+
MAX_PAGES_TO_SHOW,
|
|
337
|
+
pages - startButton
|
|
338
|
+
)
|
|
339
|
+
}).map((_, index) => {
|
|
340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
341
|
+
import_react_router4.Link,
|
|
342
|
+
{
|
|
343
|
+
to: (() => {
|
|
344
|
+
searchParams.set(
|
|
345
|
+
"offset",
|
|
346
|
+
String((startButton + index) * limit)
|
|
347
|
+
);
|
|
348
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
349
|
+
})(),
|
|
350
|
+
className: (0, import_utils3.cn)(
|
|
351
|
+
"w-6 block text-center transition-colors",
|
|
352
|
+
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
353
|
+
),
|
|
354
|
+
children: startButton + index + 1
|
|
355
|
+
},
|
|
356
|
+
index
|
|
357
|
+
);
|
|
358
|
+
}),
|
|
359
|
+
endButton < pages && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
360
|
+
import_react_router4.Link,
|
|
361
|
+
{
|
|
362
|
+
to: (() => {
|
|
363
|
+
searchParams.set(
|
|
364
|
+
"offset",
|
|
365
|
+
String((endButton + 1) * limit)
|
|
366
|
+
);
|
|
367
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
368
|
+
})(),
|
|
369
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
370
|
+
children: "\uB2E4\uC74C"
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
] }) });
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/table/table_form.tsx
|
|
358
377
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
378
|
+
function TableForm({
|
|
379
|
+
columns,
|
|
380
|
+
primaryKey = "id"
|
|
381
|
+
}) {
|
|
382
|
+
const { pathname } = (0, import_react_router5.useLocation)();
|
|
383
|
+
const { items, total, limit, offset, orderBy, direction, searchKey } = useTable();
|
|
384
|
+
const navigate = (0, import_react_router5.useNavigate)();
|
|
385
|
+
const search = (query) => {
|
|
386
|
+
const searchParams2 = new URLSearchParams(window.location.search);
|
|
387
|
+
searchParams2.set("query", query);
|
|
388
|
+
searchParams2.set("offset", "0");
|
|
389
|
+
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
390
|
+
};
|
|
391
|
+
const [searchParams] = (0, import_react_router5.useSearchParams)();
|
|
392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
393
|
+
searchKey && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
394
|
+
"form",
|
|
395
|
+
{
|
|
396
|
+
className: "h-18 px-4 flex items-center border-t",
|
|
397
|
+
onSubmit: (e) => {
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
const formData = new FormData(e.currentTarget);
|
|
400
|
+
const query = formData.get("query");
|
|
401
|
+
search(query);
|
|
402
|
+
},
|
|
403
|
+
children: [
|
|
404
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
405
|
+
"button",
|
|
406
|
+
{
|
|
407
|
+
type: "submit",
|
|
408
|
+
className: "w-10 h-10 flex justify-center items-center",
|
|
409
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_go2.GoSearch, { className: "text-xl mr-4" })
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
413
|
+
"input",
|
|
414
|
+
{
|
|
415
|
+
className: "outline-none h-full flex-1",
|
|
416
|
+
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
417
|
+
name: "query",
|
|
418
|
+
defaultValue: searchParams.get("query") ?? ""
|
|
419
|
+
}
|
|
420
|
+
)
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
),
|
|
424
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
425
|
+
Table,
|
|
426
|
+
{
|
|
427
|
+
data: items,
|
|
428
|
+
columns,
|
|
429
|
+
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
430
|
+
limit,
|
|
431
|
+
offset,
|
|
432
|
+
orderBy,
|
|
433
|
+
direction
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
437
|
+
TablePageButtons,
|
|
438
|
+
{
|
|
439
|
+
total,
|
|
440
|
+
limit,
|
|
441
|
+
offset,
|
|
442
|
+
MAX_PAGES_TO_SHOW: 10
|
|
443
|
+
}
|
|
444
|
+
)
|
|
445
|
+
] });
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// src/table/page.tsx
|
|
449
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
359
450
|
function createTablePage({
|
|
360
451
|
name,
|
|
361
452
|
columns,
|
|
@@ -364,82 +455,19 @@ function createTablePage({
|
|
|
364
455
|
return function TablePage({
|
|
365
456
|
header: Header
|
|
366
457
|
}) {
|
|
367
|
-
const { pathname } = (0,
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const navigate = (0, import_react_router4.useNavigate)();
|
|
371
|
-
const search = (query) => {
|
|
372
|
-
const searchParams2 = new URLSearchParams(window.location.search);
|
|
373
|
-
searchParams2.set("query", query);
|
|
374
|
-
searchParams2.set("offset", "0");
|
|
375
|
-
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
376
|
-
};
|
|
377
|
-
const [searchParams] = (0, import_react_router4.useSearchParams)();
|
|
378
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
379
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
458
|
+
const { pathname } = (0, import_react_router6.useLocation)();
|
|
459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
460
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
380
461
|
Header,
|
|
381
462
|
{
|
|
382
463
|
title: name,
|
|
383
|
-
actions: /* @__PURE__ */ (0,
|
|
464
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_router6.Link, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
384
465
|
name,
|
|
385
466
|
" \uCD94\uAC00"
|
|
386
467
|
] })
|
|
387
468
|
}
|
|
388
469
|
),
|
|
389
|
-
/* @__PURE__ */ (0,
|
|
390
|
-
searchKey && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
391
|
-
"form",
|
|
392
|
-
{
|
|
393
|
-
className: "h-18 px-4 flex items-center border-t",
|
|
394
|
-
onSubmit: (e) => {
|
|
395
|
-
e.preventDefault();
|
|
396
|
-
const formData = new FormData(e.currentTarget);
|
|
397
|
-
const query = formData.get("query");
|
|
398
|
-
search(query);
|
|
399
|
-
},
|
|
400
|
-
children: [
|
|
401
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
402
|
-
"button",
|
|
403
|
-
{
|
|
404
|
-
type: "submit",
|
|
405
|
-
className: "w-10 h-10 flex justify-center items-center",
|
|
406
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_go2.GoSearch, { className: "text-xl mr-4" })
|
|
407
|
-
}
|
|
408
|
-
),
|
|
409
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
410
|
-
"input",
|
|
411
|
-
{
|
|
412
|
-
className: "outline-none h-full flex-1",
|
|
413
|
-
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
414
|
-
name: "query",
|
|
415
|
-
defaultValue: searchParams.get("query") ?? ""
|
|
416
|
-
}
|
|
417
|
-
)
|
|
418
|
-
]
|
|
419
|
-
}
|
|
420
|
-
),
|
|
421
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
422
|
-
Table,
|
|
423
|
-
{
|
|
424
|
-
data: items,
|
|
425
|
-
columns,
|
|
426
|
-
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
427
|
-
limit,
|
|
428
|
-
offset,
|
|
429
|
-
orderBy,
|
|
430
|
-
direction
|
|
431
|
-
}
|
|
432
|
-
),
|
|
433
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
434
|
-
TablePageButtons,
|
|
435
|
-
{
|
|
436
|
-
total,
|
|
437
|
-
limit,
|
|
438
|
-
offset,
|
|
439
|
-
MAX_PAGES_TO_SHOW: 10
|
|
440
|
-
}
|
|
441
|
-
)
|
|
442
|
-
] })
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "max-w-7xl mx-auto w-full overflow-auto", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TableForm, { columns, primaryKey }) })
|
|
443
471
|
] });
|
|
444
472
|
};
|
|
445
473
|
}
|
|
@@ -447,11 +475,11 @@ function createTablePage({
|
|
|
447
475
|
// src/form/create_form_component.tsx
|
|
448
476
|
var import_utils4 = require("dn-react-toolkit/utils");
|
|
449
477
|
var import_react2 = require("react");
|
|
450
|
-
var
|
|
478
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
451
479
|
function createComponent(tag, options) {
|
|
452
480
|
return function FormComponent({ className, ...props }) {
|
|
453
481
|
const Tag = tag;
|
|
454
|
-
return /* @__PURE__ */ (0,
|
|
482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tag, { ...props, className: (0, import_utils4.cn)(options.className, className) });
|
|
455
483
|
};
|
|
456
484
|
}
|
|
457
485
|
|
|
@@ -470,21 +498,21 @@ var FormLabel = createComponent("label", {
|
|
|
470
498
|
var import_react_store_input3 = require("react-store-input");
|
|
471
499
|
|
|
472
500
|
// src/client/env_loader.tsx
|
|
473
|
-
var
|
|
474
|
-
var
|
|
501
|
+
var import_react_router7 = require("react-router");
|
|
502
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
475
503
|
|
|
476
504
|
// src/client/file_input.tsx
|
|
477
505
|
var import_react3 = require("react");
|
|
478
|
-
var
|
|
506
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
479
507
|
|
|
480
508
|
// src/client/use_user_agent.tsx
|
|
481
|
-
var
|
|
509
|
+
var import_react_router8 = require("react-router");
|
|
482
510
|
|
|
483
511
|
// src/client/store_text_editor.tsx
|
|
484
512
|
var import_dn_react_text_editor = require("dn-react-text-editor");
|
|
485
513
|
var import_react_store_input2 = require("react-store-input");
|
|
486
514
|
var import_react4 = require("react");
|
|
487
|
-
var
|
|
515
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
488
516
|
function StoreTextEditor({
|
|
489
517
|
store,
|
|
490
518
|
name,
|
|
@@ -543,7 +571,7 @@ function StoreTextEditor({
|
|
|
543
571
|
}
|
|
544
572
|
return void 0;
|
|
545
573
|
};
|
|
546
|
-
return /* @__PURE__ */ (0,
|
|
574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
547
575
|
import_dn_react_text_editor.TextEditor,
|
|
548
576
|
{
|
|
549
577
|
...props,
|
|
@@ -561,19 +589,19 @@ function StoreTextEditor({
|
|
|
561
589
|
var import_client = require("dn-react-toolkit/file/client");
|
|
562
590
|
|
|
563
591
|
// src/crud/crud_form.tsx
|
|
564
|
-
var
|
|
592
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
565
593
|
function CrudForm({
|
|
566
594
|
AdminHeader
|
|
567
595
|
}) {
|
|
568
596
|
const form = useFormContext();
|
|
569
597
|
const component = (0, import_react_store_input3.useStoreComponent)(form.store);
|
|
570
|
-
return /* @__PURE__ */ (0,
|
|
571
|
-
/* @__PURE__ */ (0,
|
|
598
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
599
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
572
600
|
AdminHeader,
|
|
573
601
|
{
|
|
574
602
|
title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
|
|
575
|
-
actions: /* @__PURE__ */ (0,
|
|
576
|
-
form.item && /* @__PURE__ */ (0,
|
|
603
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
604
|
+
form.item && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
577
605
|
"button",
|
|
578
606
|
{
|
|
579
607
|
type: "button",
|
|
@@ -584,7 +612,7 @@ function CrudForm({
|
|
|
584
612
|
children: "\uC0AD\uC81C\uD558\uAE30"
|
|
585
613
|
}
|
|
586
614
|
),
|
|
587
|
-
/* @__PURE__ */ (0,
|
|
615
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
588
616
|
"button",
|
|
589
617
|
{
|
|
590
618
|
type: "button",
|
|
@@ -596,15 +624,15 @@ function CrudForm({
|
|
|
596
624
|
] })
|
|
597
625
|
}
|
|
598
626
|
),
|
|
599
|
-
/* @__PURE__ */ (0,
|
|
627
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: Object.entries(form.columns).map(
|
|
600
628
|
([name, value]) => {
|
|
601
629
|
function InputComponent() {
|
|
602
630
|
if (value.component) {
|
|
603
631
|
const Component = value.component;
|
|
604
|
-
return /* @__PURE__ */ (0,
|
|
632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, { store: form.store, name });
|
|
605
633
|
}
|
|
606
634
|
if (value.type === "textarea") {
|
|
607
|
-
return /* @__PURE__ */ (0,
|
|
635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
608
636
|
StoreTextEditor,
|
|
609
637
|
{
|
|
610
638
|
store: form.store,
|
|
@@ -619,9 +647,9 @@ function CrudForm({
|
|
|
619
647
|
}
|
|
620
648
|
if (value.options) {
|
|
621
649
|
const Component = value.options;
|
|
622
|
-
return /* @__PURE__ */ (0,
|
|
650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(component.select, { name, className: "select-form", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, {}) });
|
|
623
651
|
}
|
|
624
|
-
return /* @__PURE__ */ (0,
|
|
652
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
625
653
|
component.input,
|
|
626
654
|
{
|
|
627
655
|
name,
|
|
@@ -632,14 +660,14 @@ function CrudForm({
|
|
|
632
660
|
}
|
|
633
661
|
const v = form.store.state[name];
|
|
634
662
|
if (typeof v === "boolean") {
|
|
635
|
-
return /* @__PURE__ */ (0,
|
|
663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex", children: [
|
|
636
664
|
value.label,
|
|
637
|
-
/* @__PURE__ */ (0,
|
|
665
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "ml-auto", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InputComponent, {}) })
|
|
638
666
|
] });
|
|
639
667
|
}
|
|
640
|
-
return /* @__PURE__ */ (0,
|
|
641
|
-
/* @__PURE__ */ (0,
|
|
642
|
-
/* @__PURE__ */ (0,
|
|
668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FormRow, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(FormEntry, { children: [
|
|
669
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FormLabel, { children: value.label }, name),
|
|
670
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InputComponent, {})
|
|
643
671
|
] }) }, name);
|
|
644
672
|
}
|
|
645
673
|
) }) })
|
|
@@ -647,7 +675,7 @@ function CrudForm({
|
|
|
647
675
|
}
|
|
648
676
|
|
|
649
677
|
// src/crud/crud_page.tsx
|
|
650
|
-
var
|
|
678
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
651
679
|
function crudPage({
|
|
652
680
|
name,
|
|
653
681
|
primaryKey,
|
|
@@ -657,17 +685,17 @@ function crudPage({
|
|
|
657
685
|
}) {
|
|
658
686
|
const create = (prefix) => {
|
|
659
687
|
return function Page() {
|
|
660
|
-
const data = (0,
|
|
661
|
-
const { pathname } = (0,
|
|
688
|
+
const data = (0, import_react_router9.useLoaderData)();
|
|
689
|
+
const { pathname } = (0, import_react_router9.useLocation)();
|
|
662
690
|
if (pathname === prefix) {
|
|
663
691
|
const Component = createTablePage({
|
|
664
692
|
...tablePageOptions,
|
|
665
693
|
name
|
|
666
694
|
});
|
|
667
|
-
return /* @__PURE__ */ (0,
|
|
695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Component, { header });
|
|
668
696
|
}
|
|
669
697
|
if (pathname.startsWith(prefix)) {
|
|
670
|
-
return /* @__PURE__ */ (0,
|
|
698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
671
699
|
CrudFormProvider,
|
|
672
700
|
{
|
|
673
701
|
item: data?.item,
|
|
@@ -675,7 +703,7 @@ function crudPage({
|
|
|
675
703
|
name,
|
|
676
704
|
columns: formOptions.columns,
|
|
677
705
|
primaryKey,
|
|
678
|
-
children: formOptions.form ? /* @__PURE__ */ (0,
|
|
706
|
+
children: formOptions.form ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FormDelegate, { component: formOptions.form }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CrudForm, { AdminHeader: header })
|
|
679
707
|
}
|
|
680
708
|
);
|
|
681
709
|
}
|
|
@@ -690,7 +718,7 @@ function FormDelegate({
|
|
|
690
718
|
component: Component
|
|
691
719
|
}) {
|
|
692
720
|
const form = useFormContext();
|
|
693
|
-
return /* @__PURE__ */ (0,
|
|
721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Component, { form });
|
|
694
722
|
}
|
|
695
723
|
// Annotate the CommonJS export names for ESM import in node:
|
|
696
724
|
0 && (module.exports = {
|