dn-react-router-toolkit 0.8.1 → 0.9.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.
- package/dist/api/create_api_handler.d.mts +2 -2
- package/dist/api/create_api_handler.d.ts +2 -2
- package/dist/api/create_api_handler.js +55 -52
- package/dist/api/create_api_handler.mjs +61 -59
- package/dist/api/create_handler.d.mts +5 -5
- package/dist/api/create_handler.d.ts +5 -5
- package/dist/api/create_handler.js +41 -44
- package/dist/api/create_handler.mjs +41 -44
- package/dist/api/index.d.mts +4 -3
- package/dist/api/index.d.ts +4 -3
- package/dist/api/index.js +118 -102
- package/dist/api/index.mjs +130 -109
- package/dist/api/item_api_handler.d.mts +4 -3
- package/dist/api/item_api_handler.d.ts +4 -3
- package/dist/api/item_api_handler.js +22 -6
- package/dist/api/item_api_handler.mjs +28 -6
- package/dist/auth/cookie_manager.d.mts +1 -1
- package/dist/auth/cookie_manager.d.ts +1 -1
- package/dist/auth/index.d.mts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +18 -18
- package/dist/auth/index.mjs +18 -18
- package/dist/auth/with_auth.d.mts +2 -2
- package/dist/auth/with_auth.d.ts +2 -2
- package/dist/auth/with_auth.js +18 -18
- package/dist/auth/with_auth.mjs +18 -18
- package/dist/client/editor.d.mts +2 -2
- package/dist/client/editor.d.ts +2 -2
- package/dist/client/editor.js +9 -3
- package/dist/client/editor.mjs +9 -3
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +9 -3
- package/dist/client/index.mjs +9 -3
- package/dist/crud/crud_form.js +22 -4
- package/dist/crud/crud_form.mjs +11 -3
- package/dist/crud/crud_form_provider.js +16 -3
- package/dist/crud/crud_form_provider.mjs +14 -1
- package/dist/crud/index.d.mts +0 -20
- package/dist/crud/index.d.ts +0 -20
- package/dist/crud/index.js +32 -8589
- package/dist/crud/index.mjs +11 -8599
- package/dist/db/backup/index.d.mts +1 -1
- package/dist/db/backup/index.d.ts +1 -1
- package/dist/form/create_form_component.js +21 -2
- package/dist/form/create_form_component.mjs +10 -1
- package/dist/form/form_components.js +21 -2
- package/dist/form/form_components.mjs +10 -1
- package/dist/form/index.js +21 -2
- package/dist/form/index.mjs +10 -1
- package/dist/post/editor_toolbar.js +20 -3
- package/dist/post/editor_toolbar.mjs +9 -2
- package/dist/post/index.js +93 -7711
- package/dist/post/index.mjs +69 -7723
- package/dist/post/post_form_page.js +91 -7711
- package/dist/post/post_form_page.mjs +69 -7725
- package/dist/post/thumbnail_picker.js +21 -2
- package/dist/post/thumbnail_picker.mjs +10 -1
- package/dist/table/buttons.js +11 -14
- package/dist/table/buttons.mjs +10 -13
- package/dist/table/index.d.mts +0 -2
- package/dist/table/index.d.ts +0 -2
- package/dist/table/index.js +24 -95
- package/dist/table/index.mjs +23 -92
- package/dist/table/load_table.d.mts +1 -1
- package/dist/table/load_table.d.ts +1 -1
- package/dist/table/load_table.js +2 -2
- package/dist/table/load_table.mjs +2 -2
- package/dist/table/loader.js +2 -2
- package/dist/table/loader.mjs +2 -2
- package/dist/table/table.d.mts +2 -2
- package/dist/table/table.d.ts +2 -2
- package/dist/table/table.js +14 -25
- package/dist/table/table.mjs +11 -24
- package/dist/table/table_form.js +16 -39
- package/dist/table/table_form.mjs +15 -38
- package/dist/utils/cn.d.mts +3 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.js +32 -0
- package/dist/utils/cn.mjs +7 -0
- package/dist/utils/date.d.mts +5 -0
- package/dist/utils/date.d.ts +5 -0
- package/dist/utils/date.js +65 -0
- package/dist/utils/date.mjs +29 -0
- package/dist/utils/index.d.mts +7 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +116 -0
- package/dist/utils/index.mjs +73 -0
- package/dist/utils/korean.d.mts +6 -0
- package/dist/utils/korean.d.ts +6 -0
- package/dist/{crud/generate_pages.js → utils/korean.js} +16 -30
- package/dist/utils/korean.mjs +16 -0
- package/dist/utils/singleton.d.mts +3 -0
- package/dist/utils/singleton.d.ts +3 -0
- package/dist/utils/singleton.js +37 -0
- package/dist/utils/singleton.mjs +12 -0
- package/dist/utils/sleep.d.mts +3 -0
- package/dist/utils/sleep.d.ts +3 -0
- package/dist/{table/item_loader.js → utils/sleep.js} +8 -19
- package/dist/utils/sleep.mjs +7 -0
- package/dist/utils/slug.d.mts +3 -0
- package/dist/utils/slug.d.ts +3 -0
- package/dist/{crud/generate_handlers.js → utils/slug.js} +8 -15
- package/dist/utils/slug.mjs +7 -0
- package/package.json +7 -3
- package/dist/crud/crud_loader.d.mts +0 -26
- package/dist/crud/crud_loader.d.ts +0 -26
- package/dist/crud/crud_loader.js +0 -351
- package/dist/crud/crud_loader.mjs +0 -337
- package/dist/crud/crud_page.d.mts +0 -32
- package/dist/crud/crud_page.d.ts +0 -32
- package/dist/crud/crud_page.js +0 -776
- package/dist/crud/crud_page.mjs +0 -758
- package/dist/crud/generate_handlers.d.mts +0 -16
- package/dist/crud/generate_handlers.d.ts +0 -16
- package/dist/crud/generate_handlers.mjs +0 -14
- package/dist/crud/generate_pages.d.mts +0 -19
- package/dist/crud/generate_pages.d.ts +0 -19
- package/dist/crud/generate_pages.mjs +0 -30
- package/dist/crud/generate_routes.d.mts +0 -5
- package/dist/crud/generate_routes.d.ts +0 -5
- package/dist/crud/generate_routes.js +0 -7639
- package/dist/crud/generate_routes.mjs +0 -7627
- package/dist/table/item_loader.d.mts +0 -14
- package/dist/table/item_loader.d.ts +0 -14
- package/dist/table/item_loader.mjs +0 -18
- package/dist/table/page.d.mts +0 -16
- package/dist/table/page.d.ts +0 -16
- package/dist/table/page.js +0 -375
- package/dist/table/page.mjs +0 -350
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/post/thumbnail_picker.tsx
|
|
@@ -24,8 +34,17 @@ __export(thumbnail_picker_exports, {
|
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(thumbnail_picker_exports);
|
|
26
36
|
var import_react_store_input = require("react-store-input");
|
|
27
|
-
var import_utils = require("dn-react-toolkit/utils");
|
|
28
37
|
var import_react = require("react");
|
|
38
|
+
|
|
39
|
+
// src/utils/cn.ts
|
|
40
|
+
function cn(...classes) {
|
|
41
|
+
return classes.filter(Boolean).join(" ").trim();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/utils/date.ts
|
|
45
|
+
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
46
|
+
|
|
47
|
+
// src/post/thumbnail_picker.tsx
|
|
29
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
49
|
function PostThumbnailPicker({
|
|
31
50
|
store,
|
|
@@ -68,7 +87,7 @@ function PostThumbnailPicker({
|
|
|
68
87
|
"button",
|
|
69
88
|
{
|
|
70
89
|
type: "button",
|
|
71
|
-
className:
|
|
90
|
+
className: cn(
|
|
72
91
|
"border border-neutral-200 rounded-lg overflow-hidden aspect-4/3",
|
|
73
92
|
thumbnail === url && "border-transparent ring-2 ring-primary"
|
|
74
93
|
),
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
// src/post/thumbnail_picker.tsx
|
|
2
2
|
import { useSelector } from "react-store-input";
|
|
3
|
-
import { cn } from "dn-react-toolkit/utils";
|
|
4
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
// src/utils/cn.ts
|
|
6
|
+
function cn(...classes) {
|
|
7
|
+
return classes.filter(Boolean).join(" ").trim();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// src/utils/date.ts
|
|
11
|
+
import moment from "moment-timezone";
|
|
12
|
+
|
|
13
|
+
// src/post/thumbnail_picker.tsx
|
|
5
14
|
import { jsx } from "react/jsx-runtime";
|
|
6
15
|
function PostThumbnailPicker({
|
|
7
16
|
store,
|
package/dist/table/buttons.js
CHANGED
|
@@ -23,8 +23,14 @@ __export(buttons_exports, {
|
|
|
23
23
|
TablePageButtons: () => TablePageButtons
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(buttons_exports);
|
|
26
|
-
var import_utils = require("dn-react-toolkit/utils");
|
|
27
26
|
var import_react_router = require("react-router");
|
|
27
|
+
|
|
28
|
+
// src/utils/cn.ts
|
|
29
|
+
function cn(...classes) {
|
|
30
|
+
return classes.filter(Boolean).join(" ").trim();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/table/buttons.tsx
|
|
28
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
35
|
function TablePageButtons({
|
|
30
36
|
MAX_PAGES_TO_SHOW,
|
|
@@ -43,10 +49,7 @@ function TablePageButtons({
|
|
|
43
49
|
import_react_router.Link,
|
|
44
50
|
{
|
|
45
51
|
to: (() => {
|
|
46
|
-
searchParams.set(
|
|
47
|
-
"offset",
|
|
48
|
-
String((startButton - 1) * limit)
|
|
49
|
-
);
|
|
52
|
+
searchParams.set("offset", String((startButton - 1) * limit));
|
|
50
53
|
return `${pathname}?${searchParams.toString()}`;
|
|
51
54
|
})(),
|
|
52
55
|
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
@@ -54,10 +57,7 @@ function TablePageButtons({
|
|
|
54
57
|
}
|
|
55
58
|
),
|
|
56
59
|
Array.from({
|
|
57
|
-
length: Math.min(
|
|
58
|
-
MAX_PAGES_TO_SHOW,
|
|
59
|
-
pages - startButton
|
|
60
|
-
)
|
|
60
|
+
length: Math.min(MAX_PAGES_TO_SHOW, pages - startButton)
|
|
61
61
|
}).map((_, index) => {
|
|
62
62
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
63
63
|
import_react_router.Link,
|
|
@@ -69,7 +69,7 @@ function TablePageButtons({
|
|
|
69
69
|
);
|
|
70
70
|
return `${pathname}?${searchParams.toString()}`;
|
|
71
71
|
})(),
|
|
72
|
-
className:
|
|
72
|
+
className: cn(
|
|
73
73
|
"w-6 block text-center transition-colors",
|
|
74
74
|
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
75
75
|
),
|
|
@@ -82,10 +82,7 @@ function TablePageButtons({
|
|
|
82
82
|
import_react_router.Link,
|
|
83
83
|
{
|
|
84
84
|
to: (() => {
|
|
85
|
-
searchParams.set(
|
|
86
|
-
"offset",
|
|
87
|
-
String((endButton + 1) * limit)
|
|
88
|
-
);
|
|
85
|
+
searchParams.set("offset", String((endButton + 1) * limit));
|
|
89
86
|
return `${pathname}?${searchParams.toString()}`;
|
|
90
87
|
})(),
|
|
91
88
|
className: "w-10 block text-center transition-colors hover:text-primary",
|
package/dist/table/buttons.mjs
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
// src/table/buttons.tsx
|
|
2
|
-
import { cn } from "dn-react-toolkit/utils";
|
|
3
2
|
import { Link, useLocation, useSearchParams } from "react-router";
|
|
3
|
+
|
|
4
|
+
// src/utils/cn.ts
|
|
5
|
+
function cn(...classes) {
|
|
6
|
+
return classes.filter(Boolean).join(" ").trim();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/table/buttons.tsx
|
|
4
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
11
|
function TablePageButtons({
|
|
6
12
|
MAX_PAGES_TO_SHOW,
|
|
@@ -19,10 +25,7 @@ function TablePageButtons({
|
|
|
19
25
|
Link,
|
|
20
26
|
{
|
|
21
27
|
to: (() => {
|
|
22
|
-
searchParams.set(
|
|
23
|
-
"offset",
|
|
24
|
-
String((startButton - 1) * limit)
|
|
25
|
-
);
|
|
28
|
+
searchParams.set("offset", String((startButton - 1) * limit));
|
|
26
29
|
return `${pathname}?${searchParams.toString()}`;
|
|
27
30
|
})(),
|
|
28
31
|
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
@@ -30,10 +33,7 @@ function TablePageButtons({
|
|
|
30
33
|
}
|
|
31
34
|
),
|
|
32
35
|
Array.from({
|
|
33
|
-
length: Math.min(
|
|
34
|
-
MAX_PAGES_TO_SHOW,
|
|
35
|
-
pages - startButton
|
|
36
|
-
)
|
|
36
|
+
length: Math.min(MAX_PAGES_TO_SHOW, pages - startButton)
|
|
37
37
|
}).map((_, index) => {
|
|
38
38
|
return /* @__PURE__ */ jsx(
|
|
39
39
|
Link,
|
|
@@ -58,10 +58,7 @@ function TablePageButtons({
|
|
|
58
58
|
Link,
|
|
59
59
|
{
|
|
60
60
|
to: (() => {
|
|
61
|
-
searchParams.set(
|
|
62
|
-
"offset",
|
|
63
|
-
String((endButton + 1) * limit)
|
|
64
|
-
);
|
|
61
|
+
searchParams.set("offset", String((endButton + 1) * limit));
|
|
65
62
|
return `${pathname}?${searchParams.toString()}`;
|
|
66
63
|
})(),
|
|
67
64
|
className: "w-10 block text-center transition-colors hover:text-primary",
|
package/dist/table/index.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { BaseTableRepository, ColumnOf, FindAllOptions, InsertModelOf, SchemaOf, SelectModelOf, TableRepository } from './repository.mjs';
|
|
2
2
|
export { TablePageButtons } from './buttons.mjs';
|
|
3
|
-
export { TableItemLoaderOptions, tableItemloader } from './item_loader.mjs';
|
|
4
3
|
export { tableLoader } from './loader.mjs';
|
|
5
|
-
export { createTablePage } from './page.mjs';
|
|
6
4
|
export { OrderedTableProps, Table, TableColumnOptions, TableColumnProps } from './table.mjs';
|
|
7
5
|
export { TableLoaderOptions, loadTable } from './load_table.mjs';
|
|
8
6
|
export { LoadedModel, TableForm, TablePageOptions } from './table_form.mjs';
|
package/dist/table/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { BaseTableRepository, ColumnOf, FindAllOptions, InsertModelOf, SchemaOf, SelectModelOf, TableRepository } from './repository.js';
|
|
2
2
|
export { TablePageButtons } from './buttons.js';
|
|
3
|
-
export { TableItemLoaderOptions, tableItemloader } from './item_loader.js';
|
|
4
3
|
export { tableLoader } from './loader.js';
|
|
5
|
-
export { createTablePage } from './page.js';
|
|
6
4
|
export { OrderedTableProps, Table, TableColumnOptions, TableColumnProps } from './table.js';
|
|
7
5
|
export { TableLoaderOptions, loadTable } from './load_table.js';
|
|
8
6
|
export { LoadedModel, TableForm, TablePageOptions } from './table_form.js';
|
package/dist/table/index.js
CHANGED
|
@@ -24,9 +24,7 @@ __export(table_exports, {
|
|
|
24
24
|
Table: () => Table,
|
|
25
25
|
TableForm: () => TableForm,
|
|
26
26
|
TablePageButtons: () => TablePageButtons,
|
|
27
|
-
createTablePage: () => createTablePage,
|
|
28
27
|
loadTable: () => loadTable,
|
|
29
|
-
tableItemloader: () => tableItemloader,
|
|
30
28
|
tableLoader: () => tableLoader,
|
|
31
29
|
useTable: () => useTable
|
|
32
30
|
});
|
|
@@ -86,8 +84,14 @@ var BaseTableRepository = class {
|
|
|
86
84
|
};
|
|
87
85
|
|
|
88
86
|
// src/table/buttons.tsx
|
|
89
|
-
var import_utils = require("dn-react-toolkit/utils");
|
|
90
87
|
var import_react_router = require("react-router");
|
|
88
|
+
|
|
89
|
+
// src/utils/cn.ts
|
|
90
|
+
function cn(...classes) {
|
|
91
|
+
return classes.filter(Boolean).join(" ").trim();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/table/buttons.tsx
|
|
91
95
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
92
96
|
function TablePageButtons({
|
|
93
97
|
MAX_PAGES_TO_SHOW,
|
|
@@ -106,10 +110,7 @@ function TablePageButtons({
|
|
|
106
110
|
import_react_router.Link,
|
|
107
111
|
{
|
|
108
112
|
to: (() => {
|
|
109
|
-
searchParams.set(
|
|
110
|
-
"offset",
|
|
111
|
-
String((startButton - 1) * limit)
|
|
112
|
-
);
|
|
113
|
+
searchParams.set("offset", String((startButton - 1) * limit));
|
|
113
114
|
return `${pathname}?${searchParams.toString()}`;
|
|
114
115
|
})(),
|
|
115
116
|
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
@@ -117,10 +118,7 @@ function TablePageButtons({
|
|
|
117
118
|
}
|
|
118
119
|
),
|
|
119
120
|
Array.from({
|
|
120
|
-
length: Math.min(
|
|
121
|
-
MAX_PAGES_TO_SHOW,
|
|
122
|
-
pages - startButton
|
|
123
|
-
)
|
|
121
|
+
length: Math.min(MAX_PAGES_TO_SHOW, pages - startButton)
|
|
124
122
|
}).map((_, index) => {
|
|
125
123
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
124
|
import_react_router.Link,
|
|
@@ -132,7 +130,7 @@ function TablePageButtons({
|
|
|
132
130
|
);
|
|
133
131
|
return `${pathname}?${searchParams.toString()}`;
|
|
134
132
|
})(),
|
|
135
|
-
className:
|
|
133
|
+
className: cn(
|
|
136
134
|
"w-6 block text-center transition-colors",
|
|
137
135
|
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
138
136
|
),
|
|
@@ -145,10 +143,7 @@ function TablePageButtons({
|
|
|
145
143
|
import_react_router.Link,
|
|
146
144
|
{
|
|
147
145
|
to: (() => {
|
|
148
|
-
searchParams.set(
|
|
149
|
-
"offset",
|
|
150
|
-
String((endButton + 1) * limit)
|
|
151
|
-
);
|
|
146
|
+
searchParams.set("offset", String((endButton + 1) * limit));
|
|
152
147
|
return `${pathname}?${searchParams.toString()}`;
|
|
153
148
|
})(),
|
|
154
149
|
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
@@ -158,22 +153,6 @@ function TablePageButtons({
|
|
|
158
153
|
] }) });
|
|
159
154
|
}
|
|
160
155
|
|
|
161
|
-
// src/table/item_loader.tsx
|
|
162
|
-
var tableItemloader = ({
|
|
163
|
-
repository
|
|
164
|
-
}) => {
|
|
165
|
-
return async (args) => {
|
|
166
|
-
const { params } = args;
|
|
167
|
-
if (params["itemId"] === "new") {
|
|
168
|
-
return { item: void 0 };
|
|
169
|
-
}
|
|
170
|
-
const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
|
|
171
|
-
return {
|
|
172
|
-
item
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
|
|
177
156
|
// src/table/load_table.tsx
|
|
178
157
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
179
158
|
async function loadTable({
|
|
@@ -184,7 +163,7 @@ async function loadTable({
|
|
|
184
163
|
const searchParams = new URL(request.url).searchParams;
|
|
185
164
|
const { where, searchKey, defaultOrderBy, defaultDirection } = options;
|
|
186
165
|
const query = searchParams.get("query") ?? void 0;
|
|
187
|
-
const limit = Number(searchParams.get("limit") ?? "
|
|
166
|
+
const limit = Number(searchParams.get("limit") ?? "10");
|
|
188
167
|
const offset = Number(searchParams.get("offset") ?? "0");
|
|
189
168
|
const orderBy = searchParams.get("orderBy") ?? defaultOrderBy;
|
|
190
169
|
const direction = searchParams.get("direction") ?? defaultDirection;
|
|
@@ -204,7 +183,7 @@ async function loadTable({
|
|
|
204
183
|
`%${query}%`
|
|
205
184
|
) : void 0,
|
|
206
185
|
...filterWhere,
|
|
207
|
-
|
|
186
|
+
where
|
|
208
187
|
);
|
|
209
188
|
const total = await repository.countTotal({ where: whereClauses });
|
|
210
189
|
const items = await repository.findAll({
|
|
@@ -251,15 +230,7 @@ function tableLoader({
|
|
|
251
230
|
};
|
|
252
231
|
}
|
|
253
232
|
|
|
254
|
-
// src/table/page.tsx
|
|
255
|
-
var import_react_router5 = require("react-router");
|
|
256
|
-
|
|
257
|
-
// src/table/table_form.tsx
|
|
258
|
-
var import_react_router4 = require("react-router");
|
|
259
|
-
var import_go2 = require("react-icons/go");
|
|
260
|
-
|
|
261
233
|
// src/table/table.tsx
|
|
262
|
-
var import_utils2 = require("dn-react-toolkit/utils");
|
|
263
234
|
var import_go = require("react-icons/go");
|
|
264
235
|
var import_react_router2 = require("react-router");
|
|
265
236
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -281,10 +252,7 @@ function Table({
|
|
|
281
252
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
282
253
|
"table",
|
|
283
254
|
{
|
|
284
|
-
className: (
|
|
285
|
-
className,
|
|
286
|
-
"text-[15px] border-separate border-spacing-0"
|
|
287
|
-
),
|
|
255
|
+
className: cn(className, "text-[15px] border-separate border-spacing-0"),
|
|
288
256
|
children: [
|
|
289
257
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tr", { children: keys.map((key) => {
|
|
290
258
|
const value = columns[key];
|
|
@@ -300,7 +268,7 @@ function Table({
|
|
|
300
268
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
301
269
|
"button",
|
|
302
270
|
{
|
|
303
|
-
className:
|
|
271
|
+
className: cn(
|
|
304
272
|
orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
|
|
305
273
|
"px-4 flex items-center w-full"
|
|
306
274
|
),
|
|
@@ -323,13 +291,11 @@ function Table({
|
|
|
323
291
|
}
|
|
324
292
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: reactNode });
|
|
325
293
|
}
|
|
326
|
-
const filter = filters[key];
|
|
294
|
+
const filter = filters?.[key];
|
|
327
295
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
328
296
|
"th",
|
|
329
297
|
{
|
|
330
|
-
className: (
|
|
331
|
-
"py-4 border-y font-normal align-top"
|
|
332
|
-
),
|
|
298
|
+
className: cn("py-4 border-y font-normal align-top"),
|
|
333
299
|
children: [
|
|
334
300
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Head, {}),
|
|
335
301
|
filter && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-3 mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
@@ -340,12 +306,7 @@ function Table({
|
|
|
340
306
|
const value2 = e.target.value;
|
|
341
307
|
setSearchParams((prev) => {
|
|
342
308
|
if (value2) {
|
|
343
|
-
prev.set(
|
|
344
|
-
key,
|
|
345
|
-
encodeURIComponent(
|
|
346
|
-
value2
|
|
347
|
-
)
|
|
348
|
-
);
|
|
309
|
+
prev.set(key, encodeURIComponent(value2));
|
|
349
310
|
} else {
|
|
350
311
|
prev.delete(key);
|
|
351
312
|
}
|
|
@@ -354,14 +315,7 @@ function Table({
|
|
|
354
315
|
},
|
|
355
316
|
children: [
|
|
356
317
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "\uC804\uCCB4" }),
|
|
357
|
-
filter.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
358
|
-
"option",
|
|
359
|
-
{
|
|
360
|
-
value: option,
|
|
361
|
-
children: option
|
|
362
|
-
},
|
|
363
|
-
option
|
|
364
|
-
))
|
|
318
|
+
filter.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: option, children: option }, option))
|
|
365
319
|
]
|
|
366
320
|
}
|
|
367
321
|
) })
|
|
@@ -400,7 +354,7 @@ function Table({
|
|
|
400
354
|
className: "block content-center px-4 w-full h-full",
|
|
401
355
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, {})
|
|
402
356
|
}
|
|
403
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, {});
|
|
357
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-4 w-full h-full content-center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Content, {}) });
|
|
404
358
|
const cell = Mapper ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
405
359
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
406
360
|
}) }, i))
|
|
@@ -410,6 +364,10 @@ function Table({
|
|
|
410
364
|
);
|
|
411
365
|
}
|
|
412
366
|
|
|
367
|
+
// src/table/table_form.tsx
|
|
368
|
+
var import_react_router4 = require("react-router");
|
|
369
|
+
var import_go2 = require("react-icons/go");
|
|
370
|
+
|
|
413
371
|
// src/table/use_table.tsx
|
|
414
372
|
var import_react_router3 = require("react-router");
|
|
415
373
|
function useTable() {
|
|
@@ -498,42 +456,13 @@ function TableForm({
|
|
|
498
456
|
)
|
|
499
457
|
] });
|
|
500
458
|
}
|
|
501
|
-
|
|
502
|
-
// src/table/page.tsx
|
|
503
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
504
|
-
function createTablePage({
|
|
505
|
-
name,
|
|
506
|
-
columns,
|
|
507
|
-
primaryKey = "id"
|
|
508
|
-
}) {
|
|
509
|
-
return function TablePage({
|
|
510
|
-
header: Header
|
|
511
|
-
}) {
|
|
512
|
-
const { pathname } = (0, import_react_router5.useLocation)();
|
|
513
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
514
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
515
|
-
Header,
|
|
516
|
-
{
|
|
517
|
-
title: name,
|
|
518
|
-
actions: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_router5.Link, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
519
|
-
name,
|
|
520
|
-
" \uCD94\uAC00"
|
|
521
|
-
] })
|
|
522
|
-
}
|
|
523
|
-
),
|
|
524
|
-
/* @__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 }) })
|
|
525
|
-
] });
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
459
|
// Annotate the CommonJS export names for ESM import in node:
|
|
529
460
|
0 && (module.exports = {
|
|
530
461
|
BaseTableRepository,
|
|
531
462
|
Table,
|
|
532
463
|
TableForm,
|
|
533
464
|
TablePageButtons,
|
|
534
|
-
createTablePage,
|
|
535
465
|
loadTable,
|
|
536
|
-
tableItemloader,
|
|
537
466
|
tableLoader,
|
|
538
467
|
useTable
|
|
539
468
|
});
|
package/dist/table/index.mjs
CHANGED
|
@@ -57,8 +57,14 @@ var BaseTableRepository = class {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// src/table/buttons.tsx
|
|
60
|
-
import { cn } from "dn-react-toolkit/utils";
|
|
61
60
|
import { Link, useLocation, useSearchParams } from "react-router";
|
|
61
|
+
|
|
62
|
+
// src/utils/cn.ts
|
|
63
|
+
function cn(...classes) {
|
|
64
|
+
return classes.filter(Boolean).join(" ").trim();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/table/buttons.tsx
|
|
62
68
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
63
69
|
function TablePageButtons({
|
|
64
70
|
MAX_PAGES_TO_SHOW,
|
|
@@ -77,10 +83,7 @@ function TablePageButtons({
|
|
|
77
83
|
Link,
|
|
78
84
|
{
|
|
79
85
|
to: (() => {
|
|
80
|
-
searchParams.set(
|
|
81
|
-
"offset",
|
|
82
|
-
String((startButton - 1) * limit)
|
|
83
|
-
);
|
|
86
|
+
searchParams.set("offset", String((startButton - 1) * limit));
|
|
84
87
|
return `${pathname}?${searchParams.toString()}`;
|
|
85
88
|
})(),
|
|
86
89
|
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
@@ -88,10 +91,7 @@ function TablePageButtons({
|
|
|
88
91
|
}
|
|
89
92
|
),
|
|
90
93
|
Array.from({
|
|
91
|
-
length: Math.min(
|
|
92
|
-
MAX_PAGES_TO_SHOW,
|
|
93
|
-
pages - startButton
|
|
94
|
-
)
|
|
94
|
+
length: Math.min(MAX_PAGES_TO_SHOW, pages - startButton)
|
|
95
95
|
}).map((_, index) => {
|
|
96
96
|
return /* @__PURE__ */ jsx(
|
|
97
97
|
Link,
|
|
@@ -116,10 +116,7 @@ function TablePageButtons({
|
|
|
116
116
|
Link,
|
|
117
117
|
{
|
|
118
118
|
to: (() => {
|
|
119
|
-
searchParams.set(
|
|
120
|
-
"offset",
|
|
121
|
-
String((endButton + 1) * limit)
|
|
122
|
-
);
|
|
119
|
+
searchParams.set("offset", String((endButton + 1) * limit));
|
|
123
120
|
return `${pathname}?${searchParams.toString()}`;
|
|
124
121
|
})(),
|
|
125
122
|
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
@@ -129,22 +126,6 @@ function TablePageButtons({
|
|
|
129
126
|
] }) });
|
|
130
127
|
}
|
|
131
128
|
|
|
132
|
-
// src/table/item_loader.tsx
|
|
133
|
-
var tableItemloader = ({
|
|
134
|
-
repository
|
|
135
|
-
}) => {
|
|
136
|
-
return async (args) => {
|
|
137
|
-
const { params } = args;
|
|
138
|
-
if (params["itemId"] === "new") {
|
|
139
|
-
return { item: void 0 };
|
|
140
|
-
}
|
|
141
|
-
const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
|
|
142
|
-
return {
|
|
143
|
-
item
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
|
|
148
129
|
// src/table/load_table.tsx
|
|
149
130
|
import {
|
|
150
131
|
and,
|
|
@@ -159,7 +140,7 @@ async function loadTable({
|
|
|
159
140
|
const searchParams = new URL(request.url).searchParams;
|
|
160
141
|
const { where, searchKey, defaultOrderBy, defaultDirection } = options;
|
|
161
142
|
const query = searchParams.get("query") ?? void 0;
|
|
162
|
-
const limit = Number(searchParams.get("limit") ?? "
|
|
143
|
+
const limit = Number(searchParams.get("limit") ?? "10");
|
|
163
144
|
const offset = Number(searchParams.get("offset") ?? "0");
|
|
164
145
|
const orderBy = searchParams.get("orderBy") ?? defaultOrderBy;
|
|
165
146
|
const direction = searchParams.get("direction") ?? defaultDirection;
|
|
@@ -179,7 +160,7 @@ async function loadTable({
|
|
|
179
160
|
`%${query}%`
|
|
180
161
|
) : void 0,
|
|
181
162
|
...filterWhere,
|
|
182
|
-
|
|
163
|
+
where
|
|
183
164
|
);
|
|
184
165
|
const total = await repository.countTotal({ where: whereClauses });
|
|
185
166
|
const items = await repository.findAll({
|
|
@@ -226,15 +207,7 @@ function tableLoader({
|
|
|
226
207
|
};
|
|
227
208
|
}
|
|
228
209
|
|
|
229
|
-
// src/table/page.tsx
|
|
230
|
-
import { Link as Link3, useLocation as useLocation3 } from "react-router";
|
|
231
|
-
|
|
232
|
-
// src/table/table_form.tsx
|
|
233
|
-
import { useLocation as useLocation2, useNavigate, useSearchParams as useSearchParams3 } from "react-router";
|
|
234
|
-
import { GoSearch } from "react-icons/go";
|
|
235
|
-
|
|
236
210
|
// src/table/table.tsx
|
|
237
|
-
import { cn as cn2 } from "dn-react-toolkit/utils";
|
|
238
211
|
import { GoArrowDown, GoArrowUp } from "react-icons/go";
|
|
239
212
|
import { Link as Link2, useSearchParams as useSearchParams2 } from "react-router";
|
|
240
213
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -256,10 +229,7 @@ function Table({
|
|
|
256
229
|
return /* @__PURE__ */ jsxs2(
|
|
257
230
|
"table",
|
|
258
231
|
{
|
|
259
|
-
className:
|
|
260
|
-
className,
|
|
261
|
-
"text-[15px] border-separate border-spacing-0"
|
|
262
|
-
),
|
|
232
|
+
className: cn(className, "text-[15px] border-separate border-spacing-0"),
|
|
263
233
|
children: [
|
|
264
234
|
/* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsx2("tr", { children: keys.map((key) => {
|
|
265
235
|
const value = columns[key];
|
|
@@ -275,7 +245,7 @@ function Table({
|
|
|
275
245
|
return /* @__PURE__ */ jsxs2(
|
|
276
246
|
"button",
|
|
277
247
|
{
|
|
278
|
-
className:
|
|
248
|
+
className: cn(
|
|
279
249
|
orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
|
|
280
250
|
"px-4 flex items-center w-full"
|
|
281
251
|
),
|
|
@@ -298,13 +268,11 @@ function Table({
|
|
|
298
268
|
}
|
|
299
269
|
return /* @__PURE__ */ jsx2(Fragment2, { children: reactNode });
|
|
300
270
|
}
|
|
301
|
-
const filter = filters[key];
|
|
271
|
+
const filter = filters?.[key];
|
|
302
272
|
return /* @__PURE__ */ jsxs2(
|
|
303
273
|
"th",
|
|
304
274
|
{
|
|
305
|
-
className:
|
|
306
|
-
"py-4 border-y font-normal align-top"
|
|
307
|
-
),
|
|
275
|
+
className: cn("py-4 border-y font-normal align-top"),
|
|
308
276
|
children: [
|
|
309
277
|
/* @__PURE__ */ jsx2(Head, {}),
|
|
310
278
|
filter && /* @__PURE__ */ jsx2("div", { className: "px-3 mt-4", children: /* @__PURE__ */ jsxs2(
|
|
@@ -315,12 +283,7 @@ function Table({
|
|
|
315
283
|
const value2 = e.target.value;
|
|
316
284
|
setSearchParams((prev) => {
|
|
317
285
|
if (value2) {
|
|
318
|
-
prev.set(
|
|
319
|
-
key,
|
|
320
|
-
encodeURIComponent(
|
|
321
|
-
value2
|
|
322
|
-
)
|
|
323
|
-
);
|
|
286
|
+
prev.set(key, encodeURIComponent(value2));
|
|
324
287
|
} else {
|
|
325
288
|
prev.delete(key);
|
|
326
289
|
}
|
|
@@ -329,14 +292,7 @@ function Table({
|
|
|
329
292
|
},
|
|
330
293
|
children: [
|
|
331
294
|
/* @__PURE__ */ jsx2("option", { value: "", children: "\uC804\uCCB4" }),
|
|
332
|
-
filter.map((option) => /* @__PURE__ */ jsx2(
|
|
333
|
-
"option",
|
|
334
|
-
{
|
|
335
|
-
value: option,
|
|
336
|
-
children: option
|
|
337
|
-
},
|
|
338
|
-
option
|
|
339
|
-
))
|
|
295
|
+
filter.map((option) => /* @__PURE__ */ jsx2("option", { value: option, children: option }, option))
|
|
340
296
|
]
|
|
341
297
|
}
|
|
342
298
|
) })
|
|
@@ -375,7 +331,7 @@ function Table({
|
|
|
375
331
|
className: "block content-center px-4 w-full h-full",
|
|
376
332
|
children: /* @__PURE__ */ jsx2(Content, {})
|
|
377
333
|
}
|
|
378
|
-
) : /* @__PURE__ */ jsx2(Content, {});
|
|
334
|
+
) : /* @__PURE__ */ jsx2("div", { className: "px-4 w-full h-full content-center", children: /* @__PURE__ */ jsx2(Content, {}) });
|
|
379
335
|
const cell = Mapper ? /* @__PURE__ */ jsx2(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
380
336
|
return /* @__PURE__ */ jsx2("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
381
337
|
}) }, i))
|
|
@@ -385,6 +341,10 @@ function Table({
|
|
|
385
341
|
);
|
|
386
342
|
}
|
|
387
343
|
|
|
344
|
+
// src/table/table_form.tsx
|
|
345
|
+
import { useLocation as useLocation2, useNavigate, useSearchParams as useSearchParams3 } from "react-router";
|
|
346
|
+
import { GoSearch } from "react-icons/go";
|
|
347
|
+
|
|
388
348
|
// src/table/use_table.tsx
|
|
389
349
|
import { useLoaderData } from "react-router";
|
|
390
350
|
function useTable() {
|
|
@@ -473,41 +433,12 @@ function TableForm({
|
|
|
473
433
|
)
|
|
474
434
|
] });
|
|
475
435
|
}
|
|
476
|
-
|
|
477
|
-
// src/table/page.tsx
|
|
478
|
-
import { Fragment as Fragment4, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
479
|
-
function createTablePage({
|
|
480
|
-
name,
|
|
481
|
-
columns,
|
|
482
|
-
primaryKey = "id"
|
|
483
|
-
}) {
|
|
484
|
-
return function TablePage({
|
|
485
|
-
header: Header
|
|
486
|
-
}) {
|
|
487
|
-
const { pathname } = useLocation3();
|
|
488
|
-
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
489
|
-
/* @__PURE__ */ jsx4(
|
|
490
|
-
Header,
|
|
491
|
-
{
|
|
492
|
-
title: name,
|
|
493
|
-
actions: /* @__PURE__ */ jsxs4(Link3, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
494
|
-
name,
|
|
495
|
-
" \uCD94\uAC00"
|
|
496
|
-
] })
|
|
497
|
-
}
|
|
498
|
-
),
|
|
499
|
-
/* @__PURE__ */ jsx4("div", { className: "max-w-7xl mx-auto w-full overflow-auto", children: /* @__PURE__ */ jsx4(TableForm, { columns, primaryKey }) })
|
|
500
|
-
] });
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
436
|
export {
|
|
504
437
|
BaseTableRepository,
|
|
505
438
|
Table,
|
|
506
439
|
TableForm,
|
|
507
440
|
TablePageButtons,
|
|
508
|
-
createTablePage,
|
|
509
441
|
loadTable,
|
|
510
|
-
tableItemloader,
|
|
511
442
|
tableLoader,
|
|
512
443
|
useTable
|
|
513
444
|
};
|