lkd-web-kit 0.4.2 → 0.4.5

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.
Files changed (142) hide show
  1. package/dist/form/utils/nullable-but-required.cjs +6 -7
  2. package/dist/form/utils/nullable-but-required.js +6 -7
  3. package/dist/form/utils/optional-but-required.cjs +6 -7
  4. package/dist/form/utils/optional-but-required.js +6 -7
  5. package/dist/hooks/useZodConfig.cjs +21 -0
  6. package/dist/hooks/useZodConfig.js +17 -0
  7. package/dist/index.cjs +2 -0
  8. package/dist/index.d.ts +8 -6
  9. package/dist/index.js +1 -0
  10. package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +38 -33
  11. package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +38 -33
  12. package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +1 -1
  13. package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +1 -1
  14. package/dist/node_modules/zod/v4/classic/coerce.cjs +28 -0
  15. package/dist/node_modules/zod/v4/classic/coerce.js +20 -0
  16. package/dist/node_modules/zod/v4/classic/compat.cjs +37 -0
  17. package/dist/node_modules/zod/v4/classic/compat.js +30 -0
  18. package/dist/node_modules/zod/v4/classic/errors.cjs +49 -0
  19. package/dist/node_modules/zod/v4/classic/errors.js +44 -0
  20. package/dist/node_modules/zod/v4/classic/external.cjs +231 -0
  21. package/dist/node_modules/zod/v4/classic/external.js +28 -0
  22. package/dist/node_modules/zod/v4/classic/index.cjs +10 -0
  23. package/dist/node_modules/zod/v4/classic/index.js +5 -0
  24. package/dist/node_modules/zod/v4/classic/iso.cjs +46 -0
  25. package/dist/node_modules/zod/v4/classic/iso.js +35 -0
  26. package/dist/node_modules/zod/v4/classic/parse.cjs +16 -0
  27. package/dist/node_modules/zod/v4/classic/parse.js +9 -0
  28. package/dist/node_modules/zod/v4/classic/schemas.cjs +1155 -0
  29. package/dist/node_modules/zod/v4/classic/schemas.js +1006 -0
  30. package/dist/node_modules/zod/v4/core/api.cjs +1016 -0
  31. package/dist/node_modules/zod/v4/core/api.js +903 -0
  32. package/dist/node_modules/zod/v4/core/checks.cjs +587 -0
  33. package/dist/node_modules/zod/v4/core/checks.js +562 -0
  34. package/dist/node_modules/zod/v4/core/core.cjs +72 -0
  35. package/dist/node_modules/zod/v4/core/core.js +63 -0
  36. package/dist/node_modules/zod/v4/core/doc.cjs +41 -0
  37. package/dist/node_modules/zod/v4/core/doc.js +37 -0
  38. package/dist/node_modules/zod/v4/core/errors.cjs +204 -0
  39. package/dist/node_modules/zod/v4/core/errors.js +194 -0
  40. package/dist/node_modules/zod/v4/core/function.cjs +81 -0
  41. package/dist/node_modules/zod/v4/core/function.js +76 -0
  42. package/dist/node_modules/zod/v4/core/index.cjs +261 -0
  43. package/dist/node_modules/zod/v4/core/index.js +20 -0
  44. package/dist/node_modules/zod/v4/core/json-schema.cjs +2 -0
  45. package/dist/node_modules/zod/v4/core/json-schema.js +1 -0
  46. package/dist/node_modules/zod/v4/core/parse.cjs +71 -0
  47. package/dist/node_modules/zod/v4/core/parse.js +60 -0
  48. package/dist/node_modules/zod/v4/core/regexes.cjs +139 -0
  49. package/dist/node_modules/zod/v4/core/regexes.js +95 -0
  50. package/dist/node_modules/zod/v4/core/registries.cjs +52 -0
  51. package/dist/node_modules/zod/v4/core/registries.js +44 -0
  52. package/dist/node_modules/zod/v4/core/schemas.cjs +1793 -0
  53. package/dist/node_modules/zod/v4/core/schemas.js +1720 -0
  54. package/dist/node_modules/zod/v4/core/to-json-schema.cjs +823 -0
  55. package/dist/node_modules/zod/v4/core/to-json-schema.js +818 -0
  56. package/dist/node_modules/zod/v4/core/util.cjs +543 -0
  57. package/dist/node_modules/zod/v4/core/util.js +491 -0
  58. package/dist/node_modules/zod/v4/core/versions.cjs +11 -0
  59. package/dist/node_modules/zod/v4/core/versions.js +7 -0
  60. package/dist/node_modules/zod/v4/index.cjs +10 -0
  61. package/dist/node_modules/zod/v4/index.js +5 -0
  62. package/dist/node_modules/zod/v4/locales/ar.cjs +121 -0
  63. package/dist/node_modules/zod/v4/locales/ar.js +119 -0
  64. package/dist/node_modules/zod/v4/locales/az.cjs +120 -0
  65. package/dist/node_modules/zod/v4/locales/az.js +118 -0
  66. package/dist/node_modules/zod/v4/locales/be.cjs +169 -0
  67. package/dist/node_modules/zod/v4/locales/be.js +167 -0
  68. package/dist/node_modules/zod/v4/locales/ca.cjs +123 -0
  69. package/dist/node_modules/zod/v4/locales/ca.js +121 -0
  70. package/dist/node_modules/zod/v4/locales/cs.cjs +140 -0
  71. package/dist/node_modules/zod/v4/locales/cs.js +138 -0
  72. package/dist/node_modules/zod/v4/locales/de.cjs +121 -0
  73. package/dist/node_modules/zod/v4/locales/de.js +119 -0
  74. package/dist/node_modules/zod/v4/locales/en.cjs +125 -0
  75. package/dist/node_modules/zod/v4/locales/en.js +120 -0
  76. package/dist/node_modules/zod/v4/locales/eo.cjs +124 -0
  77. package/dist/node_modules/zod/v4/locales/eo.js +119 -0
  78. package/dist/node_modules/zod/v4/locales/es.cjs +122 -0
  79. package/dist/node_modules/zod/v4/locales/es.js +120 -0
  80. package/dist/node_modules/zod/v4/locales/fa.cjs +127 -0
  81. package/dist/node_modules/zod/v4/locales/fa.js +125 -0
  82. package/dist/node_modules/zod/v4/locales/fi.cjs +127 -0
  83. package/dist/node_modules/zod/v4/locales/fi.js +125 -0
  84. package/dist/node_modules/zod/v4/locales/fr-CA.cjs +122 -0
  85. package/dist/node_modules/zod/v4/locales/fr-CA.js +120 -0
  86. package/dist/node_modules/zod/v4/locales/fr.cjs +121 -0
  87. package/dist/node_modules/zod/v4/locales/fr.js +119 -0
  88. package/dist/node_modules/zod/v4/locales/he.cjs +122 -0
  89. package/dist/node_modules/zod/v4/locales/he.js +120 -0
  90. package/dist/node_modules/zod/v4/locales/hu.cjs +122 -0
  91. package/dist/node_modules/zod/v4/locales/hu.js +120 -0
  92. package/dist/node_modules/zod/v4/locales/id.cjs +121 -0
  93. package/dist/node_modules/zod/v4/locales/id.js +119 -0
  94. package/dist/node_modules/zod/v4/locales/index.cjs +85 -0
  95. package/dist/node_modules/zod/v4/locales/index.js +39 -0
  96. package/dist/node_modules/zod/v4/locales/it.cjs +122 -0
  97. package/dist/node_modules/zod/v4/locales/it.js +120 -0
  98. package/dist/node_modules/zod/v4/locales/ja.cjs +120 -0
  99. package/dist/node_modules/zod/v4/locales/ja.js +118 -0
  100. package/dist/node_modules/zod/v4/locales/kh.cjs +122 -0
  101. package/dist/node_modules/zod/v4/locales/kh.js +120 -0
  102. package/dist/node_modules/zod/v4/locales/ko.cjs +126 -0
  103. package/dist/node_modules/zod/v4/locales/ko.js +124 -0
  104. package/dist/node_modules/zod/v4/locales/mk.cjs +123 -0
  105. package/dist/node_modules/zod/v4/locales/mk.js +121 -0
  106. package/dist/node_modules/zod/v4/locales/ms.cjs +121 -0
  107. package/dist/node_modules/zod/v4/locales/ms.js +119 -0
  108. package/dist/node_modules/zod/v4/locales/nl.cjs +122 -0
  109. package/dist/node_modules/zod/v4/locales/nl.js +120 -0
  110. package/dist/node_modules/zod/v4/locales/no.cjs +121 -0
  111. package/dist/node_modules/zod/v4/locales/no.js +119 -0
  112. package/dist/node_modules/zod/v4/locales/ota.cjs +122 -0
  113. package/dist/node_modules/zod/v4/locales/ota.js +120 -0
  114. package/dist/node_modules/zod/v4/locales/pl.cjs +122 -0
  115. package/dist/node_modules/zod/v4/locales/pl.js +120 -0
  116. package/dist/node_modules/zod/v4/locales/ps.cjs +127 -0
  117. package/dist/node_modules/zod/v4/locales/ps.js +125 -0
  118. package/dist/node_modules/zod/v4/locales/pt.cjs +121 -0
  119. package/dist/node_modules/zod/v4/locales/pt.js +119 -0
  120. package/dist/node_modules/zod/v4/locales/ru.cjs +169 -0
  121. package/dist/node_modules/zod/v4/locales/ru.js +167 -0
  122. package/dist/node_modules/zod/v4/locales/sl.cjs +122 -0
  123. package/dist/node_modules/zod/v4/locales/sl.js +120 -0
  124. package/dist/node_modules/zod/v4/locales/sv.cjs +123 -0
  125. package/dist/node_modules/zod/v4/locales/sv.js +121 -0
  126. package/dist/node_modules/zod/v4/locales/ta.cjs +122 -0
  127. package/dist/node_modules/zod/v4/locales/ta.js +120 -0
  128. package/dist/node_modules/zod/v4/locales/th.cjs +122 -0
  129. package/dist/node_modules/zod/v4/locales/th.js +120 -0
  130. package/dist/node_modules/zod/v4/locales/tr.cjs +123 -0
  131. package/dist/node_modules/zod/v4/locales/tr.js +118 -0
  132. package/dist/node_modules/zod/v4/locales/ua.cjs +122 -0
  133. package/dist/node_modules/zod/v4/locales/ua.js +120 -0
  134. package/dist/node_modules/zod/v4/locales/ur.cjs +122 -0
  135. package/dist/node_modules/zod/v4/locales/ur.js +120 -0
  136. package/dist/node_modules/zod/v4/locales/vi.cjs +121 -0
  137. package/dist/node_modules/zod/v4/locales/vi.js +119 -0
  138. package/dist/node_modules/zod/v4/locales/zh-CN.cjs +121 -0
  139. package/dist/node_modules/zod/v4/locales/zh-CN.js +119 -0
  140. package/dist/node_modules/zod/v4/locales/zh-TW.cjs +122 -0
  141. package/dist/node_modules/zod/v4/locales/zh-TW.js +120 -0
  142. package/package.json +6 -6
