dn-react-router-toolkit 0.7.14 → 0.8.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/create_api_handler.d.mts +5 -4
- package/dist/api/create_api_handler.d.ts +5 -4
- package/dist/api/create_api_handler.js +0 -1
- package/dist/api/create_api_handler.mjs +0 -1
- package/dist/api/index.d.mts +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +0 -2
- package/dist/api/index.mjs +0 -2
- package/dist/api/item_api_handler.d.mts +5 -4
- package/dist/api/item_api_handler.d.ts +5 -4
- package/dist/api/item_api_handler.js +0 -1
- package/dist/api/item_api_handler.mjs +0 -1
- package/dist/auth/cookie_manager.d.mts +2 -1
- package/dist/auth/cookie_manager.d.ts +2 -1
- package/dist/auth/cookie_manager.js +9 -3
- package/dist/auth/cookie_manager.mjs +9 -3
- package/dist/auth/index.js +9 -3
- package/dist/auth/index.mjs +9 -3
- package/dist/crud/crud_form.js +1 -1
- package/dist/crud/crud_form.mjs +1 -1
- package/dist/crud/crud_loader.d.mts +6 -5
- package/dist/crud/crud_loader.d.ts +6 -5
- package/dist/crud/crud_loader.js +46 -34
- package/dist/crud/crud_loader.mjs +46 -34
- package/dist/crud/crud_page.d.mts +3 -2
- package/dist/crud/crud_page.d.ts +3 -2
- package/dist/crud/crud_page.js +226 -198
- package/dist/crud/crud_page.mjs +224 -202
- package/dist/crud/generate_handlers.d.mts +3 -2
- package/dist/crud/generate_handlers.d.ts +3 -2
- package/dist/crud/generate_pages.d.mts +2 -1
- package/dist/crud/generate_pages.d.ts +2 -1
- package/dist/crud/index.d.mts +5 -3
- package/dist/crud/index.d.ts +5 -3
- package/dist/crud/index.js +246 -206
- package/dist/crud/index.mjs +252 -218
- package/dist/post/index.js +65 -58
- package/dist/post/index.mjs +68 -67
- package/dist/post/post_form_page.js +65 -58
- package/dist/post/post_form_page.mjs +68 -67
- package/dist/table/index.d.mts +7 -3
- package/dist/table/index.d.ts +7 -3
- package/dist/table/index.js +153 -105
- package/dist/table/index.mjs +149 -110
- package/dist/table/item_loader.d.mts +5 -4
- package/dist/table/item_loader.d.ts +5 -4
- package/dist/table/load_table.d.mts +30 -0
- package/dist/table/load_table.d.ts +30 -0
- package/dist/table/load_table.js +67 -0
- package/dist/table/load_table.mjs +45 -0
- package/dist/table/loader.d.mts +7 -15
- package/dist/table/loader.d.ts +7 -15
- package/dist/table/loader.js +47 -31
- package/dist/table/loader.mjs +46 -32
- package/dist/table/page.d.mts +6 -16
- package/dist/table/page.d.ts +6 -16
- package/dist/table/page.js +193 -165
- package/dist/table/page.mjs +194 -172
- package/dist/table/repository.d.mts +13 -11
- package/dist/table/repository.d.ts +13 -11
- package/dist/table/repository.js +1 -1
- package/dist/table/repository.mjs +1 -1
- package/dist/table/table_form.d.mts +13 -0
- package/dist/table/table_form.d.ts +13 -0
- package/dist/table/table_form.js +295 -0
- package/dist/table/table_form.mjs +270 -0
- package/dist/table/use_table.d.mts +4 -0
- package/dist/table/use_table.d.ts +4 -0
- package/dist/table/use_table.js +43 -0
- package/dist/table/use_table.mjs +18 -0
- package/package.json +3 -3
package/dist/crud/index.mjs
CHANGED
|
@@ -7971,54 +7971,68 @@ function CrudForm({
|
|
|
7971
7971
|
return /* @__PURE__ */ jsx6(FormRow, { children: /* @__PURE__ */ jsxs2(FormEntry, { children: [
|
|
7972
7972
|
/* @__PURE__ */ jsx6(FormLabel, { children: value.label }, name),
|
|
7973
7973
|
/* @__PURE__ */ jsx6(InputComponent, {})
|
|
7974
|
-
] }) });
|
|
7974
|
+
] }) }, name);
|
|
7975
7975
|
}
|
|
7976
7976
|
) }) })
|
|
7977
7977
|
] });
|
|
7978
7978
|
}
|
|
7979
7979
|
|
|
7980
|
-
// src/table/
|
|
7980
|
+
// src/table/load_table.tsx
|
|
7981
7981
|
import {
|
|
7982
7982
|
and,
|
|
7983
7983
|
ilike
|
|
7984
7984
|
} from "drizzle-orm";
|
|
7985
|
+
async function loadTable({
|
|
7986
|
+
request,
|
|
7987
|
+
repository,
|
|
7988
|
+
options
|
|
7989
|
+
}) {
|
|
7990
|
+
const searchParams = new URL(request.url).searchParams;
|
|
7991
|
+
const { where, searchKey, defaultOrderBy, defaultDirection } = options;
|
|
7992
|
+
const query = searchParams.get("query") ?? void 0;
|
|
7993
|
+
const limit = Number(searchParams.get("limit") ?? "20");
|
|
7994
|
+
const offset = Number(searchParams.get("offset") ?? "0");
|
|
7995
|
+
const orderBy = searchParams.get("orderBy") ?? defaultOrderBy;
|
|
7996
|
+
const direction = searchParams.get("direction") ?? defaultDirection;
|
|
7997
|
+
const whereClauses = and(
|
|
7998
|
+
searchKey && query ? ilike(
|
|
7999
|
+
repository.schema[searchKey],
|
|
8000
|
+
`%${query}%`
|
|
8001
|
+
) : void 0,
|
|
8002
|
+
...where ?? []
|
|
8003
|
+
);
|
|
8004
|
+
const total = await repository.countTotal({ where: whereClauses });
|
|
8005
|
+
const items = await repository.findAll({
|
|
8006
|
+
orderBy,
|
|
8007
|
+
direction,
|
|
8008
|
+
limit,
|
|
8009
|
+
offset,
|
|
8010
|
+
where: whereClauses
|
|
8011
|
+
});
|
|
8012
|
+
return {
|
|
8013
|
+
items,
|
|
8014
|
+
total,
|
|
8015
|
+
limit,
|
|
8016
|
+
offset,
|
|
8017
|
+
orderBy,
|
|
8018
|
+
direction,
|
|
8019
|
+
searchKey
|
|
8020
|
+
};
|
|
8021
|
+
}
|
|
8022
|
+
|
|
8023
|
+
// src/table/loader.tsx
|
|
7985
8024
|
function tableLoader({
|
|
7986
8025
|
repository,
|
|
7987
|
-
|
|
8026
|
+
options
|
|
7988
8027
|
}) {
|
|
7989
8028
|
return async ({ request }) => {
|
|
7990
|
-
const
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
const offset = Number(searchParams.get("offset") ?? "0");
|
|
7995
|
-
const orderBy = searchParams.get("orderBy") ?? defaultOrderBy;
|
|
7996
|
-
const direction = searchParams.get("direction") ?? defaultDirection;
|
|
7997
|
-
const whereClauses = and(
|
|
7998
|
-
searchKey && query ? ilike(
|
|
7999
|
-
repository.schema[searchKey],
|
|
8000
|
-
`%${query}%`
|
|
8001
|
-
) : void 0,
|
|
8002
|
-
...where ?? []
|
|
8003
|
-
);
|
|
8004
|
-
const total = await repository.countTotal({ where: whereClauses });
|
|
8005
|
-
const items = await repository.findAll({
|
|
8006
|
-
orderBy,
|
|
8007
|
-
direction,
|
|
8008
|
-
limit,
|
|
8009
|
-
offset,
|
|
8010
|
-
where: whereClauses
|
|
8029
|
+
const table = await loadTable({
|
|
8030
|
+
request,
|
|
8031
|
+
repository,
|
|
8032
|
+
options
|
|
8011
8033
|
});
|
|
8012
8034
|
return {
|
|
8013
|
-
table
|
|
8014
|
-
items,
|
|
8015
|
-
total,
|
|
8016
|
-
limit,
|
|
8017
|
-
offset,
|
|
8018
|
-
orderBy,
|
|
8019
|
-
direction,
|
|
8020
|
-
searchKey
|
|
8021
|
-
}
|
|
8035
|
+
table
|
|
8022
8036
|
};
|
|
8023
8037
|
};
|
|
8024
8038
|
}
|
|
@@ -8051,7 +8065,6 @@ import {
|
|
|
8051
8065
|
import {
|
|
8052
8066
|
and as and2
|
|
8053
8067
|
} from "drizzle-orm";
|
|
8054
|
-
import "react-router";
|
|
8055
8068
|
import { v4 } from "uuid";
|
|
8056
8069
|
function apiHandler({
|
|
8057
8070
|
withAuthAction,
|
|
@@ -8140,7 +8153,6 @@ function apiHandler({
|
|
|
8140
8153
|
|
|
8141
8154
|
// src/api/item_api_handler.ts
|
|
8142
8155
|
import { UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
8143
|
-
import "react-router";
|
|
8144
8156
|
function itemApiHandler({
|
|
8145
8157
|
withAuthAction,
|
|
8146
8158
|
repository
|
|
@@ -8232,96 +8244,20 @@ function crudHandler({
|
|
|
8232
8244
|
}
|
|
8233
8245
|
|
|
8234
8246
|
// src/crud/crud_page.tsx
|
|
8235
|
-
import { useLoaderData as useLoaderData2, useLocation as
|
|
8247
|
+
import { useLoaderData as useLoaderData2, useLocation as useLocation4 } from "react-router";
|
|
8236
8248
|
|
|
8237
8249
|
// src/table/page.tsx
|
|
8238
|
-
import {
|
|
8239
|
-
Link as Link3,
|
|
8240
|
-
useLoaderData,
|
|
8241
|
-
useLocation as useLocation2,
|
|
8242
|
-
useNavigate as useNavigate2,
|
|
8243
|
-
useSearchParams as useSearchParams3
|
|
8244
|
-
} from "react-router";
|
|
8245
|
-
import { GoSearch } from "react-icons/go";
|
|
8250
|
+
import { Link as Link3, useLocation as useLocation3 } from "react-router";
|
|
8246
8251
|
|
|
8247
|
-
// src/table/
|
|
8248
|
-
import {
|
|
8249
|
-
import {
|
|
8250
|
-
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
8251
|
-
function TablePageButtons({
|
|
8252
|
-
MAX_PAGES_TO_SHOW,
|
|
8253
|
-
total,
|
|
8254
|
-
limit,
|
|
8255
|
-
offset
|
|
8256
|
-
}) {
|
|
8257
|
-
const pages = Math.ceil(total / limit);
|
|
8258
|
-
const { pathname } = useLocation();
|
|
8259
|
-
const [searchParams] = useSearchParams();
|
|
8260
|
-
const currentPage = Math.floor(offset / limit) + 1;
|
|
8261
|
-
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
8262
|
-
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
8263
|
-
return /* @__PURE__ */ jsx7(Fragment3, { children: pages > 1 && /* @__PURE__ */ jsxs3("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
8264
|
-
startButton > 1 && /* @__PURE__ */ jsx7(
|
|
8265
|
-
Link,
|
|
8266
|
-
{
|
|
8267
|
-
to: (() => {
|
|
8268
|
-
searchParams.set(
|
|
8269
|
-
"offset",
|
|
8270
|
-
String((startButton - 1) * limit)
|
|
8271
|
-
);
|
|
8272
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
8273
|
-
})(),
|
|
8274
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
8275
|
-
children: "\uC774\uC804"
|
|
8276
|
-
}
|
|
8277
|
-
),
|
|
8278
|
-
Array.from({
|
|
8279
|
-
length: Math.min(
|
|
8280
|
-
MAX_PAGES_TO_SHOW,
|
|
8281
|
-
pages - startButton
|
|
8282
|
-
)
|
|
8283
|
-
}).map((_, index2) => {
|
|
8284
|
-
return /* @__PURE__ */ jsx7(
|
|
8285
|
-
Link,
|
|
8286
|
-
{
|
|
8287
|
-
to: (() => {
|
|
8288
|
-
searchParams.set(
|
|
8289
|
-
"offset",
|
|
8290
|
-
String((startButton + index2) * limit)
|
|
8291
|
-
);
|
|
8292
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
8293
|
-
})(),
|
|
8294
|
-
className: cn2(
|
|
8295
|
-
"w-6 block text-center transition-colors",
|
|
8296
|
-
currentPage === startButton + index2 + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
8297
|
-
),
|
|
8298
|
-
children: startButton + index2 + 1
|
|
8299
|
-
},
|
|
8300
|
-
index2
|
|
8301
|
-
);
|
|
8302
|
-
}),
|
|
8303
|
-
endButton < pages && /* @__PURE__ */ jsx7(
|
|
8304
|
-
Link,
|
|
8305
|
-
{
|
|
8306
|
-
to: (() => {
|
|
8307
|
-
searchParams.set(
|
|
8308
|
-
"offset",
|
|
8309
|
-
String((endButton + 1) * limit)
|
|
8310
|
-
);
|
|
8311
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
8312
|
-
})(),
|
|
8313
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
8314
|
-
children: "\uB2E4\uC74C"
|
|
8315
|
-
}
|
|
8316
|
-
)
|
|
8317
|
-
] }) });
|
|
8318
|
-
}
|
|
8252
|
+
// src/table/table_form.tsx
|
|
8253
|
+
import { useLocation as useLocation2, useNavigate as useNavigate2, useSearchParams as useSearchParams3 } from "react-router";
|
|
8254
|
+
import { GoSearch } from "react-icons/go";
|
|
8319
8255
|
|
|
8320
8256
|
// src/table/table.tsx
|
|
8321
|
-
import { cn as
|
|
8257
|
+
import { cn as cn2 } from "dn-react-toolkit/utils";
|
|
8322
8258
|
import { GoArrowDown, GoArrowUp } from "react-icons/go";
|
|
8323
|
-
import { Link
|
|
8324
|
-
import { Fragment as
|
|
8259
|
+
import { Link, useSearchParams } from "react-router";
|
|
8260
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
8325
8261
|
function Table({
|
|
8326
8262
|
className = "min-w-full whitespace-nowrap",
|
|
8327
8263
|
data,
|
|
@@ -8335,13 +8271,13 @@ function Table({
|
|
|
8335
8271
|
}) {
|
|
8336
8272
|
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
8337
8273
|
const sortedArray = [...data];
|
|
8338
|
-
const [_, setSearchParams] =
|
|
8339
|
-
return /* @__PURE__ */
|
|
8274
|
+
const [_, setSearchParams] = useSearchParams();
|
|
8275
|
+
return /* @__PURE__ */ jsxs3(
|
|
8340
8276
|
"table",
|
|
8341
8277
|
{
|
|
8342
|
-
className:
|
|
8278
|
+
className: cn2(className, "text-[15px] border-separate border-spacing-0"),
|
|
8343
8279
|
children: [
|
|
8344
|
-
/* @__PURE__ */
|
|
8280
|
+
/* @__PURE__ */ jsx7("thead", { children: /* @__PURE__ */ jsx7("tr", { children: keys.map((key) => {
|
|
8345
8281
|
const value = columns[key];
|
|
8346
8282
|
function getReactNode() {
|
|
8347
8283
|
if (value && typeof value === "object" && "label" in value) {
|
|
@@ -8352,10 +8288,10 @@ function Table({
|
|
|
8352
8288
|
function Head() {
|
|
8353
8289
|
const reactNode = getReactNode();
|
|
8354
8290
|
if (typeof reactNode === "string") {
|
|
8355
|
-
return /* @__PURE__ */
|
|
8291
|
+
return /* @__PURE__ */ jsxs3(
|
|
8356
8292
|
"button",
|
|
8357
8293
|
{
|
|
8358
|
-
className:
|
|
8294
|
+
className: cn2(
|
|
8359
8295
|
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
8360
8296
|
"px-4 h-14 flex items-center w-full"
|
|
8361
8297
|
),
|
|
@@ -8371,17 +8307,17 @@ function Table({
|
|
|
8371
8307
|
},
|
|
8372
8308
|
children: [
|
|
8373
8309
|
reactNode,
|
|
8374
|
-
orderBy === key && /* @__PURE__ */
|
|
8310
|
+
orderBy === key && /* @__PURE__ */ jsx7("div", { className: "ml-0.5", children: direction === "asc" ? /* @__PURE__ */ jsx7(GoArrowUp, {}) : /* @__PURE__ */ jsx7(GoArrowDown, {}) })
|
|
8375
8311
|
]
|
|
8376
8312
|
}
|
|
8377
8313
|
);
|
|
8378
8314
|
}
|
|
8379
|
-
return /* @__PURE__ */
|
|
8315
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: reactNode });
|
|
8380
8316
|
}
|
|
8381
|
-
return /* @__PURE__ */
|
|
8317
|
+
return /* @__PURE__ */ jsx7("th", { className: cn2("border-y font-normal"), children: /* @__PURE__ */ jsx7(Head, {}) }, key);
|
|
8382
8318
|
}) }) }),
|
|
8383
|
-
/* @__PURE__ */
|
|
8384
|
-
sortedArray.length === 0 && /* @__PURE__ */
|
|
8319
|
+
/* @__PURE__ */ jsxs3("tbody", { children: [
|
|
8320
|
+
sortedArray.length === 0 && /* @__PURE__ */ jsx7("tr", { children: /* @__PURE__ */ jsx7(
|
|
8385
8321
|
"td",
|
|
8386
8322
|
{
|
|
8387
8323
|
colSpan: keys.length,
|
|
@@ -8389,7 +8325,7 @@ function Table({
|
|
|
8389
8325
|
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
8390
8326
|
}
|
|
8391
8327
|
) }),
|
|
8392
|
-
sortedArray.map((item, i) => /* @__PURE__ */
|
|
8328
|
+
sortedArray.map((item, i) => /* @__PURE__ */ jsx7("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
|
|
8393
8329
|
const value = item[key];
|
|
8394
8330
|
function Content() {
|
|
8395
8331
|
if (key in columns) {
|
|
@@ -8397,22 +8333,22 @@ function Table({
|
|
|
8397
8333
|
if (column && typeof column === "object" && "mapper" in column) {
|
|
8398
8334
|
const mapper = column.mapper;
|
|
8399
8335
|
if (mapper) {
|
|
8400
|
-
return /* @__PURE__ */
|
|
8336
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: mapper(item) });
|
|
8401
8337
|
}
|
|
8402
8338
|
}
|
|
8403
8339
|
}
|
|
8404
|
-
return /* @__PURE__ */
|
|
8340
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: String(value) });
|
|
8405
8341
|
}
|
|
8406
|
-
const linkedContent = getLink ? /* @__PURE__ */
|
|
8407
|
-
|
|
8342
|
+
const linkedContent = getLink ? /* @__PURE__ */ jsx7(
|
|
8343
|
+
Link,
|
|
8408
8344
|
{
|
|
8409
8345
|
to: getLink(item),
|
|
8410
8346
|
className: "block content-center px-4 w-full h-full",
|
|
8411
|
-
children: /* @__PURE__ */
|
|
8347
|
+
children: /* @__PURE__ */ jsx7(Content, {})
|
|
8412
8348
|
}
|
|
8413
|
-
) : /* @__PURE__ */
|
|
8414
|
-
const cell = Mapper ? /* @__PURE__ */
|
|
8415
|
-
return /* @__PURE__ */
|
|
8349
|
+
) : /* @__PURE__ */ jsx7(Content, {});
|
|
8350
|
+
const cell = Mapper ? /* @__PURE__ */ jsx7(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
8351
|
+
return /* @__PURE__ */ jsx7("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
8416
8352
|
}) }, i))
|
|
8417
8353
|
] })
|
|
8418
8354
|
]
|
|
@@ -8420,8 +8356,169 @@ function Table({
|
|
|
8420
8356
|
);
|
|
8421
8357
|
}
|
|
8422
8358
|
|
|
8423
|
-
// src/table/
|
|
8359
|
+
// src/table/use_table.tsx
|
|
8360
|
+
import { useLoaderData } from "react-router";
|
|
8361
|
+
function useTable() {
|
|
8362
|
+
const { table } = useLoaderData();
|
|
8363
|
+
const { items, total, limit, offset, orderBy, direction, searchKey } = table;
|
|
8364
|
+
return {
|
|
8365
|
+
items,
|
|
8366
|
+
total,
|
|
8367
|
+
limit,
|
|
8368
|
+
offset,
|
|
8369
|
+
orderBy,
|
|
8370
|
+
direction,
|
|
8371
|
+
searchKey
|
|
8372
|
+
};
|
|
8373
|
+
}
|
|
8374
|
+
|
|
8375
|
+
// src/table/buttons.tsx
|
|
8376
|
+
import { cn as cn3 } from "dn-react-toolkit/utils";
|
|
8377
|
+
import { Link as Link2, useLocation, useSearchParams as useSearchParams2 } from "react-router";
|
|
8378
|
+
import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
8379
|
+
function TablePageButtons({
|
|
8380
|
+
MAX_PAGES_TO_SHOW,
|
|
8381
|
+
total,
|
|
8382
|
+
limit,
|
|
8383
|
+
offset
|
|
8384
|
+
}) {
|
|
8385
|
+
const pages = Math.ceil(total / limit);
|
|
8386
|
+
const { pathname } = useLocation();
|
|
8387
|
+
const [searchParams] = useSearchParams2();
|
|
8388
|
+
const currentPage = Math.floor(offset / limit) + 1;
|
|
8389
|
+
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
8390
|
+
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
8391
|
+
return /* @__PURE__ */ jsx8(Fragment4, { children: pages > 1 && /* @__PURE__ */ jsxs4("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
8392
|
+
startButton > 1 && /* @__PURE__ */ jsx8(
|
|
8393
|
+
Link2,
|
|
8394
|
+
{
|
|
8395
|
+
to: (() => {
|
|
8396
|
+
searchParams.set(
|
|
8397
|
+
"offset",
|
|
8398
|
+
String((startButton - 1) * limit)
|
|
8399
|
+
);
|
|
8400
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
8401
|
+
})(),
|
|
8402
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
8403
|
+
children: "\uC774\uC804"
|
|
8404
|
+
}
|
|
8405
|
+
),
|
|
8406
|
+
Array.from({
|
|
8407
|
+
length: Math.min(
|
|
8408
|
+
MAX_PAGES_TO_SHOW,
|
|
8409
|
+
pages - startButton
|
|
8410
|
+
)
|
|
8411
|
+
}).map((_, index2) => {
|
|
8412
|
+
return /* @__PURE__ */ jsx8(
|
|
8413
|
+
Link2,
|
|
8414
|
+
{
|
|
8415
|
+
to: (() => {
|
|
8416
|
+
searchParams.set(
|
|
8417
|
+
"offset",
|
|
8418
|
+
String((startButton + index2) * limit)
|
|
8419
|
+
);
|
|
8420
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
8421
|
+
})(),
|
|
8422
|
+
className: cn3(
|
|
8423
|
+
"w-6 block text-center transition-colors",
|
|
8424
|
+
currentPage === startButton + index2 + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
8425
|
+
),
|
|
8426
|
+
children: startButton + index2 + 1
|
|
8427
|
+
},
|
|
8428
|
+
index2
|
|
8429
|
+
);
|
|
8430
|
+
}),
|
|
8431
|
+
endButton < pages && /* @__PURE__ */ jsx8(
|
|
8432
|
+
Link2,
|
|
8433
|
+
{
|
|
8434
|
+
to: (() => {
|
|
8435
|
+
searchParams.set(
|
|
8436
|
+
"offset",
|
|
8437
|
+
String((endButton + 1) * limit)
|
|
8438
|
+
);
|
|
8439
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
8440
|
+
})(),
|
|
8441
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
8442
|
+
children: "\uB2E4\uC74C"
|
|
8443
|
+
}
|
|
8444
|
+
)
|
|
8445
|
+
] }) });
|
|
8446
|
+
}
|
|
8447
|
+
|
|
8448
|
+
// src/table/table_form.tsx
|
|
8424
8449
|
import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
8450
|
+
function TableForm({
|
|
8451
|
+
columns,
|
|
8452
|
+
primaryKey = "id"
|
|
8453
|
+
}) {
|
|
8454
|
+
const { pathname } = useLocation2();
|
|
8455
|
+
const { items, total, limit, offset, orderBy, direction, searchKey } = useTable();
|
|
8456
|
+
const navigate = useNavigate2();
|
|
8457
|
+
const search = (query) => {
|
|
8458
|
+
const searchParams2 = new URLSearchParams(window.location.search);
|
|
8459
|
+
searchParams2.set("query", query);
|
|
8460
|
+
searchParams2.set("offset", "0");
|
|
8461
|
+
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
8462
|
+
};
|
|
8463
|
+
const [searchParams] = useSearchParams3();
|
|
8464
|
+
return /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
8465
|
+
searchKey && /* @__PURE__ */ jsxs5(
|
|
8466
|
+
"form",
|
|
8467
|
+
{
|
|
8468
|
+
className: "h-18 px-4 flex items-center border-t",
|
|
8469
|
+
onSubmit: (e) => {
|
|
8470
|
+
e.preventDefault();
|
|
8471
|
+
const formData = new FormData(e.currentTarget);
|
|
8472
|
+
const query = formData.get("query");
|
|
8473
|
+
search(query);
|
|
8474
|
+
},
|
|
8475
|
+
children: [
|
|
8476
|
+
/* @__PURE__ */ jsx9(
|
|
8477
|
+
"button",
|
|
8478
|
+
{
|
|
8479
|
+
type: "submit",
|
|
8480
|
+
className: "w-10 h-10 flex justify-center items-center",
|
|
8481
|
+
children: /* @__PURE__ */ jsx9(GoSearch, { className: "text-xl mr-4" })
|
|
8482
|
+
}
|
|
8483
|
+
),
|
|
8484
|
+
/* @__PURE__ */ jsx9(
|
|
8485
|
+
"input",
|
|
8486
|
+
{
|
|
8487
|
+
className: "outline-none h-full flex-1",
|
|
8488
|
+
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
8489
|
+
name: "query",
|
|
8490
|
+
defaultValue: searchParams.get("query") ?? ""
|
|
8491
|
+
}
|
|
8492
|
+
)
|
|
8493
|
+
]
|
|
8494
|
+
}
|
|
8495
|
+
),
|
|
8496
|
+
/* @__PURE__ */ jsx9(
|
|
8497
|
+
Table,
|
|
8498
|
+
{
|
|
8499
|
+
data: items,
|
|
8500
|
+
columns,
|
|
8501
|
+
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
8502
|
+
limit,
|
|
8503
|
+
offset,
|
|
8504
|
+
orderBy,
|
|
8505
|
+
direction
|
|
8506
|
+
}
|
|
8507
|
+
),
|
|
8508
|
+
/* @__PURE__ */ jsx9(
|
|
8509
|
+
TablePageButtons,
|
|
8510
|
+
{
|
|
8511
|
+
total,
|
|
8512
|
+
limit,
|
|
8513
|
+
offset,
|
|
8514
|
+
MAX_PAGES_TO_SHOW: 10
|
|
8515
|
+
}
|
|
8516
|
+
)
|
|
8517
|
+
] });
|
|
8518
|
+
}
|
|
8519
|
+
|
|
8520
|
+
// src/table/page.tsx
|
|
8521
|
+
import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
8425
8522
|
function createTablePage({
|
|
8426
8523
|
name,
|
|
8427
8524
|
columns,
|
|
@@ -8430,88 +8527,25 @@ function createTablePage({
|
|
|
8430
8527
|
return function TablePage({
|
|
8431
8528
|
header: Header
|
|
8432
8529
|
}) {
|
|
8433
|
-
const { pathname } =
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
const navigate = useNavigate2();
|
|
8437
|
-
const search = (query) => {
|
|
8438
|
-
const searchParams2 = new URLSearchParams(window.location.search);
|
|
8439
|
-
searchParams2.set("query", query);
|
|
8440
|
-
searchParams2.set("offset", "0");
|
|
8441
|
-
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
8442
|
-
};
|
|
8443
|
-
const [searchParams] = useSearchParams3();
|
|
8444
|
-
return /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
8445
|
-
/* @__PURE__ */ jsx9(
|
|
8530
|
+
const { pathname } = useLocation3();
|
|
8531
|
+
return /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
8532
|
+
/* @__PURE__ */ jsx10(
|
|
8446
8533
|
Header,
|
|
8447
8534
|
{
|
|
8448
8535
|
title: name,
|
|
8449
|
-
actions: /* @__PURE__ */
|
|
8536
|
+
actions: /* @__PURE__ */ jsxs6(Link3, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
8450
8537
|
name,
|
|
8451
8538
|
" \uCD94\uAC00"
|
|
8452
8539
|
] })
|
|
8453
8540
|
}
|
|
8454
8541
|
),
|
|
8455
|
-
/* @__PURE__ */
|
|
8456
|
-
searchKey && /* @__PURE__ */ jsxs5(
|
|
8457
|
-
"form",
|
|
8458
|
-
{
|
|
8459
|
-
className: "h-18 px-4 flex items-center border-t",
|
|
8460
|
-
onSubmit: (e) => {
|
|
8461
|
-
e.preventDefault();
|
|
8462
|
-
const formData = new FormData(e.currentTarget);
|
|
8463
|
-
const query = formData.get("query");
|
|
8464
|
-
search(query);
|
|
8465
|
-
},
|
|
8466
|
-
children: [
|
|
8467
|
-
/* @__PURE__ */ jsx9(
|
|
8468
|
-
"button",
|
|
8469
|
-
{
|
|
8470
|
-
type: "submit",
|
|
8471
|
-
className: "w-10 h-10 flex justify-center items-center",
|
|
8472
|
-
children: /* @__PURE__ */ jsx9(GoSearch, { className: "text-xl mr-4" })
|
|
8473
|
-
}
|
|
8474
|
-
),
|
|
8475
|
-
/* @__PURE__ */ jsx9(
|
|
8476
|
-
"input",
|
|
8477
|
-
{
|
|
8478
|
-
className: "outline-none h-full flex-1",
|
|
8479
|
-
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
8480
|
-
name: "query",
|
|
8481
|
-
defaultValue: searchParams.get("query") ?? ""
|
|
8482
|
-
}
|
|
8483
|
-
)
|
|
8484
|
-
]
|
|
8485
|
-
}
|
|
8486
|
-
),
|
|
8487
|
-
/* @__PURE__ */ jsx9(
|
|
8488
|
-
Table,
|
|
8489
|
-
{
|
|
8490
|
-
data: items,
|
|
8491
|
-
columns,
|
|
8492
|
-
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
8493
|
-
limit,
|
|
8494
|
-
offset,
|
|
8495
|
-
orderBy,
|
|
8496
|
-
direction
|
|
8497
|
-
}
|
|
8498
|
-
),
|
|
8499
|
-
/* @__PURE__ */ jsx9(
|
|
8500
|
-
TablePageButtons,
|
|
8501
|
-
{
|
|
8502
|
-
total,
|
|
8503
|
-
limit,
|
|
8504
|
-
offset,
|
|
8505
|
-
MAX_PAGES_TO_SHOW: 10
|
|
8506
|
-
}
|
|
8507
|
-
)
|
|
8508
|
-
] })
|
|
8542
|
+
/* @__PURE__ */ jsx10("div", { className: "max-w-7xl mx-auto w-full overflow-auto", children: /* @__PURE__ */ jsx10(TableForm, { columns, primaryKey }) })
|
|
8509
8543
|
] });
|
|
8510
8544
|
};
|
|
8511
8545
|
}
|
|
8512
8546
|
|
|
8513
8547
|
// src/crud/crud_page.tsx
|
|
8514
|
-
import { jsx as
|
|
8548
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
8515
8549
|
function crudPage({
|
|
8516
8550
|
name,
|
|
8517
8551
|
primaryKey,
|
|
@@ -8522,16 +8556,16 @@ function crudPage({
|
|
|
8522
8556
|
const create = (prefix2) => {
|
|
8523
8557
|
return function Page() {
|
|
8524
8558
|
const data = useLoaderData2();
|
|
8525
|
-
const { pathname } =
|
|
8559
|
+
const { pathname } = useLocation4();
|
|
8526
8560
|
if (pathname === prefix2) {
|
|
8527
8561
|
const Component = createTablePage({
|
|
8528
8562
|
...tablePageOptions,
|
|
8529
8563
|
name
|
|
8530
8564
|
});
|
|
8531
|
-
return /* @__PURE__ */
|
|
8565
|
+
return /* @__PURE__ */ jsx11(Component, { header });
|
|
8532
8566
|
}
|
|
8533
8567
|
if (pathname.startsWith(prefix2)) {
|
|
8534
|
-
return /* @__PURE__ */
|
|
8568
|
+
return /* @__PURE__ */ jsx11(
|
|
8535
8569
|
CrudFormProvider,
|
|
8536
8570
|
{
|
|
8537
8571
|
item: data?.item,
|
|
@@ -8539,7 +8573,7 @@ function crudPage({
|
|
|
8539
8573
|
name,
|
|
8540
8574
|
columns: formOptions.columns,
|
|
8541
8575
|
primaryKey,
|
|
8542
|
-
children: formOptions.form ? /* @__PURE__ */
|
|
8576
|
+
children: formOptions.form ? /* @__PURE__ */ jsx11(FormDelegate, { component: formOptions.form }) : /* @__PURE__ */ jsx11(CrudForm, { AdminHeader: header })
|
|
8543
8577
|
}
|
|
8544
8578
|
);
|
|
8545
8579
|
}
|
|
@@ -8554,7 +8588,7 @@ function FormDelegate({
|
|
|
8554
8588
|
component: Component
|
|
8555
8589
|
}) {
|
|
8556
8590
|
const form = useFormContext();
|
|
8557
|
-
return /* @__PURE__ */
|
|
8591
|
+
return /* @__PURE__ */ jsx11(Component, { form });
|
|
8558
8592
|
}
|
|
8559
8593
|
|
|
8560
8594
|
// src/crud/generate_handlers.ts
|
|
@@ -8570,15 +8604,15 @@ var generateHandlers = (handlers) => {
|
|
|
8570
8604
|
};
|
|
8571
8605
|
|
|
8572
8606
|
// src/crud/generate_pages.tsx
|
|
8573
|
-
import { useLocation as
|
|
8574
|
-
import { jsx as
|
|
8607
|
+
import { useLocation as useLocation5 } from "react-router";
|
|
8608
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
8575
8609
|
var generatePages = (pages) => {
|
|
8576
8610
|
function Page() {
|
|
8577
|
-
const { pathname } =
|
|
8611
|
+
const { pathname } = useLocation5();
|
|
8578
8612
|
for (const route2 of Object.keys(pages)) {
|
|
8579
8613
|
if (pathname.startsWith(route2)) {
|
|
8580
8614
|
const Page2 = pages[route2].create(route2);
|
|
8581
|
-
return /* @__PURE__ */
|
|
8615
|
+
return /* @__PURE__ */ jsx12(Page2, {});
|
|
8582
8616
|
}
|
|
8583
8617
|
}
|
|
8584
8618
|
}
|