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,14 +0,0 @@
|
|
|
1
|
-
import { TableRepository } from './repository.mjs';
|
|
2
|
-
import { LoaderFunctionArgs } from 'react-router';
|
|
3
|
-
import { PgTableWithColumns } from 'drizzle-orm/pg-core';
|
|
4
|
-
import 'drizzle-orm';
|
|
5
|
-
import 'drizzle-orm/node-postgres';
|
|
6
|
-
|
|
7
|
-
type TableItemLoaderOptions<T extends PgTableWithColumns<any>, TSelect> = {
|
|
8
|
-
repository: TableRepository<T, TSelect>;
|
|
9
|
-
};
|
|
10
|
-
declare const tableItemloader: <T extends PgTableWithColumns<any>, TSelect>({ repository, }: TableItemLoaderOptions<T, TSelect>) => (args: LoaderFunctionArgs) => Promise<{
|
|
11
|
-
item: Awaited<TSelect> | undefined;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
export { type TableItemLoaderOptions, tableItemloader };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TableRepository } from './repository.js';
|
|
2
|
-
import { LoaderFunctionArgs } from 'react-router';
|
|
3
|
-
import { PgTableWithColumns } from 'drizzle-orm/pg-core';
|
|
4
|
-
import 'drizzle-orm';
|
|
5
|
-
import 'drizzle-orm/node-postgres';
|
|
6
|
-
|
|
7
|
-
type TableItemLoaderOptions<T extends PgTableWithColumns<any>, TSelect> = {
|
|
8
|
-
repository: TableRepository<T, TSelect>;
|
|
9
|
-
};
|
|
10
|
-
declare const tableItemloader: <T extends PgTableWithColumns<any>, TSelect>({ repository, }: TableItemLoaderOptions<T, TSelect>) => (args: LoaderFunctionArgs) => Promise<{
|
|
11
|
-
item: Awaited<TSelect> | undefined;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
export { type TableItemLoaderOptions, tableItemloader };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// src/table/item_loader.tsx
|
|
2
|
-
var tableItemloader = ({
|
|
3
|
-
repository
|
|
4
|
-
}) => {
|
|
5
|
-
return async (args) => {
|
|
6
|
-
const { params } = args;
|
|
7
|
-
if (params["itemId"] === "new") {
|
|
8
|
-
return { item: void 0 };
|
|
9
|
-
}
|
|
10
|
-
const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
|
|
11
|
-
return {
|
|
12
|
-
item
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
tableItemloader
|
|
18
|
-
};
|
package/dist/table/page.d.mts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { FC, ReactNode } from 'react';
|
|
3
|
-
import { TablePageOptions } from './table_form.mjs';
|
|
4
|
-
import './table.mjs';
|
|
5
|
-
import './use_table.mjs';
|
|
6
|
-
|
|
7
|
-
declare function createTablePage<TModel>({ name, columns, primaryKey, }: TablePageOptions<TModel> & {
|
|
8
|
-
name: string;
|
|
9
|
-
}): ({ header: Header, }: {
|
|
10
|
-
header: FC<{
|
|
11
|
-
title: string;
|
|
12
|
-
actions?: ReactNode;
|
|
13
|
-
}>;
|
|
14
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
15
|
-
|
|
16
|
-
export { createTablePage };
|
package/dist/table/page.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { FC, ReactNode } from 'react';
|
|
3
|
-
import { TablePageOptions } from './table_form.js';
|
|
4
|
-
import './table.js';
|
|
5
|
-
import './use_table.js';
|
|
6
|
-
|
|
7
|
-
declare function createTablePage<TModel>({ name, columns, primaryKey, }: TablePageOptions<TModel> & {
|
|
8
|
-
name: string;
|
|
9
|
-
}): ({ header: Header, }: {
|
|
10
|
-
header: FC<{
|
|
11
|
-
title: string;
|
|
12
|
-
actions?: ReactNode;
|
|
13
|
-
}>;
|
|
14
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
15
|
-
|
|
16
|
-
export { createTablePage };
|
package/dist/table/page.js
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/table/page.tsx
|
|
21
|
-
var page_exports = {};
|
|
22
|
-
__export(page_exports, {
|
|
23
|
-
createTablePage: () => createTablePage
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(page_exports);
|
|
26
|
-
var import_react_router5 = require("react-router");
|
|
27
|
-
|
|
28
|
-
// src/table/table_form.tsx
|
|
29
|
-
var import_react_router4 = require("react-router");
|
|
30
|
-
var import_go2 = require("react-icons/go");
|
|
31
|
-
|
|
32
|
-
// src/table/table.tsx
|
|
33
|
-
var import_utils = require("dn-react-toolkit/utils");
|
|
34
|
-
var import_go = require("react-icons/go");
|
|
35
|
-
var import_react_router = require("react-router");
|
|
36
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
function Table({
|
|
38
|
-
className = "min-w-full whitespace-nowrap",
|
|
39
|
-
data,
|
|
40
|
-
columns,
|
|
41
|
-
mapper: Mapper,
|
|
42
|
-
getLink,
|
|
43
|
-
limit,
|
|
44
|
-
offset,
|
|
45
|
-
orderBy,
|
|
46
|
-
direction,
|
|
47
|
-
filters
|
|
48
|
-
}) {
|
|
49
|
-
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
50
|
-
const sortedArray = [...data];
|
|
51
|
-
const [_, setSearchParams] = (0, import_react_router.useSearchParams)();
|
|
52
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
53
|
-
"table",
|
|
54
|
-
{
|
|
55
|
-
className: (0, import_utils.cn)(
|
|
56
|
-
className,
|
|
57
|
-
"text-[15px] border-separate border-spacing-0"
|
|
58
|
-
),
|
|
59
|
-
children: [
|
|
60
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: keys.map((key) => {
|
|
61
|
-
const value = columns[key];
|
|
62
|
-
function getReactNode() {
|
|
63
|
-
if (value && typeof value === "object" && "label" in value) {
|
|
64
|
-
return value.label;
|
|
65
|
-
}
|
|
66
|
-
return value;
|
|
67
|
-
}
|
|
68
|
-
function Head() {
|
|
69
|
-
const reactNode = getReactNode();
|
|
70
|
-
if (typeof reactNode === "string") {
|
|
71
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
72
|
-
"button",
|
|
73
|
-
{
|
|
74
|
-
className: (0, import_utils.cn)(
|
|
75
|
-
orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
|
|
76
|
-
"px-4 flex items-center w-full"
|
|
77
|
-
),
|
|
78
|
-
onClick: () => {
|
|
79
|
-
let newDirection = "asc";
|
|
80
|
-
if (orderBy === key) {
|
|
81
|
-
newDirection = direction === "asc" ? "desc" : "asc";
|
|
82
|
-
}
|
|
83
|
-
setSearchParams({
|
|
84
|
-
orderBy: key,
|
|
85
|
-
direction: newDirection
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
children: [
|
|
89
|
-
reactNode,
|
|
90
|
-
orderBy === key && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ml-0.5", children: direction === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_go.GoArrowUp, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_go.GoArrowDown, {}) })
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: reactNode });
|
|
96
|
-
}
|
|
97
|
-
const filter = filters[key];
|
|
98
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
99
|
-
"th",
|
|
100
|
-
{
|
|
101
|
-
className: (0, import_utils.cn)(
|
|
102
|
-
"py-4 border-y font-normal align-top"
|
|
103
|
-
),
|
|
104
|
-
children: [
|
|
105
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Head, {}),
|
|
106
|
-
filter && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-3 mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
107
|
-
"select",
|
|
108
|
-
{
|
|
109
|
-
className: "w-full h-10 px-1.5 border rounded-full outline-none",
|
|
110
|
-
onChange: (e) => {
|
|
111
|
-
const value2 = e.target.value;
|
|
112
|
-
setSearchParams((prev) => {
|
|
113
|
-
if (value2) {
|
|
114
|
-
prev.set(
|
|
115
|
-
key,
|
|
116
|
-
encodeURIComponent(
|
|
117
|
-
value2
|
|
118
|
-
)
|
|
119
|
-
);
|
|
120
|
-
} else {
|
|
121
|
-
prev.delete(key);
|
|
122
|
-
}
|
|
123
|
-
return prev;
|
|
124
|
-
});
|
|
125
|
-
},
|
|
126
|
-
children: [
|
|
127
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "\uC804\uCCB4" }),
|
|
128
|
-
filter.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
129
|
-
"option",
|
|
130
|
-
{
|
|
131
|
-
value: option,
|
|
132
|
-
children: option
|
|
133
|
-
},
|
|
134
|
-
option
|
|
135
|
-
))
|
|
136
|
-
]
|
|
137
|
-
}
|
|
138
|
-
) })
|
|
139
|
-
]
|
|
140
|
-
},
|
|
141
|
-
key
|
|
142
|
-
);
|
|
143
|
-
}) }) }),
|
|
144
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [
|
|
145
|
-
sortedArray.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
146
|
-
"td",
|
|
147
|
-
{
|
|
148
|
-
colSpan: keys.length,
|
|
149
|
-
className: "px-4 h-20 text-gray-400 text-center",
|
|
150
|
-
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
151
|
-
}
|
|
152
|
-
) }),
|
|
153
|
-
sortedArray.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
|
|
154
|
-
const value = item[key];
|
|
155
|
-
function Content() {
|
|
156
|
-
if (key in columns) {
|
|
157
|
-
const column = columns[key];
|
|
158
|
-
if (column && typeof column === "object" && "mapper" in column) {
|
|
159
|
-
const mapper = column.mapper;
|
|
160
|
-
if (mapper) {
|
|
161
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: mapper(item) });
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: String(value) });
|
|
166
|
-
}
|
|
167
|
-
const linkedContent = getLink ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
|
-
import_react_router.Link,
|
|
169
|
-
{
|
|
170
|
-
to: getLink(item),
|
|
171
|
-
className: "block content-center px-4 w-full h-full",
|
|
172
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Content, {})
|
|
173
|
-
}
|
|
174
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Content, {});
|
|
175
|
-
const cell = Mapper ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
176
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
177
|
-
}) }, i))
|
|
178
|
-
] })
|
|
179
|
-
]
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// src/table/use_table.tsx
|
|
185
|
-
var import_react_router2 = require("react-router");
|
|
186
|
-
function useTable() {
|
|
187
|
-
const { table } = (0, import_react_router2.useLoaderData)();
|
|
188
|
-
return table;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// src/table/buttons.tsx
|
|
192
|
-
var import_utils2 = require("dn-react-toolkit/utils");
|
|
193
|
-
var import_react_router3 = require("react-router");
|
|
194
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
195
|
-
function TablePageButtons({
|
|
196
|
-
MAX_PAGES_TO_SHOW,
|
|
197
|
-
total,
|
|
198
|
-
limit,
|
|
199
|
-
offset
|
|
200
|
-
}) {
|
|
201
|
-
const pages = Math.ceil(total / limit);
|
|
202
|
-
const { pathname } = (0, import_react_router3.useLocation)();
|
|
203
|
-
const [searchParams] = (0, import_react_router3.useSearchParams)();
|
|
204
|
-
const currentPage = Math.floor(offset / limit) + 1;
|
|
205
|
-
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
206
|
-
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
207
|
-
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: [
|
|
208
|
-
startButton > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
209
|
-
import_react_router3.Link,
|
|
210
|
-
{
|
|
211
|
-
to: (() => {
|
|
212
|
-
searchParams.set(
|
|
213
|
-
"offset",
|
|
214
|
-
String((startButton - 1) * limit)
|
|
215
|
-
);
|
|
216
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
217
|
-
})(),
|
|
218
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
219
|
-
children: "\uC774\uC804"
|
|
220
|
-
}
|
|
221
|
-
),
|
|
222
|
-
Array.from({
|
|
223
|
-
length: Math.min(
|
|
224
|
-
MAX_PAGES_TO_SHOW,
|
|
225
|
-
pages - startButton
|
|
226
|
-
)
|
|
227
|
-
}).map((_, index) => {
|
|
228
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
229
|
-
import_react_router3.Link,
|
|
230
|
-
{
|
|
231
|
-
to: (() => {
|
|
232
|
-
searchParams.set(
|
|
233
|
-
"offset",
|
|
234
|
-
String((startButton + index) * limit)
|
|
235
|
-
);
|
|
236
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
237
|
-
})(),
|
|
238
|
-
className: (0, import_utils2.cn)(
|
|
239
|
-
"w-6 block text-center transition-colors",
|
|
240
|
-
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
241
|
-
),
|
|
242
|
-
children: startButton + index + 1
|
|
243
|
-
},
|
|
244
|
-
index
|
|
245
|
-
);
|
|
246
|
-
}),
|
|
247
|
-
endButton < pages && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
248
|
-
import_react_router3.Link,
|
|
249
|
-
{
|
|
250
|
-
to: (() => {
|
|
251
|
-
searchParams.set(
|
|
252
|
-
"offset",
|
|
253
|
-
String((endButton + 1) * limit)
|
|
254
|
-
);
|
|
255
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
256
|
-
})(),
|
|
257
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
258
|
-
children: "\uB2E4\uC74C"
|
|
259
|
-
}
|
|
260
|
-
)
|
|
261
|
-
] }) });
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// src/table/table_form.tsx
|
|
265
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
266
|
-
function TableForm({
|
|
267
|
-
columns,
|
|
268
|
-
primaryKey = "id"
|
|
269
|
-
}) {
|
|
270
|
-
const { pathname } = (0, import_react_router4.useLocation)();
|
|
271
|
-
const {
|
|
272
|
-
items,
|
|
273
|
-
total,
|
|
274
|
-
limit,
|
|
275
|
-
offset,
|
|
276
|
-
orderBy,
|
|
277
|
-
direction,
|
|
278
|
-
searchKey,
|
|
279
|
-
filters
|
|
280
|
-
} = useTable();
|
|
281
|
-
const navigate = (0, import_react_router4.useNavigate)();
|
|
282
|
-
const search = (query) => {
|
|
283
|
-
const searchParams2 = new URLSearchParams(window.location.search);
|
|
284
|
-
searchParams2.set("query", query);
|
|
285
|
-
searchParams2.set("offset", "0");
|
|
286
|
-
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
287
|
-
};
|
|
288
|
-
const [searchParams] = (0, import_react_router4.useSearchParams)();
|
|
289
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
290
|
-
searchKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
291
|
-
"form",
|
|
292
|
-
{
|
|
293
|
-
className: "h-20 px-4 flex items-center border-t",
|
|
294
|
-
onSubmit: (e) => {
|
|
295
|
-
e.preventDefault();
|
|
296
|
-
const formData = new FormData(e.currentTarget);
|
|
297
|
-
const query = formData.get("query");
|
|
298
|
-
search(query);
|
|
299
|
-
},
|
|
300
|
-
children: [
|
|
301
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
302
|
-
"button",
|
|
303
|
-
{
|
|
304
|
-
type: "submit",
|
|
305
|
-
className: "w-10 h-10 flex justify-center items-center",
|
|
306
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_go2.GoSearch, { className: "text-xl mr-4" })
|
|
307
|
-
}
|
|
308
|
-
),
|
|
309
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
310
|
-
"input",
|
|
311
|
-
{
|
|
312
|
-
className: "outline-none h-full flex-1",
|
|
313
|
-
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
314
|
-
name: "query",
|
|
315
|
-
defaultValue: searchParams.get("query") ?? ""
|
|
316
|
-
}
|
|
317
|
-
)
|
|
318
|
-
]
|
|
319
|
-
}
|
|
320
|
-
),
|
|
321
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
322
|
-
Table,
|
|
323
|
-
{
|
|
324
|
-
data: items,
|
|
325
|
-
columns,
|
|
326
|
-
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
327
|
-
limit,
|
|
328
|
-
offset,
|
|
329
|
-
orderBy,
|
|
330
|
-
direction,
|
|
331
|
-
filters
|
|
332
|
-
}
|
|
333
|
-
),
|
|
334
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
335
|
-
TablePageButtons,
|
|
336
|
-
{
|
|
337
|
-
total,
|
|
338
|
-
limit,
|
|
339
|
-
offset,
|
|
340
|
-
MAX_PAGES_TO_SHOW: 10
|
|
341
|
-
}
|
|
342
|
-
)
|
|
343
|
-
] });
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// src/table/page.tsx
|
|
347
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
348
|
-
function createTablePage({
|
|
349
|
-
name,
|
|
350
|
-
columns,
|
|
351
|
-
primaryKey = "id"
|
|
352
|
-
}) {
|
|
353
|
-
return function TablePage({
|
|
354
|
-
header: Header
|
|
355
|
-
}) {
|
|
356
|
-
const { pathname } = (0, import_react_router5.useLocation)();
|
|
357
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
358
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
359
|
-
Header,
|
|
360
|
-
{
|
|
361
|
-
title: name,
|
|
362
|
-
actions: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_router5.Link, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
363
|
-
name,
|
|
364
|
-
" \uCD94\uAC00"
|
|
365
|
-
] })
|
|
366
|
-
}
|
|
367
|
-
),
|
|
368
|
-
/* @__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 }) })
|
|
369
|
-
] });
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
373
|
-
0 && (module.exports = {
|
|
374
|
-
createTablePage
|
|
375
|
-
});
|