dn-react-router-toolkit 0.7.15 → 0.8.1

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.
Files changed (67) hide show
  1. package/dist/api/create_api_handler.d.mts +5 -4
  2. package/dist/api/create_api_handler.d.ts +5 -4
  3. package/dist/api/create_api_handler.js +0 -1
  4. package/dist/api/create_api_handler.mjs +0 -1
  5. package/dist/api/index.d.mts +1 -0
  6. package/dist/api/index.d.ts +1 -0
  7. package/dist/api/index.js +13 -6
  8. package/dist/api/index.mjs +14 -7
  9. package/dist/api/item_api_handler.d.mts +8 -5
  10. package/dist/api/item_api_handler.d.ts +8 -5
  11. package/dist/api/item_api_handler.js +13 -5
  12. package/dist/api/item_api_handler.mjs +14 -6
  13. package/dist/crud/crud_loader.d.mts +6 -5
  14. package/dist/crud/crud_loader.d.ts +6 -5
  15. package/dist/crud/crud_loader.js +79 -38
  16. package/dist/crud/crud_loader.mjs +81 -39
  17. package/dist/crud/crud_page.d.mts +3 -2
  18. package/dist/crud/crud_page.d.ts +3 -2
  19. package/dist/crud/crud_page.js +279 -201
  20. package/dist/crud/crud_page.mjs +277 -205
  21. package/dist/crud/generate_handlers.d.mts +3 -2
  22. package/dist/crud/generate_handlers.d.ts +3 -2
  23. package/dist/crud/generate_pages.d.mts +2 -1
  24. package/dist/crud/generate_pages.d.ts +2 -1
  25. package/dist/crud/index.d.mts +5 -3
  26. package/dist/crud/index.d.ts +5 -3
  27. package/dist/crud/index.js +338 -219
  28. package/dist/crud/index.mjs +346 -232
  29. package/dist/post/index.js +71 -64
  30. package/dist/post/index.mjs +76 -74
  31. package/dist/post/post_form_page.js +71 -64
  32. package/dist/post/post_form_page.mjs +76 -74
  33. package/dist/table/index.d.mts +7 -3
  34. package/dist/table/index.d.ts +7 -3
  35. package/dist/table/index.js +233 -111
  36. package/dist/table/index.mjs +230 -116
  37. package/dist/table/item_loader.d.mts +5 -4
  38. package/dist/table/item_loader.d.ts +5 -4
  39. package/dist/table/load_table.d.mts +36 -0
  40. package/dist/table/load_table.d.ts +36 -0
  41. package/dist/table/load_table.js +87 -0
  42. package/dist/table/load_table.mjs +66 -0
  43. package/dist/table/loader.d.mts +10 -15
  44. package/dist/table/loader.d.ts +10 -15
  45. package/dist/table/loader.js +67 -31
  46. package/dist/table/loader.mjs +67 -32
  47. package/dist/table/page.d.mts +6 -16
  48. package/dist/table/page.d.ts +6 -16
  49. package/dist/table/page.js +247 -169
  50. package/dist/table/page.mjs +248 -176
  51. package/dist/table/repository.d.mts +14 -10
  52. package/dist/table/repository.d.ts +14 -10
  53. package/dist/table/repository.js +5 -1
  54. package/dist/table/repository.mjs +5 -1
  55. package/dist/table/table.d.mts +4 -1
  56. package/dist/table/table.d.ts +4 -1
  57. package/dist/table/table.js +55 -6
  58. package/dist/table/table.mjs +55 -6
  59. package/dist/table/table_form.d.mts +13 -0
  60. package/dist/table/table_form.d.ts +13 -0
  61. package/dist/table/table_form.js +345 -0
  62. package/dist/table/table_form.mjs +320 -0
  63. package/dist/table/use_table.d.mts +4 -0
  64. package/dist/table/use_table.d.ts +4 -0
  65. package/dist/table/use_table.js +34 -0
  66. package/dist/table/use_table.mjs +9 -0
  67. package/package.json +2 -2
@@ -23,7 +23,7 @@ __export(crud_page_exports, {
23
23
  crudPage: () => crudPage
24
24
  });
25
25
  module.exports = __toCommonJS(crud_page_exports);
