dn-react-router-toolkit 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/crud_loader.js +34 -5
- package/dist/crud/crud_loader.mjs +36 -6
- package/dist/crud/crud_page.js +69 -19
- package/dist/crud/crud_page.mjs +69 -19
- package/dist/crud/index.js +109 -30
- package/dist/crud/index.mjs +111 -31
- package/dist/post/index.js +6 -6
- package/dist/post/index.mjs +8 -7
- package/dist/post/post_form_page.js +6 -6
- package/dist/post/post_form_page.mjs +8 -7
- package/dist/table/index.d.mts +1 -1
- package/dist/table/index.d.ts +1 -1
- package/dist/table/index.js +94 -20
- package/dist/table/index.mjs +95 -20
- package/dist/table/load_table.d.mts +7 -1
- package/dist/table/load_table.d.ts +7 -1
- package/dist/table/load_table.js +21 -1
- package/dist/table/load_table.mjs +22 -1
- package/dist/table/loader.d.mts +3 -0
- package/dist/table/loader.d.ts +3 -0
- package/dist/table/loader.js +21 -1
- package/dist/table/loader.mjs +22 -1
- package/dist/table/page.js +69 -19
- package/dist/table/page.mjs +69 -19
- 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 +4 -1
- package/dist/table/table.d.ts +4 -1
- package/dist/table/table.js +55 -6
- package/dist/table/table.mjs +55 -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 +69 -19
- package/dist/table/table_form.mjs +69 -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 +2 -2
package/dist/crud/index.js
CHANGED
|
@@ -6516,10 +6516,10 @@ var require_listCacheClear = __commonJS({
|
|
|
6516
6516
|
var require_eq = __commonJS({
|
|
6517
6517
|
"node_modules/lodash/eq.js"(exports2, module2) {
|
|
6518
6518
|
"use strict";
|
|
6519
|
-
function
|
|
6519
|
+
function eq2(value, other) {
|
|
6520
6520
|
return value === other || value !== value && other !== other;
|
|
6521
6521
|
}
|
|
6522
|
-
module2.exports =
|
|
6522
|
+
module2.exports = eq2;
|
|
6523
6523
|
}
|
|
6524
6524
|
});
|
|
6525
6525
|
|
|
@@ -6527,11 +6527,11 @@ var require_eq = __commonJS({
|
|
|
6527
6527
|
var require_assocIndexOf = __commonJS({
|
|
6528
6528
|
"node_modules/lodash/_assocIndexOf.js"(exports2, module2) {
|
|
6529
6529
|
"use strict";
|
|
6530
|
-
var
|
|
6530
|
+
var eq2 = require_eq();
|
|
6531
6531
|
function assocIndexOf(array, key) {
|
|
6532
6532
|
var length = array.length;
|
|
6533
6533
|
while (length--) {
|
|
6534
|
-
if (
|
|
6534
|
+
if (eq2(array[length][0], key)) {
|
|
6535
6535
|
return length;
|
|
6536
6536
|
}
|
|
6537
6537
|
}
|
|
@@ -6989,12 +6989,12 @@ var require_assignValue = __commonJS({
|
|
|
6989
6989
|
"node_modules/lodash/_assignValue.js"(exports2, module2) {
|
|
6990
6990
|
"use strict";
|
|
6991
6991
|
var baseAssignValue = require_baseAssignValue();
|
|
6992
|
-
var
|
|
6992
|
+
var eq2 = require_eq();
|
|
6993
6993
|
var objectProto = Object.prototype;
|
|
6994
6994
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
6995
6995
|
function assignValue(object, key, value) {
|
|
6996
6996
|
var objValue = object[key];
|
|
6997
|
-
if (!(hasOwnProperty.call(object, key) &&
|
|
6997
|
+
if (!(hasOwnProperty.call(object, key) && eq2(objValue, value)) || value === void 0 && !(key in object)) {
|
|
6998
6998
|
baseAssignValue(object, key, value);
|
|
6999
6999
|
}
|
|
7000
7000
|
}
|
|
@@ -8005,11 +8005,22 @@ async function loadTable({
|
|
|
8005
8005
|
const offset = Number(searchParams.get("offset") ?? "0");
|
|
8006
8006
|
const orderBy = searchParams.get("orderBy") ?? defaultOrderBy;
|
|
8007
8007
|
const direction = searchParams.get("direction") ?? defaultDirection;
|
|
8008
|
+
const filterWhere = Object.entries(options.filters ?? {}).map(([key, value]) => {
|
|
8009
|
+
const param = searchParams.get(key);
|
|
8010
|
+
if (param) {
|
|
8011
|
+
return (0, import_drizzle_orm.eq)(
|
|
8012
|
+
repository.schema[key],
|
|
8013
|
+
decodeURIComponent(param)
|
|
8014
|
+
);
|
|
8015
|
+
}
|
|
8016
|
+
return void 0;
|
|
8017
|
+
}).filter(Boolean);
|
|
8008
8018
|
const whereClauses = (0, import_drizzle_orm.and)(
|
|
8009
8019
|
searchKey && query ? (0, import_drizzle_orm.ilike)(
|
|
8010
8020
|
repository.schema[searchKey],
|
|
8011
8021
|
`%${query}%`
|
|
8012
8022
|
) : void 0,
|
|
8023
|
+
...filterWhere,
|
|
8013
8024
|
...where ?? []
|
|
8014
8025
|
);
|
|
8015
8026
|
const total = await repository.countTotal({ where: whereClauses });
|
|
@@ -8020,6 +8031,14 @@ async function loadTable({
|
|
|
8020
8031
|
offset,
|
|
8021
8032
|
where: whereClauses
|
|
8022
8033
|
});
|
|
8034
|
+
const filters = Object.fromEntries(
|
|
8035
|
+
await Promise.all(
|
|
8036
|
+
Object.keys(options.filters ?? {}).map(async (key) => {
|
|
8037
|
+
const values = await repository.select(key);
|
|
8038
|
+
return [key, values.filter(Boolean)];
|
|
8039
|
+
})
|
|
8040
|
+
)
|
|
8041
|
+
);
|
|
8023
8042
|
return {
|
|
8024
8043
|
items,
|
|
8025
8044
|
total,
|
|
@@ -8027,7 +8046,8 @@ async function loadTable({
|
|
|
8027
8046
|
offset,
|
|
8028
8047
|
orderBy,
|
|
8029
8048
|
direction,
|
|
8030
|
-
searchKey
|
|
8049
|
+
searchKey,
|
|
8050
|
+
filters
|
|
8031
8051
|
};
|
|
8032
8052
|
}
|
|
8033
8053
|
|
|
@@ -8157,18 +8177,27 @@ function apiHandler({
|
|
|
8157
8177
|
var import_http2 = require("dn-react-toolkit/http");
|
|
8158
8178
|
function itemApiHandler({
|
|
8159
8179
|
withAuthAction,
|
|
8160
|
-
repository
|
|
8180
|
+
repository,
|
|
8181
|
+
isOwnedBy,
|
|
8182
|
+
roles
|
|
8161
8183
|
}) {
|
|
8162
8184
|
const loader = async ({ request }) => {
|
|
8163
8185
|
return {};
|
|
8164
8186
|
};
|
|
8165
8187
|
const action = withAuthAction((auth) => async ({ params, request }) => {
|
|
8166
|
-
if (!auth || auth.role
|
|
8167
|
-
|
|
8188
|
+
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
8189
|
+
throw (0, import_http2.UNAUTHORIZED)();
|
|
8190
|
+
}
|
|
8191
|
+
const itemId = params.itemId;
|
|
8192
|
+
const existing = await repository.find(itemId);
|
|
8193
|
+
if (!existing) {
|
|
8194
|
+
throw (0, import_http2.NOT_FOUND)();
|
|
8195
|
+
}
|
|
8196
|
+
if (isOwnedBy && !isOwnedBy(existing, auth)) {
|
|
8197
|
+
throw (0, import_http2.FORBIDDEN)();
|
|
8168
8198
|
}
|
|
8169
8199
|
switch (request.method) {
|
|
8170
8200
|
case "DELETE": {
|
|
8171
|
-
const itemId = params.itemId;
|
|
8172
8201
|
await repository.delete(itemId);
|
|
8173
8202
|
return {};
|
|
8174
8203
|
}
|
|
@@ -8269,7 +8298,8 @@ function Table({
|
|
|
8269
8298
|
limit,
|
|
8270
8299
|
offset,
|
|
8271
8300
|
orderBy,
|
|
8272
|
-
direction
|
|
8301
|
+
direction,
|
|
8302
|
+
filters
|
|
8273
8303
|
}) {
|
|
8274
8304
|
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
8275
8305
|
const sortedArray = [...data];
|
|
@@ -8277,7 +8307,10 @@ function Table({
|
|
|
8277
8307
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
8278
8308
|
"table",
|
|
8279
8309
|
{
|
|
8280
|
-
className: (0, import_utils3.cn)(
|
|
8310
|
+
className: (0, import_utils3.cn)(
|
|
8311
|
+
className,
|
|
8312
|
+
"text-[15px] border-separate border-spacing-0"
|
|
8313
|
+
),
|
|
8281
8314
|
children: [
|
|
8282
8315
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: keys.map((key) => {
|
|
8283
8316
|
const value = columns[key];
|
|
@@ -8294,8 +8327,8 @@ function Table({
|
|
|
8294
8327
|
"button",
|
|
8295
8328
|
{
|
|
8296
8329
|
className: (0, import_utils3.cn)(
|
|
8297
|
-
orderBy === key ? "text-
|
|
8298
|
-
"px-4
|
|
8330
|
+
orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
|
|
8331
|
+
"px-4 flex items-center w-full"
|
|
8299
8332
|
),
|
|
8300
8333
|
onClick: () => {
|
|
8301
8334
|
let newDirection = "asc";
|
|
@@ -8316,14 +8349,59 @@ function Table({
|
|
|
8316
8349
|
}
|
|
8317
8350
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: reactNode });
|
|
8318
8351
|
}
|
|
8319
|
-
|
|
8352
|
+
const filter = filters[key];
|
|
8353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
8354
|
+
"th",
|
|
8355
|
+
{
|
|
8356
|
+
className: (0, import_utils3.cn)(
|
|
8357
|
+
"py-4 border-y font-normal align-top"
|
|
8358
|
+
),
|
|
8359
|
+
children: [
|
|
8360
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Head, {}),
|
|
8361
|
+
filter && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "px-3 mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
8362
|
+
"select",
|
|
8363
|
+
{
|
|
8364
|
+
className: "w-full h-10 px-1.5 border rounded-full outline-none",
|
|
8365
|
+
onChange: (e) => {
|
|
8366
|
+
const value2 = e.target.value;
|
|
8367
|
+
setSearchParams((prev) => {
|
|
8368
|
+
if (value2) {
|
|
8369
|
+
prev.set(
|
|
8370
|
+
key,
|
|
8371
|
+
encodeURIComponent(
|
|
8372
|
+
value2
|
|
8373
|
+
)
|
|
8374
|
+
);
|
|
8375
|
+
} else {
|
|
8376
|
+
prev.delete(key);
|
|
8377
|
+
}
|
|
8378
|
+
return prev;
|
|
8379
|
+
});
|
|
8380
|
+
},
|
|
8381
|
+
children: [
|
|
8382
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "", children: "\uC804\uCCB4" }),
|
|
8383
|
+
filter.map((option) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
8384
|
+
"option",
|
|
8385
|
+
{
|
|
8386
|
+
value: option,
|
|
8387
|
+
children: option
|
|
8388
|
+
},
|
|
8389
|
+
option
|
|
8390
|
+
))
|
|
8391
|
+
]
|
|
8392
|
+
}
|
|
8393
|
+
) })
|
|
8394
|
+
]
|
|
8395
|
+
},
|
|
8396
|
+
key
|
|
8397
|
+
);
|
|
8320
8398
|
}) }) }),
|
|
8321
8399
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("tbody", { children: [
|
|
8322
8400
|
sortedArray.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
8323
8401
|
"td",
|
|
8324
8402
|
{
|
|
8325
8403
|
colSpan: keys.length,
|
|
8326
|
-
className: "px-4 h-
|
|
8404
|
+
className: "px-4 h-20 text-gray-400 text-center",
|
|
8327
8405
|
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
8328
8406
|
}
|
|
8329
8407
|
) }),
|
|
@@ -8362,16 +8440,7 @@ function Table({
|
|
|
8362
8440
|
var import_react_router5 = require("react-router");
|
|
8363
8441
|
function useTable() {
|
|
8364
8442
|
const { table } = (0, import_react_router5.useLoaderData)();
|
|
8365
|
-
|
|
8366
|
-
return {
|
|
8367
|
-
items,
|
|
8368
|
-
total,
|
|
8369
|
-
limit,
|
|
8370
|
-
offset,
|
|
8371
|
-
orderBy,
|
|
8372
|
-
direction,
|
|
8373
|
-
searchKey
|
|
8374
|
-
};
|
|
8443
|
+
return table;
|
|
8375
8444
|
}
|
|
8376
8445
|
|
|
8377
8446
|
// src/table/buttons.tsx
|
|
@@ -8454,7 +8523,16 @@ function TableForm({
|
|
|
8454
8523
|
primaryKey = "id"
|
|
8455
8524
|
}) {
|
|
8456
8525
|
const { pathname } = (0, import_react_router7.useLocation)();
|
|
8457
|
-
const {
|
|
8526
|
+
const {
|
|
8527
|
+
items,
|
|
8528
|
+
total,
|
|
8529
|
+
limit,
|
|
8530
|
+
offset,
|
|
8531
|
+
orderBy,
|
|
8532
|
+
direction,
|
|
8533
|
+
searchKey,
|
|
8534
|
+
filters
|
|
8535
|
+
} = useTable();
|
|
8458
8536
|
const navigate = (0, import_react_router7.useNavigate)();
|
|
8459
8537
|
const search = (query) => {
|
|
8460
8538
|
const searchParams2 = new URLSearchParams(window.location.search);
|
|
@@ -8467,7 +8545,7 @@ function TableForm({
|
|
|
8467
8545
|
searchKey && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
8468
8546
|
"form",
|
|
8469
8547
|
{
|
|
8470
|
-
className: "h-
|
|
8548
|
+
className: "h-20 px-4 flex items-center border-t",
|
|
8471
8549
|
onSubmit: (e) => {
|
|
8472
8550
|
e.preventDefault();
|
|
8473
8551
|
const formData = new FormData(e.currentTarget);
|
|
@@ -8504,7 +8582,8 @@ function TableForm({
|
|
|
8504
8582
|
limit,
|
|
8505
8583
|
offset,
|
|
8506
8584
|
orderBy,
|
|
8507
|
-
direction
|
|
8585
|
+
direction,
|
|
8586
|
+
filters
|
|
8508
8587
|
}
|
|
8509
8588
|
),
|
|
8510
8589
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
package/dist/crud/index.mjs
CHANGED
|
@@ -6510,10 +6510,10 @@ var require_listCacheClear = __commonJS({
|
|
|
6510
6510
|
var require_eq = __commonJS({
|
|
6511
6511
|
"node_modules/lodash/eq.js"(exports, module) {
|
|
6512
6512
|
"use strict";
|
|
6513
|
-
function
|
|
6513
|
+
function eq2(value, other) {
|
|
6514
6514
|
return value === other || value !== value && other !== other;
|
|
6515
6515
|
}
|
|
6516
|
-
module.exports =
|
|
6516
|
+
module.exports = eq2;
|
|
6517
6517
|
}
|
|
6518
6518
|
});
|
|
6519
6519
|
|
|
@@ -6521,11 +6521,11 @@ var require_eq = __commonJS({
|
|
|
6521
6521
|
var require_assocIndexOf = __commonJS({
|
|
6522
6522
|
"node_modules/lodash/_assocIndexOf.js"(exports, module) {
|
|
6523
6523
|
"use strict";
|
|
6524
|
-
var
|
|
6524
|
+
var eq2 = require_eq();
|
|
6525
6525
|
function assocIndexOf(array, key) {
|
|
6526
6526
|
var length = array.length;
|
|
6527
6527
|
while (length--) {
|
|
6528
|
-
if (
|
|
6528
|
+
if (eq2(array[length][0], key)) {
|
|
6529
6529
|
return length;
|
|
6530
6530
|
}
|
|
6531
6531
|
}
|
|
@@ -6983,12 +6983,12 @@ var require_assignValue = __commonJS({
|
|
|
6983
6983
|
"node_modules/lodash/_assignValue.js"(exports, module) {
|
|
6984
6984
|
"use strict";
|
|
6985
6985
|
var baseAssignValue = require_baseAssignValue();
|
|
6986
|
-
var
|
|
6986
|
+
var eq2 = require_eq();
|
|
6987
6987
|
var objectProto = Object.prototype;
|
|
6988
6988
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
6989
6989
|
function assignValue(object, key, value) {
|
|
6990
6990
|
var objValue = object[key];
|
|
6991
|
-
if (!(hasOwnProperty.call(object, key) &&
|
|
6991
|
+
if (!(hasOwnProperty.call(object, key) && eq2(objValue, value)) || value === void 0 && !(key in object)) {
|
|
6992
6992
|
baseAssignValue(object, key, value);
|
|
6993
6993
|
}
|
|
6994
6994
|
}
|
|
@@ -7980,6 +7980,7 @@ function CrudForm({
|
|
|
7980
7980
|
// src/table/load_table.tsx
|
|
7981
7981
|
import {
|
|
7982
7982
|
and,
|
|
7983
|
+
eq,
|
|
7983
7984
|
ilike
|
|
7984
7985
|
} from "drizzle-orm";
|
|
7985
7986
|
async function loadTable({
|
|
@@ -7994,11 +7995,22 @@ async function loadTable({
|
|
|
7994
7995
|
const offset = Number(searchParams.get("offset") ?? "0");
|
|
7995
7996
|
const orderBy = searchParams.get("orderBy") ?? defaultOrderBy;
|
|
7996
7997
|
const direction = searchParams.get("direction") ?? defaultDirection;
|
|
7998
|
+
const filterWhere = Object.entries(options.filters ?? {}).map(([key, value]) => {
|
|
7999
|
+
const param = searchParams.get(key);
|
|
8000
|
+
if (param) {
|
|
8001
|
+
return eq(
|
|
8002
|
+
repository.schema[key],
|
|
8003
|
+
decodeURIComponent(param)
|
|
8004
|
+
);
|
|
8005
|
+
}
|
|
8006
|
+
return void 0;
|
|
8007
|
+
}).filter(Boolean);
|
|
7997
8008
|
const whereClauses = and(
|
|
7998
8009
|
searchKey && query ? ilike(
|
|
7999
8010
|
repository.schema[searchKey],
|
|
8000
8011
|
`%${query}%`
|
|
8001
8012
|
) : void 0,
|
|
8013
|
+
...filterWhere,
|
|
8002
8014
|
...where ?? []
|
|
8003
8015
|
);
|
|
8004
8016
|
const total = await repository.countTotal({ where: whereClauses });
|
|
@@ -8009,6 +8021,14 @@ async function loadTable({
|
|
|
8009
8021
|
offset,
|
|
8010
8022
|
where: whereClauses
|
|
8011
8023
|
});
|
|
8024
|
+
const filters = Object.fromEntries(
|
|
8025
|
+
await Promise.all(
|
|
8026
|
+
Object.keys(options.filters ?? {}).map(async (key) => {
|
|
8027
|
+
const values = await repository.select(key);
|
|
8028
|
+
return [key, values.filter(Boolean)];
|
|
8029
|
+
})
|
|
8030
|
+
)
|
|
8031
|
+
);
|
|
8012
8032
|
return {
|
|
8013
8033
|
items,
|
|
8014
8034
|
total,
|
|
@@ -8016,7 +8036,8 @@ async function loadTable({
|
|
|
8016
8036
|
offset,
|
|
8017
8037
|
orderBy,
|
|
8018
8038
|
direction,
|
|
8019
|
-
searchKey
|
|
8039
|
+
searchKey,
|
|
8040
|
+
filters
|
|
8020
8041
|
};
|
|
8021
8042
|
}
|
|
8022
8043
|
|
|
@@ -8152,21 +8173,30 @@ function apiHandler({
|
|
|
8152
8173
|
}
|
|
8153
8174
|
|
|
8154
8175
|
// src/api/item_api_handler.ts
|
|
8155
|
-
import { UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
8176
|
+
import { FORBIDDEN, NOT_FOUND, UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
8156
8177
|
function itemApiHandler({
|
|
8157
8178
|
withAuthAction,
|
|
8158
|
-
repository
|
|
8179
|
+
repository,
|
|
8180
|
+
isOwnedBy,
|
|
8181
|
+
roles
|
|
8159
8182
|
}) {
|
|
8160
8183
|
const loader = async ({ request }) => {
|
|
8161
8184
|
return {};
|
|
8162
8185
|
};
|
|
8163
8186
|
const action = withAuthAction((auth) => async ({ params, request }) => {
|
|
8164
|
-
if (!auth || auth.role
|
|
8165
|
-
|
|
8187
|
+
if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
|
|
8188
|
+
throw UNAUTHORIZED2();
|
|
8189
|
+
}
|
|
8190
|
+
const itemId = params.itemId;
|
|
8191
|
+
const existing = await repository.find(itemId);
|
|
8192
|
+
if (!existing) {
|
|
8193
|
+
throw NOT_FOUND();
|
|
8194
|
+
}
|
|
8195
|
+
if (isOwnedBy && !isOwnedBy(existing, auth)) {
|
|
8196
|
+
throw FORBIDDEN();
|
|
8166
8197
|
}
|
|
8167
8198
|
switch (request.method) {
|
|
8168
8199
|
case "DELETE": {
|
|
8169
|
-
const itemId = params.itemId;
|
|
8170
8200
|
await repository.delete(itemId);
|
|
8171
8201
|
return {};
|
|
8172
8202
|
}
|
|
@@ -8267,7 +8297,8 @@ function Table({
|
|
|
8267
8297
|
limit,
|
|
8268
8298
|
offset,
|
|
8269
8299
|
orderBy,
|
|
8270
|
-
direction
|
|
8300
|
+
direction,
|
|
8301
|
+
filters
|
|
8271
8302
|
}) {
|
|
8272
8303
|
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
8273
8304
|
const sortedArray = [...data];
|
|
@@ -8275,7 +8306,10 @@ function Table({
|
|
|
8275
8306
|
return /* @__PURE__ */ jsxs3(
|
|
8276
8307
|
"table",
|
|
8277
8308
|
{
|
|
8278
|
-
className: cn2(
|
|
8309
|
+
className: cn2(
|
|
8310
|
+
className,
|
|
8311
|
+
"text-[15px] border-separate border-spacing-0"
|
|
8312
|
+
),
|
|
8279
8313
|
children: [
|
|
8280
8314
|
/* @__PURE__ */ jsx7("thead", { children: /* @__PURE__ */ jsx7("tr", { children: keys.map((key) => {
|
|
8281
8315
|
const value = columns[key];
|
|
@@ -8292,8 +8326,8 @@ function Table({
|
|
|
8292
8326
|
"button",
|
|
8293
8327
|
{
|
|
8294
8328
|
className: cn2(
|
|
8295
|
-
orderBy === key ? "text-
|
|
8296
|
-
"px-4
|
|
8329
|
+
orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
|
|
8330
|
+
"px-4 flex items-center w-full"
|
|
8297
8331
|
),
|
|
8298
8332
|
onClick: () => {
|
|
8299
8333
|
let newDirection = "asc";
|
|
@@ -8314,14 +8348,59 @@ function Table({
|
|
|
8314
8348
|
}
|
|
8315
8349
|
return /* @__PURE__ */ jsx7(Fragment3, { children: reactNode });
|
|
8316
8350
|
}
|
|
8317
|
-
|
|
8351
|
+
const filter = filters[key];
|
|
8352
|
+
return /* @__PURE__ */ jsxs3(
|
|
8353
|
+
"th",
|
|
8354
|
+
{
|
|
8355
|
+
className: cn2(
|
|
8356
|
+
"py-4 border-y font-normal align-top"
|
|
8357
|
+
),
|
|
8358
|
+
children: [
|
|
8359
|
+
/* @__PURE__ */ jsx7(Head, {}),
|
|
8360
|
+
filter && /* @__PURE__ */ jsx7("div", { className: "px-3 mt-4", children: /* @__PURE__ */ jsxs3(
|
|
8361
|
+
"select",
|
|
8362
|
+
{
|
|
8363
|
+
className: "w-full h-10 px-1.5 border rounded-full outline-none",
|
|
8364
|
+
onChange: (e) => {
|
|
8365
|
+
const value2 = e.target.value;
|
|
8366
|
+
setSearchParams((prev) => {
|
|
8367
|
+
if (value2) {
|
|
8368
|
+
prev.set(
|
|
8369
|
+
key,
|
|
8370
|
+
encodeURIComponent(
|
|
8371
|
+
value2
|
|
8372
|
+
)
|
|
8373
|
+
);
|
|
8374
|
+
} else {
|
|
8375
|
+
prev.delete(key);
|
|
8376
|
+
}
|
|
8377
|
+
return prev;
|
|
8378
|
+
});
|
|
8379
|
+
},
|
|
8380
|
+
children: [
|
|
8381
|
+
/* @__PURE__ */ jsx7("option", { value: "", children: "\uC804\uCCB4" }),
|
|
8382
|
+
filter.map((option) => /* @__PURE__ */ jsx7(
|
|
8383
|
+
"option",
|
|
8384
|
+
{
|
|
8385
|
+
value: option,
|
|
8386
|
+
children: option
|
|
8387
|
+
},
|
|
8388
|
+
option
|
|
8389
|
+
))
|
|
8390
|
+
]
|
|
8391
|
+
}
|
|
8392
|
+
) })
|
|
8393
|
+
]
|
|
8394
|
+
},
|
|
8395
|
+
key
|
|
8396
|
+
);
|
|
8318
8397
|
}) }) }),
|
|
8319
8398
|
/* @__PURE__ */ jsxs3("tbody", { children: [
|
|
8320
8399
|
sortedArray.length === 0 && /* @__PURE__ */ jsx7("tr", { children: /* @__PURE__ */ jsx7(
|
|
8321
8400
|
"td",
|
|
8322
8401
|
{
|
|
8323
8402
|
colSpan: keys.length,
|
|
8324
|
-
className: "px-4 h-
|
|
8403
|
+
className: "px-4 h-20 text-gray-400 text-center",
|
|
8325
8404
|
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
8326
8405
|
}
|
|
8327
8406
|
) }),
|
|
@@ -8360,16 +8439,7 @@ function Table({
|
|
|
8360
8439
|
import { useLoaderData } from "react-router";
|
|
8361
8440
|
function useTable() {
|
|
8362
8441
|
const { table } = useLoaderData();
|
|
8363
|
-
|
|
8364
|
-
return {
|
|
8365
|
-
items,
|
|
8366
|
-
total,
|
|
8367
|
-
limit,
|
|
8368
|
-
offset,
|
|
8369
|
-
orderBy,
|
|
8370
|
-
direction,
|
|
8371
|
-
searchKey
|
|
8372
|
-
};
|
|
8442
|
+
return table;
|
|
8373
8443
|
}
|
|
8374
8444
|
|
|
8375
8445
|
// src/table/buttons.tsx
|
|
@@ -8452,7 +8522,16 @@ function TableForm({
|
|
|
8452
8522
|
primaryKey = "id"
|
|
8453
8523
|
}) {
|
|
8454
8524
|
const { pathname } = useLocation2();
|
|
8455
|
-
const {
|
|
8525
|
+
const {
|
|
8526
|
+
items,
|
|
8527
|
+
total,
|
|
8528
|
+
limit,
|
|
8529
|
+
offset,
|
|
8530
|
+
orderBy,
|
|
8531
|
+
direction,
|
|
8532
|
+
searchKey,
|
|
8533
|
+
filters
|
|
8534
|
+
} = useTable();
|
|
8456
8535
|
const navigate = useNavigate2();
|
|
8457
8536
|
const search = (query) => {
|
|
8458
8537
|
const searchParams2 = new URLSearchParams(window.location.search);
|
|
@@ -8465,7 +8544,7 @@ function TableForm({
|
|
|
8465
8544
|
searchKey && /* @__PURE__ */ jsxs5(
|
|
8466
8545
|
"form",
|
|
8467
8546
|
{
|
|
8468
|
-
className: "h-
|
|
8547
|
+
className: "h-20 px-4 flex items-center border-t",
|
|
8469
8548
|
onSubmit: (e) => {
|
|
8470
8549
|
e.preventDefault();
|
|
8471
8550
|
const formData = new FormData(e.currentTarget);
|
|
@@ -8502,7 +8581,8 @@ function TableForm({
|
|
|
8502
8581
|
limit,
|
|
8503
8582
|
offset,
|
|
8504
8583
|
orderBy,
|
|
8505
|
-
direction
|
|
8584
|
+
direction,
|
|
8585
|
+
filters
|
|
8506
8586
|
}
|
|
8507
8587
|
),
|
|
8508
8588
|
/* @__PURE__ */ jsx9(
|
package/dist/post/index.js
CHANGED
|
@@ -6516,10 +6516,10 @@ var require_listCacheClear = __commonJS({
|
|
|
6516
6516
|
var require_eq = __commonJS({
|
|
6517
6517
|
"node_modules/lodash/eq.js"(exports2, module2) {
|
|
6518
6518
|
"use strict";
|
|
6519
|
-
function
|
|
6519
|
+
function eq2(value, other) {
|
|
6520
6520
|
return value === other || value !== value && other !== other;
|
|
6521
6521
|
}
|
|
6522
|
-
module2.exports =
|
|
6522
|
+
module2.exports = eq2;
|
|
6523
6523
|
}
|
|
6524
6524
|
});
|
|
6525
6525
|
|
|
@@ -6527,11 +6527,11 @@ var require_eq = __commonJS({
|
|
|
6527
6527
|
var require_assocIndexOf = __commonJS({
|
|
6528
6528
|
"node_modules/lodash/_assocIndexOf.js"(exports2, module2) {
|
|
6529
6529
|
"use strict";
|
|
6530
|
-
var
|
|
6530
|
+
var eq2 = require_eq();
|
|
6531
6531
|
function assocIndexOf(array, key) {
|
|
6532
6532
|
var length = array.length;
|
|
6533
6533
|
while (length--) {
|
|
6534
|
-
if (
|
|
6534
|
+
if (eq2(array[length][0], key)) {
|
|
6535
6535
|
return length;
|
|
6536
6536
|
}
|
|
6537
6537
|
}
|
|
@@ -6989,12 +6989,12 @@ var require_assignValue = __commonJS({
|
|
|
6989
6989
|
"node_modules/lodash/_assignValue.js"(exports2, module2) {
|
|
6990
6990
|
"use strict";
|
|
6991
6991
|
var baseAssignValue = require_baseAssignValue();
|
|
6992
|
-
var
|
|
6992
|
+
var eq2 = require_eq();
|
|
6993
6993
|
var objectProto = Object.prototype;
|
|
6994
6994
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
6995
6995
|
function assignValue(object, key, value) {
|
|
6996
6996
|
var objValue = object[key];
|
|
6997
|
-
if (!(hasOwnProperty.call(object, key) &&
|
|
6997
|
+
if (!(hasOwnProperty.call(object, key) && eq2(objValue, value)) || value === void 0 && !(key in object)) {
|
|
6998
6998
|
baseAssignValue(object, key, value);
|
|
6999
6999
|
}
|
|
7000
7000
|
}
|
package/dist/post/index.mjs
CHANGED
|
@@ -6510,10 +6510,10 @@ var require_listCacheClear = __commonJS({
|
|
|
6510
6510
|
var require_eq = __commonJS({
|
|
6511
6511
|
"node_modules/lodash/eq.js"(exports, module) {
|
|
6512
6512
|
"use strict";
|
|
6513
|
-
function
|
|
6513
|
+
function eq2(value, other) {
|
|
6514
6514
|
return value === other || value !== value && other !== other;
|
|
6515
6515
|
}
|
|
6516
|
-
module.exports =
|
|
6516
|
+
module.exports = eq2;
|
|
6517
6517
|
}
|
|
6518
6518
|
});
|
|
6519
6519
|
|
|
@@ -6521,11 +6521,11 @@ var require_eq = __commonJS({
|
|
|
6521
6521
|
var require_assocIndexOf = __commonJS({
|
|
6522
6522
|
"node_modules/lodash/_assocIndexOf.js"(exports, module) {
|
|
6523
6523
|
"use strict";
|
|
6524
|
-
var
|
|
6524
|
+
var eq2 = require_eq();
|
|
6525
6525
|
function assocIndexOf(array, key) {
|
|
6526
6526
|
var length = array.length;
|
|
6527
6527
|
while (length--) {
|
|
6528
|
-
if (
|
|
6528
|
+
if (eq2(array[length][0], key)) {
|
|
6529
6529
|
return length;
|
|
6530
6530
|
}
|
|
6531
6531
|
}
|
|
@@ -6983,12 +6983,12 @@ var require_assignValue = __commonJS({
|
|
|
6983
6983
|
"node_modules/lodash/_assignValue.js"(exports, module) {
|
|
6984
6984
|
"use strict";
|
|
6985
6985
|
var baseAssignValue = require_baseAssignValue();
|
|
6986
|
-
var
|
|
6986
|
+
var eq2 = require_eq();
|
|
6987
6987
|
var objectProto = Object.prototype;
|
|
6988
6988
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
6989
6989
|
function assignValue(object, key, value) {
|
|
6990
6990
|
var objValue = object[key];
|
|
6991
|
-
if (!(hasOwnProperty.call(object, key) &&
|
|
6991
|
+
if (!(hasOwnProperty.call(object, key) && eq2(objValue, value)) || value === void 0 && !(key in object)) {
|
|
6992
6992
|
baseAssignValue(object, key, value);
|
|
6993
6993
|
}
|
|
6994
6994
|
}
|
|
@@ -7938,6 +7938,7 @@ import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-run
|
|
|
7938
7938
|
// src/table/load_table.tsx
|
|
7939
7939
|
import {
|
|
7940
7940
|
and,
|
|
7941
|
+
eq,
|
|
7941
7942
|
ilike
|
|
7942
7943
|
} from "drizzle-orm";
|
|
7943
7944
|
|
|
@@ -7956,7 +7957,7 @@ import {
|
|
|
7956
7957
|
import { v4 } from "uuid";
|
|
7957
7958
|
|
|
7958
7959
|
// src/api/item_api_handler.ts
|
|
7959
|
-
import { UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
7960
|
+
import { FORBIDDEN, NOT_FOUND, UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
|
|
7960
7961
|
|
|
7961
7962
|
// src/crud/crud_page.tsx
|
|
7962
7963
|
import { useLoaderData as useLoaderData2, useLocation as useLocation4 } from "react-router";
|
|
@@ -6516,10 +6516,10 @@ var require_listCacheClear = __commonJS({
|
|
|
6516
6516
|
var require_eq = __commonJS({
|
|
6517
6517
|
"node_modules/lodash/eq.js"(exports2, module2) {
|
|
6518
6518
|
"use strict";
|
|
6519
|
-
function
|
|
6519
|
+
function eq2(value, other) {
|
|
6520
6520
|
return value === other || value !== value && other !== other;
|
|
6521
6521
|
}
|
|
6522
|
-
module2.exports =
|
|
6522
|
+
module2.exports = eq2;
|
|
6523
6523
|
}
|
|
6524
6524
|
});
|
|
6525
6525
|
|
|
@@ -6527,11 +6527,11 @@ var require_eq = __commonJS({
|
|
|
6527
6527
|
var require_assocIndexOf = __commonJS({
|
|
6528
6528
|
"node_modules/lodash/_assocIndexOf.js"(exports2, module2) {
|
|
6529
6529
|
"use strict";
|
|
6530
|
-
var
|
|
6530
|
+
var eq2 = require_eq();
|
|
6531
6531
|
function assocIndexOf(array, key) {
|
|
6532
6532
|
var length = array.length;
|
|
6533
6533
|
while (length--) {
|
|
6534
|
-
if (
|
|
6534
|
+
if (eq2(array[length][0], key)) {
|
|
6535
6535
|
return length;
|
|
6536
6536
|
}
|
|
6537
6537
|
}
|
|
@@ -6989,12 +6989,12 @@ var require_assignValue = __commonJS({
|
|
|
6989
6989
|
"node_modules/lodash/_assignValue.js"(exports2, module2) {
|
|
6990
6990
|
"use strict";
|
|
6991
6991
|
var baseAssignValue = require_baseAssignValue();
|
|
6992
|
-
var
|
|
6992
|
+
var eq2 = require_eq();
|
|
6993
6993
|
var objectProto = Object.prototype;
|
|
6994
6994
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
6995
6995
|
function assignValue(object, key, value) {
|
|
6996
6996
|
var objValue = object[key];
|
|
6997
|
-
if (!(hasOwnProperty.call(object, key) &&
|
|
6997
|
+
if (!(hasOwnProperty.call(object, key) && eq2(objValue, value)) || value === void 0 && !(key in object)) {
|
|
6998
6998
|
baseAssignValue(object, key, value);
|
|
6999
6999
|
}
|
|
7000
7000
|
}
|