next-recomponents 2.0.39 → 2.0.41

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.mjs CHANGED
@@ -3862,98 +3862,97 @@ function Input({
3862
3862
  className,
3863
3863
  regex,
3864
3864
  invalidMessage = "Valor no v\xE1lido",
3865
+ icon = null,
3865
3866
  ...props
3866
3867
  }) {
3867
3868
  const value = `${(props == null ? void 0 : props.value) || ""}`;
3868
3869
  const isValid = !regex ? true : regex.test(value);
3869
3870
  const isPassword = props.type === "password";
3870
3871
  const [showPassword, setShowPassword] = useState4(false);
3871
- return /* @__PURE__ */ jsxs4("div", { className: "w-full", children: [
3872
- /* @__PURE__ */ jsxs4("label", { className: "flex flex-col gap-1", children: [
3873
- /* @__PURE__ */ jsxs4("div", { className: "font-bold", children: [
3872
+ const svg = icon;
3873
+ return /* @__PURE__ */ jsxs4("div", { className: "w-full relative my-3", children: [
3874
+ /* @__PURE__ */ jsxs4("div", { className: "relative flex items-center border rounded bg-white pr-1 mb-5 w-full", children: [
3875
+ /* @__PURE__ */ jsx5(
3876
+ "input",
3877
+ {
3878
+ ...props,
3879
+ type: isPassword && showPassword ? "text" : props.type,
3880
+ className: [
3881
+ "block p-2 w-full bg-transparent min-w-0",
3882
+ isPassword && "pr-10",
3883
+ value !== "" && !isValid && "bg-red-200 text-black",
3884
+ value !== "" && isValid && "bg-green-200 text-black",
3885
+ className
3886
+ ].filter(Boolean).join(" ")
3887
+ }
3888
+ ),
3889
+ /* @__PURE__ */ jsxs4("label", { className: "absolute -top-2.5 left-2 text-xs font-bold px-1", children: [
3874
3890
  label,
3875
- " ",
3876
- (props == null ? void 0 : props.required) && /* @__PURE__ */ jsx5("span", { className: "text-red-500", children: "*" })
3891
+ (props == null ? void 0 : props.required) && /* @__PURE__ */ jsx5("span", { className: "text-red-500 ml-1", children: "*" })
3877
3892
  ] }),
3878
- /* @__PURE__ */ jsxs4("div", { className: "relative", children: [
3879
- /* @__PURE__ */ jsx5(
3880
- "input",
3881
- {
3882
- ...props,
3883
- type: isPassword && showPassword ? "text" : props.type,
3884
- className: [
3885
- "p-2 w-full rounded border shadow",
3886
- isPassword && "pr-10",
3887
- value !== "" && !isValid && "bg-red-200 text-black",
3888
- value !== "" && isValid && "bg-green-200 text-black",
3889
- className
3890
- ].filter(Boolean).join(" ")
3891
- }
3892
- ),
3893
- isPassword && /* @__PURE__ */ jsx5(
3894
- "button",
3895
- {
3896
- type: "button",
3897
- onClick: () => setShowPassword((prev) => !prev),
3898
- className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-800 focus:outline-none",
3899
- "aria-label": showPassword ? "Ocultar contrase\xF1a" : "Mostrar contrase\xF1a",
3900
- children: showPassword ? (
3901
- // Ojo cerrado (ocultar)
3902
- /* @__PURE__ */ jsx5(
3903
- "svg",
3904
- {
3905
- xmlns: "http://www.w3.org/2000/svg",
3906
- className: "h-5 w-5",
3907
- fill: "none",
3908
- viewBox: "0 0 24 24",
3909
- stroke: "currentColor",
3910
- children: /* @__PURE__ */ jsx5(
3893
+ isPassword ? /* @__PURE__ */ jsx5(
3894
+ "button",
3895
+ {
3896
+ type: "button",
3897
+ onClick: () => setShowPassword((prev) => !prev),
3898
+ className: "absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-800 focus:outline-none",
3899
+ "aria-label": showPassword ? "Ocultar contrase\xF1a" : "Mostrar contrase\xF1a",
3900
+ children: showPassword ? (
3901
+ // Ojo cerrado (ocultar)
3902
+ /* @__PURE__ */ jsx5(
3903
+ "svg",
3904
+ {
3905
+ xmlns: "http://www.w3.org/2000/svg",
3906
+ className: "h-5 w-5",
3907
+ fill: "none",
3908
+ viewBox: "0 0 24 24",
3909
+ stroke: "currentColor",
3910
+ children: /* @__PURE__ */ jsx5(
3911
+ "path",
3912
+ {
3913
+ strokeLinecap: "round",
3914
+ strokeLinejoin: "round",
3915
+ strokeWidth: 2,
3916
+ d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
3917
+ }
3918
+ )
3919
+ }
3920
+ )
3921
+ ) : (
3922
+ // Ojo abierto (mostrar)
3923
+ /* @__PURE__ */ jsxs4(
3924
+ "svg",
3925
+ {
3926
+ xmlns: "http://www.w3.org/2000/svg",
3927
+ className: "h-5 w-5",
3928
+ fill: "none",
3929
+ viewBox: "0 0 24 24",
3930
+ stroke: "currentColor",
3931
+ children: [
3932
+ /* @__PURE__ */ jsx5(
3933
+ "path",
3934
+ {
3935
+ strokeLinecap: "round",
3936
+ strokeLinejoin: "round",
3937
+ strokeWidth: 2,
3938
+ d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
3939
+ }
3940
+ ),
3941
+ /* @__PURE__ */ jsx5(
3911
3942
  "path",
3912
3943
  {
3913
3944
  strokeLinecap: "round",
3914
3945
  strokeLinejoin: "round",
3915
3946
  strokeWidth: 2,
3916
- d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
3947
+ d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
3917
3948
  }
3918
3949
  )
3919
- }
3920
- )
3921
- ) : (
3922
- // Ojo abierto (mostrar)
3923
- /* @__PURE__ */ jsxs4(
3924
- "svg",
3925
- {
3926
- xmlns: "http://www.w3.org/2000/svg",
3927
- className: "h-5 w-5",
3928
- fill: "none",
3929
- viewBox: "0 0 24 24",
3930
- stroke: "currentColor",
3931
- children: [
3932
- /* @__PURE__ */ jsx5(
3933
- "path",
3934
- {
3935
- strokeLinecap: "round",
3936
- strokeLinejoin: "round",
3937
- strokeWidth: 2,
3938
- d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
3939
- }
3940
- ),
3941
- /* @__PURE__ */ jsx5(
3942
- "path",
3943
- {
3944
- strokeLinecap: "round",
3945
- strokeLinejoin: "round",
3946
- strokeWidth: 2,
3947
- d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
3948
- }
3949
- )
3950
- ]
3951
- }
3952
- )
3950
+ ]
3951
+ }
3953
3952
  )
3954
- }
3955
- )
3956
- ] })
3953
+ )
3954
+ }
3955
+ ) : /* @__PURE__ */ jsx5("i", { className: "absulute right-[12px] text-[#3a7bd5] ", children: svg })
3957
3956
  ] }),
3958
3957
  !isValid && value !== "" && /* @__PURE__ */ jsx5("div", { className: "text-red-800 invalid", children: invalidMessage })
3959
3958
  ] });
@@ -36160,41 +36159,38 @@ function TextArea({
36160
36159
  ...props
36161
36160
  }) {
36162
36161
  const [value, setValue] = useState6((props == null ? void 0 : props.value) || "");
36163
- return /* @__PURE__ */ jsx7("div", { className: "w-full", children: /* @__PURE__ */ jsxs6("label", { className: "flex flex-col gap-1", children: [
36164
- /* @__PURE__ */ jsxs6("div", { className: "font-bold ", children: [
36162
+ return /* @__PURE__ */ jsx7("div", { className: "w-full relative my-3", children: /* @__PURE__ */ jsxs6("div", { className: "relative flex items-center border rounded bg-white ", children: [
36163
+ /* @__PURE__ */ jsx7(
36164
+ "textarea",
36165
+ {
36166
+ ...props,
36167
+ className: ["p-1 w-full transparent", className].join(" "),
36168
+ value,
36169
+ onChange: (e) => {
36170
+ if (maxLength) {
36171
+ e.target.value = e.target.value.slice(0, maxLength);
36172
+ }
36173
+ setValue(e.target.value);
36174
+ onChange == null ? void 0 : onChange(e);
36175
+ }
36176
+ }
36177
+ ),
36178
+ " ",
36179
+ /* @__PURE__ */ jsxs6("label", { className: "absolute -top-2.5 left-2 text-xs font-bold px-1", children: [
36165
36180
  label,
36166
36181
  " ",
36167
36182
  (props == null ? void 0 : props.required) && /* @__PURE__ */ jsx7("span", { className: "text-red-500", children: "*" })
36168
36183
  ] }),
36169
- /* @__PURE__ */ jsxs6("div", { children: [
36170
- /* @__PURE__ */ jsx7(
36171
- "textarea",
36172
- {
36173
- ...props,
36174
- className: ["p-1 w-full rounded border shadow", className].join(
36175
- " "
36176
- ),
36177
- value,
36178
- onChange: (e) => {
36179
- if (maxLength) {
36180
- e.target.value = e.target.value.slice(0, maxLength);
36181
- }
36182
- setValue(e.target.value);
36183
- onChange == null ? void 0 : onChange(e);
36184
- }
36185
- }
36186
- ),
36187
- maxLength && /* @__PURE__ */ jsxs6("div", { className: " text-xs text-gray text-right", children: [
36188
- value.length,
36189
- " / ",
36190
- maxLength
36191
- ] })
36184
+ maxLength && /* @__PURE__ */ jsxs6("div", { className: " text-xs text-gray text-right", children: [
36185
+ value.length,
36186
+ " / ",
36187
+ maxLength
36192
36188
  ] })
36193
36189
  ] }) });
36194
36190
  }
36195
36191
 
36196
36192
  // src/use-resources/index.ts
36197
- import { useCallback, useEffect as useEffect4, useRef as useRef2, useState as useState7 } from "react";
36193
+ import { useEffect as useEffect4, useState as useState7 } from "react";
36198
36194
 
36199
36195
  // src/use-resources/get.token.tsx
36200
36196
  import { useMemo as useMemo2 } from "react";
@@ -36285,27 +36281,6 @@ var httpStatusCodes = [
36285
36281
  var http_codes_default = httpStatusCodes;
36286
36282
 
36287
36283
  // src/use-resources/index.ts
36288
- function getErrorMeaning(error) {
36289
- var _a;
36290
- return (_a = http_codes_default.find((s) => s.code === (error == null ? void 0 : error.status))) == null ? void 0 : _a.meaning;
36291
- }
36292
- function mergeDataArray(existing, incoming, matchId) {
36293
- const idx = existing.findIndex((d) => (d == null ? void 0 : d.id) == matchId);
36294
- if (idx >= 0) {
36295
- return existing.map((d, i) => i === idx ? incoming : d);
36296
- }
36297
- return [incoming, ...existing];
36298
- }
36299
- function cloneKey(state, key) {
36300
- var _a;
36301
- return {
36302
- ...state,
36303
- [key]: {
36304
- ...state[key],
36305
- data: ((_a = state[key]) == null ? void 0 : _a.data) ? [...state[key].data] : []
36306
- }
36307
- };
36308
- }
36309
36284
  function useResources({
36310
36285
  baseURI,
36311
36286
  endpoints,
@@ -36313,311 +36288,398 @@ function useResources({
36313
36288
  }) {
36314
36289
  const token = useToken();
36315
36290
  const [info, setInfo] = useState7(
36316
- () => Object.keys(endpoints).reduce((acc, key) => {
36291
+ Object.keys(endpoints).reduce((acc, key) => {
36317
36292
  var _a, _b;
36318
- acc[key] = {
36319
- loaded: false,
36320
- id: (_a = endpoints[key]) == null ? void 0 : _a.id,
36321
- defaultParams: (_b = endpoints[key]) == null ? void 0 : _b.defaultParams,
36322
- data: [],
36323
- selectedItem: {},
36324
- state: "success",
36325
- errorMessage: ""
36326
- };
36327
- return acc;
36328
- }, {})
36329
- );
36330
- const infoRef = useRef2(info);
36331
- useEffect4(() => {
36332
- infoRef.current = info;
36333
- }, [info]);
36334
- const setKeyLoading = useCallback((key) => {
36335
- setInfo((prev) => ({
36336
- ...cloneKey(prev, key),
36337
- [key]: {
36338
- ...cloneKey(prev, key)[key],
36339
- state: "loading",
36340
- errorMessage: ""
36341
- }
36342
- }));
36343
- }, []);
36344
- const setKeyError = useCallback(
36345
- (key, error) => {
36346
- const meaning = getErrorMeaning(error);
36347
- if ((error == null ? void 0 : error.status) === 403) onError == null ? void 0 : onError({ error, errorMessage: meaning });
36348
- setInfo((prev) => ({
36349
- ...cloneKey(prev, key),
36293
+ const newAcc = {
36294
+ ...acc,
36350
36295
  [key]: {
36351
- ...cloneKey(prev, key)[key],
36352
- state: "error",
36353
- errorMessage: meaning || (error == null ? void 0 : error.message)
36296
+ loaded: false,
36297
+ id: (_a = endpoints[key]) == null ? void 0 : _a.id,
36298
+ defaultParams: (_b = endpoints[key]) == null ? void 0 : _b.defaultParams,
36299
+ data: [],
36300
+ selectedItem: {}
36354
36301
  }
36355
- }));
36356
- },
36357
- [onError]
36302
+ };
36303
+ return newAcc;
36304
+ }, {})
36358
36305
  );
36359
- const show = useCallback(
36360
- async (key, { limit = 10, page = 1, merge = true, ...query }) => {
36361
- setInfo((prev) => ({
36362
- ...cloneKey(prev, key),
36363
- [key]: {
36364
- ...cloneKey(prev, key)[key],
36365
- state: "loading",
36366
- errorMessage: "",
36367
- params: query,
36368
- loaded: true
36369
- }
36370
- }));
36371
- try {
36372
- const { data: res } = await axios.get(`${baseURI}/${key}`, {
36306
+ const results = Object.keys(endpoints).reduce(
36307
+ (acc, key) => {
36308
+ var _a, _b, _c, _d, _e, _f, _g;
36309
+ const endpoint = endpoints[key];
36310
+ const showFunc = async ({ limit = 10, page = 1, merge = true, ...query }, autoLoad = false) => {
36311
+ const options = {
36312
+ method: "GET",
36313
+ url: `${baseURI}/${key}`,
36373
36314
  params: { limit, page, ...query },
36374
36315
  headers: { Authorization: token }
36375
- });
36376
- setInfo((prev) => {
36377
- var _a, _b;
36378
- const prevData = (_b = (_a = prev[key]) == null ? void 0 : _a.data) != null ? _b : [];
36379
- const merged = merge ? page === 1 ? res.data : [...prevData, ...res.data] : res.data;
36380
- return {
36381
- ...prev,
36382
- [key]: {
36383
- ...prev[key],
36384
- state: "success",
36385
- errorMessage: "",
36386
- data: merged,
36387
- totalItems: res.totalItems,
36388
- totalPages: res.totalPages,
36389
- currentPage: res.currentPage
36316
+ };
36317
+ const newInfo = { ...info };
36318
+ newInfo[key].state = "loading";
36319
+ newInfo[key].errorMessage = "";
36320
+ newInfo[key].params = query;
36321
+ newInfo[key].loaded = true;
36322
+ setInfo(newInfo);
36323
+ try {
36324
+ const consulta = await axios.request(options);
36325
+ const d = consulta.data;
36326
+ newInfo[key].state = "success";
36327
+ newInfo[key].errorMessage = "";
36328
+ newInfo[key].data = merge ? page == 1 ? d.data : [...d.data, ...newInfo[key].data || []] : d.data;
36329
+ newInfo[key].totalItems = d.totalItems;
36330
+ newInfo[key].totalPages = d.totalPages;
36331
+ newInfo[key].currentPage = d.currentPage;
36332
+ setInfo({ ...newInfo });
36333
+ return d.data;
36334
+ } catch (error) {
36335
+ const item = http_codes_default.find((s) => s.code == error.status);
36336
+ newInfo[key].state = "error";
36337
+ newInfo[key].errorMessage = item == null ? void 0 : item.meaning;
36338
+ if (error.status == 403) {
36339
+ onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
36340
+ }
36341
+ setInfo({ ...newInfo });
36342
+ return error;
36343
+ }
36344
+ };
36345
+ const findFunc = async (id, query) => {
36346
+ var _a2, _b2, _c2;
36347
+ const options = {
36348
+ method: "GET",
36349
+ url: `${baseURI}/${key}/${id}`,
36350
+ params: { ...query },
36351
+ headers: { Authorization: token }
36352
+ };
36353
+ const newInfo = { ...info };
36354
+ newInfo[key].state = "loading";
36355
+ newInfo[key].errorMessage = "";
36356
+ newInfo[key].params = query;
36357
+ newInfo[key].loaded = true;
36358
+ setInfo(newInfo);
36359
+ try {
36360
+ const consulta = await axios.request(options);
36361
+ const d = consulta.data;
36362
+ newInfo[key].state = "success";
36363
+ newInfo[key].errorMessage = "";
36364
+ newInfo[key].selectedItem = d;
36365
+ const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex((d2) => (d2 == null ? void 0 : d2.id) == id);
36366
+ if (index >= 0) {
36367
+ newInfo[key].data[index] = d;
36368
+ } else {
36369
+ if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
36370
+ newInfo[key].data.unshift(d);
36371
+ } else {
36372
+ newInfo[key].data = [d];
36390
36373
  }
36391
- };
36392
- });
36393
- return res.data;
36394
- } catch (error) {
36395
- setKeyError(key, error);
36396
- return error;
36397
- }
36398
- },
36399
- [baseURI, token, setKeyError]
36400
- );
36401
- const find = useCallback(
36402
- async (key, id, query) => {
36403
- setInfo((prev) => ({
36404
- ...cloneKey(prev, key),
36405
- [key]: {
36406
- ...cloneKey(prev, key)[key],
36407
- state: "loading",
36408
- errorMessage: "",
36409
- params: query,
36410
- loaded: true
36374
+ }
36375
+ setInfo({ ...newInfo });
36376
+ return d;
36377
+ } catch (error) {
36378
+ const item = http_codes_default.find((s) => s.code == error.status);
36379
+ newInfo[key].state = "error";
36380
+ newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
36381
+ if (error.status == 403) {
36382
+ onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
36383
+ }
36384
+ setInfo({ ...newInfo });
36385
+ return error;
36411
36386
  }
36412
- }));
36413
- try {
36414
- const { data: d } = await axios.get(`${baseURI}/${key}/${id}`, {
36415
- params: query,
36387
+ };
36388
+ const bodyCreateFunc = async (data) => {
36389
+ var _a2, _b2, _c2, _d2, _e2, _f2;
36390
+ const options = {
36391
+ method: "POST",
36392
+ url: `${baseURI}/${key}`,
36393
+ data: Array.isArray(data) ? [...data] : { ...data },
36416
36394
  headers: { Authorization: token }
36417
- });
36418
- setInfo((prev) => {
36419
- var _a, _b;
36420
- return {
36421
- ...prev,
36422
- [key]: {
36423
- ...prev[key],
36424
- state: "success",
36425
- errorMessage: "",
36426
- selectedItem: d,
36427
- data: mergeDataArray((_b = (_a = prev[key]) == null ? void 0 : _a.data) != null ? _b : [], d, id)
36395
+ };
36396
+ const newInfo = { ...info };
36397
+ newInfo[key].state = "loading";
36398
+ newInfo[key].errorMessage = "";
36399
+ setInfo(newInfo);
36400
+ try {
36401
+ const consulta = await axios.request(options);
36402
+ const d = consulta.data;
36403
+ newInfo[key].state = "success";
36404
+ newInfo[key].errorMessage = "";
36405
+ if (Array.isArray(data)) {
36406
+ for (let datum of data) {
36407
+ const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
36408
+ (d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
36409
+ );
36410
+ if (index >= 0) {
36411
+ newInfo[key].data[index] = d;
36412
+ } else {
36413
+ if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
36414
+ newInfo[key].data.unshift(d);
36415
+ } else {
36416
+ newInfo[key].data = [d];
36417
+ }
36418
+ }
36428
36419
  }
36429
- };
36430
- });
36431
- return d;
36432
- } catch (error) {
36433
- setKeyError(key, error);
36434
- return error;
36435
- }
36436
- },
36437
- [baseURI, token, setKeyError]
36438
- );
36439
- const buildFormData = (data) => {
36440
- const fd = new FormData();
36441
- if (Array.isArray(data)) {
36442
- data.forEach((item, i) => {
36443
- Object.entries(item).forEach(
36444
- ([k, v]) => fd.append(`${k}[${i}]`, v)
36445
- );
36446
- });
36447
- } else {
36448
- Object.entries(data).forEach(([k, v]) => fd.append(k, v));
36449
- }
36450
- return fd;
36451
- };
36452
- const hasFiles = (data) => Array.isArray(data) ? data.some((item) => Object.values(item).some((v) => v instanceof File)) : Object.values(data).some((v) => v instanceof File);
36453
- const create = useCallback(
36454
- async (key, data) => {
36455
- setKeyLoading(key);
36456
- const isForm = hasFiles(data);
36457
- const payload = isForm ? buildFormData(data) : Array.isArray(data) ? [...data] : { ...data };
36458
- const headers = { Authorization: token };
36459
- if (isForm) headers["Content-Type"] = "multipart/form-data";
36460
- try {
36461
- const { data: d } = await axios.post(`${baseURI}/${key}`, payload, {
36462
- headers
36463
- });
36464
- setInfo((prev) => {
36465
- var _a, _b;
36466
- const prevData = (_b = (_a = prev[key]) == null ? void 0 : _a.data) != null ? _b : [];
36467
- const incoming = Array.isArray(d) ? d : [d];
36468
- const updatedData = incoming.reduce(
36469
- (acc, item) => mergeDataArray(acc, item, item == null ? void 0 : item.id),
36470
- [...prevData]
36471
- );
36472
- return {
36473
- ...prev,
36474
- [key]: {
36475
- ...prev[key],
36476
- state: "success",
36477
- errorMessage: "",
36478
- selectedItem: Array.isArray(data) ? prev[key].selectedItem : d,
36479
- data: updatedData
36420
+ newInfo[key].data = newInfo[key].data.flat();
36421
+ } else {
36422
+ newInfo[key].selectedItem = d;
36423
+ const index = (_e2 = (_d2 = newInfo[key]) == null ? void 0 : _d2.data) == null ? void 0 : _e2.findIndex(
36424
+ (d2) => (d2 == null ? void 0 : d2.id) == (data == null ? void 0 : data.id)
36425
+ );
36426
+ if (index >= 0) {
36427
+ newInfo[key].data[index] = d;
36428
+ } else {
36429
+ if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
36430
+ newInfo[key].data.unshift(d);
36431
+ } else {
36432
+ newInfo[key].data = [d];
36433
+ }
36434
+ }
36435
+ }
36436
+ setInfo({ ...newInfo });
36437
+ return d;
36438
+ } catch (error) {
36439
+ const item = http_codes_default.find((s) => s.code == error.status);
36440
+ newInfo[key].state = "error";
36441
+ newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
36442
+ if (error.status == 403) {
36443
+ onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
36444
+ }
36445
+ setInfo({ ...newInfo });
36446
+ return error;
36447
+ }
36448
+ };
36449
+ const formCreateFunc = async (data) => {
36450
+ var _a2, _b2, _c2, _d2, _e2, _f2;
36451
+ const newInfo = { ...info };
36452
+ newInfo[key].state = "loading";
36453
+ newInfo[key].errorMessage = "";
36454
+ setInfo(newInfo);
36455
+ try {
36456
+ const formData = new FormData();
36457
+ if (Array.isArray(data)) {
36458
+ data.forEach((item, i) => {
36459
+ for (const [k, v] of Object.entries(item)) {
36460
+ formData.append(`${k}[${i}]`, v);
36461
+ }
36462
+ });
36463
+ } else {
36464
+ for (const [k, v] of Object.entries(data)) {
36465
+ formData.append(k, v);
36466
+ }
36467
+ }
36468
+ const options = {
36469
+ method: "POST",
36470
+ url: `${baseURI}/${key}`,
36471
+ data: formData,
36472
+ headers: {
36473
+ Authorization: token,
36474
+ "Content-Type": "multipart/form-data"
36480
36475
  }
36481
36476
  };
36482
- });
36483
- return d;
36484
- } catch (error) {
36485
- setKeyError(key, error);
36486
- return error;
36487
- }
36488
- },
36489
- [baseURI, token, setKeyLoading, setKeyError]
36490
- );
36491
- const update = useCallback(
36492
- async (key, id, data) => {
36493
- setKeyLoading(key);
36494
- try {
36495
- const { data: d } = await axios.patch(
36496
- `${baseURI}/${key}/${id}`,
36497
- Array.isArray(data) ? [...data] : { ...data },
36498
- { headers: { Authorization: token } }
36499
- );
36500
- setInfo((prev) => {
36501
- var _a, _b, _c, _d;
36502
- return {
36503
- ...prev,
36504
- [key]: {
36505
- ...prev[key],
36506
- state: "success",
36507
- errorMessage: "",
36508
- selectedItem: { ...prev[key].selectedItem, ...d },
36509
- data: mergeDataArray(
36510
- (_b = (_a = prev[key]) == null ? void 0 : _a.data) != null ? _b : [],
36511
- { ...(_d = (_c = prev[key]) == null ? void 0 : _c.data) == null ? void 0 : _d.find((i) => (i == null ? void 0 : i.id) == id), ...d },
36512
- id
36513
- )
36477
+ const consulta = await axios.request(options);
36478
+ const d = consulta.data;
36479
+ newInfo[key].state = "success";
36480
+ newInfo[key].errorMessage = "";
36481
+ if (Array.isArray(data)) {
36482
+ for (let datum of data) {
36483
+ const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
36484
+ (d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
36485
+ );
36486
+ if (index >= 0) {
36487
+ newInfo[key].data[index] = d;
36488
+ } else {
36489
+ if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
36490
+ newInfo[key].data.unshift(d);
36491
+ } else {
36492
+ newInfo[key].data = [d];
36493
+ }
36494
+ }
36495
+ }
36496
+ newInfo[key].data = newInfo[key].data.flat();
36497
+ } else {
36498
+ newInfo[key].selectedItem = d;
36499
+ const index = (_e2 = (_d2 = newInfo[key]) == null ? void 0 : _d2.data) == null ? void 0 : _e2.findIndex(
36500
+ (d2) => (d2 == null ? void 0 : d2.id) == (data == null ? void 0 : data.id)
36501
+ );
36502
+ if (index >= 0) {
36503
+ newInfo[key].data[index] = d;
36504
+ } else {
36505
+ if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
36506
+ newInfo[key].data.unshift(d);
36507
+ } else {
36508
+ newInfo[key].data = [d];
36509
+ }
36514
36510
  }
36511
+ }
36512
+ setInfo({ ...newInfo });
36513
+ return d;
36514
+ } catch (error) {
36515
+ const item = http_codes_default.find((s) => s.code == error.status);
36516
+ newInfo[key].state = "error";
36517
+ newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
36518
+ if (error.status == 403) {
36519
+ onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
36520
+ }
36521
+ setInfo({ ...newInfo });
36522
+ return error;
36523
+ }
36524
+ };
36525
+ acc[key] = {
36526
+ ...endpoint,
36527
+ loaded: false,
36528
+ show: showFunc,
36529
+ find: findFunc,
36530
+ create: async (data) => {
36531
+ const hasFile = Array.isArray(data) ? data.some(
36532
+ (item) => Object.values(item).some((value) => value instanceof File)
36533
+ ) : Object.values(data).some((value) => value instanceof File);
36534
+ if (hasFile) {
36535
+ return await formCreateFunc(data);
36536
+ }
36537
+ return await bodyCreateFunc(data);
36538
+ },
36539
+ update: async (id, data) => {
36540
+ var _a2, _b2, _c2;
36541
+ const options = {
36542
+ method: "PATCH",
36543
+ url: `${baseURI}/${key}/${id}`,
36544
+ data: Array.isArray(data) ? [...data] : { ...data },
36545
+ headers: { Authorization: token }
36515
36546
  };
36516
- });
36517
- return d;
36518
- } catch (error) {
36519
- setKeyError(key, error);
36520
- return error;
36521
- }
36522
- },
36523
- [baseURI, token, setKeyLoading, setKeyError]
36524
- );
36525
- const remove = useCallback(
36526
- async (key, id) => {
36527
- setKeyLoading(key);
36528
- try {
36529
- const { data: d } = await axios.delete(`${baseURI}/${key}/${id}`, {
36530
- headers: { Authorization: token }
36531
- });
36532
- setInfo((prev) => {
36533
- var _a, _b;
36534
- return {
36535
- ...prev,
36536
- [key]: {
36537
- ...prev[key],
36538
- state: "success",
36539
- errorMessage: "",
36540
- selectedItem: d,
36541
- data: ((_b = (_a = prev[key]) == null ? void 0 : _a.data) != null ? _b : []).filter((item) => (item == null ? void 0 : item.id) != id)
36547
+ const newInfo = { ...info };
36548
+ newInfo[key].state = "loading";
36549
+ newInfo[key].errorMessage = "";
36550
+ setInfo(newInfo);
36551
+ try {
36552
+ const consulta = await axios.request(options);
36553
+ const d = consulta.data;
36554
+ newInfo[key].state = "success";
36555
+ newInfo[key].errorMessage = "";
36556
+ newInfo[key].selectedItem = { ...newInfo[key].selectedItem, ...d };
36557
+ const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
36558
+ (d2) => (d2 == null ? void 0 : d2.id) == id
36559
+ );
36560
+ if (index >= 0) {
36561
+ newInfo[key].data[index] = { ...newInfo[key].data[index], ...d };
36562
+ } else {
36563
+ if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
36564
+ newInfo[key].data.unshift(d);
36565
+ } else {
36566
+ newInfo[key].data = [d];
36567
+ }
36542
36568
  }
36569
+ setInfo({ ...newInfo });
36570
+ return d;
36571
+ } catch (error) {
36572
+ const item = http_codes_default.find((s) => s.code == error.status);
36573
+ newInfo[key].state = "error";
36574
+ newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
36575
+ if (error.status == 403) {
36576
+ onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
36577
+ }
36578
+ setInfo({ ...newInfo });
36579
+ return error;
36580
+ }
36581
+ },
36582
+ remove: async (id) => {
36583
+ var _a2, _b2;
36584
+ const options = {
36585
+ method: "DELETE",
36586
+ url: `${baseURI}/${key}/${id}`,
36587
+ headers: { Authorization: token }
36543
36588
  };
36544
- });
36545
- return d;
36546
- } catch (error) {
36547
- setKeyError(key, error);
36548
- return error;
36549
- }
36550
- },
36551
- [baseURI, token, setKeyLoading, setKeyError]
36552
- );
36553
- const getAllPages = useCallback(
36554
- async (key, limit = 100) => {
36555
- var _a, _b;
36556
- const allData = [];
36557
- let page = 1;
36558
- let totalPages = 1;
36559
- do {
36560
- const pageData = await show(key, { limit, page, merge: false });
36561
- if (Array.isArray(pageData)) allData.push(...pageData);
36562
- totalPages = (_b = (_a = infoRef.current[key]) == null ? void 0 : _a.totalPages) != null ? _b : page;
36563
- page++;
36564
- } while (page <= totalPages);
36565
- setInfo((prev) => ({
36566
- ...prev,
36567
- [key]: { ...prev[key], data: allData }
36568
- }));
36569
- return allData;
36589
+ const newInfo = { ...info };
36590
+ newInfo[key].state = "loading";
36591
+ newInfo[key].errorMessage = "";
36592
+ setInfo(newInfo);
36593
+ try {
36594
+ const consulta = await axios.request(options);
36595
+ const d = consulta.data;
36596
+ newInfo[key].state = "success";
36597
+ newInfo[key].errorMessage = "";
36598
+ newInfo[key].selectedItem = d;
36599
+ const index = (_b2 = (_a2 = newInfo[key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.findIndex(
36600
+ (d2) => (d2 == null ? void 0 : d2.id) == id
36601
+ );
36602
+ if (index >= 0) {
36603
+ newInfo[key].data.splice(index, 1);
36604
+ }
36605
+ setInfo({ ...newInfo });
36606
+ return d.data;
36607
+ } catch (error) {
36608
+ const item = http_codes_default.find((s) => s.code == error.status);
36609
+ newInfo[key].state = "error";
36610
+ newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
36611
+ if (error.status == 403) {
36612
+ onError == null ? void 0 : onError({ error, ...{ errorMessage: item == null ? void 0 : item.meaning } });
36613
+ }
36614
+ setInfo({ ...newInfo });
36615
+ return error;
36616
+ }
36617
+ },
36618
+ totalPages: (_a = info[key]) == null ? void 0 : _a.totalPages,
36619
+ currentPage: (_b = info[key]) == null ? void 0 : _b.currentPage,
36620
+ state: ((_c = info[key]) == null ? void 0 : _c.state) || "success",
36621
+ errorMessage: (_d = info[key]) == null ? void 0 : _d.errorMessage,
36622
+ params: (_e = info[key]) == null ? void 0 : _e.params,
36623
+ setLoaded: () => {
36624
+ const newInfo = { ...info };
36625
+ newInfo[key].loaded = true;
36626
+ setInfo(newInfo);
36627
+ },
36628
+ getAllPages: async (limit = 100) => {
36629
+ const allData = [];
36630
+ let currentPage = 1;
36631
+ let totalPages = 1;
36632
+ while (currentPage <= totalPages) {
36633
+ const response = await results[key].show({
36634
+ limit,
36635
+ page: currentPage
36636
+ });
36637
+ const currentInfo = info[key];
36638
+ if (Array.isArray(response)) {
36639
+ allData.push(...response);
36640
+ }
36641
+ currentPage = currentInfo.currentPage || currentPage + 1;
36642
+ totalPages = currentInfo.totalPages || currentPage;
36643
+ }
36644
+ const newInfo = { ...info };
36645
+ newInfo[key].data = allData;
36646
+ newInfo[key].currentPage = currentPage;
36647
+ newInfo[key].totalPages = totalPages;
36648
+ setInfo(newInfo);
36649
+ return allData;
36650
+ },
36651
+ data: ((_f = info[key]) == null ? void 0 : _f.data) || [],
36652
+ selectedItem: ((_g = info[key]) == null ? void 0 : _g.selectedItem) || {}
36653
+ };
36654
+ return acc;
36570
36655
  },
36571
- [show]
36656
+ {}
36572
36657
  );
36658
+ async function doSome() {
36659
+ var _a, _b, _c, _d, _e;
36660
+ const key = Object.keys(info).find((k) => {
36661
+ return info[k].loaded === false;
36662
+ });
36663
+ if (key) {
36664
+ if ((_a = info[key]) == null ? void 0 : _a.id) {
36665
+ await results[key].find((_b = info[key]) == null ? void 0 : _b.id, (_c = info[key]) == null ? void 0 : _c.defaultParams);
36666
+ } else if ((_d = info[key]) == null ? void 0 : _d.defaultParams) {
36667
+ await results[key].show((_e = info[key]) == null ? void 0 : _e.defaultParams);
36668
+ } else {
36669
+ results[key].setLoaded();
36670
+ }
36671
+ }
36672
+ }
36573
36673
  useEffect4(() => {
36574
- var _a, _b;
36575
- const key = Object.keys(info).find((k) => info[k].loaded === false);
36576
- if (!key) return;
36577
- if ((_a = info[key]) == null ? void 0 : _a.id) {
36578
- find(key, info[key].id, info[key].defaultParams);
36579
- } else if ((_b = info[key]) == null ? void 0 : _b.defaultParams) {
36580
- show(key, info[key].defaultParams);
36581
- } else {
36582
- setInfo((prev) => ({
36583
- ...prev,
36584
- [key]: { ...prev[key], loaded: true }
36585
- }));
36586
- }
36587
- }, [
36588
- Object.keys(info).map((k) => info[k].loaded).join(",")
36589
- ]);
36590
- const results = Object.keys(endpoints).reduce((acc, key) => {
36591
- var _a, _b, _c, _d;
36592
- const s = info[key];
36593
- acc[key] = {
36594
- ...endpoints[key],
36595
- data: (_a = s == null ? void 0 : s.data) != null ? _a : [],
36596
- selectedItem: (_b = s == null ? void 0 : s.selectedItem) != null ? _b : {},
36597
- state: (_c = s == null ? void 0 : s.state) != null ? _c : "success",
36598
- errorMessage: s == null ? void 0 : s.errorMessage,
36599
- params: s == null ? void 0 : s.params,
36600
- totalPages: s == null ? void 0 : s.totalPages,
36601
- currentPage: s == null ? void 0 : s.currentPage,
36602
- totalItems: s == null ? void 0 : s.totalItems,
36603
- loaded: (_d = s == null ? void 0 : s.loaded) != null ? _d : false,
36604
- show: (opts) => show(key, opts),
36605
- find: (id, query) => find(key, id, query),
36606
- create: (data) => create(key, data),
36607
- update: (id, data) => update(key, id, data),
36608
- remove: (id) => remove(key, id),
36609
- getAllPages: (limit) => getAllPages(key, limit),
36610
- setLoaded: () => setInfo((prev) => ({ ...prev, [key]: { ...prev[key], loaded: true } }))
36611
- };
36612
- return acc;
36613
- }, {});
36674
+ doSome();
36675
+ }, [JSON.stringify(Object.values(info).map((v) => v.loaded))]);
36614
36676
  return results;
36615
36677
  }
36616
36678
 
36617
36679
  // src/select/index.tsx
36618
36680
  import React5, {
36619
36681
  useEffect as useEffect5,
36620
- useRef as useRef3,
36682
+ useRef as useRef2,
36621
36683
  useState as useState8
36622
36684
  } from "react";
36623
36685
 
@@ -36676,7 +36738,7 @@ function Select({
36676
36738
  );
36677
36739
  const [hasEdition, setHasEdition] = useState8(false);
36678
36740
  const [highlightedIndex, setHighlightedIndex] = useState8(-1);
36679
- const inputRef = useRef3(null);
36741
+ const inputRef = useRef2(null);
36680
36742
  const validOption = (value) => {
36681
36743
  return options.find((opt) => opt.label == value);
36682
36744
  };
@@ -36724,7 +36786,7 @@ function Select({
36724
36786
  setInputValue(opt.label);
36725
36787
  setIsOpen(false);
36726
36788
  };
36727
- const containerRef = useRef3(null);
36789
+ const containerRef = useRef2(null);
36728
36790
  const [openUpwards, setOpenUpwards] = useState8(false);
36729
36791
  useEffect5(() => {
36730
36792
  if (isOpen && containerRef.current) {
@@ -36738,23 +36800,15 @@ function Select({
36738
36800
  }
36739
36801
  }
36740
36802
  }, [isOpen]);
36741
- return /* @__PURE__ */ jsxs7("div", { ref: containerRef, className: "w-full", children: [
36742
- label && /* @__PURE__ */ jsxs7("label", { className: "font-bold mb-1 block", children: [
36743
- label,
36744
- " ",
36745
- (props == null ? void 0 : props.required) && /* @__PURE__ */ jsx10("span", { className: "text-red-500", children: "*" })
36746
- ] }),
36747
- /* @__PURE__ */ jsxs7("div", { className: "relative", children: [
36803
+ return /* @__PURE__ */ jsxs7("div", { ref: containerRef, className: "w-full relative my-3", children: [
36804
+ /* @__PURE__ */ jsxs7("div", { className: "relative flex items-center border rounded bg-white", children: [
36748
36805
  /* @__PURE__ */ jsx10(
36749
36806
  "input",
36750
36807
  {
36751
36808
  autoComplete: "off",
36752
36809
  ref: inputRef,
36753
36810
  ...props,
36754
- className: [
36755
- "p-2 w-full rounded border shadow",
36756
- props == null ? void 0 : props.className
36757
- ].join(" "),
36811
+ className: ["p-2 w-full transparent", props == null ? void 0 : props.className].join(" "),
36758
36812
  value: inputValue,
36759
36813
  onBlur: (e) => {
36760
36814
  setTimeout(() => {
@@ -36784,6 +36838,11 @@ function Select({
36784
36838
  onKeyDown: handleKeyDown
36785
36839
  }
36786
36840
  ),
36841
+ label && /* @__PURE__ */ jsxs7("label", { className: "absolute -top-2.5 left-2 text-xs font-bold px-1", children: [
36842
+ label,
36843
+ " ",
36844
+ (props == null ? void 0 : props.required) && /* @__PURE__ */ jsx10("span", { className: "text-red-500", children: "*" })
36845
+ ] }),
36787
36846
  !isOpen && /* @__PURE__ */ jsx10("div", { className: "absolute top-0 right-0 flex flex-col justify-center items-center px-2 py-2 font-bold", children: /* @__PURE__ */ jsx10(SelectIcon, {}) }),
36788
36847
  isOpen && inputValue != "" && /* @__PURE__ */ jsx10(
36789
36848
  "button",
@@ -36807,7 +36866,7 @@ function Select({
36807
36866
  "div",
36808
36867
  {
36809
36868
  style: { zIndex: 9999999999 },
36810
- className: `absolute w-full border rounded shadow bg-white z-10 max-h-100 overflow-y-auto ${openUpwards ? "bottom-full mb-1" : "mt-1"}`,
36869
+ className: `absolute w-full border rounded shadow bg-white z-10 max-h-100 top-10 overflow-y-auto ${openUpwards ? "bottom-full mb-1" : "mt-1"}`,
36811
36870
  children: filtered.map((opt, index) => /* @__PURE__ */ jsx10(
36812
36871
  "div",
36813
36872
  {
@@ -36859,10 +36918,10 @@ function Select({
36859
36918
  }
36860
36919
 
36861
36920
  // src/modal/index.tsx
36862
- import { cloneElement as cloneElement2, useEffect as useEffect6, useMemo as useMemo3 } from "react";
36921
+ import { cloneElement as cloneElement2, useEffect as useEffect6, useMemo as useMemo4 } from "react";
36863
36922
 
36864
36923
  // src/pop/index.tsx
36865
- import { useState as useState9, useCallback as useCallback2, useRef as useRef4 } from "react";
36924
+ import { useState as useState9, useCallback, useRef as useRef3 } from "react";
36866
36925
 
36867
36926
  // src/pop/actions.tsx
36868
36927
  import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
@@ -37014,13 +37073,6 @@ function PopupOverlay({
37014
37073
  {
37015
37074
  className: "fixed inset-0 flex items-center justify-center z-[1000] ",
37016
37075
  style: { background: "rgba(15,23,42,0.45)", backdropFilter: "blur(2px)" },
37017
- onClick: (e) => {
37018
- var _a;
37019
- if (e.target === e.currentTarget) {
37020
- onClose(false);
37021
- (_a = popup.onCancel) == null ? void 0 : _a.call(popup);
37022
- }
37023
- },
37024
37076
  children: [
37025
37077
  /* @__PURE__ */ jsx14("style", { children: `
37026
37078
  @keyframes fadeInScale {
@@ -37107,8 +37159,8 @@ var INITIAL_STATE = {
37107
37159
  };
37108
37160
  function usePopup() {
37109
37161
  const [popup, setPopup] = useState9(INITIAL_STATE);
37110
- const messageRef = useRef4(null);
37111
- const open = useCallback2(
37162
+ const messageRef = useRef3(null);
37163
+ const open = useCallback(
37112
37164
  (partial) => {
37113
37165
  const { message, ...rest } = partial;
37114
37166
  messageRef.current = message;
@@ -37116,7 +37168,7 @@ function usePopup() {
37116
37168
  },
37117
37169
  []
37118
37170
  );
37119
- const close = useCallback2((confirmed, value) => {
37171
+ const close = useCallback((confirmed, value) => {
37120
37172
  setPopup((prev) => {
37121
37173
  var _a, _b;
37122
37174
  if (confirmed) (_a = prev.onConfirm) == null ? void 0 : _a.call(prev, value);
@@ -37124,7 +37176,7 @@ function usePopup() {
37124
37176
  return { ...prev, visible: false, inputValue: "" };
37125
37177
  });
37126
37178
  }, []);
37127
- const alert2 = useCallback2(
37179
+ const alert2 = useCallback(
37128
37180
  (message, color = "primary") => new Promise(
37129
37181
  (resolve) => open({
37130
37182
  type: "alert",
@@ -37136,7 +37188,7 @@ function usePopup() {
37136
37188
  ),
37137
37189
  [open]
37138
37190
  );
37139
- const modal = useCallback2(
37191
+ const modal = useCallback(
37140
37192
  (message, color = "primary", icons = false, full = false) => new Promise(
37141
37193
  (resolve) => open({
37142
37194
  type: "modal",
@@ -37150,7 +37202,7 @@ function usePopup() {
37150
37202
  ),
37151
37203
  [open]
37152
37204
  );
37153
- const confirm = useCallback2(
37205
+ const confirm = useCallback(
37154
37206
  (message, color = "primary") => new Promise(
37155
37207
  (resolve) => open({
37156
37208
  type: "confirm",
@@ -37162,7 +37214,7 @@ function usePopup() {
37162
37214
  ),
37163
37215
  [open]
37164
37216
  );
37165
- const prompt = useCallback2(
37217
+ const prompt = useCallback(
37166
37218
  (message, color = "primary") => new Promise(
37167
37219
  (resolve) => open({
37168
37220
  type: "prompt",
@@ -37174,7 +37226,7 @@ function usePopup() {
37174
37226
  ),
37175
37227
  [open]
37176
37228
  );
37177
- const updateMessage = useCallback2((message) => {
37229
+ const updateMessage = useCallback((message) => {
37178
37230
  messageRef.current = message;
37179
37231
  setPopup((prev) => ({ ...prev }));
37180
37232
  }, []);
@@ -37207,7 +37259,7 @@ function Modal({
37207
37259
  }) {
37208
37260
  const pop = usePopup();
37209
37261
  const hide = () => pop.close(false);
37210
- const childrenWithHide = useMemo3(
37262
+ const childrenWithHide = useMemo4(
37211
37263
  () => cloneElement2(children, { hide }),
37212
37264
  [children]
37213
37265
  );
@@ -37470,14 +37522,14 @@ function DocumentViewer({ item }) {
37470
37522
  // src/table3/index.tsx
37471
37523
  import React9, {
37472
37524
  useEffect as useEffect9,
37473
- useMemo as useMemo6,
37525
+ useMemo as useMemo7,
37474
37526
  useReducer as useReducer2,
37475
- useRef as useRef6,
37527
+ useRef as useRef5,
37476
37528
  useState as useState13
37477
37529
  } from "react";
37478
37530
 
37479
37531
  // src/table3/filter.tsx
37480
- import { useEffect as useEffect8, useMemo as useMemo4, useState as useState11 } from "react";
37532
+ import { useEffect as useEffect8, useMemo as useMemo5, useState as useState11 } from "react";
37481
37533
 
37482
37534
  // src/table3/filters.tsx
37483
37535
  import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
@@ -37589,12 +37641,12 @@ function Filter({
37589
37641
  }) {
37590
37642
  const [visible, setVisible] = useState11(false);
37591
37643
  const [text, setText] = useState11("");
37592
- const items = useMemo4(
37644
+ const items = useMemo5(
37593
37645
  () => [...new Set(Object.values(objectData).map((o) => o[h]))],
37594
37646
  [objectData]
37595
37647
  );
37596
37648
  const [selected, setSelected] = useState11(items);
37597
- const itemsFiltered = useMemo4(
37649
+ const itemsFiltered = useMemo5(
37598
37650
  () => items.sort((a, b) => `${a}`.localeCompare(b)).filter((item) => {
37599
37651
  if (!text) return true;
37600
37652
  return `${item}`.toLowerCase().includes(text.toLowerCase());
@@ -38203,7 +38255,7 @@ function TableFooter({
38203
38255
  }
38204
38256
 
38205
38257
  // src/table3/dialog.tsx
38206
- import React8, { useMemo as useMemo5 } from "react";
38258
+ import React8, { useMemo as useMemo6 } from "react";
38207
38259
  import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
38208
38260
  function Dialog3({
38209
38261
  modalRef,
@@ -38220,7 +38272,7 @@ function Dialog3({
38220
38272
  var _a;
38221
38273
  return (_a = modalRef.current) == null ? void 0 : _a.close();
38222
38274
  };
38223
- const clonedModal = useMemo5(() => {
38275
+ const clonedModal = useMemo6(() => {
38224
38276
  if (dialogRow && React8.isValidElement(children)) {
38225
38277
  return React8.cloneElement(children, {
38226
38278
  key: JSON.stringify(dialogRow),
@@ -38323,7 +38375,7 @@ function Table3({
38323
38375
  setObjectData(data);
38324
38376
  setPage(1);
38325
38377
  }, [data]);
38326
- const headers = useMemo6(() => {
38378
+ const headers = useMemo7(() => {
38327
38379
  if (!objectData) return [];
38328
38380
  return [
38329
38381
  ...new Set(
@@ -38331,12 +38383,12 @@ function Table3({
38331
38383
  )
38332
38384
  ];
38333
38385
  }, [objectData]);
38334
- const totalPages = useMemo6(() => {
38386
+ const totalPages = useMemo7(() => {
38335
38387
  if (!objectData) return 0;
38336
38388
  return maxItems ? Math.ceil(Object.keys(objectData).length / maxItems) : 1;
38337
38389
  }, [objectData, maxItems]);
38338
38390
  const [sort, setSort] = useState13(sortBy);
38339
- const modalRef = useRef6(null);
38391
+ const modalRef = useRef5(null);
38340
38392
  const [dialogRow, setDialogRow] = useState13({});
38341
38393
  const context = {
38342
38394
  objectData,