@@ -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
  });
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const React = require('react');
6
+ const external = require('../node_modules/zod/v4/classic/external.cjs');
7
+
8
+ const useZodConfig = () => {
9
+ React.useEffect(() => {
10
+ external.config({
11
+ customError: (iss) => {
12
+ if (iss.code === "too_small")
13
+ return iss.minimum === 1 ? `Campo requerido` : `Minimo ${iss.minimum} caracteres`;
14
+ if (iss.code === "too_big") return `Maximo ${iss.maximum} caracteres`;
15
+ if (iss.code === "invalid_format" && iss.format === "email") return `Email invalido`;
16
+ }
17
+ });
18
+ }, []);
19
+ };
20
+
21
+ exports.useZodConfig = useZodConfig;
@@ -0,0 +1,17 @@
1
+ import { useEffect } from 'react';
2
+ import * as external from '../node_modules/zod/v4/classic/external.js';
3
+
4
+ const useZodConfig = () => {
5
+ useEffect(() => {
6
+ external.config({
7
+ customError: (iss) => {
8
+ if (iss.code === "too_small")
9
+ return iss.minimum === 1 ? `Campo requerido` : `Minimo ${iss.minimum} caracteres`;
10
+ if (iss.code === "too_big") return `Maximo ${iss.maximum} caracteres`;
11
+ if (iss.code === "invalid_format" && iss.format === "email") return `Email invalido`;
12
+ }
13
+ });
14
+ }, []);
15
+ };
16
+
17
+ export { useZodConfig };
package/dist/index.cjs CHANGED
@@ -44,6 +44,7 @@ const useBreakpoint = require('./hooks/useBreakpoint.cjs');
44
44
  const useFetchNextPageOnScroll = require('./hooks/useFetchNextPageOnScroll.cjs');
