next-recomponents 1.3.4 → 1.3.6
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/index.d.mts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +292 -274
- package/dist/index.mjs +284 -266
- package/package.json +1 -1
- package/src/table/filter.menu.tsx +5 -8
- package/src/table/filters.tsx +16 -0
- package/src/table/h.tsx +74 -31
- package/src/table/index.tsx +9 -40
- package/src/table/td.tsx +48 -57
package/dist/index.mjs
CHANGED
|
@@ -11110,9 +11110,6 @@ var regularExpresions = {
|
|
|
11110
11110
|
};
|
|
11111
11111
|
var regular_expresions_default = regularExpresions;
|
|
11112
11112
|
|
|
11113
|
-
// src/table/index.tsx
|
|
11114
|
-
import { useState as useState7 } from "react";
|
|
11115
|
-
|
|
11116
11113
|
// src/table/h.tsx
|
|
11117
11114
|
import React4, { useEffect as useEffect7, useMemo as useMemo7, useRef as useRef4, useState as useState6 } from "react";
|
|
11118
11115
|
|
|
@@ -11126,7 +11123,6 @@ function TD(_a) {
|
|
|
11126
11123
|
index,
|
|
11127
11124
|
color: color2,
|
|
11128
11125
|
symbols,
|
|
11129
|
-
handlers,
|
|
11130
11126
|
mapedData,
|
|
11131
11127
|
setMapedData
|
|
11132
11128
|
} = _b, props = __objRest(_b, [
|
|
@@ -11135,11 +11131,10 @@ function TD(_a) {
|
|
|
11135
11131
|
"index",
|
|
11136
11132
|
"color",
|
|
11137
11133
|
"symbols",
|
|
11138
|
-
"handlers",
|
|
11139
11134
|
"mapedData",
|
|
11140
11135
|
"setMapedData"
|
|
11141
11136
|
]);
|
|
11142
|
-
var _a2, _b2
|
|
11137
|
+
var _a2, _b2;
|
|
11143
11138
|
const [isHidded, setIsHidded] = useState4(false);
|
|
11144
11139
|
const newProps = symbols && React3.isValidElement(symbols[item == null ? void 0 : item.name]) && ((_b2 = Object.keys((_a2 = symbols[item == null ? void 0 : item.name]) == null ? void 0 : _a2.props)) == null ? void 0 : _b2.reduce(
|
|
11145
11140
|
(acc, i) => {
|
|
@@ -11159,65 +11154,58 @@ function TD(_a) {
|
|
|
11159
11154
|
},
|
|
11160
11155
|
{ defaultValue: item == null ? void 0 : item.content }
|
|
11161
11156
|
));
|
|
11162
|
-
const newProps2 = handlers && React3.isValidElement(handlers[item == null ? void 0 : item.name]) && ((_d = Object.keys((_c = handlers[item == null ? void 0 : item.name]) == null ? void 0 : _c.props)) == null ? void 0 : _d.reduce(
|
|
11163
|
-
(acc, i) => {
|
|
11164
|
-
try {
|
|
11165
|
-
const newAcc = __spreadValues({}, acc);
|
|
11166
|
-
const hasEvent = `${i}`.startsWith("on");
|
|
11167
|
-
if (hasEvent) {
|
|
11168
|
-
newAcc[i] = (e) => {
|
|
11169
|
-
var _a3, _b3;
|
|
11170
|
-
e.item = item;
|
|
11171
|
-
(_b3 = (_a3 = handlers[item == null ? void 0 : item.name].props)[i]) == null ? void 0 : _b3.call(_a3, e);
|
|
11172
|
-
if (i == "onChange") {
|
|
11173
|
-
const newData = [...mapedData];
|
|
11174
|
-
newData[index][item == null ? void 0 : item.name].content = e.target.value;
|
|
11175
|
-
setMapedData == null ? void 0 : setMapedData(newData);
|
|
11176
|
-
}
|
|
11177
|
-
};
|
|
11178
|
-
}
|
|
11179
|
-
return newAcc;
|
|
11180
|
-
} catch (error) {
|
|
11181
|
-
}
|
|
11182
|
-
},
|
|
11183
|
-
{ value: item == null ? void 0 : item.content }
|
|
11184
|
-
));
|
|
11185
11157
|
return /* @__PURE__ */ jsx8(
|
|
11186
11158
|
"td",
|
|
11187
11159
|
{
|
|
11188
11160
|
onDoubleClick: (e) => setIsHidded(!isHidded),
|
|
11189
|
-
title: item == null ? void 0 : item.title,
|
|
11190
11161
|
className: [
|
|
11191
11162
|
isHidded && color2,
|
|
11192
11163
|
!isHidded && "whitespace-nowrap overflow-hidden text-ellipsis ",
|
|
11193
|
-
"border-b max-w-[200px] p-5 "
|
|
11194
|
-
["number", "money"].includes(item
|
|
11164
|
+
"border-b max-w-[200px] p-5 "
|
|
11165
|
+
// ["number", "money"].includes(item?.cellTypeOf) && "text-right",
|
|
11195
11166
|
].join(" "),
|
|
11196
|
-
children:
|
|
11197
|
-
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11167
|
+
children: /* @__PURE__ */ jsxs6("div", { className: symbols && symbols[item == null ? void 0 : item.name] && "flex justify-between", children: [
|
|
11168
|
+
symbols && /* @__PURE__ */ jsx8("div", { children: React3.Children.map(symbols[item == null ? void 0 : item.name], (child) => {
|
|
11169
|
+
if (React3.isValidElement(child)) {
|
|
11170
|
+
return React3.cloneElement(child, __spreadValues({}, newProps));
|
|
11171
|
+
}
|
|
11172
|
+
return child;
|
|
11173
|
+
}) }),
|
|
11174
|
+
/* @__PURE__ */ jsx8("div", { children: (item == null ? void 0 : item.handler) ? React3.Children.map(item.handler, (handler) => {
|
|
11175
|
+
if (React3.isValidElement(handler)) {
|
|
11176
|
+
return React3.cloneElement(handler, {
|
|
11177
|
+
value: mapedData[index][item.name].content,
|
|
11178
|
+
onChange: (e) => {
|
|
11179
|
+
var _a3, _b3;
|
|
11180
|
+
const nmd = [...mapedData];
|
|
11181
|
+
nmd[index][item.name].content = e.target.value;
|
|
11182
|
+
e.item = Object.assign(
|
|
11183
|
+
{},
|
|
11184
|
+
...nmd.map(
|
|
11185
|
+
(d) => Object.keys(d).map((k) => ({ [k]: d[k].content }))
|
|
11186
|
+
)[index]
|
|
11187
|
+
);
|
|
11188
|
+
e.setData = (data) => {
|
|
11189
|
+
const nmd2 = [...mapedData];
|
|
11190
|
+
for (let datum in data) {
|
|
11191
|
+
nmd2[index][datum].content = data[datum];
|
|
11192
|
+
}
|
|
11193
|
+
setMapedData == null ? void 0 : setMapedData(nmd2);
|
|
11194
|
+
};
|
|
11195
|
+
setMapedData == null ? void 0 : setMapedData(nmd);
|
|
11196
|
+
(_b3 = (_a3 = handler == null ? void 0 : handler.props) == null ? void 0 : _a3.onChange) == null ? void 0 : _b3.call(_a3, e);
|
|
11208
11197
|
}
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
)
|
|
11198
|
+
});
|
|
11199
|
+
}
|
|
11200
|
+
return handler;
|
|
11201
|
+
}) : item.content })
|
|
11202
|
+
] })
|
|
11215
11203
|
}
|
|
11216
11204
|
);
|
|
11217
11205
|
}
|
|
11218
11206
|
|
|
11219
11207
|
// src/table/filters.tsx
|
|
11220
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
11208
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
11221
11209
|
function FilterOffIcon() {
|
|
11222
11210
|
return /* @__PURE__ */ jsx9(
|
|
11223
11211
|
"svg",
|
|
@@ -11233,6 +11221,24 @@ function FilterOffIcon() {
|
|
|
11233
11221
|
}
|
|
11234
11222
|
);
|
|
11235
11223
|
}
|
|
11224
|
+
function SaveIcon() {
|
|
11225
|
+
return /* @__PURE__ */ jsxs7(
|
|
11226
|
+
"svg",
|
|
11227
|
+
{
|
|
11228
|
+
stroke: "currentColor",
|
|
11229
|
+
fill: "currentColor",
|
|
11230
|
+
strokeWidth: "0",
|
|
11231
|
+
viewBox: "0 0 512 512",
|
|
11232
|
+
height: "20px",
|
|
11233
|
+
width: "20px",
|
|
11234
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
11235
|
+
children: [
|
|
11236
|
+
/* @__PURE__ */ jsx9("path", { d: "M272 64h-16c-4.4 0-8 3.6-8 8v72c0 4.4 7.6 8 12 8h12c4.4 0 8-3.6 8-8V72c0-4.4-3.6-8-8-8z" }),
|
|
11237
|
+
/* @__PURE__ */ jsx9("path", { d: "M433.9 130.1L382 78.2c-9-9-21.3-14.2-34.1-14.2h-28c-8.8 0-16 7.3-16 16.2v80c0 8.8-7.2 16-16 16H160c-8.8 0-16-7.2-16-16v-80c0-8.8-7.2-16.2-16-16.2H96c-17.6 0-32 14.4-32 32v320c0 17.6 14.4 32 32 32h320c17.6 0 32-14.4 32-32V164c0-12.7-5.1-24.9-14.1-33.9zM322 400.1c0 8.8-8 16-17.8 16H143.8c-9.8 0-17.8-7.2-17.8-16v-96c0-8.8 8-16 17.8-16h160.4c9.8 0 17.8 7.2 17.8 16v96z" })
|
|
11238
|
+
]
|
|
11239
|
+
}
|
|
11240
|
+
);
|
|
11241
|
+
}
|
|
11236
11242
|
function ExcelIcon() {
|
|
11237
11243
|
return /* @__PURE__ */ jsx9(
|
|
11238
11244
|
"svg",
|
|
@@ -11251,7 +11257,7 @@ function ExcelIcon() {
|
|
|
11251
11257
|
|
|
11252
11258
|
// src/table/filter.menu.tsx
|
|
11253
11259
|
import { useEffect as useEffect6, useState as useState5 } from "react";
|
|
11254
|
-
import { Fragment as Fragment3, jsx as jsx10, jsxs as
|
|
11260
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
11255
11261
|
function FilterMenu({
|
|
11256
11262
|
h,
|
|
11257
11263
|
mapedData,
|
|
@@ -11264,11 +11270,7 @@ function FilterMenu({
|
|
|
11264
11270
|
const [newMapedData, setNewMapedData] = useState5([]);
|
|
11265
11271
|
useEffect6(() => {
|
|
11266
11272
|
setNewMapedData(
|
|
11267
|
-
[
|
|
11268
|
-
...new Set(
|
|
11269
|
-
mapedData.filter((md) => md.__visible__ === true).map((md) => md[h])
|
|
11270
|
-
)
|
|
11271
|
-
].filter((item) => {
|
|
11273
|
+
[...new Set(mapedData.map((md) => md[h]))].filter((item) => {
|
|
11272
11274
|
return item && `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
11273
11275
|
})
|
|
11274
11276
|
);
|
|
@@ -11276,14 +11278,14 @@ function FilterMenu({
|
|
|
11276
11278
|
useEffect6(() => {
|
|
11277
11279
|
setText("");
|
|
11278
11280
|
}, [selectedFilter]);
|
|
11279
|
-
return selectedFilter == index && /* @__PURE__ */
|
|
11281
|
+
return selectedFilter == index && /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
11280
11282
|
/* @__PURE__ */ jsx10(
|
|
11281
11283
|
"div",
|
|
11282
11284
|
{
|
|
11283
11285
|
className: "absolute bg-white border rounded min-w-[200px] ",
|
|
11284
11286
|
style: { zIndex: 9999999 },
|
|
11285
|
-
children: /* @__PURE__ */
|
|
11286
|
-
/* @__PURE__ */
|
|
11287
|
+
children: /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-start text-black", children: [
|
|
11288
|
+
/* @__PURE__ */ jsxs8(
|
|
11287
11289
|
"div",
|
|
11288
11290
|
{
|
|
11289
11291
|
className: "flex gap-1 w-full hover:bg-gray-100 p-3 cursor-pointer",
|
|
@@ -11317,13 +11319,13 @@ function FilterMenu({
|
|
|
11317
11319
|
}
|
|
11318
11320
|
}
|
|
11319
11321
|
) }),
|
|
11320
|
-
/* @__PURE__ */ jsx10("div", { className: "px-2 w-full h-[150px]", children: /* @__PURE__ */
|
|
11322
|
+
/* @__PURE__ */ jsx10("div", { className: "px-2 w-full h-[150px]", children: /* @__PURE__ */ jsxs8(
|
|
11321
11323
|
"div",
|
|
11322
11324
|
{
|
|
11323
11325
|
style: { overflow: "auto" },
|
|
11324
11326
|
className: "border h-full flex gap-2 flex-col p-1",
|
|
11325
11327
|
children: [
|
|
11326
|
-
/* @__PURE__ */ jsx10("div", { className: "flex gap-2 items-center justify-start ", children: /* @__PURE__ */
|
|
11328
|
+
/* @__PURE__ */ jsx10("div", { className: "flex gap-2 items-center justify-start ", children: /* @__PURE__ */ jsxs8("label", { children: [
|
|
11327
11329
|
/* @__PURE__ */ jsx10(
|
|
11328
11330
|
"input",
|
|
11329
11331
|
{
|
|
@@ -11331,10 +11333,11 @@ function FilterMenu({
|
|
|
11331
11333
|
checked: mapedData.map((d) => d[h].exclude).every((d) => d === false),
|
|
11332
11334
|
onChange: (e) => {
|
|
11333
11335
|
const nmd = [...mapedData];
|
|
11336
|
+
const all = nmd.map((d) => d[h].exclude).every((d) => d === false);
|
|
11334
11337
|
setMapedData(
|
|
11335
11338
|
nmd.map((d) => {
|
|
11336
11339
|
const newd = __spreadValues({}, d);
|
|
11337
|
-
newd[h].exclude =
|
|
11340
|
+
newd[h].exclude = all;
|
|
11338
11341
|
return newd;
|
|
11339
11342
|
})
|
|
11340
11343
|
);
|
|
@@ -11363,7 +11366,7 @@ function FilterMenu({
|
|
|
11363
11366
|
"div",
|
|
11364
11367
|
{
|
|
11365
11368
|
className: "flex gap-2 items-center justify-start",
|
|
11366
|
-
children: /* @__PURE__ */
|
|
11369
|
+
children: /* @__PURE__ */ jsxs8("label", { children: [
|
|
11367
11370
|
/* @__PURE__ */ jsx10(
|
|
11368
11371
|
"input",
|
|
11369
11372
|
{
|
|
@@ -11414,163 +11417,6 @@ function FilterMenu({
|
|
|
11414
11417
|
] });
|
|
11415
11418
|
}
|
|
11416
11419
|
|
|
11417
|
-
// src/table/h.tsx
|
|
11418
|
-
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
11419
|
-
function HTable(_a) {
|
|
11420
|
-
var _b = _a, {
|
|
11421
|
-
data,
|
|
11422
|
-
mapedData,
|
|
11423
|
-
setMapedData,
|
|
11424
|
-
symbols,
|
|
11425
|
-
totals,
|
|
11426
|
-
exportName
|
|
11427
|
-
} = _b, props = __objRest(_b, [
|
|
11428
|
-
"data",
|
|
11429
|
-
"mapedData",
|
|
11430
|
-
"setMapedData",
|
|
11431
|
-
"symbols",
|
|
11432
|
-
"totals",
|
|
11433
|
-
"exportName"
|
|
11434
|
-
]);
|
|
11435
|
-
const [selected, setSelected] = useState6(null);
|
|
11436
|
-
const [selectedFilter, setSelectedFilter] = useState6(null);
|
|
11437
|
-
const modalRef = useRef4(null);
|
|
11438
|
-
const head = useMemo7(() => {
|
|
11439
|
-
return [...new Set(data.map((d) => Object.keys(d)).flat())];
|
|
11440
|
-
}, [data]);
|
|
11441
|
-
const mapedTotals = useMemo7(() => {
|
|
11442
|
-
return mapedData == null ? void 0 : mapedData.reduce((acc, md) => {
|
|
11443
|
-
head.forEach((h) => {
|
|
11444
|
-
var _a2, _b2;
|
|
11445
|
-
const value = isNaN(+((_a2 = md[h]) == null ? void 0 : _a2.content)) ? 0 : +((_b2 = md[h]) == null ? void 0 : _b2.content);
|
|
11446
|
-
if (acc[h]) {
|
|
11447
|
-
acc[h] += value;
|
|
11448
|
-
} else {
|
|
11449
|
-
acc[h] = value;
|
|
11450
|
-
}
|
|
11451
|
-
});
|
|
11452
|
-
return acc;
|
|
11453
|
-
}, {});
|
|
11454
|
-
}, [mapedData]);
|
|
11455
|
-
useEffect7(() => {
|
|
11456
|
-
const newData = data.map((d, trkey) => {
|
|
11457
|
-
const obj = { __visible__: true };
|
|
11458
|
-
for (let key in d) {
|
|
11459
|
-
const typeOf = typeof d[key];
|
|
11460
|
-
const isObject2 = typeOf == "object";
|
|
11461
|
-
const isDate = typeOf == "string" && d[key].includes("T");
|
|
11462
|
-
const cellTypeOf = isDate ? "date" : isObject2 ? "object" : typeOf;
|
|
11463
|
-
const content = cellTypeOf == "date" ? d[key].split("T").join(" ").split(".")[0] : cellTypeOf == "object" ? React4.isValidElement(d[key]) ? d[key] : JSON.stringify(d[key]) : d[key];
|
|
11464
|
-
obj[key] = {
|
|
11465
|
-
index: trkey,
|
|
11466
|
-
originalData: content,
|
|
11467
|
-
cellTypeOf,
|
|
11468
|
-
title: content,
|
|
11469
|
-
content,
|
|
11470
|
-
name: key,
|
|
11471
|
-
exclude: false
|
|
11472
|
-
};
|
|
11473
|
-
}
|
|
11474
|
-
return obj;
|
|
11475
|
-
});
|
|
11476
|
-
setMapedData(newData);
|
|
11477
|
-
}, [data]);
|
|
11478
|
-
return /* @__PURE__ */ jsx11(Fragment4, { children: /* @__PURE__ */ jsxs8("table", __spreadProps(__spreadValues({}, props), { className: "w-full border-collapse table-auto", children: [
|
|
11479
|
-
/* @__PURE__ */ jsx11("thead", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ jsx11("tr", { children: head.map((h, key) => {
|
|
11480
|
-
return /* @__PURE__ */ jsxs8(
|
|
11481
|
-
"th",
|
|
11482
|
-
{
|
|
11483
|
-
className: "whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px] border-b p-5",
|
|
11484
|
-
children: [
|
|
11485
|
-
/* @__PURE__ */ jsx11(
|
|
11486
|
-
"div",
|
|
11487
|
-
{
|
|
11488
|
-
className: "cursor-pointer flex ",
|
|
11489
|
-
onClick: (e) => {
|
|
11490
|
-
setSelectedFilter(key == selectedFilter ? null : key);
|
|
11491
|
-
},
|
|
11492
|
-
children: /* @__PURE__ */ jsxs8("div", { className: "text-white w-full bg-black rounded p-1 flex justify-center", children: [
|
|
11493
|
-
h,
|
|
11494
|
-
" ",
|
|
11495
|
-
!mapedData.map((d) => d[h].exclude).every((d) => d === false) && /* @__PURE__ */ jsx11("div", { className: "text-red-300", children: /* @__PURE__ */ jsx11(FilterOffIcon, {}) })
|
|
11496
|
-
] })
|
|
11497
|
-
}
|
|
11498
|
-
),
|
|
11499
|
-
/* @__PURE__ */ jsx11(
|
|
11500
|
-
FilterMenu,
|
|
11501
|
-
{
|
|
11502
|
-
h,
|
|
11503
|
-
mapedData,
|
|
11504
|
-
setMapedData,
|
|
11505
|
-
index: key,
|
|
11506
|
-
selectedFilter,
|
|
11507
|
-
setSelectedFilter
|
|
11508
|
-
}
|
|
11509
|
-
)
|
|
11510
|
-
]
|
|
11511
|
-
},
|
|
11512
|
-
h
|
|
11513
|
-
);
|
|
11514
|
-
}) }) }),
|
|
11515
|
-
/* @__PURE__ */ jsx11("tbody", { className: "divide-y divide-gray-200", children: mapedData.map((md, trKey) => {
|
|
11516
|
-
var _a2;
|
|
11517
|
-
const color2 = trKey % 2 == 0 ? "bg-white" : "bg-gray-100";
|
|
11518
|
-
for (let d in md) {
|
|
11519
|
-
if (md[d].exclude === true) {
|
|
11520
|
-
return null;
|
|
11521
|
-
}
|
|
11522
|
-
}
|
|
11523
|
-
return /* @__PURE__ */ jsx11(
|
|
11524
|
-
"tr",
|
|
11525
|
-
{
|
|
11526
|
-
onDoubleClick: (e) => {
|
|
11527
|
-
var _a3;
|
|
11528
|
-
(_a3 = modalRef.current) == null ? void 0 : _a3.showModal();
|
|
11529
|
-
},
|
|
11530
|
-
onClick: (e) => setSelected(trKey),
|
|
11531
|
-
className: [
|
|
11532
|
-
"hover:bg-green-100 ",
|
|
11533
|
-
color2,
|
|
11534
|
-
selected == trKey && "bg-green-200 hover:bg-green-300"
|
|
11535
|
-
].join(" "),
|
|
11536
|
-
children: head.map((h, tdKey) => {
|
|
11537
|
-
var _a3;
|
|
11538
|
-
const item = md[h];
|
|
11539
|
-
const id3 = trKey + "-" + (((_a3 = md == null ? void 0 : md.id) == null ? void 0 : _a3.content) || tdKey) + "-" + h;
|
|
11540
|
-
return /* @__PURE__ */ jsx11(
|
|
11541
|
-
TD,
|
|
11542
|
-
{
|
|
11543
|
-
index: trKey,
|
|
11544
|
-
symbols,
|
|
11545
|
-
handlers: props.handlers,
|
|
11546
|
-
item,
|
|
11547
|
-
color: color2,
|
|
11548
|
-
mapedData,
|
|
11549
|
-
setMapedData
|
|
11550
|
-
},
|
|
11551
|
-
id3
|
|
11552
|
-
);
|
|
11553
|
-
})
|
|
11554
|
-
},
|
|
11555
|
-
((_a2 = md == null ? void 0 : md.id) == null ? void 0 : _a2.content) || trKey
|
|
11556
|
-
);
|
|
11557
|
-
}) }),
|
|
11558
|
-
/* @__PURE__ */ jsx11("tfoot", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ jsx11("tr", { children: head.map((h, fkey) => {
|
|
11559
|
-
return /* @__PURE__ */ jsx11(
|
|
11560
|
-
"th",
|
|
11561
|
-
{
|
|
11562
|
-
className: "text-right border-b max-w-[200px] p-5 ",
|
|
11563
|
-
children: totals && totals.includes(h) && /* @__PURE__ */ jsxs8("div", { className: "flex justify-between text-white w-full bg-black rounded p-1", children: [
|
|
11564
|
-
/* @__PURE__ */ jsx11("div", { className: "p-1", children: symbols && symbols[h] && symbols[h] }),
|
|
11565
|
-
/* @__PURE__ */ jsx11("div", { className: "p-1", children: mapedTotals[h] })
|
|
11566
|
-
] })
|
|
11567
|
-
},
|
|
11568
|
-
fkey
|
|
11569
|
-
);
|
|
11570
|
-
}) }) })
|
|
11571
|
-
] })) });
|
|
11572
|
-
}
|
|
11573
|
-
|
|
11574
11420
|
// ../../node_modules/xlsx/xlsx.mjs
|
|
11575
11421
|
var XLSX = {};
|
|
11576
11422
|
XLSX.version = "0.18.5";
|
|
@@ -32072,46 +31918,218 @@ function useExportdata() {
|
|
|
32072
31918
|
};
|
|
32073
31919
|
}
|
|
32074
31920
|
|
|
32075
|
-
// src/table/
|
|
32076
|
-
import { Fragment as
|
|
32077
|
-
function
|
|
32078
|
-
|
|
32079
|
-
|
|
31921
|
+
// src/table/h.tsx
|
|
31922
|
+
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
31923
|
+
function HTable(_a) {
|
|
31924
|
+
var _b = _a, {
|
|
31925
|
+
data,
|
|
31926
|
+
symbols,
|
|
31927
|
+
totals,
|
|
31928
|
+
exportName,
|
|
31929
|
+
onSave
|
|
31930
|
+
} = _b, props = __objRest(_b, [
|
|
31931
|
+
"data",
|
|
31932
|
+
"symbols",
|
|
31933
|
+
"totals",
|
|
31934
|
+
"exportName",
|
|
31935
|
+
"onSave"
|
|
31936
|
+
]);
|
|
31937
|
+
if (!Array.isArray(data)) return null;
|
|
31938
|
+
const [mapedData, setMapedData] = useState6([...data]);
|
|
32080
31939
|
const exported = useExportdata();
|
|
32081
|
-
|
|
32082
|
-
|
|
32083
|
-
|
|
32084
|
-
|
|
32085
|
-
|
|
32086
|
-
|
|
32087
|
-
|
|
32088
|
-
|
|
32089
|
-
|
|
32090
|
-
|
|
32091
|
-
|
|
32092
|
-
|
|
32093
|
-
|
|
32094
|
-
|
|
32095
|
-
|
|
32096
|
-
|
|
32097
|
-
|
|
32098
|
-
|
|
32099
|
-
|
|
31940
|
+
const [selected, setSelected] = useState6(null);
|
|
31941
|
+
const [selectedFilter, setSelectedFilter] = useState6(null);
|
|
31942
|
+
const modalRef = useRef4(null);
|
|
31943
|
+
const head = useMemo7(() => {
|
|
31944
|
+
return [...new Set(data.map((d) => Object.keys(d)).flat())];
|
|
31945
|
+
}, [data]);
|
|
31946
|
+
const mapedTotals = useMemo7(() => {
|
|
31947
|
+
return mapedData == null ? void 0 : mapedData.reduce((acc, md) => {
|
|
31948
|
+
head.forEach((h) => {
|
|
31949
|
+
var _a2, _b2;
|
|
31950
|
+
const value = isNaN(+((_a2 = md[h]) == null ? void 0 : _a2.content)) ? 0 : +((_b2 = md[h]) == null ? void 0 : _b2.content);
|
|
31951
|
+
if (acc[h]) {
|
|
31952
|
+
acc[h] += value;
|
|
31953
|
+
} else {
|
|
31954
|
+
acc[h] = value;
|
|
31955
|
+
}
|
|
31956
|
+
});
|
|
31957
|
+
return acc;
|
|
31958
|
+
}, {});
|
|
31959
|
+
}, [mapedData]);
|
|
31960
|
+
useEffect7(() => {
|
|
31961
|
+
setMapedData(data);
|
|
31962
|
+
}, [data]);
|
|
31963
|
+
useEffect7(() => {
|
|
31964
|
+
const newData = data.map((d, trkey) => {
|
|
31965
|
+
var _a2, _b2;
|
|
31966
|
+
const obj = {};
|
|
31967
|
+
for (let key in d) {
|
|
31968
|
+
const item = {};
|
|
31969
|
+
for (let key2 in d) {
|
|
31970
|
+
item[key2] = ((_a2 = d[key2]) == null ? void 0 : _a2.content) || d[key2];
|
|
31971
|
+
}
|
|
31972
|
+
const typeOf = typeof d[key];
|
|
31973
|
+
const isObject2 = typeOf == "object";
|
|
31974
|
+
const isDate = typeOf == "string" && d[key].toString().includes("T");
|
|
31975
|
+
const cellTypeOf = isDate ? "date" : isObject2 ? "object" : typeOf;
|
|
31976
|
+
const content = cellTypeOf == "date" ? d[key].split("T").join(" ").split(".")[0] : cellTypeOf == "object" ? React4.isValidElement(d[key]) ? ((_b2 = d[key]) == null ? void 0 : _b2.props).defaultValue : JSON.stringify(d[key]) : d[key];
|
|
31977
|
+
const handler = React4.isValidElement(d[key]) ? d[key] : null;
|
|
31978
|
+
obj[key] = {
|
|
31979
|
+
index: trkey,
|
|
31980
|
+
originalData: content,
|
|
31981
|
+
cellTypeOf,
|
|
31982
|
+
title: content,
|
|
31983
|
+
content,
|
|
31984
|
+
name: key,
|
|
31985
|
+
exclude: false,
|
|
31986
|
+
handler
|
|
31987
|
+
};
|
|
32100
31988
|
}
|
|
32101
|
-
|
|
32102
|
-
|
|
32103
|
-
|
|
32104
|
-
|
|
32105
|
-
|
|
32106
|
-
|
|
32107
|
-
|
|
32108
|
-
|
|
31989
|
+
return obj;
|
|
31990
|
+
});
|
|
31991
|
+
setMapedData(newData);
|
|
31992
|
+
}, [data]);
|
|
31993
|
+
const values = useMemo7(() => {
|
|
31994
|
+
return mapedData.map((d) => Object.keys(d).map((k) => ({ [k]: d[k].content }))).map((d) => Object.assign({}, ...d));
|
|
31995
|
+
}, [mapedData]);
|
|
31996
|
+
return /* @__PURE__ */ jsxs9(Fragment4, { children: [
|
|
31997
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex gap-2", children: [
|
|
31998
|
+
onSave && /* @__PURE__ */ jsxs9(
|
|
31999
|
+
"button",
|
|
32000
|
+
{
|
|
32001
|
+
className: "p-2 border rounded shadow bg-blue-800 text-white flex gap-1",
|
|
32002
|
+
onClick: (e) => {
|
|
32003
|
+
onSave({ data: values });
|
|
32004
|
+
},
|
|
32005
|
+
children: [
|
|
32006
|
+
/* @__PURE__ */ jsx11(SaveIcon, {}),
|
|
32007
|
+
" Guardar"
|
|
32008
|
+
]
|
|
32009
|
+
}
|
|
32010
|
+
),
|
|
32011
|
+
exportName && mapedData.length > 0 && /* @__PURE__ */ jsx11(Fragment4, { children: /* @__PURE__ */ jsxs9(
|
|
32012
|
+
"button",
|
|
32013
|
+
{
|
|
32014
|
+
className: "p-2 border rounded shadow bg-green-800 text-white flex gap-1",
|
|
32015
|
+
onClick: (e) => exported.export(values, exportName),
|
|
32016
|
+
children: [
|
|
32017
|
+
/* @__PURE__ */ jsx11(ExcelIcon, {}),
|
|
32018
|
+
" Exportar"
|
|
32019
|
+
]
|
|
32020
|
+
}
|
|
32021
|
+
) })
|
|
32022
|
+
] }),
|
|
32023
|
+
/* @__PURE__ */ jsxs9("table", __spreadProps(__spreadValues({}, props), { className: "w-full border-collapse table-auto", children: [
|
|
32024
|
+
/* @__PURE__ */ jsx11("thead", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ jsx11("tr", { children: head.map((h, key) => {
|
|
32025
|
+
var _a2;
|
|
32026
|
+
return /* @__PURE__ */ jsxs9(
|
|
32027
|
+
"th",
|
|
32028
|
+
{
|
|
32029
|
+
className: "whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px] border-b p-2",
|
|
32030
|
+
children: [
|
|
32031
|
+
/* @__PURE__ */ jsx11(
|
|
32032
|
+
"div",
|
|
32033
|
+
{
|
|
32034
|
+
className: "cursor-pointer flex ",
|
|
32035
|
+
onClick: (e) => {
|
|
32036
|
+
setSelectedFilter(key == selectedFilter ? null : key);
|
|
32037
|
+
},
|
|
32038
|
+
children: /* @__PURE__ */ jsxs9("div", { className: "text-white w-full bg-black rounded flex justify-center", children: [
|
|
32039
|
+
h,
|
|
32040
|
+
" ",
|
|
32041
|
+
!((_a2 = mapedData == null ? void 0 : mapedData.map((d) => {
|
|
32042
|
+
var _a3;
|
|
32043
|
+
return (_a3 = d[h]) == null ? void 0 : _a3.exclude;
|
|
32044
|
+
})) == null ? void 0 : _a2.every((d) => d === false)) && /* @__PURE__ */ jsx11("div", { className: "text-red-300", children: /* @__PURE__ */ jsx11(FilterOffIcon, {}) })
|
|
32045
|
+
] })
|
|
32046
|
+
}
|
|
32047
|
+
),
|
|
32048
|
+
/* @__PURE__ */ jsx11(
|
|
32049
|
+
FilterMenu,
|
|
32050
|
+
{
|
|
32051
|
+
h,
|
|
32052
|
+
mapedData,
|
|
32053
|
+
setMapedData,
|
|
32054
|
+
index: key,
|
|
32055
|
+
selectedFilter,
|
|
32056
|
+
setSelectedFilter
|
|
32057
|
+
}
|
|
32058
|
+
)
|
|
32059
|
+
]
|
|
32060
|
+
},
|
|
32061
|
+
h
|
|
32062
|
+
);
|
|
32063
|
+
}) }) }),
|
|
32064
|
+
/* @__PURE__ */ jsx11("tbody", { className: "divide-y divide-gray-200", children: mapedData.map((md, trKey) => {
|
|
32065
|
+
var _a2;
|
|
32066
|
+
const color2 = trKey % 2 == 0 ? "bg-white" : "bg-gray-100";
|
|
32067
|
+
for (let d in md) {
|
|
32068
|
+
if (md[d].exclude === true) {
|
|
32069
|
+
return null;
|
|
32070
|
+
}
|
|
32071
|
+
}
|
|
32072
|
+
return /* @__PURE__ */ jsx11(
|
|
32073
|
+
"tr",
|
|
32074
|
+
{
|
|
32075
|
+
onDoubleClick: (e) => {
|
|
32076
|
+
var _a3;
|
|
32077
|
+
(_a3 = modalRef.current) == null ? void 0 : _a3.showModal();
|
|
32078
|
+
},
|
|
32079
|
+
onClick: (e) => setSelected(trKey),
|
|
32080
|
+
className: [
|
|
32081
|
+
"hover:bg-green-100 ",
|
|
32082
|
+
color2,
|
|
32083
|
+
selected == trKey && "bg-green-200 hover:bg-green-300"
|
|
32084
|
+
].join(" "),
|
|
32085
|
+
children: head.map((h, tdKey) => {
|
|
32086
|
+
var _a3;
|
|
32087
|
+
const item = md[h];
|
|
32088
|
+
const id3 = trKey + "-" + (((_a3 = md == null ? void 0 : md.id) == null ? void 0 : _a3.content) || tdKey) + "-" + h;
|
|
32089
|
+
return /* @__PURE__ */ jsx11(
|
|
32090
|
+
TD,
|
|
32091
|
+
{
|
|
32092
|
+
index: trKey,
|
|
32093
|
+
symbols,
|
|
32094
|
+
item,
|
|
32095
|
+
color: color2,
|
|
32096
|
+
mapedData,
|
|
32097
|
+
setMapedData
|
|
32098
|
+
},
|
|
32099
|
+
id3
|
|
32100
|
+
);
|
|
32101
|
+
})
|
|
32102
|
+
},
|
|
32103
|
+
((_a2 = md == null ? void 0 : md.id) == null ? void 0 : _a2.content) || trKey
|
|
32104
|
+
);
|
|
32105
|
+
}) }),
|
|
32106
|
+
totals && /* @__PURE__ */ jsx11("tfoot", { className: "bg-gray-800 text-white", children: /* @__PURE__ */ jsx11("tr", { children: head.map((h, fkey) => {
|
|
32107
|
+
return /* @__PURE__ */ jsx11(
|
|
32108
|
+
"th",
|
|
32109
|
+
{
|
|
32110
|
+
className: "text-right border-b max-w-[200px] p-2 ",
|
|
32111
|
+
children: totals.includes(h) && /* @__PURE__ */ jsxs9("div", { className: "flex justify-between text-white w-full bg-black rounded ", children: [
|
|
32112
|
+
/* @__PURE__ */ jsx11("div", { className: "p-1", children: symbols && symbols[h] && symbols[h] }),
|
|
32113
|
+
/* @__PURE__ */ jsx11("div", { className: "p-1", children: mapedTotals[h] })
|
|
32114
|
+
] })
|
|
32115
|
+
},
|
|
32116
|
+
fkey
|
|
32117
|
+
);
|
|
32118
|
+
}) }) })
|
|
32119
|
+
] }))
|
|
32109
32120
|
] });
|
|
32110
32121
|
}
|
|
32111
32122
|
|
|
32123
|
+
// src/table/index.tsx
|
|
32124
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
32125
|
+
function Table(_a) {
|
|
32126
|
+
var props = __objRest(_a, []);
|
|
32127
|
+
return /* @__PURE__ */ jsx12("div", { className: "bg-gray-200 border rounded shadow p-1", children: Array.isArray(props.data) ? /* @__PURE__ */ jsx12(HTable, __spreadValues({}, props)) : /* @__PURE__ */ jsx12("div", { className: " p-5 border rounded shadow bg-yellw-500", children: "No es un array" }) });
|
|
32128
|
+
}
|
|
32129
|
+
|
|
32112
32130
|
// src/text-area/index.tsx
|
|
32113
32131
|
import {
|
|
32114
|
-
useState as
|
|
32132
|
+
useState as useState7
|
|
32115
32133
|
} from "react";
|
|
32116
32134
|
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
32117
32135
|
function TextArea(_a) {
|
|
@@ -32128,7 +32146,7 @@ function TextArea(_a) {
|
|
|
32128
32146
|
"onChange",
|
|
32129
32147
|
"children"
|
|
32130
32148
|
]);
|
|
32131
|
-
const [value, setValue] =
|
|
32149
|
+
const [value, setValue] = useState7(children);
|
|
32132
32150
|
return /* @__PURE__ */ jsx13("div", { className: "w-full", children: /* @__PURE__ */ jsxs10("label", { className: "flex flex-col gap-1", children: [
|
|
32133
32151
|
/* @__PURE__ */ jsx13("div", { className: "font-bold ", children: label }),
|
|
32134
32152
|
/* @__PURE__ */ jsxs10("div", { children: [
|
|
@@ -32158,7 +32176,7 @@ function TextArea(_a) {
|
|
|
32158
32176
|
}
|
|
32159
32177
|
|
|
32160
32178
|
// src/use-resources/index.ts
|
|
32161
|
-
import { useEffect as useEffect8, useMemo as useMemo9, useState as
|
|
32179
|
+
import { useEffect as useEffect8, useMemo as useMemo9, useState as useState8 } from "react";
|
|
32162
32180
|
|
|
32163
32181
|
// src/use-resources/get.token.tsx
|
|
32164
32182
|
import { useMemo as useMemo8 } from "react";
|
|
@@ -32256,7 +32274,7 @@ function useResources({
|
|
|
32256
32274
|
onError
|
|
32257
32275
|
}) {
|
|
32258
32276
|
const token = useToken();
|
|
32259
|
-
const [info, setInfo] =
|
|
32277
|
+
const [info, setInfo] = useState8({});
|
|
32260
32278
|
const result = useMemo9(() => {
|
|
32261
32279
|
var _c, _d, _e, _f, _g, _h, _i;
|
|
32262
32280
|
const r = {};
|
|
@@ -32509,7 +32527,7 @@ function useResources({
|
|
|
32509
32527
|
import React6, {
|
|
32510
32528
|
useEffect as useEffect9,
|
|
32511
32529
|
useRef as useRef5,
|
|
32512
|
-
useState as
|
|
32530
|
+
useState as useState9
|
|
32513
32531
|
} from "react";
|
|
32514
32532
|
|
|
32515
32533
|
// src/select/icon.tsx
|
|
@@ -32562,15 +32580,15 @@ function Select(_a) {
|
|
|
32562
32580
|
"children",
|
|
32563
32581
|
"strictMode"
|
|
32564
32582
|
]);
|
|
32565
|
-
const [isOpen, setIsOpen] =
|
|
32566
|
-
const [inputValue, setInputValue] =
|
|
32567
|
-
const [options, setOptions] =
|
|
32583
|
+
const [isOpen, setIsOpen] = useState9(false);
|
|
32584
|
+
const [inputValue, setInputValue] = useState9((props == null ? void 0 : props.value) || "");
|
|
32585
|
+
const [options, setOptions] = useState9(
|
|
32568
32586
|
[]
|
|
32569
32587
|
);
|
|
32570
|
-
const [filtered, setFiltered] =
|
|
32588
|
+
const [filtered, setFiltered] = useState9(
|
|
32571
32589
|
[]
|
|
32572
32590
|
);
|
|
32573
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
32591
|
+
const [highlightedIndex, setHighlightedIndex] = useState9(-1);
|
|
32574
32592
|
const inputRef = useRef5(null);
|
|
32575
32593
|
const validOption = (value) => {
|
|
32576
32594
|
return options.find((opt) => opt.label == value);
|
|
@@ -32618,7 +32636,7 @@ function Select(_a) {
|
|
|
32618
32636
|
setIsOpen(false);
|
|
32619
32637
|
};
|
|
32620
32638
|
const containerRef = useRef5(null);
|
|
32621
|
-
const [openUpwards, setOpenUpwards] =
|
|
32639
|
+
const [openUpwards, setOpenUpwards] = useState9(false);
|
|
32622
32640
|
useEffect9(() => {
|
|
32623
32641
|
if (isOpen && containerRef.current) {
|
|
32624
32642
|
const rect = containerRef.current.getBoundingClientRect();
|
|
@@ -32736,7 +32754,7 @@ function Select(_a) {
|
|
|
32736
32754
|
|
|
32737
32755
|
// src/modal/index.tsx
|
|
32738
32756
|
import React7, { useRef as useRef6 } from "react";
|
|
32739
|
-
import { Fragment as
|
|
32757
|
+
import { Fragment as Fragment5, jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
32740
32758
|
function Modal({ button, children, ref }) {
|
|
32741
32759
|
const modalRef = ref || useRef6(null);
|
|
32742
32760
|
function show() {
|
|
@@ -32747,7 +32765,7 @@ function Modal({ button, children, ref }) {
|
|
|
32747
32765
|
var _a;
|
|
32748
32766
|
typeof modalRef == "object" && ((_a = modalRef.current) == null ? void 0 : _a.close());
|
|
32749
32767
|
}
|
|
32750
|
-
return /* @__PURE__ */ jsxs12(
|
|
32768
|
+
return /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
32751
32769
|
React7.Children.map(button, (child) => {
|
|
32752
32770
|
if (React7.isValidElement(child)) {
|
|
32753
32771
|
return React7.cloneElement(child, {
|