lkd-web-kit 0.4.1 → 0.4.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.
@@ -7,13 +7,14 @@ const jsxRuntime = require('react/jsx-runtime');
7
7
  const core = require('@mantine/core');
8
8
  const reactHookForm = require('react-hook-form');
9
9
 
10
- const FormButtonSubmit = (props) => {
10
+ const FormButtonSubmit = ({ disabled, ...props }) => {
11
11
  const {
12
- formState: { isSubmitting }
12
+ formState: { isSubmitting, isSubmitSuccessful }
13
13
  } = reactHookForm.useFormContext();
14
14
  return /* @__PURE__ */ jsxRuntime.jsx(
15
15
  core.Button,
16
16
  {
17
+ disabled: disabled ?? (isSubmitSuccessful && props.disabledWhenSuccess),
17
18
  loading: isSubmitting,
18
19
  type: "submit",
19
20
  ...props
@@ -3,13 +3,14 @@ import { jsx } from 'react/jsx-runtime';
3
3
  import { Button } from '@mantine/core';
4
4
  import { useFormContext } from 'react-hook-form';
5
5
 
6
- const FormButtonSubmit = (props) => {
6
+ const FormButtonSubmit = ({ disabled, ...props }) => {
7
7
  const {
8
- formState: { isSubmitting }
8
+ formState: { isSubmitting, isSubmitSuccessful }
9
9
  } = useFormContext();
10
10
  return /* @__PURE__ */ jsx(
11
11
  Button,
12
12
  {
13
+ disabled: disabled ?? (isSubmitSuccessful && props.disabledWhenSuccess),
13
14
  loading: isSubmitting,
14
15
  type: "submit",
15
16
  ...props
@@ -2,13 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const zod = require('zod');
6
-
7
- const nullableButRequired = (schema, message = "Campo requerido") => schema.nullable().superRefine((val, ctx) => {
8
- if (val === null) {
9
- ctx.addIssue({
10
- code: zod.z.ZodIssueCode.custom,
11
- message
5
+ const nullableButRequired = (schema, message = "Campo requerido") => schema.nullable().check((ctx) => {
6
+ if (ctx.value === null) {
7
+ ctx.issues.push({
8
+ code: "custom",
9
+ message,
10
+ input: ctx.value
12
11
  });
13
12
  }
14
13
  });
@@ -1,10 +1,9 @@
1
- import { z } from 'zod';
2
-
3
- const nullableButRequired = (schema, message = "Campo requerido") => schema.nullable().superRefine((val, ctx) => {
4
- if (val === null) {
5
- ctx.addIssue({
6
- code: z.ZodIssueCode.custom,
7
- message
1
+ const nullableButRequired = (schema, message = "Campo requerido") => schema.nullable().check((ctx) => {
2
+ if (ctx.value === null) {
3
+ ctx.issues.push({
4
+ code: "custom",
5
+ message,
6
+ input: ctx.value
8
7
  });
9
8
  }
10
9
  });
@@ -2,13 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const zod = require('zod');
6
-
7
- const optionalButRequired = (schema, message = "Campo requerido") => schema.optional().superRefine((val, ctx) => {
8
- if (val === void 0) {
9
- ctx.addIssue({
10
- code: zod.z.ZodIssueCode.custom,
11
- message
5
+ const optionalButRequired = (schema, message = "Campo requerido") => schema.optional().check((ctx) => {
6
+ if (ctx.value === void 0) {
7
+ ctx.issues.push({
8
+ code: "custom",
9
+ message,
10
+ input: ctx.value
12
11
  });
13
12
  }
14
13
  });
@@ -1,10 +1,9 @@
1
- import { z } from 'zod';
2
-
3
- const optionalButRequired = (schema, message = "Campo requerido") => schema.optional().superRefine((val, ctx) => {
4
- if (val === void 0) {
5
- ctx.addIssue({
6
- code: z.ZodIssueCode.custom,
7
- message
1
+ const optionalButRequired = (schema, message = "Campo requerido") => schema.optional().check((ctx) => {
2
+ if (ctx.value === void 0) {
3
+ ctx.issues.push({
4
+ code: "custom",
5
+ message,
6
+ input: ctx.value
8
7
  });
9
8
  }
10
9
  });
package/dist/index.d.ts CHANGED
@@ -45,7 +45,8 @@ import { TextInputProps } from '@mantine/core';
45
45
  import { TimeInputProps } from '@mantine/dates';
46
46
  import { UseFormReturn } from 'react-hook-form';
47
47
  import { VirtualItem } from '@tanstack/react-virtual';
48
- import { z } from 'zod';
48
+ import { z } from 'zod/v4';
49
+ import { ZodType } from 'zod/v4';
49
50
  import { ZodTypeAny } from 'zod';
50
51
 
51
52
  export declare const addBodyJsonHook: BeforeErrorHook;
@@ -106,9 +107,10 @@ export declare const Form: <T extends FieldValues, TContext = any, TT extends T
106
107
 
107
108
  export declare function formatBytes(bytes: number, decimals?: number): string;
108
109
 
109
- export declare const FormButtonSubmit: (props: FormButtonSubmitProps) => JSX.Element;
110
+ export declare const FormButtonSubmit: ({ disabled, ...props }: FormButtonSubmitProps) => JSX.Element;
110
111
 
111
112
  export declare interface FormButtonSubmitProps extends ButtonProps, ElementProps<'button', keyof ButtonProps> {
113
+ disabledWhenSuccess?: boolean;
112
114
  }
113
115
 
114
116
  export declare const FormCheckbox: FC<CheckboxProps & WithFormProps>;
@@ -425,7 +427,7 @@ export declare const newRoute: {
425
427
  <LocalQuery extends object = {}, PathParams extends Params = {}>(pathBuilder: (params: PathParams) => string, options?: RouteOptions<LocalQuery, PathParams> | undefined): (params?: RouteInput<PathParams, LocalQuery> | undefined) => string;
426
428
  };
427
429
 
428
- export declare const nullableButRequired: <T extends ZodTypeAny>(schema: T, message?: string) => z.ZodEffects<z.ZodNullable<T>, T["_output"] | null, T["_input"] | null>;
430
+ export declare const nullableButRequired: <T extends ZodType>(schema: T, message?: string) => z.ZodNullable<T>;
429
431
 
430
432
  export declare const numberToTimeInput: (number: number) => string;
431
433
 
@@ -436,7 +438,7 @@ export declare type OnScrollProgressOptions = {
436
438
  disabled?: boolean;
437
439
  };
438
440
 
439
- export declare const optionalButRequired: <T extends ZodTypeAny>(schema: T, message?: string) => z.ZodEffects<z.ZodOptional<T>, T["_output"] | undefined, T["_input"] | undefined>;
441
+ export declare const optionalButRequired: <T extends ZodType>(schema: T, message?: string) => z.ZodOptional<T>;
440
442
 
441
443
  export declare const PageDataProvider: ({ value, children }: PageDataProviderProps) => JSX.Element;
442
444
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkd-web-kit",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "A template for creating React component libraries with Vite.",
5
5
  "author": "LKD",
6
6
  "license": "MIT",
@@ -57,17 +57,17 @@
57
57
  "@mantine/dates": "^8.1.2",
58
58
  "@mantine/hooks": "^8.1.2",
59
59
  "@mantine/notifications": "^8.1.2",
60
- "@tanstack/react-query": "^5.81.2",
60
+ "@tanstack/react-query": "^5.81.5",
61
61
  "clsx": "^2.1.1",
62
62
  "ky": "^1.8.1",
63
- "next": "^15.3.4",
63
+ "next": "^15.3.5",
64
64
  "react": "^19.1.0",
65
65
  "react-dom": "^19.1.0",
66
- "react-hook-form": "^7.58.1",
66
+ "react-hook-form": "^7.60.0",
67
67
  "react-query-kit": "^3.3.1",
68
- "zod": "^3.25.67"
68
+ "zod": "^3.25.74"
69
69
  },
70
70
  "dependencies": {
71
- "@tanstack/react-virtual": "^3.13.11"
71
+ "@tanstack/react-virtual": "^3.13.12"
72
72
  }
73
73
  }