lkd-web-kit 0.0.0 → 0.0.2

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.
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
6
+ HttpStatus2[HttpStatus2["Continue"] = 100] = "Continue";
7
+ HttpStatus2[HttpStatus2["SwitchingProtocols"] = 101] = "SwitchingProtocols";
8
+ HttpStatus2[HttpStatus2["Processing"] = 102] = "Processing";
9
+ HttpStatus2[HttpStatus2["EarlyHints"] = 103] = "EarlyHints";
10
+ HttpStatus2[HttpStatus2["Ok"] = 200] = "Ok";
11
+ HttpStatus2[HttpStatus2["Created"] = 201] = "Created";
12
+ HttpStatus2[HttpStatus2["Accepted"] = 202] = "Accepted";
13
+ HttpStatus2[HttpStatus2["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
14
+ HttpStatus2[HttpStatus2["NoContent"] = 204] = "NoContent";
15
+ HttpStatus2[HttpStatus2["ResetContent"] = 205] = "ResetContent";
16
+ HttpStatus2[HttpStatus2["PartialContent"] = 206] = "PartialContent";
17
+ HttpStatus2[HttpStatus2["MultiStatus"] = 207] = "MultiStatus";
18
+ HttpStatus2[HttpStatus2["AlreadyReported"] = 208] = "AlreadyReported";
19
+ HttpStatus2[HttpStatus2["ImUsed"] = 226] = "ImUsed";
20
+ HttpStatus2[HttpStatus2["MultipleChoices"] = 300] = "MultipleChoices";
21
+ HttpStatus2[HttpStatus2["MovedPermanently"] = 301] = "MovedPermanently";
22
+ HttpStatus2[HttpStatus2["Found"] = 302] = "Found";
23
+ HttpStatus2[HttpStatus2["SeeOther"] = 303] = "SeeOther";
24
+ HttpStatus2[HttpStatus2["NotModified"] = 304] = "NotModified";
25
+ HttpStatus2[HttpStatus2["UseProxy"] = 305] = "UseProxy";
26
+ HttpStatus2[HttpStatus2["TemporaryRedirect"] = 307] = "TemporaryRedirect";
27
+ HttpStatus2[HttpStatus2["PermanentRedirect"] = 308] = "PermanentRedirect";
28
+ HttpStatus2[HttpStatus2["BadRequest"] = 400] = "BadRequest";
29
+ HttpStatus2[HttpStatus2["Unauthorized"] = 401] = "Unauthorized";
30
+ HttpStatus2[HttpStatus2["PaymentRequired"] = 402] = "PaymentRequired";
31
+ HttpStatus2[HttpStatus2["Forbidden"] = 403] = "Forbidden";
32
+ HttpStatus2[HttpStatus2["NotFound"] = 404] = "NotFound";
33
+ HttpStatus2[HttpStatus2["MethodNotAllowed"] = 405] = "MethodNotAllowed";
34
+ HttpStatus2[HttpStatus2["NotAcceptable"] = 406] = "NotAcceptable";
35
+ HttpStatus2[HttpStatus2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
36
+ HttpStatus2[HttpStatus2["RequestTimeout"] = 408] = "RequestTimeout";
37
+ HttpStatus2[HttpStatus2["Conflict"] = 409] = "Conflict";
38
+ HttpStatus2[HttpStatus2["Gone"] = 410] = "Gone";
39
+ HttpStatus2[HttpStatus2["LengthRequired"] = 411] = "LengthRequired";
40
+ HttpStatus2[HttpStatus2["PreconditionFailed"] = 412] = "PreconditionFailed";
41
+ HttpStatus2[HttpStatus2["PayloadTooLarge"] = 413] = "PayloadTooLarge";
42
+ HttpStatus2[HttpStatus2["UriTooLong"] = 414] = "UriTooLong";
43
+ HttpStatus2[HttpStatus2["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
44
+ HttpStatus2[HttpStatus2["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
45
+ HttpStatus2[HttpStatus2["ExpectationFailed"] = 417] = "ExpectationFailed";
46
+ HttpStatus2[HttpStatus2["MisdirectedRequest"] = 421] = "MisdirectedRequest";
47
+ HttpStatus2[HttpStatus2["UnprocessableEntity"] = 422] = "UnprocessableEntity";
48
+ HttpStatus2[HttpStatus2["Locked"] = 423] = "Locked";
49
+ HttpStatus2[HttpStatus2["FailedDependency"] = 424] = "FailedDependency";
50
+ HttpStatus2[HttpStatus2["TooEarly"] = 425] = "TooEarly";
51
+ HttpStatus2[HttpStatus2["UpgradeRequired"] = 426] = "UpgradeRequired";
52
+ HttpStatus2[HttpStatus2["PreconditionRequired"] = 428] = "PreconditionRequired";
53
+ HttpStatus2[HttpStatus2["TooManyRequests"] = 429] = "TooManyRequests";
54
+ HttpStatus2[HttpStatus2["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
55
+ HttpStatus2[HttpStatus2["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
56
+ HttpStatus2[HttpStatus2["InternalServerError"] = 500] = "InternalServerError";
57
+ HttpStatus2[HttpStatus2["NotImplemented"] = 501] = "NotImplemented";
58
+ HttpStatus2[HttpStatus2["BadGateway"] = 502] = "BadGateway";
59
+ HttpStatus2[HttpStatus2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
60
+ HttpStatus2[HttpStatus2["GatewayTimeout"] = 504] = "GatewayTimeout";
61
+ HttpStatus2[HttpStatus2["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
62
+ HttpStatus2[HttpStatus2["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
63
+ HttpStatus2[HttpStatus2["InsufficientStorage"] = 507] = "InsufficientStorage";
64
+ HttpStatus2[HttpStatus2["LoopDetected"] = 508] = "LoopDetected";
65
+ HttpStatus2[HttpStatus2["NotExtended"] = 510] = "NotExtended";
66
+ HttpStatus2[HttpStatus2["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
67
+ return HttpStatus2;
68
+ })(HttpStatus || {});
69
+
70
+ var Revalidate = /* @__PURE__ */ ((Revalidate2) => {
71
+ Revalidate2[Revalidate2["OneHour"] = 3600] = "OneHour";
72
+ Revalidate2[Revalidate2["OneDay"] = 86400] = "OneDay";
73
+ Revalidate2[Revalidate2["OneWeek"] = 604800] = "OneWeek";
74
+ Revalidate2[Revalidate2["OneMonth"] = 2592e3] = "OneMonth";
75
+ Revalidate2[Revalidate2["OneYear"] = 31536e3] = "OneYear";
76
+ return Revalidate2;
77
+ })(Revalidate || {});
78
+
79
+ exports.HttpStatus = HttpStatus;
80
+ exports.Revalidate = Revalidate;
@@ -0,0 +1,73 @@
1
+ export declare enum HttpStatus {
2
+ Continue = 100,
3
+ SwitchingProtocols = 101,
4
+ Processing = 102,
5
+ EarlyHints = 103,
6
+ Ok = 200,
7
+ Created = 201,
8
+ Accepted = 202,
9
+ NonAuthoritativeInformation = 203,
10
+ NoContent = 204,
11
+ ResetContent = 205,
12
+ PartialContent = 206,
13
+ MultiStatus = 207,
14
+ AlreadyReported = 208,
15
+ ImUsed = 226,
16
+ MultipleChoices = 300,
17
+ MovedPermanently = 301,
18
+ Found = 302,
19
+ SeeOther = 303,
20
+ NotModified = 304,
21
+ UseProxy = 305,
22
+ TemporaryRedirect = 307,
23
+ PermanentRedirect = 308,
24
+ BadRequest = 400,
25
+ Unauthorized = 401,
26
+ PaymentRequired = 402,
27
+ Forbidden = 403,
28
+ NotFound = 404,
29
+ MethodNotAllowed = 405,
30
+ NotAcceptable = 406,
31
+ ProxyAuthenticationRequired = 407,
32
+ RequestTimeout = 408,
33
+ Conflict = 409,
34
+ Gone = 410,
35
+ LengthRequired = 411,
36
+ PreconditionFailed = 412,
37
+ PayloadTooLarge = 413,
38
+ UriTooLong = 414,
39
+ UnsupportedMediaType = 415,
40
+ RangeNotSatisfiable = 416,
41
+ ExpectationFailed = 417,
42
+ MisdirectedRequest = 421,
43
+ UnprocessableEntity = 422,
44
+ Locked = 423,
45
+ FailedDependency = 424,
46
+ TooEarly = 425,
47
+ UpgradeRequired = 426,
48
+ PreconditionRequired = 428,
49
+ TooManyRequests = 429,
50
+ RequestHeaderFieldsTooLarge = 431,
51
+ UnavailableForLegalReasons = 451,
52
+ InternalServerError = 500,
53
+ NotImplemented = 501,
54
+ BadGateway = 502,
55
+ ServiceUnavailable = 503,
56
+ GatewayTimeout = 504,
57
+ HttpVersionNotSupported = 505,
58
+ VariantAlsoNegotiates = 506,
59
+ InsufficientStorage = 507,
60
+ LoopDetected = 508,
61
+ NotExtended = 510,
62
+ NetworkAuthenticationRequired = 511
63
+ }
64
+
65
+ export declare enum Revalidate {
66
+ OneHour = 3600,
67
+ OneDay = 86400,
68
+ OneWeek = 604800,
69
+ OneMonth = 2592000,
70
+ OneYear = 31536000
71
+ }
72
+
73
+ export { }
@@ -0,0 +1,75 @@
1
+ var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
2
+ HttpStatus2[HttpStatus2["Continue"] = 100] = "Continue";
3
+ HttpStatus2[HttpStatus2["SwitchingProtocols"] = 101] = "SwitchingProtocols";
4
+ HttpStatus2[HttpStatus2["Processing"] = 102] = "Processing";
5
+ HttpStatus2[HttpStatus2["EarlyHints"] = 103] = "EarlyHints";
6
+ HttpStatus2[HttpStatus2["Ok"] = 200] = "Ok";
7
+ HttpStatus2[HttpStatus2["Created"] = 201] = "Created";
8
+ HttpStatus2[HttpStatus2["Accepted"] = 202] = "Accepted";
9
+ HttpStatus2[HttpStatus2["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
10
+ HttpStatus2[HttpStatus2["NoContent"] = 204] = "NoContent";
11
+ HttpStatus2[HttpStatus2["ResetContent"] = 205] = "ResetContent";
12
+ HttpStatus2[HttpStatus2["PartialContent"] = 206] = "PartialContent";
13
+ HttpStatus2[HttpStatus2["MultiStatus"] = 207] = "MultiStatus";
14
+ HttpStatus2[HttpStatus2["AlreadyReported"] = 208] = "AlreadyReported";
15
+ HttpStatus2[HttpStatus2["ImUsed"] = 226] = "ImUsed";
16
+ HttpStatus2[HttpStatus2["MultipleChoices"] = 300] = "MultipleChoices";
17
+ HttpStatus2[HttpStatus2["MovedPermanently"] = 301] = "MovedPermanently";
18
+ HttpStatus2[HttpStatus2["Found"] = 302] = "Found";
19
+ HttpStatus2[HttpStatus2["SeeOther"] = 303] = "SeeOther";
20
+ HttpStatus2[HttpStatus2["NotModified"] = 304] = "NotModified";
21
+ HttpStatus2[HttpStatus2["UseProxy"] = 305] = "UseProxy";
22
+ HttpStatus2[HttpStatus2["TemporaryRedirect"] = 307] = "TemporaryRedirect";
23
+ HttpStatus2[HttpStatus2["PermanentRedirect"] = 308] = "PermanentRedirect";
24
+ HttpStatus2[HttpStatus2["BadRequest"] = 400] = "BadRequest";
25
+ HttpStatus2[HttpStatus2["Unauthorized"] = 401] = "Unauthorized";
26
+ HttpStatus2[HttpStatus2["PaymentRequired"] = 402] = "PaymentRequired";
27
+ HttpStatus2[HttpStatus2["Forbidden"] = 403] = "Forbidden";
28
+ HttpStatus2[HttpStatus2["NotFound"] = 404] = "NotFound";
29
+ HttpStatus2[HttpStatus2["MethodNotAllowed"] = 405] = "MethodNotAllowed";
30
+ HttpStatus2[HttpStatus2["NotAcceptable"] = 406] = "NotAcceptable";
31
+ HttpStatus2[HttpStatus2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
32
+ HttpStatus2[HttpStatus2["RequestTimeout"] = 408] = "RequestTimeout";
33
+ HttpStatus2[HttpStatus2["Conflict"] = 409] = "Conflict";
34
+ HttpStatus2[HttpStatus2["Gone"] = 410] = "Gone";
35
+ HttpStatus2[HttpStatus2["LengthRequired"] = 411] = "LengthRequired";
36
+ HttpStatus2[HttpStatus2["PreconditionFailed"] = 412] = "PreconditionFailed";
37
+ HttpStatus2[HttpStatus2["PayloadTooLarge"] = 413] = "PayloadTooLarge";
38
+ HttpStatus2[HttpStatus2["UriTooLong"] = 414] = "UriTooLong";
39
+ HttpStatus2[HttpStatus2["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
40
+ HttpStatus2[HttpStatus2["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
41
+ HttpStatus2[HttpStatus2["ExpectationFailed"] = 417] = "ExpectationFailed";
42
+ HttpStatus2[HttpStatus2["MisdirectedRequest"] = 421] = "MisdirectedRequest";
43
+ HttpStatus2[HttpStatus2["UnprocessableEntity"] = 422] = "UnprocessableEntity";
44
+ HttpStatus2[HttpStatus2["Locked"] = 423] = "Locked";
45
+ HttpStatus2[HttpStatus2["FailedDependency"] = 424] = "FailedDependency";
46
+ HttpStatus2[HttpStatus2["TooEarly"] = 425] = "TooEarly";
47
+ HttpStatus2[HttpStatus2["UpgradeRequired"] = 426] = "UpgradeRequired";
48
+ HttpStatus2[HttpStatus2["PreconditionRequired"] = 428] = "PreconditionRequired";
49
+ HttpStatus2[HttpStatus2["TooManyRequests"] = 429] = "TooManyRequests";
50
+ HttpStatus2[HttpStatus2["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
51
+ HttpStatus2[HttpStatus2["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
52
+ HttpStatus2[HttpStatus2["InternalServerError"] = 500] = "InternalServerError";
53
+ HttpStatus2[HttpStatus2["NotImplemented"] = 501] = "NotImplemented";
54
+ HttpStatus2[HttpStatus2["BadGateway"] = 502] = "BadGateway";
55
+ HttpStatus2[HttpStatus2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
56
+ HttpStatus2[HttpStatus2["GatewayTimeout"] = 504] = "GatewayTimeout";
57
+ HttpStatus2[HttpStatus2["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
58
+ HttpStatus2[HttpStatus2["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
59
+ HttpStatus2[HttpStatus2["InsufficientStorage"] = 507] = "InsufficientStorage";
60
+ HttpStatus2[HttpStatus2["LoopDetected"] = 508] = "LoopDetected";
61
+ HttpStatus2[HttpStatus2["NotExtended"] = 510] = "NotExtended";
62
+ HttpStatus2[HttpStatus2["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
63
+ return HttpStatus2;
64
+ })(HttpStatus || {});
65
+
66
+ var Revalidate = /* @__PURE__ */ ((Revalidate2) => {
67
+ Revalidate2[Revalidate2["OneHour"] = 3600] = "OneHour";
68
+ Revalidate2[Revalidate2["OneDay"] = 86400] = "OneDay";
69
+ Revalidate2[Revalidate2["OneWeek"] = 604800] = "OneWeek";
70
+ Revalidate2[Revalidate2["OneMonth"] = 2592e3] = "OneMonth";
71
+ Revalidate2[Revalidate2["OneYear"] = 31536e3] = "OneYear";
72
+ return Revalidate2;
73
+ })(Revalidate || {});
74
+
75
+ export { HttpStatus, Revalidate };
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const require$$1 = require('react/jsx-runtime');
6
+ const navigation = require('./navigation-DnFkn_t2.cjs');
7
+ const require$$0 = require('react');
8
+
9
+ const NavigationHistoryContext = require$$0.createContext(null);
10
+ function NavigationHistoryProvider({ children }) {
11
+ const pathname = navigation.navigationExports.usePathname();
12
+ const searchParams = navigation.navigationExports.useSearchParams();
13
+ const [history, setHistory] = require$$0.useState([]);
14
+ require$$0.useEffect(() => {
15
+ const fullPath = searchParams?.size ? `${pathname}?${searchParams.toString()}` : pathname;
16
+ if (fullPath) {
17
+ setHistory((prev) => {
18
+ if (prev.length > 0 && prev[prev.length - 1] === fullPath) {
19
+ return prev;
20
+ }
21
+ return [...prev, fullPath];
22
+ });
23
+ }
24
+ }, [pathname, searchParams]);
25
+ return /* @__PURE__ */ require$$1.jsx(NavigationHistoryContext.Provider, { value: { history }, children });
26
+ }
27
+ const QP_BACK_URL_NAME = "backUrl";
28
+ function useNavigationHistory() {
29
+ const context = require$$0.useContext(NavigationHistoryContext);
30
+ const router = navigation.navigationExports.useRouter();
31
+ if (!context) {
32
+ throw new Error("useNavigationHistory debe usarse dentro de un NavigationHistoryProvider");
33
+ }
34
+ const searchParams = navigation.navigationExports.useSearchParams();
35
+ const { history } = context;
36
+ const goBack = (fallback) => {
37
+ const returnUrl = searchParams.get(QP_BACK_URL_NAME);
38
+ if (returnUrl) {
39
+ router.push(returnUrl);
40
+ return;
41
+ }
42
+ if (history.length <= 1) {
43
+ router.push(fallback ?? "/");
44
+ return;
45
+ }
46
+ const previousRoute = history[history.length - 2];
47
+ const currentRoute = history[history.length - 1];
48
+ if (history.length >= 3 && history[history.length - 3] === currentRoute) {
49
+ router.push(fallback ?? "/");
50
+ return;
51
+ }
52
+ router.push(previousRoute ?? "/");
53
+ };
54
+ return {
55
+ history,
56
+ goBack,
57
+ currentRoute: history.length > 0 ? history[history.length - 1] : null,
58
+ hasPreviousRoute: history.length > 1,
59
+ getPreviousRoute: () => history.length >= 2 ? history[history.length - 2] : null
60
+ };
61
+ }
62
+
63
+ const PageData = require$$0.createContext(void 0);
64
+ const PageDataProvider = ({
65
+ value,
66
+ children
67
+ }) => /* @__PURE__ */ require$$1.jsx(PageData.Provider, { value, children });
68
+ const usePageData = () => {
69
+ const data = require$$0.useContext(PageData);
70
+ if (data === void 0) throw new Error("Out of context: usePageData");
71
+ return data;
72
+ };
73
+
74
+ exports.NavigationHistoryProvider = NavigationHistoryProvider;
75
+ exports.PageDataProvider = PageDataProvider;
76
+ exports.QP_BACK_URL_NAME = QP_BACK_URL_NAME;
77
+ exports.useNavigationHistory = useNavigationHistory;
78
+ exports.usePageData = usePageData;
@@ -0,0 +1,39 @@
1
+ import { JSX } from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ declare interface NavigationHistoryHook {
5
+ history: string[];
6
+ goBack: (fallback?: string) => void;
7
+ currentRoute: string | null;
8
+ hasPreviousRoute: boolean;
9
+ getPreviousRoute: () => string | null;
10
+ }
11
+
12
+ /**
13
+ * Proveedor de historial de navegación
14
+ * Solo se encarga de registrar las rutas visitadas
15
+ */
16
+ export declare function NavigationHistoryProvider({ children }: NavigationHistoryProviderProps): JSX.Element;
17
+
18
+ declare interface NavigationHistoryProviderProps {
19
+ children: ReactNode;
20
+ }
21
+
22
+ export declare const PageDataProvider: ({ value, children }: PageDataProviderProps) => JSX.Element;
23
+
24
+ declare interface PageDataProviderProps {
25
+ children: React.ReactNode;
26
+ value: any;
27
+ }
28
+
29
+ export declare const QP_BACK_URL_NAME = "backUrl";
30
+
31
+ /**
32
+ * Hook para usar el historial de navegación
33
+ * @returns {NavigationHistoryHook} Objeto con el historial y la función goBack
34
+ */
35
+ export declare function useNavigationHistory(): NavigationHistoryHook;
36
+
37
+ export declare const usePageData: <T>() => T;
38
+
39
+ export { }
@@ -0,0 +1,70 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { n as navigationExports } from './navigation-sZaWnl2V.js';
3
+ import { createContext, useState, useEffect, useContext } from 'react';
4
+
5
+ const NavigationHistoryContext = createContext(null);
6
+ function NavigationHistoryProvider({ children }) {
7
+ const pathname = navigationExports.usePathname();
8
+ const searchParams = navigationExports.useSearchParams();
9
+ const [history, setHistory] = useState([]);
10
+ useEffect(() => {
11
+ const fullPath = searchParams?.size ? `${pathname}?${searchParams.toString()}` : pathname;
12
+ if (fullPath) {
13
+ setHistory((prev) => {
14
+ if (prev.length > 0 && prev[prev.length - 1] === fullPath) {
15
+ return prev;
16
+ }
17
+ return [...prev, fullPath];
18
+ });
19
+ }
20
+ }, [pathname, searchParams]);
21
+ return /* @__PURE__ */ jsx(NavigationHistoryContext.Provider, { value: { history }, children });
22
+ }
23
+ const QP_BACK_URL_NAME = "backUrl";
24
+ function useNavigationHistory() {
25
+ const context = useContext(NavigationHistoryContext);
26
+ const router = navigationExports.useRouter();
27
+ if (!context) {
28
+ throw new Error("useNavigationHistory debe usarse dentro de un NavigationHistoryProvider");
29
+ }
30
+ const searchParams = navigationExports.useSearchParams();
31
+ const { history } = context;
32
+ const goBack = (fallback) => {
33
+ const returnUrl = searchParams.get(QP_BACK_URL_NAME);
34
+ if (returnUrl) {
35
+ router.push(returnUrl);
36
+ return;
37
+ }
38
+ if (history.length <= 1) {
39
+ router.push(fallback ?? "/");
40
+ return;
41
+ }
42
+ const previousRoute = history[history.length - 2];
43
+ const currentRoute = history[history.length - 1];
44
+ if (history.length >= 3 && history[history.length - 3] === currentRoute) {
45
+ router.push(fallback ?? "/");
46
+ return;
47
+ }
48
+ router.push(previousRoute ?? "/");
49
+ };
50
+ return {
51
+ history,
52
+ goBack,
53
+ currentRoute: history.length > 0 ? history[history.length - 1] : null,
54
+ hasPreviousRoute: history.length > 1,
55
+ getPreviousRoute: () => history.length >= 2 ? history[history.length - 2] : null
56
+ };
57
+ }
58
+
59
+ const PageData = createContext(void 0);
60
+ const PageDataProvider = ({
61
+ value,
62
+ children
63
+ }) => /* @__PURE__ */ jsx(PageData.Provider, { value, children });
64
+ const usePageData = () => {
65
+ const data = useContext(PageData);
66
+ if (data === void 0) throw new Error("Out of context: usePageData");
67
+ return data;
68
+ };
69
+
70
+ export { NavigationHistoryProvider, PageDataProvider, QP_BACK_URL_NAME, useNavigationHistory, usePageData };
@@ -2,9 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const jsxRuntime = require('react/jsx-runtime');
5
+ const require$$1 = require('react/jsx-runtime');
6
6
  const core = require('@mantine/core');
7
7
  const reactHookForm = require('react-hook-form');
8
+ const zodValidator = require('./zodValidator-Bx6RMGoL.cjs');
9
+ const zod = require('zod');
8
10
 
9
11
  const Form = ({
10
12
  methods,
@@ -13,7 +15,7 @@ const Form = ({
13
15
  onSubmitError,
14
16
  ...rest
15
17
  }) => {
16
- return /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children: /* @__PURE__ */ jsxRuntime.jsx(
18
+ return /* @__PURE__ */ require$$1.jsx(reactHookForm.FormProvider, { ...methods, children: /* @__PURE__ */ require$$1.jsx(
17
19
  core.Box,
18
20
  {
19
21
  component: "form",
@@ -26,7 +28,7 @@ const Form = ({
26
28
  const FormButtonSubmit = (props) => {
27
29
  const { formState } = reactHookForm.useFormContext();
28
30
  const { isSubmitting } = formState;
29
- return /* @__PURE__ */ jsxRuntime.jsx(
31
+ return /* @__PURE__ */ require$$1.jsx(
30
32
  core.Button,
31
33
  {
32
34
  loading: isSubmitting,
@@ -36,5 +38,21 @@ const FormButtonSubmit = (props) => {
36
38
  );
37
39
  };
38
40
 
41
+ const nullableInput = (schema, message = "Campo requerido") => {
42
+ return schema.nullable().transform((val, ctx) => {
43
+ if (val === null) {
44
+ ctx.addIssue({
45
+ code: zod.z.ZodIssueCode.custom,
46
+ fatal: true,
47
+ message
48
+ });
49
+ return zod.z.NEVER;
50
+ }
51
+ return val;
52
+ });
53
+ };
54
+
55
+ exports.zodValidator = zodValidator.zodValidator;
39
56
  exports.Form = Form;
40
57
  exports.FormButtonSubmit = FormButtonSubmit;
58
+ exports.nullableInput = nullableInput;
@@ -6,6 +6,8 @@ import { JSX } from 'react/jsx-runtime';
6
6
  import { SubmitErrorHandler } from 'react-hook-form';
7
7
  import { SubmitHandler } from 'react-hook-form';
8
8
  import { UseFormReturn } from 'react-hook-form';
9
+ import { z } from 'zod';
10
+ import { ZodTypeAny } from 'zod';
9
11
 
10
12
  export declare const Form: <T extends FieldValues>({ methods, onSubmit, onSubmitError, ...rest }: FormProps<T>) => JSX.Element;
11
13
 
@@ -20,4 +22,8 @@ declare interface FormProps<T extends FieldValues> extends BoxProps, ElementProp
20
22
  onSubmitError?: SubmitErrorHandler<any>;
21
23
  }
22
24
 
25
+ export declare const nullableInput: <T extends ZodTypeAny>(schema: T, message?: string) => z.ZodEffects<z.ZodNullable<T>, (T["_output"] & undefined) | (T["_output"] & {}), T["_input"] | null>;
26
+
27
+ export declare const zodValidator: (schema: ZodTypeAny) => (values: any) => string | undefined;
28
+
23
29
  export { }
@@ -1,6 +1,8 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { Box, Button } from '@mantine/core';
3
3
  import { FormProvider, useFormContext } from 'react-hook-form';
4
+ export { z as zodValidator } from './zodValidator-ChEQ3cmF.js';
5
+ import { z } from 'zod';
4
6
 
5
7
  const Form = ({
6
8
  methods,
@@ -32,4 +34,18 @@ const FormButtonSubmit = (props) => {
32
34
  );
33
35
  };
34
36
 
35
- export { Form, FormButtonSubmit };
37
+ const nullableInput = (schema, message = "Campo requerido") => {
38
+ return schema.nullable().transform((val, ctx) => {
39
+ if (val === null) {
40
+ ctx.addIssue({
41
+ code: z.ZodIssueCode.custom,
42
+ fatal: true,
43
+ message
44
+ });
45
+ return z.NEVER;
46
+ }
47
+ return val;
48
+ });
49
+ };
50
+
51
+ export { Form, FormButtonSubmit, nullableInput };
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const require$$1 = require('react/jsx-runtime');
6
+ const reactHookForm = require('react-hook-form');
7
+ require('@mantine/core');
8
+ const zodValidator = require('./zodValidator-Bx6RMGoL.cjs');
9
+ require('zod');
10
+ const require$$0 = require('react');
11
+
12
+ const withForm = (WrappedComponent, getControllerProps) => {
13
+ const FormField = (props) => {
14
+ const { validate, name = "", placeholder, label, description, ...withFormRestProps } = props;
15
+ return /* @__PURE__ */ require$$1.jsx(
16
+ reactHookForm.Controller,
17
+ {
18
+ name,
19
+ defaultValue: "",
20
+ rules: {
21
+ validate: validate && !props.disabled ? zodValidator.zodValidator(validate) : void 0
22
+ },
23
+ disabled: props.disabled,
24
+ ...getControllerProps?.(props),
25
+ render: (renderProps) => {
26
+ const {
27
+ fieldState: { isTouched, error }
28
+ } = renderProps;
29
+ const fieldProps = {
30
+ ...renderProps,
31
+ props: {
32
+ ...props,
33
+ validate: void 0
34
+ },
35
+ field: {
36
+ ...renderProps.field,
37
+ label,
38
+ placeholder,
39
+ description,
40
+ error: error?.message
41
+ },
42
+ ...withFormRestProps
43
+ };
44
+ return /* @__PURE__ */ require$$1.jsx(WrappedComponent, { ...fieldProps });
45
+ }
46
+ }
47
+ );
48
+ };
49
+ FormField.displayName = `withForm(${WrappedComponent.displayName})`;
50
+ return FormField;
51
+ };
52
+
53
+ const withModalManager = (WrappedComponent) => {
54
+ const Component = ({
55
+ removeModal,
56
+ opened,
57
+ ...props
58
+ }) => {
59
+ const [isOpen, setIsOpen] = require$$0.useState(false);
60
+ const onClose = () => {
61
+ setIsOpen(false);
62
+ setTimeout(() => removeModal(), 200);
63
+ props.onClose?.();
64
+ };
65
+ require$$0.useEffect(() => {
66
+ if (opened) setTimeout(() => setIsOpen(true), 0);
67
+ else onClose();
68
+ }, [opened]);
69
+ return /* @__PURE__ */ require$$1.jsx(WrappedComponent, { ...props, opened: isOpen, onClose });
70
+ };
71
+ Component.displayName = `withModalManager(${WrappedComponent.displayName})`;
72
+ return Component;
73
+ };
74
+
75
+ exports.withForm = withForm;
76
+ exports.withModalManager = withModalManager;
package/dist/hocs.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { ControllerProps } from 'react-hook-form';
2
+ import { FC } from 'react';
3
+ import { ModalProps } from '@mantine/core';
4
+ import { ZodTypeAny } from 'zod';
5
+
6
+ export declare type FormFieldProps<T = unknown> = Parameters<ControllerProps['render']>[0] & {
7
+ props: T;
8
+ field: {
9
+ label?: React.ReactNode;
10
+ placeholder?: string;
11
+ description?: React.ReactNode;
12
+ error?: string;
13
+ };
14
+ };
15
+
16
+ export declare const withForm: <P extends unknown>(WrappedComponent: React.ComponentType<FormFieldProps<P>>, getControllerProps?: (props: P) => Omit<Partial<ControllerProps>, "render">) => FC<P & WithFormProps>;
17
+
18
+ export declare interface WithFormProps {
19
+ name?: string;
20
+ label?: React.ReactNode;
21
+ placeholder?: string;
22
+ description?: React.ReactNode;
23
+ validate?: ZodTypeAny;
24
+ disabled?: boolean;
25
+ }
26
+
27
+ export declare const withModalManager: <P extends Object>(WrappedComponent: React.ComponentType<P & ModalProps>) => FC<P & WithModalManagerProps & ModalProps>;
28
+
29
+ export declare interface WithModalManagerProps {
30
+ removeModal: () => void;
31
+ opened: boolean;
32
+ }
33
+
34
+ export { }