45
45
  const useOnScrollProgress = require('./hooks/useOnScrollProgress.cjs');
46
46
  const useUpdateSearchParams = require('./hooks/useUpdateSearchParams.cjs');
47
+ const useZodConfig = require('./hooks/useZodConfig.cjs');
47
48
  const breakpointsWithPx = require('./mantine/breakpoints-with-px.cjs');
48
49
  const toTailwindColors = require('./mantine/to-tailwind-colors.cjs');
49
50
  const myDefaultTheme = require('./mantine/my-default-theme.cjs');
@@ -106,6 +107,7 @@ exports.useBreakpoint = useBreakpoint.useBreakpoint;
106
107
  exports.useFetchNextPageOnScroll = useFetchNextPageOnScroll.useFetchNextPageOnScroll;
107
108
  exports.useOnScrollProgress = useOnScrollProgress.useOnScrollProgress;
108
109
  exports.useUpdateSearchParams = useUpdateSearchParams.useUpdateSearchParams;
110
+ exports.useZodConfig = useZodConfig.useZodConfig;
109
111
  exports.breakpointsWithPx = breakpointsWithPx.breakpointsWithPx;
110
112
  exports.toTailwindColors = toTailwindColors.toTailwindColors;
111
113
  exports.myDefaultTheme = myDefaultTheme.myDefaultTheme;