26
- var import_react_router7 = require("react-router");
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 import_react_router4 = require("react-router");
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/buttons.tsx
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,
@@ -265,17 +195,21 @@ function Table({
265
195
  limit,
266
196
  offset,
267
197
  orderBy,
268
- direction
198
+ direction,
199
+ filters
269
200
  }) {
270
201
  const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
271
202
  const sortedArray = [...data];
272
- const [_, setSearchParams] = (0, import_react_router3.useSearchParams)();
273
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
203
+ const [_, setSearchParams] = (0, import_react_router2.useSearchParams)();
204
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
274
205
  "table",
275
206
  {
276
- className: (0, import_utils3.cn)(className, "text-[15px] border-separate border-spacing-0"),
207
+ className: (0, import_utils2.cn)(
208
+ className,
209
+ "text-[15px] border-separate border-spacing-0"
210
+ ),
277
211
  children: [
278
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: keys.map((key) => {
212
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: keys.map((key) => {
279
213
  const value = columns[key];
280
214
  function getReactNode() {
281
215
  if (value && typeof value === "object" && "label" in value) {
@@ -286,12 +220,12 @@ function Table({
286
220
  function Head() {
287
221
  const reactNode = getReactNode();
288
222
  if (typeof reactNode === "string") {
289
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
223
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
290
224
  "button",
291
225
  {
292
- className: (0, import_utils3.cn)(
293
- orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
294
- "px-4 h-14 flex items-center w-full"
226
+ className: (0, import_utils2.cn)(
227
+ orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
228
+ "px-4 flex items-center w-full"
295
229
  ),
296
230
  onClick: () => {
297
231
  let newDirection = "asc";
@@ -305,25 +239,70 @@ function Table({
305
239
  },
306
240
  children: [
307
241
  reactNode,
308
- orderBy === key && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ml-0.5", children: direction === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_go.GoArrowUp, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_go.GoArrowDown, {}) })
242
+ 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
243
  ]
310
244
  }
311
245
  );
312
246
  }
313
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: reactNode });
247
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: reactNode });
314
248
  }
315
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { className: (0, import_utils3.cn)("border-y font-normal"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Head, {}) }, key);
249
+ const filter = filters[key];
250
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
251
+ "th",
252
+ {
253
+ className: (0, import_utils2.cn)(
254
+ "py-4 border-y font-normal align-top"
255
+ ),
256
+ children: [
257
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Head, {}),
258
+ filter && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-3 mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
259
+ "select",
260
+ {
261
+ className: "w-full h-10 px-1.5 border rounded-full outline-none",
262
+ onChange: (e) => {
263
+ const value2 = e.target.value;
264
+ setSearchParams((prev) => {
265
+ if (value2) {
266
+ prev.set(
267
+ key,
268
+ encodeURIComponent(
269
+ value2
270
+ )
271
+ );
272
+ } else {
273
+ prev.delete(key);
274
+ }
275
+ return prev;
276
+ });
277
+ },
278
+ children: [
279
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "\uC804\uCCB4" }),
280
+ filter.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
281
+ "option",
282
+ {
283
+ value: option,
284
+ children: option
285
+ },
286
+ option
287
+ ))
288
+ ]
289
+ }
290
+ ) })
291
+ ]
292
+ },
293
+ key
294
+ );
316
295
  }) }) }),
317
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tbody", { children: [
318
- sortedArray.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
296
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tbody", { children: [
297
+ sortedArray.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
319
298
  "td",
320
299
  {
321
300
  colSpan: keys.length,
322
- className: "px-4 h-14 text-neutral-400 text-center",
301
+ className: "px-4 h-20 text-gray-400 text-center",
323
302
  children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
324
303
  }
325
304
  ) }),
326
- sortedArray.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
305
+ sortedArray.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
327
306
  const value = item[key];
328
307
  function Content() {
329
308
  if (key in columns) {
@@ -331,22 +310,22 @@ function Table({
331
310
  if (column && typeof column === "object" && "mapper" in column) {
332
311
  const mapper = column.mapper;
333
312
  if (mapper) {
334
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: mapper(item) });
313
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: mapper(item) });
335
314
  }
336
315
  }
337
316
  }
338
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: String(value) });
317
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: String(value) });
339
318
  }
340
- const linkedContent = getLink ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
341
- import_react_router3.Link,
319
+ const linkedContent = getLink ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
320
+ import_react_router2.Link,
342
321
  {
343
322
  to: getLink(item),
344
323
  className: "block content-center px-4 w-full h-full",
345
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Content, {})
324
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, {})
346
325
  }
347
- ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Content, {});
348
- const cell = Mapper ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
349
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { className: "px-0 h-14 border-b", children: cell }, key);
326
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, {});
327
+ const cell = Mapper ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
328
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "px-0 h-14 border-b", children: cell }, key);
350
329
  }) }, i))
