dn-react-router-toolkit 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +13 -4
- package/dist/api/index.mjs +14 -5
- package/dist/api/item_api_handler.d.mts +4 -2
- package/dist/api/item_api_handler.d.ts +4 -2
- package/dist/api/item_api_handler.js +13 -4
- package/dist/api/item_api_handler.mjs +14 -5
- package/dist/crud/index.d.mts +0 -20
- package/dist/crud/index.d.ts +0 -20
- package/dist/crud/index.js +12 -8508
- package/dist/crud/index.mjs +0 -8516
- package/dist/post/index.js +67 -7705
- package/dist/post/index.mjs +54 -7717
- package/dist/post/post_form_page.js +67 -7705
- package/dist/post/post_form_page.mjs +54 -7717
- package/dist/table/index.d.mts +1 -3
- package/dist/table/index.d.ts +1 -3
- package/dist/table/index.js +83 -76
- package/dist/table/index.mjs +84 -74
- package/dist/table/load_table.d.mts +8 -2
- package/dist/table/load_table.d.ts +8 -2
- package/dist/table/load_table.js +23 -3
- package/dist/table/load_table.mjs +24 -3
- package/dist/table/loader.d.mts +3 -0
- package/dist/table/loader.d.ts +3 -0
- package/dist/table/loader.js +23 -3
- package/dist/table/loader.mjs +24 -3
- package/dist/table/repository.d.mts +6 -4
- package/dist/table/repository.d.ts +6 -4
- package/dist/table/repository.js +4 -0
- package/dist/table/repository.mjs +4 -0
- package/dist/table/table.d.mts +5 -2
- package/dist/table/table.d.ts +5 -2
- package/dist/table/table.js +38 -6
- package/dist/table/table.mjs +38 -6
- package/dist/table/table_form.d.mts +2 -2
- package/dist/table/table_form.d.ts +2 -2
- package/dist/table/table_form.js +52 -19
- package/dist/table/table_form.mjs +52 -19
- package/dist/table/use_table.d.mts +3 -3
- package/dist/table/use_table.d.ts +3 -3
- package/dist/table/use_table.js +1 -10
- package/dist/table/use_table.mjs +1 -10
- package/package.json +1 -1
- 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 -322
- package/dist/crud/crud_loader.mjs +0 -307
- 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 -726
- package/dist/crud/crud_page.mjs +0 -708
- package/dist/crud/generate_handlers.d.mts +0 -16
- package/dist/crud/generate_handlers.d.ts +0 -16
- package/dist/crud/generate_handlers.js +0 -39
- 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.js +0 -55
- 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.js +0 -43
- 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 -325
- package/dist/table/page.mjs +0 -300
|
@@ -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,43 +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/item_loader.tsx
|
|
21
|
-
var item_loader_exports = {};
|
|
22
|
-
__export(item_loader_exports, {
|
|
23
|
-
tableItemloader: () => tableItemloader
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(item_loader_exports);
|
|
26
|
-
var tableItemloader = ({
|
|
27
|
-
repository
|
|
28
|
-
}) => {
|
|
29
|
-
return async (args) => {
|
|
30
|
-
const { params } = args;
|
|
31
|
-
if (params["itemId"] === "new") {
|
|
32
|
-
return { item: void 0 };
|
|
33
|
-
}
|
|
34
|
-
const item = params["itemId"] ? await repository.find(params["itemId"]) : void 0;
|
|
35
|
-
return {
|
|
36
|
-
item
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
42
|
-
tableItemloader
|
|
43
|
-
});
|
|
@@ -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,325 +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
|
-
}) {
|
|
48
|
-
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
49
|
-
const sortedArray = [...data];
|
|
50
|
-
const [_, setSearchParams] = (0, import_react_router.useSearchParams)();
|
|
51
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
52
|
-
"table",
|
|
53
|
-
{
|
|
54
|
-
className: (0, import_utils.cn)(className, "text-[15px] border-separate border-spacing-0"),
|
|
55
|
-
children: [
|
|
56
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: keys.map((key) => {
|
|
57
|
-
const value = columns[key];
|
|
58
|
-
function getReactNode() {
|
|
59
|
-
if (value && typeof value === "object" && "label" in value) {
|
|
60
|
-
return value.label;
|
|
61
|
-
}
|
|
62
|
-
return value;
|
|
63
|
-
}
|
|
64
|
-
function Head() {
|
|
65
|
-
const reactNode = getReactNode();
|
|
66
|
-
if (typeof reactNode === "string") {
|
|
67
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
68
|
-
"button",
|
|
69
|
-
{
|
|
70
|
-
className: (0, import_utils.cn)(
|
|
71
|
-
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
72
|
-
"px-4 h-14 flex items-center w-full"
|
|
73
|
-
),
|
|
74
|
-
onClick: () => {
|
|
75
|
-
let newDirection = "asc";
|
|
76
|
-
if (orderBy === key) {
|
|
77
|
-
newDirection = direction === "asc" ? "desc" : "asc";
|
|
78
|
-
}
|
|
79
|
-
setSearchParams({
|
|
80
|
-
orderBy: key,
|
|
81
|
-
direction: newDirection
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
children: [
|
|
85
|
-
reactNode,
|
|
86
|
-
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, {}) })
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: reactNode });
|
|
92
|
-
}
|
|
93
|
-
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
|
-
}) }) }),
|
|
95
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [
|
|
96
|
-
sortedArray.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
|
-
"td",
|
|
98
|
-
{
|
|
99
|
-
colSpan: keys.length,
|
|
100
|
-
className: "px-4 h-14 text-neutral-400 text-center",
|
|
101
|
-
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
102
|
-
}
|
|
103
|
-
) }),
|
|
104
|
-
sortedArray.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
|
|
105
|
-
const value = item[key];
|
|
106
|
-
function Content() {
|
|
107
|
-
if (key in columns) {
|
|
108
|
-
const column = columns[key];
|
|
109
|
-
if (column && typeof column === "object" && "mapper" in column) {
|
|
110
|
-
const mapper = column.mapper;
|
|
111
|
-
if (mapper) {
|
|
112
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: mapper(item) });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: String(value) });
|
|
117
|
-
}
|
|
118
|
-
const linkedContent = getLink ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
119
|
-
import_react_router.Link,
|
|
120
|
-
{
|
|
121
|
-
to: getLink(item),
|
|
122
|
-
className: "block content-center px-4 w-full h-full",
|
|
123
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Content, {})
|
|
124
|
-
}
|
|
125
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Content, {});
|
|
126
|
-
const cell = Mapper ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
127
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
128
|
-
}) }, i))
|
|
129
|
-
] })
|
|
130
|
-
]
|
|
131
|
-
}
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// src/table/use_table.tsx
|
|
136
|
-
var import_react_router2 = require("react-router");
|
|
137
|
-
function useTable() {
|
|
138
|
-
const { table } = (0, import_react_router2.useLoaderData)();
|
|
139
|
-
const { items, total, limit, offset, orderBy, direction, searchKey } = table;
|
|
140
|
-
return {
|
|
141
|
-
items,
|
|
142
|
-
total,
|
|
143
|
-
limit,
|
|
144
|
-
offset,
|
|
145
|
-
orderBy,
|
|
146
|
-
direction,
|
|
147
|
-
searchKey
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/table/buttons.tsx
|
|
152
|
-
var import_utils2 = require("dn-react-toolkit/utils");
|
|
153
|
-
var import_react_router3 = require("react-router");
|
|
154
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
155
|
-
function TablePageButtons({
|
|
156
|
-
MAX_PAGES_TO_SHOW,
|
|
157
|
-
total,
|
|
158
|
-
limit,
|
|
159
|
-
offset
|
|
160
|
-
}) {
|
|
161
|
-
const pages = Math.ceil(total / limit);
|
|
162
|
-
const { pathname } = (0, import_react_router3.useLocation)();
|
|
163
|
-
const [searchParams] = (0, import_react_router3.useSearchParams)();
|
|
164
|
-
const currentPage = Math.floor(offset / limit) + 1;
|
|
165
|
-
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
166
|
-
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
167
|
-
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: [
|
|
168
|
-
startButton > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
169
|
-
import_react_router3.Link,
|
|
170
|
-
{
|
|
171
|
-
to: (() => {
|
|
172
|
-
searchParams.set(
|
|
173
|
-
"offset",
|
|
174
|
-
String((startButton - 1) * limit)
|
|
175
|
-
);
|
|
176
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
177
|
-
})(),
|
|
178
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
179
|
-
children: "\uC774\uC804"
|
|
180
|
-
}
|
|
181
|
-
),
|
|
182
|
-
Array.from({
|
|
183
|
-
length: Math.min(
|
|
184
|
-
MAX_PAGES_TO_SHOW,
|
|
185
|
-
pages - startButton
|
|
186
|
-
)
|
|
187
|
-
}).map((_, index) => {
|
|
188
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
189
|
-
import_react_router3.Link,
|
|
190
|
-
{
|
|
191
|
-
to: (() => {
|
|
192
|
-
searchParams.set(
|
|
193
|
-
"offset",
|
|
194
|
-
String((startButton + index) * limit)
|
|
195
|
-
);
|
|
196
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
197
|
-
})(),
|
|
198
|
-
className: (0, import_utils2.cn)(
|
|
199
|
-
"w-6 block text-center transition-colors",
|
|
200
|
-
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
201
|
-
),
|
|
202
|
-
children: startButton + index + 1
|
|
203
|
-
},
|
|
204
|
-
index
|
|
205
|
-
);
|
|
206
|
-
}),
|
|
207
|
-
endButton < pages && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
208
|
-
import_react_router3.Link,
|
|
209
|
-
{
|
|
210
|
-
to: (() => {
|
|
211
|
-
searchParams.set(
|
|
212
|
-
"offset",
|
|
213
|
-
String((endButton + 1) * limit)
|
|
214
|
-
);
|
|
215
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
216
|
-
})(),
|
|
217
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
218
|
-
children: "\uB2E4\uC74C"
|
|
219
|
-
}
|
|
220
|
-
)
|
|
221
|
-
] }) });
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// src/table/table_form.tsx
|
|
225
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
226
|
-
function TableForm({
|
|
227
|
-
columns,
|
|
228
|
-
primaryKey = "id"
|
|
229
|
-
}) {
|
|
230
|
-
const { pathname } = (0, import_react_router4.useLocation)();
|
|
231
|
-
const { items, total, limit, offset, orderBy, direction, searchKey } = useTable();
|
|
232
|
-
const navigate = (0, import_react_router4.useNavigate)();
|
|
233
|
-
const search = (query) => {
|
|
234
|
-
const searchParams2 = new URLSearchParams(window.location.search);
|
|
235
|
-
searchParams2.set("query", query);
|
|
236
|
-
searchParams2.set("offset", "0");
|
|
237
|
-
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
238
|
-
};
|
|
239
|
-
const [searchParams] = (0, import_react_router4.useSearchParams)();
|
|
240
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
241
|
-
searchKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
242
|
-
"form",
|
|
243
|
-
{
|
|
244
|
-
className: "h-18 px-4 flex items-center border-t",
|
|
245
|
-
onSubmit: (e) => {
|
|
246
|
-
e.preventDefault();
|
|
247
|
-
const formData = new FormData(e.currentTarget);
|
|
248
|
-
const query = formData.get("query");
|
|
249
|
-
search(query);
|
|
250
|
-
},
|
|
251
|
-
children: [
|
|
252
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
253
|
-
"button",
|
|
254
|
-
{
|
|
255
|
-
type: "submit",
|
|
256
|
-
className: "w-10 h-10 flex justify-center items-center",
|
|
257
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_go2.GoSearch, { className: "text-xl mr-4" })
|
|
258
|
-
}
|
|
259
|
-
),
|
|
260
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
261
|
-
"input",
|
|
262
|
-
{
|
|
263
|
-
className: "outline-none h-full flex-1",
|
|
264
|
-
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
265
|
-
name: "query",
|
|
266
|
-
defaultValue: searchParams.get("query") ?? ""
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
]
|
|
270
|
-
}
|
|
271
|
-
),
|
|
272
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
273
|
-
Table,
|
|
274
|
-
{
|
|
275
|
-
data: items,
|
|
276
|
-
columns,
|
|
277
|
-
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
278
|
-
limit,
|
|
279
|
-
offset,
|
|
280
|
-
orderBy,
|
|
281
|
-
direction
|
|
282
|
-
}
|
|
283
|
-
),
|
|
284
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
285
|
-
TablePageButtons,
|
|
286
|
-
{
|
|
287
|
-
total,
|
|
288
|
-
limit,
|
|
289
|
-
offset,
|
|
290
|
-
MAX_PAGES_TO_SHOW: 10
|
|
291
|
-
}
|
|
292
|
-
)
|
|
293
|
-
] });
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// src/table/page.tsx
|
|
297
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
298
|
-
function createTablePage({
|
|
299
|
-
name,
|
|
300
|
-
columns,
|
|
301
|
-
primaryKey = "id"
|
|
302
|
-
}) {
|
|
303
|
-
return function TablePage({
|
|
304
|
-
header: Header
|
|
305
|
-
}) {
|
|
306
|
-
const { pathname } = (0, import_react_router5.useLocation)();
|
|
307
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
308
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
309
|
-
Header,
|
|
310
|
-
{
|
|
311
|
-
title: name,
|
|
312
|
-
actions: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react_router5.Link, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
313
|
-
name,
|
|
314
|
-
" \uCD94\uAC00"
|
|
315
|
-
] })
|
|
316
|
-
}
|
|
317
|
-
),
|
|
318
|
-
/* @__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 }) })
|
|
319
|
-
] });
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
323
|
-
0 && (module.exports = {
|
|
324
|
-
createTablePage
|
|
325
|
-
});
|