@surdeddd/bottom-sheet 0.1.0
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/LICENSE +21 -0
- package/README.md +377 -0
- package/dist/BottomSheetEngine-CvSVbo6c.d.cts +704 -0
- package/dist/BottomSheetEngine-DbO8rW_3.d.ts +704 -0
- package/dist/element.cjs +3442 -0
- package/dist/element.d.cts +88 -0
- package/dist/element.d.ts +88 -0
- package/dist/element.iife.global.js +3 -0
- package/dist/element.js +3442 -0
- package/dist/index.cjs +3693 -0
- package/dist/index.d.cts +184 -0
- package/dist/index.d.ts +184 -0
- package/dist/index.js +3669 -0
- package/dist/integrations/formik.cjs +27 -0
- package/dist/integrations/formik.d.cts +27 -0
- package/dist/integrations/formik.d.ts +27 -0
- package/dist/integrations/formik.js +25 -0
- package/dist/integrations/react-hook-form.cjs +28 -0
- package/dist/integrations/react-hook-form.d.cts +30 -0
- package/dist/integrations/react-hook-form.d.ts +30 -0
- package/dist/integrations/react-hook-form.js +26 -0
- package/dist/overlay.cjs +1058 -0
- package/dist/overlay.d.cts +282 -0
- package/dist/overlay.d.ts +282 -0
- package/dist/overlay.js +1053 -0
- package/dist/preact.cjs +2 -0
- package/dist/preact.d.cts +5 -0
- package/dist/preact.d.ts +5 -0
- package/dist/preact.js +2 -0
- package/dist/qwik.cjs +3046 -0
- package/dist/qwik.d.cts +55 -0
- package/dist/qwik.d.ts +55 -0
- package/dist/qwik.js +3044 -0
- package/dist/react.cjs +4162 -0
- package/dist/react.d.cts +301 -0
- package/dist/react.d.ts +301 -0
- package/dist/react.js +4156 -0
- package/dist/solid.cjs +3063 -0
- package/dist/solid.d.cts +66 -0
- package/dist/solid.d.ts +66 -0
- package/dist/solid.js +3061 -0
- package/dist/styles.css +508 -0
- package/dist/svelte.cjs +3200 -0
- package/dist/svelte.d.ts +89 -0
- package/dist/svelte.js +3177 -0
- package/dist/themes/ios.css +24 -0
- package/dist/themes/material.css +24 -0
- package/dist/themes/vercel.css +24 -0
- package/dist/transform-Brkf-wzo.d.cts +4 -0
- package/dist/transform-Brkf-wzo.d.ts +4 -0
- package/dist/vue.cjs +3361 -0
- package/dist/vue.d.ts +68 -0
- package/dist/vue.js +3358 -0
- package/package.json +288 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
// src/integrations/formik.ts
|
|
6
|
+
function useFormikGuard(sheetRef, formikRef, _tag) {
|
|
7
|
+
react.useEffect(() => {
|
|
8
|
+
const target = sheetRef.current;
|
|
9
|
+
if (!target) return;
|
|
10
|
+
const off = target.on("before-snap", (payload) => {
|
|
11
|
+
const formik = formikRef.current;
|
|
12
|
+
if (!formik) return;
|
|
13
|
+
if (formik.isSubmitting) {
|
|
14
|
+
payload.cancel();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (payload.id === "closed" && formik.dirty) {
|
|
18
|
+
payload.cancel();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return off;
|
|
22
|
+
}, [sheetRef, formikRef]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.useFormikGuard = useFormikGuard;
|
|
26
|
+
//# sourceMappingURL=formik.cjs.map
|
|
27
|
+
//# sourceMappingURL=formik.cjs.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { d as SheetEventMap } from '../BottomSheetEngine-CvSVbo6c.cjs';
|
|
2
|
+
import '../transform-Brkf-wzo.cjs';
|
|
3
|
+
|
|
4
|
+
type FormikStateLike = {
|
|
5
|
+
dirty: boolean;
|
|
6
|
+
isSubmitting: boolean;
|
|
7
|
+
};
|
|
8
|
+
type SheetEventTarget = {
|
|
9
|
+
on: <K extends keyof SheetEventMap>(event: K, listener: (payload: SheetEventMap[K]) => void) => () => void;
|
|
10
|
+
};
|
|
11
|
+
type SheetGuardRef = {
|
|
12
|
+
current: SheetEventTarget | null | undefined;
|
|
13
|
+
} | {
|
|
14
|
+
readonly current: SheetEventTarget | null | undefined;
|
|
15
|
+
};
|
|
16
|
+
type FormikRefLike = {
|
|
17
|
+
current: FormikStateLike | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Formik counterpart to useFormGuard — takes a `ref<FormikProps>` because
|
|
21
|
+
* Formik's render-prop API doesn't surface props at hook-call time the way
|
|
22
|
+
* useForm() does. Use `<Formik innerRef={formikRef}>` or stash `useFormik()`
|
|
23
|
+
* on a ref yourself.
|
|
24
|
+
*/
|
|
25
|
+
declare function useFormikGuard<Values extends Record<string, unknown> = Record<string, unknown>>(sheetRef: SheetGuardRef, formikRef: FormikRefLike, _tag?: Values): void;
|
|
26
|
+
|
|
27
|
+
export { type FormikRefLike, type FormikStateLike, type SheetEventTarget, type SheetGuardRef, useFormikGuard };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { d as SheetEventMap } from '../BottomSheetEngine-DbO8rW_3.js';
|
|
2
|
+
import '../transform-Brkf-wzo.js';
|
|
3
|
+
|
|
4
|
+
type FormikStateLike = {
|
|
5
|
+
dirty: boolean;
|
|
6
|
+
isSubmitting: boolean;
|
|
7
|
+
};
|
|
8
|
+
type SheetEventTarget = {
|
|
9
|
+
on: <K extends keyof SheetEventMap>(event: K, listener: (payload: SheetEventMap[K]) => void) => () => void;
|
|
10
|
+
};
|
|
11
|
+
type SheetGuardRef = {
|
|
12
|
+
current: SheetEventTarget | null | undefined;
|
|
13
|
+
} | {
|
|
14
|
+
readonly current: SheetEventTarget | null | undefined;
|
|
15
|
+
};
|
|
16
|
+
type FormikRefLike = {
|
|
17
|
+
current: FormikStateLike | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Formik counterpart to useFormGuard — takes a `ref<FormikProps>` because
|
|
21
|
+
* Formik's render-prop API doesn't surface props at hook-call time the way
|
|
22
|
+
* useForm() does. Use `<Formik innerRef={formikRef}>` or stash `useFormik()`
|
|
23
|
+
* on a ref yourself.
|
|
24
|
+
*/
|
|
25
|
+
declare function useFormikGuard<Values extends Record<string, unknown> = Record<string, unknown>>(sheetRef: SheetGuardRef, formikRef: FormikRefLike, _tag?: Values): void;
|
|
26
|
+
|
|
27
|
+
export { type FormikRefLike, type FormikStateLike, type SheetEventTarget, type SheetGuardRef, useFormikGuard };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/integrations/formik.ts
|
|
4
|
+
function useFormikGuard(sheetRef, formikRef, _tag) {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const target = sheetRef.current;
|
|
7
|
+
if (!target) return;
|
|
8
|
+
const off = target.on("before-snap", (payload) => {
|
|
9
|
+
const formik = formikRef.current;
|
|
10
|
+
if (!formik) return;
|
|
11
|
+
if (formik.isSubmitting) {
|
|
12
|
+
payload.cancel();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (payload.id === "closed" && formik.dirty) {
|
|
16
|
+
payload.cancel();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return off;
|
|
20
|
+
}, [sheetRef, formikRef]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { useFormikGuard };
|
|
24
|
+
//# sourceMappingURL=formik.js.map
|
|
25
|
+
//# sourceMappingURL=formik.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
// src/integrations/react-hook-form.ts
|
|
6
|
+
function useFormGuard(sheetRef, methods, _tag) {
|
|
7
|
+
const methodsRef = react.useRef(methods);
|
|
8
|
+
methodsRef.current = methods;
|
|
9
|
+
react.useEffect(() => {
|
|
10
|
+
const target = sheetRef.current;
|
|
11
|
+
if (!target) return;
|
|
12
|
+
const off = target.on("before-snap", (payload) => {
|
|
13
|
+
const { isDirty, isSubmitting } = methodsRef.current.formState;
|
|
14
|
+
if (isSubmitting) {
|
|
15
|
+
payload.cancel();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (payload.id === "closed" && isDirty) {
|
|
19
|
+
payload.cancel();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return off;
|
|
23
|
+
}, [sheetRef]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.useFormGuard = useFormGuard;
|
|
27
|
+
//# sourceMappingURL=react-hook-form.cjs.map
|
|
28
|
+
//# sourceMappingURL=react-hook-form.cjs.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { d as SheetEventMap } from '../BottomSheetEngine-CvSVbo6c.cjs';
|
|
2
|
+
import '../transform-Brkf-wzo.cjs';
|
|
3
|
+
|
|
4
|
+
type RhfFormStateLike = {
|
|
5
|
+
formState: {
|
|
6
|
+
isDirty: boolean;
|
|
7
|
+
isSubmitting: boolean;
|
|
8
|
+
isSubmitSuccessful: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type SheetEventTarget = {
|
|
12
|
+
on: <K extends keyof SheetEventMap>(event: K, listener: (payload: SheetEventMap[K]) => void) => () => void;
|
|
13
|
+
};
|
|
14
|
+
type SheetGuardRef = {
|
|
15
|
+
current: SheetEventTarget | null | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
readonly current: SheetEventTarget | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Gates close attempts behind react-hook-form's `isDirty` / `isSubmitting`.
|
|
21
|
+
* Cancels closing while the form is dirty (consumer prompts then re-calls
|
|
22
|
+
* close) and cancels every snap while submit is in flight.
|
|
23
|
+
*
|
|
24
|
+
* The `methods` argument is read through a ref refreshed each render, so a
|
|
25
|
+
* freshly-constructed `useForm()` return on each parent render is safe —
|
|
26
|
+
* the listener always reads live form state, never a closure-captured one.
|
|
27
|
+
*/
|
|
28
|
+
declare function useFormGuard<TFieldValues extends Record<string, unknown> = Record<string, unknown>>(sheetRef: SheetGuardRef, methods: RhfFormStateLike, _tag?: TFieldValues): void;
|
|
29
|
+
|
|
30
|
+
export { type RhfFormStateLike, type SheetEventTarget, type SheetGuardRef, useFormGuard };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { d as SheetEventMap } from '../BottomSheetEngine-DbO8rW_3.js';
|
|
2
|
+
import '../transform-Brkf-wzo.js';
|
|
3
|
+
|
|
4
|
+
type RhfFormStateLike = {
|
|
5
|
+
formState: {
|
|
6
|
+
isDirty: boolean;
|
|
7
|
+
isSubmitting: boolean;
|
|
8
|
+
isSubmitSuccessful: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type SheetEventTarget = {
|
|
12
|
+
on: <K extends keyof SheetEventMap>(event: K, listener: (payload: SheetEventMap[K]) => void) => () => void;
|
|
13
|
+
};
|
|
14
|
+
type SheetGuardRef = {
|
|
15
|
+
current: SheetEventTarget | null | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
readonly current: SheetEventTarget | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Gates close attempts behind react-hook-form's `isDirty` / `isSubmitting`.
|
|
21
|
+
* Cancels closing while the form is dirty (consumer prompts then re-calls
|
|
22
|
+
* close) and cancels every snap while submit is in flight.
|
|
23
|
+
*
|
|
24
|
+
* The `methods` argument is read through a ref refreshed each render, so a
|
|
25
|
+
* freshly-constructed `useForm()` return on each parent render is safe —
|
|
26
|
+
* the listener always reads live form state, never a closure-captured one.
|
|
27
|
+
*/
|
|
28
|
+
declare function useFormGuard<TFieldValues extends Record<string, unknown> = Record<string, unknown>>(sheetRef: SheetGuardRef, methods: RhfFormStateLike, _tag?: TFieldValues): void;
|
|
29
|
+
|
|
30
|
+
export { type RhfFormStateLike, type SheetEventTarget, type SheetGuardRef, useFormGuard };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/integrations/react-hook-form.ts
|
|
4
|
+
function useFormGuard(sheetRef, methods, _tag) {
|
|
5
|
+
const methodsRef = useRef(methods);
|
|
6
|
+
methodsRef.current = methods;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const target = sheetRef.current;
|
|
9
|
+
if (!target) return;
|
|
10
|
+
const off = target.on("before-snap", (payload) => {
|
|
11
|
+
const { isDirty, isSubmitting } = methodsRef.current.formState;
|
|
12
|
+
if (isSubmitting) {
|
|
13
|
+
payload.cancel();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (payload.id === "closed" && isDirty) {
|
|
17
|
+
payload.cancel();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return off;
|
|
21
|
+
}, [sheetRef]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { useFormGuard };
|
|
25
|
+
//# sourceMappingURL=react-hook-form.js.map
|
|
26
|
+
//# sourceMappingURL=react-hook-form.js.map
|