dn-react-router-toolkit 0.8.0 → 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 (47) hide show
  1. package/dist/api/index.js +13 -4
  2. package/dist/api/index.mjs +14 -5
  3. package/dist/api/item_api_handler.d.mts +4 -2
  4. package/dist/api/item_api_handler.d.ts +4 -2
  5. package/dist/api/item_api_handler.js +13 -4
  6. package/dist/api/item_api_handler.mjs +14 -5
  7. package/dist/crud/crud_loader.js +34 -5
  8. package/dist/crud/crud_loader.mjs +36 -6
  9. package/dist/crud/crud_page.js +69 -19
  10. package/dist/crud/crud_page.mjs +69 -19
  11. package/dist/crud/index.js +109 -30
  12. package/dist/crud/index.mjs +111 -31
  13. package/dist/post/index.js +6 -6
  14. package/dist/post/index.mjs +8 -7
  15. package/dist/post/post_form_page.js +6 -6
  16. package/dist/post/post_form_page.mjs +8 -7
  17. package/dist/table/index.d.mts +1 -1
  18. package/dist/table/index.d.ts +1 -1
  19. package/dist/table/index.js +94 -20
  20. package/dist/table/index.mjs +95 -20
  21. package/dist/table/load_table.d.mts +7 -1
  22. package/dist/table/load_table.d.ts +7 -1
  23. package/dist/table/load_table.js +21 -1
  24. package/dist/table/load_table.mjs +22 -1
  25. package/dist/table/loader.d.mts +3 -0
  26. package/dist/table/loader.d.ts +3 -0
  27. package/dist/table/loader.js +21 -1
  28. package/dist/table/loader.mjs +22 -1
  29. package/dist/table/page.js +69 -19
  30. package/dist/table/page.mjs +69 -19
  31. package/dist/table/repository.d.mts +6 -4
  32. package/dist/table/repository.d.ts +6 -4
  33. package/dist/table/repository.js +4 -0
  34. package/dist/table/repository.mjs +4 -0
  35. package/dist/table/table.d.mts +4 -1
  36. package/dist/table/table.d.ts +4 -1
  37. package/dist/table/table.js +55 -6
  38. package/dist/table/table.mjs +55 -6
  39. package/dist/table/table_form.d.mts +2 -2
  40. package/dist/table/table_form.d.ts +2 -2
  41. package/dist/table/table_form.js +69 -19
  42. package/dist/table/table_form.mjs +69 -19
  43. package/dist/table/use_table.d.mts +3 -3
  44. package/dist/table/use_table.d.ts +3 -3
  45. package/dist/table/use_table.js +1 -10
  46. package/dist/table/use_table.mjs +1 -10
  47. package/package.json +2 -2
