dn-react-router-toolkit 0.4.2 → 0.5.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 +28 -0
- package/dist/api/create_api_handler.d.ts +28 -0
- package/dist/api/create_api_handler.js +148 -0
- package/dist/api/create_api_handler.mjs +132 -0
- package/dist/api/create_handler.d.mts +1 -1
- package/dist/api/create_handler.d.ts +1 -1
- package/dist/api/create_handler.js +29 -26
- package/dist/api/create_handler.mjs +29 -26
- package/dist/api/index.js +29 -26
- package/dist/api/index.mjs +29 -26
- package/dist/api/item_api_handler.d.mts +18 -0
- package/dist/api/item_api_handler.d.ts +18 -0
- package/dist/api/item_api_handler.js +55 -0
- package/dist/api/item_api_handler.mjs +30 -0
- package/dist/auth/index.d.mts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +62 -16
- package/dist/auth/index.mjs +60 -15
- package/dist/auth/with_auth.d.mts +8 -3
- package/dist/auth/with_auth.d.ts +8 -3
- package/dist/auth/with_auth.js +62 -16
- package/dist/auth/with_auth.mjs +60 -15
- package/dist/crud/crud_form.d.mts +13 -0
- package/dist/crud/crud_form.d.ts +13 -0
- package/dist/crud/crud_form.js +88 -0
- package/dist/crud/crud_form.mjs +55 -0
- package/dist/crud/crud_form_provider.d.mts +34 -0
- package/dist/crud/crud_form_provider.d.ts +34 -0
- package/dist/crud/crud_form_provider.js +160 -0
- package/dist/crud/crud_form_provider.mjs +124 -0
- package/dist/crud/crud_loader.d.mts +21 -0
- package/dist/crud/crud_loader.d.ts +21 -0
- package/dist/crud/crud_loader.js +288 -0
- package/dist/crud/crud_loader.mjs +273 -0
- package/dist/crud/crud_page.d.mts +25 -0
- package/dist/crud/crud_page.d.ts +25 -0
- package/dist/crud/crud_page.js +645 -0
- package/dist/crud/crud_page.mjs +616 -0
- package/dist/crud/generate_handlers.d.mts +15 -0
- package/dist/crud/generate_handlers.d.ts +15 -0
- package/dist/crud/generate_handlers.js +39 -0
- package/dist/crud/generate_handlers.mjs +14 -0
- package/dist/crud/generate_pages.d.mts +11 -0
- package/dist/crud/generate_pages.d.ts +11 -0
- package/dist/crud/generate_pages.js +52 -0
- package/dist/crud/generate_pages.mjs +17 -0
- package/dist/crud/generate_routes.d.mts +5 -0
- package/dist/crud/generate_routes.d.ts +5 -0
- package/dist/crud/generate_routes.js +62 -0
- package/dist/crud/generate_routes.mjs +27 -0
- package/dist/crud/index.d.mts +21 -0
- package/dist/crud/index.d.ts +21 -0
- package/dist/crud/index.js +970 -0
- package/dist/crud/index.mjs +945 -0
- package/dist/db/index.d.mts +4 -0
- package/dist/db/index.d.ts +4 -0
- package/dist/db/index.js +46 -0
- package/dist/db/index.mjs +8 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/table/buttons.d.mts +10 -0
- package/dist/table/buttons.d.ts +10 -0
- package/dist/table/buttons.js +102 -0
- package/dist/table/buttons.mjs +71 -0
- package/dist/table/index.d.mts +9 -0
- package/dist/table/index.d.ts +9 -0
- package/dist/table/index.js +570 -0
- package/dist/table/index.mjs +543 -0
- package/dist/table/item_loader.d.mts +12 -0
- package/dist/table/item_loader.d.ts +12 -0
- package/dist/table/item_loader.js +51 -0
- package/dist/table/item_loader.mjs +26 -0
- package/dist/table/loader.d.mts +28 -0
- package/dist/table/loader.d.ts +28 -0
- package/dist/table/loader.js +70 -0
- package/dist/table/loader.mjs +48 -0
- package/dist/table/page.d.mts +27 -0
- package/dist/table/page.d.ts +27 -0
- package/dist/table/page.js +444 -0
- package/dist/table/page.mjs +415 -0
- package/dist/table/repository.d.mts +38 -0
- package/dist/table/repository.d.ts +38 -0
- package/dist/table/repository.js +76 -0
- package/dist/table/repository.mjs +56 -0
- package/dist/table/table.d.mts +27 -0
- package/dist/table/table.d.ts +27 -0
- package/dist/table/table.js +290 -0
- package/dist/table/table.mjs +255 -0
- package/package.json +78 -59
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/table/table.tsx
|
|
31
|
+
var table_exports = {};
|
|
32
|
+
__export(table_exports, {
|
|
33
|
+
Table: () => Table
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(table_exports);
|
|
36
|
+
var import_utils = require("dn-react-toolkit/utils");
|
|
37
|
+
|
|
38
|
+
// node_modules/react-icons/lib/iconBase.mjs
|
|
39
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
40
|
+
|
|
41
|
+
// node_modules/react-icons/lib/iconContext.mjs
|
|
42
|
+
var import_react = __toESM(require("react"), 1);
|
|
43
|
+
var DefaultContext = {
|
|
44
|
+
color: void 0,
|
|
45
|
+
size: void 0,
|
|
46
|
+
className: void 0,
|
|
47
|
+
style: void 0,
|
|
48
|
+
attr: void 0
|
|
49
|
+
};
|
|
50
|
+
var IconContext = import_react.default.createContext && /* @__PURE__ */ import_react.default.createContext(DefaultContext);
|
|
51
|
+
|
|
52
|
+
// node_modules/react-icons/lib/iconBase.mjs
|
|
53
|
+
var _excluded = ["attr", "size", "title"];
|
|
54
|
+
function _objectWithoutProperties(source, excluded) {
|
|
55
|
+
if (source == null) return {};
|
|
56
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
57
|
+
var key, i;
|
|
58
|
+
if (Object.getOwnPropertySymbols) {
|
|
59
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
60
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
61
|
+
key = sourceSymbolKeys[i];
|
|
62
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
63
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
64
|
+
target[key] = source[key];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
70
|
+
if (source == null) return {};
|
|
71
|
+
var target = {};
|
|
72
|
+
for (var key in source) {
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
74
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
75
|
+
target[key] = source[key];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
function _extends() {
|
|
81
|
+
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
82
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
83
|
+
var source = arguments[i];
|
|
84
|
+
for (var key in source) {
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
86
|
+
target[key] = source[key];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return target;
|
|
91
|
+
};
|
|
92
|
+
return _extends.apply(this, arguments);
|
|
93
|
+
}
|
|
94
|
+
function ownKeys(e, r) {
|
|
95
|
+
var t = Object.keys(e);
|
|
96
|
+
if (Object.getOwnPropertySymbols) {
|
|
97
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
98
|
+
r && (o = o.filter(function(r2) {
|
|
99
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
100
|
+
})), t.push.apply(t, o);
|
|
101
|
+
}
|
|
102
|
+
return t;
|
|
103
|
+
}
|
|
104
|
+
function _objectSpread(e) {
|
|
105
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
106
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
107
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
108
|
+
_defineProperty(e, r2, t[r2]);
|
|
109
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
110
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return e;
|
|
114
|
+
}
|
|
115
|
+
function _defineProperty(obj, key, value) {
|
|
116
|
+
key = _toPropertyKey(key);
|
|
117
|
+
if (key in obj) {
|
|
118
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
119
|
+
} else {
|
|
120
|
+
obj[key] = value;
|
|
121
|
+
}
|
|
122
|
+
return obj;
|
|
123
|
+
}
|
|
124
|
+
function _toPropertyKey(t) {
|
|
125
|
+
var i = _toPrimitive(t, "string");
|
|
126
|
+
return "symbol" == typeof i ? i : i + "";
|
|
127
|
+
}
|
|
128
|
+
function _toPrimitive(t, r) {
|
|
129
|
+
if ("object" != typeof t || !t) return t;
|
|
130
|
+
var e = t[Symbol.toPrimitive];
|
|
131
|
+
if (void 0 !== e) {
|
|
132
|
+
var i = e.call(t, r || "default");
|
|
133
|
+
if ("object" != typeof i) return i;
|
|
134
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
135
|
+
}
|
|
136
|
+
return ("string" === r ? String : Number)(t);
|
|
137
|
+
}
|
|
138
|
+
function Tree2Element(tree) {
|
|
139
|
+
return tree && tree.map((node, i) => /* @__PURE__ */ import_react2.default.createElement(node.tag, _objectSpread({
|
|
140
|
+
key: i
|
|
141
|
+
}, node.attr), Tree2Element(node.child)));
|
|
142
|
+
}
|
|
143
|
+
function GenIcon(data) {
|
|
144
|
+
return (props) => /* @__PURE__ */ import_react2.default.createElement(IconBase, _extends({
|
|
145
|
+
attr: _objectSpread({}, data.attr)
|
|
146
|
+
}, props), Tree2Element(data.child));
|
|
147
|
+
}
|
|
148
|
+
function IconBase(props) {
|
|
149
|
+
var elem = (conf) => {
|
|
150
|
+
var {
|
|
151
|
+
attr,
|
|
152
|
+
size,
|
|
153
|
+
title
|
|
154
|
+
} = props, svgProps = _objectWithoutProperties(props, _excluded);
|
|
155
|
+
var computedSize = size || conf.size || "1em";
|
|
156
|
+
var className;
|
|
157
|
+
if (conf.className) className = conf.className;
|
|
158
|
+
if (props.className) className = (className ? className + " " : "") + props.className;
|
|
159
|
+
return /* @__PURE__ */ import_react2.default.createElement("svg", _extends({
|
|
160
|
+
stroke: "currentColor",
|
|
161
|
+
fill: "currentColor",
|
|
162
|
+
strokeWidth: "0"
|
|
163
|
+
}, conf.attr, attr, svgProps, {
|
|
164
|
+
className,
|
|
165
|
+
style: _objectSpread(_objectSpread({
|
|
166
|
+
color: props.color || conf.color
|
|
167
|
+
}, conf.style), props.style),
|
|
168
|
+
height: computedSize,
|
|
169
|
+
width: computedSize,
|
|
170
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
171
|
+
}), title && /* @__PURE__ */ import_react2.default.createElement("title", null, title), props.children);
|
|
172
|
+
};
|
|
173
|
+
return IconContext !== void 0 ? /* @__PURE__ */ import_react2.default.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// node_modules/react-icons/go/index.mjs
|
|
177
|
+
function GoArrowDown(props) {
|
|
178
|
+
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);
|
|
179
|
+
}
|
|
180
|
+
function GoArrowUp(props) {
|
|
181
|
+
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);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/table/table.tsx
|
|
185
|
+
var import_react_router = require("react-router");
|
|
186
|
+
var import_react3 = __toESM(require("react"));
|
|
187
|
+
function Table({
|
|
188
|
+
className = "min-w-full whitespace-nowrap",
|
|
189
|
+
data,
|
|
190
|
+
columns,
|
|
191
|
+
mapper: Mapper,
|
|
192
|
+
getLink,
|
|
193
|
+
limit,
|
|
194
|
+
offset,
|
|
195
|
+
orderBy,
|
|
196
|
+
direction
|
|
197
|
+
}) {
|
|
198
|
+
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
199
|
+
const sortedArray = [...data];
|
|
200
|
+
const [_, setSearchParams] = (0, import_react_router.useSearchParams)();
|
|
201
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
202
|
+
"table",
|
|
203
|
+
{
|
|
204
|
+
className: (0, import_utils.cn)(
|
|
205
|
+
className,
|
|
206
|
+
"text-[15px] border-separate border-spacing-0"
|
|
207
|
+
)
|
|
208
|
+
},
|
|
209
|
+
/* @__PURE__ */ import_react3.default.createElement("thead", null, /* @__PURE__ */ import_react3.default.createElement("tr", null, keys.map((key) => {
|
|
210
|
+
const value = columns[key];
|
|
211
|
+
function getReactNode() {
|
|
212
|
+
if (value && typeof value === "object" && "label" in value) {
|
|
213
|
+
return value.label;
|
|
214
|
+
}
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
function Head() {
|
|
218
|
+
const reactNode = getReactNode();
|
|
219
|
+
if (typeof reactNode === "string") {
|
|
220
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
221
|
+
"button",
|
|
222
|
+
{
|
|
223
|
+
className: (0, import_utils.cn)(
|
|
224
|
+
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
225
|
+
"px-4 h-14 flex items-center w-full"
|
|
226
|
+
),
|
|
227
|
+
onClick: () => {
|
|
228
|
+
let newDirection = "asc";
|
|
229
|
+
if (orderBy === key) {
|
|
230
|
+
newDirection = direction === "asc" ? "desc" : "asc";
|
|
231
|
+
}
|
|
232
|
+
setSearchParams({
|
|
233
|
+
orderBy: key,
|
|
234
|
+
direction: newDirection
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
reactNode,
|
|
239
|
+
orderBy === key && /* @__PURE__ */ import_react3.default.createElement("div", { className: "ml-0.5" }, direction === "asc" ? /* @__PURE__ */ import_react3.default.createElement(GoArrowUp, null) : /* @__PURE__ */ import_react3.default.createElement(GoArrowDown, null))
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, reactNode);
|
|
243
|
+
}
|
|
244
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
245
|
+
"th",
|
|
246
|
+
{
|
|
247
|
+
key,
|
|
248
|
+
className: (0, import_utils.cn)("border-y font-normal")
|
|
249
|
+
},
|
|
250
|
+
/* @__PURE__ */ import_react3.default.createElement(Head, null)
|
|
251
|
+
);
|
|
252
|
+
}))),
|
|
253
|
+
/* @__PURE__ */ import_react3.default.createElement("tbody", null, sortedArray.length === 0 && /* @__PURE__ */ import_react3.default.createElement("tr", null, /* @__PURE__ */ import_react3.default.createElement(
|
|
254
|
+
"td",
|
|
255
|
+
{
|
|
256
|
+
colSpan: keys.length,
|
|
257
|
+
className: "px-4 h-14 text-neutral-400 text-center"
|
|
258
|
+
},
|
|
259
|
+
"\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
260
|
+
)), sortedArray.map((item, i) => /* @__PURE__ */ import_react3.default.createElement("tr", { key: i, className: "hover:bg-gray-50 transition-colors" }, keys.map((key, i2) => {
|
|
261
|
+
const value = item[key];
|
|
262
|
+
function Content() {
|
|
263
|
+
if (key in columns) {
|
|
264
|
+
const column = columns[key];
|
|
265
|
+
if (column && typeof column === "object" && "mapper" in column) {
|
|
266
|
+
const mapper = column.mapper;
|
|
267
|
+
if (mapper) {
|
|
268
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, mapper(item));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, String(value));
|
|
273
|
+
}
|
|
274
|
+
const linkedContent = getLink ? /* @__PURE__ */ import_react3.default.createElement(
|
|
275
|
+
import_react_router.Link,
|
|
276
|
+
{
|
|
277
|
+
to: getLink(item),
|
|
278
|
+
className: "block content-center px-4 w-full h-full"
|
|
279
|
+
},
|
|
280
|
+
/* @__PURE__ */ import_react3.default.createElement(Content, null)
|
|
281
|
+
) : /* @__PURE__ */ import_react3.default.createElement(Content, null);
|
|
282
|
+
const cell = Mapper ? /* @__PURE__ */ import_react3.default.createElement(Mapper, { item, index: i2 }, linkedContent) : linkedContent;
|
|
283
|
+
return /* @__PURE__ */ import_react3.default.createElement("td", { key, className: "px-0 h-14 border-b" }, cell);
|
|
284
|
+
}))))
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
288
|
+
0 && (module.exports = {
|
|
289
|
+
Table
|
|
290
|
+
});
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// src/table/table.tsx
|
|
2
|
+
import { cn } from "dn-react-toolkit/utils";
|
|
3
|
+
|
|
4
|
+
// node_modules/react-icons/lib/iconBase.mjs
|
|
5
|
+
import React2 from "react";
|
|
6
|
+
|
|
7
|
+
// node_modules/react-icons/lib/iconContext.mjs
|
|
8
|
+
import React from "react";
|
|
9
|
+
var DefaultContext = {
|
|
10
|
+
color: void 0,
|
|
11
|
+
size: void 0,
|
|
12
|
+
className: void 0,
|
|
13
|
+
style: void 0,
|
|
14
|
+
attr: void 0
|
|
15
|
+
};
|
|
16
|
+
var IconContext = React.createContext && /* @__PURE__ */ React.createContext(DefaultContext);
|
|
17
|
+
|
|
18
|
+
// node_modules/react-icons/lib/iconBase.mjs
|
|
19
|
+
var _excluded = ["attr", "size", "title"];
|
|
20
|
+
function _objectWithoutProperties(source, excluded) {
|
|
21
|
+
if (source == null) return {};
|
|
22
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
23
|
+
var key, i;
|
|
24
|
+
if (Object.getOwnPropertySymbols) {
|
|
25
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
26
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
27
|
+
key = sourceSymbolKeys[i];
|
|
28
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
29
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
30
|
+
target[key] = source[key];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
}
|
|
35
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
36
|
+
if (source == null) return {};
|
|
37
|
+
var target = {};
|
|
38
|
+
for (var key in source) {
|
|
39
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
40
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
41
|
+
target[key] = source[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
function _extends() {
|
|
47
|
+
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
48
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
49
|
+
var source = arguments[i];
|
|
50
|
+
for (var key in source) {
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
52
|
+
target[key] = source[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
};
|
|
58
|
+
return _extends.apply(this, arguments);
|
|
59
|
+
}
|
|
60
|
+
function ownKeys(e, r) {
|
|
61
|
+
var t = Object.keys(e);
|
|
62
|
+
if (Object.getOwnPropertySymbols) {
|
|
63
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
64
|
+
r && (o = o.filter(function(r2) {
|
|
65
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
66
|
+
})), t.push.apply(t, o);
|
|
67
|
+
}
|
|
68
|
+
return t;
|
|
69
|
+
}
|
|
70
|
+
function _objectSpread(e) {
|
|
71
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
72
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
73
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
74
|
+
_defineProperty(e, r2, t[r2]);
|
|
75
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
76
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return e;
|
|
80
|
+
}
|
|
81
|
+
function _defineProperty(obj, key, value) {
|
|
82
|
+
key = _toPropertyKey(key);
|
|
83
|
+
if (key in obj) {
|
|
84
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
85
|
+
} else {
|
|
86
|
+
obj[key] = value;
|
|
87
|
+
}
|
|
88
|
+
return obj;
|
|
89
|
+
}
|
|
90
|
+
function _toPropertyKey(t) {
|
|
91
|
+
var i = _toPrimitive(t, "string");
|
|
92
|
+
return "symbol" == typeof i ? i : i + "";
|
|
93
|
+
}
|
|
94
|
+
function _toPrimitive(t, r) {
|
|
95
|
+
if ("object" != typeof t || !t) return t;
|
|
96
|
+
var e = t[Symbol.toPrimitive];
|
|
97
|
+
if (void 0 !== e) {
|
|
98
|
+
var i = e.call(t, r || "default");
|
|
99
|
+
if ("object" != typeof i) return i;
|
|
100
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
101
|
+
}
|
|
102
|
+
return ("string" === r ? String : Number)(t);
|
|
103
|
+
}
|
|
104
|
+
function Tree2Element(tree) {
|
|
105
|
+
return tree && tree.map((node, i) => /* @__PURE__ */ React2.createElement(node.tag, _objectSpread({
|
|
106
|
+
key: i
|
|
107
|
+
}, node.attr), Tree2Element(node.child)));
|
|
108
|
+
}
|
|
109
|
+
function GenIcon(data) {
|
|
110
|
+
return (props) => /* @__PURE__ */ React2.createElement(IconBase, _extends({
|
|
111
|
+
attr: _objectSpread({}, data.attr)
|
|
112
|
+
}, props), Tree2Element(data.child));
|
|
113
|
+
}
|
|
114
|
+
function IconBase(props) {
|
|
115
|
+
var elem = (conf) => {
|
|
116
|
+
var {
|
|
117
|
+
attr,
|
|
118
|
+
size,
|
|
119
|
+
title
|
|
120
|
+
} = props, svgProps = _objectWithoutProperties(props, _excluded);
|
|
121
|
+
var computedSize = size || conf.size || "1em";
|
|
122
|
+
var className;
|
|
123
|
+
if (conf.className) className = conf.className;
|
|
124
|
+
if (props.className) className = (className ? className + " " : "") + props.className;
|
|
125
|
+
return /* @__PURE__ */ React2.createElement("svg", _extends({
|
|
126
|
+
stroke: "currentColor",
|
|
127
|
+
fill: "currentColor",
|
|
128
|
+
strokeWidth: "0"
|
|
129
|
+
}, conf.attr, attr, svgProps, {
|
|
130
|
+
className,
|
|
131
|
+
style: _objectSpread(_objectSpread({
|
|
132
|
+
color: props.color || conf.color
|
|
133
|
+
}, conf.style), props.style),
|
|
134
|
+
height: computedSize,
|
|
135
|
+
width: computedSize,
|
|
136
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
137
|
+
}), title && /* @__PURE__ */ React2.createElement("title", null, title), props.children);
|
|
138
|
+
};
|
|
139
|
+
return IconContext !== void 0 ? /* @__PURE__ */ React2.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// node_modules/react-icons/go/index.mjs
|
|
143
|
+
function GoArrowDown(props) {
|
|
144
|
+
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);
|
|
145
|
+
}
|
|
146
|
+
function GoArrowUp(props) {
|
|
147
|
+
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);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/table/table.tsx
|
|
151
|
+
import { Link, useSearchParams } from "react-router";
|
|
152
|
+
import React3 from "react";
|
|
153
|
+
function Table({
|
|
154
|
+
className = "min-w-full whitespace-nowrap",
|
|
155
|
+
data,
|
|
156
|
+
columns,
|
|
157
|
+
mapper: Mapper,
|
|
158
|
+
getLink,
|
|
159
|
+
limit,
|
|
160
|
+
offset,
|
|
161
|
+
orderBy,
|
|
162
|
+
direction
|
|
163
|
+
}) {
|
|
164
|
+
const keys = Object.entries(columns).filter((entry) => entry[1]).map(([key]) => key);
|
|
165
|
+
const sortedArray = [...data];
|
|
166
|
+
const [_, setSearchParams] = useSearchParams();
|
|
167
|
+
return /* @__PURE__ */ React3.createElement(
|
|
168
|
+
"table",
|
|
169
|
+
{
|
|
170
|
+
className: cn(
|
|
171
|
+
className,
|
|
172
|
+
"text-[15px] border-separate border-spacing-0"
|
|
173
|
+
)
|
|
174
|
+
},
|
|
175
|
+
/* @__PURE__ */ React3.createElement("thead", null, /* @__PURE__ */ React3.createElement("tr", null, keys.map((key) => {
|
|
176
|
+
const value = columns[key];
|
|
177
|
+
function getReactNode() {
|
|
178
|
+
if (value && typeof value === "object" && "label" in value) {
|
|
179
|
+
return value.label;
|
|
180
|
+
}
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
function Head() {
|
|
184
|
+
const reactNode = getReactNode();
|
|
185
|
+
if (typeof reactNode === "string") {
|
|
186
|
+
return /* @__PURE__ */ React3.createElement(
|
|
187
|
+
"button",
|
|
188
|
+
{
|
|
189
|
+
className: cn(
|
|
190
|
+
orderBy === key ? "text-neutral-900 font-medium" : "text-neutral-500",
|
|
191
|
+
"px-4 h-14 flex items-center w-full"
|
|
192
|
+
),
|
|
193
|
+
onClick: () => {
|
|
194
|
+
let newDirection = "asc";
|
|
195
|
+
if (orderBy === key) {
|
|
196
|
+
newDirection = direction === "asc" ? "desc" : "asc";
|
|
197
|
+
}
|
|
198
|
+
setSearchParams({
|
|
199
|
+
orderBy: key,
|
|
200
|
+
direction: newDirection
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
reactNode,
|
|
205
|
+
orderBy === key && /* @__PURE__ */ React3.createElement("div", { className: "ml-0.5" }, direction === "asc" ? /* @__PURE__ */ React3.createElement(GoArrowUp, null) : /* @__PURE__ */ React3.createElement(GoArrowDown, null))
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, reactNode);
|
|
209
|
+
}
|
|
210
|
+
return /* @__PURE__ */ React3.createElement(
|
|
211
|
+
"th",
|
|
212
|
+
{
|
|
213
|
+
key,
|
|
214
|
+
className: cn("border-y font-normal")
|
|
215
|
+
},
|
|
216
|
+
/* @__PURE__ */ React3.createElement(Head, null)
|
|
217
|
+
);
|
|
218
|
+
}))),
|
|
219
|
+
/* @__PURE__ */ React3.createElement("tbody", null, sortedArray.length === 0 && /* @__PURE__ */ React3.createElement("tr", null, /* @__PURE__ */ React3.createElement(
|
|
220
|
+
"td",
|
|
221
|
+
{
|
|
222
|
+
colSpan: keys.length,
|
|
223
|
+
className: "px-4 h-14 text-neutral-400 text-center"
|
|
224
|
+
},
|
|
225
|
+
"\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
|
|
226
|
+
)), sortedArray.map((item, i) => /* @__PURE__ */ React3.createElement("tr", { key: i, className: "hover:bg-gray-50 transition-colors" }, keys.map((key, i2) => {
|
|
227
|
+
const value = item[key];
|
|
228
|
+
function Content() {
|
|
229
|
+
if (key in columns) {
|
|
230
|
+
const column = columns[key];
|
|
231
|
+
if (column && typeof column === "object" && "mapper" in column) {
|
|
232
|
+
const mapper = column.mapper;
|
|
233
|
+
if (mapper) {
|
|
234
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, mapper(item));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, String(value));
|
|
239
|
+
}
|
|
240
|
+
const linkedContent = getLink ? /* @__PURE__ */ React3.createElement(
|
|
241
|
+
Link,
|
|
242
|
+
{
|
|
243
|
+
to: getLink(item),
|
|
244
|
+
className: "block content-center px-4 w-full h-full"
|
|
245
|
+
},
|
|
246
|
+
/* @__PURE__ */ React3.createElement(Content, null)
|
|
247
|
+
) : /* @__PURE__ */ React3.createElement(Content, null);
|
|
248
|
+
const cell = Mapper ? /* @__PURE__ */ React3.createElement(Mapper, { item, index: i2 }, linkedContent) : linkedContent;
|
|
249
|
+
return /* @__PURE__ */ React3.createElement("td", { key, className: "px-0 h-14 border-b" }, cell);
|
|
250
|
+
}))))
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
export {
|
|
254
|
+
Table
|
|
255
|
+
};
|
package/package.json
CHANGED
|
@@ -1,65 +1,84 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"name": "dn-react-router-toolkit",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"types": "./dist/index.d.ts",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./auth": {
|
|
14
|
+
"types": "./dist/auth/index.d.ts",
|
|
15
|
+
"import": "./dist/auth/index.mjs",
|
|
16
|
+
"require": "./dist/auth/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./api": {
|
|
19
|
+
"types": "./dist/api/index.d.ts",
|
|
20
|
+
"import": "./dist/api/index.mjs",
|
|
21
|
+
"require": "./dist/api/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./client": {
|
|
24
|
+
"types": "./dist/client/index.d.ts",
|
|
25
|
+
"import": "./dist/client/index.mjs",
|
|
26
|
+
"require": "./dist/client/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./seo": {
|
|
29
|
+
"types": "./dist/seo/index.d.ts",
|
|
30
|
+
"import": "./dist/seo/index.mjs",
|
|
31
|
+
"require": "./dist/seo/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./db": {
|
|
34
|
+
"types": "./dist/db/index.d.ts",
|
|
35
|
+
"import": "./dist/db/index.mjs",
|
|
36
|
+
"require": "./dist/db/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./table": {
|
|
39
|
+
"types": "./dist/table/index.d.ts",
|
|
40
|
+
"import": "./dist/table/index.mjs",
|
|
41
|
+
"require": "./dist/table/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./crud": {
|
|
44
|
+
"types": "./dist/crud/index.d.ts",
|
|
45
|
+
"import": "./dist/crud/index.mjs",
|
|
46
|
+
"require": "./dist/crud/index.js"
|
|
47
|
+
}
|
|
12
48
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"require": "./dist/auth/index.js"
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsup",
|
|
51
|
+
"dev": "tsup --watch"
|
|
17
52
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"require": "./dist/api/index.js"
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/dndnsoft/dn-react-router-toolkit.git"
|
|
22
56
|
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
57
|
+
"author": "",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/dndnsoft/dn-react-router-toolkit/issues"
|
|
27
61
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
62
|
+
"homepage": "https://github.com/dndnsoft/dn-react-router-toolkit#readme",
|
|
63
|
+
"description": "",
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/node": "^24.10.1",
|
|
66
|
+
"@types/react": "^19",
|
|
67
|
+
"@types/react-dom": "^19",
|
|
68
|
+
"schema-dts": "^1.1.5",
|
|
69
|
+
"tsup": "^8.5.1",
|
|
70
|
+
"typescript": "^5.7.3"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@react-router/dev": "^7.11.0",
|
|
74
|
+
"dn-react-toolkit": "0.2.29",
|
|
75
|
+
"pg": "^8.16.3",
|
|
76
|
+
"uuid": "^13.0.0"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"drizzle-orm": "0.45.1",
|
|
80
|
+
"react": "^19",
|
|
81
|
+
"react-dom": "^19",
|
|
82
|
+
"react-router": "^7"
|
|
32
83
|
}
|
|
33
|
-
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "tsup",
|
|
36
|
-
"dev": "tsup --watch"
|
|
37
|
-
},
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/dndnsoft/dn-react-router-toolkit.git"
|
|
41
|
-
},
|
|
42
|
-
"author": "",
|
|
43
|
-
"license": "MIT",
|
|
44
|
-
"bugs": {
|
|
45
|
-
"url": "https://github.com/dndnsoft/dn-react-router-toolkit/issues"
|
|
46
|
-
},
|
|
47
|
-
"homepage": "https://github.com/dndnsoft/dn-react-router-toolkit#readme",
|
|
48
|
-
"description": "",
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@types/node": "^24.10.1",
|
|
51
|
-
"@types/react": "^19",
|
|
52
|
-
"@types/react-dom": "^19",
|
|
53
|
-
"schema-dts": "^1.1.5",
|
|
54
|
-
"tsup": "^8.5.1",
|
|
55
|
-
"typescript": "^5.7.3"
|
|
56
|
-
},
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"dn-react-toolkit": "0.2.7"
|
|
59
|
-
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"react": "^19",
|
|
62
|
-
"react-dom": "^19",
|
|
63
|
-
"react-router": "^7"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
84
|
+
}
|