package/dist/index.d.ts CHANGED
@@ -45,8 +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';
49
- import { ZodTypeAny } from 'zod';
48
+ import { z } from 'zod/v4';
49
+ import { ZodType } from 'zod/v4';
50
50
 
51
51
  export declare const addBodyJsonHook: BeforeErrorHook;
52
52
 
@@ -426,7 +426,7 @@ export declare const newRoute: {
426
426
  <LocalQuery extends object = {}, PathParams extends Params = {}>(pathBuilder: (params: PathParams) => string, options?: RouteOptions<LocalQuery, PathParams> | undefined): (params?: RouteInput<PathParams, LocalQuery> | undefined) => string;
427
427
  };
428
428
 
429
- export declare const nullableButRequired: <T extends ZodTypeAny>(schema: T, message?: string) => z.ZodEffects<z.ZodNullable<T>, T["_output"] | null, T["_input"] | null>;
429
+ export declare const nullableButRequired: <T extends ZodType>(schema: T, message?: string) => z.ZodNullable<T>;
430
430
 
431
431
  export declare const numberToTimeInput: (number: number) => string;
432
432
 
@@ -437,7 +437,7 @@ export declare type OnScrollProgressOptions = {
437
437
  disabled?: boolean;
438
438
  };
439
439
 
440
- export declare const optionalButRequired: <T extends ZodTypeAny>(schema: T, message?: string) => z.ZodEffects<z.ZodOptional<T>, T["_output"] | undefined, T["_input"] | undefined>;
440
+ export declare const optionalButRequired: <T extends ZodType>(schema: T, message?: string) => z.ZodOptional<T>;
441
441
 
442
442
  export declare const PageDataProvider: ({ value, children }: PageDataProviderProps) => JSX.Element;
443
443
 
@@ -543,6 +543,8 @@ export declare const useUpdateSearchParams: () => {
543
543
  searchParams: ReadonlyURLSearchParams;
544
544
  };
545
545
 
546
+ export declare const useZodConfig: () => void;
547
+
546
548
  export declare const withForm: <P extends unknown>(WrappedComponent: React.ComponentType<FormFieldProps<P>>, getControllerProps?: (fieldProps: P) => Omit<Partial<ControllerProps>, "render">) => FC<P & WithFormProps>;
547
549
 
