@boxcustodia/library 2.0.0-alpha.19 → 2.0.0-alpha.20
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/components/button/button.cjs.js +1 -1
- package/dist/components/button/button.es.js +19 -18
- package/dist/components/button/components/base-button.cjs.js +1 -1
- package/dist/components/button/components/base-button.es.js +20 -20
- package/dist/components/calendar/calendar.cjs.js +1 -1
- package/dist/components/calendar/calendar.es.js +1 -0
- package/dist/components/date-picker/date-input.cjs.js +1 -1
- package/dist/components/date-picker/date-input.es.js +92 -75
- package/dist/components/date-picker/date-picker.cjs.js +1 -1
- package/dist/components/date-picker/date-picker.es.js +104 -95
- package/dist/components/date-picker/date-picker.utils.cjs.js +1 -1
- package/dist/components/date-picker/date-picker.utils.es.js +51 -43
- package/dist/components/date-picker/use-hidden-field-value.cjs.js +1 -0
- package/dist/components/date-picker/use-hidden-field-value.es.js +11 -0
- package/dist/components/menu/menu.es.js +1 -9
- package/dist/components/otp/otp.cjs.js +2 -0
- package/dist/components/otp/otp.es.js +93 -0
- package/dist/components/password/password.cjs.js +1 -1
- package/dist/components/password/password.es.js +2 -2
- package/dist/components/select/select.cjs.js +1 -1
- package/dist/components/select/select.es.js +68 -60
- package/dist/hooks/internal/is-apple-device.cjs.js +1 -0
- package/dist/hooks/internal/is-apple-device.es.js +9 -0
- package/dist/hooks/internal/use-latest-ref.cjs.js +1 -0
- package/dist/hooks/internal/use-latest-ref.es.js +11 -0
- package/dist/hooks/use-array/use-array.cjs.js +1 -1
- package/dist/hooks/use-array/use-array.es.js +54 -42
- package/dist/hooks/use-async/use-async.cjs.js +1 -1
- package/dist/hooks/use-async/use-async.es.js +53 -20
- package/dist/hooks/use-boolean/use-boolean.cjs.js +1 -0
- package/dist/hooks/use-boolean/use-boolean.es.js +25 -0
- package/dist/hooks/use-click-outside/use-click-outside.cjs.js +1 -1
- package/dist/hooks/use-click-outside/use-click-outside.es.js +26 -12
- package/dist/hooks/use-debounce-callback/use-debounced-callback.cjs.js +1 -1
- package/dist/hooks/use-debounce-callback/use-debounced-callback.es.js +27 -10
- package/dist/hooks/use-debounce-value/use-debounced-value.cjs.js +1 -1
- package/dist/hooks/use-debounce-value/use-debounced-value.es.js +7 -9
- package/dist/hooks/use-disclosure/use-disclosure.cjs.js +1 -1
- package/dist/hooks/use-disclosure/use-disclosure.es.js +21 -11
- package/dist/hooks/use-document-title/use-document-title.cjs.js +1 -1
- package/dist/hooks/use-document-title/use-document-title.es.js +14 -12
- package/dist/hooks/use-event-listener/use-event-listener.cjs.js +1 -1
- package/dist/hooks/use-event-listener/use-event-listener.es.js +17 -9
- package/dist/hooks/use-hotkey/use-hotkey.cjs.js +1 -1
- package/dist/hooks/use-hotkey/use-hotkey.es.js +30 -14
- package/dist/hooks/use-hotkey/utils/is-input-field.cjs.js +1 -1
- package/dist/hooks/use-hotkey/utils/is-input-field.es.js +4 -2
- package/dist/hooks/use-hotkey/utils/match-and-run.cjs.js +1 -0
- package/dist/hooks/use-hotkey/utils/match-and-run.es.js +12 -0
- package/dist/hooks/use-hotkey/utils/match-key-modifiers.cjs.js +1 -1
- package/dist/hooks/use-hotkey/utils/match-key-modifiers.es.js +13 -12
- package/dist/hooks/use-hover/use-hover.cjs.js +1 -1
- package/dist/hooks/use-hover/use-hover.es.js +32 -17
- package/dist/hooks/use-is-visible/use-is-visible.cjs.js +1 -1
- package/dist/hooks/use-is-visible/use-is-visible.es.js +31 -27
- package/dist/hooks/use-local-storage/use-local-storage.cjs.js +1 -1
- package/dist/hooks/use-local-storage/use-local-storage.es.js +52 -20
- package/dist/hooks/use-media-query/use-media-query.cjs.js +1 -1
- package/dist/hooks/use-media-query/use-media-query.es.js +21 -11
- package/dist/hooks/use-mutation/use-mutation.cjs.js +1 -1
- package/dist/hooks/use-mutation/use-mutation.es.js +36 -22
- package/dist/hooks/use-object/use-object.cjs.js +1 -1
- package/dist/hooks/use-object/use-object.es.js +26 -22
- package/dist/hooks/use-prevent-page-close/use-prevent-page-close.cjs.js +1 -0
- package/dist/hooks/use-prevent-page-close/use-prevent-page-close.es.js +14 -0
- package/dist/hooks/use-step/use-step.cjs.js +1 -1
- package/dist/hooks/use-step/use-step.es.js +25 -24
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +308 -300
- package/dist/src/components/date-picker/date-picker.utils.d.ts +17 -0
- package/dist/src/components/date-picker/use-hidden-field-value.d.ts +12 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/hooks/index.d.ts +2 -2
- package/dist/src/hooks/internal/index.d.ts +2 -0
- package/dist/src/hooks/internal/is-apple-device.d.ts +12 -0
- package/dist/src/hooks/internal/use-latest-ref.d.ts +12 -0
- package/dist/src/hooks/use-array/use-array.d.ts +24 -11
- package/dist/src/hooks/use-async/use-async.d.ts +16 -13
- package/dist/src/hooks/use-boolean/index.d.ts +1 -0
- package/dist/src/hooks/use-boolean/use-boolean.d.ts +15 -0
- package/dist/src/hooks/use-boolean/use-boolean.test.d.ts +1 -0
- package/dist/src/hooks/use-click-outside/use-click-outside.d.ts +23 -1
- package/dist/src/hooks/use-debounce-callback/use-debounced-callback.d.ts +19 -1
- package/dist/src/hooks/use-debounce-value/use-debounced-value.d.ts +10 -1
- package/dist/src/hooks/use-disclosure/use-disclosure.d.ts +17 -8
- package/dist/src/hooks/use-document-title/use-document-title.d.ts +11 -0
- package/dist/src/hooks/use-event-listener/use-event-listener.d.ts +18 -1
- package/dist/src/hooks/use-hotkey/index.d.ts +2 -1
- package/dist/src/hooks/use-hotkey/use-hotkey.d.ts +62 -5
- package/dist/src/hooks/use-hotkey/utils/index.d.ts +4 -3
- package/dist/src/hooks/use-hotkey/utils/is-input-field.d.ts +12 -2
- package/dist/src/hooks/use-hotkey/utils/is-input-field.test.d.ts +1 -0
- package/dist/src/hooks/use-hotkey/utils/match-and-run.d.ts +36 -0
- package/dist/src/hooks/use-hotkey/utils/match-and-run.test.d.ts +1 -0
- package/dist/src/hooks/use-hotkey/utils/match-key-modifiers.d.ts +20 -6
- package/dist/src/hooks/use-hotkey/utils/match-key-modifiers.test.d.ts +1 -0
- package/dist/src/hooks/use-hover/use-hover.d.ts +8 -4
- package/dist/src/hooks/use-is-visible/use-is-visible.d.ts +28 -4
- package/dist/src/hooks/use-local-storage/use-local-storage.d.ts +13 -2
- package/dist/src/hooks/use-media-query/use-media-query.d.ts +10 -1
- package/dist/src/hooks/use-media-query/use-media-query.test.d.ts +1 -0
- package/dist/src/hooks/use-mutation/use-mutation.d.ts +18 -11
- package/dist/src/hooks/use-object/use-object.d.ts +15 -6
- package/dist/src/hooks/use-prevent-page-close/index.d.ts +1 -0
- package/dist/src/hooks/use-prevent-page-close/use-prevent-page-close.d.ts +10 -0
- package/dist/src/hooks/use-prevent-page-close/use-prevent-page-close.test.d.ts +1 -0
- package/dist/src/hooks/use-step/use-step.d.ts +18 -11
- package/dist/src/utils/form.d.ts +10 -0
- package/package.json +1 -1
- package/src/components/alert-dialog/alert-dialog.test.tsx +13 -9
- package/src/components/auto-complete/auto-complete.test.tsx +4 -14
- package/src/components/avatar/avatar.test.tsx +7 -12
- package/src/components/button/button.test.tsx +10 -15
- package/src/components/button/button.tsx +14 -9
- package/src/components/button/components/base-button.tsx +2 -4
- package/src/components/calendar/calendar.test.tsx +12 -19
- package/src/components/calendar/calendar.tsx +4 -0
- package/src/components/card/card.test.tsx +4 -6
- package/src/components/checkbox/checkbox.test.tsx +12 -8
- package/src/components/checkbox-group/checkbox-group.test.tsx +7 -8
- package/src/components/combobox/combobox.test.tsx +24 -21
- package/src/components/date-picker/date-input-form.test.tsx +77 -0
- package/src/components/date-picker/date-input.stories.tsx +30 -18
- package/src/components/date-picker/date-input.tsx +77 -44
- package/src/components/date-picker/date-picker.stories.tsx +31 -1
- package/src/components/date-picker/date-picker.test.tsx +3 -13
- package/src/components/date-picker/date-picker.tsx +35 -16
- package/src/components/date-picker/date-picker.utils.test.ts +32 -14
- package/src/components/date-picker/date-picker.utils.ts +33 -0
- package/src/components/date-picker/use-date-input-popover.test.ts +3 -1
- package/src/components/date-picker/use-hidden-field-value.ts +23 -0
- package/src/components/dialog/dialog.test.tsx +10 -8
- package/src/components/dropzone/dropzone.test.tsx +11 -13
- package/src/components/empty/empty.test.tsx +4 -3
- package/src/components/field/field.test.tsx +12 -13
- package/src/components/form/form.stories.tsx +16 -1
- package/src/components/index.ts +1 -0
- package/src/components/label/label.test.tsx +3 -3
- package/src/components/menu/menu.tsx +1 -5
- package/src/components/number-input/number-input.test.tsx +6 -2
- package/src/components/password/password.test.tsx +20 -6
- package/src/components/password/password.tsx +2 -2
- package/src/components/popover/popover.test.tsx +4 -4
- package/src/components/progress/progress.test.tsx +7 -8
- package/src/components/radio-group/radio-group.test.tsx +17 -11
- package/src/components/select/select.test.tsx +10 -10
- package/src/components/select/select.tsx +9 -1
- package/src/components/stepper/stepper.stories.tsx +11 -15
- package/src/components/stepper/stepper.test.tsx +6 -4
- package/src/components/switch/switch.test.tsx +3 -3
- package/src/components/table/table.test.tsx +9 -3
- package/src/components/tabs/tabs.test.tsx +6 -2
- package/src/components/tag/tag.test.tsx +1 -3
- package/src/components/textarea/textarea.test.tsx +4 -1
- package/src/components/timeline/timeline.test.tsx +10 -5
- package/src/components/toast/toast.test.tsx +11 -14
- package/src/components/tooltip/tooltip.test.tsx +1 -5
- package/src/components/tree/tree.test.tsx +3 -1
- package/src/hooks/index.ts +2 -2
- package/src/hooks/internal/index.ts +2 -0
- package/src/hooks/internal/is-apple-device.test.ts +41 -0
- package/src/hooks/internal/is-apple-device.ts +33 -0
- package/src/hooks/internal/use-isomorphic-layout-effect.ts +3 -1
- package/src/hooks/internal/use-latest-ref.ts +21 -0
- package/src/hooks/use-array/use-array.stories.tsx +435 -64
- package/src/hooks/use-array/use-array.test.tsx +398 -15
- package/src/hooks/use-array/use-array.ts +105 -66
- package/src/hooks/use-async/use-async.stories.tsx +255 -131
- package/src/hooks/use-async/use-async.test.ts +397 -0
- package/src/hooks/use-async/use-async.ts +117 -39
- package/src/hooks/use-boolean/index.ts +1 -0
- package/src/hooks/use-boolean/use-boolean.stories.tsx +377 -0
- package/src/hooks/use-boolean/use-boolean.test.tsx +177 -0
- package/src/hooks/use-boolean/use-boolean.ts +50 -0
- package/src/hooks/use-click-outside/use-click-outside.stories.tsx +188 -18
- package/src/hooks/use-click-outside/use-click-outside.test.tsx +89 -10
- package/src/hooks/use-click-outside/use-click-outside.ts +62 -16
- package/src/hooks/use-debounce-callback/use-debounced-callback.stories.tsx +141 -41
- package/src/hooks/use-debounce-callback/use-debounced-callback.test.ts +217 -9
- package/src/hooks/use-debounce-callback/use-debounced-callback.ts +71 -11
- package/src/hooks/use-debounce-value/use-debounced-value.stories.tsx +247 -47
- package/src/hooks/use-debounce-value/use-debounced-value.test.ts +105 -10
- package/src/hooks/use-debounce-value/use-debounced-value.ts +19 -10
- package/src/hooks/use-disclosure/use-disclosure.stories.tsx +305 -14
- package/src/hooks/use-disclosure/use-disclosure.test.ts +198 -50
- package/src/hooks/use-disclosure/use-disclosure.ts +49 -29
- package/src/hooks/use-document-title/use-document-title.stories.tsx +54 -0
- package/src/hooks/use-document-title/use-document-title.test.tsx +26 -0
- package/src/hooks/use-document-title/{use-document-title.tsx → use-document-title.ts} +17 -3
- package/src/hooks/use-event-listener/use-event-listener.stories.tsx +105 -9
- package/src/hooks/use-event-listener/use-event-listener.test.tsx +77 -10
- package/src/hooks/use-event-listener/use-event-listener.ts +71 -11
- package/src/hooks/use-focus-trap/use-focus-trap.test.ts +31 -6
- package/src/hooks/use-focus-trap/use-focus-trap.ts +3 -2
- package/src/hooks/use-hotkey/index.ts +9 -1
- package/src/hooks/use-hotkey/use-hotkey.stories.tsx +279 -74
- package/src/hooks/use-hotkey/use-hotkey.test.tsx +286 -34
- package/src/hooks/use-hotkey/use-hotkey.ts +141 -17
- package/src/hooks/use-hotkey/utils/index.ts +8 -3
- package/src/hooks/use-hotkey/utils/is-input-field.test.ts +78 -0
- package/src/hooks/use-hotkey/utils/is-input-field.ts +31 -10
- package/src/hooks/use-hotkey/utils/match-and-run.test.ts +203 -0
- package/src/hooks/use-hotkey/utils/match-and-run.ts +62 -0
- package/src/hooks/use-hotkey/utils/match-key-modifiers.test.ts +65 -0
- package/src/hooks/use-hotkey/utils/match-key-modifiers.ts +39 -12
- package/src/hooks/use-hover/use-hover.stories.tsx +258 -80
- package/src/hooks/use-hover/use-hover.test.tsx +266 -26
- package/src/hooks/use-hover/use-hover.tsx +93 -28
- package/src/hooks/use-is-visible/use-is-visible.stories.tsx +193 -46
- package/src/hooks/use-is-visible/use-is-visible.test.tsx +235 -7
- package/src/hooks/use-is-visible/use-is-visible.ts +114 -0
- package/src/hooks/use-local-storage/use-local-storage.stories.tsx +129 -29
- package/src/hooks/use-local-storage/use-local-storage.test.ts +106 -41
- package/src/hooks/use-local-storage/use-local-storage.ts +100 -31
- package/src/hooks/use-media-query/use-media-query.stories.tsx +86 -26
- package/src/hooks/use-media-query/use-media-query.test.ts +132 -0
- package/src/hooks/use-media-query/use-media-query.ts +39 -14
- package/src/hooks/use-memoized-fn/use-memoized-fn.ts +0 -1
- package/src/hooks/use-mutation/use-mutation.stories.tsx +260 -94
- package/src/hooks/use-mutation/use-mutation.test.ts +359 -0
- package/src/hooks/use-mutation/use-mutation.ts +97 -0
- package/src/hooks/use-object/use-object.stories.tsx +310 -79
- package/src/hooks/use-object/use-object.test.tsx +235 -56
- package/src/hooks/use-object/use-object.ts +59 -0
- package/src/hooks/use-pagination/use-pagination.tsx +0 -1
- package/src/hooks/use-prevent-page-close/index.ts +1 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.stories.tsx +39 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.test.ts +89 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.ts +27 -0
- package/src/hooks/use-range-pagination/use-range-pagination.test.tsx +1 -1
- package/src/hooks/use-range-pagination/use-range-pagination.tsx +1 -1
- package/src/hooks/use-selection/use-selection.ts +0 -1
- package/src/hooks/use-step/use-step.stories.tsx +178 -65
- package/src/hooks/use-step/use-step.test.ts +178 -53
- package/src/hooks/use-step/use-step.ts +57 -49
- package/src/utils/form.test.tsx +13 -8
- package/src/utils/form.tsx +10 -0
- package/src/utils/functions/getFormData.test.ts +1 -1
- package/dist/hooks/use-hotkey/utils/create-hotkey-listener.cjs.js +0 -1
- package/dist/hooks/use-hotkey/utils/create-hotkey-listener.es.js +0 -10
- package/dist/hooks/use-prevent-close-window/use-prevent-close-window.cjs.js +0 -1
- package/dist/hooks/use-prevent-close-window/use-prevent-close-window.es.js +0 -15
- package/dist/hooks/use-toggle/use-toggle.cjs.js +0 -1
- package/dist/hooks/use-toggle/use-toggle.es.js +0 -10
- package/dist/src/hooks/use-hotkey/utils/create-hotkey-listener.d.ts +0 -1
- package/dist/src/hooks/use-prevent-close-window/index.d.ts +0 -1
- package/dist/src/hooks/use-prevent-close-window/use-prevent-close-window.d.ts +0 -13
- package/dist/src/hooks/use-toggle/index.d.ts +0 -1
- package/dist/src/hooks/use-toggle/use-toggle.d.ts +0 -3
- package/src/hooks/use-async/use-async.test.tsx +0 -68
- package/src/hooks/use-hotkey/utils/create-hotkey-listener.ts +0 -25
- package/src/hooks/use-is-visible/use-is-visible.tsx +0 -49
- package/src/hooks/use-mutation/use-mutation.test.tsx +0 -83
- package/src/hooks/use-mutation/use-mutation.tsx +0 -59
- package/src/hooks/use-object/use-object.tsx +0 -46
- package/src/hooks/use-prevent-close-window/index.ts +0 -1
- package/src/hooks/use-prevent-close-window/use-prevent-close-window.stories.tsx +0 -32
- package/src/hooks/use-prevent-close-window/use-prevent-close-window.test.ts +0 -79
- package/src/hooks/use-prevent-close-window/use-prevent-close-window.ts +0 -33
- package/src/hooks/use-toggle/index.ts +0 -1
- package/src/hooks/use-toggle/use-toggle.stories.tsx +0 -25
- package/src/hooks/use-toggle/use-toggle.test.tsx +0 -64
- package/src/hooks/use-toggle/use-toggle.ts +0 -14
- /package/dist/src/{hooks/use-prevent-close-window/use-prevent-close-window.test.d.ts → components/date-picker/date-input-form.test.d.ts} +0 -0
- /package/dist/src/hooks/{use-toggle/use-toggle.test.d.ts → internal/is-apple-device.test.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),k=require("../internal/use-latest-ref.cjs.js");function m(b,l){const n=k.useLatestRef(b),u=e.useRef(null),s=e.useRef(null),c=e.useRef(!0),[o,r]=e.useState(!1),t=e.useCallback(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[]),R=e.useCallback((...i)=>{t(),s.current=i,r(!0),u.current=setTimeout(()=>{u.current=null,c.current&&r(!1),n.current(...i)},l)},[l,t,n]),a=e.useCallback(()=>{t(),c.current&&r(!1)},[t]),f=e.useCallback(()=>{u.current!==null&&(t(),c.current&&r(!1),s.current!==null&&n.current(...s.current))},[t,n]);e.useEffect(()=>()=>{c.current=!1,t()},[t]);const d=e.useMemo(()=>({cancel:a,flush:f,isPending:o}),[a,f,o]);return[R,d]}exports.useDebouncedCallback=m;
|
|
@@ -1,15 +1,32 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { useRef as l, useState as p, useCallback as c, useEffect as g, useMemo as k } from "react";
|
|
2
|
+
import { useLatestRef as C } from "../internal/use-latest-ref.es.js";
|
|
3
|
+
function h(R, o) {
|
|
4
|
+
const n = C(R), t = l(null), s = l(null), r = l(!0), [f, u] = p(!1), e = c(() => {
|
|
5
|
+
t.current !== null && (clearTimeout(t.current), t.current = null);
|
|
6
|
+
}, []), b = c(
|
|
7
|
+
(...m) => {
|
|
8
|
+
e(), s.current = m, u(!0), t.current = setTimeout(() => {
|
|
9
|
+
t.current = null, r.current && u(!1), n.current(...m);
|
|
10
|
+
}, o);
|
|
9
11
|
},
|
|
10
|
-
[
|
|
12
|
+
[o, e, n]
|
|
13
|
+
), i = c(() => {
|
|
14
|
+
e(), r.current && u(!1);
|
|
15
|
+
}, [e]), a = c(() => {
|
|
16
|
+
t.current !== null && (e(), r.current && u(!1), s.current !== null && n.current(...s.current));
|
|
17
|
+
}, [e, n]);
|
|
18
|
+
g(
|
|
19
|
+
() => () => {
|
|
20
|
+
r.current = !1, e();
|
|
21
|
+
},
|
|
22
|
+
[e]
|
|
23
|
+
);
|
|
24
|
+
const d = k(
|
|
25
|
+
() => ({ cancel: i, flush: a, isPending: f }),
|
|
26
|
+
[i, a, f]
|
|
11
27
|
);
|
|
28
|
+
return [b, d];
|
|
12
29
|
}
|
|
13
30
|
export {
|
|
14
|
-
|
|
31
|
+
h as useDebouncedCallback
|
|
15
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),r=require("../use-debounce-callback/use-debounced-callback.cjs.js");function b(e,t){const[o,n]=c.useState(e),[u,s]=r.useDebouncedCallback(n,t);return c.useEffect(()=>{u(e)},[e,u]),[o,s]}exports.useDebouncedValue=b;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useState as s, useEffect as r } from "react";
|
|
2
|
+
import { useDebouncedCallback as d } from "../use-debounce-callback/use-debounced-callback.es.js";
|
|
3
|
+
function m(e, t) {
|
|
4
|
+
const [c, n] = s(e), [o, u] = d(n, t);
|
|
4
5
|
return r(() => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}, t);
|
|
8
|
-
return () => clearTimeout(n);
|
|
9
|
-
}, [e, t]), u;
|
|
6
|
+
o(e);
|
|
7
|
+
}, [e, o]), [c, u];
|
|
10
8
|
}
|
|
11
9
|
export {
|
|
12
|
-
|
|
10
|
+
m as useDebouncedValue
|
|
13
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),l=require("../internal/use-latest-ref.cjs.js");function g(o){const[c,a]=n.useState(o?.defaultOpen??!1),f=l.useLatestRef(o?.onOpenChange),s=n.useRef(!0);n.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]);const i=n.useMemo(()=>{const t=e=>a(u=>{const r=e(u);return r===u?u:(s.current&&f.current?.(r),r)});return{open:()=>t(()=>!0),close:()=>t(()=>!1),toggle:()=>t(e=>!e),setOpen:e=>t(()=>e)}},[]);return[c,i]}exports.useDisclosure=g;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import { useState as i,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}, [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { useState as i, useRef as l, useEffect as m, useMemo as p } from "react";
|
|
2
|
+
import { useLatestRef as O } from "../internal/use-latest-ref.es.js";
|
|
3
|
+
function d(s) {
|
|
4
|
+
const [u, c] = i(s?.defaultOpen ?? !1), f = O(s?.onOpenChange), n = l(!0);
|
|
5
|
+
m(() => (n.current = !0, () => {
|
|
6
|
+
n.current = !1;
|
|
7
|
+
}), []);
|
|
8
|
+
const a = p(() => {
|
|
9
|
+
const t = (e) => c((r) => {
|
|
10
|
+
const o = e(r);
|
|
11
|
+
return o === r ? r : (n.current && f.current?.(o), o);
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
open: () => t(() => !0),
|
|
15
|
+
close: () => t(() => !1),
|
|
16
|
+
toggle: () => t((e) => !e),
|
|
17
|
+
setOpen: (e) => t(() => e)
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return [u, a];
|
|
11
21
|
}
|
|
12
22
|
export {
|
|
13
|
-
|
|
23
|
+
d as useDisclosure
|
|
14
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),i=require("../internal/is-browser.cjs.js");function f(t,c={}){const{restoreOnUnmount:u=!1,template:r,enabled:s=!0}=c,o=n.useRef(u);o.current=u,n.useEffect(()=>{if(!i.isBrowser)return;const e=document.title;return()=>{o.current&&(document.title=e)}},[]),n.useEffect(()=>{if(!i.isBrowser||!s||typeof t!="string")return;const e=t.trim();e.length!==0&&(document.title=r?r.replace("%s",e):e)},[t,r,s])}exports.useDocumentTitle=f;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { useRef as c, useEffect as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
n
|
|
5
|
-
|
|
1
|
+
import { useRef as c, useEffect as i } from "react";
|
|
2
|
+
import { isBrowser as s } from "../internal/is-browser.es.js";
|
|
3
|
+
function p(t, f = {}) {
|
|
4
|
+
const { restoreOnUnmount: n = !1, template: r, enabled: o = !0 } = f, u = c(n);
|
|
5
|
+
u.current = n, i(() => {
|
|
6
|
+
if (!s) return;
|
|
7
|
+
const e = document.title;
|
|
6
8
|
return () => {
|
|
7
|
-
|
|
9
|
+
u.current && (document.title = e);
|
|
8
10
|
};
|
|
9
|
-
}, []),
|
|
10
|
-
if (typeof
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
}, [
|
|
11
|
+
}, []), i(() => {
|
|
12
|
+
if (!s || !o || typeof t != "string") return;
|
|
13
|
+
const e = t.trim();
|
|
14
|
+
e.length !== 0 && (document.title = r ? r.replace("%s", e) : e);
|
|
15
|
+
}, [t, r, o]);
|
|
14
16
|
}
|
|
15
17
|
export {
|
|
16
|
-
|
|
18
|
+
p as useDocumentTitle
|
|
17
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react"),c=require("../internal/use-latest-ref.cjs.js"),o=require("../internal/is-browser.cjs.js"),R=e=>e==null?o.isBrowser?window:null:"current"in e?e.current:e;function b(e,i,t,r){const f=c.useLatestRef(i),s=c.useLatestRef(r),l=typeof r=="boolean"?r:r?.capture,v=typeof r=="object"?r.once:void 0,a=typeof r=="object"?r.passive:void 0;L.useEffect(()=>{if(!o.isBrowser)return;const n=R(t);if(!n)return;const u=d=>{f.current(d)};return n.addEventListener(e,u,s.current),()=>{n.removeEventListener(e,u,s.current)}},[e,t,l,v,a])}exports.useEventListener=b;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useEffect as a } from "react";
|
|
2
|
+
import { useLatestRef as u } from "../internal/use-latest-ref.es.js";
|
|
3
|
+
import { isBrowser as s } from "../internal/is-browser.es.js";
|
|
4
|
+
const E = (e) => e == null ? s ? window : null : "current" in e ? e.current : e;
|
|
5
|
+
function w(e, f, t, r) {
|
|
6
|
+
const i = u(f), c = u(r), v = typeof r == "boolean" ? r : r?.capture, l = typeof r == "object" ? r.once : void 0, d = typeof r == "object" ? r.passive : void 0;
|
|
7
|
+
a(() => {
|
|
8
|
+
if (!s) return;
|
|
9
|
+
const n = E(t);
|
|
10
|
+
if (!n) return;
|
|
11
|
+
const o = (m) => {
|
|
12
|
+
i.current(m);
|
|
8
13
|
};
|
|
9
|
-
|
|
14
|
+
return n.addEventListener(e, o, c.current), () => {
|
|
15
|
+
n.removeEventListener(e, o, c.current);
|
|
16
|
+
};
|
|
17
|
+
}, [e, t, v, l, d]);
|
|
10
18
|
}
|
|
11
19
|
export {
|
|
12
|
-
|
|
20
|
+
w as useEventListener
|
|
13
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./utils/match-and-run.cjs.js"),T=require("../use-event-listener/use-event-listener.cjs.js"),l=["INPUT","TEXTAREA","SELECT"];function g(t,e,n){const o=Array.isArray(t)&&typeof e!="function",r=o?e??{}:n??{},{eventName:c="keydown",watch:a=!0,preventDefault:i=!0,triggerOnContentEditable:A=!1,tagsToIgnore:y=l}=r,m=o?t:s(t,e,{preventDefault:i,triggerOnContentEditable:A}),f=E=>{a&&u.matchAndRun(E,m,y)};T.useEventListener(c,f,document)}const s=(t,e,n)=>(Array.isArray(t)?t:[t]).map(r=>[r,e,n]);function H(t,e,n){const r=Array.isArray(t)&&typeof e!="function"?t:s(t,e,n??{});return c=>{u.matchAndRun(c,r,[])}}exports.getHotkeyHandler=H;exports.useHotkey=g;
|
|
@@ -1,18 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
const {
|
|
6
|
-
eventName:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { matchAndRun as a } from "./utils/match-and-run.es.js";
|
|
2
|
+
import { useEventListener as E } from "../use-event-listener/use-event-listener.es.js";
|
|
3
|
+
const T = ["INPUT", "TEXTAREA", "SELECT"];
|
|
4
|
+
function F(t, r, o) {
|
|
5
|
+
const n = Array.isArray(t) && typeof r != "function", e = n ? r ?? {} : o ?? {}, {
|
|
6
|
+
eventName: c = "keydown",
|
|
7
|
+
watch: s = !0,
|
|
8
|
+
preventDefault: u = !0,
|
|
9
|
+
triggerOnContentEditable: A = !1,
|
|
10
|
+
tagsToIgnore: m = T
|
|
11
|
+
} = e, f = n ? t : i(
|
|
12
|
+
t,
|
|
13
|
+
r,
|
|
14
|
+
{ preventDefault: u, triggerOnContentEditable: A }
|
|
13
15
|
);
|
|
14
|
-
|
|
16
|
+
E(c, (y) => {
|
|
17
|
+
s && a(y, f, m);
|
|
18
|
+
}, document);
|
|
19
|
+
}
|
|
20
|
+
const i = (t, r, o) => (Array.isArray(t) ? t : [t]).map((e) => [e, r, o]);
|
|
21
|
+
function g(t, r, o) {
|
|
22
|
+
const e = Array.isArray(t) && typeof r != "function" ? t : i(
|
|
23
|
+
t,
|
|
24
|
+
r,
|
|
25
|
+
o ?? {}
|
|
26
|
+
);
|
|
27
|
+
return (c) => {
|
|
28
|
+
a(c, e, []);
|
|
29
|
+
};
|
|
15
30
|
}
|
|
16
31
|
export {
|
|
17
|
-
|
|
32
|
+
g as getHotkeyHandler,
|
|
33
|
+
F as useHotkey
|
|
18
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(t,r,n)=>{const e=t.target;return e?!!(typeof e.tagName=="string"&&r.includes(e.tagName)||!n&&e.isContentEditable===!0):!1};exports.shouldIgnoreEvent=u;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = (e, r, n) => {
|
|
2
|
+
const t = e.target;
|
|
3
|
+
return t ? !!(typeof t.tagName == "string" && r.includes(t.tagName) || !n && t.isContentEditable === !0) : !1;
|
|
4
|
+
};
|
|
2
5
|
export {
|
|
3
|
-
r as isInputField,
|
|
4
6
|
a as shouldIgnoreEvent
|
|
5
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./is-input-field.cjs.js"),c=require("./match-key-modifiers.cjs.js"),s=(e,n,o)=>{for(const[r,i,t]of n){const u=t?.triggerOnContentEditable??!1;if(a.shouldIgnoreEvent(e,o,u)||!c.matchKeyModifiers(e,r))continue;(t?.preventDefault??!0)&&e.preventDefault(),i(e)}};exports.matchAndRun=s;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { shouldIgnoreEvent as a } from "./is-input-field.es.js";
|
|
2
|
+
import { matchKeyModifiers as l } from "./match-key-modifiers.es.js";
|
|
3
|
+
const s = (t, n, o) => {
|
|
4
|
+
for (const [r, i, e] of n) {
|
|
5
|
+
const f = e?.triggerOnContentEditable ?? !1;
|
|
6
|
+
if (a(t, o, f) || !l(t, r)) continue;
|
|
7
|
+
(e?.preventDefault ?? !0) && t.preventDefault(), i(t);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
s as matchAndRun
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../internal/is-apple-device.cjs.js"),l=t=>{const e=t.toLowerCase().split("+"),i=e.pop()??"",s=e.includes("mod"),o=s&&r.isAppleDevice(),c=s&&!r.isAppleDevice();return{mainKey:i,shift:e.includes("shift"),ctrl:e.includes("ctrl")||c,alt:e.includes("alt"),meta:e.includes("meta")||o}},n=(t,e)=>{const{mainKey:i,shift:s,ctrl:o,alt:c,meta:a}=l(e);return t.key.toLowerCase()===i&&t.shiftKey===s&&t.ctrlKey===o&&t.altKey===c&&t.metaKey===a};exports.getKeyModifiers=l;exports.matchKeyModifiers=n;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { isAppleDevice as r } from "../../internal/is-apple-device.es.js";
|
|
2
|
+
const l = (s) => {
|
|
3
|
+
const t = s.toLowerCase().split("+"), o = t.pop() ?? "", e = t.includes("mod"), c = e && r(), i = e && !r();
|
|
3
4
|
return {
|
|
4
|
-
mainKey:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
mainKey: o,
|
|
6
|
+
shift: t.includes("shift"),
|
|
7
|
+
ctrl: t.includes("ctrl") || i,
|
|
8
|
+
alt: t.includes("alt"),
|
|
9
|
+
meta: t.includes("meta") || c
|
|
9
10
|
};
|
|
10
|
-
},
|
|
11
|
-
const { mainKey:
|
|
12
|
-
return
|
|
11
|
+
}, m = (s, t) => {
|
|
12
|
+
const { mainKey: o, shift: e, ctrl: c, alt: i, meta: a } = l(t);
|
|
13
|
+
return s.key.toLowerCase() === o && s.shiftKey === e && s.ctrlKey === c && s.altKey === i && s.metaKey === a;
|
|
13
14
|
};
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
l as getKeyModifiers,
|
|
17
|
+
m as matchKeyModifiers
|
|
17
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),R=require("../internal/use-latest-ref.cjs.js");function b(T={}){const{openDelay:o=0,closeDelay:a=0,onHoverStart:d,onHoverEnd:p}=T,[E,r]=e.useState(!1),i=R.useLatestRef(d),f=R.useLatestRef(p),t=e.useRef(null),n=e.useRef(null),u=e.useCallback(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),s=e.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null)},[]),L=e.useCallback(l=>{if(!l)return;const v=c=>{s(),o>0?t.current=setTimeout(()=>{t.current=null,r(!0),i.current?.(c)},o):(r(!0),i.current?.(c))},m=c=>{u(),a>0?n.current=setTimeout(()=>{n.current=null,r(!1),f.current?.(c)},a):(r(!1),f.current?.(c))};return l.addEventListener("pointerenter",v),l.addEventListener("pointerleave",m),()=>{l.removeEventListener("pointerenter",v),l.removeEventListener("pointerleave",m),u(),s(),r(!1)}},[o,a,u,s]);return e.useEffect(()=>()=>{u(),s()},[u,s]),{hovered:E,ref:L}}exports.useHover=b;
|
|
@@ -1,20 +1,35 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
t
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { useState as h, useRef as p, useCallback as i, useEffect as S } from "react";
|
|
2
|
+
import { useLatestRef as E } from "../internal/use-latest-ref.es.js";
|
|
3
|
+
function D(T = {}) {
|
|
4
|
+
const { openDelay: c = 0, closeDelay: s = 0, onHoverStart: d, onHoverEnd: L } = T, [R, e] = h(!1), a = E(d), f = E(L), r = p(null), t = p(null), n = i(() => {
|
|
5
|
+
r.current !== null && (clearTimeout(r.current), r.current = null);
|
|
6
|
+
}, []), u = i(() => {
|
|
7
|
+
t.current !== null && (clearTimeout(t.current), t.current = null);
|
|
8
|
+
}, []), H = i(
|
|
9
|
+
(l) => {
|
|
10
|
+
if (!l) return;
|
|
11
|
+
const m = (o) => {
|
|
12
|
+
u(), c > 0 ? r.current = setTimeout(() => {
|
|
13
|
+
r.current = null, e(!0), a.current?.(o);
|
|
14
|
+
}, c) : (e(!0), a.current?.(o));
|
|
15
|
+
}, v = (o) => {
|
|
16
|
+
n(), s > 0 ? t.current = setTimeout(() => {
|
|
17
|
+
t.current = null, e(!1), f.current?.(o);
|
|
18
|
+
}, s) : (e(!1), f.current?.(o));
|
|
19
|
+
};
|
|
20
|
+
return l.addEventListener("pointerenter", m), l.addEventListener("pointerleave", v), () => {
|
|
21
|
+
l.removeEventListener("pointerenter", m), l.removeEventListener("pointerleave", v), n(), u(), e(!1);
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
[c, s, n, u]
|
|
25
|
+
);
|
|
26
|
+
return S(
|
|
27
|
+
() => () => {
|
|
28
|
+
n(), u();
|
|
29
|
+
},
|
|
30
|
+
[n, u]
|
|
31
|
+
), { hovered: R, ref: H };
|
|
17
32
|
}
|
|
18
33
|
export {
|
|
19
|
-
|
|
34
|
+
D as useHover
|
|
20
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),S=require("../internal/is-browser.cjs.js"),h=require("../internal/use-latest-ref.cjs.js");function p(b={}){const{onVisible:g,triggerOnce:n=!1,freezeOnceVisible:i=!1,root:u=null,rootMargin:c="0px",threshold:o=0}=b,f=e.useRef(null),[d,R]=e.useState(!1),[V,I]=e.useState(null),v=h.useLatestRef(g),r=e.useRef(!1);return e.useEffect(()=>{if(!S.isBrowser||typeof IntersectionObserver>"u")return;const l=f.current;if(l==null)return;r.current=!1;const s=new IntersectionObserver(([t])=>{if(r.current||!t)return;const a=t.isIntersecting;I(t),R(O=>i&&O?!0:a),a&&(v.current?.(),n&&(r.current=!0,s.disconnect()))},{root:u,rootMargin:c,threshold:o});return s.observe(l),()=>{r.current||s.disconnect()}},[u,c,o,n,i]),{ref:f,isVisible:d,entry:V}}exports.useIsVisible=p;
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { useRef as b, useState as a, useEffect as R } from "react";
|
|
2
|
+
import { isBrowser as h } from "../internal/is-browser.es.js";
|
|
3
|
+
import { useLatestRef as w } from "../internal/use-latest-ref.es.js";
|
|
4
|
+
function L(g = {}) {
|
|
5
|
+
const {
|
|
6
|
+
onVisible: d,
|
|
7
|
+
triggerOnce: n = !1,
|
|
8
|
+
freezeOnceVisible: s = !1,
|
|
9
|
+
root: i = null,
|
|
10
|
+
rootMargin: o = "0px",
|
|
11
|
+
threshold: c = 0
|
|
12
|
+
} = g, f = b(null), [m, p] = a(!1), [V, I] = a(null), v = w(d), e = b(!1);
|
|
13
|
+
return R(() => {
|
|
14
|
+
if (!h || typeof IntersectionObserver > "u") return;
|
|
15
|
+
const u = f.current;
|
|
16
|
+
if (u == null) return;
|
|
17
|
+
e.current = !1;
|
|
18
|
+
const r = new IntersectionObserver(
|
|
19
|
+
([t]) => {
|
|
20
|
+
if (e.current || !t) return;
|
|
21
|
+
const l = t.isIntersecting;
|
|
22
|
+
I(t), p(
|
|
23
|
+
(O) => s && O ? !0 : l
|
|
24
|
+
), l && (v.current?.(), n && (e.current = !0, r.disconnect()));
|
|
25
|
+
},
|
|
26
|
+
{ root: i, rootMargin: o, threshold: c }
|
|
27
|
+
);
|
|
28
|
+
return r.observe(u), () => {
|
|
29
|
+
e.current || r.disconnect();
|
|
24
30
|
};
|
|
25
|
-
}, [
|
|
26
|
-
r && s?.();
|
|
27
|
-
}, [r]), { ref: e, isVisible: r };
|
|
31
|
+
}, [i, o, c, n, s]), { ref: f, isVisible: m, entry: V };
|
|
28
32
|
}
|
|
29
33
|
export {
|
|
30
|
-
|
|
34
|
+
L as useIsVisible
|
|
31
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),S=require("../internal/is-browser.cjs.js"),m={read:r=>JSON.parse(r),write:r=>JSON.stringify(r)},c=new Map;function g(r){c.get(r)?.forEach(e=>e())}function v(r,e){if(!S.isBrowser)return()=>{};let o=c.get(r);o||(o=new Set,c.set(r,o)),o.add(e);const s=n=>{n.storageArea===localStorage&&(n.key===r||n.key===null)&&e()};return window.addEventListener("storage",s),()=>{o.delete(e),o.size===0&&c.delete(r),window.removeEventListener("storage",s)}}function h(r,e,o={}){const s=o.serializer??m,n=a.useCallback(t=>v(r,t),[r]),f=a.useCallback(()=>{if(!S.isBrowser)return null;try{return localStorage.getItem(r)}catch{return null}},[r]),d=a.useCallback(()=>null,[]),l=a.useSyncExternalStore(n,f,d),u=a.useMemo(()=>{if(l===null)return e;try{return s.read(l)}catch(t){return console.error(`Error parsing localStorage key "${r}":`,t),e}},[l,e,r,s]),b=a.useCallback(t=>{try{const i=typeof t=="function"?t(u):t;localStorage.setItem(r,s.write(i)),g(r)}catch(i){console.error(`Error setting localStorage key "${r}":`,i)}},[r,u,s]),w=a.useCallback(()=>{try{localStorage.removeItem(r),g(r)}catch(t){console.error(`Error removing localStorage key "${r}":`,t)}},[r]);return[u,b,w]}exports.useLocalStorage=h;
|
|
@@ -1,29 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useCallback as a, useSyncExternalStore as p, useMemo as h } from "react";
|
|
2
|
+
import { isBrowser as f } from "../internal/is-browser.es.js";
|
|
3
|
+
const v = {
|
|
4
|
+
read: (r) => JSON.parse(r),
|
|
5
|
+
write: (r) => JSON.stringify(r)
|
|
6
|
+
}, c = /* @__PURE__ */ new Map();
|
|
7
|
+
function g(r) {
|
|
8
|
+
c.get(r)?.forEach((e) => e());
|
|
9
|
+
}
|
|
10
|
+
function E(r, e) {
|
|
11
|
+
if (!f) return () => {
|
|
12
|
+
};
|
|
13
|
+
let o = c.get(r);
|
|
14
|
+
o || (o = /* @__PURE__ */ new Set(), c.set(r, o)), o.add(e);
|
|
15
|
+
const n = (s) => {
|
|
16
|
+
s.storageArea === localStorage && (s.key === r || s.key === null) && e();
|
|
17
|
+
};
|
|
18
|
+
return window.addEventListener("storage", n), () => {
|
|
19
|
+
o.delete(e), o.size === 0 && c.delete(r), window.removeEventListener("storage", n);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function I(r, e, o = {}) {
|
|
23
|
+
const n = o.serializer ?? v, s = a(
|
|
24
|
+
(t) => E(r, t),
|
|
25
|
+
[r]
|
|
26
|
+
), S = a(() => {
|
|
27
|
+
if (!f) return null;
|
|
4
28
|
try {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return console.error(`Error parsing localStorage key "${o}":`, r), e !== void 0 ? e : void 0;
|
|
29
|
+
return localStorage.getItem(r);
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
9
32
|
}
|
|
10
|
-
}, [
|
|
11
|
-
|
|
33
|
+
}, [r]), d = a(() => null, []), l = p(s, S, d), i = h(() => {
|
|
34
|
+
if (l === null) return e;
|
|
12
35
|
try {
|
|
13
|
-
|
|
14
|
-
} catch (
|
|
15
|
-
console.error(`Error
|
|
36
|
+
return n.read(l);
|
|
37
|
+
} catch (t) {
|
|
38
|
+
return console.error(`Error parsing localStorage key "${r}":`, t), e;
|
|
16
39
|
}
|
|
17
|
-
}, [
|
|
18
|
-
|
|
19
|
-
|
|
40
|
+
}, [l, e, r, n]), m = a(
|
|
41
|
+
(t) => {
|
|
42
|
+
try {
|
|
43
|
+
const u = typeof t == "function" ? t(i) : t;
|
|
44
|
+
localStorage.setItem(r, n.write(u)), g(r);
|
|
45
|
+
} catch (u) {
|
|
46
|
+
console.error(`Error setting localStorage key "${r}":`, u);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
[r, i, n]
|
|
50
|
+
), w = a(() => {
|
|
20
51
|
try {
|
|
21
|
-
localStorage.removeItem(
|
|
22
|
-
} catch (
|
|
23
|
-
console.error(`Error removing localStorage key "${
|
|
52
|
+
localStorage.removeItem(r), g(r);
|
|
53
|
+
} catch (t) {
|
|
54
|
+
console.error(`Error removing localStorage key "${r}":`, t);
|
|
24
55
|
}
|
|
25
|
-
}];
|
|
56
|
+
}, [r]);
|
|
57
|
+
return [i, m, w];
|
|
26
58
|
}
|
|
27
59
|
export {
|
|
28
|
-
|
|
60
|
+
I as useLocalStorage
|
|
29
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),d=require("../internal/is-browser.cjs.js");function c(){return d.isBrowser&&typeof window.matchMedia=="function"}function l(e,s={}){const{defaultValue:t=!1}=s,o=n.useCallback(r=>{if(!c())return()=>{};const a=window.matchMedia(e);return a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[e]),i=n.useCallback(()=>c()?window.matchMedia(e).matches:t,[e,t]),u=n.useCallback(()=>t,[t]);return n.useSyncExternalStore(o,i,u)}exports.useMediaQuery=l;
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
1
|
+
import { useCallback as n, useSyncExternalStore as d } from "react";
|
|
2
|
+
import { isBrowser as f } from "../internal/is-browser.es.js";
|
|
3
|
+
function a() {
|
|
4
|
+
return f && typeof window.matchMedia == "function";
|
|
5
|
+
}
|
|
6
|
+
function w(e, c = {}) {
|
|
7
|
+
const { defaultValue: t = !1 } = c, i = n(
|
|
8
|
+
(r) => {
|
|
9
|
+
if (!a()) return () => {
|
|
10
|
+
};
|
|
11
|
+
const o = window.matchMedia(e);
|
|
12
|
+
return o.addEventListener("change", r), () => o.removeEventListener("change", r);
|
|
13
|
+
},
|
|
14
|
+
[e]
|
|
15
|
+
), s = n(() => a() ? window.matchMedia(e).matches : t, [e, t]), u = n(
|
|
16
|
+
() => t,
|
|
17
|
+
[t]
|
|
18
|
+
);
|
|
19
|
+
return d(i, s, u);
|
|
20
|
+
}
|
|
11
21
|
export {
|
|
12
|
-
|
|
22
|
+
w as useMediaQuery
|
|
13
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),c=require("../internal/use-latest-ref.cjs.js"),k=s=>{const[u,l]=t.useState("idle"),[y,a]=t.useState(null),[L,o]=t.useState(null),d=c.useLatestRef(s.fn),R=c.useLatestRef(s.onMutate),i=c.useLatestRef(s.onSuccess),S=c.useLatestRef(s.onError),g=c.useLatestRef(s.onSettled),f=t.useCallback(async e=>{R.current?.(e),l("pending"),a(null),o(null);let n=null,r=null;try{return n=await d.current(e),a(n),l("success"),i.current?.(n,e),n}catch(E){throw r=E,o(r),l("error"),S.current?.(r,e),r}finally{g.current?.(n,r,e)}},[d,R,i,S,g]),M=t.useCallback(e=>{f(e).catch(()=>{})},[f]),h=t.useCallback(()=>{l("idle"),a(null),o(null)},[]);return{mutate:M,mutateAsync:f,reset:h,data:y,error:L,status:u,isIdle:u==="idle",isPending:u==="pending",isSuccess:u==="success",isError:u==="error"}};exports.useMutation=k;
|