dn-react-router-toolkit 0.7.15 → 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/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 +225 -197
- package/dist/crud/crud_page.mjs +223 -201
- 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 +245 -205
- package/dist/crud/index.mjs +251 -217
- 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 +1 -1
package/dist/crud/crud_page.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/crud/crud_page.tsx
|
|
2
|
-
import { useLoaderData as useLoaderData2, useLocation as
|
|
2
|
+
import { useLoaderData as useLoaderData2, useLocation as useLocation4 } from "react-router";
|
|
3
3
|
|
|
4
4
|
// src/crud/crud_form_provider.tsx
|
|
5
5
|
import { useNavigate } from "react-router";
|
|
@@ -154,93 +154,17 @@ function CrudFormProvider({
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
// src/table/page.tsx
|
|
157
|
-
import {
|
|
158
|
-
Link as Link3,
|
|
159
|
-
useLoaderData,
|
|
160
|
-
useLocation as useLocation2,
|
|
161
|
-
useNavigate as useNavigate2,
|
|
162
|
-
useSearchParams as useSearchParams3
|
|
163
|
-
} from "react-router";
|
|
164
|
-
import { GoSearch } from "react-icons/go";
|
|
157
|
+
import { Link as Link3, useLocation as useLocation3 } from "react-router";
|
|
165
158
|
|
|
166
|
-
// src/table/
|
|
167
|
-
import {
|
|
168
|
-
import {
|
|
169
|
-
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
170
|
-
function TablePageButtons({
|
|
171
|
-
MAX_PAGES_TO_SHOW,
|
|
172
|
-
total,
|
|
173
|
-
limit,
|
|
174
|
-
offset
|
|
175
|
-
}) {
|
|
176
|
-
const pages = Math.ceil(total / limit);
|
|
177
|
-
const { pathname } = useLocation();
|
|
178
|
-
const [searchParams] = useSearchParams();
|
|
179
|
-
const currentPage = Math.floor(offset / limit) + 1;
|
|
180
|
-
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
181
|
-
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
182
|
-
return /* @__PURE__ */ jsx2(Fragment, { children: pages > 1 && /* @__PURE__ */ jsxs("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
183
|
-
startButton > 1 && /* @__PURE__ */ jsx2(
|
|
184
|
-
Link,
|
|
185
|
-
{
|
|
186
|
-
to: (() => {
|
|
187
|
-
searchParams.set(
|
|
188
|
-
"offset",
|
|
189
|
-
String((startButton - 1) * limit)
|
|
190
|
-
);
|
|
191
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
192
|
-
})(),
|
|
193
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
194
|
-
children: "\uC774\uC804"
|
|
195
|
-
}
|
|
196
|
-
),
|
|
197
|
-
Array.from({
|
|
198
|
-
length: Math.min(
|
|
199
|
-
MAX_PAGES_TO_SHOW,
|
|
200
|
-
pages - startButton
|
|
201
|
-
)
|
|
202
|
-
}).map((_, index) => {
|
|
203
|
-
return /* @__PURE__ */ jsx2(
|
|
204
|
-
Link,
|
|
205
|
-
{
|
|
206
|
-
to: (() => {
|
|
207
|
-
searchParams.set(
|
|
208
|
-
"offset",
|
|
209
|
-
String((startButton + index) * limit)
|
|
210
|
-
);
|
|
211
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
212
|
-
})(),
|
|
213
|
-
className: cn(
|
|
214
|
-
"w-6 block text-center transition-colors",
|
|
215
|
-
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
216
|
-
),
|
|
217
|
-
children: startButton + index + 1
|
|
218
|
-
},
|
|
219
|
-
index
|
|
220
|
-
);
|
|
221
|
-
}),
|
|
222
|
-
endButton < pages && /* @__PURE__ */ jsx2(
|
|
223
|
-
Link,
|
|
224
|
-
{
|
|
225
|
-
to: (() => {
|
|
226
|
-
searchParams.set(
|
|
227
|
-
"offset",
|
|
228
|
-
String((endButton + 1) * limit)
|
|
229
|
-
);
|
|
230
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
231
|
-
})(),
|
|
232
|
-
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
233
|
-
children: "\uB2E4\uC74C"
|
|
234
|
-
}
|
|
235
|
-
)
|
|
236
|
-
] }) });
|
|
237
|
-
}
|
|
159
|
+
// src/table/table_form.tsx
|
|
160
|
+
import { useLocation as useLocation2, useNavigate as useNavigate2, useSearchParams as useSearchParams3 } from "react-router";
|
|
161
|
+
import { GoSearch } from "react-icons/go";
|
|
238
162
|
|
|
239
163
|
// src/table/table.tsx
|
|
240
|
-
import { cn
|
|
164
|
+
import { cn } from "dn-react-toolkit/utils";
|
|
241
165
|
import { GoArrowDown, GoArrowUp } from "react-icons/go";
|
|
242
|
-
import { Link
|
|
243
|
-
import { Fragment
|
|
166
|
+
import { Link, useSearchParams } from "react-router";
|
|
167
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
244
168
|
function Table({
|
|
245
169
|
className = "min-w-full whitespace-nowrap",
|
|
246
170
|
data,
|
|
@@ -254,13 +178,13 @@ function Table({
|
|
|
254
178
|
}) {
|
|
255
179
|
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
256
180
|
const sortedArray = [...data];
|
|
257
|
-
const [_, setSearchParams] =
|
|
258
|
-
return /* @__PURE__ */
|
|
181
|
+
const [_, setSearchParams] = useSearchParams();
|
|
182
|
+
return /* @__PURE__ */ jsxs(
|
|
259
183
|
"table",
|
|
260
184
|
{
|
|
261
|
-
className:
|
|
185
|
+
className: cn(className, "text-[15px] border-separate border-spacing-0"),
|
|
262
186
|
children: [
|
|
263
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsx2("tr", { children: keys.map((key) => {
|
|
264
188
|
const value = columns[key];
|
|
265
189
|
function getReactNode() {
|
|
266
190
|
if (value && typeof value === "object" && "label" in value) {
|
|
@@ -271,10 +195,10 @@ function Table({
|
|
|
271
195
|
function Head() {
|
|
272
196
|
const reactNode = getReactNode();
|
|
273
197
|
if (typeof reactNode === "string") {
|
|
274
|
-
return /* @__PURE__ */
|
|
198
|
+
return /* @__PURE__ */ jsxs(
|
|
275
199
|
"button",
|
|
276
200
|
{
|
|
277
|
-
className:
|
|
201
|
+
className: cn(
|
|
278
202
|
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
279
203
|
"px-4 h-14 flex items-center w-full"
|
|
280
204
|
),
|
|
@@ -290,17 +214,17 @@ function Table({
|
|
|
290
214
|
},
|
|
291
215
|
children: [
|
|
292
216
|
reactNode,
|
|
293
|
-
orderBy === key && /* @__PURE__ */
|
|
217
|
+
orderBy === key && /* @__PURE__ */ jsx2("div", { className: "ml-0.5", children: direction === "asc" ? /* @__PURE__ */ jsx2(GoArrowUp, {}) : /* @__PURE__ */ jsx2(GoArrowDown, {}) })
|
|
294
218
|
]
|
|
295
219
|
}
|
|
296
220
|
);
|
|
297
221
|
}
|
|
298
|
-
return /* @__PURE__ */
|
|
222
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: reactNode });
|
|
299
223
|
}
|
|
300
|
-
return /* @__PURE__ */
|
|
224
|
+
return /* @__PURE__ */ jsx2("th", { className: cn("border-y font-normal"), children: /* @__PURE__ */ jsx2(Head, {}) }, key);
|
|
301
225
|
}) }) }),
|
|
302
|
-
/* @__PURE__ */
|
|
303
|
-
sortedArray.length === 0 && /* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ jsxs("tbody", { children: [
|
|
227
|
+
sortedArray.length === 0 && /* @__PURE__ */ jsx2("tr", { children: /* @__PURE__ */ jsx2(
|
|
304
228
|
"td",
|
|
305
229
|
{
|
|
306
230
|
colSpan: keys.length,
|
|
@@ -308,7 +232,7 @@ function Table({
|
|
|
308
232
|
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
309
233
|
}
|
|
310
234
|
) }),
|
|
311
|
-
sortedArray.map((item, i) => /* @__PURE__ */
|
|
235
|
+
sortedArray.map((item, i) => /* @__PURE__ */ jsx2("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
|
|
312
236
|
const value = item[key];
|
|
313
237
|
function Content() {
|
|
314
238
|
if (key in columns) {
|
|
@@ -316,22 +240,22 @@ function Table({
|
|
|
316
240
|
if (column && typeof column === "object" && "mapper" in column) {
|
|
317
241
|
const mapper = column.mapper;
|
|
318
242
|
if (mapper) {
|
|
319
|
-
return /* @__PURE__ */
|
|
243
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: mapper(item) });
|
|
320
244
|
}
|
|
321
245
|
}
|
|
322
246
|
}
|
|
323
|
-
return /* @__PURE__ */
|
|
247
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: String(value) });
|
|
324
248
|
}
|
|
325
|
-
const linkedContent = getLink ? /* @__PURE__ */
|
|
326
|
-
|
|
249
|
+
const linkedContent = getLink ? /* @__PURE__ */ jsx2(
|
|
250
|
+
Link,
|
|
327
251
|
{
|
|
328
252
|
to: getLink(item),
|
|
329
253
|
className: "block content-center px-4 w-full h-full",
|
|
330
|
-
children: /* @__PURE__ */
|
|
254
|
+
children: /* @__PURE__ */ jsx2(Content, {})
|
|
331
255
|
}
|
|
332
|
-
) : /* @__PURE__ */
|
|
333
|
-
const cell = Mapper ? /* @__PURE__ */
|
|
334
|
-
return /* @__PURE__ */
|
|
256
|
+
) : /* @__PURE__ */ jsx2(Content, {});
|
|
257
|
+
const cell = Mapper ? /* @__PURE__ */ jsx2(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
258
|
+
return /* @__PURE__ */ jsx2("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
335
259
|
}) }, i))
|
|
336
260
|
] })
|
|
337
261
|
]
|
|
@@ -339,8 +263,169 @@ function Table({
|
|
|
339
263
|
);
|
|
340
264
|
}
|
|
341
265
|
|
|
342
|
-
// src/table/
|
|
266
|
+
// src/table/use_table.tsx
|
|
267
|
+
import { useLoaderData } from "react-router";
|
|
268
|
+
function useTable() {
|
|
269
|
+
const { table } = useLoaderData();
|
|
270
|
+
const { items, total, limit, offset, orderBy, direction, searchKey } = table;
|
|
271
|
+
return {
|
|
272
|
+
items,
|
|
273
|
+
total,
|
|
274
|
+
limit,
|
|
275
|
+
offset,
|
|
276
|
+
orderBy,
|
|
277
|
+
direction,
|
|
278
|
+
searchKey
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/table/buttons.tsx
|
|
283
|
+
import { cn as cn2 } from "dn-react-toolkit/utils";
|
|
284
|
+
import { Link as Link2, useLocation, useSearchParams as useSearchParams2 } from "react-router";
|
|
285
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
286
|
+
function TablePageButtons({
|
|
287
|
+
MAX_PAGES_TO_SHOW,
|
|
288
|
+
total,
|
|
289
|
+
limit,
|
|
290
|
+
offset
|
|
291
|
+
}) {
|
|
292
|
+
const pages = Math.ceil(total / limit);
|
|
293
|
+
const { pathname } = useLocation();
|
|
294
|
+
const [searchParams] = useSearchParams2();
|
|
295
|
+
const currentPage = Math.floor(offset / limit) + 1;
|
|
296
|
+
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
297
|
+
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
298
|
+
return /* @__PURE__ */ jsx3(Fragment2, { children: pages > 1 && /* @__PURE__ */ jsxs2("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
299
|
+
startButton > 1 && /* @__PURE__ */ jsx3(
|
|
300
|
+
Link2,
|
|
301
|
+
{
|
|
302
|
+
to: (() => {
|
|
303
|
+
searchParams.set(
|
|
304
|
+
"offset",
|
|
305
|
+
String((startButton - 1) * limit)
|
|
306
|
+
);
|
|
307
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
308
|
+
})(),
|
|
309
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
310
|
+
children: "\uC774\uC804"
|
|
311
|
+
}
|
|
312
|
+
),
|
|
313
|
+
Array.from({
|
|
314
|
+
length: Math.min(
|
|
315
|
+
MAX_PAGES_TO_SHOW,
|
|
316
|
+
pages - startButton
|
|
317
|
+
)
|
|
318
|
+
}).map((_, index) => {
|
|
319
|
+
return /* @__PURE__ */ jsx3(
|
|
320
|
+
Link2,
|
|
321
|
+
{
|
|
322
|
+
to: (() => {
|
|
323
|
+
searchParams.set(
|
|
324
|
+
"offset",
|
|
325
|
+
String((startButton + index) * limit)
|
|
326
|
+
);
|
|
327
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
328
|
+
})(),
|
|
329
|
+
className: cn2(
|
|
330
|
+
"w-6 block text-center transition-colors",
|
|
331
|
+
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
332
|
+
),
|
|
333
|
+
children: startButton + index + 1
|
|
334
|
+
},
|
|
335
|
+
index
|
|
336
|
+
);
|
|
337
|
+
}),
|
|
338
|
+
endButton < pages && /* @__PURE__ */ jsx3(
|
|
339
|
+
Link2,
|
|
340
|
+
{
|
|
341
|
+
to: (() => {
|
|
342
|
+
searchParams.set(
|
|
343
|
+
"offset",
|
|
344
|
+
String((endButton + 1) * limit)
|
|
345
|
+
);
|
|
346
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
347
|
+
})(),
|
|
348
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
349
|
+
children: "\uB2E4\uC74C"
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
] }) });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// src/table/table_form.tsx
|
|
343
356
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
357
|
+
function TableForm({
|
|
358
|
+
columns,
|
|
359
|
+
primaryKey = "id"
|
|
360
|
+
}) {
|
|
361
|
+
const { pathname } = useLocation2();
|
|
362
|
+
const { items, total, limit, offset, orderBy, direction, searchKey } = useTable();
|
|
363
|
+
const navigate = useNavigate2();
|
|
364
|
+
const search = (query) => {
|
|
365
|
+
const searchParams2 = new URLSearchParams(window.location.search);
|
|
366
|
+
searchParams2.set("query", query);
|
|
367
|
+
searchParams2.set("offset", "0");
|
|
368
|
+
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
369
|
+
};
|
|
370
|
+
const [searchParams] = useSearchParams3();
|
|
371
|
+
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
372
|
+
searchKey && /* @__PURE__ */ jsxs3(
|
|
373
|
+
"form",
|
|
374
|
+
{
|
|
375
|
+
className: "h-18 px-4 flex items-center border-t",
|
|
376
|
+
onSubmit: (e) => {
|
|
377
|
+
e.preventDefault();
|
|
378
|
+
const formData = new FormData(e.currentTarget);
|
|
379
|
+
const query = formData.get("query");
|
|
380
|
+
search(query);
|
|
381
|
+
},
|
|
382
|
+
children: [
|
|
383
|
+
/* @__PURE__ */ jsx4(
|
|
384
|
+
"button",
|
|
385
|
+
{
|
|
386
|
+
type: "submit",
|
|
387
|
+
className: "w-10 h-10 flex justify-center items-center",
|
|
388
|
+
children: /* @__PURE__ */ jsx4(GoSearch, { className: "text-xl mr-4" })
|
|
389
|
+
}
|
|
390
|
+
),
|
|
391
|
+
/* @__PURE__ */ jsx4(
|
|
392
|
+
"input",
|
|
393
|
+
{
|
|
394
|
+
className: "outline-none h-full flex-1",
|
|
395
|
+
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
396
|
+
name: "query",
|
|
397
|
+
defaultValue: searchParams.get("query") ?? ""
|
|
398
|
+
}
|
|
399
|
+
)
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
),
|
|
403
|
+
/* @__PURE__ */ jsx4(
|
|
404
|
+
Table,
|
|
405
|
+
{
|
|
406
|
+
data: items,
|
|
407
|
+
columns,
|
|
408
|
+
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
409
|
+
limit,
|
|
410
|
+
offset,
|
|
411
|
+
orderBy,
|
|
412
|
+
direction
|
|
413
|
+
}
|
|
414
|
+
),
|
|
415
|
+
/* @__PURE__ */ jsx4(
|
|
416
|
+
TablePageButtons,
|
|
417
|
+
{
|
|
418
|
+
total,
|
|
419
|
+
limit,
|
|
420
|
+
offset,
|
|
421
|
+
MAX_PAGES_TO_SHOW: 10
|
|
422
|
+
}
|
|
423
|
+
)
|
|
424
|
+
] });
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// src/table/page.tsx
|
|
428
|
+
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
344
429
|
function createTablePage({
|
|
345
430
|
name,
|
|
346
431
|
columns,
|
|
@@ -349,82 +434,19 @@ function createTablePage({
|
|
|
349
434
|
return function TablePage({
|
|
350
435
|
header: Header
|
|
351
436
|
}) {
|
|
352
|
-
const { pathname } =
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
const navigate = useNavigate2();
|
|
356
|
-
const search = (query) => {
|
|
357
|
-
const searchParams2 = new URLSearchParams(window.location.search);
|
|
358
|
-
searchParams2.set("query", query);
|
|
359
|
-
searchParams2.set("offset", "0");
|
|
360
|
-
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
361
|
-
};
|
|
362
|
-
const [searchParams] = useSearchParams3();
|
|
363
|
-
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
364
|
-
/* @__PURE__ */ jsx4(
|
|
437
|
+
const { pathname } = useLocation3();
|
|
438
|
+
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
439
|
+
/* @__PURE__ */ jsx5(
|
|
365
440
|
Header,
|
|
366
441
|
{
|
|
367
442
|
title: name,
|
|
368
|
-
actions: /* @__PURE__ */
|
|
443
|
+
actions: /* @__PURE__ */ jsxs4(Link3, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
369
444
|
name,
|
|
370
445
|
" \uCD94\uAC00"
|
|
371
446
|
] })
|
|
372
447
|
}
|
|
373
448
|
),
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
searchKey && /* @__PURE__ */ jsxs3(
|
|
376
|
-
"form",
|
|
377
|
-
{
|
|
378
|
-
className: "h-18 px-4 flex items-center border-t",
|
|
379
|
-
onSubmit: (e) => {
|
|
380
|
-
e.preventDefault();
|
|
381
|
-
const formData = new FormData(e.currentTarget);
|
|
382
|
-
const query = formData.get("query");
|
|
383
|
-
search(query);
|
|
384
|
-
},
|
|
385
|
-
children: [
|
|
386
|
-
/* @__PURE__ */ jsx4(
|
|
387
|
-
"button",
|
|
388
|
-
{
|
|
389
|
-
type: "submit",
|
|
390
|
-
className: "w-10 h-10 flex justify-center items-center",
|
|
391
|
-
children: /* @__PURE__ */ jsx4(GoSearch, { className: "text-xl mr-4" })
|
|
392
|
-
}
|
|
393
|
-
),
|
|
394
|
-
/* @__PURE__ */ jsx4(
|
|
395
|
-
"input",
|
|
396
|
-
{
|
|
397
|
-
className: "outline-none h-full flex-1",
|
|
398
|
-
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
399
|
-
name: "query",
|
|
400
|
-
defaultValue: searchParams.get("query") ?? ""
|
|
401
|
-
}
|
|
402
|
-
)
|
|
403
|
-
]
|
|
404
|
-
}
|
|
405
|
-
),
|
|
406
|
-
/* @__PURE__ */ jsx4(
|
|
407
|
-
Table,
|
|
408
|
-
{
|
|
409
|
-
data: items,
|
|
410
|
-
columns,
|
|
411
|
-
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
412
|
-
limit,
|
|
413
|
-
offset,
|
|
414
|
-
orderBy,
|
|
415
|
-
direction
|
|
416
|
-
}
|
|
417
|
-
),
|
|
418
|
-
/* @__PURE__ */ jsx4(
|
|
419
|
-
TablePageButtons,
|
|
420
|
-
{
|
|
421
|
-
total,
|
|
422
|
-
limit,
|
|
423
|
-
offset,
|
|
424
|
-
MAX_PAGES_TO_SHOW: 10
|
|
425
|
-
}
|
|
426
|
-
)
|
|
427
|
-
] })
|
|
449
|
+
/* @__PURE__ */ jsx5("div", { className: "max-w-7xl mx-auto w-full overflow-auto", children: /* @__PURE__ */ jsx5(TableForm, { columns, primaryKey }) })
|
|
428
450
|
] });
|
|
429
451
|
};
|
|
430
452
|
}
|
|
@@ -432,11 +454,11 @@ function createTablePage({
|
|
|
432
454
|
// src/form/create_form_component.tsx
|
|
433
455
|
import { cn as cn3 } from "dn-react-toolkit/utils";
|
|
434
456
|
import "react";
|
|
435
|
-
import { jsx as
|
|
457
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
436
458
|
function createComponent(tag, options) {
|
|
437
459
|
return function FormComponent({ className, ...props }) {
|
|
438
460
|
const Tag = tag;
|
|
439
|
-
return /* @__PURE__ */
|
|
461
|
+
return /* @__PURE__ */ jsx6(Tag, { ...props, className: cn3(options.className, className) });
|
|
440
462
|
};
|
|
441
463
|
}
|
|
442
464
|
|
|
@@ -456,13 +478,13 @@ import { useStoreComponent } from "react-store-input";
|
|
|
456
478
|
|
|
457
479
|
// src/client/env_loader.tsx
|
|
458
480
|
import { useRouteLoaderData } from "react-router";
|
|
459
|
-
import { jsx as
|
|
481
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
460
482
|
|
|
461
483
|
// src/client/file_input.tsx
|
|
462
484
|
import {
|
|
463
485
|
useRef
|
|
464
486
|
} from "react";
|
|
465
|
-
import { Fragment as
|
|
487
|
+
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
466
488
|
|
|
467
489
|
// src/client/use_user_agent.tsx
|
|
468
490
|
import { useRouteLoaderData as useRouteLoaderData2 } from "react-router";
|
|
@@ -473,7 +495,7 @@ import {
|
|
|
473
495
|
} from "dn-react-text-editor";
|
|
474
496
|
import { useStoreController } from "react-store-input";
|
|
475
497
|
import { useImperativeHandle, useRef as useRef2 } from "react";
|
|
476
|
-
import { jsx as
|
|
498
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
477
499
|
function StoreTextEditor({
|
|
478
500
|
store,
|
|
479
501
|
name,
|
|
@@ -532,7 +554,7 @@ function StoreTextEditor({
|
|
|
532
554
|
}
|
|
533
555
|
return void 0;
|
|
534
556
|
};
|
|
535
|
-
return /* @__PURE__ */
|
|
557
|
+
return /* @__PURE__ */ jsx9(
|
|
536
558
|
TextEditor,
|
|
537
559
|
{
|
|
538
560
|
...props,
|
|
@@ -550,19 +572,19 @@ function StoreTextEditor({
|
|
|
550
572
|
import { generateMetadata } from "dn-react-toolkit/file/client";
|
|
551
573
|
|
|
552
574
|
// src/crud/crud_form.tsx
|
|
553
|
-
import { Fragment as
|
|
575
|
+
import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
554
576
|
function CrudForm({
|
|
555
577
|
AdminHeader
|
|
556
578
|
}) {
|
|
557
579
|
const form = useFormContext();
|
|
558
580
|
const component = useStoreComponent(form.store);
|
|
559
|
-
return /* @__PURE__ */
|
|
560
|
-
/* @__PURE__ */
|
|
581
|
+
return /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
582
|
+
/* @__PURE__ */ jsx10(
|
|
561
583
|
AdminHeader,
|
|
562
584
|
{
|
|
563
585
|
title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
|
|
564
|
-
actions: /* @__PURE__ */
|
|
565
|
-
form.item && /* @__PURE__ */
|
|
586
|
+
actions: /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
587
|
+
form.item && /* @__PURE__ */ jsx10(
|
|
566
588
|
"button",
|
|
567
589
|
{
|
|
568
590
|
type: "button",
|
|
@@ -573,7 +595,7 @@ function CrudForm({
|
|
|
573
595
|
children: "\uC0AD\uC81C\uD558\uAE30"
|
|
574
596
|
}
|
|
575
597
|
),
|
|
576
|
-
/* @__PURE__ */
|
|
598
|
+
/* @__PURE__ */ jsx10(
|
|
577
599
|
"button",
|
|
578
600
|
{
|
|
579
601
|
type: "button",
|
|
@@ -585,15 +607,15 @@ function CrudForm({
|
|
|
585
607
|
] })
|
|
586
608
|
}
|
|
587
609
|
),
|
|
588
|
-
/* @__PURE__ */
|
|
610
|
+
/* @__PURE__ */ jsx10("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ jsx10(Fragment6, { children: Object.entries(form.columns).map(
|
|
589
611
|
([name, value]) => {
|
|
590
612
|
function InputComponent() {
|
|
591
613
|
if (value.component) {
|
|
592
614
|
const Component = value.component;
|
|
593
|
-
return /* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ jsx10(Component, { store: form.store, name });
|
|
594
616
|
}
|
|
595
617
|
if (value.type === "textarea") {
|
|
596
|
-
return /* @__PURE__ */
|
|
618
|
+
return /* @__PURE__ */ jsx10(
|
|
597
619
|
StoreTextEditor,
|
|
598
620
|
{
|
|
599
621
|
store: form.store,
|
|
@@ -608,9 +630,9 @@ function CrudForm({
|
|
|
608
630
|
}
|
|
609
631
|
if (value.options) {
|
|
610
632
|
const Component = value.options;
|
|
611
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ jsx10(component.select, { name, className: "select-form", children: /* @__PURE__ */ jsx10(Component, {}) });
|
|
612
634
|
}
|
|
613
|
-
return /* @__PURE__ */
|
|
635
|
+
return /* @__PURE__ */ jsx10(
|
|
614
636
|
component.input,
|
|
615
637
|
{
|
|
616
638
|
name,
|
|
@@ -621,14 +643,14 @@ function CrudForm({
|
|
|
621
643
|
}
|
|
622
644
|
const v = form.store.state[name];
|
|
623
645
|
if (typeof v === "boolean") {
|
|
624
|
-
return /* @__PURE__ */
|
|
646
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex", children: [
|
|
625
647
|
value.label,
|
|
626
|
-
/* @__PURE__ */
|
|
648
|
+
/* @__PURE__ */ jsx10("div", { className: "ml-auto", children: /* @__PURE__ */ jsx10(InputComponent, {}) })
|
|
627
649
|
] });
|
|
628
650
|
}
|
|
629
|
-
return /* @__PURE__ */
|
|
630
|
-
/* @__PURE__ */
|
|
631
|
-
/* @__PURE__ */
|
|
651
|
+
return /* @__PURE__ */ jsx10(FormRow, { children: /* @__PURE__ */ jsxs6(FormEntry, { children: [
|
|
652
|
+
/* @__PURE__ */ jsx10(FormLabel, { children: value.label }, name),
|
|
653
|
+
/* @__PURE__ */ jsx10(InputComponent, {})
|
|
632
654
|
] }) }, name);
|
|
633
655
|
}
|
|
634
656
|
) }) })
|
|
@@ -636,7 +658,7 @@ function CrudForm({
|
|
|
636
658
|
}
|
|
637
659
|
|
|
638
660
|
// src/crud/crud_page.tsx
|
|
639
|
-
import { jsx as
|
|
661
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
640
662
|
function crudPage({
|
|
641
663
|
name,
|
|
642
664
|
primaryKey,
|
|
@@ -647,16 +669,16 @@ function crudPage({
|
|
|
647
669
|
const create = (prefix) => {
|
|
648
670
|
return function Page() {
|
|
649
671
|
const data = useLoaderData2();
|
|
650
|
-
const { pathname } =
|
|
672
|
+
const { pathname } = useLocation4();
|
|
651
673
|
if (pathname === prefix) {
|
|
652
674
|
const Component = createTablePage({
|
|
653
675
|
...tablePageOptions,
|
|
654
676
|
name
|
|
655
677
|
});
|
|
656
|
-
return /* @__PURE__ */
|
|
678
|
+
return /* @__PURE__ */ jsx11(Component, { header });
|
|
657
679
|
}
|
|
658
680
|
if (pathname.startsWith(prefix)) {
|
|
659
|
-
return /* @__PURE__ */
|
|
681
|
+
return /* @__PURE__ */ jsx11(
|
|
660
682
|
CrudFormProvider,
|
|
661
683
|
{
|
|
662
684
|
item: data?.item,
|
|
@@ -664,7 +686,7 @@ function crudPage({
|
|
|
664
686
|
name,
|
|
665
687
|
columns: formOptions.columns,
|
|
666
688
|
primaryKey,
|
|
667
|
-
children: formOptions.form ? /* @__PURE__ */
|
|
689
|
+
children: formOptions.form ? /* @__PURE__ */ jsx11(FormDelegate, { component: formOptions.form }) : /* @__PURE__ */ jsx11(CrudForm, { AdminHeader: header })
|
|
668
690
|
}
|
|
669
691
|
);
|
|
670
692
|
}
|
|
@@ -679,7 +701,7 @@ function FormDelegate({
|
|
|
679
701
|
component: Component
|
|
680
702
|
}) {
|
|
681
703
|
const form = useFormContext();
|
|
682
|
-
return /* @__PURE__ */
|
|
704
|
+
return /* @__PURE__ */ jsx11(Component, { form });
|
|
683
705
|
}
|
|
684
706
|
export {
|
|
685
707
|
crudPage
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { LoaderFunctionArgs } from 'react-router';
|
|
2
2
|
import { CrudHandler } from './crud_loader.mjs';
|
|
3
|
-
import '../table/
|
|
3
|
+
import '../table/item_loader.mjs';
|
|
4
4
|
import '../table/repository.mjs';
|
|
5
5
|
import 'drizzle-orm';
|
|
6
|
+
import 'drizzle-orm/node-postgres';
|
|
6
7
|
import 'drizzle-orm/pg-core';
|
|
7
|
-
import '../table/
|
|
8
|
+
import '../table/load_table.mjs';
|
|
8
9
|
import '../api/create_api_handler.mjs';
|
|
9
10
|
import '../auth/with_auth.mjs';
|
|
10
11
|
import 'dn-react-toolkit/auth';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { LoaderFunctionArgs } from 'react-router';
|
|
2
2
|
import { CrudHandler } from './crud_loader.js';
|
|
3
|
-
import '../table/
|
|
3
|
+
import '../table/item_loader.js';
|
|
4
4
|
import '../table/repository.js';
|
|
5
5
|
import 'drizzle-orm';
|
|
6
|
+
import 'drizzle-orm/node-postgres';
|
|
6
7
|
import 'drizzle-orm/pg-core';
|
|
7
|
-
import '../table/
|
|
8
|
+
import '../table/load_table.js';
|
|
8
9
|
import '../api/create_api_handler.js';
|
|
9
10
|
import '../auth/with_auth.js';
|
|
10
11
|
import 'dn-react-toolkit/auth';
|
|
@@ -3,8 +3,9 @@ import { CrudPage } from './crud_page.mjs';
|
|
|
3
3
|
import './crud_form_provider.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-store-input';
|
|
6
|
-
import '../table/
|
|
6
|
+
import '../table/table_form.mjs';
|
|
7
7
|
import '../table/table.mjs';
|
|
8
|
+
import '../table/use_table.mjs';
|
|
8
9
|
|
|
9
10
|
declare const generatePages: (pages: Record<string, CrudPage>) => {
|
|
10
11
|
Page: () => react_jsx_runtime.JSX.Element | undefined;
|