dn-react-router-toolkit 0.7.7 → 0.7.8
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 -5
- package/dist/api/create_api_handler.d.ts +5 -5
- package/dist/client/env_loader.d.mts +2 -2
- package/dist/client/env_loader.d.ts +2 -2
- package/dist/client/env_loader.js +2 -12
- package/dist/client/env_loader.mjs +2 -2
- package/dist/client/file_input.d.mts +3 -2
- package/dist/client/file_input.d.ts +3 -2
- package/dist/client/file_input.js +30 -37
- package/dist/client/file_input.mjs +33 -28
- package/dist/client/index.d.mts +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +38 -44
- package/dist/client/index.mjs +39 -33
- package/dist/client/store_text_editor.d.mts +2 -2
- package/dist/client/store_text_editor.d.ts +2 -2
- package/dist/client/store_text_editor.js +3 -12
- package/dist/client/store_text_editor.mjs +3 -2
- package/dist/crud/crud_form.d.mts +5 -4
- package/dist/crud/crud_form.d.ts +5 -4
- package/dist/crud/crud_form.js +74 -72
- package/dist/crud/crud_form.mjs +79 -62
- package/dist/crud/crud_form_provider.d.mts +9 -7
- package/dist/crud/crud_form_provider.d.ts +9 -7
- package/dist/crud/crud_form_provider.js +2 -12
- package/dist/crud/crud_form_provider.mjs +6 -3
- package/dist/crud/crud_page.d.mts +10 -6
- package/dist/crud/crud_page.d.ts +10 -6
- package/dist/crud/crud_page.js +272 -409
- package/dist/crud/crud_page.mjs +277 -399
- package/dist/crud/generate_pages.d.mts +10 -2
- package/dist/crud/generate_pages.d.ts +10 -2
- package/dist/crud/generate_pages.js +17 -14
- package/dist/crud/generate_pages.mjs +17 -4
- package/dist/crud/index.d.mts +2 -1
- package/dist/crud/index.d.ts +2 -1
- package/dist/crud/index.js +290 -404
- package/dist/crud/index.mjs +295 -404
- package/dist/form/create_form_component.d.mts +3 -2
- package/dist/form/create_form_component.d.ts +3 -2
- package/dist/form/create_form_component.js +3 -12
- package/dist/form/create_form_component.mjs +3 -2
- package/dist/form/form_components.d.mts +5 -4
- package/dist/form/form_components.d.ts +5 -4
- package/dist/form/form_components.js +3 -12
- package/dist/form/form_components.mjs +3 -2
- package/dist/form/index.d.mts +1 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.js +3 -12
- package/dist/form/index.mjs +3 -2
- package/dist/post/editor_toolbar.d.mts +4 -3
- package/dist/post/editor_toolbar.d.ts +4 -3
- package/dist/post/editor_toolbar.js +116 -273
- package/dist/post/editor_toolbar.mjs +123 -263
- package/dist/post/index.d.mts +1 -0
- package/dist/post/index.d.ts +1 -0
- package/dist/post/index.js +329 -411
- package/dist/post/index.mjs +337 -409
- package/dist/post/post_form_page.d.mts +5 -4
- package/dist/post/post_form_page.d.ts +5 -4
- package/dist/post/post_form_page.js +331 -413
- package/dist/post/post_form_page.mjs +337 -409
- package/dist/post/thumbnail_picker.d.mts +3 -2
- package/dist/post/thumbnail_picker.d.ts +3 -2
- package/dist/post/thumbnail_picker.js +14 -23
- package/dist/post/thumbnail_picker.mjs +14 -13
- package/dist/seo/index.d.mts +1 -1
- package/dist/seo/index.d.ts +1 -1
- package/dist/seo/index.js +2 -2
- package/dist/seo/index.mjs +2 -2
- package/dist/seo/seo.d.mts +2 -2
- package/dist/seo/seo.d.ts +2 -2
- package/dist/seo/seo.js +2 -2
- package/dist/seo/seo.mjs +2 -2
- package/dist/table/buttons.d.mts +2 -2
- package/dist/table/buttons.d.ts +2 -2
- package/dist/table/buttons.js +42 -57
- package/dist/table/buttons.mjs +42 -47
- package/dist/table/index.d.mts +1 -0
- package/dist/table/index.d.ts +1 -0
- package/dist/table/index.js +185 -338
- package/dist/table/index.mjs +185 -328
- package/dist/table/page.d.mts +5 -4
- package/dist/table/page.d.ts +5 -4
- package/dist/table/page.js +185 -338
- package/dist/table/page.mjs +185 -328
- package/dist/table/table.d.mts +5 -4
- package/dist/table/table.d.ts +5 -4
- package/dist/table/table.js +77 -237
- package/dist/table/table.mjs +77 -227
- package/package.json +7 -5
package/dist/table/index.mjs
CHANGED
|
@@ -55,7 +55,7 @@ var BaseTableRepository = class {
|
|
|
55
55
|
// src/table/buttons.tsx
|
|
56
56
|
import { cn } from "dn-react-toolkit/utils";
|
|
57
57
|
import { Link, useLocation, useSearchParams } from "react-router";
|
|
58
|
-
import
|
|
58
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
59
59
|
function TablePageButtons({
|
|
60
60
|
MAX_PAGES_TO_SHOW,
|
|
61
61
|
total,
|
|
@@ -68,57 +68,52 @@ function TablePageButtons({
|
|
|
68
68
|
const currentPage = Math.floor(offset / limit) + 1;
|
|
69
69
|
const startButton = (Math.ceil(currentPage / MAX_PAGES_TO_SHOW) - 1) * MAX_PAGES_TO_SHOW;
|
|
70
70
|
const endButton = Math.min(startButton + MAX_PAGES_TO_SHOW - 1, pages);
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
to: (() => {
|
|
75
|
-
searchParams.set(
|
|
76
|
-
"offset",
|
|
77
|
-
String((startButton - 1) * limit)
|
|
78
|
-
);
|
|
79
|
-
return `${pathname}?${searchParams.toString()}`;
|
|
80
|
-
})(),
|
|
81
|
-
className: "w-10 block text-center transition-colors hover:text-primary"
|
|
82
|
-
},
|
|
83
|
-
"\uC774\uC804"
|
|
84
|
-
), Array.from({
|
|
85
|
-
length: Math.min(
|
|
86
|
-
MAX_PAGES_TO_SHOW,
|
|
87
|
-
pages - startButton
|
|
88
|
-
)
|
|
89
|
-
}).map((_, index) => {
|
|
90
|
-
return /* @__PURE__ */ React.createElement(
|
|
71
|
+
return /* @__PURE__ */ jsx(Fragment, { children: pages > 1 && /* @__PURE__ */ jsxs("div", { className: "flex justify-center items-center my-8 gap-4 text-neutral-400", children: [
|
|
72
|
+
startButton > 1 && /* @__PURE__ */ jsx(
|
|
91
73
|
Link,
|
|
92
74
|
{
|
|
93
|
-
key: index,
|
|
94
75
|
to: (() => {
|
|
95
|
-
searchParams.set(
|
|
96
|
-
"offset",
|
|
97
|
-
String((startButton + index) * limit)
|
|
98
|
-
);
|
|
76
|
+
searchParams.set("offset", String((startButton - 1) * limit));
|
|
99
77
|
return `${pathname}?${searchParams.toString()}`;
|
|
100
78
|
})(),
|
|
101
|
-
className:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
79
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
80
|
+
children: "\uC774\uC804"
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
Array.from({
|
|
84
|
+
length: Math.min(MAX_PAGES_TO_SHOW, pages - startButton)
|
|
85
|
+
}).map((_, index) => {
|
|
86
|
+
return /* @__PURE__ */ jsx(
|
|
87
|
+
Link,
|
|
88
|
+
{
|
|
89
|
+
to: (() => {
|
|
90
|
+
searchParams.set(
|
|
91
|
+
"offset",
|
|
92
|
+
String((startButton + index) * limit)
|
|
93
|
+
);
|
|
94
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
95
|
+
})(),
|
|
96
|
+
className: cn(
|
|
97
|
+
"w-6 block text-center transition-colors",
|
|
98
|
+
currentPage === startButton + index + 1 ? "font-bold text-primary" : "hover:text-primary"
|
|
99
|
+
),
|
|
100
|
+
children: startButton + index + 1
|
|
101
|
+
},
|
|
102
|
+
index
|
|
103
|
+
);
|
|
104
|
+
}),
|
|
105
|
+
endButton < pages && /* @__PURE__ */ jsx(
|
|
106
|
+
Link,
|
|
107
|
+
{
|
|
108
|
+
to: (() => {
|
|
109
|
+
searchParams.set("offset", String((endButton + 1) * limit));
|
|
110
|
+
return `${pathname}?${searchParams.toString()}`;
|
|
111
|
+
})(),
|
|
112
|
+
className: "w-10 block text-center transition-colors hover:text-primary",
|
|
113
|
+
children: "\uB2E4\uC74C"
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] }) });
|
|
122
117
|
}
|
|
123
118
|
|
|
124
119
|
// src/table/item_loader.tsx
|
|
@@ -191,160 +186,13 @@ import {
|
|
|
191
186
|
useNavigate,
|
|
192
187
|
useSearchParams as useSearchParams3
|
|
193
188
|
} from "react-router";
|
|
194
|
-
|
|
195
|
-
// node_modules/react-icons/lib/iconBase.mjs
|
|
196
|
-
import React3 from "react";
|
|
197
|
-
|
|
198
|
-
// node_modules/react-icons/lib/iconContext.mjs
|
|
199
|
-
import React2 from "react";
|
|
200
|
-
var DefaultContext = {
|
|
201
|
-
color: void 0,
|
|
202
|
-
size: void 0,
|
|
203
|
-
className: void 0,
|
|
204
|
-
style: void 0,
|
|
205
|
-
attr: void 0
|
|
206
|
-
};
|
|
207
|
-
var IconContext = React2.createContext && /* @__PURE__ */ React2.createContext(DefaultContext);
|
|
208
|
-
|
|
209
|
-
// node_modules/react-icons/lib/iconBase.mjs
|
|
210
|
-
var _excluded = ["attr", "size", "title"];
|
|
211
|
-
function _objectWithoutProperties(source, excluded) {
|
|
212
|
-
if (source == null) return {};
|
|
213
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
214
|
-
var key, i;
|
|
215
|
-
if (Object.getOwnPropertySymbols) {
|
|
216
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
217
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
218
|
-
key = sourceSymbolKeys[i];
|
|
219
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
220
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
221
|
-
target[key] = source[key];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return target;
|
|
225
|
-
}
|
|
226
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
227
|
-
if (source == null) return {};
|
|
228
|
-
var target = {};
|
|
229
|
-
for (var key in source) {
|
|
230
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
231
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
232
|
-
target[key] = source[key];
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return target;
|
|
236
|
-
}
|
|
237
|
-
function _extends() {
|
|
238
|
-
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
239
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
240
|
-
var source = arguments[i];
|
|
241
|
-
for (var key in source) {
|
|
242
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
243
|
-
target[key] = source[key];
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return target;
|
|
248
|
-
};
|
|
249
|
-
return _extends.apply(this, arguments);
|
|
250
|
-
}
|
|
251
|
-
function ownKeys(e, r) {
|
|
252
|
-
var t = Object.keys(e);
|
|
253
|
-
if (Object.getOwnPropertySymbols) {
|
|
254
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
255
|
-
r && (o = o.filter(function(r2) {
|
|
256
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
257
|
-
})), t.push.apply(t, o);
|
|
258
|
-
}
|
|
259
|
-
return t;
|
|
260
|
-
}
|
|
261
|
-
function _objectSpread(e) {
|
|
262
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
263
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
264
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
265
|
-
_defineProperty(e, r2, t[r2]);
|
|
266
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
267
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
return e;
|
|
271
|
-
}
|
|
272
|
-
function _defineProperty(obj, key, value) {
|
|
273
|
-
key = _toPropertyKey(key);
|
|
274
|
-
if (key in obj) {
|
|
275
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
276
|
-
} else {
|
|
277
|
-
obj[key] = value;
|
|
278
|
-
}
|
|
279
|
-
return obj;
|
|
280
|
-
}
|
|
281
|
-
function _toPropertyKey(t) {
|
|
282
|
-
var i = _toPrimitive(t, "string");
|
|
283
|
-
return "symbol" == typeof i ? i : i + "";
|
|
284
|
-
}
|
|
285
|
-
function _toPrimitive(t, r) {
|
|
286
|
-
if ("object" != typeof t || !t) return t;
|
|
287
|
-
var e = t[Symbol.toPrimitive];
|
|
288
|
-
if (void 0 !== e) {
|
|
289
|
-
var i = e.call(t, r || "default");
|
|
290
|
-
if ("object" != typeof i) return i;
|
|
291
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
292
|
-
}
|
|
293
|
-
return ("string" === r ? String : Number)(t);
|
|
294
|
-
}
|
|
295
|
-
function Tree2Element(tree) {
|
|
296
|
-
return tree && tree.map((node, i) => /* @__PURE__ */ React3.createElement(node.tag, _objectSpread({
|
|
297
|
-
key: i
|
|
298
|
-
}, node.attr), Tree2Element(node.child)));
|
|
299
|
-
}
|
|
300
|
-
function GenIcon(data) {
|
|
301
|
-
return (props) => /* @__PURE__ */ React3.createElement(IconBase, _extends({
|
|
302
|
-
attr: _objectSpread({}, data.attr)
|
|
303
|
-
}, props), Tree2Element(data.child));
|
|
304
|
-
}
|
|
305
|
-
function IconBase(props) {
|
|
306
|
-
var elem = (conf) => {
|
|
307
|
-
var {
|
|
308
|
-
attr,
|
|
309
|
-
size,
|
|
310
|
-
title
|
|
311
|
-
} = props, svgProps = _objectWithoutProperties(props, _excluded);
|
|
312
|
-
var computedSize = size || conf.size || "1em";
|
|
313
|
-
var className;
|
|
314
|
-
if (conf.className) className = conf.className;
|
|
315
|
-
if (props.className) className = (className ? className + " " : "") + props.className;
|
|
316
|
-
return /* @__PURE__ */ React3.createElement("svg", _extends({
|
|
317
|
-
stroke: "currentColor",
|
|
318
|
-
fill: "currentColor",
|
|
319
|
-
strokeWidth: "0"
|
|
320
|
-
}, conf.attr, attr, svgProps, {
|
|
321
|
-
className,
|
|
322
|
-
style: _objectSpread(_objectSpread({
|
|
323
|
-
color: props.color || conf.color
|
|
324
|
-
}, conf.style), props.style),
|
|
325
|
-
height: computedSize,
|
|
326
|
-
width: computedSize,
|
|
327
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
328
|
-
}), title && /* @__PURE__ */ React3.createElement("title", null, title), props.children);
|
|
329
|
-
};
|
|
330
|
-
return IconContext !== void 0 ? /* @__PURE__ */ React3.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// node_modules/react-icons/go/index.mjs
|
|
334
|
-
function GoArrowDown(props) {
|
|
335
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M4.97 13.22a.75.75 0 0 1 1.06 0L11 18.19V3.75a.75.75 0 0 1 1.5 0v14.44l4.97-4.97a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734l-6.25 6.25a.75.75 0 0 1-1.06 0l-6.25-6.25a.75.75 0 0 1 0-1.06Z" }, "child": [] }] })(props);
|
|
336
|
-
}
|
|
337
|
-
function GoArrowUp(props) {
|
|
338
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M18.655 10.405a.75.75 0 0 1-1.06 0l-4.97-4.97v14.44a.75.75 0 0 1-1.5 0V5.435l-4.97 4.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l6.25-6.25a.75.75 0 0 1 1.06 0l6.25 6.25a.75.75 0 0 1 0 1.06Z" }, "child": [] }] })(props);
|
|
339
|
-
}
|
|
340
|
-
function GoSearch(props) {
|
|
341
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M10.25 2a8.25 8.25 0 0 1 6.34 13.53l5.69 5.69a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-5.69-5.69A8.25 8.25 0 1 1 10.25 2ZM3.5 10.25a6.75 6.75 0 1 0 13.5 0 6.75 6.75 0 0 0-13.5 0Z" }, "child": [] }] })(props);
|
|
342
|
-
}
|
|
189
|
+
import { GoSearch } from "react-icons/go";
|
|
343
190
|
|
|
344
191
|
// src/table/table.tsx
|
|
345
192
|
import { cn as cn2 } from "dn-react-toolkit/utils";
|
|
193
|
+
import { GoArrowDown, GoArrowUp } from "react-icons/go";
|
|
346
194
|
import { Link as Link2, useSearchParams as useSearchParams2 } from "react-router";
|
|
347
|
-
import
|
|
195
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
348
196
|
function Table({
|
|
349
197
|
className = "min-w-full whitespace-nowrap",
|
|
350
198
|
data,
|
|
@@ -359,95 +207,92 @@ function Table({
|
|
|
359
207
|
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
360
208
|
const sortedArray = [...data];
|
|
361
209
|
const [_, setSearchParams] = useSearchParams2();
|
|
362
|
-
return /* @__PURE__ */
|
|
210
|
+
return /* @__PURE__ */ jsxs2(
|
|
363
211
|
"table",
|
|
364
212
|
{
|
|
365
|
-
className: cn2(
|
|
366
|
-
|
|
367
|
-
"
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
213
|
+
className: cn2(className, "text-[15px] border-separate border-spacing-0"),
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsx2("tr", { children: keys.map((key) => {
|
|
216
|
+
const value = columns[key];
|
|
217
|
+
function getReactNode() {
|
|
218
|
+
if (value && typeof value === "object" && "label" in value) {
|
|
219
|
+
return value.label;
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
}
|
|
223
|
+
function Head() {
|
|
224
|
+
const reactNode = getReactNode();
|
|
225
|
+
if (typeof reactNode === "string") {
|
|
226
|
+
return /* @__PURE__ */ jsxs2(
|
|
227
|
+
"button",
|
|
228
|
+
{
|
|
229
|
+
className: cn2(
|
|
230
|
+
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
231
|
+
"px-4 h-14 flex items-center w-full"
|
|
232
|
+
),
|
|
233
|
+
onClick: () => {
|
|
234
|
+
let newDirection = "asc";
|
|
235
|
+
if (orderBy === key) {
|
|
236
|
+
newDirection = direction === "asc" ? "desc" : "asc";
|
|
237
|
+
}
|
|
238
|
+
setSearchParams({
|
|
239
|
+
orderBy: key,
|
|
240
|
+
direction: newDirection
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
children: [
|
|
244
|
+
reactNode,
|
|
245
|
+
orderBy === key && /* @__PURE__ */ jsx2("div", { className: "ml-0.5", children: direction === "asc" ? /* @__PURE__ */ jsx2(GoArrowUp, {}) : /* @__PURE__ */ jsx2(GoArrowDown, {}) })
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children: reactNode });
|
|
251
|
+
}
|
|
252
|
+
return /* @__PURE__ */ jsx2("th", { className: cn2("border-y font-normal"), children: /* @__PURE__ */ jsx2(Head, {}) }, key);
|
|
253
|
+
}) }) }),
|
|
254
|
+
/* @__PURE__ */ jsxs2("tbody", { children: [
|
|
255
|
+
sortedArray.length === 0 && /* @__PURE__ */ jsx2("tr", { children: /* @__PURE__ */ jsx2(
|
|
256
|
+
"td",
|
|
383
257
|
{
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
258
|
+
colSpan: keys.length,
|
|
259
|
+
className: "px-4 h-14 text-neutral-400 text-center",
|
|
260
|
+
children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
261
|
+
}
|
|
262
|
+
) }),
|
|
263
|
+
sortedArray.map((item, i) => /* @__PURE__ */ jsx2("tr", { className: "hover:bg-gray-50 transition-colors", children: keys.map((key, i2) => {
|
|
264
|
+
const value = item[key];
|
|
265
|
+
function Content() {
|
|
266
|
+
if (key in columns) {
|
|
267
|
+
const column = columns[key];
|
|
268
|
+
if (column && typeof column === "object" && "mapper" in column) {
|
|
269
|
+
const mapper = column.mapper;
|
|
270
|
+
if (mapper) {
|
|
271
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children: mapper(item) });
|
|
272
|
+
}
|
|
392
273
|
}
|
|
393
|
-
setSearchParams({
|
|
394
|
-
orderBy: key,
|
|
395
|
-
direction: newDirection
|
|
396
|
-
});
|
|
397
274
|
}
|
|
398
|
-
|
|
399
|
-
reactNode,
|
|
400
|
-
orderBy === key && /* @__PURE__ */ React4.createElement("div", { className: "ml-0.5" }, direction === "asc" ? /* @__PURE__ */ React4.createElement(GoArrowUp, null) : /* @__PURE__ */ React4.createElement(GoArrowDown, null))
|
|
401
|
-
);
|
|
402
|
-
}
|
|
403
|
-
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, reactNode);
|
|
404
|
-
}
|
|
405
|
-
return /* @__PURE__ */ React4.createElement(
|
|
406
|
-
"th",
|
|
407
|
-
{
|
|
408
|
-
key,
|
|
409
|
-
className: cn2("border-y font-normal")
|
|
410
|
-
},
|
|
411
|
-
/* @__PURE__ */ React4.createElement(Head, null)
|
|
412
|
-
);
|
|
413
|
-
}))),
|
|
414
|
-
/* @__PURE__ */ React4.createElement("tbody", null, sortedArray.length === 0 && /* @__PURE__ */ React4.createElement("tr", null, /* @__PURE__ */ React4.createElement(
|
|
415
|
-
"td",
|
|
416
|
-
{
|
|
417
|
-
colSpan: keys.length,
|
|
418
|
-
className: "px-4 h-14 text-neutral-400 text-center"
|
|
419
|
-
},
|
|
420
|
-
"\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
421
|
-
)), sortedArray.map((item, i) => /* @__PURE__ */ React4.createElement("tr", { key: i, className: "hover:bg-gray-50 transition-colors" }, keys.map((key, i2) => {
|
|
422
|
-
const value = item[key];
|
|
423
|
-
function Content() {
|
|
424
|
-
if (key in columns) {
|
|
425
|
-
const column = columns[key];
|
|
426
|
-
if (column && typeof column === "object" && "mapper" in column) {
|
|
427
|
-
const mapper = column.mapper;
|
|
428
|
-
if (mapper) {
|
|
429
|
-
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, mapper(item));
|
|
275
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children: String(value) });
|
|
430
276
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}))))
|
|
277
|
+
const linkedContent = getLink ? /* @__PURE__ */ jsx2(
|
|
278
|
+
Link2,
|
|
279
|
+
{
|
|
280
|
+
to: getLink(item),
|
|
281
|
+
className: "block content-center px-4 w-full h-full",
|
|
282
|
+
children: /* @__PURE__ */ jsx2(Content, {})
|
|
283
|
+
}
|
|
284
|
+
) : /* @__PURE__ */ jsx2(Content, {});
|
|
285
|
+
const cell = Mapper ? /* @__PURE__ */ jsx2(Mapper, { item, index: i2, children: linkedContent }) : linkedContent;
|
|
286
|
+
return /* @__PURE__ */ jsx2("td", { className: "px-0 h-14 border-b", children: cell }, key);
|
|
287
|
+
}) }, i))
|
|
288
|
+
] })
|
|
289
|
+
]
|
|
290
|
+
}
|
|
446
291
|
);
|
|
447
292
|
}
|
|
448
293
|
|
|
449
294
|
// src/table/page.tsx
|
|
450
|
-
import
|
|
295
|
+
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
451
296
|
function createTablePage({
|
|
452
297
|
name,
|
|
453
298
|
columns,
|
|
@@ -467,60 +312,72 @@ function createTablePage({
|
|
|
467
312
|
navigate(`${pathname}?${searchParams2.toString()}`);
|
|
468
313
|
};
|
|
469
314
|
const [searchParams] = useSearchParams3();
|
|
470
|
-
return /* @__PURE__ */
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
title: name,
|
|
474
|
-
actions: /* @__PURE__ */ React5.createElement(Link3, { to: `${pathname}/new`, className: "button-primary" }, name, " \uCD94\uAC00")
|
|
475
|
-
}
|
|
476
|
-
), /* @__PURE__ */ React5.createElement("div", { className: "max-w-7xl mx-auto w-full overflow-auto" }, searchKey && /* @__PURE__ */ React5.createElement(
|
|
477
|
-
"form",
|
|
478
|
-
{
|
|
479
|
-
className: "h-18 px-4 flex items-center border-t",
|
|
480
|
-
onSubmit: (e) => {
|
|
481
|
-
e.preventDefault();
|
|
482
|
-
const formData = new FormData(e.currentTarget);
|
|
483
|
-
const query = formData.get("query");
|
|
484
|
-
search(query);
|
|
485
|
-
}
|
|
486
|
-
},
|
|
487
|
-
/* @__PURE__ */ React5.createElement(
|
|
488
|
-
"button",
|
|
489
|
-
{
|
|
490
|
-
type: "submit",
|
|
491
|
-
className: "w-10 h-10 flex justify-center items-center"
|
|
492
|
-
},
|
|
493
|
-
/* @__PURE__ */ React5.createElement(GoSearch, { className: "text-xl mr-4" })
|
|
494
|
-
),
|
|
495
|
-
/* @__PURE__ */ React5.createElement(
|
|
496
|
-
"input",
|
|
315
|
+
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
316
|
+
/* @__PURE__ */ jsx3(
|
|
317
|
+
Header,
|
|
497
318
|
{
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
319
|
+
title: name,
|
|
320
|
+
actions: /* @__PURE__ */ jsxs3(Link3, { to: `${pathname}/new`, className: "button-primary", children: [
|
|
321
|
+
name,
|
|
322
|
+
" \uCD94\uAC00"
|
|
323
|
+
] })
|
|
502
324
|
}
|
|
503
|
-
)
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
325
|
+
),
|
|
326
|
+
/* @__PURE__ */ jsxs3("div", { className: "max-w-7xl mx-auto w-full overflow-auto", children: [
|
|
327
|
+
searchKey && /* @__PURE__ */ jsxs3(
|
|
328
|
+
"form",
|
|
329
|
+
{
|
|
330
|
+
className: "h-18 px-4 flex items-center border-t",
|
|
331
|
+
onSubmit: (e) => {
|
|
332
|
+
e.preventDefault();
|
|
333
|
+
const formData = new FormData(e.currentTarget);
|
|
334
|
+
const query = formData.get("query");
|
|
335
|
+
search(query);
|
|
336
|
+
},
|
|
337
|
+
children: [
|
|
338
|
+
/* @__PURE__ */ jsx3(
|
|
339
|
+
"button",
|
|
340
|
+
{
|
|
341
|
+
type: "submit",
|
|
342
|
+
className: "w-10 h-10 flex justify-center items-center",
|
|
343
|
+
children: /* @__PURE__ */ jsx3(GoSearch, { className: "text-xl mr-4" })
|
|
344
|
+
}
|
|
345
|
+
),
|
|
346
|
+
/* @__PURE__ */ jsx3(
|
|
347
|
+
"input",
|
|
348
|
+
{
|
|
349
|
+
className: "outline-none h-full flex-1",
|
|
350
|
+
placeholder: "\uC5EC\uAE30\uC5D0 \uAC80\uC0C9\uD558\uC138\uC694...",
|
|
351
|
+
name: "query",
|
|
352
|
+
defaultValue: searchParams.get("query") ?? ""
|
|
353
|
+
}
|
|
354
|
+
)
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
),
|
|
358
|
+
/* @__PURE__ */ jsx3(
|
|
359
|
+
Table,
|
|
360
|
+
{
|
|
361
|
+
data: items,
|
|
362
|
+
columns,
|
|
363
|
+
getLink: primaryKey ? (item) => `${pathname}/${item[primaryKey]}` : void 0,
|
|
364
|
+
limit,
|
|
365
|
+
offset,
|
|
366
|
+
orderBy,
|
|
367
|
+
direction
|
|
368
|
+
}
|
|
369
|
+
),
|
|
370
|
+
/* @__PURE__ */ jsx3(
|
|
371
|
+
TablePageButtons,
|
|
372
|
+
{
|
|
373
|
+
total,
|
|
374
|
+
limit,
|
|
375
|
+
offset,
|
|
376
|
+
MAX_PAGES_TO_SHOW: 10
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
] })
|
|
380
|
+
] });
|
|
524
381
|
};
|
|
525
382
|
}
|
|
526
383
|
export {
|
package/dist/table/page.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
1
2
|
import { TableColumnOptions } from './table.mjs';
|
|
2
|
-
import
|
|
3
|
+
import { FC, ReactNode } from 'react';
|
|
3
4
|
|
|
4
5
|
type TableProps<TModel> = {
|
|
5
6
|
items: TModel[];
|
|
@@ -16,10 +17,10 @@ type TablePageOptions<TModel> = {
|
|
|
16
17
|
primaryKey?: keyof TModel;
|
|
17
18
|
};
|
|
18
19
|
declare function createTablePage<TModel>({ name, columns, primaryKey, }: TablePageOptions<TModel>): ({ header: Header, }: {
|
|
19
|
-
header:
|
|
20
|
+
header: FC<{
|
|
20
21
|
title: string;
|
|
21
|
-
actions?:
|
|
22
|
+
actions?: ReactNode;
|
|
22
23
|
}>;
|
|
23
|
-
}) =>
|
|
24
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
24
25
|
|
|
25
26
|
export { type TablePageOptions, type TableProps, createTablePage };
|
package/dist/table/page.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
1
2
|
import { TableColumnOptions } from './table.js';
|
|
2
|
-
import
|
|
3
|
+
import { FC, ReactNode } from 'react';
|
|
3
4
|
|
|
4
5
|
type TableProps<TModel> = {
|
|
5
6
|
items: TModel[];
|
|
@@ -16,10 +17,10 @@ type TablePageOptions<TModel> = {
|
|
|
16
17
|
primaryKey?: keyof TModel;
|
|
17
18
|
};
|
|
18
19
|
declare function createTablePage<TModel>({ name, columns, primaryKey, }: TablePageOptions<TModel>): ({ header: Header, }: {
|
|
19
|
-
header:
|
|
20
|
+
header: FC<{
|
|
20
21
|
title: string;
|
|
21
|
-
actions?:
|
|
22
|
+
actions?: ReactNode;
|
|
22
23
|
}>;
|
|
23
|
-
}) =>
|
|
24
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
24
25
|
|
|
25
26
|
export { type TablePageOptions, type TableProps, createTablePage };
|