351
330
  ] })
352
331
  ]
@@ -354,8 +333,170 @@ function Table({
354
333
  );
355
334
  }
356
335
 
357
- // src/table/page.tsx
336
+ // src/table/use_table.tsx
337
+ var import_react_router3 = require("react-router");
338
+ function useTable() {
339
+ const { table } = (0, import_react_router3.useLoaderData)();
340
+ return table;
341
+ }
342
+
343
+ // src/table/buttons.tsx
344
+ var import_utils3 = require("dn-react-toolkit/utils");
345
+ var import_react_router4 = require("react-router");
346
+ var import_jsx_runtime3 = require("react/jsx-runtime");
347
+ function TablePageButtons({
348
+ MAX_PAGES_TO_SHOW,
349
+ total,
350
+ limit,
351
+ offset
352
+ }) {
353
+ const pages = Math.ceil(total / limit);
354
+ const { pathname } = (0, import_react_router4.useLocation)();
355
+ const [searchParams] = (0, import_react_router4.useSearchParams)();
356
+ const currentPage = Math.floor(offset / limit) + 1;
357
+ const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
358
+ const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
359
+ 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: [
360
+ startButton > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
361
+ import_react_router4.Link,
362
+ {
363
+ to: (() => {
364
+ searchParams.set(
365
+ "offset",
366
+ String((startButton - 1) * limit)
367
+ );
368
+ return `${pathname}?${searchParams.toString()}`;
369
+ })(),
370
+ className: "w-10 block text-center transition-colors hover:text-primary",
371
+ children: "\uC774\uC804"
372
+ }
373
+ ),
374
+ Array.from({
375
+ length: Math.min(
376
+ MAX_PAGES_TO_SHOW,
377
+ pages - startButton
378
+ )
379
+ }).map((_, index) => {
380
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
381
+ import_react_router4.Link,
382
+ {
383
+ to: (() => {
384
+ searchParams.set(
385
+ "offset",
386
+ String((startButton + index) * limit)
387
+ );
388
+ return `${pathname}?${searchParams.toString()}`;
389
+ })(),
390
+ className: (0, import_utils3.cn)(
391
+ "w-6 block text-center transition-colors",
392
+ currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
393
+ ),
394
+ children: startButton + index + 1
395
+ },
396
+ index
397
+ );
398
+ }),
399
+ endButton < pages && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
400
+ import_react_router4.Link,
401
+ {
402
+ to: (() => {
403
+ searchParams.set(
404
+ "offset",
405
+ String((endButton + 1) * limit)
406
+ );
407
+ return `${pathname}?${searchParams.toString()}`;
408
+ })(),
409
+ className: "w-10 block text-center transition-colors hover:text-primary",
410
+ children: "\uB2E4\uC74C"
411
+ }
412
+ )
413
+ ] }) });
414
+ }
415
+
416
+ // src/table/table_form.tsx
358
417
  var import_jsx_runtime4 = require("react/jsx-runtime");