@@ -12,7 +12,8 @@ function Table({
12
12
  limit,
13
13
  offset,
14
14
  orderBy,
15
- direction
15
+ direction,
16
+ filters
16
17
  }) {
17
18
  const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
18
19
  const sortedArray = [...data];
@@ -20,7 +21,10 @@ function Table({
20
21
  return /* @__PURE__ */ jsxs(
21
22
  "table",
22
23
  {
23
- className: cn(className, "text-[15px] border-separate border-spacing-0"),
24
+ className: cn(
25
+ className,
26
+ "text-[15px] border-separate border-spacing-0"
27
+ ),
24
28
  children: [
25
29
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: keys.map((key) => {
26
30
  const value = columns[key];
@@ -37,8 +41,8 @@ function Table({
37
41
  "button",
38
42
  {
39
43
  className: cn(
40
- orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
41
- "px-4 h-14 flex items-center w-full"
44
+ orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
45
+ "px-4 flex items-center w-full"
42
46
  ),
43
47
  onClick: () => {
44
48
  let newDirection = "asc";
@@ -59,14 +63,59 @@ function Table({
59
63
  }
60
64
  return /* @__PURE__ */ jsx(Fragment, { children: reactNode });
61
65
  }
62
- return /* @__PURE__ */ jsx("th", { className: cn("border-y font-normal"), children: /* @__PURE__ */ jsx(Head, {}) }, key);
66
+ const filter = filters[key];
67
+ return /* @__PURE__ */ jsxs(
68
+ "th",
69
+ {
70
+ className: cn(
71
+ "py-4 border-y font-normal align-top"
72
+ ),
73
+ children: [
74
+ /* @__PURE__ */ jsx(Head, {}),
75
+ filter && /* @__PURE__ */ jsx("div", { className: "px-3 mt-4", children: /* @__PURE__ */ jsxs(
76
+ "select",
77
+ {
78
+ className: "w-full h-10 px-1.5 border rounded-full outline-none",
79
+ onChange: (e) => {
80
+ const value2 = e.target.value;
81
+ setSearchParams((prev) => {
82
+ if (value2) {
83
+ prev.set(
84
+ key,
85
+ encodeURIComponent(
86
+ value2
87
+ )
88
+ );
89
+ } else {
90
+ prev.delete(key);
91
+ }
92
+ return prev;
93
+ });
94
+ },
95
+ children: [
96
+ /* @__PURE__ */ jsx("option", { value: "", children: "\uC804\uCCB4" }),
97
+ filter.map((option) => /* @__PURE__ */ jsx(
98
+ "option",
99
+ {
100
+ value: option,
101
+ children: option
102
+ },
103
+ option
104
+ ))
105
+ ]
106
+ }
107
+ ) })
108
+ ]
109
+ },
110
+ key
111
+ );
63
112
  }) }) }),
64
113
  /* @__PURE__ */ jsxs("tbody", { children: [
65
114
  sortedArray.length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
66
115
  "td",
67
116
  {
68
117
  colSpan: keys.length,
69
- className: "px-4 h-14 text-neutral-400 text-center",
118
+ className: "px-4 h-20 text-gray-400 text-center",
70
119
  children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
71
120
  }
72
121
  ) }),
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { TableColumnOptions } from './table.mjs';
3
- import { LoadedTable } from './use_table.mjs';
3
+ import { TableLoaderData } from './use_table.mjs';
4
4
  import 'react';
5
5
 
6
6
  type TablePageOptions<TModel> = {
7
7
  columns: TableColumnOptions<TModel>;
8
8
  primaryKey?: keyof TModel;
9
9
  };
10
- type LoadedModel<T extends (...args: any) => any> = LoadedTable<T>["items"][number];
10
+ type LoadedModel<T extends (...args: any) => any> = TableLoaderData<T>["items"][number];
11
11
  declare function TableForm<T extends (...args: any) => any>({ columns, primaryKey, }: TablePageOptions<LoadedModel<T>>): react_jsx_runtime.JSX.Element;
12
12
 
13
13
  export { type LoadedModel, TableForm, type TablePageOptions };
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { TableColumnOptions } from './table.js';
3
- import { LoadedTable } from './use_table.js';
3
+ import { TableLoaderData } from './use_table.js';
4
4
  import 'react';
5
5
 
6
6
  type TablePageOptions<TModel> = {
7
7
  columns: TableColumnOptions<TModel>;
8
8
  primaryKey?: keyof TModel;
9
9
  };
10
- type LoadedModel<T extends (...args: any) => any> = LoadedTable<T>["items"][number];
10
+ type LoadedModel<T extends (...args: any) => any> = TableLoaderData<T>["items"][number];
11
11
  declare function TableForm<T extends (...args: any) => any>({ columns, primaryKey, }: TablePageOptions<LoadedModel<T>>): react_jsx_runtime.JSX.Element;
12
12
 
13
13
  export { type LoadedModel, TableForm, type TablePageOptions };
@@ -40,7 +40,8 @@ function Table({
40
40
  limit,
41
41
  offset,
42
42
  orderBy,
43
- direction
43
+ direction,
44
+ filters
44
45
  }) {
45
46
  const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
46
47
  const sortedArray = [...data];
@@ -48,7 +49,10 @@ function Table({
48
49
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
49
50
  "table",
50
51
  {
51
- className: (0, import_utils.cn)(className, "text-[15px] border-separate border-spacing-0"),
52
+ className: (0, import_utils.cn)(
53
+ className,
54
+ "text-[15px] border-separate border-spacing-0"
55
+ ),
52
56
  children: [
53
57
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: keys.map((key) => {
54
58
  const value = columns[key];
@@ -65,8 +69,8 @@ function Table({
65
69
  "button",
66
70
  {
67
71
  className: (0, import_utils.cn)(
68
- orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
69
- "px-4 h-14 flex items-center w-full"
72
+ orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
73
+ "px-4 flex items-center w-full"
70
74
  ),
71
75
  onClick: () => {
72
76
  let newDirection = "asc";
@@ -87,14 +91,59 @@ function Table({
87
91
  }
88
92
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: reactNode });
89
93
  }
90
- 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);
94
+ const filter = filters[key];
95
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
96
+ "th",
97
+ {
98
+ className: (0, import_utils.cn)(
99
+ "py-4 border-y font-normal align-top"
100
+ ),
101
+ children: [
102
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Head, {}),
103
+ filter && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-3 mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
104
+ "select",
105
+ {
106
+ className: "w-full h-10 px-1.5 border rounded-full outline-none",
107
+ onChange: (e) => {
108
+ const value2 = e.target.value;
109
+ setSearchParams((prev) => {
110
+ if (value2) {
111
+ prev.set(
112
+ key,
113
+ encodeURIComponent(
114
+ value2
115
+ )
116
+ );
117
+ } else {
118
+ prev.delete(key);
119
+ }
120
+ return prev;
121
+ });
122
+ },
123
+ children: [
124
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "\uC804\uCCB4" }),
125
+ filter.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
126
+ "option",
127
+ {
128
+ value: option,
129
+ children: option
130
+ },
131
+ option
132
+ ))
133
+ ]
134
+ }
135
+ ) })
136
+ ]
137
+ },
138
+ key
139
+ );
91
140
  }) }) }),
