lkd-web-kit 0.0.2 → 0.0.3

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/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 };
package/dist/hocs.cjs.js DELETED
@@ -1,76 +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 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 DELETED
@@ -1,34 +0,0 @@
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 { }
package/dist/hocs.es.js DELETED
@@ -1,71 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { Controller } from 'react-hook-form';
3
- import '@mantine/core';
4
- import { z as zodValidator } from './zodValidator-ChEQ3cmF.js';
5
- import 'zod';
6
- import { useState, useEffect } from 'react';
7
-
8
- const withForm = (WrappedComponent, getControllerProps) => {
9
- const FormField = (props) => {
10
- const { validate, name = "", placeholder, label, description, ...withFormRestProps } = props;
11
- return /* @__PURE__ */ jsx(
12
- Controller,
13
- {
14
- name,
15
- defaultValue: "",
16
- rules: {
17
- validate: validate && !props.disabled ? zodValidator(validate) : void 0
18
- },
19
- disabled: props.disabled,
20
- ...getControllerProps?.(props),
21
- render: (renderProps) => {
22
- const {
23
- fieldState: { isTouched, error }
24
- } = renderProps;
25
- const fieldProps = {
26
- ...renderProps,
27
- props: {
28
- ...props,
29
- validate: void 0
30
- },
31
- field: {
32
- ...renderProps.field,
33
- label,
34
- placeholder,
35
- description,
36
- error: error?.message
37
- },
38
- ...withFormRestProps
39
- };
40
- return /* @__PURE__ */ jsx(WrappedComponent, { ...fieldProps });
41
- }
42
- }
43
- );
44
- };
45
- FormField.displayName = `withForm(${WrappedComponent.displayName})`;
46
- return FormField;
47
- };
48
-
49
- const withModalManager = (WrappedComponent) => {
50
- const Component = ({
51
- removeModal,
52
- opened,
53
- ...props
54
- }) => {
55
- const [isOpen, setIsOpen] = useState(false);
56
- const onClose = () => {
57
- setIsOpen(false);
58
- setTimeout(() => removeModal(), 200);
59
- props.onClose?.();
60
- };
61
- useEffect(() => {
62
- if (opened) setTimeout(() => setIsOpen(true), 0);
63
- else onClose();
64
- }, [opened]);
65
- return /* @__PURE__ */ jsx(WrappedComponent, { ...props, opened: isOpen, onClose });
66
- };
67
- Component.displayName = `withModalManager(${WrappedComponent.displayName})`;
68
- return Component;
69
- };
70
-
71
- export { withForm, withModalManager };
package/dist/hooks.cjs.js DELETED
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- require('@mantine/core');
6
- const useFetchNextPageOnScroll = require('./useFetchNextPageOnScroll-Fqj7Vp-O.cjs');
7
- require('./navigation-DnFkn_t2.cjs');
8
-
9
-
10
-
11
- exports.useFetchNextPageOnScroll = useFetchNextPageOnScroll.useFetchNextPageOnScroll;
12
- exports.useOnScrollProgress = useFetchNextPageOnScroll.useOnScrollProgress;
package/dist/hooks.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { InfiniteData } from '@tanstack/react-query';
2
- import { InfiniteQueryHookResult } from 'react-query-kit';
3
- import { RefObject } from 'react';
4
-
5
- export declare const useFetchNextPageOnScroll: (infinity: InfiniteQueryHookResult<InfiniteData<{
6
- data: unknown[];
7
- }, number>, Error>, elementRef?: RefObject<HTMLElement | null>) => void;
8
-
9
- export declare const useOnScrollProgress: (triggerPercentage: number, callback: () => void, elementRef?: RefObject<HTMLElement | null>) => void;
10
-
11
- export { }
package/dist/hooks.es.js DELETED
@@ -1,3 +0,0 @@
1
- import '@mantine/core';
2
- export { u as useFetchNextPageOnScroll, a as useOnScrollProgress } from './useFetchNextPageOnScroll-08q9N5OE.js';
3
- import './navigation-sZaWnl2V.js';
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const breakpointsWithPx = {
6
- xs: "576px",
7
- sm: "640px",
8
- md: "768px",
9
- lg: "1024px",
10
- xl: "1280px",
11
- ["2xl"]: "1536px"
12
- };
13
-
14
- const toTailwindColors = (colors) => Object.entries(colors).reduce(
15
- (acc, [key, value]) => {
16
- acc[key] = value.reduce(
17
- (acc2, color, index) => {
18
- acc2[index] = color;
19
- return acc2;
20
- },
21
- {}
22
- );
23
- return acc;
24
- },
25
- {}
26
- );
27
-
28
- exports.breakpointsWithPx = breakpointsWithPx;
29
- exports.toTailwindColors = toTailwindColors;
package/dist/mantine.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import { DefaultMantineColor } from '@mantine/core';
2
- import { MantineColorShade } from '@mantine/core';
3
- import { MantineThemeColors } from '@mantine/core';
4
-
5
- export declare const breakpointsWithPx: {
6
- xs: string;
7
- sm: string;
8
- md: string;
9
- lg: string;
10
- xl: string;
11
- "2xl": string;
12
- };
13
-
14
- export declare const toTailwindColors: (colors: MantineThemeColors) => Record<DefaultMantineColor, Record<MantineColorShade, string>>;
15
-
16
- export { }
@@ -1,24 +0,0 @@
1
- const breakpointsWithPx = {
2
- xs: "576px",
3
- sm: "640px",
4
- md: "768px",
5
- lg: "1024px",
6
- xl: "1280px",
7
- ["2xl"]: "1536px"
8
- };
9
-
10
- const toTailwindColors = (colors) => Object.entries(colors).reduce(
11
- (acc, [key, value]) => {
12
- acc[key] = value.reduce(
13
- (acc2, color, index) => {
14
- acc2[index] = color;
15
- return acc2;
16
- },
17
- {}
18
- );
19
- return acc;
20
- },
21
- {}
22
- );
23
-
24
- export { breakpointsWithPx, toTailwindColors };