lkd-web-kit 0.0.15 → 0.0.17
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/components/EmptyState/index.cjs +2 -0
- package/dist/components/EmptyState/index.cjs.map +1 -0
- package/dist/components/EmptyState/index.mjs +37 -0
- package/dist/components/EmptyState/index.mjs.map +1 -0
- package/dist/components/Icon.cjs +2 -0
- package/dist/components/Icon.cjs.map +1 -0
- package/dist/components/Icon.mjs +55 -0
- package/dist/components/Icon.mjs.map +1 -0
- package/dist/components/InfinityLoader/index.cjs +2 -0
- package/dist/components/InfinityLoader/index.cjs.map +1 -0
- package/dist/components/InfinityLoader/index.mjs +7 -0
- package/dist/components/InfinityLoader/index.mjs.map +1 -0
- package/dist/components/NavItems.cjs +2 -0
- package/dist/components/NavItems.cjs.map +1 -0
- package/dist/components/NavItems.mjs +37 -0
- package/dist/components/NavItems.mjs.map +1 -0
- package/dist/components/SelectInfinity/index.cjs +2 -0
- package/dist/components/SelectInfinity/index.cjs.map +1 -0
- package/dist/components/SelectInfinity/index.mjs +107 -0
- package/dist/components/SelectInfinity/index.mjs.map +1 -0
- package/dist/consts/http-status.cjs +2 -0
- package/dist/consts/http-status.cjs.map +1 -0
- package/dist/consts/http-status.mjs +5 -0
- package/dist/consts/http-status.mjs.map +1 -0
- package/dist/consts/revalidate.cjs +2 -0
- package/dist/consts/revalidate.cjs.map +1 -0
- package/dist/consts/revalidate.mjs +5 -0
- package/dist/consts/revalidate.mjs.map +1 -0
- package/dist/contexts/NavigationHistoryContext/index.cjs +2 -0
- package/dist/contexts/NavigationHistoryContext/index.cjs.map +1 -0
- package/dist/contexts/NavigationHistoryContext/index.mjs +48 -0
- package/dist/contexts/NavigationHistoryContext/index.mjs.map +1 -0
- package/dist/contexts/PageDataContext/index.cjs +2 -0
- package/dist/contexts/PageDataContext/index.cjs.map +1 -0
- package/dist/contexts/PageDataContext/index.mjs +16 -0
- package/dist/contexts/PageDataContext/index.mjs.map +1 -0
- package/dist/form/Form.cjs +2 -0
- package/dist/form/Form.cjs.map +1 -0
- package/dist/form/Form.mjs +22 -0
- package/dist/form/Form.mjs.map +1 -0
- package/dist/form/FormButtonSubmit.cjs +2 -0
- package/dist/form/FormButtonSubmit.cjs.map +1 -0
- package/dist/form/FormButtonSubmit.mjs +19 -0
- package/dist/form/FormButtonSubmit.mjs.map +1 -0
- package/dist/form/utils/nullableInput.cjs +2 -0
- package/dist/form/utils/nullableInput.cjs.map +1 -0
- package/dist/form/utils/nullableInput.mjs +10 -0
- package/dist/form/utils/nullableInput.mjs.map +1 -0
- package/dist/form/utils/zodValidator.cjs +2 -0
- package/dist/form/utils/zodValidator.cjs.map +1 -0
- package/dist/form/utils/zodValidator.mjs +10 -0
- package/dist/form/utils/zodValidator.mjs.map +1 -0
- package/dist/hocs/withForm.cjs +2 -0
- package/dist/hocs/withForm.cjs.map +1 -0
- package/dist/hocs/withForm.mjs +48 -0
- package/dist/hocs/withForm.mjs.map +1 -0
- package/dist/hocs/withModalManager.cjs +2 -0
- package/dist/hocs/withModalManager.cjs.map +1 -0
- package/dist/hocs/withModalManager.mjs +29 -0
- package/dist/hocs/withModalManager.mjs.map +1 -0
- package/dist/hooks/useFetchNextPageOnScroll.cjs +2 -0
- package/dist/hooks/useFetchNextPageOnScroll.cjs.map +1 -0
- package/dist/hooks/useFetchNextPageOnScroll.mjs +19 -0
- package/dist/hooks/useFetchNextPageOnScroll.mjs.map +1 -0
- package/dist/hooks/useOnScrollProgress.cjs +2 -0
- package/dist/hooks/useOnScrollProgress.cjs.map +1 -0
- package/dist/hooks/useOnScrollProgress.mjs +20 -0
- package/dist/hooks/useOnScrollProgress.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +61 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mantine/breakpointsWithPx.cjs +2 -0
- package/dist/mantine/breakpointsWithPx.cjs.map +1 -0
- package/dist/mantine/breakpointsWithPx.mjs +12 -0
- package/dist/mantine/breakpointsWithPx.mjs.map +1 -0
- package/dist/mantine/toTailwindColors.cjs +2 -0
- package/dist/mantine/toTailwindColors.cjs.map +1 -0
- package/dist/mantine/toTailwindColors.mjs +11 -0
- package/dist/mantine/toTailwindColors.mjs.map +1 -0
- package/dist/utils/array/groupBy.cjs +2 -0
- package/dist/utils/array/groupBy.cjs.map +1 -0
- package/dist/utils/array/groupBy.mjs +35 -0
- package/dist/utils/array/groupBy.mjs.map +1 -0
- package/dist/utils/array/shuffleArray.cjs +2 -0
- package/dist/utils/array/shuffleArray.cjs.map +1 -0
- package/dist/utils/array/shuffleArray.mjs +14 -0
- package/dist/utils/array/shuffleArray.mjs.map +1 -0
- package/dist/utils/formatBytes.cjs +2 -0
- package/dist/utils/formatBytes.cjs.map +1 -0
- package/dist/utils/formatBytes.mjs +9 -0
- package/dist/utils/formatBytes.mjs.map +1 -0
- package/dist/utils/isInfinityEmpty.cjs +2 -0
- package/dist/utils/isInfinityEmpty.cjs.map +1 -0
- package/dist/utils/isInfinityEmpty.mjs +5 -0
- package/dist/utils/isInfinityEmpty.mjs.map +1 -0
- package/dist/utils/ky/addBodyJsonHook.cjs +2 -0
- package/dist/utils/ky/addBodyJsonHook.cjs.map +1 -0
- package/dist/utils/ky/addBodyJsonHook.mjs +6 -0
- package/dist/utils/ky/addBodyJsonHook.mjs.map +1 -0
- package/dist/utils/ky/parseJson.cjs +2 -0
- package/dist/utils/ky/parseJson.cjs.map +1 -0
- package/dist/utils/ky/parseJson.mjs +7 -0
- package/dist/utils/ky/parseJson.mjs.map +1 -0
- package/dist/utils/newHref.cjs +2 -0
- package/dist/utils/newHref.cjs.map +1 -0
- package/dist/utils/newHref.mjs +21 -0
- package/dist/utils/newHref.mjs.map +1 -0
- package/package.json +5 -5
- package/dist/lkd-web-kit.cjs +0 -33
- package/dist/lkd-web-kit.cjs.map +0 -1
- package/dist/lkd-web-kit.js +0 -4359
- package/dist/lkd-web-kit.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("clsx"),a=require("../Icon.cjs"),o=e=>e&&e.__esModule?e:{default:e},d=o(n),u={sm:48,md:60,lg:84},m=({label:e,action:s,icon:c,className:l,size:r="md",...i})=>t.jsxs("div",{className:d.default("justfiy-center flex flex-col items-center gap-1",l),...i,children:[t.jsx(a,{i:c,size:u[r],className:"text-gray-2"}),t.jsx("p",{className:"text-gray-6 text-sm font-semibold",children:e}),t.jsx("div",{children:s})]});exports.EmptyState=m;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/EmptyState/index.tsx"],"sourcesContent":["import clsx from 'clsx';\r\nimport { ComponentProps, ReactNode } from 'react';\r\nimport Icon, { IconFC } from '../Icon';\r\n\r\nexport interface EmptyProps extends ComponentProps<'div'> {\r\n label: ReactNode;\r\n action?: ReactNode;\r\n icon: IconFC;\r\n size?: keyof typeof pxBySize;\r\n}\r\n\r\nconst pxBySize = {\r\n sm: 48,\r\n md: 60,\r\n lg: 84,\r\n};\r\n\r\nexport const EmptyState = ({\r\n label,\r\n action,\r\n icon,\r\n className,\r\n size = 'md',\r\n ...props\r\n}: EmptyProps) => {\r\n return (\r\n <div\r\n className={clsx('justfiy-center flex flex-col items-center gap-1', className)}\r\n {...props}\r\n >\r\n <Icon\r\n i={icon}\r\n size={pxBySize[size]}\r\n className=\"text-gray-2\"\r\n />\r\n <p className=\"text-gray-6 text-sm font-semibold\">{label}</p>\r\n <div>{action}</div>\r\n </div>\r\n );\r\n};\r\n"],"names":["pxBySize","EmptyState","label","action","icon","className","size","props","jsxs","clsx","jsx","Icon"],"mappings":"0MAWMA,EAAW,CACf,GAAI,GACJ,GAAI,GACJ,GAAI,EACN,EAEaC,EAAa,CAAC,CACzB,MAAAC,EACA,OAAAC,EACA,KAAAC,EACA,UAAAC,EACA,KAAAC,EAAO,KACP,GAAGC,CACL,IAEIC,EAAA,KAAC,MAAA,CACC,UAAWC,EAAAA,QAAK,kDAAmDJ,CAAS,EAC3E,GAAGE,EAEJ,SAAA,CAAAG,EAAA,IAACC,EAAA,CACC,EAAGP,EACH,KAAMJ,EAASM,CAAI,EACnB,UAAU,aAAA,CACZ,EACCI,EAAA,IAAA,IAAA,CAAE,UAAU,oCAAqC,SAAMR,EAAA,EACxDQ,EAAAA,IAAC,OAAK,SAAOP,CAAA,CAAA,CAAA,CAAA,CACf"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import l from "clsx";
|
|
3
|
+
import a from "../Icon.mjs";
|
|
4
|
+
const n = {
|
|
5
|
+
sm: 48,
|
|
6
|
+
md: 60,
|
|
7
|
+
lg: 84
|
|
8
|
+
}, f = ({
|
|
9
|
+
label: t,
|
|
10
|
+
action: s,
|
|
11
|
+
icon: m,
|
|
12
|
+
className: r,
|
|
13
|
+
size: i = "md",
|
|
14
|
+
...c
|
|
15
|
+
}) => /* @__PURE__ */ o(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
className: l("justfiy-center flex flex-col items-center gap-1", r),
|
|
19
|
+
...c,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ e(
|
|
22
|
+
a,
|
|
23
|
+
{
|
|
24
|
+
i: m,
|
|
25
|
+
size: n[i],
|
|
26
|
+
className: "text-gray-2"
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ e("p", { className: "text-gray-6 text-sm font-semibold", children: t }),
|
|
30
|
+
/* @__PURE__ */ e("div", { children: s })
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
export {
|
|
35
|
+
f as EmptyState
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/components/EmptyState/index.tsx"],"sourcesContent":["import clsx from 'clsx';\r\nimport { ComponentProps, ReactNode } from 'react';\r\nimport Icon, { IconFC } from '../Icon';\r\n\r\nexport interface EmptyProps extends ComponentProps<'div'> {\r\n label: ReactNode;\r\n action?: ReactNode;\r\n icon: IconFC;\r\n size?: keyof typeof pxBySize;\r\n}\r\n\r\nconst pxBySize = {\r\n sm: 48,\r\n md: 60,\r\n lg: 84,\r\n};\r\n\r\nexport const EmptyState = ({\r\n label,\r\n action,\r\n icon,\r\n className,\r\n size = 'md',\r\n ...props\r\n}: EmptyProps) => {\r\n return (\r\n <div\r\n className={clsx('justfiy-center flex flex-col items-center gap-1', className)}\r\n {...props}\r\n >\r\n <Icon\r\n i={icon}\r\n size={pxBySize[size]}\r\n className=\"text-gray-2\"\r\n />\r\n <p className=\"text-gray-6 text-sm font-semibold\">{label}</p>\r\n <div>{action}</div>\r\n </div>\r\n );\r\n};\r\n"],"names":["pxBySize","EmptyState","label","action","icon","className","size","props","jsxs","clsx","jsx","Icon"],"mappings":";;;AAWA,MAAMA,IAAW;AAAA,EACf,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEaC,IAAa,CAAC;AAAA,EACzB,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,GAAGC;AACL,MAEI,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC,EAAK,mDAAmDJ,CAAS;AAAA,IAC3E,GAAGE;AAAA,IAEJ,UAAA;AAAA,MAAA,gBAAAG;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,GAAGP;AAAA,UACH,MAAMJ,EAASM,CAAI;AAAA,UACnB,WAAU;AAAA,QAAA;AAAA,MACZ;AAAA,MACC,gBAAAI,EAAA,KAAA,EAAE,WAAU,qCAAqC,UAAMR,GAAA;AAAA,MACxD,gBAAAQ,EAAC,SAAK,UAAOP,EAAA,CAAA;AAAA,IAAA;AAAA,EAAA;AACf;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";const l=require("react/jsx-runtime"),n=require("clsx"),o=t=>t&&t.__esModule?t:{default:t},r=o(n),c=({i:t,size:e="md",style:h,rotate:i,className:s,...d})=>l.jsx(t,{...typeof e=="number"?{height:e,width:e}:u[e],viewBox:"0 0 24 24",style:{...h,transform:`rotate(${i}deg)`},className:r.default("shrink-0",s),...d}),u={xs:{height:16,width:16},sm:{height:20,width:20},md:{height:24,width:24},lg:{height:28,width:28},xl:{height:32,width:32},"2xl":{height:40,width:40}};module.exports=c;
|
|
2
|
+
//# sourceMappingURL=Icon.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.cjs","sources":["../../src/components/Icon.tsx"],"sourcesContent":["\"use client\";\r\nimport clsx from \"clsx\";\r\nimport React, { ComponentPropsWithoutRef } from \"react\";\r\n\r\nexport type IconFC = React.FC<ComponentPropsWithoutRef<\"svg\">>;\r\nexport interface IconProps extends ComponentPropsWithoutRef<\"svg\"> {\r\n i: IconFC;\r\n /**\r\n * @property xs: 16px\r\n * @property sm: 20px\r\n * @property md: 24px\r\n * @property lg: 28px\r\n * @property xl: 32px\r\n * @property 2xl: 40px\r\n */\r\n size?: keyof typeof stylesBySize | number;\r\n}\r\n\r\nconst Icon = ({\r\n i: I,\r\n size = \"md\",\r\n style,\r\n rotate,\r\n className,\r\n ...rest\r\n}: IconProps) => {\r\n /* \r\n Para que no haya colisiones de ids al renderizar el icono en varios lados, le pasamos este id a la prop idprefix.\r\n Esta prop es agregada gracias al archivo svgr-dynamic-ids.js que se encuentra en la raíz del proyecto.\r\n */\r\n\r\n return (\r\n <I\r\n {...(typeof size === \"number\"\r\n ? {\r\n height: size,\r\n width: size\r\n }\r\n : stylesBySize[size])}\r\n viewBox=\"0 0 24 24\"\r\n style={{\r\n ...style,\r\n transform: `rotate(${rotate}deg)`\r\n }}\r\n className={clsx(\"shrink-0\", className)}\r\n {...rest}\r\n />\r\n );\r\n};\r\n\r\nconst stylesBySize = {\r\n xs: {\r\n height: 16,\r\n width: 16\r\n },\r\n sm: {\r\n height: 20,\r\n width: 20\r\n },\r\n md: {\r\n height: 24,\r\n width: 24\r\n },\r\n lg: {\r\n height: 28,\r\n width: 28\r\n },\r\n xl: {\r\n height: 32,\r\n width: 32\r\n },\r\n [\"2xl\"]: {\r\n height: 40,\r\n width: 40\r\n }\r\n};\r\n\r\nexport default Icon;\r\n"],"names":["Icon","I","size","style","rotate","className","rest","jsx","stylesBySize","clsx"],"mappings":"2HAkBMA,EAAO,CAAC,CACZ,EAAGC,EACH,KAAAC,EAAO,KACP,MAAAC,EACA,OAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IAOIC,EAAA,IAACN,EAAA,CACE,GAAI,OAAOC,GAAS,SACjB,CACE,OAAQA,EACR,MAAOA,CAAA,EAETM,EAAaN,CAAI,EACrB,QAAQ,YACR,MAAO,CACL,GAAGC,EACH,UAAW,UAAUC,CAAM,MAC7B,EACA,UAAWK,EAAAA,QAAK,WAAYJ,CAAS,EACpC,GAAGC,CAAA,CACN,EAIEE,EAAe,CACnB,GAAI,CACF,OAAQ,GACR,MAAO,EACT,EACA,GAAI,CACF,OAAQ,GACR,MAAO,EACT,EACA,GAAI,CACF,OAAQ,GACR,MAAO,EACT,EACA,GAAI,CACF,OAAQ,GACR,MAAO,EACT,EACA,GAAI,CACF,OAAQ,GACR,MAAO,EACT,EACC,MAAQ,CACP,OAAQ,GACR,MAAO,EAAA,CAEX"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
3
|
+
import d from "clsx";
|
|
4
|
+
const n = ({
|
|
5
|
+
i: h,
|
|
6
|
+
size: t = "md",
|
|
7
|
+
style: e,
|
|
8
|
+
rotate: i,
|
|
9
|
+
className: o,
|
|
10
|
+
...r
|
|
11
|
+
}) => /* @__PURE__ */ s(
|
|
12
|
+
h,
|
|
13
|
+
{
|
|
14
|
+
...typeof t == "number" ? {
|
|
15
|
+
height: t,
|
|
16
|
+
width: t
|
|
17
|
+
} : m[t],
|
|
18
|
+
viewBox: "0 0 24 24",
|
|
19
|
+
style: {
|
|
20
|
+
...e,
|
|
21
|
+
transform: `rotate(${i}deg)`
|
|
22
|
+
},
|
|
23
|
+
className: d("shrink-0", o),
|
|
24
|
+
...r
|
|
25
|
+
}
|
|
26
|
+
), m = {
|
|
27
|
+
xs: {
|
|
28
|
+
height: 16,
|
|
29
|
+
width: 16
|
|
30
|
+
},
|
|
31
|
+
sm: {
|
|
32
|
+
height: 20,
|
|
33
|
+
width: 20
|
|
34
|
+
},
|
|
35
|
+
md: {
|
|
36
|
+
height: 24,
|
|
37
|
+
width: 24
|
|
38
|
+
},
|
|
39
|
+
lg: {
|
|
40
|
+
height: 28,
|
|
41
|
+
width: 28
|
|
42
|
+
},
|
|
43
|
+
xl: {
|
|
44
|
+
height: 32,
|
|
45
|
+
width: 32
|
|
46
|
+
},
|
|
47
|
+
"2xl": {
|
|
48
|
+
height: 40,
|
|
49
|
+
width: 40
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
n as default
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=Icon.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.mjs","sources":["../../src/components/Icon.tsx"],"sourcesContent":["\"use client\";\r\nimport clsx from \"clsx\";\r\nimport React, { ComponentPropsWithoutRef } from \"react\";\r\n\r\nexport type IconFC = React.FC<ComponentPropsWithoutRef<\"svg\">>;\r\nexport interface IconProps extends ComponentPropsWithoutRef<\"svg\"> {\r\n i: IconFC;\r\n /**\r\n * @property xs: 16px\r\n * @property sm: 20px\r\n * @property md: 24px\r\n * @property lg: 28px\r\n * @property xl: 32px\r\n * @property 2xl: 40px\r\n */\r\n size?: keyof typeof stylesBySize | number;\r\n}\r\n\r\nconst Icon = ({\r\n i: I,\r\n size = \"md\",\r\n style,\r\n rotate,\r\n className,\r\n ...rest\r\n}: IconProps) => {\r\n /* \r\n Para que no haya colisiones de ids al renderizar el icono en varios lados, le pasamos este id a la prop idprefix.\r\n Esta prop es agregada gracias al archivo svgr-dynamic-ids.js que se encuentra en la raíz del proyecto.\r\n */\r\n\r\n return (\r\n <I\r\n {...(typeof size === \"number\"\r\n ? {\r\n height: size,\r\n width: size\r\n }\r\n : stylesBySize[size])}\r\n viewBox=\"0 0 24 24\"\r\n style={{\r\n ...style,\r\n transform: `rotate(${rotate}deg)`\r\n }}\r\n className={clsx(\"shrink-0\", className)}\r\n {...rest}\r\n />\r\n );\r\n};\r\n\r\nconst stylesBySize = {\r\n xs: {\r\n height: 16,\r\n width: 16\r\n },\r\n sm: {\r\n height: 20,\r\n width: 20\r\n },\r\n md: {\r\n height: 24,\r\n width: 24\r\n },\r\n lg: {\r\n height: 28,\r\n width: 28\r\n },\r\n xl: {\r\n height: 32,\r\n width: 32\r\n },\r\n [\"2xl\"]: {\r\n height: 40,\r\n width: 40\r\n }\r\n};\r\n\r\nexport default Icon;\r\n"],"names":["Icon","I","size","style","rotate","className","rest","jsx","stylesBySize","clsx"],"mappings":";;;AAkBA,MAAMA,IAAO,CAAC;AAAA,EACZ,GAAGC;AAAA,EACH,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,MAOI,gBAAAC;AAAA,EAACN;AAAA,EAAA;AAAA,IACE,GAAI,OAAOC,KAAS,WACjB;AAAA,MACE,QAAQA;AAAA,MACR,OAAOA;AAAA,IAAA,IAETM,EAAaN,CAAI;AAAA,IACrB,SAAQ;AAAA,IACR,OAAO;AAAA,MACL,GAAGC;AAAA,MACH,WAAW,UAAUC,CAAM;AAAA,IAC7B;AAAA,IACA,WAAWK,EAAK,YAAYJ,CAAS;AAAA,IACpC,GAAGC;AAAA,EAAA;AACN,GAIEE,IAAe;AAAA,EACnB,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACA,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAAA,EACC,OAAQ;AAAA,IACP,QAAQ;AAAA,IACR,OAAO;AAAA,EAAA;AAEX;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),t=require("@mantine/core"),a=({infinity:e,loaderProps:s,...o})=>r.jsx(t.Center,{...o,children:e.isFetching?r.jsx(t.Loader,{...s}):!e.hasNextPage&&(e.data?.pages.length??0)>1&&r.jsx("p",{children:"No hay más resultados"})});exports.InfinityLoader=a;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/InfinityLoader/index.tsx"],"sourcesContent":["import { Center, CenterProps, Loader, LoaderProps } from '@mantine/core';\r\nimport { InfiniteData } from '@tanstack/react-query';\r\nimport { InfiniteQueryHookResult } from 'react-query-kit';\r\n\r\nexport interface InfinityLoaderProps extends CenterProps {\r\n infinity: InfiniteQueryHookResult<InfiniteData<{ data: unknown[] }>, unknown>;\r\n loaderProps?: LoaderProps;\r\n}\r\n\r\nexport const InfinityLoader = ({ infinity, loaderProps, ...props }: InfinityLoaderProps) => {\r\n return (\r\n <Center {...props}>\r\n {infinity.isFetching ? (\r\n <Loader {...loaderProps} />\r\n ) : (\r\n !infinity.hasNextPage &&\r\n (infinity.data?.pages.length ?? 0) > 1 && <p>No hay más resultados</p>\r\n )}\r\n </Center>\r\n );\r\n};\r\n"],"names":["InfinityLoader","infinity","loaderProps","props","jsx","Center","Loader"],"mappings":"gJASaA,EAAiB,CAAC,CAAE,SAAAC,EAAU,YAAAC,EAAa,GAAGC,KAEvDC,EAAA,IAACC,UAAQ,GAAGF,EACT,WAAS,WACRC,EAAA,IAACE,EAAQ,OAAA,CAAA,GAAGJ,CAAa,CAAA,EAEzB,CAACD,EAAS,cACTA,EAAS,MAAM,MAAM,QAAU,GAAK,GAAKG,EAAAA,IAAC,IAAE,CAAA,SAAA,uBAAA,CAAqB,CAEtE,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { Center as a, Loader as s } from "@mantine/core";
|
|
3
|
+
const m = ({ infinity: e, loaderProps: o, ...t }) => /* @__PURE__ */ r(a, { ...t, children: e.isFetching ? /* @__PURE__ */ r(s, { ...o }) : !e.hasNextPage && (e.data?.pages.length ?? 0) > 1 && /* @__PURE__ */ r("p", { children: "No hay más resultados" }) });
|
|
4
|
+
export {
|
|
5
|
+
m as InfinityLoader
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/components/InfinityLoader/index.tsx"],"sourcesContent":["import { Center, CenterProps, Loader, LoaderProps } from '@mantine/core';\r\nimport { InfiniteData } from '@tanstack/react-query';\r\nimport { InfiniteQueryHookResult } from 'react-query-kit';\r\n\r\nexport interface InfinityLoaderProps extends CenterProps {\r\n infinity: InfiniteQueryHookResult<InfiniteData<{ data: unknown[] }>, unknown>;\r\n loaderProps?: LoaderProps;\r\n}\r\n\r\nexport const InfinityLoader = ({ infinity, loaderProps, ...props }: InfinityLoaderProps) => {\r\n return (\r\n <Center {...props}>\r\n {infinity.isFetching ? (\r\n <Loader {...loaderProps} />\r\n ) : (\r\n !infinity.hasNextPage &&\r\n (infinity.data?.pages.length ?? 0) > 1 && <p>No hay más resultados</p>\r\n )}\r\n </Center>\r\n );\r\n};\r\n"],"names":["InfinityLoader","infinity","loaderProps","props","jsx","Center","Loader"],"mappings":";;AASO,MAAMA,IAAiB,CAAC,EAAE,UAAAC,GAAU,aAAAC,GAAa,GAAGC,QAEvD,gBAAAC,EAACC,KAAQ,GAAGF,GACT,YAAS,aACR,gBAAAC,EAACE,GAAQ,EAAA,GAAGJ,EAAa,CAAA,IAEzB,CAACD,EAAS,gBACTA,EAAS,MAAM,MAAM,UAAU,KAAK,KAAK,gBAAAG,EAAC,KAAE,EAAA,UAAA,wBAAA,CAAqB,EAEtE,CAAA;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),c=require("@mantine/core"),r=require("next/link"),i=require("next/navigation"),l=e=>e&&e.__esModule?e:{default:e},m=l(r),d=({items:e})=>{const o=i.usePathname();return a.jsx(c.Stack,{gap:0,children:e.map(({href:n,isActive:u,...t})=>{if(n){const s=u??n.includes(o);return a.jsx(c.NavLink,{active:s,component:m.default,prefetch:!1,href:n,...t},t.label)}return a.jsx(c.NavLink,{active:u,component:"button",...t},t.label)})})};exports.NavItems=d;
|
|
2
|
+
//# sourceMappingURL=NavItems.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavItems.cjs","sources":["../../src/components/NavItems.tsx"],"sourcesContent":["'use client';\r\nimport { NavLink, Stack } from '@mantine/core';\r\nimport Link from 'next/link';\r\nimport { usePathname } from 'next/navigation';\r\nimport { MouseEvent, ReactNode } from 'react';\r\n\r\nexport interface NavItemsProps {\r\n items: {\r\n leftSection?: ReactNode;\r\n rightSection?: ReactNode;\r\n onClick?: (e: MouseEvent<Element>) => void;\r\n disabled?: boolean;\r\n className?: string;\r\n children?: ReactNode;\r\n label: string;\r\n\r\n // custom props\r\n href?: string;\r\n isActive?: boolean;\r\n }[];\r\n}\r\n\r\nexport const NavItems = ({ items }: NavItemsProps) => {\r\n const pathname = usePathname();\r\n\r\n return (\r\n <Stack gap={0}>\r\n {items.map(({ href, isActive, ...navLinkProps }) => {\r\n if (href) {\r\n const active = isActive ?? href.includes(pathname);\r\n return (\r\n <NavLink\r\n active={active}\r\n key={navLinkProps.label}\r\n component={Link}\r\n prefetch={false}\r\n href={href}\r\n {...navLinkProps}\r\n />\r\n );\r\n }\r\n\r\n return (\r\n <NavLink\r\n key={navLinkProps.label}\r\n active={isActive}\r\n component=\"button\"\r\n {...navLinkProps}\r\n />\r\n );\r\n })}\r\n </Stack>\r\n );\r\n};\r\n"],"names":["NavItems","items","pathname","usePathname","jsx","Stack","href","isActive","navLinkProps","active","NavLink","Link"],"mappings":"2PAsBaA,EAAW,CAAC,CAAE,MAAAC,KAA2B,CACpD,MAAMC,EAAWC,EAAAA,YAAY,EAE7B,OACGC,EAAA,IAAAC,EAAA,MAAA,CAAM,IAAK,EACT,SAAMJ,EAAA,IAAI,CAAC,CAAE,KAAAK,EAAM,SAAAC,EAAU,GAAGC,CAAA,IAAmB,CAClD,GAAIF,EAAM,CACR,MAAMG,EAASF,GAAYD,EAAK,SAASJ,CAAQ,EAE/C,OAAAE,EAAA,IAACM,EAAA,QAAA,CACC,OAAAD,EAEA,UAAWE,EAAA,QACX,SAAU,GACV,KAAAL,EACC,GAAGE,CAAA,EAJCA,EAAa,KAKpB,CAAA,CAKF,OAAAJ,EAAA,IAACM,EAAA,QAAA,CAEC,OAAQH,EACR,UAAU,SACT,GAAGC,CAAA,EAHCA,EAAa,KAIpB,CAEH,CAAA,EACH,CAEJ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { Stack as l, NavLink as n } from "@mantine/core";
|
|
4
|
+
import p from "next/link";
|
|
5
|
+
import { usePathname as i } from "next/navigation";
|
|
6
|
+
const d = ({ items: r }) => {
|
|
7
|
+
const a = i();
|
|
8
|
+
return /* @__PURE__ */ m(l, { gap: 0, children: r.map(({ href: e, isActive: o, ...t }) => {
|
|
9
|
+
if (e) {
|
|
10
|
+
const c = o ?? e.includes(a);
|
|
11
|
+
return /* @__PURE__ */ m(
|
|
12
|
+
n,
|
|
13
|
+
{
|
|
14
|
+
active: c,
|
|
15
|
+
component: p,
|
|
16
|
+
prefetch: !1,
|
|
17
|
+
href: e,
|
|
18
|
+
...t
|
|
19
|
+
},
|
|
20
|
+
t.label
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return /* @__PURE__ */ m(
|
|
24
|
+
n,
|
|
25
|
+
{
|
|
26
|
+
active: o,
|
|
27
|
+
component: "button",
|
|
28
|
+
...t
|
|
29
|
+
},
|
|
30
|
+
t.label
|
|
31
|
+
);
|
|
32
|
+
}) });
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
d as NavItems
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=NavItems.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavItems.mjs","sources":["../../src/components/NavItems.tsx"],"sourcesContent":["'use client';\r\nimport { NavLink, Stack } from '@mantine/core';\r\nimport Link from 'next/link';\r\nimport { usePathname } from 'next/navigation';\r\nimport { MouseEvent, ReactNode } from 'react';\r\n\r\nexport interface NavItemsProps {\r\n items: {\r\n leftSection?: ReactNode;\r\n rightSection?: ReactNode;\r\n onClick?: (e: MouseEvent<Element>) => void;\r\n disabled?: boolean;\r\n className?: string;\r\n children?: ReactNode;\r\n label: string;\r\n\r\n // custom props\r\n href?: string;\r\n isActive?: boolean;\r\n }[];\r\n}\r\n\r\nexport const NavItems = ({ items }: NavItemsProps) => {\r\n const pathname = usePathname();\r\n\r\n return (\r\n <Stack gap={0}>\r\n {items.map(({ href, isActive, ...navLinkProps }) => {\r\n if (href) {\r\n const active = isActive ?? href.includes(pathname);\r\n return (\r\n <NavLink\r\n active={active}\r\n key={navLinkProps.label}\r\n component={Link}\r\n prefetch={false}\r\n href={href}\r\n {...navLinkProps}\r\n />\r\n );\r\n }\r\n\r\n return (\r\n <NavLink\r\n key={navLinkProps.label}\r\n active={isActive}\r\n component=\"button\"\r\n {...navLinkProps}\r\n />\r\n );\r\n })}\r\n </Stack>\r\n );\r\n};\r\n"],"names":["NavItems","items","pathname","usePathname","jsx","Stack","href","isActive","navLinkProps","active","NavLink","Link"],"mappings":";;;;;AAsBO,MAAMA,IAAW,CAAC,EAAE,OAAAC,QAA2B;AACpD,QAAMC,IAAWC,EAAY;AAE7B,SACG,gBAAAC,EAAAC,GAAA,EAAM,KAAK,GACT,UAAMJ,EAAA,IAAI,CAAC,EAAE,MAAAK,GAAM,UAAAC,GAAU,GAAGC,EAAA,MAAmB;AAClD,QAAIF,GAAM;AACR,YAAMG,IAASF,KAAYD,EAAK,SAASJ,CAAQ;AAE/C,aAAA,gBAAAE;AAAA,QAACM;AAAA,QAAA;AAAA,UACC,QAAAD;AAAA,UAEA,WAAWE;AAAA,UACX,UAAU;AAAA,UACV,MAAAL;AAAA,UACC,GAAGE;AAAA,QAAA;AAAA,QAJCA,EAAa;AAAA,MAKpB;AAAA,IAAA;AAKF,WAAA,gBAAAJ;AAAA,MAACM;AAAA,MAAA;AAAA,QAEC,QAAQH;AAAA,QACR,WAAU;AAAA,QACT,GAAGC;AAAA,MAAA;AAAA,MAHCA,EAAa;AAAA,IAIpB;AAAA,EAEH,CAAA,GACH;AAEJ;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("@mantine/core"),g=require("react"),C=require("../../hooks/useFetchNextPageOnScroll.cjs"),S=require("../InfinityLoader/index.cjs");function f({value:a,onChange:b,data:r=[],searchValue:x,onSearchChange:l,renderOption:c,onOptionSubmit:p,nothingFoundMessage:d,infinity:s,placeholder:m,...h}){const n=o.useCombobox({onDropdownClose:()=>{n.resetSelectedOption(),n.focusTarget(),l?.("")},onDropdownOpen:()=>{n.focusSearchInput()}}),i=r.map(t=>e.jsx(o.Combobox.Option,{value:t.value,children:c?c({option:t}):t.label},t.value)),j=r.find(t=>t.value===a),u=g.useRef(null);return C.useFetchNextPageOnScroll(s,u),e.jsxs(o.Combobox,{store:n,middlewares:{shift:{crossAxis:!0}},onOptionSubmit:t=>{b?.(t),p?.(t),n.closeDropdown()},children:[e.jsx(o.Combobox.Target,{children:e.jsx(o.InputBase,{component:"button",type:"button",pointer:!0,rightSection:e.jsx(o.Combobox.Chevron,{}),onClick:()=>n.toggleDropdown(),rightSectionPointerEvents:"none",...h,children:j?.label||e.jsx(o.Input.Placeholder,{children:m})})}),e.jsxs(o.Combobox.Dropdown,{children:[e.jsx(o.Combobox.Search,{value:x,onChange:t=>l?.(t.currentTarget.value),placeholder:"Escribe para buscar"}),e.jsx(o.Combobox.Options,{children:e.jsxs(o.ScrollArea.Autosize,{mah:200,type:"scroll",viewportRef:u,children:[i.length>0?i:s.isFetching?null:e.jsx(o.Combobox.Empty,{onClick:()=>n.closeDropdown(),className:"min-h-6",children:d??"Sin resultados"}),e.jsx(S.InfinityLoader,{className:"text-sm",infinity:s,loaderProps:{size:"sm",className:"mt-1 mb-2"}})]})})]})]})}exports.SelectInfinity=f;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/SelectInfinity/index.tsx"],"sourcesContent":["'use client';\r\nimport {\r\n Combobox,\r\n ComboboxItem,\r\n ElementProps,\r\n Input,\r\n InputBase,\r\n InputBaseProps,\r\n ScrollArea,\r\n useCombobox,\r\n} from '@mantine/core';\r\nimport { InfiniteData } from '@tanstack/react-query';\r\nimport { ReactNode, useRef } from 'react';\r\nimport { InfiniteQueryHookResult } from 'react-query-kit';\r\nimport { useFetchNextPageOnScroll } from '../../hooks/useFetchNextPageOnScroll';\r\nimport { InfinityLoader } from '../InfinityLoader';\r\n\r\nexport interface SelectInfinityProps\r\n extends InputBaseProps,\r\n ElementProps<'button', keyof InputBaseProps | 'value' | 'onChange'> {\r\n value?: string | null;\r\n onChange?: (value: string | null) => void;\r\n data?: ComboboxItem[];\r\n searchValue?: string;\r\n onSearchChange?: (value: string) => void;\r\n renderOption?: (args: { option: ComboboxItem }) => React.ReactNode;\r\n onOptionSubmit?: (value: string) => void;\r\n nothingFoundMessage?: ReactNode;\r\n infinity: InfiniteQueryHookResult<InfiniteData<{ data: unknown[] }, number>, Error>;\r\n placeholder?: string;\r\n}\r\n\r\nexport function SelectInfinity({\r\n value,\r\n onChange,\r\n data = [],\r\n searchValue,\r\n onSearchChange,\r\n renderOption,\r\n onOptionSubmit,\r\n nothingFoundMessage,\r\n infinity,\r\n placeholder,\r\n ...props\r\n}: SelectInfinityProps) {\r\n const combobox = useCombobox({\r\n onDropdownClose: () => {\r\n combobox.resetSelectedOption();\r\n combobox.focusTarget();\r\n onSearchChange?.('');\r\n },\r\n onDropdownOpen: () => {\r\n combobox.focusSearchInput();\r\n },\r\n });\r\n\r\n const options = data.map((i) => (\r\n <Combobox.Option\r\n value={i.value}\r\n key={i.value}\r\n >\r\n {renderOption ? renderOption({ option: i }) : i.label}\r\n </Combobox.Option>\r\n ));\r\n\r\n const selectedOption = data.find((i) => i.value === value);\r\n\r\n const scrollAreaRef = useRef<HTMLDivElement>(null);\r\n\r\n useFetchNextPageOnScroll(infinity, scrollAreaRef);\r\n\r\n return (\r\n <Combobox\r\n store={combobox}\r\n middlewares={{\r\n shift: {\r\n crossAxis: true,\r\n },\r\n }}\r\n onOptionSubmit={(val) => {\r\n onChange?.(val);\r\n onOptionSubmit?.(val);\r\n combobox.closeDropdown();\r\n }}\r\n >\r\n <Combobox.Target>\r\n <InputBase\r\n component=\"button\"\r\n type=\"button\"\r\n pointer\r\n rightSection={<Combobox.Chevron />}\r\n onClick={() => combobox.toggleDropdown()}\r\n rightSectionPointerEvents=\"none\"\r\n {...props}\r\n >\r\n {selectedOption?.label || <Input.Placeholder>{placeholder}</Input.Placeholder>}\r\n </InputBase>\r\n </Combobox.Target>\r\n <Combobox.Dropdown>\r\n <Combobox.Search\r\n value={searchValue}\r\n onChange={(event) => onSearchChange?.(event.currentTarget.value)}\r\n placeholder=\"Escribe para buscar\"\r\n />\r\n <Combobox.Options>\r\n <ScrollArea.Autosize\r\n mah={200}\r\n type=\"scroll\"\r\n viewportRef={scrollAreaRef}\r\n >\r\n {options.length > 0 ? (\r\n options\r\n ) : !infinity.isFetching ? (\r\n <Combobox.Empty\r\n onClick={() => combobox.closeDropdown()}\r\n className=\"min-h-6\"\r\n >\r\n {nothingFoundMessage ?? 'Sin resultados'}\r\n </Combobox.Empty>\r\n ) : null}\r\n <InfinityLoader\r\n className=\"text-sm\"\r\n infinity={infinity}\r\n loaderProps={{\r\n size: 'sm',\r\n className: 'mt-1 mb-2',\r\n }}\r\n />\r\n </ScrollArea.Autosize>\r\n </Combobox.Options>\r\n </Combobox.Dropdown>\r\n </Combobox>\r\n );\r\n}\r\n"],"names":["SelectInfinity","value","onChange","data","searchValue","onSearchChange","renderOption","onOptionSubmit","nothingFoundMessage","infinity","placeholder","props","combobox","useCombobox","options","i","jsx","Combobox","selectedOption","scrollAreaRef","useRef","useFetchNextPageOnScroll","jsxs","val","InputBase","Input","event","ScrollArea","InfinityLoader"],"mappings":"+QAgCO,SAASA,EAAe,CAC7B,MAAAC,EACA,SAAAC,EACA,KAAAC,EAAO,CAAC,EACR,YAAAC,EACA,eAAAC,EACA,aAAAC,EACA,eAAAC,EACA,oBAAAC,EACA,SAAAC,EACA,YAAAC,EACA,GAAGC,CACL,EAAwB,CACtB,MAAMC,EAAWC,EAAAA,YAAY,CAC3B,gBAAiB,IAAM,CACrBD,EAAS,oBAAoB,EAC7BA,EAAS,YAAY,EACrBP,IAAiB,EAAE,CACrB,EACA,eAAgB,IAAM,CACpBO,EAAS,iBAAiB,CAAA,CAC5B,CACD,EAEKE,EAAUX,EAAK,IAAKY,GACxBC,EAAA,IAACC,EAAAA,SAAS,OAAT,CACC,MAAOF,EAAE,MAGR,WAAeT,EAAa,CAAE,OAAQS,CAAE,CAAC,EAAIA,EAAE,KAAA,EAF3CA,EAAE,KAAA,CAIV,EAEKG,EAAiBf,EAAK,KAAMY,GAAMA,EAAE,QAAUd,CAAK,EAEnDkB,EAAgBC,SAAuB,IAAI,EAEjDC,OAAAA,EAAA,yBAAyBZ,EAAUU,CAAa,EAG9CG,EAAA,KAACL,EAAA,SAAA,CACC,MAAOL,EACP,YAAa,CACX,MAAO,CACL,UAAW,EAAA,CAEf,EACA,eAAiBW,GAAQ,CACvBrB,IAAWqB,CAAG,EACdhB,IAAiBgB,CAAG,EACpBX,EAAS,cAAc,CACzB,EAEA,SAAA,CAACI,EAAAA,IAAAC,EAAA,SAAS,OAAT,CACC,SAAAD,EAAA,IAACQ,EAAA,UAAA,CACC,UAAU,SACV,KAAK,SACL,QAAO,GACP,aAAcR,EAAA,IAACC,WAAS,QAAT,CAAA,CAAiB,EAChC,QAAS,IAAML,EAAS,eAAe,EACvC,0BAA0B,OACzB,GAAGD,EAEH,YAAgB,OAASK,EAAA,IAACS,EAAM,MAAA,YAAN,CAAmB,SAAYf,CAAA,CAAA,CAAA,CAAA,EAE9D,EACAY,EAAAA,KAACL,EAAS,SAAA,SAAT,CACC,SAAA,CAAAD,EAAA,IAACC,EAAAA,SAAS,OAAT,CACC,MAAOb,EACP,SAAWsB,GAAUrB,IAAiBqB,EAAM,cAAc,KAAK,EAC/D,YAAY,qBAAA,CACd,EACAV,EAAAA,IAACC,EAAS,SAAA,QAAT,CACC,SAAAK,EAAA,KAACK,EAAAA,WAAW,SAAX,CACC,IAAK,IACL,KAAK,SACL,YAAaR,EAEZ,SAAA,CAAAL,EAAQ,OAAS,EAChBA,EACGL,EAAS,WAOV,KANFO,EAAA,IAACC,EAAAA,SAAS,MAAT,CACC,QAAS,IAAML,EAAS,cAAc,EACtC,UAAU,UAET,SAAuBJ,GAAA,gBAAA,CAAA,EAG5BQ,EAAA,IAACY,EAAA,eAAA,CACC,UAAU,UACV,SAAAnB,EACA,YAAa,CACX,KAAM,KACN,UAAW,WAAA,CACb,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CAAA,CAAA,CACF,CAEJ"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as o, jsxs as l } from "react/jsx-runtime";
|
|
3
|
+
import { useCombobox as S, Combobox as t, InputBase as v, Input as w, ScrollArea as C } from "@mantine/core";
|
|
4
|
+
import { useRef as D } from "react";
|
|
5
|
+
import { useFetchNextPageOnScroll as O } from "../../hooks/useFetchNextPageOnScroll.mjs";
|
|
6
|
+
import { InfinityLoader as I } from "../InfinityLoader/index.mjs";
|
|
7
|
+
function R({
|
|
8
|
+
value: u,
|
|
9
|
+
onChange: m,
|
|
10
|
+
data: s = [],
|
|
11
|
+
searchValue: d,
|
|
12
|
+
onSearchChange: c,
|
|
13
|
+
renderOption: i,
|
|
14
|
+
onOptionSubmit: h,
|
|
15
|
+
nothingFoundMessage: b,
|
|
16
|
+
infinity: n,
|
|
17
|
+
placeholder: f,
|
|
18
|
+
...g
|
|
19
|
+
}) {
|
|
20
|
+
const r = S({
|
|
21
|
+
onDropdownClose: () => {
|
|
22
|
+
r.resetSelectedOption(), r.focusTarget(), c?.("");
|
|
23
|
+
},
|
|
24
|
+
onDropdownOpen: () => {
|
|
25
|
+
r.focusSearchInput();
|
|
26
|
+
}
|
|
27
|
+
}), p = s.map((e) => /* @__PURE__ */ o(
|
|
28
|
+
t.Option,
|
|
29
|
+
{
|
|
30
|
+
value: e.value,
|
|
31
|
+
children: i ? i({ option: e }) : e.label
|
|
32
|
+
},
|
|
33
|
+
e.value
|
|
34
|
+
)), x = s.find((e) => e.value === u), a = D(null);
|
|
35
|
+
return O(n, a), /* @__PURE__ */ l(
|
|
36
|
+
t,
|
|
37
|
+
{
|
|
38
|
+
store: r,
|
|
39
|
+
middlewares: {
|
|
40
|
+
shift: {
|
|
41
|
+
crossAxis: !0
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
onOptionSubmit: (e) => {
|
|
45
|
+
m?.(e), h?.(e), r.closeDropdown();
|
|
46
|
+
},
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ o(t.Target, { children: /* @__PURE__ */ o(
|
|
49
|
+
v,
|
|
50
|
+
{
|
|
51
|
+
component: "button",
|
|
52
|
+
type: "button",
|
|
53
|
+
pointer: !0,
|
|
54
|
+
rightSection: /* @__PURE__ */ o(t.Chevron, {}),
|
|
55
|
+
onClick: () => r.toggleDropdown(),
|
|
56
|
+
rightSectionPointerEvents: "none",
|
|
57
|
+
...g,
|
|
58
|
+
children: x?.label || /* @__PURE__ */ o(w.Placeholder, { children: f })
|
|
59
|
+
}
|
|
60
|
+
) }),
|
|
61
|
+
/* @__PURE__ */ l(t.Dropdown, { children: [
|
|
62
|
+
/* @__PURE__ */ o(
|
|
63
|
+
t.Search,
|
|
64
|
+
{
|
|
65
|
+
value: d,
|
|
66
|
+
onChange: (e) => c?.(e.currentTarget.value),
|
|
67
|
+
placeholder: "Escribe para buscar"
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ o(t.Options, { children: /* @__PURE__ */ l(
|
|
71
|
+
C.Autosize,
|
|
72
|
+
{
|
|
73
|
+
mah: 200,
|
|
74
|
+
type: "scroll",
|
|
75
|
+
viewportRef: a,
|
|
76
|
+
children: [
|
|
77
|
+
p.length > 0 ? p : n.isFetching ? null : /* @__PURE__ */ o(
|
|
78
|
+
t.Empty,
|
|
79
|
+
{
|
|
80
|
+
onClick: () => r.closeDropdown(),
|
|
81
|
+
className: "min-h-6",
|
|
82
|
+
children: b ?? "Sin resultados"
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
/* @__PURE__ */ o(
|
|
86
|
+
I,
|
|
87
|
+
{
|
|
88
|
+
className: "text-sm",
|
|
89
|
+
infinity: n,
|
|
90
|
+
loaderProps: {
|
|
91
|
+
size: "sm",
|
|
92
|
+
className: "mt-1 mb-2"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
) })
|
|
99
|
+
] })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
R as SelectInfinity
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/components/SelectInfinity/index.tsx"],"sourcesContent":["'use client';\r\nimport {\r\n Combobox,\r\n ComboboxItem,\r\n ElementProps,\r\n Input,\r\n InputBase,\r\n InputBaseProps,\r\n ScrollArea,\r\n useCombobox,\r\n} from '@mantine/core';\r\nimport { InfiniteData } from '@tanstack/react-query';\r\nimport { ReactNode, useRef } from 'react';\r\nimport { InfiniteQueryHookResult } from 'react-query-kit';\r\nimport { useFetchNextPageOnScroll } from '../../hooks/useFetchNextPageOnScroll';\r\nimport { InfinityLoader } from '../InfinityLoader';\r\n\r\nexport interface SelectInfinityProps\r\n extends InputBaseProps,\r\n ElementProps<'button', keyof InputBaseProps | 'value' | 'onChange'> {\r\n value?: string | null;\r\n onChange?: (value: string | null) => void;\r\n data?: ComboboxItem[];\r\n searchValue?: string;\r\n onSearchChange?: (value: string) => void;\r\n renderOption?: (args: { option: ComboboxItem }) => React.ReactNode;\r\n onOptionSubmit?: (value: string) => void;\r\n nothingFoundMessage?: ReactNode;\r\n infinity: InfiniteQueryHookResult<InfiniteData<{ data: unknown[] }, number>, Error>;\r\n placeholder?: string;\r\n}\r\n\r\nexport function SelectInfinity({\r\n value,\r\n onChange,\r\n data = [],\r\n searchValue,\r\n onSearchChange,\r\n renderOption,\r\n onOptionSubmit,\r\n nothingFoundMessage,\r\n infinity,\r\n placeholder,\r\n ...props\r\n}: SelectInfinityProps) {\r\n const combobox = useCombobox({\r\n onDropdownClose: () => {\r\n combobox.resetSelectedOption();\r\n combobox.focusTarget();\r\n onSearchChange?.('');\r\n },\r\n onDropdownOpen: () => {\r\n combobox.focusSearchInput();\r\n },\r\n });\r\n\r\n const options = data.map((i) => (\r\n <Combobox.Option\r\n value={i.value}\r\n key={i.value}\r\n >\r\n {renderOption ? renderOption({ option: i }) : i.label}\r\n </Combobox.Option>\r\n ));\r\n\r\n const selectedOption = data.find((i) => i.value === value);\r\n\r\n const scrollAreaRef = useRef<HTMLDivElement>(null);\r\n\r\n useFetchNextPageOnScroll(infinity, scrollAreaRef);\r\n\r\n return (\r\n <Combobox\r\n store={combobox}\r\n middlewares={{\r\n shift: {\r\n crossAxis: true,\r\n },\r\n }}\r\n onOptionSubmit={(val) => {\r\n onChange?.(val);\r\n onOptionSubmit?.(val);\r\n combobox.closeDropdown();\r\n }}\r\n >\r\n <Combobox.Target>\r\n <InputBase\r\n component=\"button\"\r\n type=\"button\"\r\n pointer\r\n rightSection={<Combobox.Chevron />}\r\n onClick={() => combobox.toggleDropdown()}\r\n rightSectionPointerEvents=\"none\"\r\n {...props}\r\n >\r\n {selectedOption?.label || <Input.Placeholder>{placeholder}</Input.Placeholder>}\r\n </InputBase>\r\n </Combobox.Target>\r\n <Combobox.Dropdown>\r\n <Combobox.Search\r\n value={searchValue}\r\n onChange={(event) => onSearchChange?.(event.currentTarget.value)}\r\n placeholder=\"Escribe para buscar\"\r\n />\r\n <Combobox.Options>\r\n <ScrollArea.Autosize\r\n mah={200}\r\n type=\"scroll\"\r\n viewportRef={scrollAreaRef}\r\n >\r\n {options.length > 0 ? (\r\n options\r\n ) : !infinity.isFetching ? (\r\n <Combobox.Empty\r\n onClick={() => combobox.closeDropdown()}\r\n className=\"min-h-6\"\r\n >\r\n {nothingFoundMessage ?? 'Sin resultados'}\r\n </Combobox.Empty>\r\n ) : null}\r\n <InfinityLoader\r\n className=\"text-sm\"\r\n infinity={infinity}\r\n loaderProps={{\r\n size: 'sm',\r\n className: 'mt-1 mb-2',\r\n }}\r\n />\r\n </ScrollArea.Autosize>\r\n </Combobox.Options>\r\n </Combobox.Dropdown>\r\n </Combobox>\r\n );\r\n}\r\n"],"names":["SelectInfinity","value","onChange","data","searchValue","onSearchChange","renderOption","onOptionSubmit","nothingFoundMessage","infinity","placeholder","props","combobox","useCombobox","options","i","jsx","Combobox","selectedOption","scrollAreaRef","useRef","useFetchNextPageOnScroll","jsxs","val","InputBase","Input","event","ScrollArea","InfinityLoader"],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var o=(e=>(e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.EarlyHints=103]="EarlyHints",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.ImUsed=226]="ImUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e))(o||{});exports.HttpStatus=o;
|
|
2
|
+
//# sourceMappingURL=http-status.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-status.cjs","sources":["../../src/consts/http-status.ts"],"sourcesContent":["export enum HttpStatus {\r\n Continue = 100,\r\n SwitchingProtocols = 101,\r\n Processing = 102,\r\n EarlyHints = 103,\r\n Ok = 200,\r\n Created = 201,\r\n Accepted = 202,\r\n NonAuthoritativeInformation = 203,\r\n NoContent = 204,\r\n ResetContent = 205,\r\n PartialContent = 206,\r\n MultiStatus = 207,\r\n AlreadyReported = 208,\r\n ImUsed = 226,\r\n MultipleChoices = 300,\r\n MovedPermanently = 301,\r\n Found = 302,\r\n SeeOther = 303,\r\n NotModified = 304,\r\n UseProxy = 305,\r\n TemporaryRedirect = 307,\r\n PermanentRedirect = 308,\r\n BadRequest = 400,\r\n Unauthorized = 401,\r\n PaymentRequired = 402,\r\n Forbidden = 403,\r\n NotFound = 404,\r\n MethodNotAllowed = 405,\r\n NotAcceptable = 406,\r\n ProxyAuthenticationRequired = 407,\r\n RequestTimeout = 408,\r\n Conflict = 409,\r\n Gone = 410,\r\n LengthRequired = 411,\r\n PreconditionFailed = 412,\r\n PayloadTooLarge = 413,\r\n UriTooLong = 414,\r\n UnsupportedMediaType = 415,\r\n RangeNotSatisfiable = 416,\r\n ExpectationFailed = 417,\r\n MisdirectedRequest = 421,\r\n UnprocessableEntity = 422,\r\n Locked = 423,\r\n FailedDependency = 424,\r\n TooEarly = 425,\r\n UpgradeRequired = 426,\r\n PreconditionRequired = 428,\r\n TooManyRequests = 429,\r\n RequestHeaderFieldsTooLarge = 431,\r\n UnavailableForLegalReasons = 451,\r\n InternalServerError = 500,\r\n NotImplemented = 501,\r\n BadGateway = 502,\r\n ServiceUnavailable = 503,\r\n GatewayTimeout = 504,\r\n HttpVersionNotSupported = 505,\r\n VariantAlsoNegotiates = 506,\r\n InsufficientStorage = 507,\r\n LoopDetected = 508,\r\n NotExtended = 510,\r\n NetworkAuthenticationRequired = 511,\r\n}\r\n"],"names":["HttpStatus"],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var o = /* @__PURE__ */ ((e) => (e[e.Continue = 100] = "Continue", e[e.SwitchingProtocols = 101] = "SwitchingProtocols", e[e.Processing = 102] = "Processing", e[e.EarlyHints = 103] = "EarlyHints", e[e.Ok = 200] = "Ok", e[e.Created = 201] = "Created", e[e.Accepted = 202] = "Accepted", e[e.NonAuthoritativeInformation = 203] = "NonAuthoritativeInformation", e[e.NoContent = 204] = "NoContent", e[e.ResetContent = 205] = "ResetContent", e[e.PartialContent = 206] = "PartialContent", e[e.MultiStatus = 207] = "MultiStatus", e[e.AlreadyReported = 208] = "AlreadyReported", e[e.ImUsed = 226] = "ImUsed", e[e.MultipleChoices = 300] = "MultipleChoices", e[e.MovedPermanently = 301] = "MovedPermanently", e[e.Found = 302] = "Found", e[e.SeeOther = 303] = "SeeOther", e[e.NotModified = 304] = "NotModified", e[e.UseProxy = 305] = "UseProxy", e[e.TemporaryRedirect = 307] = "TemporaryRedirect", e[e.PermanentRedirect = 308] = "PermanentRedirect", e[e.BadRequest = 400] = "BadRequest", e[e.Unauthorized = 401] = "Unauthorized", e[e.PaymentRequired = 402] = "PaymentRequired", e[e.Forbidden = 403] = "Forbidden", e[e.NotFound = 404] = "NotFound", e[e.MethodNotAllowed = 405] = "MethodNotAllowed", e[e.NotAcceptable = 406] = "NotAcceptable", e[e.ProxyAuthenticationRequired = 407] = "ProxyAuthenticationRequired", e[e.RequestTimeout = 408] = "RequestTimeout", e[e.Conflict = 409] = "Conflict", e[e.Gone = 410] = "Gone", e[e.LengthRequired = 411] = "LengthRequired", e[e.PreconditionFailed = 412] = "PreconditionFailed", e[e.PayloadTooLarge = 413] = "PayloadTooLarge", e[e.UriTooLong = 414] = "UriTooLong", e[e.UnsupportedMediaType = 415] = "UnsupportedMediaType", e[e.RangeNotSatisfiable = 416] = "RangeNotSatisfiable", e[e.ExpectationFailed = 417] = "ExpectationFailed", e[e.MisdirectedRequest = 421] = "MisdirectedRequest", e[e.UnprocessableEntity = 422] = "UnprocessableEntity", e[e.Locked = 423] = "Locked", e[e.FailedDependency = 424] = "FailedDependency", e[e.TooEarly = 425] = "TooEarly", e[e.UpgradeRequired = 426] = "UpgradeRequired", e[e.PreconditionRequired = 428] = "PreconditionRequired", e[e.TooManyRequests = 429] = "TooManyRequests", e[e.RequestHeaderFieldsTooLarge = 431] = "RequestHeaderFieldsTooLarge", e[e.UnavailableForLegalReasons = 451] = "UnavailableForLegalReasons", e[e.InternalServerError = 500] = "InternalServerError", e[e.NotImplemented = 501] = "NotImplemented", e[e.BadGateway = 502] = "BadGateway", e[e.ServiceUnavailable = 503] = "ServiceUnavailable", e[e.GatewayTimeout = 504] = "GatewayTimeout", e[e.HttpVersionNotSupported = 505] = "HttpVersionNotSupported", e[e.VariantAlsoNegotiates = 506] = "VariantAlsoNegotiates", e[e.InsufficientStorage = 507] = "InsufficientStorage", e[e.LoopDetected = 508] = "LoopDetected", e[e.NotExtended = 510] = "NotExtended", e[e.NetworkAuthenticationRequired = 511] = "NetworkAuthenticationRequired", e))(o || {});
|
|
2
|
+
export {
|
|
3
|
+
o as HttpStatus
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=http-status.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-status.mjs","sources":["../../src/consts/http-status.ts"],"sourcesContent":["export enum HttpStatus {\r\n Continue = 100,\r\n SwitchingProtocols = 101,\r\n Processing = 102,\r\n EarlyHints = 103,\r\n Ok = 200,\r\n Created = 201,\r\n Accepted = 202,\r\n NonAuthoritativeInformation = 203,\r\n NoContent = 204,\r\n ResetContent = 205,\r\n PartialContent = 206,\r\n MultiStatus = 207,\r\n AlreadyReported = 208,\r\n ImUsed = 226,\r\n MultipleChoices = 300,\r\n MovedPermanently = 301,\r\n Found = 302,\r\n SeeOther = 303,\r\n NotModified = 304,\r\n UseProxy = 305,\r\n TemporaryRedirect = 307,\r\n PermanentRedirect = 308,\r\n BadRequest = 400,\r\n Unauthorized = 401,\r\n PaymentRequired = 402,\r\n Forbidden = 403,\r\n NotFound = 404,\r\n MethodNotAllowed = 405,\r\n NotAcceptable = 406,\r\n ProxyAuthenticationRequired = 407,\r\n RequestTimeout = 408,\r\n Conflict = 409,\r\n Gone = 410,\r\n LengthRequired = 411,\r\n PreconditionFailed = 412,\r\n PayloadTooLarge = 413,\r\n UriTooLong = 414,\r\n UnsupportedMediaType = 415,\r\n RangeNotSatisfiable = 416,\r\n ExpectationFailed = 417,\r\n MisdirectedRequest = 421,\r\n UnprocessableEntity = 422,\r\n Locked = 423,\r\n FailedDependency = 424,\r\n TooEarly = 425,\r\n UpgradeRequired = 426,\r\n PreconditionRequired = 428,\r\n TooManyRequests = 429,\r\n RequestHeaderFieldsTooLarge = 431,\r\n UnavailableForLegalReasons = 451,\r\n InternalServerError = 500,\r\n NotImplemented = 501,\r\n BadGateway = 502,\r\n ServiceUnavailable = 503,\r\n GatewayTimeout = 504,\r\n HttpVersionNotSupported = 505,\r\n VariantAlsoNegotiates = 506,\r\n InsufficientStorage = 507,\r\n LoopDetected = 508,\r\n NotExtended = 510,\r\n NetworkAuthenticationRequired = 511,\r\n}\r\n"],"names":["HttpStatus"],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var r=(n=>(n[n.OneHour=3600]="OneHour",n[n.OneDay=86400]="OneDay",n[n.OneWeek=604800]="OneWeek",n[n.OneMonth=2592e3]="OneMonth",n[n.OneYear=31536e3]="OneYear",n))(r||{});exports.Revalidate=r;
|
|
2
|
+
//# sourceMappingURL=revalidate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidate.cjs","sources":["../../src/consts/revalidate.ts"],"sourcesContent":["export enum Revalidate {\r\n OneHour = 3600,\r\n OneDay = 86400,\r\n OneWeek = 604800,\r\n OneMonth = 2592000,\r\n OneYear = 31536000\r\n}\r\n"],"names":["Revalidate"],"mappings":"gFAAY,IAAAA,GAAAA,IACVA,EAAAA,EAAA,QAAU,IAAV,EAAA,UACAA,EAAAA,EAAA,OAAS,KAAT,EAAA,SACAA,EAAAA,EAAA,QAAU,MAAV,EAAA,UACAA,EAAAA,EAAA,SAAW,MAAX,EAAA,WACAA,EAAAA,EAAA,QAAU,OAAV,EAAA,UALUA,IAAAA,GAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var O = /* @__PURE__ */ ((n) => (n[n.OneHour = 3600] = "OneHour", n[n.OneDay = 86400] = "OneDay", n[n.OneWeek = 604800] = "OneWeek", n[n.OneMonth = 2592e3] = "OneMonth", n[n.OneYear = 31536e3] = "OneYear", n))(O || {});
|
|
2
|
+
export {
|
|
3
|
+
O as Revalidate
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=revalidate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidate.mjs","sources":["../../src/consts/revalidate.ts"],"sourcesContent":["export enum Revalidate {\r\n OneHour = 3600,\r\n OneDay = 86400,\r\n OneWeek = 604800,\r\n OneMonth = 2592000,\r\n OneYear = 31536000\r\n}\r\n"],"names":["Revalidate"],"mappings":"AAAY,IAAAA,sBAAAA,OACVA,EAAAA,EAAA,UAAU,IAAV,IAAA,WACAA,EAAAA,EAAA,SAAS,KAAT,IAAA,UACAA,EAAAA,EAAA,UAAU,MAAV,IAAA,WACAA,EAAAA,EAAA,WAAW,MAAX,IAAA,YACAA,EAAAA,EAAA,UAAU,OAAV,IAAA,WALUA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),i=require("next/navigation"),u=require("react"),c=u.createContext(null);function v({children:s}){const e=i.usePathname(),o=i.useSearchParams(),[t,a]=u.useState([]);return u.useEffect(()=>{const r=o?.size?`${e}?${o.toString()}`:e;r&&a(n=>n.length>0&&n[n.length-1]===r?n:[...n,r])},[e,o]),P.jsx(c.Provider,{value:{history:t},children:s})}const g="backUrl";function y(){const s=u.useContext(c),e=i.useRouter();if(!s)throw new Error("useNavigationHistory debe usarse dentro de un NavigationHistoryProvider");const o=i.useSearchParams(),{history:t}=s;return{history:t,goBack:r=>{const n=o.get(g);if(n){e.push(n);return}if(t.length<=1){e.push(r??"/");return}const h=t[t.length-2],l=t[t.length-1];if(t.length>=3&&t[t.length-3]===l){e.push(r??"/");return}e.push(h??"/")},currentRoute:t.length>0?t[t.length-1]:null,hasPreviousRoute:t.length>1,getPreviousRoute:()=>t.length>=2?t[t.length-2]:null}}exports.NavigationHistoryProvider=v;exports.QP_BACK_URL_NAME=g;exports.useNavigationHistory=y;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/contexts/NavigationHistoryContext/index.tsx"],"sourcesContent":["'use client';\r\nimport { usePathname, useRouter, useSearchParams } from 'next/navigation';\r\nimport { createContext, ReactNode, useContext, useEffect, useState } from 'react';\r\n\r\n// Defining types for the context value\r\ninterface NavigationHistoryContextType {\r\n history: string[];\r\n}\r\n\r\n// Creating the context with a proper type\r\nconst NavigationHistoryContext = createContext<NavigationHistoryContextType | null>(null);\r\n\r\n// Props type for the provider component\r\ninterface NavigationHistoryProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\n/**\r\n * Proveedor de historial de navegación\r\n * Solo se encarga de registrar las rutas visitadas\r\n */\r\nexport function NavigationHistoryProvider({ children }: NavigationHistoryProviderProps) {\r\n const pathname = usePathname();\r\n const searchParams = useSearchParams();\r\n\r\n // Estado para almacenar el historial de navegación\r\n const [history, setHistory] = useState<string[]>([]);\r\n\r\n // Efecto para actualizar el historial cuando cambia la ruta o los parámetros\r\n useEffect(() => {\r\n // Creamos la URL completa (ruta + parámetros)\r\n const fullPath = searchParams?.size ? `${pathname}?${searchParams.toString()}` : pathname;\r\n\r\n if (fullPath) {\r\n setHistory((prev) => {\r\n // Evitar duplicados consecutivos\r\n if (prev.length > 0 && prev[prev.length - 1] === fullPath) {\r\n return prev;\r\n }\r\n return [...prev, fullPath];\r\n });\r\n }\r\n }, [pathname, searchParams]);\r\n\r\n return (\r\n <NavigationHistoryContext.Provider value={{ history }}>\r\n {children}\r\n </NavigationHistoryContext.Provider>\r\n );\r\n}\r\n\r\n// Return type for the useNavigationHistory hook\r\ninterface NavigationHistoryHook {\r\n history: string[];\r\n goBack: (fallback?: string) => void;\r\n currentRoute: string | null;\r\n hasPreviousRoute: boolean;\r\n getPreviousRoute: () => string | null;\r\n}\r\n\r\nexport const QP_BACK_URL_NAME = 'backUrl';\r\n\r\n/**\r\n * Hook para usar el historial de navegación\r\n * @returns {NavigationHistoryHook} Objeto con el historial y la función goBack\r\n */\r\nexport function useNavigationHistory(): NavigationHistoryHook {\r\n const context = useContext(NavigationHistoryContext);\r\n const router = useRouter();\r\n\r\n if (!context) {\r\n throw new Error('useNavigationHistory debe usarse dentro de un NavigationHistoryProvider');\r\n }\r\n\r\n const searchParams = useSearchParams();\r\n\r\n const { history } = context;\r\n\r\n /**\r\n * Navega hacia atrás en el historial o a la ruta de fallback\r\n * @param {string} fallback - Ruta a la que ir si no hay historial previo\r\n */\r\n const goBack = (fallback?: string) => {\r\n const returnUrl = searchParams.get(QP_BACK_URL_NAME);\r\n if (returnUrl) {\r\n router.push(returnUrl);\r\n return;\r\n }\r\n\r\n if (history.length <= 1) {\r\n router.push(fallback ?? '/');\r\n return;\r\n }\r\n\r\n // Obtener las dos últimas rutas\r\n const previousRoute = history[history.length - 2];\r\n const currentRoute = history[history.length - 1];\r\n\r\n // Si hay más de 2 rutas en el historial y detectamos un patrón de bucle\r\n if (history.length >= 3 && history[history.length - 3] === currentRoute) {\r\n // Ir a una ruta segura (home) o a la ruta de fallback\r\n router.push(fallback ?? '/');\r\n return;\r\n }\r\n\r\n // Navegación normal\r\n router.push(previousRoute ?? '/');\r\n };\r\n\r\n return {\r\n history,\r\n goBack,\r\n currentRoute: history.length > 0 ? history[history.length - 1] : null,\r\n hasPreviousRoute: history.length > 1,\r\n getPreviousRoute: () => (history.length >= 2 ? history[history.length - 2] : null),\r\n };\r\n}\r\n"],"names":["NavigationHistoryContext","createContext","NavigationHistoryProvider","children","pathname","usePathname","searchParams","useSearchParams","history","setHistory","useState","useEffect","fullPath","prev","jsx","QP_BACK_URL_NAME","useNavigationHistory","context","useContext","router","useRouter","fallback","returnUrl","previousRoute","currentRoute"],"mappings":"kLAUMA,EAA2BC,gBAAmD,IAAI,EAWxE,SAAAC,EAA0B,CAAE,SAAAC,GAA4C,CACtF,MAAMC,EAAWC,EAAAA,YAAY,EACvBC,EAAeC,EAAAA,gBAAgB,EAG/B,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAAmB,CAAA,CAAE,EAGnDC,OAAAA,EAAAA,UAAU,IAAM,CAER,MAAAC,EAAWN,GAAc,KAAO,GAAGF,CAAQ,IAAIE,EAAa,UAAU,GAAKF,EAE7EQ,GACFH,EAAYI,GAENA,EAAK,OAAS,GAAKA,EAAKA,EAAK,OAAS,CAAC,IAAMD,EACxCC,EAEF,CAAC,GAAGA,EAAMD,CAAQ,CAC1B,CACH,EACC,CAACR,EAAUE,CAAY,CAAC,EAGzBQ,EAAA,IAACd,EAAyB,SAAzB,CAAkC,MAAO,CAAE,QAAAQ,CAAA,EACzC,SAAAL,EACH,CAEJ,CAWO,MAAMY,EAAmB,UAMzB,SAASC,GAA8C,CACtD,MAAAC,EAAUC,aAAWlB,CAAwB,EAC7CmB,EAASC,EAAAA,UAAU,EAEzB,GAAI,CAACH,EACG,MAAA,IAAI,MAAM,yEAAyE,EAG3F,MAAMX,EAAeC,EAAAA,gBAAgB,EAE/B,CAAE,QAAAC,GAAYS,EAiCb,MAAA,CACL,QAAAT,EACA,OA7Bca,GAAsB,CAC9B,MAAAC,EAAYhB,EAAa,IAAIS,CAAgB,EACnD,GAAIO,EAAW,CACbH,EAAO,KAAKG,CAAS,EACrB,MAAA,CAGE,GAAAd,EAAQ,QAAU,EAAG,CAChBW,EAAA,KAAKE,GAAY,GAAG,EAC3B,MAAA,CAIF,MAAME,EAAgBf,EAAQA,EAAQ,OAAS,CAAC,EAC1CgB,EAAehB,EAAQA,EAAQ,OAAS,CAAC,EAG3C,GAAAA,EAAQ,QAAU,GAAKA,EAAQA,EAAQ,OAAS,CAAC,IAAMgB,EAAc,CAEhEL,EAAA,KAAKE,GAAY,GAAG,EAC3B,MAAA,CAIKF,EAAA,KAAKI,GAAiB,GAAG,CAClC,EAKE,aAAcf,EAAQ,OAAS,EAAIA,EAAQA,EAAQ,OAAS,CAAC,EAAI,KACjE,iBAAkBA,EAAQ,OAAS,EACnC,iBAAkB,IAAOA,EAAQ,QAAU,EAAIA,EAAQA,EAAQ,OAAS,CAAC,EAAI,IAC/E,CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
3
|
+
import { usePathname as l, useSearchParams as i, useRouter as f } from "next/navigation";
|
|
4
|
+
import { createContext as m, useState as P, useEffect as v, useContext as y } from "react";
|
|
5
|
+
const a = m(null);
|
|
6
|
+
function H({ children: s }) {
|
|
7
|
+
const e = l(), r = i(), [t, u] = P([]);
|
|
8
|
+
return v(() => {
|
|
9
|
+
const o = r?.size ? `${e}?${r.toString()}` : e;
|
|
10
|
+
o && u((n) => n.length > 0 && n[n.length - 1] === o ? n : [...n, o]);
|
|
11
|
+
}, [e, r]), /* @__PURE__ */ g(a.Provider, { value: { history: t }, children: s });
|
|
12
|
+
}
|
|
13
|
+
const R = "backUrl";
|
|
14
|
+
function N() {
|
|
15
|
+
const s = y(a), e = f();
|
|
16
|
+
if (!s)
|
|
17
|
+
throw new Error("useNavigationHistory debe usarse dentro de un NavigationHistoryProvider");
|
|
18
|
+
const r = i(), { history: t } = s;
|
|
19
|
+
return {
|
|
20
|
+
history: t,
|
|
21
|
+
goBack: (o) => {
|
|
22
|
+
const n = r.get(R);
|
|
23
|
+
if (n) {
|
|
24
|
+
e.push(n);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (t.length <= 1) {
|
|
28
|
+
e.push(o ?? "/");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const c = t[t.length - 2], h = t[t.length - 1];
|
|
32
|
+
if (t.length >= 3 && t[t.length - 3] === h) {
|
|
33
|
+
e.push(o ?? "/");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
e.push(c ?? "/");
|
|
37
|
+
},
|
|
38
|
+
currentRoute: t.length > 0 ? t[t.length - 1] : null,
|
|
39
|
+
hasPreviousRoute: t.length > 1,
|
|
40
|
+
getPreviousRoute: () => t.length >= 2 ? t[t.length - 2] : null
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
H as NavigationHistoryProvider,
|
|
45
|
+
R as QP_BACK_URL_NAME,
|
|
46
|
+
N as useNavigationHistory
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/contexts/NavigationHistoryContext/index.tsx"],"sourcesContent":["'use client';\r\nimport { usePathname, useRouter, useSearchParams } from 'next/navigation';\r\nimport { createContext, ReactNode, useContext, useEffect, useState } from 'react';\r\n\r\n// Defining types for the context value\r\ninterface NavigationHistoryContextType {\r\n history: string[];\r\n}\r\n\r\n// Creating the context with a proper type\r\nconst NavigationHistoryContext = createContext<NavigationHistoryContextType | null>(null);\r\n\r\n// Props type for the provider component\r\ninterface NavigationHistoryProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\n/**\r\n * Proveedor de historial de navegación\r\n * Solo se encarga de registrar las rutas visitadas\r\n */\r\nexport function NavigationHistoryProvider({ children }: NavigationHistoryProviderProps) {\r\n const pathname = usePathname();\r\n const searchParams = useSearchParams();\r\n\r\n // Estado para almacenar el historial de navegación\r\n const [history, setHistory] = useState<string[]>([]);\r\n\r\n // Efecto para actualizar el historial cuando cambia la ruta o los parámetros\r\n useEffect(() => {\r\n // Creamos la URL completa (ruta + parámetros)\r\n const fullPath = searchParams?.size ? `${pathname}?${searchParams.toString()}` : pathname;\r\n\r\n if (fullPath) {\r\n setHistory((prev) => {\r\n // Evitar duplicados consecutivos\r\n if (prev.length > 0 && prev[prev.length - 1] === fullPath) {\r\n return prev;\r\n }\r\n return [...prev, fullPath];\r\n });\r\n }\r\n }, [pathname, searchParams]);\r\n\r\n return (\r\n <NavigationHistoryContext.Provider value={{ history }}>\r\n {children}\r\n </NavigationHistoryContext.Provider>\r\n );\r\n}\r\n\r\n// Return type for the useNavigationHistory hook\r\ninterface NavigationHistoryHook {\r\n history: string[];\r\n goBack: (fallback?: string) => void;\r\n currentRoute: string | null;\r\n hasPreviousRoute: boolean;\r\n getPreviousRoute: () => string | null;\r\n}\r\n\r\nexport const QP_BACK_URL_NAME = 'backUrl';\r\n\r\n/**\r\n * Hook para usar el historial de navegación\r\n * @returns {NavigationHistoryHook} Objeto con el historial y la función goBack\r\n */\r\nexport function useNavigationHistory(): NavigationHistoryHook {\r\n const context = useContext(NavigationHistoryContext);\r\n const router = useRouter();\r\n\r\n if (!context) {\r\n throw new Error('useNavigationHistory debe usarse dentro de un NavigationHistoryProvider');\r\n }\r\n\r\n const searchParams = useSearchParams();\r\n\r\n const { history } = context;\r\n\r\n /**\r\n * Navega hacia atrás en el historial o a la ruta de fallback\r\n * @param {string} fallback - Ruta a la que ir si no hay historial previo\r\n */\r\n const goBack = (fallback?: string) => {\r\n const returnUrl = searchParams.get(QP_BACK_URL_NAME);\r\n if (returnUrl) {\r\n router.push(returnUrl);\r\n return;\r\n }\r\n\r\n if (history.length <= 1) {\r\n router.push(fallback ?? '/');\r\n return;\r\n }\r\n\r\n // Obtener las dos últimas rutas\r\n const previousRoute = history[history.length - 2];\r\n const currentRoute = history[history.length - 1];\r\n\r\n // Si hay más de 2 rutas en el historial y detectamos un patrón de bucle\r\n if (history.length >= 3 && history[history.length - 3] === currentRoute) {\r\n // Ir a una ruta segura (home) o a la ruta de fallback\r\n router.push(fallback ?? '/');\r\n return;\r\n }\r\n\r\n // Navegación normal\r\n router.push(previousRoute ?? '/');\r\n };\r\n\r\n return {\r\n history,\r\n goBack,\r\n currentRoute: history.length > 0 ? history[history.length - 1] : null,\r\n hasPreviousRoute: history.length > 1,\r\n getPreviousRoute: () => (history.length >= 2 ? history[history.length - 2] : null),\r\n };\r\n}\r\n"],"names":["NavigationHistoryContext","createContext","NavigationHistoryProvider","children","pathname","usePathname","searchParams","useSearchParams","history","setHistory","useState","useEffect","fullPath","prev","jsx","QP_BACK_URL_NAME","useNavigationHistory","context","useContext","router","useRouter","fallback","returnUrl","previousRoute","currentRoute"],"mappings":";;;;AAUA,MAAMA,IAA2BC,EAAmD,IAAI;AAWxE,SAAAC,EAA0B,EAAE,UAAAC,KAA4C;AACtF,QAAMC,IAAWC,EAAY,GACvBC,IAAeC,EAAgB,GAG/B,CAACC,GAASC,CAAU,IAAIC,EAAmB,CAAA,CAAE;AAGnD,SAAAC,EAAU,MAAM;AAER,UAAAC,IAAWN,GAAc,OAAO,GAAGF,CAAQ,IAAIE,EAAa,UAAU,KAAKF;AAEjF,IAAIQ,KACFH,EAAW,CAACI,MAENA,EAAK,SAAS,KAAKA,EAAKA,EAAK,SAAS,CAAC,MAAMD,IACxCC,IAEF,CAAC,GAAGA,GAAMD,CAAQ,CAC1B;AAAA,EACH,GACC,CAACR,GAAUE,CAAY,CAAC,GAGzB,gBAAAQ,EAACd,EAAyB,UAAzB,EAAkC,OAAO,EAAE,SAAAQ,EAAA,GACzC,UAAAL,GACH;AAEJ;AAWO,MAAMY,IAAmB;AAMzB,SAASC,IAA8C;AACtD,QAAAC,IAAUC,EAAWlB,CAAwB,GAC7CmB,IAASC,EAAU;AAEzB,MAAI,CAACH;AACG,UAAA,IAAI,MAAM,yEAAyE;AAG3F,QAAMX,IAAeC,EAAgB,GAE/B,EAAE,SAAAC,MAAYS;AAiCb,SAAA;AAAA,IACL,SAAAT;AAAA,IACA,QA7Ba,CAACa,MAAsB;AAC9B,YAAAC,IAAYhB,EAAa,IAAIS,CAAgB;AACnD,UAAIO,GAAW;AACb,QAAAH,EAAO,KAAKG,CAAS;AACrB;AAAA,MAAA;AAGE,UAAAd,EAAQ,UAAU,GAAG;AAChB,QAAAW,EAAA,KAAKE,KAAY,GAAG;AAC3B;AAAA,MAAA;AAIF,YAAME,IAAgBf,EAAQA,EAAQ,SAAS,CAAC,GAC1CgB,IAAehB,EAAQA,EAAQ,SAAS,CAAC;AAG3C,UAAAA,EAAQ,UAAU,KAAKA,EAAQA,EAAQ,SAAS,CAAC,MAAMgB,GAAc;AAEhE,QAAAL,EAAA,KAAKE,KAAY,GAAG;AAC3B;AAAA,MAAA;AAIK,MAAAF,EAAA,KAAKI,KAAiB,GAAG;AAAA,IAClC;AAAA,IAKE,cAAcf,EAAQ,SAAS,IAAIA,EAAQA,EAAQ,SAAS,CAAC,IAAI;AAAA,IACjE,kBAAkBA,EAAQ,SAAS;AAAA,IACnC,kBAAkB,MAAOA,EAAQ,UAAU,IAAIA,EAAQA,EAAQ,SAAS,CAAC,IAAI;AAAA,EAC/E;AACF;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),t=require("react"),a=t.createContext(void 0),n=({value:e,children:r})=>o.jsx(a.Provider,{value:e,children:r}),s=()=>{const e=t.useContext(a);if(e===void 0)throw new Error("Out of context: usePageData");return e};exports.PageDataProvider=n;exports.usePageData=s;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/contexts/PageDataContext/index.tsx"],"sourcesContent":["\"use client\";\r\nimport { createContext, useContext } from \"react\";\r\n\r\nconst PageData = createContext<any | undefined>(undefined);\r\n\r\ninterface PageDataProviderProps {\r\n children: React.ReactNode;\r\n value: any;\r\n}\r\n\r\nexport const PageDataProvider = ({\r\n value,\r\n children\r\n}: PageDataProviderProps) => (\r\n <PageData.Provider value={value}>{children}</PageData.Provider>\r\n);\r\nexport const usePageData = <T,>(): T => {\r\n const data = useContext(PageData);\r\n if (data === undefined) throw new Error(\"Out of context: usePageData\");\r\n\r\n return data;\r\n};\r\n"],"names":["PageData","createContext","PageDataProvider","value","children","jsx","usePageData","data","useContext"],"mappings":"qJAGMA,EAAWC,gBAA+B,MAAS,EAO5CC,EAAmB,CAAC,CAC/B,MAAAC,EACA,SAAAC,CACF,IACGC,EAAA,IAAAL,EAAS,SAAT,CAAkB,MAAAG,EAAe,SAAAC,CAAS,CAAA,EAEhCE,EAAc,IAAa,CAChC,MAAAC,EAAOC,aAAWR,CAAQ,EAChC,GAAIO,IAAS,OAAiB,MAAA,IAAI,MAAM,6BAA6B,EAE9D,OAAAA,CACT"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as a, useContext as n } from "react";
|
|
4
|
+
const e = a(void 0), c = ({
|
|
5
|
+
value: t,
|
|
6
|
+
children: o
|
|
7
|
+
}) => /* @__PURE__ */ r(e.Provider, { value: t, children: o }), u = () => {
|
|
8
|
+
const t = n(e);
|
|
9
|
+
if (t === void 0) throw new Error("Out of context: usePageData");
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
c as PageDataProvider,
|
|
14
|
+
u as usePageData
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/contexts/PageDataContext/index.tsx"],"sourcesContent":["\"use client\";\r\nimport { createContext, useContext } from \"react\";\r\n\r\nconst PageData = createContext<any | undefined>(undefined);\r\n\r\ninterface PageDataProviderProps {\r\n children: React.ReactNode;\r\n value: any;\r\n}\r\n\r\nexport const PageDataProvider = ({\r\n value,\r\n children\r\n}: PageDataProviderProps) => (\r\n <PageData.Provider value={value}>{children}</PageData.Provider>\r\n);\r\nexport const usePageData = <T,>(): T => {\r\n const data = useContext(PageData);\r\n if (data === undefined) throw new Error(\"Out of context: usePageData\");\r\n\r\n return data;\r\n};\r\n"],"names":["PageData","createContext","PageDataProvider","value","children","jsx","usePageData","data","useContext"],"mappings":";;;AAGA,MAAMA,IAAWC,EAA+B,MAAS,GAO5CC,IAAmB,CAAC;AAAA,EAC/B,OAAAC;AAAA,EACA,UAAAC;AACF,MACG,gBAAAC,EAAAL,EAAS,UAAT,EAAkB,OAAAG,GAAe,UAAAC,EAAS,CAAA,GAEhCE,IAAc,MAAa;AAChC,QAAAC,IAAOC,EAAWR,CAAQ;AAChC,MAAIO,MAAS,OAAiB,OAAA,IAAI,MAAM,6BAA6B;AAE9D,SAAAA;AACT;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),i=require("@mantine/core"),c=require("react-hook-form"),u=({methods:e,onSubmit:o=()=>{},onSubmitError:t,...n})=>r.jsx(c.FormProvider,{...e,children:r.jsx(i.Box,{component:"form",onSubmit:e.handleSubmit(o,t),...n})});exports.Form=u;
|
|
2
|
+
//# sourceMappingURL=Form.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.cjs","sources":["../../src/form/Form.tsx"],"sourcesContent":["'use client';\r\nimport { Box, BoxProps, ElementProps } from '@mantine/core';\r\nimport {\r\n FieldValues,\r\n FormProvider,\r\n SubmitErrorHandler,\r\n SubmitHandler,\r\n UseFormReturn,\r\n} from 'react-hook-form';\r\n\r\n// TODO: Completar el tipado con el schema usando z.output<schema> en el data del onSubmit\r\ninterface FormProps<T extends FieldValues> extends BoxProps, ElementProps<'form', 'onSubmit'> {\r\n methods: UseFormReturn<T, any, any>;\r\n onSubmit?: SubmitHandler<T>;\r\n onSubmitError?: SubmitErrorHandler<any>;\r\n}\r\n\r\nexport const Form = <T extends FieldValues>({\r\n methods,\r\n onSubmit = () => {},\r\n onSubmitError,\r\n ...rest\r\n}: FormProps<T>) => {\r\n return (\r\n <FormProvider {...methods}>\r\n <Box\r\n component=\"form\"\r\n onSubmit={methods.handleSubmit(onSubmit, onSubmitError)}\r\n {...rest}\r\n />\r\n </FormProvider>\r\n );\r\n};\r\n"],"names":["Form","methods","onSubmit","onSubmitError","rest","jsx","FormProvider","Box"],"mappings":"0LAiBaA,EAAO,CAAwB,CAC1C,QAAAC,EACA,SAAAC,EAAW,IAAM,CAAC,EAClB,cAAAC,EACA,GAAGC,CACL,IAEIC,EAAA,IAACC,EAAc,aAAA,CAAA,GAAGL,EAChB,SAAAI,EAAA,IAACE,EAAA,IAAA,CACC,UAAU,OACV,SAAUN,EAAQ,aAAaC,EAAUC,CAAa,EACrD,GAAGC,CAAA,CAAA,EAER"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { Box as n } from "@mantine/core";
|
|
4
|
+
import { FormProvider as e } from "react-hook-form";
|
|
5
|
+
const u = ({
|
|
6
|
+
methods: o,
|
|
7
|
+
onSubmit: m = () => {
|
|
8
|
+
},
|
|
9
|
+
onSubmitError: t,
|
|
10
|
+
...i
|
|
11
|
+
}) => /* @__PURE__ */ r(e, { ...o, children: /* @__PURE__ */ r(
|
|
12
|
+
n,
|
|
13
|
+
{
|
|
14
|
+
component: "form",
|
|
15
|
+
onSubmit: o.handleSubmit(m, t),
|
|
16
|
+
...i
|
|
17
|
+
}
|
|
18
|
+
) });
|
|
19
|
+
export {
|
|
20
|
+
u as Form
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=Form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.mjs","sources":["../../src/form/Form.tsx"],"sourcesContent":["'use client';\r\nimport { Box, BoxProps, ElementProps } from '@mantine/core';\r\nimport {\r\n FieldValues,\r\n FormProvider,\r\n SubmitErrorHandler,\r\n SubmitHandler,\r\n UseFormReturn,\r\n} from 'react-hook-form';\r\n\r\n// TODO: Completar el tipado con el schema usando z.output<schema> en el data del onSubmit\r\ninterface FormProps<T extends FieldValues> extends BoxProps, ElementProps<'form', 'onSubmit'> {\r\n methods: UseFormReturn<T, any, any>;\r\n onSubmit?: SubmitHandler<T>;\r\n onSubmitError?: SubmitErrorHandler<any>;\r\n}\r\n\r\nexport const Form = <T extends FieldValues>({\r\n methods,\r\n onSubmit = () => {},\r\n onSubmitError,\r\n ...rest\r\n}: FormProps<T>) => {\r\n return (\r\n <FormProvider {...methods}>\r\n <Box\r\n component=\"form\"\r\n onSubmit={methods.handleSubmit(onSubmit, onSubmitError)}\r\n {...rest}\r\n />\r\n </FormProvider>\r\n );\r\n};\r\n"],"names":["Form","methods","onSubmit","onSubmitError","rest","jsx","FormProvider","Box"],"mappings":";;;;AAiBO,MAAMA,IAAO,CAAwB;AAAA,EAC1C,SAAAC;AAAA,EACA,UAAAC,IAAW,MAAM;AAAA,EAAC;AAAA,EAClB,eAAAC;AAAA,EACA,GAAGC;AACL,MAEI,gBAAAC,EAACC,GAAc,EAAA,GAAGL,GAChB,UAAA,gBAAAI;AAAA,EAACE;AAAA,EAAA;AAAA,IACC,WAAU;AAAA,IACV,UAAUN,EAAQ,aAAaC,GAAUC,CAAa;AAAA,IACrD,GAAGC;AAAA,EAAA;AAAA,GAER;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("@mantine/core"),u=require("react-hook-form"),i=t=>{const{formState:e}=u.useFormContext(),{isSubmitting:o}=e;return r.jsx(n.Button,{loading:o,type:"submit",...t})};exports.FormButtonSubmit=i;
|
|
2
|
+
//# sourceMappingURL=FormButtonSubmit.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormButtonSubmit.cjs","sources":["../../src/form/FormButtonSubmit.tsx"],"sourcesContent":["'use client';\r\nimport { Button, ButtonProps, ElementProps } from '@mantine/core';\r\nimport { useFormContext } from 'react-hook-form';\r\n\r\nexport interface FormButtonSubmitProps\r\n extends ButtonProps,\r\n ElementProps<'button', keyof ButtonProps> {}\r\n\r\nexport const FormButtonSubmit = (props: FormButtonSubmitProps) => {\r\n const { formState } = useFormContext();\r\n\r\n const { isSubmitting } = formState;\r\n\r\n return (\r\n <Button\r\n // disabled={isSubmitSuccessful}\r\n loading={isSubmitting}\r\n type=\"submit\"\r\n {...props}\r\n />\r\n );\r\n};\r\n"],"names":["FormButtonSubmit","props","formState","useFormContext","isSubmitting","jsx","Button"],"mappings":"0LAQaA,EAAoBC,GAAiC,CAC1D,KAAA,CAAE,UAAAC,CAAU,EAAIC,iBAAe,EAE/B,CAAE,aAAAC,GAAiBF,EAGvB,OAAAG,EAAA,IAACC,EAAA,OAAA,CAEC,QAASF,EACT,KAAK,SACJ,GAAGH,CAAA,CACN,CAEJ"}
|