lkd-web-kit 0.0.2 → 0.0.4

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.
@@ -1,116 +0,0 @@
1
- import { CenterProps } from '@mantine/core';
2
- import { ComboboxItem } from '@mantine/core';
3
- import { ComponentProps } from 'react';
4
- import { ComponentPropsWithoutRef } from 'react';
5
- import { default as default_2 } from 'react';
6
- import { ElementProps } from '@mantine/core';
7
- import { InfiniteData } from '@tanstack/react-query';
8
- import { InfiniteQueryHookResult } from 'react-query-kit';
9
- import { InputBaseProps } from '@mantine/core';
10
- import { JSX } from 'react/jsx-runtime';
11
- import { LoaderProps } from '@mantine/core';
12
- import { MouseEvent as MouseEvent_2 } from 'react';
13
- import { ReactNode } from 'react';
14
-
15
- export declare interface EmptyProps extends ComponentProps<'div'> {
16
- label: ReactNode;
17
- action?: ReactNode;
18
- icon: IconFC;
19
- size?: keyof typeof pxBySize;
20
- }
21
-
22
- export declare const EmptyState: ({ label, action, icon, className, size, ...props }: EmptyProps) => JSX.Element;
23
-
24
- export declare type IconFC = default_2.FC<ComponentPropsWithoutRef<"svg">>;
25
-
26
- export declare interface IconProps extends ComponentPropsWithoutRef<"svg"> {
27
- i: IconFC;
28
- /**
29
- * @property xs: 16px
30
- * @property sm: 20px
31
- * @property md: 24px
32
- * @property lg: 28px
33
- * @property xl: 32px
34
- * @property 2xl: 40px
35
- */
36
- size?: keyof typeof stylesBySize | number;
37
- }
38
-
39
- export declare const InfinityLoader: ({ infinity, loaderProps, ...props }: InfinityLoaderProps) => JSX.Element;
40
-
41
- export declare interface InfinityLoaderProps extends CenterProps {
42
- infinity: InfiniteQueryHookResult<InfiniteData<{
43
- data: unknown[];
44
- }>, unknown>;
45
- loaderProps?: LoaderProps;
46
- }
47
-
48
- export declare const NavItems: ({ items }: NavItemsProps) => JSX.Element;
49
-
50
- export declare interface NavItemsProps {
51
- items: {
52
- leftSection?: ReactNode;
53
- rightSection?: ReactNode;
54
- onClick?: (e: MouseEvent_2<Element>) => void;
55
- disabled?: boolean;
56
- className?: string;
57
- children?: ReactNode;
58
- label: string;
59
- href?: string;
60
- isActive?: boolean;
61
- }[];
62
- }
63
-
64
- declare const pxBySize: {
65
- sm: number;
66
- md: number;
67
- lg: number;
68
- };
69
-
70
- export declare function SelectInfinity({ value, onChange, data, searchValue, onSearchChange, renderOption, onOptionSubmit, nothingFoundMessage, infinity, placeholder, ...props }: SelectInfinityProps): JSX.Element;
71
-
72
- export declare interface SelectInfinityProps extends InputBaseProps, ElementProps<'button', keyof InputBaseProps | 'value' | 'onChange'> {
73
- value?: string | null;
74
- onChange?: (value: string | null) => void;
75
- data?: ComboboxItem[];
76
- searchValue?: string;
77
- onSearchChange?: (value: string) => void;
78
- renderOption?: (args: {
79
- option: ComboboxItem;
80
- }) => React.ReactNode;
81
- onOptionSubmit?: (value: string) => void;
82
- nothingFoundMessage?: ReactNode;
83
- infinity: InfiniteQueryHookResult<InfiniteData<{
84
- data: unknown[];
85
- }, number>, Error>;
86
- placeholder?: string;
87
- }
88
-
89
- declare const stylesBySize: {
90
- xs: {
91
- height: number;
92
- width: number;
93
- };
94
- sm: {
95
- height: number;
96
- width: number;
97
- };
98
- md: {
99
- height: number;
100
- width: number;
101
- };
102
- lg: {
103
- height: number;
104
- width: number;
105
- };
106
- xl: {
107
- height: number;
108
- width: number;
109
- };
110
- "2xl": {
111
- height: number;
112
- width: number;
113
- };
114
- };
115
-
116
- export { }
@@ -1,80 +0,0 @@
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;
package/dist/consts.d.ts DELETED
@@ -1,73 +0,0 @@
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 { }
package/dist/consts.es.js DELETED
@@ -1,75 +0,0 @@
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 };
@@ -1,78 +0,0 @@
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;
@@ -1,39 +0,0 @@
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 { }
@@ -1,70 +0,0 @@
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 };
package/dist/form.cjs.js DELETED
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const require$$1 = require('react/jsx-runtime');
6
- const core = require('@mantine/core');
7
- const reactHookForm = require('react-hook-form');
8
- const zodValidator = require('./zodValidator-Bx6RMGoL.cjs');
9
- const zod = require('zod');
10
-
11
- const Form = ({
12
- methods,
13
- onSubmit = () => {
14
- },
15
- onSubmitError,
16
- ...rest
17
- }) => {
18
- return /* @__PURE__ */ require$$1.jsx(reactHookForm.FormProvider, { ...methods, children: /* @__PURE__ */ require$$1.jsx(
19
- core.Box,
20
- {
21
- component: "form",
22
- onSubmit: methods.handleSubmit(onSubmit, onSubmitError),
23
- ...rest
24
- }
25
- ) });
26
- };
27
-
28
- const FormButtonSubmit = (props) => {
29
- const { formState } = reactHookForm.useFormContext();
30
- const { isSubmitting } = formState;
31
- return /* @__PURE__ */ require$$1.jsx(
32
- core.Button,
33
- {
34
- loading: isSubmitting,
35
- type: "submit",
36
- ...props
37
- }
38
- );
39
- };
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;
56
- exports.Form = Form;
57
- exports.FormButtonSubmit = FormButtonSubmit;
58
- exports.nullableInput = nullableInput;
package/dist/form.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import { BoxProps } from '@mantine/core';
2
- import { ButtonProps } from '@mantine/core';
3
- import { ElementProps } from '@mantine/core';
4
- import { FieldValues } from 'react-hook-form';
5
- import { JSX } from 'react/jsx-runtime';
6
- import { SubmitErrorHandler } from 'react-hook-form';
7
- import { SubmitHandler } from 'react-hook-form';
8
- import { UseFormReturn } from 'react-hook-form';
9
- import { z } from 'zod';
10
- import { ZodTypeAny } from 'zod';
11
-
12
- export declare const Form: <T extends FieldValues>({ methods, onSubmit, onSubmitError, ...rest }: FormProps<T>) => JSX.Element;
13
-
14
- export declare const FormButtonSubmit: (props: FormButtonSubmitProps) => JSX.Element;
15
-
16
- export declare interface FormButtonSubmitProps extends ButtonProps, ElementProps<"button", keyof ButtonProps> {
17
- }
18
-
19
- declare interface FormProps<T extends FieldValues> extends BoxProps, ElementProps<'form', 'onSubmit'> {
20
- methods: UseFormReturn<T, any, any>;
21
- onSubmit?: SubmitHandler<T>;
22
- onSubmitError?: SubmitErrorHandler<any>;
23
- }
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
-
29
- export { }
package/dist/form.es.js DELETED
@@ -1,51 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { Box, Button } from '@mantine/core';
3
- import { FormProvider, useFormContext } from 'react-hook-form';
4
- export { z as zodValidator } from './zodValidator-ChEQ3cmF.js';
5
- import { z } from 'zod';
6
-
7
- const Form = ({
8
- methods,
9
- onSubmit = () => {
10
- },
11
- onSubmitError,
12
- ...rest
13
- }) => {
14
- return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsx(
15
- Box,
16
- {
17
- component: "form",
18
- onSubmit: methods.handleSubmit(onSubmit, onSubmitError),
19
- ...rest
20
- }
21
- ) });
22
- };
23
-
24
- const FormButtonSubmit = (props) => {
25
- const { formState } = useFormContext();
26
- const { isSubmitting } = formState;
27
- return /* @__PURE__ */ jsx(
28
- Button,
29
- {
30
- loading: isSubmitting,
31
- type: "submit",
32
- ...props
33
- }
34
- );
35
- };
36
-
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 };