next-recomponents 2.0.65 → 2.0.67
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +137 -144
- package/dist/index.mjs +85 -94
- package/package.json +1 -1
- package/src/text-area/index.tsx +16 -21
- package/src/use-resources/index.ts +12 -12
package/dist/index.js
CHANGED
|
@@ -36169,41 +36169,34 @@ function Table(props) {
|
|
|
36169
36169
|
}
|
|
36170
36170
|
|
|
36171
36171
|
// src/text-area/index.tsx
|
|
36172
|
-
var import_react6 = require("react");
|
|
36173
36172
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
36174
36173
|
function TextArea({
|
|
36175
36174
|
label,
|
|
36176
36175
|
className,
|
|
36177
36176
|
maxLength,
|
|
36178
36177
|
onChange,
|
|
36179
|
-
|
|
36178
|
+
value,
|
|
36180
36179
|
...props
|
|
36181
36180
|
}) {
|
|
36182
|
-
const
|
|
36183
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "w-full relative my-3", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative flex items-center border rounded bg-white
|
|
36181
|
+
const currentValue = String(value != null ? value : "");
|
|
36182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "w-full relative my-3", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative flex items-center border rounded bg-white", children: [
|
|
36184
36183
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
36185
36184
|
"textarea",
|
|
36186
36185
|
{
|
|
36187
36186
|
...props,
|
|
36188
36187
|
className: ["p-1 w-full transparent", className].join(" "),
|
|
36189
|
-
value,
|
|
36190
|
-
|
|
36191
|
-
|
|
36192
|
-
e.target.value = e.target.value.slice(0, maxLength);
|
|
36193
|
-
}
|
|
36194
|
-
setValue(e.target.value);
|
|
36195
|
-
onChange == null ? void 0 : onChange(e);
|
|
36196
|
-
}
|
|
36188
|
+
value: currentValue,
|
|
36189
|
+
maxLength,
|
|
36190
|
+
onChange
|
|
36197
36191
|
}
|
|
36198
36192
|
),
|
|
36199
|
-
" ",
|
|
36200
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "absolute -top-2.5 left-2 text-xs font-bold px-1", children: [
|
|
36193
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "absolute -top-2.5 left-2 text-xs font-bold px-1", children: [
|
|
36201
36194
|
label,
|
|
36202
36195
|
" ",
|
|
36203
|
-
|
|
36196
|
+
props.required && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-red-500", children: "*" })
|
|
36204
36197
|
] }),
|
|
36205
|
-
maxLength && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "
|
|
36206
|
-
|
|
36198
|
+
maxLength && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "text-xs text-gray text-right", children: [
|
|
36199
|
+
currentValue.length,
|
|
36207
36200
|
" / ",
|
|
36208
36201
|
maxLength
|
|
36209
36202
|
] })
|
|
@@ -36211,12 +36204,12 @@ function TextArea({
|
|
|
36211
36204
|
}
|
|
36212
36205
|
|
|
36213
36206
|
// src/use-resources/index.ts
|
|
36214
|
-
var
|
|
36207
|
+
var import_react7 = require("react");
|
|
36215
36208
|
|
|
36216
36209
|
// src/use-resources/get.token.tsx
|
|
36217
|
-
var
|
|
36210
|
+
var import_react6 = require("react");
|
|
36218
36211
|
function useToken() {
|
|
36219
|
-
const token = (0,
|
|
36212
|
+
const token = (0, import_react6.useMemo)(() => {
|
|
36220
36213
|
if (typeof window != "undefined") {
|
|
36221
36214
|
const t = window.localStorage.getItem("token");
|
|
36222
36215
|
if (t) return t;
|
|
@@ -36308,7 +36301,7 @@ function useResources({
|
|
|
36308
36301
|
onError
|
|
36309
36302
|
}) {
|
|
36310
36303
|
const token = useToken();
|
|
36311
|
-
const [info, setInfo] = (0,
|
|
36304
|
+
const [info, setInfo] = (0, import_react7.useState)(
|
|
36312
36305
|
Object.keys(endpoints).reduce((acc, key) => {
|
|
36313
36306
|
var _a, _b;
|
|
36314
36307
|
const newAcc = {
|
|
@@ -36685,27 +36678,27 @@ function useResources({
|
|
|
36685
36678
|
);
|
|
36686
36679
|
async function doSome() {
|
|
36687
36680
|
var _a, _b, _c, _d, _e;
|
|
36688
|
-
const
|
|
36689
|
-
|
|
36690
|
-
|
|
36691
|
-
|
|
36692
|
-
|
|
36693
|
-
|
|
36694
|
-
|
|
36695
|
-
|
|
36696
|
-
|
|
36697
|
-
|
|
36681
|
+
const keys2 = Object.keys(info);
|
|
36682
|
+
for (let key of keys2) {
|
|
36683
|
+
if (key) {
|
|
36684
|
+
if ((_a = info[key]) == null ? void 0 : _a.id) {
|
|
36685
|
+
await results[key].find((_b = info[key]) == null ? void 0 : _b.id, (_c = info[key]) == null ? void 0 : _c.defaultParams);
|
|
36686
|
+
} else if ((_d = info[key]) == null ? void 0 : _d.defaultParams) {
|
|
36687
|
+
await results[key].show((_e = info[key]) == null ? void 0 : _e.defaultParams);
|
|
36688
|
+
} else {
|
|
36689
|
+
results[key].setLoaded();
|
|
36690
|
+
}
|
|
36698
36691
|
}
|
|
36699
36692
|
}
|
|
36700
36693
|
}
|
|
36701
|
-
(0,
|
|
36694
|
+
(0, import_react7.useEffect)(() => {
|
|
36702
36695
|
doSome();
|
|
36703
|
-
}, [
|
|
36696
|
+
}, []);
|
|
36704
36697
|
return results;
|
|
36705
36698
|
}
|
|
36706
36699
|
|
|
36707
36700
|
// src/select/index.tsx
|
|
36708
|
-
var
|
|
36701
|
+
var import_react8 = __toESM(require("react"));
|
|
36709
36702
|
|
|
36710
36703
|
// src/select/icon.tsx
|
|
36711
36704
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
@@ -36752,13 +36745,13 @@ function Select({
|
|
|
36752
36745
|
strictMode = true,
|
|
36753
36746
|
...props
|
|
36754
36747
|
}) {
|
|
36755
|
-
const [isOpen, setIsOpen] = (0,
|
|
36756
|
-
const [inputValue, setInputValue] = (0,
|
|
36757
|
-
const [options, setOptions] = (0,
|
|
36748
|
+
const [isOpen, setIsOpen] = (0, import_react8.useState)(false);
|
|
36749
|
+
const [inputValue, setInputValue] = (0, import_react8.useState)("");
|
|
36750
|
+
const [options, setOptions] = (0, import_react8.useState)(
|
|
36758
36751
|
[]
|
|
36759
36752
|
);
|
|
36760
|
-
const [dropdownPos, setDropdownPos] = (0,
|
|
36761
|
-
(0,
|
|
36753
|
+
const [dropdownPos, setDropdownPos] = (0, import_react8.useState)({ left: 0, width: 0 });
|
|
36754
|
+
(0, import_react8.useEffect)(() => {
|
|
36762
36755
|
if (isOpen && containerRef.current) {
|
|
36763
36756
|
const rect = containerRef.current.getBoundingClientRect();
|
|
36764
36757
|
const spaceBelow = window.innerHeight - rect.bottom;
|
|
@@ -36780,23 +36773,23 @@ function Select({
|
|
|
36780
36773
|
}
|
|
36781
36774
|
}
|
|
36782
36775
|
}, [isOpen]);
|
|
36783
|
-
const [filtered, setFiltered] = (0,
|
|
36776
|
+
const [filtered, setFiltered] = (0, import_react8.useState)(
|
|
36784
36777
|
[]
|
|
36785
36778
|
);
|
|
36786
|
-
const [hasEdition, setHasEdition] = (0,
|
|
36787
|
-
const [highlightedIndex, setHighlightedIndex] = (0,
|
|
36788
|
-
const inputRef = (0,
|
|
36779
|
+
const [hasEdition, setHasEdition] = (0, import_react8.useState)(false);
|
|
36780
|
+
const [highlightedIndex, setHighlightedIndex] = (0, import_react8.useState)(-1);
|
|
36781
|
+
const inputRef = (0, import_react8.useRef)(null);
|
|
36789
36782
|
const validOption = (value) => {
|
|
36790
36783
|
return options.find((opt) => opt.label == value);
|
|
36791
36784
|
};
|
|
36792
36785
|
const normalize = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z]/g, "");
|
|
36793
|
-
(0,
|
|
36786
|
+
(0, import_react8.useEffect)(() => {
|
|
36794
36787
|
var _a;
|
|
36795
|
-
const parsedOptions =
|
|
36788
|
+
const parsedOptions = import_react8.default.Children.toArray(children).filter((child) => {
|
|
36796
36789
|
return child.type === "option";
|
|
36797
36790
|
}).map((child) => {
|
|
36798
36791
|
var _a2;
|
|
36799
|
-
const label2 =
|
|
36792
|
+
const label2 = import_react8.default.Children.toArray(child.props.children).join("");
|
|
36800
36793
|
return {
|
|
36801
36794
|
value: ((_a2 = child.props) == null ? void 0 : _a2.value) || label2,
|
|
36802
36795
|
label: label2
|
|
@@ -36807,7 +36800,7 @@ function Select({
|
|
|
36807
36800
|
const value = (props == null ? void 0 : props.value) ? ((_a = parsedOptions.find((opt) => opt.value == props.value)) == null ? void 0 : _a.label) || "" : "";
|
|
36808
36801
|
setInputValue(value);
|
|
36809
36802
|
}, [children]);
|
|
36810
|
-
(0,
|
|
36803
|
+
(0, import_react8.useEffect)(() => {
|
|
36811
36804
|
const items = options.filter((opt) => {
|
|
36812
36805
|
if (!hasEdition) return true;
|
|
36813
36806
|
const normilizedLabel = normalize(`${opt == null ? void 0 : opt.label}`);
|
|
@@ -36836,9 +36829,9 @@ function Select({
|
|
|
36836
36829
|
setInputValue(v);
|
|
36837
36830
|
setIsOpen(false);
|
|
36838
36831
|
};
|
|
36839
|
-
const containerRef = (0,
|
|
36840
|
-
const [openUpwards, setOpenUpwards] = (0,
|
|
36841
|
-
(0,
|
|
36832
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
36833
|
+
const [openUpwards, setOpenUpwards] = (0, import_react8.useState)(false);
|
|
36834
|
+
(0, import_react8.useEffect)(() => {
|
|
36842
36835
|
if (isOpen && containerRef.current) {
|
|
36843
36836
|
const rect = containerRef.current.getBoundingClientRect();
|
|
36844
36837
|
const spaceBelow = window.innerHeight - rect.bottom;
|
|
@@ -36981,10 +36974,10 @@ function Select({
|
|
|
36981
36974
|
}
|
|
36982
36975
|
|
|
36983
36976
|
// src/modal/index.tsx
|
|
36984
|
-
var
|
|
36977
|
+
var import_react10 = require("react");
|
|
36985
36978
|
|
|
36986
36979
|
// src/pop/index.tsx
|
|
36987
|
-
var
|
|
36980
|
+
var import_react9 = require("react");
|
|
36988
36981
|
|
|
36989
36982
|
// src/pop/actions.tsx
|
|
36990
36983
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
@@ -37221,9 +37214,9 @@ var INITIAL_STATE = {
|
|
|
37221
37214
|
full: false
|
|
37222
37215
|
};
|
|
37223
37216
|
function usePopup() {
|
|
37224
|
-
const [popup, setPopup] = (0,
|
|
37225
|
-
const messageRef = (0,
|
|
37226
|
-
const open = (0,
|
|
37217
|
+
const [popup, setPopup] = (0, import_react9.useState)(INITIAL_STATE);
|
|
37218
|
+
const messageRef = (0, import_react9.useRef)(null);
|
|
37219
|
+
const open = (0, import_react9.useCallback)(
|
|
37227
37220
|
(partial) => {
|
|
37228
37221
|
const { message, ...rest } = partial;
|
|
37229
37222
|
messageRef.current = message;
|
|
@@ -37231,7 +37224,7 @@ function usePopup() {
|
|
|
37231
37224
|
},
|
|
37232
37225
|
[]
|
|
37233
37226
|
);
|
|
37234
|
-
const close = (0,
|
|
37227
|
+
const close = (0, import_react9.useCallback)(
|
|
37235
37228
|
async (confirmed, value) => {
|
|
37236
37229
|
var _a, _b, _c;
|
|
37237
37230
|
const prev = { ...popup };
|
|
@@ -37249,7 +37242,7 @@ function usePopup() {
|
|
|
37249
37242
|
},
|
|
37250
37243
|
[popup]
|
|
37251
37244
|
);
|
|
37252
|
-
const alert2 = (0,
|
|
37245
|
+
const alert2 = (0, import_react9.useCallback)(
|
|
37253
37246
|
(message, color = "primary") => new Promise(
|
|
37254
37247
|
(resolve) => open({
|
|
37255
37248
|
type: "alert",
|
|
@@ -37261,7 +37254,7 @@ function usePopup() {
|
|
|
37261
37254
|
),
|
|
37262
37255
|
[open]
|
|
37263
37256
|
);
|
|
37264
|
-
const modal = (0,
|
|
37257
|
+
const modal = (0, import_react9.useCallback)(
|
|
37265
37258
|
(message, color = "primary", icons = false, full = false, onClose) => new Promise(
|
|
37266
37259
|
(resolve) => open({
|
|
37267
37260
|
type: "modal",
|
|
@@ -37278,7 +37271,7 @@ function usePopup() {
|
|
|
37278
37271
|
),
|
|
37279
37272
|
[open]
|
|
37280
37273
|
);
|
|
37281
|
-
const confirm = (0,
|
|
37274
|
+
const confirm = (0, import_react9.useCallback)(
|
|
37282
37275
|
(message, color = "primary") => new Promise(
|
|
37283
37276
|
(resolve) => open({
|
|
37284
37277
|
type: "confirm",
|
|
@@ -37290,7 +37283,7 @@ function usePopup() {
|
|
|
37290
37283
|
),
|
|
37291
37284
|
[open]
|
|
37292
37285
|
);
|
|
37293
|
-
const prompt = (0,
|
|
37286
|
+
const prompt = (0, import_react9.useCallback)(
|
|
37294
37287
|
(message, color = "primary") => new Promise(
|
|
37295
37288
|
(resolve) => open({
|
|
37296
37289
|
type: "prompt",
|
|
@@ -37302,7 +37295,7 @@ function usePopup() {
|
|
|
37302
37295
|
),
|
|
37303
37296
|
[open]
|
|
37304
37297
|
);
|
|
37305
|
-
const updateMessage = (0,
|
|
37298
|
+
const updateMessage = (0, import_react9.useCallback)((message) => {
|
|
37306
37299
|
messageRef.current = message;
|
|
37307
37300
|
setPopup((prev) => ({ ...prev }));
|
|
37308
37301
|
}, []);
|
|
@@ -37338,17 +37331,17 @@ function Modal({
|
|
|
37338
37331
|
const hide = () => {
|
|
37339
37332
|
pop.close(false);
|
|
37340
37333
|
};
|
|
37341
|
-
const childrenWithHide = (0,
|
|
37342
|
-
() => (0,
|
|
37334
|
+
const childrenWithHide = (0, import_react10.useMemo)(
|
|
37335
|
+
() => (0, import_react10.cloneElement)(children, { hide }),
|
|
37343
37336
|
[children]
|
|
37344
37337
|
);
|
|
37345
|
-
(0,
|
|
37338
|
+
(0, import_react10.useEffect)(() => {
|
|
37346
37339
|
pop.updateMessage(childrenWithHide);
|
|
37347
37340
|
}, [childrenWithHide]);
|
|
37348
37341
|
const props = button == null ? void 0 : button.props;
|
|
37349
37342
|
const onClick = props == null ? void 0 : props.onClick;
|
|
37350
37343
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "", children: [
|
|
37351
|
-
(0,
|
|
37344
|
+
(0, import_react10.cloneElement)(button, {
|
|
37352
37345
|
onClick: (e) => {
|
|
37353
37346
|
onClick == null ? void 0 : onClick(e);
|
|
37354
37347
|
pop.modal(childrenWithHide, color, false, true, onClose);
|
|
@@ -37407,7 +37400,7 @@ function useDates() {
|
|
|
37407
37400
|
}
|
|
37408
37401
|
|
|
37409
37402
|
// src/calendar/index.tsx
|
|
37410
|
-
var
|
|
37403
|
+
var import_react11 = require("react");
|
|
37411
37404
|
var import_react_datepicker = __toESM(require("react-datepicker"));
|
|
37412
37405
|
|
|
37413
37406
|
// src/calendar/calendar.icon.tsx
|
|
@@ -37440,11 +37433,11 @@ function MyCalendar({
|
|
|
37440
37433
|
value,
|
|
37441
37434
|
...otherProps
|
|
37442
37435
|
}) {
|
|
37443
|
-
const [selectedDate, setSelectedDate] = (0,
|
|
37444
|
-
const [dateStr, setDateStr] = (0,
|
|
37436
|
+
const [selectedDate, setSelectedDate] = (0, import_react11.useState)(null);
|
|
37437
|
+
const [dateStr, setDateStr] = (0, import_react11.useState)(
|
|
37445
37438
|
defaultValue || value || ""
|
|
37446
37439
|
);
|
|
37447
|
-
const [open, setOpen] = (0,
|
|
37440
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
37448
37441
|
function handleChange(date) {
|
|
37449
37442
|
if (!date) return;
|
|
37450
37443
|
setSelectedDate(date);
|
|
@@ -37633,10 +37626,10 @@ function DocumentViewer({
|
|
|
37633
37626
|
}
|
|
37634
37627
|
|
|
37635
37628
|
// src/table3/index.tsx
|
|
37636
|
-
var
|
|
37629
|
+
var import_react16 = __toESM(require("react"));
|
|
37637
37630
|
|
|
37638
37631
|
// src/table3/filter.tsx
|
|
37639
|
-
var
|
|
37632
|
+
var import_react12 = require("react");
|
|
37640
37633
|
|
|
37641
37634
|
// src/table3/filters.tsx
|
|
37642
37635
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
@@ -37746,14 +37739,14 @@ function Filter({
|
|
|
37746
37739
|
sort,
|
|
37747
37740
|
setSort
|
|
37748
37741
|
}) {
|
|
37749
|
-
const [visible, setVisible] = (0,
|
|
37750
|
-
const [text, setText] = (0,
|
|
37751
|
-
const items = (0,
|
|
37742
|
+
const [visible, setVisible] = (0, import_react12.useState)(false);
|
|
37743
|
+
const [text, setText] = (0, import_react12.useState)("");
|
|
37744
|
+
const items = (0, import_react12.useMemo)(
|
|
37752
37745
|
() => [...new Set(Object.values(objectData).map((o) => o[h]))],
|
|
37753
37746
|
[objectData]
|
|
37754
37747
|
);
|
|
37755
|
-
const [selected, setSelected] = (0,
|
|
37756
|
-
const itemsFiltered = (0,
|
|
37748
|
+
const [selected, setSelected] = (0, import_react12.useState)(items);
|
|
37749
|
+
const itemsFiltered = (0, import_react12.useMemo)(
|
|
37757
37750
|
() => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
|
|
37758
37751
|
if (!text) return true;
|
|
37759
37752
|
return `${item}`.toLowerCase().includes(text.toLowerCase());
|
|
@@ -37790,7 +37783,7 @@ function Filter({
|
|
|
37790
37783
|
const hidden = Object.values(objectData).filter(
|
|
37791
37784
|
(d) => d._visible === false
|
|
37792
37785
|
);
|
|
37793
|
-
(0,
|
|
37786
|
+
(0, import_react12.useEffect)(() => {
|
|
37794
37787
|
if (data.length != Object.values(objectData).map((o) => (o == null ? void 0 : o._id) || (o == null ? void 0 : o.id)).length) {
|
|
37795
37788
|
const news = [...new Set(data.map((o) => o[h]))];
|
|
37796
37789
|
setSelected(news);
|
|
@@ -38041,10 +38034,10 @@ function TableHead({
|
|
|
38041
38034
|
}
|
|
38042
38035
|
|
|
38043
38036
|
// src/table3/body.tsx
|
|
38044
|
-
var
|
|
38037
|
+
var import_react14 = require("react");
|
|
38045
38038
|
|
|
38046
38039
|
// src/table3/tr.tsx
|
|
38047
|
-
var
|
|
38040
|
+
var import_react13 = __toESM(require("react"));
|
|
38048
38041
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
38049
38042
|
function TR({
|
|
38050
38043
|
handlers,
|
|
@@ -38106,7 +38099,7 @@ function TR({
|
|
|
38106
38099
|
return null;
|
|
38107
38100
|
} else if (handlers == null ? void 0 : handlers[h]) {
|
|
38108
38101
|
const original = handlers[h];
|
|
38109
|
-
const cloned =
|
|
38102
|
+
const cloned = import_react13.default.cloneElement(original, {
|
|
38110
38103
|
// si es controlado por value → actualiza con row[h]
|
|
38111
38104
|
value: ((_a = original.props) == null ? void 0 : _a.value) !== void 0 ? row[h] : void 0,
|
|
38112
38105
|
// si usa children → actualiza con row[h] también
|
|
@@ -38186,7 +38179,7 @@ function TableBody({
|
|
|
38186
38179
|
symbols,
|
|
38187
38180
|
sort
|
|
38188
38181
|
}) {
|
|
38189
|
-
const [selected, setSelected] = (0,
|
|
38182
|
+
const [selected, setSelected] = (0, import_react14.useState)(-1);
|
|
38190
38183
|
const sorted = Object.entries(objectData).sort(([, a], [, b]) => {
|
|
38191
38184
|
for (const [key, order] of Object.entries(
|
|
38192
38185
|
sort || { id: "desc", _id: "desc" }
|
|
@@ -38362,7 +38355,7 @@ function TableFooter({
|
|
|
38362
38355
|
}
|
|
38363
38356
|
|
|
38364
38357
|
// src/table3/dialog.tsx
|
|
38365
|
-
var
|
|
38358
|
+
var import_react15 = __toESM(require("react"));
|
|
38366
38359
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
38367
38360
|
function Dialog3({
|
|
38368
38361
|
modalRef,
|
|
@@ -38379,9 +38372,9 @@ function Dialog3({
|
|
|
38379
38372
|
var _a;
|
|
38380
38373
|
return (_a = modalRef.current) == null ? void 0 : _a.close();
|
|
38381
38374
|
};
|
|
38382
|
-
const clonedModal = (0,
|
|
38383
|
-
if (dialogRow &&
|
|
38384
|
-
return
|
|
38375
|
+
const clonedModal = (0, import_react15.useMemo)(() => {
|
|
38376
|
+
if (dialogRow && import_react15.default.isValidElement(children)) {
|
|
38377
|
+
return import_react15.default.cloneElement(children, {
|
|
38385
38378
|
key: JSON.stringify(dialogRow),
|
|
38386
38379
|
row: dialogRow,
|
|
38387
38380
|
show,
|
|
@@ -38435,8 +38428,8 @@ function Table3({
|
|
|
38435
38428
|
sortBy,
|
|
38436
38429
|
...props
|
|
38437
38430
|
}) {
|
|
38438
|
-
const [handlers, setHandlers] = (0,
|
|
38439
|
-
const [page, setPage] = (0,
|
|
38431
|
+
const [handlers, setHandlers] = (0, import_react16.useState)({});
|
|
38432
|
+
const [page, setPage] = (0, import_react16.useState)(1);
|
|
38440
38433
|
function dataReducer(a, b) {
|
|
38441
38434
|
if (b == null) return {};
|
|
38442
38435
|
if (Array.isArray(b)) {
|
|
@@ -38457,7 +38450,7 @@ function Table3({
|
|
|
38457
38450
|
};
|
|
38458
38451
|
const newHandlers = { ...handlers };
|
|
38459
38452
|
for (let item in cc) {
|
|
38460
|
-
const isReactComponent =
|
|
38453
|
+
const isReactComponent = import_react16.default.isValidElement(cc[item]);
|
|
38461
38454
|
if (isReactComponent) {
|
|
38462
38455
|
newHandlers[item] = cc[item];
|
|
38463
38456
|
const value = ((_c = (_b = cc[item]) == null ? void 0 : _b.props) == null ? void 0 : _c.value) || (typeof ((_e = (_d = cc[item]) == null ? void 0 : _d.props) == null ? void 0 : _e.children) !== "object" ? (_g = (_f = cc[item]) == null ? void 0 : _f.props) == null ? void 0 : _g.children : "");
|
|
@@ -38477,12 +38470,12 @@ function Table3({
|
|
|
38477
38470
|
return newA;
|
|
38478
38471
|
}
|
|
38479
38472
|
}
|
|
38480
|
-
const [objectData, setObjectData] = (0,
|
|
38481
|
-
(0,
|
|
38473
|
+
const [objectData, setObjectData] = (0, import_react16.useReducer)(dataReducer, null);
|
|
38474
|
+
(0, import_react16.useEffect)(() => {
|
|
38482
38475
|
setObjectData(data);
|
|
38483
38476
|
setPage(1);
|
|
38484
38477
|
}, [data]);
|
|
38485
|
-
const headers = (0,
|
|
38478
|
+
const headers = (0, import_react16.useMemo)(() => {
|
|
38486
38479
|
if (!objectData) return [];
|
|
38487
38480
|
return [
|
|
38488
38481
|
...new Set(
|
|
@@ -38490,13 +38483,13 @@ function Table3({
|
|
|
38490
38483
|
)
|
|
38491
38484
|
];
|
|
38492
38485
|
}, [objectData]);
|
|
38493
|
-
const totalPages = (0,
|
|
38486
|
+
const totalPages = (0, import_react16.useMemo)(() => {
|
|
38494
38487
|
if (!objectData) return 0;
|
|
38495
38488
|
return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
|
|
38496
38489
|
}, [objectData, maxItems]);
|
|
38497
|
-
const [sort, setSort] = (0,
|
|
38498
|
-
const modalRef = (0,
|
|
38499
|
-
const [dialogRow, setDialogRow] = (0,
|
|
38490
|
+
const [sort, setSort] = (0, import_react16.useState)(sortBy);
|
|
38491
|
+
const modalRef = (0, import_react16.useRef)(null);
|
|
38492
|
+
const [dialogRow, setDialogRow] = (0, import_react16.useState)({});
|
|
38500
38493
|
const context = {
|
|
38501
38494
|
objectData,
|
|
38502
38495
|
headers,
|
|
@@ -38523,7 +38516,7 @@ function Table3({
|
|
|
38523
38516
|
setSort,
|
|
38524
38517
|
...props
|
|
38525
38518
|
};
|
|
38526
|
-
(0,
|
|
38519
|
+
(0, import_react16.useEffect)(() => {
|
|
38527
38520
|
if ((dialogRow == null ? void 0 : dialogRow.id) || (dialogRow == null ? void 0 : dialogRow._id)) {
|
|
38528
38521
|
const newDialogRow = objectData[dialogRow == null ? void 0 : dialogRow.id] || objectData[dialogRow == null ? void 0 : dialogRow._id];
|
|
38529
38522
|
setDialogRow(newDialogRow);
|
|
@@ -38553,13 +38546,13 @@ function Table3({
|
|
|
38553
38546
|
}
|
|
38554
38547
|
|
|
38555
38548
|
// src/table-advanced/index.tsx
|
|
38556
|
-
var
|
|
38549
|
+
var import_react21 = require("react");
|
|
38557
38550
|
|
|
38558
38551
|
// src/table-advanced/h.table.tsx
|
|
38559
|
-
var
|
|
38552
|
+
var import_react19 = __toESM(require("react"));
|
|
38560
38553
|
|
|
38561
38554
|
// src/table-advanced/header.tsx
|
|
38562
|
-
var
|
|
38555
|
+
var import_react17 = require("react");
|
|
38563
38556
|
var import_react_dom = require("react-dom");
|
|
38564
38557
|
|
|
38565
38558
|
// src/table-advanced/icons.tsx
|
|
@@ -38813,32 +38806,32 @@ function Header({
|
|
|
38813
38806
|
index,
|
|
38814
38807
|
length
|
|
38815
38808
|
}) {
|
|
38816
|
-
const [visible, setVisible] = (0,
|
|
38817
|
-
const [hovered, setHovered] = (0,
|
|
38809
|
+
const [visible, setVisible] = (0, import_react17.useState)(false);
|
|
38810
|
+
const [hovered, setHovered] = (0, import_react17.useState)(false);
|
|
38818
38811
|
const sortIndex = context.sort.findIndex((b) => b.field == header);
|
|
38819
|
-
const [text, setText] = (0,
|
|
38820
|
-
const cellRef = (0,
|
|
38821
|
-
const [coords, setCoords] = (0,
|
|
38812
|
+
const [text, setText] = (0, import_react17.useState)("");
|
|
38813
|
+
const cellRef = (0, import_react17.useRef)(null);
|
|
38814
|
+
const [coords, setCoords] = (0, import_react17.useState)(
|
|
38822
38815
|
null
|
|
38823
38816
|
);
|
|
38824
|
-
const filteredValues = (0,
|
|
38817
|
+
const filteredValues = (0, import_react17.useMemo)(() => {
|
|
38825
38818
|
return [...new Set(context.data.map((d) => d[header]))].filter((d) => {
|
|
38826
38819
|
if (text == "") return true;
|
|
38827
38820
|
return `${d}`.toLowerCase().includes(text.toLowerCase());
|
|
38828
38821
|
});
|
|
38829
38822
|
}, [context.data, header, text]);
|
|
38830
|
-
const [selected, setSelected] = (0,
|
|
38823
|
+
const [selected, setSelected] = (0, import_react17.useState)([]);
|
|
38831
38824
|
const hasFilter = context.filters.find((b) => b.field == header);
|
|
38832
|
-
(0,
|
|
38825
|
+
(0, import_react17.useEffect)(() => {
|
|
38833
38826
|
setSelected(filteredValues);
|
|
38834
38827
|
}, [filteredValues]);
|
|
38835
|
-
(0,
|
|
38828
|
+
(0, import_react17.useEffect)(() => {
|
|
38836
38829
|
if (visible) {
|
|
38837
38830
|
context.setCurrentHeader(header);
|
|
38838
38831
|
}
|
|
38839
38832
|
setText("");
|
|
38840
38833
|
}, [visible]);
|
|
38841
|
-
(0,
|
|
38834
|
+
(0, import_react17.useEffect)(() => {
|
|
38842
38835
|
if (!visible || !cellRef.current) {
|
|
38843
38836
|
setCoords(null);
|
|
38844
38837
|
return;
|
|
@@ -39177,39 +39170,39 @@ function valueFormatter({
|
|
|
39177
39170
|
}
|
|
39178
39171
|
|
|
39179
39172
|
// src/table-advanced/use.pagination.tsx
|
|
39180
|
-
var
|
|
39173
|
+
var import_react18 = require("react");
|
|
39181
39174
|
function usePaginacion({
|
|
39182
39175
|
total,
|
|
39183
39176
|
tamanioPagina = 100,
|
|
39184
39177
|
paginaInicial = 1
|
|
39185
39178
|
}) {
|
|
39186
|
-
const [totalPaginas, setTotalPaginas] = (0,
|
|
39179
|
+
const [totalPaginas, setTotalPaginas] = (0, import_react18.useState)(
|
|
39187
39180
|
Math.max(1, Math.ceil(total / tamanioPagina))
|
|
39188
39181
|
);
|
|
39189
|
-
const [pagina, setPagina] = (0,
|
|
39182
|
+
const [pagina, setPagina] = (0, import_react18.useState)(
|
|
39190
39183
|
Math.min(Math.max(paginaInicial, 1), totalPaginas)
|
|
39191
39184
|
);
|
|
39192
39185
|
const inicio = total === 0 ? 0 : (pagina - 1) * tamanioPagina + 1;
|
|
39193
39186
|
const fin = Math.min(pagina * tamanioPagina, total);
|
|
39194
|
-
const rango = (0,
|
|
39187
|
+
const rango = (0, import_react18.useMemo)(() => {
|
|
39195
39188
|
if (total === 0) return "0 a 0";
|
|
39196
39189
|
return `${inicio} a ${fin}`;
|
|
39197
39190
|
}, [inicio, fin, total]);
|
|
39198
39191
|
const hasNext = pagina < totalPaginas;
|
|
39199
39192
|
const hasPrev = pagina > 1;
|
|
39200
|
-
const next = (0,
|
|
39193
|
+
const next = (0, import_react18.useCallback)(() => {
|
|
39201
39194
|
setPagina((p) => Math.min(p + 1, totalPaginas));
|
|
39202
39195
|
}, [totalPaginas]);
|
|
39203
|
-
const prev = (0,
|
|
39196
|
+
const prev = (0, import_react18.useCallback)(() => {
|
|
39204
39197
|
setPagina((p) => Math.max(p - 1, 1));
|
|
39205
39198
|
}, []);
|
|
39206
|
-
const irAPagina = (0,
|
|
39199
|
+
const irAPagina = (0, import_react18.useCallback)(
|
|
39207
39200
|
(n) => {
|
|
39208
39201
|
setPagina(Math.min(Math.max(n, 1), totalPaginas));
|
|
39209
39202
|
},
|
|
39210
39203
|
[totalPaginas]
|
|
39211
39204
|
);
|
|
39212
|
-
(0,
|
|
39205
|
+
(0, import_react18.useEffect)(() => {
|
|
39213
39206
|
setTotalPaginas(Math.max(1, Math.ceil(total / tamanioPagina)));
|
|
39214
39207
|
setPagina(1);
|
|
39215
39208
|
}, [total]);
|
|
@@ -39234,11 +39227,11 @@ var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
|
39234
39227
|
function HTable({
|
|
39235
39228
|
context
|
|
39236
39229
|
}) {
|
|
39237
|
-
const [isLoading, setIsloading] = (0,
|
|
39230
|
+
const [isLoading, setIsloading] = (0, import_react19.useState)(false);
|
|
39238
39231
|
const { cols, headers } = context;
|
|
39239
|
-
const [currentIndex, setCurrentIndex] = (0,
|
|
39240
|
-
const tableRef = (0,
|
|
39241
|
-
const modalRef = (0,
|
|
39232
|
+
const [currentIndex, setCurrentIndex] = (0, import_react19.useState)(-1);
|
|
39233
|
+
const tableRef = (0, import_react19.useRef)(null);
|
|
39234
|
+
const modalRef = (0, import_react19.useRef)(null);
|
|
39242
39235
|
const catDensities = { confortable: 80, compact: 30, standard: 53 };
|
|
39243
39236
|
const padding = (context == null ? void 0 : context.rowHeight) || (context == null ? void 0 : context.density) ? catDensities[context == null ? void 0 : context.density] : 53;
|
|
39244
39237
|
function useResizableColumns(headers2, defaultWidth = 160, minWidth = 60) {
|
|
@@ -39251,8 +39244,8 @@ function HTable({
|
|
|
39251
39244
|
function resize(headers3) {
|
|
39252
39245
|
return Object.fromEntries(headers3.map((h) => [h, getWidth(h)]));
|
|
39253
39246
|
}
|
|
39254
|
-
const [widths2, setWidths2] = (0,
|
|
39255
|
-
const startDrag2 = (0,
|
|
39247
|
+
const [widths2, setWidths2] = (0, import_react19.useState)({});
|
|
39248
|
+
const startDrag2 = (0, import_react19.useCallback)(
|
|
39256
39249
|
(e, headerKey) => {
|
|
39257
39250
|
var _a;
|
|
39258
39251
|
e.preventDefault();
|
|
@@ -39287,7 +39280,7 @@ function HTable({
|
|
|
39287
39280
|
return { widths: widths2, gridTemplateColumns: gridTemplateColumns2, startDrag: startDrag2, setWidths: setWidths2 };
|
|
39288
39281
|
}
|
|
39289
39282
|
const { gridTemplateColumns, startDrag, widths, setWidths } = useResizableColumns(headers);
|
|
39290
|
-
(0,
|
|
39283
|
+
(0, import_react19.useEffect)(() => {
|
|
39291
39284
|
if (!tableRef.current) return;
|
|
39292
39285
|
const observer = new ResizeObserver(([entry]) => {
|
|
39293
39286
|
const ocultos = headers.filter(
|
|
@@ -39318,7 +39311,7 @@ function HTable({
|
|
|
39318
39311
|
observer.observe(tableRef.current);
|
|
39319
39312
|
return () => observer.disconnect();
|
|
39320
39313
|
}, [headers.length]);
|
|
39321
|
-
const searchedData = (0,
|
|
39314
|
+
const searchedData = (0, import_react19.useMemo)(() => {
|
|
39322
39315
|
return context.filteredData.filter((row) => {
|
|
39323
39316
|
if (context.searchBy === "") return true;
|
|
39324
39317
|
return Object.values(row).some(
|
|
@@ -39538,7 +39531,7 @@ function HTable({
|
|
|
39538
39531
|
context.setEditions(newEditions);
|
|
39539
39532
|
}
|
|
39540
39533
|
}
|
|
39541
|
-
) : ((_c = context.buttons) == null ? void 0 : _c[key]) ?
|
|
39534
|
+
) : ((_c = context.buttons) == null ? void 0 : _c[key]) ? import_react19.default.cloneElement(context.buttons[key], {
|
|
39542
39535
|
// children: context.buttons[key]?.props?.children
|
|
39543
39536
|
// ? item
|
|
39544
39537
|
// : undefined,
|
|
@@ -39582,7 +39575,7 @@ function HTable({
|
|
|
39582
39575
|
}) : ["number", "string"].includes(typeof item) ? valueFormatter({
|
|
39583
39576
|
value: item,
|
|
39584
39577
|
currentCoin: context.currentCoin
|
|
39585
|
-
}) :
|
|
39578
|
+
}) : import_react19.default.isValidElement(item) ? item : JSON.stringify(item)
|
|
39586
39579
|
},
|
|
39587
39580
|
row.id + i
|
|
39588
39581
|
);
|
|
@@ -39717,7 +39710,7 @@ function ModalContent({
|
|
|
39717
39710
|
}
|
|
39718
39711
|
)
|
|
39719
39712
|
] }),
|
|
39720
|
-
|
|
39713
|
+
import_react19.default.cloneElement(context.modal, {
|
|
39721
39714
|
row: searchedData[currentIndex],
|
|
39722
39715
|
hide
|
|
39723
39716
|
})
|
|
@@ -39725,7 +39718,7 @@ function ModalContent({
|
|
|
39725
39718
|
}
|
|
39726
39719
|
|
|
39727
39720
|
// src/table-advanced/context.ts
|
|
39728
|
-
var
|
|
39721
|
+
var import_react20 = require("react");
|
|
39729
39722
|
|
|
39730
39723
|
// src/table-advanced/filter.reducer.ts
|
|
39731
39724
|
var filterReducer = (acc, b) => {
|
|
@@ -39753,19 +39746,19 @@ var sortReducer = (acc, b) => {
|
|
|
39753
39746
|
// src/table-advanced/context.ts
|
|
39754
39747
|
function useContext({ onSelect }) {
|
|
39755
39748
|
const excel = useExcel();
|
|
39756
|
-
const [editions, setEditions] = (0,
|
|
39757
|
-
const [selected, setSelected] = (0,
|
|
39758
|
-
const [data, setData] = (0,
|
|
39749
|
+
const [editions, setEditions] = (0, import_react20.useState)([]);
|
|
39750
|
+
const [selected, setSelected] = (0, import_react20.useState)([]);
|
|
39751
|
+
const [data, setData] = (0, import_react20.useState)([]);
|
|
39759
39752
|
const headers = [...new Set(data.map((b) => Object.keys(b)).flat())];
|
|
39760
|
-
const [currentHeader, setCurrentHeader] = (0,
|
|
39753
|
+
const [currentHeader, setCurrentHeader] = (0, import_react20.useState)(null);
|
|
39761
39754
|
const cols = headers.length;
|
|
39762
|
-
const [filters, setFilters] = (0,
|
|
39755
|
+
const [filters, setFilters] = (0, import_react20.useReducer)(
|
|
39763
39756
|
filterReducer,
|
|
39764
39757
|
new Array()
|
|
39765
39758
|
);
|
|
39766
|
-
const [searchBy, setSearchBy] = (0,
|
|
39767
|
-
const [sort, setSort] = (0,
|
|
39768
|
-
const sortedData = (0,
|
|
39759
|
+
const [searchBy, setSearchBy] = (0, import_react20.useState)("");
|
|
39760
|
+
const [sort, setSort] = (0, import_react20.useReducer)(sortReducer, new Array());
|
|
39761
|
+
const sortedData = (0, import_react20.useMemo)(() => {
|
|
39769
39762
|
return [...data].sort((a, b) => {
|
|
39770
39763
|
for (const { field, type } of sort.reverse()) {
|
|
39771
39764
|
const av = a[field];
|
|
@@ -39795,7 +39788,7 @@ function useContext({ onSelect }) {
|
|
|
39795
39788
|
}
|
|
39796
39789
|
return true;
|
|
39797
39790
|
});
|
|
39798
|
-
(0,
|
|
39791
|
+
(0, import_react20.useEffect)(() => {
|
|
39799
39792
|
if (filters.length == 0) {
|
|
39800
39793
|
setEditions([]);
|
|
39801
39794
|
}
|
|
@@ -39828,7 +39821,7 @@ var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
|
39828
39821
|
function TableAdvanced(tableProps) {
|
|
39829
39822
|
const { data, ...props } = tableProps;
|
|
39830
39823
|
const context = useContext({ onSelect: Boolean(tableProps.onSelect) });
|
|
39831
|
-
(0,
|
|
39824
|
+
(0, import_react21.useEffect)(() => {
|
|
39832
39825
|
context.setData(
|
|
39833
39826
|
Array.isArray(data) ? data.map((d) => {
|
|
39834
39827
|
return {
|
|
@@ -39839,7 +39832,7 @@ function TableAdvanced(tableProps) {
|
|
|
39839
39832
|
}) : data
|
|
39840
39833
|
);
|
|
39841
39834
|
}, [data]);
|
|
39842
|
-
(0,
|
|
39835
|
+
(0, import_react21.useEffect)(() => {
|
|
39843
39836
|
if (tableProps == null ? void 0 : tableProps.sortBy) {
|
|
39844
39837
|
const [k, v] = Object.entries(tableProps.sortBy)[0];
|
|
39845
39838
|
context.setSort({ [k]: v });
|
|
@@ -39858,15 +39851,15 @@ function TableAdvanced(tableProps) {
|
|
|
39858
39851
|
}
|
|
39859
39852
|
|
|
39860
39853
|
// src/tabs/index.tsx
|
|
39861
|
-
var
|
|
39854
|
+
var import_react22 = __toESM(require("react"));
|
|
39862
39855
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
39863
39856
|
function TabContainer({
|
|
39864
39857
|
children,
|
|
39865
39858
|
labelMaxWidth,
|
|
39866
39859
|
currentIndex = 0
|
|
39867
39860
|
}) {
|
|
39868
|
-
const [index, setIndex] = (0,
|
|
39869
|
-
const items =
|
|
39861
|
+
const [index, setIndex] = (0, import_react22.useState)(0);
|
|
39862
|
+
const items = import_react22.default.Children.toArray(
|
|
39870
39863
|
children
|
|
39871
39864
|
);
|
|
39872
39865
|
const labels = items.map((c) => c.props.label);
|
|
@@ -39875,7 +39868,7 @@ function TabContainer({
|
|
|
39875
39868
|
if (e.key === "ArrowLeft")
|
|
39876
39869
|
setIndex((k - 1 + labels.length) % labels.length);
|
|
39877
39870
|
};
|
|
39878
|
-
(0,
|
|
39871
|
+
(0, import_react22.useEffect)(() => {
|
|
39879
39872
|
setIndex(currentIndex);
|
|
39880
39873
|
}, [currentIndex]);
|
|
39881
39874
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "w-full bg-white border shadow rounded-lg ", children: [
|