dn-react-router-toolkit 0.7.15 → 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/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 +13 -6
- package/dist/api/index.mjs +14 -7
- package/dist/api/item_api_handler.d.mts +8 -5
- package/dist/api/item_api_handler.d.ts +8 -5
- package/dist/api/item_api_handler.js +13 -5
- package/dist/api/item_api_handler.mjs +14 -6
- package/dist/crud/crud_loader.d.mts +6 -5
- package/dist/crud/crud_loader.d.ts +6 -5
- package/dist/crud/crud_loader.js +79 -38
- package/dist/crud/crud_loader.mjs +81 -39
- package/dist/crud/crud_page.d.mts +3 -2
- package/dist/crud/crud_page.d.ts +3 -2
- package/dist/crud/crud_page.js +279 -201
- package/dist/crud/crud_page.mjs +277 -205
- 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 +338 -219
- package/dist/crud/index.mjs +346 -232
- package/dist/post/index.js +71 -64
- package/dist/post/index.mjs +76 -74
- package/dist/post/post_form_page.js +71 -64
- package/dist/post/post_form_page.mjs +76 -74
- package/dist/table/index.d.mts +7 -3
- package/dist/table/index.d.ts +7 -3
- package/dist/table/index.js +233 -111
- package/dist/table/index.mjs +230 -116
- 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 +36 -0
- package/dist/table/load_table.d.ts +36 -0
- package/dist/table/load_table.js +87 -0
- package/dist/table/load_table.mjs +66 -0
- package/dist/table/loader.d.mts +10 -15
- package/dist/table/loader.d.ts +10 -15
- package/dist/table/loader.js +67 -31
- package/dist/table/loader.mjs +67 -32
- package/dist/table/page.d.mts +6 -16
- package/dist/table/page.d.ts +6 -16
- package/dist/table/page.js +247 -169
- package/dist/table/page.mjs +248 -176
- package/dist/table/repository.d.mts +14 -10
- package/dist/table/repository.d.ts +14 -10
- package/dist/table/repository.js +5 -1
- package/dist/table/repository.mjs +5 -1
- 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 +13 -0
- package/dist/table/table_form.d.ts +13 -0
- package/dist/table/table_form.js +345 -0
- package/dist/table/table_form.mjs +320 -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 +34 -0
- package/dist/table/use_table.mjs +9 -0
- package/package.json +2 -2
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,
|
|
@@ -250,17 +174,21 @@ function Table({
|
|
|
250
174
|
limit,
|
|
251
175
|
offset,
|
|
252
176
|
orderBy,
|
|
253
|
-
direction
|
|
177
|
+
direction,
|
|
178
|
+
filters
|
|
254
179
|
}) {
|
|
255
180
|
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
256
181
|
const sortedArray = [...data];
|
|
257
|
-
const [_, setSearchParams] =
|
|
258
|
-
return /* @__PURE__ */
|
|
182
|
+
const [_, setSearchParams] = useSearchParams();
|
|
183
|
+
return /* @__PURE__ */ jsxs(
|
|
259
184
|
"table",
|
|
260
185
|
{
|
|
261
|
-
className:
|
|
186
|
+
className: cn(
|
|
187
|
+
className,
|
|
188
|
+
"text-[15px] border-separate border-spacing-0"
|
|
189
|
+
),
|
|
262
190
|
children: [
|
|
263
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsx2("tr", { children: keys.map((key) => {
|
|
264
192
|
const value = columns[key];
|
|
265
193
|
function getReactNode() {
|
|
266
194
|
if (value && typeof value === "object" && "label" in value) {
|
|
@@ -271,12 +199,12 @@ function Table({
|
|
|
271
199
|
function Head() {
|
|
272
200
|
const reactNode = getReactNode();
|
|
273
201
|
if (typeof reactNode === "string") {
|
|
274
|
-
return /* @__PURE__ */
|
|
202
|
+
return /* @__PURE__ */ jsxs(
|
|
275
203
|
"button",
|
|
276
204
|
{
|
|
277
|
-
className:
|
|
278
|
-
orderBy === key ? "text-
|
|
279
|
-
"px-4
|
|
205
|
+
className: cn(
|
|
206
|
+
orderBy === key ? "text-gray-900 font-medium" : "text-gray-500 font-medium",
|
|
207
|
+
"px-4 flex items-center w-full"
|
|
280
208
|
),
|
|
281
209
|
onClick: () => {
|
|
282
210
|
let newDirection = "asc";
|
|
@@ -290,25 +218,70 @@ function Table({
|
|
|
290
218
|
},
|
|
291
219
|
children: [
|
|
292
220
|
reactNode,
|
|
293
|
-
orderBy === key && /* @__PURE__ */
|
|
221
|
+
orderBy === key && /* @__PURE__ */ jsx2("div", { className: "ml-0.5", children: direction === "asc" ? /* @__PURE__ */ jsx2(GoArrowUp, {}) : /* @__PURE__ */ jsx2(GoArrowDown, {}) })
|
|
294
222
|
]
|
|
295
223
|
}
|
|
296
224
|
);
|
|
297
225
|
}
|
|
298
|
-
return /* @__PURE__ */
|
|
226
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: reactNode });
|
|
299
227
|
}
|
|
300
|
-
|
|
228
|
+
const filter = filters[key];
|
|
229
|
+
return /* @__PURE__ */ jsxs(
|
|
230
|
+
"th",
|
|
231
|
+
{
|
|
232
|
+
className: cn(
|
|
233
|
+
"py-4 border-y font-normal align-top"
|
|
234
|
+
),
|
|
235
|
+
children: [
|
|
236
|
+
/* @__PURE__ */ jsx2(Head, {}),
|
|
237
|
+
filter && /* @__PURE__ */ jsx2("div", { className: "px-3 mt-4", children: /* @__PURE__ */ jsxs(
|
|
238
|
+
"select",
|
|
239
|
+
{
|
|
240
|
+
className: "w-full h-10 px-1.5 border rounded-full outline-none",
|
|
241
|
+
onChange: (e) => {
|
|
242
|
+
const value2 = e.target.value;
|
|
243
|
+
setSearchParams((prev) => {
|
|
244
|
+
if (value2) {
|
|
245
|
+
prev.set(
|
|
246
|
+
key,
|
|
247
|
+
encodeURIComponent(
|
|
248
|
+
value2
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
} else {
|
|
252
|
+
prev.delete(key);
|
|
253
|
+
}
|
|
254
|
+
return prev;
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ jsx2("option", { value: "", children: "\uC804\uCCB4" }),
|
|
259
|
+
filter.map((option) => /* @__PURE__ */ jsx2(
|
|
260
|
+
"option",
|
|
261
|
+
{
|
|
262
|
+
value: option,
|
|
263
|
+
children: option
|
|
264
|
+
},
|
|
265
|
+
option
|
|
266
|
+
))
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
) })
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
key
|
|
273
|
+
);
|
|
301
274
|
}) }) }),
|
|
302
|
-
/* @__PURE__ */
|
|
303
|
-
sortedArray.length === 0 && /* @__PURE__ */
|
|
275
|
+
/* @__PURE__ */ jsxs("tbody", { children: [
|
|
276
|
+
sortedArray.length === 0 && /* @__PURE__ */ jsx2("tr", { children: /* @__PURE__ */ jsx2(
|
|
304
277
|
"td",
|
|
305
278
|
{
|
|
306
279
|
colSpan: keys.length,
|
|
307
|
-
className: "px-4 h-
|
|
280
|
+
className: "px-4 h-20 text-gray-400 text-center",
|
|
308
281
|
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
309
282
|
}
|
|
310
283
|
) }),
|
|
311
|
-
sortedArray.map((item, i) => /* @__PURE__ */
|
|
284
|
+
sortedArray.map((item, i) => /* @__PURE__ */ jsx2("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
|
|
312
285
|
const value = item[key];
|
|
313
286
|
function Content() {
|
|
314
287
|
if (key in columns) {
|
|
@@ -316,22 +289,22 @@ function Table({
|
|
|
316
289
|
if (column && typeof column === "object" && "mapper" in column) {
|
|
317
290
|
const mapper = column.mapper;
|
|
318
291
|
if (mapper) {
|
|
319
|
-
return /* @__PURE__ */
|
|
292
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: mapper(item) });
|
|
320
293
|
}
|
|
321
294
|
}
|
|
322
295
|
}
|
|
323
|
-
return /* @__PURE__ */
|
|
296
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: String(value) });
|
|
324
297
|
}
|
|
325
|
-
const linkedContent = getLink ? /* @__PURE__ */
|
|
326
|
-
|
|
298
|
+
const linkedContent = getLink ? /* @__PURE__ */ jsx2(
|
|
299
|
+
Link,
|
|
327
300
|
{
|
|
328
301
|
to: getLink(item),
|
|
329
302
|
className: "block content-center px-4 w-full h-full",
|
|
330
|
-
children: /* @__PURE__ */
|
|
303
|
+
children: /* @__PURE__ */ jsx2(Content, {})
|
|
331
304
|
}
|
|
332
|
-
) : /* @__PURE__ */
|
|
333
|
-
const cell = Mapper ? /* @__PURE__ */
|
|
334
|
-
return /* @__PURE__ */
|
|
305
|
+
) : /* @__PURE__ */ jsx2(Content, {});
|
|
306
|
+
const cell = Mapper ? /* @__PURE__ */ jsx2(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
307
|
+
return /* @__PURE__ */ jsx2("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
335
308
|
}) }, i))
|
|
336
309
|
] })
|
|
337
310
|
]
|
|
@@ -339,8 +312,170 @@ function Table({
|
|
|
339
312
|
);
|
|
340
313
|
}
|
|
341
314
|
|
|
342
|
-
// src/table/
|
|
315
|
+
// src/table/use_table.tsx
|
|
316
|
+
import { useLoaderData } from "react-router";
|
|
317
|
+
function useTable() {
|
|
318
|
+
const { table } = useLoaderData();
|
|
319
|
+
return table;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// src/table/buttons.tsx
|
|
323
|
+
import { cn as cn2 } from "dn-react-toolkit/utils";
|
|
324
|
+
import { Link as Link2, useLocation, useSearchParams as useSearchParams2 } from "react-router";
|
|
325
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
326
|
+
function TablePageButtons({
|
|
327
|
+
MAX_PAGES_TO_SHOW,
|
|
328
|
+
total,
|
|
329
|
+
limit,
|
|
330
|
+
offset
|
|
331
|
+
}) {
|
|
332
|
+
const pages = Math.ceil(total / limit);
|
|
333
|
+
const { pathname } = useLocation();
|
|
334
|
+
const [searchParams] = useSearchParams2();
|
|
335
|
+
const currentPage = Math.floor(offset / limit) + 1;
|
|
336
|
+
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
337
|
+
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
338
|
+
return /* @__PURE__ */ jsx3(Fragment2, { children: pages > 1 && /* @__PURE__ */ jsxs2("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
339
|
+
startButton > 1 && /* @__PURE__ */ jsx3(
|
|
340
|
+
Link2,
|
|
341
|
+
{
|
|
342
|
+
to: (() => {
|
|
343
|
+
searchParams.set(
|
|
344
|
+
"offset",
|
|
345
|
+
String((startButton - 1) * limit)
|
|
346
|
+
);
|
|
347
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
348
|
+
})(),
|
|
349
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
350
|
+
children: "\uC774\uC804"
|
|
351
|
+
}
|
|
352
|
+
),
|
|
353
|
+
Array.from({
|
|
354
|
+
length: Math.min(
|
|
355
|
+
MAX_PAGES_TO_SHOW,
|
|
356
|
+
pages - startButton
|
|
357
|
+
)
|
|
358
|
+
}).map((_, index) => {
|
|
359
|
+
return /* @__PURE__ */ jsx3(
|
|
360
|
+
Link2,
|
|
361
|
+
{
|
|
362
|
+
to: (() => {
|
|
363
|
+
searchParams.set(
|
|
364
|
+
"offset",
|
|
365
|
+
String((startButton + index) * limit)
|
|
366
|
+
);
|
|
367
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
368
|
+
})(),
|
|
369
|
+
className: cn2(
|
|
370
|
+
"w-6 block text-center transition-colors",
|
|
371
|
+
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
372
|
+
),
|
|
373
|
+
children: startButton + index + 1
|
|
374
|
+
},
|
|
375
|
+
index
|
|
376
|
+
);
|
|
377
|
+
}),
|
|
378
|
+
endButton < pages && /* @__PURE__ */ jsx3(
|
|
379
|
+
Link2,
|
|
380
|
+
{
|
|
381
|
+
to: (() => {
|
|
382
|
+
searchParams.set(
|
|
383
|
+
"offset",
|
|
384
|
+
String((endButton + 1) * limit)
|
|
385
|
+
);
|
|
386
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
387
|
+
})(),
|
|
388
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
389
|
+
children: "\uB2E4\uC74C"
|
|
390
|
+
}
|
|
391
|
+
)
|
|
392
|
+
] }) });
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// src/table/table_form.tsx
|
|
343
396
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
397
|
+
function TableForm({
|
|
398
|
+
columns,
|
|
399
|
+
primaryKey = "id"
|
|
400
|
+
}) {
|
|
401
|
+
const { pathname } = useLocation2();
|
|
402
|
+
const {
|
|
403
|
+
items,
|
|
404
|
+
total,
|
|
405
|
+
limit,
|
|
406
|
+
offset,
|
|
407
|
+
orderBy,
|
|
408
|
+
direction,
|
|
409
|
+
searchKey,
|
|
410
|
+
filters
|
|
411
|
+
} = useTable();
|
|
412
|
+
const navigate = useNavigate2();
|
|
413
|
+
const search = (query) => {
|
|
414
|
+
const searchParams2 = new URLSearchParams(window.location.search);
|
|
415
|
+
searchParams2.set("query", query);
|
|
416
|
+
searchParams2.set("offset", "0");
|
|
417
|
+
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
418
|
+
};
|
|
419
|
+
const [searchParams] = useSearchParams3();
|
|
420
|
+
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
421
|
+
searchKey && /* @__PURE__ */ jsxs3(
|
|
422
|
+
"form",
|
|
423
|
+
{
|
|
424
|
+
className: "h-20 px-4 flex items-center border-t",
|
|
425
|
+
onSubmit: (e) => {
|
|
426
|
+
e.preventDefault();
|
|
427
|
+
const formData = new FormData(e.currentTarget);
|
|
428
|
+
const query = formData.get("query");
|
|
429
|
+
search(query);
|
|
430
|
+
},
|
|
431
|
+
children: [
|
|
432
|
+
/* @__PURE__ */ jsx4(
|
|
433
|
+
"button",
|
|
434
|
+
{
|
|
435
|
+
type: "submit",
|
|
436
|
+
className: "w-10 h-10 flex justify-center items-center",
|
|
437
|
+
children: /* @__PURE__ */ jsx4(GoSearch, { className: "text-xl mr-4" })
|
|
438
|
+
}
|
|
439
|
+
),
|
|
440
|
+
/* @__PURE__ */ jsx4(
|
|
441
|
+
"input",
|
|
442
|
+
{
|
|
443
|
+
className: "outline-none h-full flex-1",
|
|
444
|
+
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
445
|
+
name: "query",
|
|
446
|
+
defaultValue: searchParams.get("query") ?? ""
|
|
447
|
+
}
|
|
448
|
+
)
|
|
449
|
+
]
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
/* @__PURE__ */ jsx4(
|
|
453
|
+
Table,
|
|
454
|
+
{
|
|
455
|
+
data: items,
|
|
456
|
+
columns,
|
|
457
|
+
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
458
|
+
limit,
|
|
459
|
+
offset,
|
|
460
|
+
orderBy,
|
|
461
|
+
direction,
|
|
462
|
+
filters
|
|
463
|
+
}
|
|
464
|
+
),
|
|
465
|
+
/* @__PURE__ */ jsx4(
|
|
466
|
+
TablePageButtons,
|
|
467
|
+
{
|
|
468
|
+
total,
|
|
469
|
+
limit,
|
|
470
|
+
offset,
|
|
471
|
+
MAX_PAGES_TO_SHOW: 10
|
|
472
|
+
}
|
|
473
|
+
)
|
|
474
|
+
] });
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// src/table/page.tsx
|
|
478
|
+
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
344
479
|
function createTablePage({
|
|
345
480
|
name,
|
|
346
481
|
columns,
|
|
@@ -349,82 +484,19 @@ function createTablePage({
|
|
|
349
484
|
return function TablePage({
|
|
350
485
|
header: Header
|
|
351
486
|
}) {
|
|
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(
|
|
487
|
+
const { pathname } = useLocation3();
|
|
488
|
+
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
489
|
+
/* @__PURE__ */ jsx5(
|
|
365
490
|
Header,
|
|
366
491
|
{
|
|
367
492
|
title: name,
|
|
368
|
-
actions: /* @__PURE__ */
|
|
493
|
+
actions: /* @__PURE__ */ jsxs4(Link3, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
369
494
|
name,
|
|
370
495
|
" \uCD94\uAC00"
|
|
371
496
|
] })
|
|
372
497
|
}
|
|
373
498
|
),
|
|
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
|
-
] })
|
|
499
|
+
/* @__PURE__ */ jsx5("div", { className: "max-w-7xl mx-auto w-full overflow-auto", children: /* @__PURE__ */ jsx5(TableForm, { columns, primaryKey }) })
|
|
428
500
|
] });
|
|
429
501
|
};
|
|
430
502
|
}
|
|
@@ -432,11 +504,11 @@ function createTablePage({
|
|
|
432
504
|
// src/form/create_form_component.tsx
|
|
433
505
|
import { cn as cn3 } from "dn-react-toolkit/utils";
|
|
434
506
|
import "react";
|
|
435
|
-
import { jsx as
|
|
507
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
436
508
|
function createComponent(tag, options) {
|
|
437
509
|
return function FormComponent({ className, ...props }) {
|
|
438
510
|
const Tag = tag;
|
|
439
|
-
return /* @__PURE__ */
|
|
511
|
+
return /* @__PURE__ */ jsx6(Tag, { ...props, className: cn3(options.className, className) });
|
|
440
512
|
};
|
|
441
513
|
}
|
|
442
514
|
|
|
@@ -456,13 +528,13 @@ import { useStoreComponent } from "react-store-input";
|
|
|
456
528
|
|
|
457
529
|
// src/client/env_loader.tsx
|
|
458
530
|
import { useRouteLoaderData } from "react-router";
|
|
459
|
-
import { jsx as
|
|
531
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
460
532
|
|
|
461
533
|
// src/client/file_input.tsx
|
|
462
534
|
import {
|
|
463
535
|
useRef
|
|
464
536
|
} from "react";
|
|
465
|
-
import { Fragment as
|
|
537
|
+
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
466
538
|
|
|
467
539
|
// src/client/use_user_agent.tsx
|
|
468
540
|
import { useRouteLoaderData as useRouteLoaderData2 } from "react-router";
|
|
@@ -473,7 +545,7 @@ import {
|
|
|
473
545
|
} from "dn-react-text-editor";
|
|
474
546
|
import { useStoreController } from "react-store-input";
|
|
475
547
|
import { useImperativeHandle, useRef as useRef2 } from "react";
|
|
476
|
-
import { jsx as
|
|
548
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
477
549
|
function StoreTextEditor({
|
|
478
550
|
store,
|
|
479
551
|
name,
|
|
@@ -532,7 +604,7 @@ function StoreTextEditor({
|
|
|
532
604
|
}
|
|
533
605
|
return void 0;
|
|
534
606
|
};
|
|
535
|
-
return /* @__PURE__ */
|
|
607
|
+
return /* @__PURE__ */ jsx9(
|
|
536
608
|
TextEditor,
|
|
537
609
|
{
|
|
538
610
|
...props,
|
|
@@ -550,19 +622,19 @@ function StoreTextEditor({
|
|
|
550
622
|
import { generateMetadata } from "dn-react-toolkit/file/client";
|
|
551
623
|
|
|
552
624
|
// src/crud/crud_form.tsx
|
|
553
|
-
import { Fragment as
|
|
625
|
+
import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
554
626
|
function CrudForm({
|
|
555
627
|
AdminHeader
|
|
556
628
|
}) {
|
|
557
629
|
const form = useFormContext();
|
|
558
630
|
const component = useStoreComponent(form.store);
|
|
559
|
-
return /* @__PURE__ */
|
|
560
|
-
/* @__PURE__ */
|
|
631
|
+
return /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
632
|
+
/* @__PURE__ */ jsx10(
|
|
561
633
|
AdminHeader,
|
|
562
634
|
{
|
|
563
635
|
title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
|
|
564
|
-
actions: /* @__PURE__ */
|
|
565
|
-
form.item && /* @__PURE__ */
|
|
636
|
+
actions: /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
637
|
+
form.item && /* @__PURE__ */ jsx10(
|
|
566
638
|
"button",
|
|
567
639
|
{
|
|
568
640
|
type: "button",
|
|
@@ -573,7 +645,7 @@ function CrudForm({
|
|
|
573
645
|
children: "\uC0AD\uC81C\uD558\uAE30"
|
|
574
646
|
}
|
|
575
647
|
),
|
|
576
|
-
/* @__PURE__ */
|
|
648
|
+
/* @__PURE__ */ jsx10(
|
|
577
649
|
"button",
|
|
578
650
|
{
|
|
579
651
|
type: "button",
|
|
@@ -585,15 +657,15 @@ function CrudForm({
|
|
|
585
657
|
] })
|
|
586
658
|
}
|
|
587
659
|
),
|
|
588
|
-
/* @__PURE__ */
|
|
660
|
+
/* @__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
661
|
([name, value]) => {
|
|
590
662
|
function InputComponent() {
|
|
591
663
|
if (value.component) {
|
|
592
664
|
const Component = value.component;
|
|
593
|
-
return /* @__PURE__ */
|
|
665
|
+
return /* @__PURE__ */ jsx10(Component, { store: form.store, name });
|
|
594
666
|
}
|
|
595
667
|
if (value.type === "textarea") {
|
|
596
|
-
return /* @__PURE__ */
|
|
668
|
+
return /* @__PURE__ */ jsx10(
|
|
597
669
|
StoreTextEditor,
|
|
598
670
|
{
|
|
599
671
|
store: form.store,
|
|
@@ -608,9 +680,9 @@ function CrudForm({
|
|
|
608
680
|
}
|
|
609
681
|
if (value.options) {
|
|
610
682
|
const Component = value.options;
|
|
611
|
-
return /* @__PURE__ */
|
|
683
|
+
return /* @__PURE__ */ jsx10(component.select, { name, className: "select-form", children: /* @__PURE__ */ jsx10(Component, {}) });
|
|
612
684
|
}
|
|
613
|
-
return /* @__PURE__ */
|
|
685
|
+
return /* @__PURE__ */ jsx10(
|
|
614
686
|
component.input,
|
|
615
687
|
{
|
|
616
688
|
name,
|
|
@@ -621,14 +693,14 @@ function CrudForm({
|
|
|
621
693
|
}
|
|
622
694
|
const v = form.store.state[name];
|
|
623
695
|
if (typeof v === "boolean") {
|
|
624
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex", children: [
|
|
625
697
|
value.label,
|
|
626
|
-
/* @__PURE__ */
|
|
698
|
+
/* @__PURE__ */ jsx10("div", { className: "ml-auto", children: /* @__PURE__ */ jsx10(InputComponent, {}) })
|
|
627
699
|
] });
|
|
628
700
|
}
|
|
629
|
-
return /* @__PURE__ */
|
|
630
|
-
/* @__PURE__ */
|
|
631
|
-
/* @__PURE__ */
|
|
701
|
+
return /* @__PURE__ */ jsx10(FormRow, { children: /* @__PURE__ */ jsxs6(FormEntry, { children: [
|
|
702
|
+
/* @__PURE__ */ jsx10(FormLabel, { children: value.label }, name),
|
|
703
|
+
/* @__PURE__ */ jsx10(InputComponent, {})
|
|
632
704
|
] }) }, name);
|
|
633
705
|
}
|
|
634
706
|
) }) })
|
|
@@ -636,7 +708,7 @@ function CrudForm({
|
|
|
636
708
|
}
|
|
637
709
|
|
|
638
710
|
// src/crud/crud_page.tsx
|
|
639
|
-
import { jsx as
|
|
711
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
640
712
|
function crudPage({
|
|
641
713
|
name,
|
|
642
714
|
primaryKey,
|
|
@@ -647,16 +719,16 @@ function crudPage({
|
|
|
647
719
|
const create = (prefix) => {
|
|
648
720
|
return function Page() {
|
|
649
721
|
const data = useLoaderData2();
|
|
650
|
-
const { pathname } =
|
|
722
|
+
const { pathname } = useLocation4();
|
|
651
723
|
if (pathname === prefix) {
|
|
652
724
|
const Component = createTablePage({
|
|
653
725
|
...tablePageOptions,
|
|
654
726
|
name
|
|
655
727
|
});
|
|
656
|
-
return /* @__PURE__ */
|
|
728
|
+
return /* @__PURE__ */ jsx11(Component, { header });
|
|
657
729
|
}
|
|
658
730
|
if (pathname.startsWith(prefix)) {
|
|
659
|
-
return /* @__PURE__ */
|
|
731
|
+
return /* @__PURE__ */ jsx11(
|
|
660
732
|
CrudFormProvider,
|
|
661
733
|
{
|
|
662
734
|
item: data?.item,
|
|
@@ -664,7 +736,7 @@ function crudPage({
|
|
|
664
736
|
name,
|
|
665
737
|
columns: formOptions.columns,
|
|
666
738
|
primaryKey,
|
|
667
|
-
children: formOptions.form ? /* @__PURE__ */
|
|
739
|
+
children: formOptions.form ? /* @__PURE__ */ jsx11(FormDelegate, { component: formOptions.form }) : /* @__PURE__ */ jsx11(CrudForm, { AdminHeader: header })
|
|
668
740
|
}
|
|
669
741
|
);
|
|
670
742
|
}
|
|
@@ -679,7 +751,7 @@ function FormDelegate({
|
|
|
679
751
|
component: Component
|
|
680
752
|
}) {
|
|
681
753
|
const form = useFormContext();
|
|
682
|
-
return /* @__PURE__ */
|
|
754
|
+
return /* @__PURE__ */ jsx11(Component, { form });
|
|
683
755
|
}
|
|
684
756
|
export {
|
|
685
757
|
crudPage
|