92
141
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [
93
142
  sortedArray.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
143
  "td",
95
144
  {
96
145
  colSpan: keys.length,
97
- className: "px-4 h-14 text-neutral-400 text-center",
146
+ className: "px-4 h-20 text-gray-400 text-center",
98
147
  children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
99
148
  }
100
149
  ) }),
@@ -133,16 +182,7 @@ function Table({
133
182
  var import_react_router2 = require("react-router");
134
183
  function useTable() {
135
184
  const { table } = (0, import_react_router2.useLoaderData)();
136
- const { items, total, limit, offset, orderBy, direction, searchKey } = table;
137
- return {
138
- items,
139
- total,
140
- limit,
141
- offset,
142
- orderBy,
143
- direction,
144
- searchKey
145
- };
185
+ return table;
146
186
  }
147
187
 
148
188
  // src/table/buttons.tsx
@@ -225,7 +265,16 @@ function TableForm({
225
265
  primaryKey = "id"
226
266
  }) {
227
267
  const { pathname } = (0, import_react_router4.useLocation)();
228
- const { items, total, limit, offset, orderBy, direction, searchKey } = useTable();
268
+ const {
269
+ items,
270
+ total,
271
+ limit,
272
+ offset,
273
+ orderBy,
274
+ direction,
275
+ searchKey,
276
+ filters
277
+ } = useTable();
229
278
  const navigate = (0, import_react_router4.useNavigate)();
230
279
  const search = (query) => {
231
280
  const searchParams2 = new URLSearchParams(window.location.search);
@@ -238,7 +287,7 @@ function TableForm({
238
287
  searchKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
239
288
  "form",
240
289
  {
241
- className: "h-18 px-4 flex items-center border-t",
290
+ className: "h-20 px-4 flex items-center border-t",
242
291
  onSubmit: (e) => {
243
292
  e.preventDefault();
244
293
  const formData = new FormData(e.currentTarget);
@@ -275,7 +324,8 @@ function TableForm({
275
324
  limit,
276
325
  offset,
277
326
  orderBy,
278
- direction
327
+ direction,
328
+ filters
279
329
  }
280
330
  ),
281
331
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -16,7 +16,8 @@ function Table({
16
16
  limit,
17
17
  offset,
18
18
  orderBy,
19
- direction
19
+ direction,
20
+ filters
20
21
  }) {
21
22
  const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
22
23
  const sortedArray = [...data];
@@ -24,7 +25,10 @@ function Table({
24
25
  return /* @__PURE__ */ jsxs(
25
26
  "table",
26
27
  {
27
- className: cn(className, "text-[15px] border-separate border-spacing-0"),
28
+ className: cn(
29
+ className,
30
+ "text-[15px] border-separate border-spacing-0"
31
+ ),
28
32
  children: [
29
33
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: keys.map((key) => {
30
34
  const value = columns[key];
@@ -41,8 +45,8 @@ function Table({
41
45
  "button",
42
46
  {
43
47
  className: cn(
44
- orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
45
- "px-4 h-14 flex items-center w-full"
48
+ orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
49
+ "px-4 flex items-center w-full"
46
50
  ),
47
51
  onClick: () => {
48
52
  let newDirection = "asc";
@@ -63,14 +67,59 @@ function Table({
63
67
  }
64
68
  return /* @__PURE__ */ jsx(Fragment, { children: reactNode });
65
69
  }
66
- return /* @__PURE__ */ jsx("th", { className: cn("border-y font-normal"), children: /* @__PURE__ */ jsx(Head, {}) }, key);
70
+ const filter = filters[key];
71
+ return /* @__PURE__ */ jsxs(
72
+ "th",
73
+ {
74
+ className: cn(
75
+ "py-4 border-y font-normal align-top"
76
+ ),
77
+ children: [
78
+ /* @__PURE__ */ jsx(Head, {}),
79
+ filter && /* @__PURE__ */ jsx("div", { className: "px-3 mt-4", children: /* @__PURE__ */ jsxs(
80
+ "select",
81
+ {
82
+ className: "w-full h-10 px-1.5 border rounded-full outline-none",
83
+ onChange: (e) => {
84
+ const value2 = e.target.value;
85
+ setSearchParams((prev) => {
86
+ if (value2) {
87
+ prev.set(
88
+ key,
89
+ encodeURIComponent(
90
+ value2
91
+ )
92
+ );
93
+ } else {
94
+ prev.delete(key);
95
+ }
96
+ return prev;
97
+ });
98
+ },
99
+ children: [
100
+ /* @__PURE__ */ jsx("option", { value: "", children: "\uC804\uCCB4" }),
101
+ filter.map((option) => /* @__PURE__ */ jsx(
102
+ "option",
103
+ {
104
+ value: option,
105
+ children: option
106
+ },
107
+ option
108
+ ))
109
+ ]
110
+ }
111
+ ) })
112
+ ]
113
+ },
114
+ key
115
+ );
67
116
  }) }) }),
68
117
  /* @__PURE__ */ jsxs("tbody", { children: [
69
118
  sortedArray.length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
70
119
  "td",
71
120
  {
72
121
  colSpan: keys.length,
73
- className: "px-4 h-14 text-neutral-400 text-center",
122
+ className: "px-4 h-20 text-gray-400 text-center",
74
123
  children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
75
124
  }
76
125
  ) }),
@@ -109,16 +158,7 @@ function Table({
109
158
  import { useLoaderData } from "react-router";
110
159
  function useTable() {
111
160
  const { table } = useLoaderData();
112
- const { items, total, limit, offset, orderBy, direction, searchKey } = table;
113
- return {
114
- items,
115
- total,
116
- limit,
117
- offset,
118
- orderBy,
119
- direction,
120
- searchKey
121
- };
161
+ return table;
122
162
  }
123
163
 
124
164
  // src/table/buttons.tsx
@@ -201,7 +241,16 @@ function TableForm({
201
241
  primaryKey = "id"
202
242
  }) {
203
243
  const { pathname } = useLocation2();
204
- const { items, total, limit, offset, orderBy, direction, searchKey } = useTable();
244
+ const {
245
+ items,
246
+ total,
247
+ limit,
248
+ offset,
249
+ orderBy,
250
+ direction,
251
+ searchKey,
252
+ filters
253
+ } = useTable();
205
254
  const navigate = useNavigate();
206
255
  const search = (query) => {
207
256
  const searchParams2 = new URLSearchParams(window.location.search);
@@ -214,7 +263,7 @@ function TableForm({
214
263
  searchKey && /* @__PURE__ */ jsxs3(
215
264
  "form",
216
265
  {
217
- className: "h-18 px-4 flex items-center border-t",
266
+ className: "h-20 px-4 flex items-center border-t",
218
267
  onSubmit: (e) => {
219
268
  e.preventDefault();
220
269
  const formData = new FormData(e.currentTarget);
@@ -251,7 +300,8 @@ function TableForm({
251
300
  limit,
252
301
  offset,
253
302
  orderBy,
254
- direction
303
+ direction,
304
+ filters
255
305
  }
256
306
  ),
257
307
  /* @__PURE__ */ jsx3(
@@ -1,4 +1,4 @@
1
- type LoadedTable<T extends (...args: any) => any> = Awaited<ReturnType<T>>["table"];
2
- declare function useTable<T extends (...args: any) => any>(): LoadedTable<T>;
1
+ type TableLoaderData<T extends (...args: any) => any> = Awaited<ReturnType<T>>["table"];
2
+ declare function useTable<T extends (...args: any) => any>(): TableLoaderData<T>;
3
3
 
4
- export { type LoadedTable, useTable };
4
+ export { type TableLoaderData, useTable };
@@ -1,4 +1,4 @@
1
- type LoadedTable<T extends (...args: any) => any> = Awaited<ReturnType<T>>["table"];
2
- declare function useTable<T extends (...args: any) => any>(): LoadedTable<T>;
1
+ type TableLoaderData<T extends (...args: any) => any> = Awaited<ReturnType<T>>["table"];
2
+ declare function useTable<T extends (...args: any) => any>(): TableLoaderData<T>;
3
3
 
4
- export { type LoadedTable, useTable };
4
+ export { type TableLoaderData, useTable };
@@ -26,16 +26,7 @@ module.exports = __toCommonJS(use_table_exports);
26
26
  var import_react_router = require("react-router");
27
27
  function useTable() {
28
28
  const { table } = (0, import_react_router.useLoaderData)();
29
- const { items, total, limit, offset, orderBy, direction, searchKey } = table;
30
- return {
31
- items,
32
- total,
33
- limit,
34
- offset,
35
- orderBy,
36
- direction,
37
- searchKey
38
- };
29
+ return table;
39
30
  }
40
31
  // Annotate the CommonJS export names for ESM import in node:
41
32
  0 && (module.exports = {
@@ -2,16 +2,7 @@
2
2
  import { useLoaderData } from "react-router";
3
3
  function useTable() {
4
4
  const { table } = useLoaderData();
5
- const { items, total, limit, offset, orderBy, direction, searchKey } = table;
6
- return {
7
- items,
8
- total,
9
- limit,
10
- offset,
11
- orderBy,
12
- direction,
13
- searchKey
14
- };
5
+ return table;
15
6
  }
16
7
  export {
17
8
  useTable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-router-toolkit",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",
@@ -100,4 +100,4 @@
100
100
  "react-dom": "^19",
101
101
  "react-router": "^7.13.1"
102
102
  }
103
- }
103
+ }