lkd-web-kit 0.4.3 → 0.4.6
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/FormButtonSubmit.cjs +6 -2
- package/dist/form/FormButtonSubmit.js +6 -2
- package/dist/hooks/useZodConfig.cjs +21 -0
- package/dist/hooks/useZodConfig.js +17 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.cjs +38 -33
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +38 -33
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.cjs +1 -1
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +1 -1
- package/dist/node_modules/zod/v4/classic/coerce.cjs +28 -0
- package/dist/node_modules/zod/v4/classic/coerce.js +20 -0
- package/dist/node_modules/zod/v4/classic/compat.cjs +37 -0
- package/dist/node_modules/zod/v4/classic/compat.js +30 -0
- package/dist/node_modules/zod/v4/classic/errors.cjs +49 -0
- package/dist/node_modules/zod/v4/classic/errors.js +44 -0
- package/dist/node_modules/zod/v4/classic/external.cjs +231 -0
- package/dist/node_modules/zod/v4/classic/external.js +28 -0
- package/dist/node_modules/zod/v4/classic/index.cjs +10 -0
- package/dist/node_modules/zod/v4/classic/index.js +5 -0
- package/dist/node_modules/zod/v4/classic/iso.cjs +46 -0
- package/dist/node_modules/zod/v4/classic/iso.js +35 -0
- package/dist/node_modules/zod/v4/classic/parse.cjs +16 -0
- package/dist/node_modules/zod/v4/classic/parse.js +9 -0
- package/dist/node_modules/zod/v4/classic/schemas.cjs +1155 -0
- package/dist/node_modules/zod/v4/classic/schemas.js +1006 -0
- package/dist/node_modules/zod/v4/core/api.cjs +1016 -0
- package/dist/node_modules/zod/v4/core/api.js +903 -0
- package/dist/node_modules/zod/v4/core/checks.cjs +587 -0
- package/dist/node_modules/zod/v4/core/checks.js +562 -0
- package/dist/node_modules/zod/v4/core/core.cjs +72 -0
- package/dist/node_modules/zod/v4/core/core.js +63 -0
- package/dist/node_modules/zod/v4/core/doc.cjs +41 -0
- package/dist/node_modules/zod/v4/core/doc.js +37 -0
- package/dist/node_modules/zod/v4/core/errors.cjs +204 -0
- package/dist/node_modules/zod/v4/core/errors.js +194 -0
- package/dist/node_modules/zod/v4/core/function.cjs +81 -0
- package/dist/node_modules/zod/v4/core/function.js +76 -0
- package/dist/node_modules/zod/v4/core/index.cjs +261 -0
- package/dist/node_modules/zod/v4/core/index.js +20 -0
- package/dist/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/dist/node_modules/zod/v4/core/json-schema.js +1 -0
- package/dist/node_modules/zod/v4/core/parse.cjs +71 -0
- package/dist/node_modules/zod/v4/core/parse.js +60 -0
- package/dist/node_modules/zod/v4/core/regexes.cjs +139 -0
- package/dist/node_modules/zod/v4/core/regexes.js +95 -0
- package/dist/node_modules/zod/v4/core/registries.cjs +52 -0
- package/dist/node_modules/zod/v4/core/registries.js +44 -0
- package/dist/node_modules/zod/v4/core/schemas.cjs +1793 -0
- package/dist/node_modules/zod/v4/core/schemas.js +1720 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs +823 -0
- package/dist/node_modules/zod/v4/core/to-json-schema.js +818 -0
- package/dist/node_modules/zod/v4/core/util.cjs +543 -0
- package/dist/node_modules/zod/v4/core/util.js +491 -0
- package/dist/node_modules/zod/v4/core/versions.cjs +11 -0
- package/dist/node_modules/zod/v4/core/versions.js +7 -0
- package/dist/node_modules/zod/v4/index.cjs +10 -0
- package/dist/node_modules/zod/v4/index.js +5 -0
- package/dist/node_modules/zod/v4/locales/ar.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/ar.js +119 -0
- package/dist/node_modules/zod/v4/locales/az.cjs +120 -0
- package/dist/node_modules/zod/v4/locales/az.js +118 -0
- package/dist/node_modules/zod/v4/locales/be.cjs +169 -0
- package/dist/node_modules/zod/v4/locales/be.js +167 -0
- package/dist/node_modules/zod/v4/locales/ca.cjs +123 -0
- package/dist/node_modules/zod/v4/locales/ca.js +121 -0
- package/dist/node_modules/zod/v4/locales/cs.cjs +140 -0
- package/dist/node_modules/zod/v4/locales/cs.js +138 -0
- package/dist/node_modules/zod/v4/locales/de.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/de.js +119 -0
- package/dist/node_modules/zod/v4/locales/en.cjs +125 -0
- package/dist/node_modules/zod/v4/locales/en.js +120 -0
- package/dist/node_modules/zod/v4/locales/eo.cjs +124 -0
- package/dist/node_modules/zod/v4/locales/eo.js +119 -0
- package/dist/node_modules/zod/v4/locales/es.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/es.js +120 -0
- package/dist/node_modules/zod/v4/locales/fa.cjs +127 -0
- package/dist/node_modules/zod/v4/locales/fa.js +125 -0
- package/dist/node_modules/zod/v4/locales/fi.cjs +127 -0
- package/dist/node_modules/zod/v4/locales/fi.js +125 -0
- package/dist/node_modules/zod/v4/locales/fr-CA.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/fr-CA.js +120 -0
- package/dist/node_modules/zod/v4/locales/fr.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/fr.js +119 -0
- package/dist/node_modules/zod/v4/locales/he.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/he.js +120 -0
- package/dist/node_modules/zod/v4/locales/hu.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/hu.js +120 -0
- package/dist/node_modules/zod/v4/locales/id.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/id.js +119 -0
- package/dist/node_modules/zod/v4/locales/index.cjs +85 -0
- package/dist/node_modules/zod/v4/locales/index.js +39 -0
- package/dist/node_modules/zod/v4/locales/it.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/it.js +120 -0
- package/dist/node_modules/zod/v4/locales/ja.cjs +120 -0
- package/dist/node_modules/zod/v4/locales/ja.js +118 -0
- package/dist/node_modules/zod/v4/locales/kh.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/kh.js +120 -0
- package/dist/node_modules/zod/v4/locales/ko.cjs +126 -0
- package/dist/node_modules/zod/v4/locales/ko.js +124 -0
- package/dist/node_modules/zod/v4/locales/mk.cjs +123 -0
- package/dist/node_modules/zod/v4/locales/mk.js +121 -0
- package/dist/node_modules/zod/v4/locales/ms.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/ms.js +119 -0
- package/dist/node_modules/zod/v4/locales/nl.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/nl.js +120 -0
- package/dist/node_modules/zod/v4/locales/no.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/no.js +119 -0
- package/dist/node_modules/zod/v4/locales/ota.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/ota.js +120 -0
- package/dist/node_modules/zod/v4/locales/pl.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/pl.js +120 -0
- package/dist/node_modules/zod/v4/locales/ps.cjs +127 -0
- package/dist/node_modules/zod/v4/locales/ps.js +125 -0
- package/dist/node_modules/zod/v4/locales/pt.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/pt.js +119 -0
- package/dist/node_modules/zod/v4/locales/ru.cjs +169 -0
- package/dist/node_modules/zod/v4/locales/ru.js +167 -0
- package/dist/node_modules/zod/v4/locales/sl.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/sl.js +120 -0
- package/dist/node_modules/zod/v4/locales/sv.cjs +123 -0
- package/dist/node_modules/zod/v4/locales/sv.js +121 -0
- package/dist/node_modules/zod/v4/locales/ta.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/ta.js +120 -0
- package/dist/node_modules/zod/v4/locales/th.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/th.js +120 -0
- package/dist/node_modules/zod/v4/locales/tr.cjs +123 -0
- package/dist/node_modules/zod/v4/locales/tr.js +118 -0
- package/dist/node_modules/zod/v4/locales/ua.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/ua.js +120 -0
- package/dist/node_modules/zod/v4/locales/ur.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/ur.js +120 -0
- package/dist/node_modules/zod/v4/locales/vi.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/vi.js +119 -0
- package/dist/node_modules/zod/v4/locales/zh-CN.cjs +121 -0
- package/dist/node_modules/zod/v4/locales/zh-CN.js +119 -0
- package/dist/node_modules/zod/v4/locales/zh-TW.cjs +122 -0
- package/dist/node_modules/zod/v4/locales/zh-TW.js +120 -0
- package/package.json +1 -1
|
@@ -7,14 +7,18 @@ 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 = ({
|
|
10
|
+
const FormButtonSubmit = ({
|
|
11
|
+
disabled,
|
|
12
|
+
disabledWhenSuccess,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
11
15
|
const {
|
|
12
16
|
formState: { isSubmitting, isSubmitSuccessful }
|
|
13
17
|
} = reactHookForm.useFormContext();
|
|
14
18
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15
19
|
core.Button,
|
|
16
20
|
{
|
|
17
|
-
disabled: disabled ?? (isSubmitSuccessful &&
|
|
21
|
+
disabled: disabled ?? (isSubmitSuccessful && disabledWhenSuccess),
|
|
18
22
|
loading: isSubmitting,
|
|
19
23
|
type: "submit",
|
|
20
24
|
...props
|
|
@@ -3,14 +3,18 @@ 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 = ({
|
|
6
|
+
const FormButtonSubmit = ({
|
|
7
|
+
disabled,
|
|
8
|
+
disabledWhenSuccess,
|
|
9
|
+
...props
|
|
10
|
+
}) => {
|
|
7
11
|
const {
|
|
8
12
|
formState: { isSubmitting, isSubmitSuccessful }
|
|
9
13
|
} = useFormContext();
|
|
10
14
|
return /* @__PURE__ */ jsx(
|
|
11
15
|
Button,
|
|
12
16
|
{
|
|
13
|
-
disabled: disabled ?? (isSubmitSuccessful &&
|
|
17
|
+
disabled: disabled ?? (isSubmitSuccessful && disabledWhenSuccess),
|
|
14
18
|
loading: isSubmitting,
|
|
15
19
|
type: "submit",
|
|
16
20
|
...props
|
|
@@ -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
|
@@ -47,7 +47,6 @@ import { UseFormReturn } from 'react-hook-form';
|
|
|
47
47
|
import { VirtualItem } from '@tanstack/react-virtual';
|
|
48
48
|
import { z } from 'zod/v4';
|
|
49
49
|
import { ZodType } from 'zod/v4';
|
|
50
|
-
import { ZodTypeAny } from 'zod';
|
|
51
50
|
|
|
52
51
|
export declare const addBodyJsonHook: BeforeErrorHook;
|
|
53
52
|
|
|
@@ -107,7 +106,7 @@ export declare const Form: <T extends FieldValues, TContext = any, TT extends T
|
|
|
107
106
|
|
|
108
107
|
export declare function formatBytes(bytes: number, decimals?: number): string;
|
|
109
108
|
|
|
110
|
-
export declare const FormButtonSubmit: ({ disabled, ...props }: FormButtonSubmitProps) => JSX.Element;
|
|
109
|
+
export declare const FormButtonSubmit: ({ disabled, disabledWhenSuccess, ...props }: FormButtonSubmitProps) => JSX.Element;
|
|
111
110
|
|
|
112
111
|
export declare interface FormButtonSubmitProps extends ButtonProps, ElementProps<'button', keyof ButtonProps> {
|
|
113
112
|
disabledWhenSuccess?: boolean;
|
|
@@ -544,6 +543,8 @@ export declare const useUpdateSearchParams: () => {
|
|
|
544
543
|
searchParams: ReadonlyURLSearchParams;
|
|
545
544
|
};
|
|
546
545
|
|
|
546
|
+
export declare const useZodConfig: () => void;
|
|
547
|
+
|
|
547
548
|
export declare const withForm: <P extends unknown>(WrappedComponent: React.ComponentType<FormFieldProps<P>>, getControllerProps?: (fieldProps: P) => Omit<Partial<ControllerProps>, "render">) => FC<P & WithFormProps>;
|
|
548
549
|
|
|
549
550
|
export declare interface WithFormProps {
|
|
@@ -551,7 +552,7 @@ export declare interface WithFormProps {
|
|
|
551
552
|
label?: ReactNode;
|
|
552
553
|
placeholder?: string;
|
|
553
554
|
description?: ReactNode;
|
|
554
|
-
validate?:
|
|
555
|
+
validate?: ZodType;
|
|
555
556
|
disabled?: boolean;
|
|
556
557
|
}
|
|
557
558
|
|
|
@@ -562,6 +563,6 @@ export declare interface WithModalManagerProps {
|
|
|
562
563
|
opened: boolean;
|
|
563
564
|
}
|
|
564
565
|
|
|
565
|
-
export declare const zodValidator: (schema:
|
|
566
|
+
export declare const zodValidator: (schema: ZodType) => (values: any) => string | undefined;
|
|
566
567
|
|
|
567
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
|
-
|
|
599
|
-
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
617
|
-
|
|
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
|
-
|
|
595
|
-
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
|
|
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)
|
|
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)
|
|
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 };
|