548
550
  export declare interface WithFormProps {
@@ -550,7 +552,7 @@ export declare interface WithFormProps {
550
552
  label?: ReactNode;
551
553
  placeholder?: string;
552
554
  description?: ReactNode;
553
- validate?: ZodTypeAny;
555
+ validate?: ZodType;
554
556
  disabled?: boolean;
555
557
  }
556
558
 
@@ -561,6 +563,6 @@ export declare interface WithModalManagerProps {
561
563
  opened: boolean;
562
564
  }
563
565
 
564
- export declare const zodValidator: (schema: ZodTypeAny) => (values: any) => string | undefined;
566
+ export declare const zodValidator: (schema: ZodType) => (values: any) => string | undefined;
565
567
 
566
568
  export { }
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ export { useBreakpoint } from './hooks/useBreakpoint.js';
40
40
  export { useFetchNextPageOnScroll } from './hooks/useFetchNextPageOnScroll.js';
41
41
  export { useOnScrollProgress } from './hooks/useOnScrollProgress.js';
42
42
  export { useUpdateSearchParams } from './hooks/useUpdateSearchParams.js';
43
+ export { useZodConfig } from './hooks/useZodConfig.js';
43
44
  export { breakpointsWithPx } from './mantine/breakpoints-with-px.js';
44
45
  export { toTailwindColors } from './mantine/to-tailwind-colors.js';
45
46
  export { myDefaultTheme } from './mantine/my-default-theme.js';
@@ -126,7 +126,6 @@ class Virtualizer {
126
126
  this.scrollElement = null;
127
127
  this.targetWindow = null;
128
128
  this.isScrolling = false;
129
- this.scrollToIndexTimeoutId = null;
130
129
  this.measurementsCache = [];
131
130
  this.itemSizeCache = /* @__PURE__ */ new Map();
132
131
  this.pendingMeasuredCacheIndexes = [];
@@ -542,7 +541,7 @@ class Virtualizer {
542
541
  } else if (align === "end") {
543
542
  toOffset -= size;
544
543
  }
545
- const maxOffset = this.getTotalSize() - size;
544
+ const maxOffset = this.getTotalSize() + this.options.scrollMargin - size;
546
545
  return Math.max(Math.min(maxOffset, toOffset), 0);
547
546
  };
548
547
  this.getOffsetForIndex = (index, align = "auto") => {
@@ -569,14 +568,7 @@ class Virtualizer {
569
568
  ];
570
569
  };
571
570
  this.isDynamicMode = () => this.elementsCache.size > 0;
572
- this.cancelScrollToIndex = () => {
573
- if (this.scrollToIndexTimeoutId !== null && this.targetWindow) {
574
- this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId);
575
- this.scrollToIndexTimeoutId = null;
576
- }
577
- };
578
571
  this.scrollToOffset = (toOffset, { align = "start", behavior } = {}) => {
579
- this.cancelScrollToIndex();
580
572
  if (behavior === "smooth" && this.isDynamicMode()) {
581
573
  console.warn(
582
574
  "The `smooth` scroll behavior is not fully supported with dynamic size."
@@ -588,39 +580,52 @@ class Virtualizer {
588
580
  });
589
581
  };
590
582
  this.scrollToIndex = (index, { align: initialAlign = "auto", behavior } = {}) => {
591
- index = Math.max(0, Math.min(index, this.options.count - 1));
592
- this.cancelScrollToIndex();
593
583
  if (behavior === "smooth" && this.isDynamicMode()) {
594
584
  console.warn(
595
585
  "The `smooth` scroll behavior is not fully supported with dynamic size."
596
586
  );
597
587
  }
598
- const offsetAndAlign = this.getOffsetForIndex(index, initialAlign);
599
- if (!offsetAndAlign) return;
600
- const [offset, align] = offsetAndAlign;
601
- this._scrollToOffset(offset, { adjustments: void 0, behavior });
602
- if (behavior !== "smooth" && this.isDynamicMode() && this.targetWindow) {
603
- this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
604
- this.scrollToIndexTimeoutId = null;
605
- const elementInDOM = this.elementsCache.has(
606
- this.options.getItemKey(index)
607
- );
608
- if (elementInDOM) {
609
- const result = this.getOffsetForIndex(index, align);
610
- if (!result) return;
611
- const [latestOffset] = result;
612
- const currentScrollOffset = this.getScrollOffset();
613
- if (!utils.approxEqual(latestOffset, currentScrollOffset)) {
614
- this.scrollToIndex(index, { align, behavior });
615
- }
616
- } else {
617
- this.scrollToIndex(index, { align, behavior });
588
+ index = Math.max(0, Math.min(index, this.options.count - 1));
589
+ let attempts = 0;
590
+ const maxAttempts = 10;
591
+ const tryScroll = (currentAlign) => {
592
+ if (!this.targetWindow) return;
593
+ const offsetInfo = this.getOffsetForIndex(index, currentAlign);
594
+ if (!offsetInfo) {
595
+ console.warn("Failed to get offset for index:", index);
596
+ return;
597
+ }
598
+ const [offset, align] = offsetInfo;
599
+ this._scrollToOffset(offset, { adjustments: void 0, behavior });
600
+ this.targetWindow.requestAnimationFrame(() => {
601
+ const currentOffset = this.getScrollOffset();
602
+ const afterInfo = this.getOffsetForIndex(index, align);
603
+ if (!afterInfo) {
604
+ console.warn("Failed to get offset for index:", index);
605
+ return;
606
+ }
607
+ if (!utils.approxEqual(afterInfo[0], currentOffset)) {
608
+ scheduleRetry(align);
618
609
  }
619
610
  });
620
- }
611
+ };
612
+ const scheduleRetry = (align) => {
613
+ if (!this.targetWindow) return;
614
+ attempts++;
615
+ if (attempts < maxAttempts) {
616
+ if (process.env.NODE_ENV !== "production" && this.options.debug) {
617
+ console.info("Schedule retry", attempts, maxAttempts);
618
+ }
619
+ this.targetWindow.requestAnimationFrame(() => tryScroll(align));
620
+ } else {
621
+ console.warn(
622
+ `Failed to scroll to index ${index} after ${maxAttempts} attempts.`
623
+ );
624
+ }
625
+ };
626
+ tryScroll(initialAlign);
621
627
  };
622
628
  this.scrollBy = (delta, { behavior } = {}) => {
623
- this.cancelScrollToIndex();
624
629
  if (behavior === "smooth" && this.isDynamicMode()) {
625
630
  console.warn(
626
631
  "The `smooth` scroll behavior is not fully supported with dynamic size."
@@ -122,7 +122,6 @@ class Virtualizer {
122
122
  this.scrollElement = null;
123
123
  this.targetWindow = null;
124
124
  this.isScrolling = false;
125
- this.scrollToIndexTimeoutId = null;
126
125
  this.measurementsCache = [];
127
126
  this.itemSizeCache = /* @__PURE__ */ new Map();
128
127
  this.pendingMeasuredCacheIndexes = [];
@@ -538,7 +537,7 @@ class Virtualizer {
538
537
  } else if (align === "end") {
539
538
  toOffset -= size;
540
539
  }
541
- const maxOffset = this.getTotalSize() - size;
540
+ const maxOffset = this.getTotalSize() + this.options.scrollMargin - size;
542
541
  return Math.max(Math.min(maxOffset, toOffset), 0);
543
542
  };
544
543
  this.getOffsetForIndex = (index, align = "auto") => {
@@ -565,14 +564,7 @@ class Virtualizer {
565
564
  ];
566
565
  };
567
566
  this.isDynamicMode = () => this.elementsCache.size > 0;
568
- this.cancelScrollToIndex = () => {
569
- if (this.scrollToIndexTimeoutId !== null && this.targetWindow) {
570
- this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId);
571
- this.scrollToIndexTimeoutId = null;
572
- }
573
- };
574
567
  this.scrollToOffset = (toOffset, { align = "start", behavior } = {}) => {
575
- this.cancelScrollToIndex();
576
568
  if (behavior === "smooth" && this.isDynamicMode()) {
577
569
  console.warn(
578
570
  "The `smooth` scroll behavior is not fully supported with dynamic size."
@@ -584,39 +576,52 @@ class Virtualizer {
584
576
  });
585
577
  };
586
578
  this.scrollToIndex = (index, { align: initialAlign = "auto", behavior } = {}) => {
587
- index = Math.max(0, Math.min(index, this.options.count - 1));
588
- this.cancelScrollToIndex();
589
579
  if (behavior === "smooth" && this.isDynamicMode()) {
590
580
  console.warn(
591
581
  "The `smooth` scroll behavior is not fully supported with dynamic size."
592
582
  );
593
583
  }
594
- const offsetAndAlign = this.getOffsetForIndex(index, initialAlign);
595
- if (!offsetAndAlign) return;
596
- const [offset, align] = offsetAndAlign;
597
- this._scrollToOffset(offset, { adjustments: void 0, behavior });
598
- if (behavior !== "smooth" && this.isDynamicMode() && this.targetWindow) {
599
- this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
600
- this.scrollToIndexTimeoutId = null;
601
- const elementInDOM = this.elementsCache.has(
602
- this.options.getItemKey(index)
603
- );
604
- if (elementInDOM) {
605
- const result = this.getOffsetForIndex(index, align);
606
- if (!result) return;
607
- const [latestOffset] = result;
608
- const currentScrollOffset = this.getScrollOffset();
609
- if (!approxEqual(latestOffset, currentScrollOffset)) {
610
- this.scrollToIndex(index, { align, behavior });
611
- }
612
- } else {
613
- this.scrollToIndex(index, { align, behavior });
584
+ index = Math.max(0, Math.min(index, this.options.count - 1));
585
+ let attempts = 0;
586
+ const maxAttempts = 10;
587
+ const tryScroll = (currentAlign) => {
588
+ if (!this.targetWindow) return;
589
+ const offsetInfo = this.getOffsetForIndex(index, currentAlign);
590
+ if (!offsetInfo) {
591
+ console.warn("Failed to get offset for index:", index);
592
+ return;
593
+ }
594
+ const [offset, align] = offsetInfo;
595
+ this._scrollToOffset(offset, { adjustments: void 0, behavior });
596
+ this.targetWindow.requestAnimationFrame(() => {
597
+ const currentOffset = this.getScrollOffset();
598
+ const afterInfo = this.getOffsetForIndex(index, align);
599
+ if (!afterInfo) {
600
+ console.warn("Failed to get offset for index:", index);
601
+ return;
602
+ }
603
+ if (!approxEqual(afterInfo[0], currentOffset)) {
604
+ scheduleRetry(align);
614
605
  }
615
606
  });
616
- }
607
+ };
608
+ const scheduleRetry = (align) => {
609
+ if (!this.targetWindow) return;
610
+ attempts++;
611
+ if (attempts < maxAttempts) {
612
+ if (process.env.NODE_ENV !== "production" && this.options.debug) {
613
+ console.info("Schedule retry", attempts, maxAttempts);
614
+ }
615
+ this.targetWindow.requestAnimationFrame(() => tryScroll(align));
616
+ } else {
617
+ console.warn(
618
+ `Failed to scroll to index ${index} after ${maxAttempts} attempts.`
619
+ );
620
+ }
621
+ };
622
+ tryScroll(initialAlign);
617
623
  };
618
624
  this.scrollBy = (delta, { behavior } = {}) => {
619
- this.cancelScrollToIndex();
620
625
  if (behavior === "smooth" && this.isDynamicMode()) {
621
626
  console.warn(
622
627
  "The `smooth` scroll behavior is not fully supported with dynamic size."
@@ -56,7 +56,7 @@ function notUndefined(value, msg) {
56
56
  return value;
57
57
  }
58
58
  }
59
- const approxEqual = (a, b) => Math.abs(a - b) <= 1;
59
+ const approxEqual = (a, b) => Math.abs(a - b) < 1.01;
60
60
  const debounce = (targetWindow, fn, ms) => {
61
61
  let timeoutId;
62
62
  return function(...args) {
@@ -52,7 +52,7 @@ function notUndefined(value, msg) {
52
52
  return value;
53
53
  }
54
54
  }
55
- const approxEqual = (a, b) => Math.abs(a - b) <= 1;
55
+ const approxEqual = (a, b) => Math.abs(a - b) < 1.01;
56
56
  const debounce = (targetWindow, fn, ms) => {
57
57
  let timeoutId;
58
58
  return function(...args) {
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const schemas = require('./schemas.cjs');
6
+ const api = require('../core/api.cjs');
7
+
8
+ function string(params) {
9
+ return api._coercedString(schemas.ZodString, params);
10
+ }
11
+ function number(params) {
12
+ return api._coercedNumber(schemas.ZodNumber, params);
13
+ }
14
+ function boolean(params) {
15
+ return api._coercedBoolean(schemas.ZodBoolean, params);
16
+ }
17
+ function bigint(params) {
18
+ return api._coercedBigint(schemas.ZodBigInt, params);
19
+ }
20
+ function date(params) {
21
+ return api._coercedDate(schemas.ZodDate, params);
22
+ }
23
+
24
+ exports.bigint = bigint;
25
+ exports.boolean = boolean;
26
+ exports.date = date;
27
+ exports.number = number;
28
+ exports.string = string;
@@ -0,0 +1,20 @@
1
+ import { ZodString, ZodNumber, ZodBoolean, ZodBigInt, ZodDate } from './schemas.js';
2
+ import { _coercedString, _coercedNumber, _coercedBoolean, _coercedBigint, _coercedDate } from '../core/api.js';
3
+
4
+ function string(params) {
5
+ return _coercedString(ZodString, params);
6
+ }
7
+ function number(params) {
8
+ return _coercedNumber(ZodNumber, params);
9
+ }
10
+ function boolean(params) {
11
+ return _coercedBoolean(ZodBoolean, params);
12
+ }
13
+ function bigint(params) {
14
+ return _coercedBigint(ZodBigInt, params);
15
+ }
16
+ function date(params) {
17
+ return _coercedDate(ZodDate, params);
18
+ }
19
+
20
+ export { bigint, boolean, date, number, string };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const core = require('../core/core.cjs');
6
+
7
+ // Zod 3 compat layer
8
+ /** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
9
+ const ZodIssueCode = {
10
+ invalid_type: "invalid_type",
11
+ too_big: "too_big",
12
+ too_small: "too_small",
13
+ invalid_format: "invalid_format",
14
+ not_multiple_of: "not_multiple_of",
15
+ unrecognized_keys: "unrecognized_keys",
16
+ invalid_union: "invalid_union",
17
+ invalid_key: "invalid_key",
18
+ invalid_element: "invalid_element",
19
+ invalid_value: "invalid_value",
20
+ custom: "custom",
21
+ };
22
+ /** @deprecated Use `z.config(params)` instead. */
23
+ function setErrorMap(map) {
24
+ core.config({
25
+ customError: map,
26
+ });
27
+ }
28
+ /** @deprecated Use `z.config()` instead. */
29
+ function getErrorMap() {
30
+ return core.config().customError;
31
+ }
32
+
33
+ exports.$brand = core.$brand;
34
+ exports.config = core.config;
35
+ exports.ZodIssueCode = ZodIssueCode;
36
+ exports.getErrorMap = getErrorMap;
37
+ exports.setErrorMap = setErrorMap;
@@ -0,0 +1,30 @@
1
+ import { config } from '../core/core.js';
2
+ export { $brand } from '../core/core.js';
3
+
4
+ // Zod 3 compat layer
5
+ /** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
6
+ const ZodIssueCode = {
7
+ invalid_type: "invalid_type",
8
+ too_big: "too_big",
9
+ too_small: "too_small",
10
+ invalid_format: "invalid_format",
11
+ not_multiple_of: "not_multiple_of",
12
+ unrecognized_keys: "unrecognized_keys",
13
+ invalid_union: "invalid_union",
14
+ invalid_key: "invalid_key",
15
+ invalid_element: "invalid_element",
16
+ invalid_value: "invalid_value",
17
+ custom: "custom",
18
+ };
19
+ /** @deprecated Use `z.config(params)` instead. */
20
+ function setErrorMap(map) {
21
+ config({
22
+ customError: map,
23
+ });
24
+ }
25
+ /** @deprecated Use `z.config()` instead. */
26
+ function getErrorMap() {
27
+ return config().customError;
28
+ }
29
+
30
+ export { ZodIssueCode, config, getErrorMap, setErrorMap };
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const errors = require('../core/errors.cjs');
6
+ const core = require('../core/core.cjs');
7
+
8
+ const initializer = (inst, issues) => {
9
+ errors.$ZodError.init(inst, issues);
10
+ inst.name = "ZodError";
11
+ Object.defineProperties(inst, {
12
+ format: {
13
+ value: (mapper) => errors.formatError(inst, mapper),
14
+ // enumerable: false,
15
+ },
16
+ flatten: {
17
+ value: (mapper) => errors.flattenError(inst, mapper),
18
+ // enumerable: false,
19
+ },
20
+ addIssue: {
21
+ value: (issue) => inst.issues.push(issue),
22
+ // enumerable: false,
23
+ },
24
+ addIssues: {
25
+ value: (issues) => inst.issues.push(...issues),
26
+ // enumerable: false,
27
+ },
28
+ isEmpty: {
29
+ get() {
30
+ return inst.issues.length === 0;
31
+ },
32
+ // enumerable: false,
33
+ },
34
+ });
35
+ // Object.defineProperty(inst, "isEmpty", {
36
+ // get() {
37
+ // return inst.issues.length === 0;
38
+ // },
39
+ // });
40
+ };
41
+ const ZodError = core.$constructor("ZodError", initializer);
42
+ const ZodRealError = core.$constructor("ZodError", initializer, {
43
+ Parent: Error,
44
+ });
45
+ // /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
46
+ // export type ErrorMapCtx = core.$ZodErrorMapCtx;
47
+
48
+ exports.ZodError = ZodError;
49
+ exports.ZodRealError = ZodRealError;
@@ -0,0 +1,44 @@
1
+ import { $ZodError, flattenError, formatError } from '../core/errors.js';
2
+ import { $constructor } from '../core/core.js';
3
+
4
+ const initializer = (inst, issues) => {
5
+ $ZodError.init(inst, issues);
6
+ inst.name = "ZodError";
7
+ Object.defineProperties(inst, {
8
+ format: {
9
+ value: (mapper) => formatError(inst, mapper),
10
+ // enumerable: false,
11
+ },
12
+ flatten: {
13
+ value: (mapper) => flattenError(inst, mapper),
14
+ // enumerable: false,
15
+ },
16
+ addIssue: {
17
+ value: (issue) => inst.issues.push(issue),
18
+ // enumerable: false,
19
+ },
20
+ addIssues: {
21
+ value: (issues) => inst.issues.push(...issues),
22
+ // enumerable: false,
23
+ },
24
+ isEmpty: {
25
+ get() {
26
+ return inst.issues.length === 0;
27
+ },
28
+ // enumerable: false,
29
+ },
30
+ });
31
+ // Object.defineProperty(inst, "isEmpty", {
32
+ // get() {
33
+ // return inst.issues.length === 0;
34
+ // },
35
+ // });
36
+ };
37
+ const ZodError = $constructor("ZodError", initializer);
38
+ const ZodRealError = $constructor("ZodError", initializer, {
39
+ Parent: Error,
40
+ });
41
+ // /** @deprecated Use `z.core.$ZodErrorMapCtx` instead. */
42
+ // export type ErrorMapCtx = core.$ZodErrorMapCtx;
43
+
44
+ export { ZodError, ZodRealError };