418
+ function TableForm({
419
+ columns,
420
+ primaryKey = "id"
421
+ }) {
422
+ const { pathname } = (0, import_react_router5.useLocation)();
423
+ const {
424
+ items,
425
+ total,
426
+ limit,
427
+ offset,
428
+ orderBy,
429
+ direction,
430
+ searchKey,
431
+ filters
432
+ } = useTable();
433
+ const navigate = (0, import_react_router5.useNavigate)();
434
+ const search = (query) => {
435
+ const searchParams2 = new URLSearchParams(window.location.search);
436
+ searchParams2.set("query", query);
437
+ searchParams2.set("offset", "0");
438
+ navigate(`${pathname}?${searchParams2.toString()}`);
439
+ };
440
+ const [searchParams] = (0, import_react_router5.useSearchParams)();
441
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
442
+ searchKey && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
443
+ "form",
444
+ {
445
+ className: "h-20 px-4 flex items-center border-t",
446
+ onSubmit: (e) => {
447
+ e.preventDefault();
448
+ const formData = new FormData(e.currentTarget);
449
+ const query = formData.get("query");
450
+ search(query);
451
+ },
452
+ children: [
453
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
454
+ "button",
455
+ {
456
+ type: "submit",
457
+ className: "w-10 h-10 flex justify-center items-center",
458
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_go2.GoSearch, { className: "text-xl mr-4" })
459
+ }
460
+ ),
461
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
462
+ "input",
463
+ {
464
+ className: "outline-none h-full flex-1",
465
+ placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
466
+ name: "query",
467
+ defaultValue: searchParams.get("query") ?? ""
468
+ }
469
+ )
470
+ ]
471
+ }
472
+ ),
473
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
474
+ Table,
475
+ {
476
+ data: items,
477
+ columns,
478
+ getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
479
+ limit,
480
+ offset,
481
+ orderBy,
482
+ direction,
483
+ filters
484
+ }
485
+ ),
486
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
487
+ TablePageButtons,
488
+ {
489
+ total,
490
+ limit,
491
+ offset,
492
+ MAX_PAGES_TO_SHOW: 10
493
+ }
494
+ )
495
+ ] });
496
+ }
497
+
498
+ // src/table/page.tsx
499
+ var import_jsx_runtime5 = require("react/jsx-runtime");
359
500
  function createTablePage({
360
501
  name,
361
502
  columns,
@@ -364,82 +505,19 @@ function createTablePage({
364
505
  return function TablePage({
365
506
  header: Header
366
507
  }) {
367
- const { pathname } = (0, import_react_router4.useLocation)();
368
- const { table } = (0, import_react_router4.useLoaderData)();
369
- const { items, total, limit, offset, orderBy, direction, searchKey } = table;
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)(
508
+ const { pathname } = (0, import_react_router6.useLocation)();
509
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
510
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
380
511
  Header,
381
512
  {
382
513
  title: name,
383
- actions: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_router4.Link, { to: `${pathname}/new`, className: "button-primary", children: [
514
+ actions: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_router6.Link, { to: `${pathname}/new`, className: "button-primary", children: [
384
515
  name,
385
516
  " \uCD94\uAC00"
386
517
  ] })
387
518
  }
388
519
  ),
389
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "max-w-7xl mx-auto w-full overflow-auto", children: [
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
- ] })
520
+ /* @__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
521
  ] });
444
522
  };
445
523
  }
@@ -447,11 +525,11 @@ function createTablePage({
447
525
  // src/form/create_form_component.tsx
448
526
  var import_utils4 = require("dn-react-toolkit/utils");
449
527
  var import_react2 = require("react");
450
- var import_jsx_runtime5 = require("react/jsx-runtime");
528
+ var import_jsx_runtime6 = require("react/jsx-runtime");
451
529
  function createComponent(tag, options) {
452
530
  return function FormComponent({ className, ...props }) {
453
531
  const Tag = tag;
454
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tag, { ...props, className: (0, import_utils4.cn)(options.className, className) });
532
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tag, { ...props, className: (0, import_utils4.cn)(options.className, className) });
455
533
  };
456
534
  }
457
535
 
@@ -470,21 +548,21 @@ var FormLabel = createComponent("label", {
470
548
  var import_react_store_input3 = require("react-store-input");
471
549
 
472
550
  // src/client/env_loader.tsx
473
- var import_react_router5 = require("react-router");
474
- var import_jsx_runtime6 = require("react/jsx-runtime");
551
+ var import_react_router7 = require("react-router");
552
+ var import_jsx_runtime7 = require("react/jsx-runtime");
475
553
 
476
554
  // src/client/file_input.tsx
477
555
  var import_react3 = require("react");
478
- var import_jsx_runtime7 = require("react/jsx-runtime");
556
+ var import_jsx_runtime8 = require("react/jsx-runtime");
479
557
 
480
558
  // src/client/use_user_agent.tsx
481
- var import_react_router6 = require("react-router");
559
+ var import_react_router8 = require("react-router");
482
560
 
483
561
  // src/client/store_text_editor.tsx
484
562
  var import_dn_react_text_editor = require("dn-react-text-editor");
485
563
  var import_react_store_input2 = require("react-store-input");
486
564
  var import_react4 = require("react");
487
- var import_jsx_runtime8 = require("react/jsx-runtime");
565
+ var import_jsx_runtime9 = require("react/jsx-runtime");
488
566
  function StoreTextEditor({
489
567
  store,
490
568
  name,
@@ -543,7 +621,7 @@ function StoreTextEditor({
543
621
  }
544
622
  return void 0;
545
623
  };
546
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
624
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
547
625
  import_dn_react_text_editor.TextEditor,
548
626
  {
549
627
  ...props,
@@ -561,19 +639,19 @@ function StoreTextEditor({
561
639
  var import_client = require("dn-react-toolkit/file/client");
562
640
 
563
641
  // src/crud/crud_form.tsx
564
- var import_jsx_runtime9 = require("react/jsx-runtime");
642
+ var import_jsx_runtime10 = require("react/jsx-runtime");
565
643
  function CrudForm({
566
644
  AdminHeader
567
645
  }) {
568
646
  const form = useFormContext();
569
647
  const component = (0, import_react_store_input3.useStoreComponent)(form.store);
570
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
571
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
648
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
649
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
572
650
  AdminHeader,
573
651
  {
574
652
  title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
575
- actions: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
576
- form.item && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
653
+ actions: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
654
+ form.item && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
577
655
  "button",
578
656
  {
579
657
  type: "button",
@@ -584,7 +662,7 @@ function CrudForm({
584
662
  children: "\uC0AD\uC81C\uD558\uAE30"
585
663
  }
586
664
  ),
587
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
665
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
588
666
  "button",
589
667
  {
590
668
  type: "button",
@@ -596,15 +674,15 @@ function CrudForm({
596
674
  ] })
597
675
  }
598
676
  ),
599
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: Object.entries(form.columns).map(
677
+ /* @__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
678
  ([name, value]) => {
601
679
  function InputComponent() {
602
680
  if (value.component) {
603
681
  const Component = value.component;
604
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Component, { store: form.store, name });
682
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, { store: form.store, name });
605
683
  }
606
684
  if (value.type === "textarea") {
607
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
685
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
608
686
  StoreTextEditor,
609
687
  {
610
688
  store: form.store,
@@ -619,9 +697,9 @@ function CrudForm({
619
697
  }
620
698
  if (value.options) {
621
699
  const Component = value.options;
622
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(component.select, { name, className: "select-form", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Component, {}) });
700
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(component.select, { name, className: "select-form", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, {}) });
623
701
  }
624
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
702
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
625
703
  component.input,
626
704
  {
627
705
  name,
@@ -632,14 +710,14 @@ function CrudForm({
632
710
  }
633
711
  const v = form.store.state[name];
634
712
  if (typeof v === "boolean") {
635
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex", children: [
713
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex", children: [
636
714
  value.label,
637
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "ml-auto", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InputComponent, {}) })
715
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "ml-auto", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InputComponent, {}) })
638
716
  ] });
639
717
  }
640
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FormRow, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(FormEntry, { children: [
641
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FormLabel, { children: value.label }, name),
642
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InputComponent, {})
718
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FormRow, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(FormEntry, { children: [
719
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FormLabel, { children: value.label }, name),
720
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InputComponent, {})
643
721
  ] }) }, name);
644
722
  }
645
723
  ) }) })
@@ -647,7 +725,7 @@ function CrudForm({
647
725
  }
648
726
 
649
727
  // src/crud/crud_page.tsx
650
- var import_jsx_runtime10 = require("react/jsx-runtime");
728
+ var import_jsx_runtime11 = require("react/jsx-runtime");
651
729
  function crudPage({
652
730
  name,
653
731
  primaryKey,
@@ -657,17 +735,17 @@ function crudPage({
657
735
  }) {
658
736
  const create = (prefix) => {
659
737
  return function Page() {
660
- const data = (0, import_react_router7.useLoaderData)();
661
- const { pathname } = (0, import_react_router7.useLocation)();
738
+ const data = (0, import_react_router9.useLoaderData)();
739
+ const { pathname } = (0, import_react_router9.useLocation)();
662
740
  if (pathname === prefix) {
663
741
  const Component = createTablePage({
664
742
  ...tablePageOptions,
665
743
  name
666
744
  });
667
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, { header });
745
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Component, { header });
668
746
  }
669
747
  if (pathname.startsWith(prefix)) {
670
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
748
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
671
749
  CrudFormProvider,
672
750
  {
673
751
  item: data?.item,
@@ -675,7 +753,7 @@ function crudPage({
675
753
  name,
676
754
  columns: formOptions.columns,
677
755
  primaryKey,
678
- children: formOptions.form ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FormDelegate, { component: formOptions.form }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CrudForm, { AdminHeader: header })
756
+ children: formOptions.form ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FormDelegate, { component: formOptions.form }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CrudForm, { AdminHeader: header })
679
757
  }
680
758
  );
681
759
  }
@@ -690,7 +768,7 @@ function FormDelegate({
690
768
  component: Component
691
769
  }) {
692
770
  const form = useFormContext();
693
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Component, { form });
771
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Component, { form });
694
772
  }
695
773
  // Annotate the CommonJS export names for ESM import in node:
696
774
  0 && (module.exports = {