@react-aria/utils 3.31.0 → 3.33.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/dist/DOMFunctions.main.js +1 -1
- package/dist/DOMFunctions.main.js.map +1 -1
- package/dist/DOMFunctions.mjs +1 -1
- package/dist/DOMFunctions.module.js +1 -1
- package/dist/DOMFunctions.module.js.map +1 -1
- package/dist/domHelpers.main.js.map +1 -1
- package/dist/domHelpers.module.js.map +1 -1
- package/dist/filterDOMProps.main.js +1 -1
- package/dist/filterDOMProps.main.js.map +1 -1
- package/dist/filterDOMProps.mjs +1 -1
- package/dist/filterDOMProps.module.js +1 -1
- package/dist/filterDOMProps.module.js.map +1 -1
- package/dist/mergeProps.main.js +3 -0
- package/dist/mergeProps.main.js.map +1 -1
- package/dist/mergeProps.mjs +3 -0
- package/dist/mergeProps.module.js +3 -0
- package/dist/mergeProps.module.js.map +1 -1
- package/dist/openLink.main.js +1 -0
- package/dist/openLink.main.js.map +1 -1
- package/dist/openLink.mjs +1 -0
- package/dist/openLink.module.js +1 -0
- package/dist/openLink.module.js.map +1 -1
- package/dist/scrollIntoView.main.js +13 -38
- package/dist/scrollIntoView.main.js.map +1 -1
- package/dist/scrollIntoView.mjs +13 -38
- package/dist/scrollIntoView.module.js +13 -38
- package/dist/scrollIntoView.module.js.map +1 -1
- package/dist/types.d.ts +8 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/useDrag1D.main.js +3 -1
- package/dist/useDrag1D.main.js.map +1 -1
- package/dist/useDrag1D.mjs +3 -1
- package/dist/useDrag1D.module.js +3 -1
- package/dist/useDrag1D.module.js.map +1 -1
- package/dist/useEvent.main.js +1 -2
- package/dist/useEvent.main.js.map +1 -1
- package/dist/useEvent.mjs +1 -2
- package/dist/useEvent.module.js +1 -2
- package/dist/useEvent.module.js.map +1 -1
- package/dist/useFormReset.main.js +1 -2
- package/dist/useFormReset.main.js.map +1 -1
- package/dist/useFormReset.mjs +1 -2
- package/dist/useFormReset.module.js +1 -2
- package/dist/useFormReset.module.js.map +1 -1
- package/dist/useLoadMoreSentinel.main.js +0 -1
- package/dist/useLoadMoreSentinel.main.js.map +1 -1
- package/dist/useLoadMoreSentinel.mjs +0 -1
- package/dist/useLoadMoreSentinel.module.js +0 -1
- package/dist/useLoadMoreSentinel.module.js.map +1 -1
- package/dist/useResizeObserver.main.js +8 -4
- package/dist/useResizeObserver.main.js.map +1 -1
- package/dist/useResizeObserver.mjs +8 -4
- package/dist/useResizeObserver.module.js +8 -4
- package/dist/useResizeObserver.module.js.map +1 -1
- package/dist/useUpdateEffect.main.js +5 -2
- package/dist/useUpdateEffect.main.js.map +1 -1
- package/dist/useUpdateEffect.mjs +5 -2
- package/dist/useUpdateEffect.module.js +5 -2
- package/dist/useUpdateEffect.module.js.map +1 -1
- package/dist/useValueEffect.main.js +13 -8
- package/dist/useValueEffect.main.js.map +1 -1
- package/dist/useValueEffect.mjs +14 -9
- package/dist/useValueEffect.module.js +14 -9
- package/dist/useValueEffect.module.js.map +1 -1
- package/dist/useViewportSize.main.js +13 -14
- package/dist/useViewportSize.main.js.map +1 -1
- package/dist/useViewportSize.mjs +13 -14
- package/dist/useViewportSize.module.js +13 -14
- package/dist/useViewportSize.module.js.map +1 -1
- package/package.json +4 -4
- package/src/domHelpers.ts +2 -2
- package/src/filterDOMProps.ts +1 -1
- package/src/mergeProps.ts +4 -2
- package/src/openLink.tsx +1 -1
- package/src/scrollIntoView.ts +19 -49
- package/src/shadowdom/DOMFunctions.ts +1 -0
- package/src/useDrag1D.ts +2 -1
- package/src/useEvent.ts +1 -1
- package/src/useFormReset.ts +1 -1
- package/src/useLoadMoreSentinel.ts +1 -1
- package/src/useResizeObserver.ts +8 -4
- package/src/useUpdateEffect.ts +5 -3
- package/src/useValueEffect.ts +15 -11
- package/src/useViewportSize.ts +15 -16
package/dist/useEvent.main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAAkC,EAClC,KAAwB,EACxB,OAAqE,EACrE,OAA2C;IAE3C,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;IACjC,IAAI,aAAa,WAAW;IAE5B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,cAAc,CAAC,IAAI,OAAO,EAC5B;QAGF,IAAI,UAAU,IAAI,OAAO;QACzB,QAAQ,gBAAgB,CAAC,OAAO,aAA8B;QAC9D,OAAO;YACL,QAAQ,mBAAmB,CAAC,OAAO,aAA8B;QACnE;IACF,GAAG;QAAC;QAAK;QAAO;QAAS;
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAAkC,EAClC,KAAwB,EACxB,OAAqE,EACrE,OAA2C;IAE3C,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;IACjC,IAAI,aAAa,WAAW;IAE5B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,cAAc,CAAC,IAAI,OAAO,EAC5B;QAGF,IAAI,UAAU,IAAI,OAAO;QACzB,QAAQ,gBAAgB,CAAC,OAAO,aAA8B;QAC9D,OAAO;YACL,QAAQ,mBAAmB,CAAC,OAAO,aAA8B;QACnE;IACF,GAAG;QAAC;QAAK;QAAO;QAAS;KAAW;AACtC","sources":["packages/@react-aria/utils/src/useEvent.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useEvent<K extends keyof GlobalEventHandlersEventMap>(\n ref: RefObject<EventTarget | null>,\n event: K | (string & {}),\n handler?: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n): void {\n let handleEvent = useEffectEvent(handler);\n let isDisabled = handler == null;\n\n useEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n\n let element = ref.current;\n element.addEventListener(event, handleEvent as EventListener, options);\n return () => {\n element.removeEventListener(event, handleEvent as EventListener, options);\n };\n }, [ref, event, options, isDisabled]);\n}\n"],"names":[],"version":3,"file":"useEvent.main.js.map"}
|
package/dist/useEvent.mjs
CHANGED
package/dist/useEvent.module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAAkC,EAClC,KAAwB,EACxB,OAAqE,EACrE,OAA2C;IAE3C,IAAI,cAAc,CAAA,GAAA,yCAAa,EAAE;IACjC,IAAI,aAAa,WAAW;IAE5B,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,cAAc,CAAC,IAAI,OAAO,EAC5B;QAGF,IAAI,UAAU,IAAI,OAAO;QACzB,QAAQ,gBAAgB,CAAC,OAAO,aAA8B;QAC9D,OAAO;YACL,QAAQ,mBAAmB,CAAC,OAAO,aAA8B;QACnE;IACF,GAAG;QAAC;QAAK;QAAO;QAAS;
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAAkC,EAClC,KAAwB,EACxB,OAAqE,EACrE,OAA2C;IAE3C,IAAI,cAAc,CAAA,GAAA,yCAAa,EAAE;IACjC,IAAI,aAAa,WAAW;IAE5B,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,cAAc,CAAC,IAAI,OAAO,EAC5B;QAGF,IAAI,UAAU,IAAI,OAAO;QACzB,QAAQ,gBAAgB,CAAC,OAAO,aAA8B;QAC9D,OAAO;YACL,QAAQ,mBAAmB,CAAC,OAAO,aAA8B;QACnE;IACF,GAAG;QAAC;QAAK;QAAO;QAAS;KAAW;AACtC","sources":["packages/@react-aria/utils/src/useEvent.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useEvent<K extends keyof GlobalEventHandlersEventMap>(\n ref: RefObject<EventTarget | null>,\n event: K | (string & {}),\n handler?: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n): void {\n let handleEvent = useEffectEvent(handler);\n let isDisabled = handler == null;\n\n useEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n\n let element = ref.current;\n element.addEventListener(event, handleEvent as EventListener, options);\n return () => {\n element.removeEventListener(event, handleEvent as EventListener, options);\n };\n }, [ref, event, options, isDisabled]);\n}\n"],"names":[],"version":3,"file":"useEvent.module.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAA6F,EAC7F,YAAe,EACf,OAA2B;IAE3B,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,IAAI,SACF,QAAQ;IAEZ;IAEA,CAAA,GAAA,sBAAQ,EAAE;YACG;QAAX,IAAI,OAAO,gBAAA,2BAAA,eAAA,IAAK,OAAO,cAAZ,mCAAA,aAAc,IAAI;QAE7B,iBAAA,2BAAA,KAAM,gBAAgB,CAAC,SAAS;QAChC,OAAO;YACL,iBAAA,2BAAA,KAAM,mBAAmB,CAAC,SAAS;QACrC;IACF,GAAG;QAAC;
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAA6F,EAC7F,YAAe,EACf,OAA2B;IAE3B,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,IAAI,SACF,QAAQ;IAEZ;IAEA,CAAA,GAAA,sBAAQ,EAAE;YACG;QAAX,IAAI,OAAO,gBAAA,2BAAA,eAAA,IAAK,OAAO,cAAZ,mCAAA,aAAc,IAAI;QAE7B,iBAAA,2BAAA,KAAM,gBAAgB,CAAC,SAAS;QAChC,OAAO;YACL,iBAAA,2BAAA,KAAM,mBAAmB,CAAC,SAAS;QACrC;IACF,GAAG;QAAC;KAAI;AACV","sources":["packages/@react-aria/utils/src/useFormReset.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useFormReset<T>(\n ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined,\n initialValue: T,\n onReset: (value: T) => void\n): void {\n let handleReset = useEffectEvent(() => {\n if (onReset) {\n onReset(initialValue);\n }\n });\n\n useEffect(() => {\n let form = ref?.current?.form;\n\n form?.addEventListener('reset', handleReset);\n return () => {\n form?.removeEventListener('reset', handleReset);\n };\n }, [ref]);\n}\n"],"names":[],"version":3,"file":"useFormReset.main.js.map"}
|
package/dist/useFormReset.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAA6F,EAC7F,YAAe,EACf,OAA2B;IAE3B,IAAI,cAAc,CAAA,GAAA,yCAAa,EAAE;QAC/B,IAAI,SACF,QAAQ;IAEZ;IAEA,CAAA,GAAA,gBAAQ,EAAE;YACG;QAAX,IAAI,OAAO,gBAAA,2BAAA,eAAA,IAAK,OAAO,cAAZ,mCAAA,aAAc,IAAI;QAE7B,iBAAA,2BAAA,KAAM,gBAAgB,CAAC,SAAS;QAChC,OAAO;YACL,iBAAA,2BAAA,KAAM,mBAAmB,CAAC,SAAS;QACrC;IACF,GAAG;QAAC;
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAA6F,EAC7F,YAAe,EACf,OAA2B;IAE3B,IAAI,cAAc,CAAA,GAAA,yCAAa,EAAE;QAC/B,IAAI,SACF,QAAQ;IAEZ;IAEA,CAAA,GAAA,gBAAQ,EAAE;YACG;QAAX,IAAI,OAAO,gBAAA,2BAAA,eAAA,IAAK,OAAO,cAAZ,mCAAA,aAAc,IAAI;QAE7B,iBAAA,2BAAA,KAAM,gBAAgB,CAAC,SAAS;QAChC,OAAO;YACL,iBAAA,2BAAA,KAAM,mBAAmB,CAAC,SAAS;QACrC;IACF,GAAG;QAAC;KAAI;AACV","sources":["packages/@react-aria/utils/src/useFormReset.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useFormReset<T>(\n ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined,\n initialValue: T,\n onReset: (value: T) => void\n): void {\n let handleReset = useEffectEvent(() => {\n if (onReset) {\n onReset(initialValue);\n }\n });\n\n useEffect(() => {\n let form = ref?.current?.form;\n\n form?.addEventListener('reset', handleReset);\n return () => {\n form?.removeEventListener('reset', handleReset);\n };\n }, [ref]);\n}\n"],"names":[],"version":3,"file":"useFormReset.module.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAoBM,SAAS,0CAAoB,KAA4B,EAAE,GAAkC;IAClG,IAAI,cAAC,UAAU,cAAE,UAAU,gBAAE,eAAe,GAAE,GAAG;IAEjD,IAAI,mBAAmB,CAAA,GAAA,mBAAK,EAAwB;IAEpD,IAAI,kBAAkB,CAAA,GAAA,wCAAa,EAAE,CAAC;QACpC,4FAA4F;QAC5F,iFAAiF;QACjF,KAAK,IAAI,SAAS,QAChB,yHAAyH;QACzH,4EAA4E;QAC5E,IAAI,MAAM,cAAc,IAAI,YAC1B;IAGN;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,IAAI,OAAO,EAAE;YACf,mKAAmK;YACnK,0MAA0M;YAC1M,yFAAyF;YACzF,iBAAiB,OAAO,GAAG,IAAI,qBAAqB,iBAAiB;gBAAC,MAAM,CAAA,GAAA,yCAAc,EAAE,gBAAA,0BAAA,IAAK,OAAO;gBAAkB,YAAY,CAAC,IAAI,EAAE,MAAM,aAAa,EAAE,EAAE,MAAM,aAAa,EAAE,EAAE,MAAM,aAAa,CAAC,CAAC;YAAA;YAChN,iBAAiB,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO;QAC9C;QAEA,OAAO;YACL,IAAI,iBAAiB,OAAO,EAC1B,iBAAiB,OAAO,CAAC,UAAU;QAEvC;IACF,GAAG;QAAC;QAAY;
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAoBM,SAAS,0CAAoB,KAA4B,EAAE,GAAkC;IAClG,IAAI,cAAC,UAAU,cAAE,UAAU,gBAAE,eAAe,GAAE,GAAG;IAEjD,IAAI,mBAAmB,CAAA,GAAA,mBAAK,EAAwB;IAEpD,IAAI,kBAAkB,CAAA,GAAA,wCAAa,EAAE,CAAC;QACpC,4FAA4F;QAC5F,iFAAiF;QACjF,KAAK,IAAI,SAAS,QAChB,yHAAyH;QACzH,4EAA4E;QAC5E,IAAI,MAAM,cAAc,IAAI,YAC1B;IAGN;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,IAAI,OAAO,EAAE;YACf,mKAAmK;YACnK,0MAA0M;YAC1M,yFAAyF;YACzF,iBAAiB,OAAO,GAAG,IAAI,qBAAqB,iBAAiB;gBAAC,MAAM,CAAA,GAAA,yCAAc,EAAE,gBAAA,0BAAA,IAAK,OAAO;gBAAkB,YAAY,CAAC,IAAI,EAAE,MAAM,aAAa,EAAE,EAAE,MAAM,aAAa,EAAE,EAAE,MAAM,aAAa,CAAC,CAAC;YAAA;YAChN,iBAAiB,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO;QAC9C;QAEA,OAAO;YACL,IAAI,iBAAiB,OAAO,EAC1B,iBAAiB,OAAO,CAAC,UAAU;QAEvC;IACF,GAAG;QAAC;QAAY;QAAK;KAAa;AACpC","sources":["packages/@react-aria/utils/src/useLoadMoreSentinel.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type {AsyncLoadable, Collection} from '@react-types/shared';\nimport {getScrollParent} from './getScrollParent';\nimport {RefObject, useRef} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport interface LoadMoreSentinelProps extends Omit<AsyncLoadable, 'isLoading'> {\n collection: Collection<any>,\n /**\n * The amount of offset from the bottom of your scrollable region that should trigger load more.\n * Uses a percentage value relative to the scroll body's client height. Load more is then triggered\n * when your current scroll position's distance from the bottom of the currently loaded list of items is less than\n * or equal to the provided value. (e.g. 1 = 100% of the scroll region's height).\n * @default 1\n */\n scrollOffset?: number\n}\n\nexport function useLoadMoreSentinel(props: LoadMoreSentinelProps, ref: RefObject<HTMLElement | null>): void {\n let {collection, onLoadMore, scrollOffset = 1} = props;\n\n let sentinelObserver = useRef<IntersectionObserver>(null);\n\n let triggerLoadMore = useEffectEvent((entries: IntersectionObserverEntry[]) => {\n // Use \"isIntersecting\" over an equality check of 0 since it seems like there is cases where\n // a intersection ratio of 0 can be reported when isIntersecting is actually true\n for (let entry of entries) {\n // Note that this will be called if the collection changes, even if onLoadMore was already called and is being processed.\n // Up to user discretion as to how to handle these multiple onLoadMore calls\n if (entry.isIntersecting && onLoadMore) {\n onLoadMore();\n }\n }\n });\n\n useLayoutEffect(() => {\n if (ref.current) {\n // Tear down and set up a new IntersectionObserver when the collection changes so that we can properly trigger additional loadMores if there is room for more items\n // Need to do this tear down and set up since using a large rootMargin will mean the observer's callback isn't called even when scrolling the item into view beause its visibility hasn't actually changed\n // https://codesandbox.io/p/sandbox/magical-swanson-dhgp89?file=%2Fsrc%2FApp.js%3A21%2C21\n sentinelObserver.current = new IntersectionObserver(triggerLoadMore, {root: getScrollParent(ref?.current) as HTMLElement, rootMargin: `0px ${100 * scrollOffset}% ${100 * scrollOffset}% ${100 * scrollOffset}%`});\n sentinelObserver.current.observe(ref.current);\n }\n\n return () => {\n if (sentinelObserver.current) {\n sentinelObserver.current.disconnect();\n }\n };\n }, [collection, ref, scrollOffset]);\n}\n"],"names":[],"version":3,"file":"useLoadMoreSentinel.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAoBM,SAAS,0CAAoB,KAA4B,EAAE,GAAkC;IAClG,IAAI,cAAC,UAAU,cAAE,UAAU,gBAAE,eAAe,GAAE,GAAG;IAEjD,IAAI,mBAAmB,CAAA,GAAA,aAAK,EAAwB;IAEpD,IAAI,kBAAkB,CAAA,GAAA,yCAAa,EAAE,CAAC;QACpC,4FAA4F;QAC5F,iFAAiF;QACjF,KAAK,IAAI,SAAS,QAChB,yHAAyH;QACzH,4EAA4E;QAC5E,IAAI,MAAM,cAAc,IAAI,YAC1B;IAGN;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,IAAI,OAAO,EAAE;YACf,mKAAmK;YACnK,0MAA0M;YAC1M,yFAAyF;YACzF,iBAAiB,OAAO,GAAG,IAAI,qBAAqB,iBAAiB;gBAAC,MAAM,CAAA,GAAA,yCAAc,EAAE,gBAAA,0BAAA,IAAK,OAAO;gBAAkB,YAAY,CAAC,IAAI,EAAE,MAAM,aAAa,EAAE,EAAE,MAAM,aAAa,EAAE,EAAE,MAAM,aAAa,CAAC,CAAC;YAAA;YAChN,iBAAiB,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO;QAC9C;QAEA,OAAO;YACL,IAAI,iBAAiB,OAAO,EAC1B,iBAAiB,OAAO,CAAC,UAAU;QAEvC;IACF,GAAG;QAAC;QAAY;
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAoBM,SAAS,0CAAoB,KAA4B,EAAE,GAAkC;IAClG,IAAI,cAAC,UAAU,cAAE,UAAU,gBAAE,eAAe,GAAE,GAAG;IAEjD,IAAI,mBAAmB,CAAA,GAAA,aAAK,EAAwB;IAEpD,IAAI,kBAAkB,CAAA,GAAA,yCAAa,EAAE,CAAC;QACpC,4FAA4F;QAC5F,iFAAiF;QACjF,KAAK,IAAI,SAAS,QAChB,yHAAyH;QACzH,4EAA4E;QAC5E,IAAI,MAAM,cAAc,IAAI,YAC1B;IAGN;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,IAAI,OAAO,EAAE;YACf,mKAAmK;YACnK,0MAA0M;YAC1M,yFAAyF;YACzF,iBAAiB,OAAO,GAAG,IAAI,qBAAqB,iBAAiB;gBAAC,MAAM,CAAA,GAAA,yCAAc,EAAE,gBAAA,0BAAA,IAAK,OAAO;gBAAkB,YAAY,CAAC,IAAI,EAAE,MAAM,aAAa,EAAE,EAAE,MAAM,aAAa,EAAE,EAAE,MAAM,aAAa,CAAC,CAAC;YAAA;YAChN,iBAAiB,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO;QAC9C;QAEA,OAAO;YACL,IAAI,iBAAiB,OAAO,EAC1B,iBAAiB,OAAO,CAAC,UAAU;QAEvC;IACF,GAAG;QAAC;QAAY;QAAK;KAAa;AACpC","sources":["packages/@react-aria/utils/src/useLoadMoreSentinel.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type {AsyncLoadable, Collection} from '@react-types/shared';\nimport {getScrollParent} from './getScrollParent';\nimport {RefObject, useRef} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport interface LoadMoreSentinelProps extends Omit<AsyncLoadable, 'isLoading'> {\n collection: Collection<any>,\n /**\n * The amount of offset from the bottom of your scrollable region that should trigger load more.\n * Uses a percentage value relative to the scroll body's client height. Load more is then triggered\n * when your current scroll position's distance from the bottom of the currently loaded list of items is less than\n * or equal to the provided value. (e.g. 1 = 100% of the scroll region's height).\n * @default 1\n */\n scrollOffset?: number\n}\n\nexport function useLoadMoreSentinel(props: LoadMoreSentinelProps, ref: RefObject<HTMLElement | null>): void {\n let {collection, onLoadMore, scrollOffset = 1} = props;\n\n let sentinelObserver = useRef<IntersectionObserver>(null);\n\n let triggerLoadMore = useEffectEvent((entries: IntersectionObserverEntry[]) => {\n // Use \"isIntersecting\" over an equality check of 0 since it seems like there is cases where\n // a intersection ratio of 0 can be reported when isIntersecting is actually true\n for (let entry of entries) {\n // Note that this will be called if the collection changes, even if onLoadMore was already called and is being processed.\n // Up to user discretion as to how to handle these multiple onLoadMore calls\n if (entry.isIntersecting && onLoadMore) {\n onLoadMore();\n }\n }\n });\n\n useLayoutEffect(() => {\n if (ref.current) {\n // Tear down and set up a new IntersectionObserver when the collection changes so that we can properly trigger additional loadMores if there is room for more items\n // Need to do this tear down and set up since using a large rootMargin will mean the observer's callback isn't called even when scrolling the item into view beause its visibility hasn't actually changed\n // https://codesandbox.io/p/sandbox/magical-swanson-dhgp89?file=%2Fsrc%2FApp.js%3A21%2C21\n sentinelObserver.current = new IntersectionObserver(triggerLoadMore, {root: getScrollParent(ref?.current) as HTMLElement, rootMargin: `0px ${100 * scrollOffset}% ${100 * scrollOffset}% ${100 * scrollOffset}%`});\n sentinelObserver.current.observe(ref.current);\n }\n\n return () => {\n if (sentinelObserver.current) {\n sentinelObserver.current.disconnect();\n }\n };\n }, [collection, ref, scrollOffset]);\n}\n"],"names":[],"version":3,"file":"useLoadMoreSentinel.module.js.map"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var $1254e5bb94ac8761$exports = require("./useEffectEvent.main.js");
|
|
1
2
|
var $aM4zL$react = require("react");
|
|
2
3
|
|
|
3
4
|
|
|
@@ -7,23 +8,27 @@ function $parcel$export(e, n, v, s) {
|
|
|
7
8
|
|
|
8
9
|
$parcel$export(module.exports, "useResizeObserver", () => $37733e1652f47193$export$683480f191c0e3ea);
|
|
9
10
|
|
|
11
|
+
|
|
10
12
|
function $37733e1652f47193$var$hasResizeObserver() {
|
|
11
13
|
return typeof window.ResizeObserver !== 'undefined';
|
|
12
14
|
}
|
|
13
15
|
function $37733e1652f47193$export$683480f191c0e3ea(options) {
|
|
16
|
+
// Only call onResize from inside the effect, otherwise we'll void our assumption that
|
|
17
|
+
// useEffectEvents are safe to pass in.
|
|
14
18
|
const { ref: ref, box: box, onResize: onResize } = options;
|
|
19
|
+
let onResizeEvent = (0, $1254e5bb94ac8761$exports.useEffectEvent)(onResize);
|
|
15
20
|
(0, $aM4zL$react.useEffect)(()=>{
|
|
16
21
|
let element = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
17
22
|
if (!element) return;
|
|
18
23
|
if (!$37733e1652f47193$var$hasResizeObserver()) {
|
|
19
|
-
window.addEventListener('resize',
|
|
24
|
+
window.addEventListener('resize', onResizeEvent, false);
|
|
20
25
|
return ()=>{
|
|
21
|
-
window.removeEventListener('resize',
|
|
26
|
+
window.removeEventListener('resize', onResizeEvent, false);
|
|
22
27
|
};
|
|
23
28
|
} else {
|
|
24
29
|
const resizeObserverInstance = new window.ResizeObserver((entries)=>{
|
|
25
30
|
if (!entries.length) return;
|
|
26
|
-
|
|
31
|
+
onResizeEvent();
|
|
27
32
|
});
|
|
28
33
|
resizeObserverInstance.observe(element, {
|
|
29
34
|
box: box
|
|
@@ -33,7 +38,6 @@ function $37733e1652f47193$export$683480f191c0e3ea(options) {
|
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
40
|
}, [
|
|
36
|
-
onResize,
|
|
37
41
|
ref,
|
|
38
42
|
box
|
|
39
43
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAKA,SAAS;IACP,OAAO,OAAO,OAAO,cAAc,KAAK;AAC1C;AAQO,SAAS,0CAAqC,OAAwC;IAC3F,sFAAsF;IACtF,uCAAuC;IACvC,MAAM,OAAC,GAAG,OAAE,GAAG,YAAE,QAAQ,EAAC,GAAG;IAC7B,IAAI,gBAAgB,CAAA,GAAA,wCAAa,EAAE;IAEnC,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,UAAU,gBAAA,0BAAA,IAAK,OAAO;QAC1B,IAAI,CAAC,SACH;QAGF,IAAI,CAAC,2CAAqB;YACxB,OAAO,gBAAgB,CAAC,UAAU,eAAe;YACjD,OAAO;gBACL,OAAO,mBAAmB,CAAC,UAAU,eAAe;YACtD;QACF,OAAO;YAEL,MAAM,yBAAyB,IAAI,OAAO,cAAc,CAAC,CAAC;gBACxD,IAAI,CAAC,QAAQ,MAAM,EACjB;gBAGF;YACF;YACA,uBAAuB,OAAO,CAAC,SAAS;qBAAC;YAAG;YAE5C,OAAO;gBACL,IAAI,SACF,uBAAuB,SAAS,CAAC;YAErC;QACF;IAEF,GAAG;QAAC;QAAK;KAAI;AACf","sources":["packages/@react-aria/utils/src/useResizeObserver.ts"],"sourcesContent":["\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nfunction hasResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n}\n\ntype useResizeObserverOptionsType<T> = {\n ref: RefObject<T | undefined | null> | undefined,\n box?: ResizeObserverBoxOptions,\n onResize: () => void\n}\n\nexport function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>): void {\n // Only call onResize from inside the effect, otherwise we'll void our assumption that\n // useEffectEvents are safe to pass in.\n const {ref, box, onResize} = options;\n let onResizeEvent = useEffectEvent(onResize);\n\n useEffect(() => {\n let element = ref?.current;\n if (!element) {\n return;\n }\n\n if (!hasResizeObserver()) {\n window.addEventListener('resize', onResizeEvent, false);\n return () => {\n window.removeEventListener('resize', onResizeEvent, false);\n };\n } else {\n\n const resizeObserverInstance = new window.ResizeObserver((entries) => {\n if (!entries.length) {\n return;\n }\n\n onResizeEvent();\n });\n resizeObserverInstance.observe(element, {box});\n\n return () => {\n if (element) {\n resizeObserverInstance.unobserve(element);\n }\n };\n }\n\n }, [ref, box]);\n}\n"],"names":[],"version":3,"file":"useResizeObserver.main.js.map"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
+
import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.mjs";
|
|
1
2
|
import {useEffect as $Vsl8o$useEffect} from "react";
|
|
2
3
|
|
|
3
4
|
|
|
5
|
+
|
|
4
6
|
function $9daab02d461809db$var$hasResizeObserver() {
|
|
5
7
|
return typeof window.ResizeObserver !== 'undefined';
|
|
6
8
|
}
|
|
7
9
|
function $9daab02d461809db$export$683480f191c0e3ea(options) {
|
|
10
|
+
// Only call onResize from inside the effect, otherwise we'll void our assumption that
|
|
11
|
+
// useEffectEvents are safe to pass in.
|
|
8
12
|
const { ref: ref, box: box, onResize: onResize } = options;
|
|
13
|
+
let onResizeEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(onResize);
|
|
9
14
|
(0, $Vsl8o$useEffect)(()=>{
|
|
10
15
|
let element = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
11
16
|
if (!element) return;
|
|
12
17
|
if (!$9daab02d461809db$var$hasResizeObserver()) {
|
|
13
|
-
window.addEventListener('resize',
|
|
18
|
+
window.addEventListener('resize', onResizeEvent, false);
|
|
14
19
|
return ()=>{
|
|
15
|
-
window.removeEventListener('resize',
|
|
20
|
+
window.removeEventListener('resize', onResizeEvent, false);
|
|
16
21
|
};
|
|
17
22
|
} else {
|
|
18
23
|
const resizeObserverInstance = new window.ResizeObserver((entries)=>{
|
|
19
24
|
if (!entries.length) return;
|
|
20
|
-
|
|
25
|
+
onResizeEvent();
|
|
21
26
|
});
|
|
22
27
|
resizeObserverInstance.observe(element, {
|
|
23
28
|
box: box
|
|
@@ -27,7 +32,6 @@ function $9daab02d461809db$export$683480f191c0e3ea(options) {
|
|
|
27
32
|
};
|
|
28
33
|
}
|
|
29
34
|
}, [
|
|
30
|
-
onResize,
|
|
31
35
|
ref,
|
|
32
36
|
box
|
|
33
37
|
]);
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
+
import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.module.js";
|
|
1
2
|
import {useEffect as $Vsl8o$useEffect} from "react";
|
|
2
3
|
|
|
3
4
|
|
|
5
|
+
|
|
4
6
|
function $9daab02d461809db$var$hasResizeObserver() {
|
|
5
7
|
return typeof window.ResizeObserver !== 'undefined';
|
|
6
8
|
}
|
|
7
9
|
function $9daab02d461809db$export$683480f191c0e3ea(options) {
|
|
10
|
+
// Only call onResize from inside the effect, otherwise we'll void our assumption that
|
|
11
|
+
// useEffectEvents are safe to pass in.
|
|
8
12
|
const { ref: ref, box: box, onResize: onResize } = options;
|
|
13
|
+
let onResizeEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(onResize);
|
|
9
14
|
(0, $Vsl8o$useEffect)(()=>{
|
|
10
15
|
let element = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
11
16
|
if (!element) return;
|
|
12
17
|
if (!$9daab02d461809db$var$hasResizeObserver()) {
|
|
13
|
-
window.addEventListener('resize',
|
|
18
|
+
window.addEventListener('resize', onResizeEvent, false);
|
|
14
19
|
return ()=>{
|
|
15
|
-
window.removeEventListener('resize',
|
|
20
|
+
window.removeEventListener('resize', onResizeEvent, false);
|
|
16
21
|
};
|
|
17
22
|
} else {
|
|
18
23
|
const resizeObserverInstance = new window.ResizeObserver((entries)=>{
|
|
19
24
|
if (!entries.length) return;
|
|
20
|
-
|
|
25
|
+
onResizeEvent();
|
|
21
26
|
});
|
|
22
27
|
resizeObserverInstance.observe(element, {
|
|
23
28
|
box: box
|
|
@@ -27,7 +32,6 @@ function $9daab02d461809db$export$683480f191c0e3ea(options) {
|
|
|
27
32
|
};
|
|
28
33
|
}
|
|
29
34
|
}, [
|
|
30
|
-
onResize,
|
|
31
35
|
ref,
|
|
32
36
|
box
|
|
33
37
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;AAKA,SAAS;IACP,OAAO,OAAO,OAAO,cAAc,KAAK;AAC1C;AAQO,SAAS,0CAAqC,OAAwC;IAC3F,sFAAsF;IACtF,uCAAuC;IACvC,MAAM,OAAC,GAAG,OAAE,GAAG,YAAE,QAAQ,EAAC,GAAG;IAC7B,IAAI,gBAAgB,CAAA,GAAA,yCAAa,EAAE;IAEnC,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,UAAU,gBAAA,0BAAA,IAAK,OAAO;QAC1B,IAAI,CAAC,SACH;QAGF,IAAI,CAAC,2CAAqB;YACxB,OAAO,gBAAgB,CAAC,UAAU,eAAe;YACjD,OAAO;gBACL,OAAO,mBAAmB,CAAC,UAAU,eAAe;YACtD;QACF,OAAO;YAEL,MAAM,yBAAyB,IAAI,OAAO,cAAc,CAAC,CAAC;gBACxD,IAAI,CAAC,QAAQ,MAAM,EACjB;gBAGF;YACF;YACA,uBAAuB,OAAO,CAAC,SAAS;qBAAC;YAAG;YAE5C,OAAO;gBACL,IAAI,SACF,uBAAuB,SAAS,CAAC;YAErC;QACF;IAEF,GAAG;QAAC;QAAK;KAAI;AACf","sources":["packages/@react-aria/utils/src/useResizeObserver.ts"],"sourcesContent":["\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nfunction hasResizeObserver() {\n return typeof window.ResizeObserver !== 'undefined';\n}\n\ntype useResizeObserverOptionsType<T> = {\n ref: RefObject<T | undefined | null> | undefined,\n box?: ResizeObserverBoxOptions,\n onResize: () => void\n}\n\nexport function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>): void {\n // Only call onResize from inside the effect, otherwise we'll void our assumption that\n // useEffectEvents are safe to pass in.\n const {ref, box, onResize} = options;\n let onResizeEvent = useEffectEvent(onResize);\n\n useEffect(() => {\n let element = ref?.current;\n if (!element) {\n return;\n }\n\n if (!hasResizeObserver()) {\n window.addEventListener('resize', onResizeEvent, false);\n return () => {\n window.removeEventListener('resize', onResizeEvent, false);\n };\n } else {\n\n const resizeObserverInstance = new window.ResizeObserver((entries) => {\n if (!entries.length) {\n return;\n }\n\n onResizeEvent();\n });\n resizeObserverInstance.observe(element, {box});\n\n return () => {\n if (element) {\n resizeObserverInstance.unobserve(element);\n }\n };\n }\n\n }, [ref, box]);\n}\n"],"names":[],"version":3,"file":"useResizeObserver.module.js.map"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var $1254e5bb94ac8761$exports = require("./useEffectEvent.main.js");
|
|
1
2
|
var $cagC1$react = require("react");
|
|
2
3
|
|
|
3
4
|
|
|
@@ -17,9 +18,11 @@ $parcel$export(module.exports, "useUpdateEffect", () => $29293a6f5c75b37e$export
|
|
|
17
18
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
19
|
* governing permissions and limitations under the License.
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
function $29293a6f5c75b37e$export$496315a1608d9602(cb, dependencies) {
|
|
21
23
|
const isInitialMount = (0, $cagC1$react.useRef)(true);
|
|
22
24
|
const lastDeps = (0, $cagC1$react.useRef)(null);
|
|
25
|
+
let cbEvent = (0, $1254e5bb94ac8761$exports.useEffectEvent)(cb);
|
|
23
26
|
(0, $cagC1$react.useEffect)(()=>{
|
|
24
27
|
isInitialMount.current = true;
|
|
25
28
|
return ()=>{
|
|
@@ -29,7 +32,7 @@ function $29293a6f5c75b37e$export$496315a1608d9602(effect, dependencies) {
|
|
|
29
32
|
(0, $cagC1$react.useEffect)(()=>{
|
|
30
33
|
let prevDeps = lastDeps.current;
|
|
31
34
|
if (isInitialMount.current) isInitialMount.current = false;
|
|
32
|
-
else if (!prevDeps || dependencies.some((dep, i)=>!Object.is(dep, prevDeps[i])))
|
|
35
|
+
else if (!prevDeps || dependencies.some((dep, i)=>!Object.is(dep, prevDeps[i]))) cbEvent();
|
|
33
36
|
lastDeps.current = dependencies;
|
|
34
37
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
38
|
}, dependencies);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CAAgB,EAAkB,EAAE,YAAmB;IACrE,MAAM,iBAAiB,CAAA,GAAA,mBAAK,EAAE;IAC9B,MAAM,WAAW,CAAA,GAAA,mBAAK,EAAgB;IACtC,IAAI,UAAU,CAAA,GAAA,wCAAa,EAAE;IAE7B,CAAA,GAAA,sBAAQ,EAAE;QACR,eAAe,OAAO,GAAG;QACzB,OAAO;YACL,eAAe,OAAO,GAAG;QAC3B;IACF,GAAG,EAAE;IAEL,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,WAAW,SAAS,OAAO;QAC/B,IAAI,eAAe,OAAO,EACxB,eAAe,OAAO,GAAG;aACpB,IAAI,CAAC,YAAY,aAAa,IAAI,CAAC,CAAC,KAAK,IAAM,CAAC,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,IAC/E;QAEF,SAAS,OAAO,GAAG;IACrB,uDAAuD;IACvD,GAAG;AACL","sources":["packages/@react-aria/utils/src/useUpdateEffect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {EffectCallback, useEffect, useRef} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\n// Like useEffect, but only called for updates after the initial render.\nexport function useUpdateEffect(cb: EffectCallback, dependencies: any[]): void {\n const isInitialMount = useRef(true);\n const lastDeps = useRef<any[] | null>(null);\n let cbEvent = useEffectEvent(cb);\n\n useEffect(() => {\n isInitialMount.current = true;\n return () => {\n isInitialMount.current = false;\n };\n }, []);\n\n useEffect(() => {\n let prevDeps = lastDeps.current;\n if (isInitialMount.current) {\n isInitialMount.current = false;\n } else if (!prevDeps || dependencies.some((dep, i) => !Object.is(dep, prevDeps[i]))) {\n cbEvent();\n }\n lastDeps.current = dependencies;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n}\n"],"names":[],"version":3,"file":"useUpdateEffect.main.js.map"}
|
package/dist/useUpdateEffect.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.mjs";
|
|
1
2
|
import {useRef as $9vW05$useRef, useEffect as $9vW05$useEffect} from "react";
|
|
2
3
|
|
|
3
4
|
/*
|
|
@@ -11,9 +12,11 @@ import {useRef as $9vW05$useRef, useEffect as $9vW05$useEffect} from "react";
|
|
|
11
12
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
13
|
* governing permissions and limitations under the License.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
function $4f58c5f72bcf79f7$export$496315a1608d9602(cb, dependencies) {
|
|
15
17
|
const isInitialMount = (0, $9vW05$useRef)(true);
|
|
16
18
|
const lastDeps = (0, $9vW05$useRef)(null);
|
|
19
|
+
let cbEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(cb);
|
|
17
20
|
(0, $9vW05$useEffect)(()=>{
|
|
18
21
|
isInitialMount.current = true;
|
|
19
22
|
return ()=>{
|
|
@@ -23,7 +26,7 @@ function $4f58c5f72bcf79f7$export$496315a1608d9602(effect, dependencies) {
|
|
|
23
26
|
(0, $9vW05$useEffect)(()=>{
|
|
24
27
|
let prevDeps = lastDeps.current;
|
|
25
28
|
if (isInitialMount.current) isInitialMount.current = false;
|
|
26
|
-
else if (!prevDeps || dependencies.some((dep, i)=>!Object.is(dep, prevDeps[i])))
|
|
29
|
+
else if (!prevDeps || dependencies.some((dep, i)=>!Object.is(dep, prevDeps[i]))) cbEvent();
|
|
27
30
|
lastDeps.current = dependencies;
|
|
28
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
32
|
}, dependencies);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.module.js";
|
|
1
2
|
import {useRef as $9vW05$useRef, useEffect as $9vW05$useEffect} from "react";
|
|
2
3
|
|
|
3
4
|
/*
|
|
@@ -11,9 +12,11 @@ import {useRef as $9vW05$useRef, useEffect as $9vW05$useEffect} from "react";
|
|
|
11
12
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
13
|
* governing permissions and limitations under the License.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
function $4f58c5f72bcf79f7$export$496315a1608d9602(cb, dependencies) {
|
|
15
17
|
const isInitialMount = (0, $9vW05$useRef)(true);
|
|
16
18
|
const lastDeps = (0, $9vW05$useRef)(null);
|
|
19
|
+
let cbEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(cb);
|
|
17
20
|
(0, $9vW05$useEffect)(()=>{
|
|
18
21
|
isInitialMount.current = true;
|
|
19
22
|
return ()=>{
|
|
@@ -23,7 +26,7 @@ function $4f58c5f72bcf79f7$export$496315a1608d9602(effect, dependencies) {
|
|
|
23
26
|
(0, $9vW05$useEffect)(()=>{
|
|
24
27
|
let prevDeps = lastDeps.current;
|
|
25
28
|
if (isInitialMount.current) isInitialMount.current = false;
|
|
26
|
-
else if (!prevDeps || dependencies.some((dep, i)=>!Object.is(dep, prevDeps[i])))
|
|
29
|
+
else if (!prevDeps || dependencies.some((dep, i)=>!Object.is(dep, prevDeps[i]))) cbEvent();
|
|
27
30
|
lastDeps.current = dependencies;
|
|
28
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
32
|
}, dependencies);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CAAgB,EAAkB,EAAE,YAAmB;IACrE,MAAM,iBAAiB,CAAA,GAAA,aAAK,EAAE;IAC9B,MAAM,WAAW,CAAA,GAAA,aAAK,EAAgB;IACtC,IAAI,UAAU,CAAA,GAAA,yCAAa,EAAE;IAE7B,CAAA,GAAA,gBAAQ,EAAE;QACR,eAAe,OAAO,GAAG;QACzB,OAAO;YACL,eAAe,OAAO,GAAG;QAC3B;IACF,GAAG,EAAE;IAEL,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,WAAW,SAAS,OAAO;QAC/B,IAAI,eAAe,OAAO,EACxB,eAAe,OAAO,GAAG;aACpB,IAAI,CAAC,YAAY,aAAa,IAAI,CAAC,CAAC,KAAK,IAAM,CAAC,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,IAC/E;QAEF,SAAS,OAAO,GAAG;IACrB,uDAAuD;IACvD,GAAG;AACL","sources":["packages/@react-aria/utils/src/useUpdateEffect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {EffectCallback, useEffect, useRef} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\n// Like useEffect, but only called for updates after the initial render.\nexport function useUpdateEffect(cb: EffectCallback, dependencies: any[]): void {\n const isInitialMount = useRef(true);\n const lastDeps = useRef<any[] | null>(null);\n let cbEvent = useEffectEvent(cb);\n\n useEffect(() => {\n isInitialMount.current = true;\n return () => {\n isInitialMount.current = false;\n };\n }, []);\n\n useEffect(() => {\n let prevDeps = lastDeps.current;\n if (isInitialMount.current) {\n isInitialMount.current = false;\n } else if (!prevDeps || dependencies.some((dep, i) => !Object.is(dep, prevDeps[i]))) {\n cbEvent();\n }\n lastDeps.current = dependencies;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n}\n"],"names":[],"version":3,"file":"useUpdateEffect.module.js.map"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var $1254e5bb94ac8761$exports = require("./useEffectEvent.main.js");
|
|
2
1
|
var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");
|
|
3
2
|
var $fymK9$react = require("react");
|
|
4
3
|
|
|
@@ -22,10 +21,13 @@ $parcel$export(module.exports, "useValueEffect", () => $19a2307bfabafaf1$export$
|
|
|
22
21
|
|
|
23
22
|
function $19a2307bfabafaf1$export$14d238f342723f25(defaultValue) {
|
|
24
23
|
let [value, setValue] = (0, $fymK9$react.useState)(defaultValue);
|
|
24
|
+
// Keep an up to date copy of value in a ref so we can access the current value in the generator.
|
|
25
|
+
// This allows us to maintain a stable queue function.
|
|
26
|
+
let currValue = (0, $fymK9$react.useRef)(value);
|
|
25
27
|
let effect = (0, $fymK9$react.useRef)(null);
|
|
26
28
|
// Store the function in a ref so we can always access the current version
|
|
27
29
|
// which has the proper `value` in scope.
|
|
28
|
-
let nextRef = (0, $
|
|
30
|
+
let nextRef = (0, $fymK9$react.useRef)(()=>{
|
|
29
31
|
if (!effect.current) return;
|
|
30
32
|
// Run the generator to the next yield.
|
|
31
33
|
let newValue = effect.current.next();
|
|
@@ -37,17 +39,20 @@ function $19a2307bfabafaf1$export$14d238f342723f25(defaultValue) {
|
|
|
37
39
|
// If the value is the same as the current value,
|
|
38
40
|
// then continue to the next yield. Otherwise,
|
|
39
41
|
// set the value in state and wait for the next layout effect.
|
|
40
|
-
if (
|
|
42
|
+
if (currValue.current === newValue.value) nextRef.current();
|
|
41
43
|
else setValue(newValue.value);
|
|
42
44
|
});
|
|
43
45
|
(0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
|
|
46
|
+
currValue.current = value;
|
|
44
47
|
// If there is an effect currently running, continue to the next yield.
|
|
45
|
-
if (effect.current) nextRef();
|
|
46
|
-
});
|
|
47
|
-
let queue = (0, $1254e5bb94ac8761$exports.useEffectEvent)((fn)=>{
|
|
48
|
-
effect.current = fn(value);
|
|
49
|
-
nextRef();
|
|
48
|
+
if (effect.current) nextRef.current();
|
|
50
49
|
});
|
|
50
|
+
let queue = (0, $fymK9$react.useCallback)((fn)=>{
|
|
51
|
+
effect.current = fn(currValue.current);
|
|
52
|
+
nextRef.current();
|
|
53
|
+
}, [
|
|
54
|
+
nextRef
|
|
55
|
+
]);
|
|
51
56
|
return [
|
|
52
57
|
value,
|
|
53
58
|
queue
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAWM,SAAS,0CAAkB,YAA2B;IAC3D,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,qBAAO,EAAE;IACjC,iGAAiG;IACjG,sDAAsD;IACtD,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE;IACvB,IAAI,SAAyC,CAAA,GAAA,mBAAK,EAAuB;IAEzE,0EAA0E;IAC1E,yCAAyC;IACzC,IAAI,UAAU,CAAA,GAAA,mBAAK,EAAE;QACnB,IAAI,CAAC,OAAO,OAAO,EACjB;QAEF,uCAAuC;QACvC,IAAI,WAAW,OAAO,OAAO,CAAC,IAAI;QAElC,8CAA8C;QAC9C,IAAI,SAAS,IAAI,EAAE;YACjB,OAAO,OAAO,GAAG;YACjB;QACF;QAEA,iDAAiD;QACjD,8CAA8C;QAC9C,8DAA8D;QAC9D,IAAI,UAAU,OAAO,KAAK,SAAS,KAAK,EACtC,QAAQ,OAAO;aAEf,SAAS,SAAS,KAAK;IAE3B;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,UAAU,OAAO,GAAG;QACpB,uEAAuE;QACvE,IAAI,OAAO,OAAO,EAChB,QAAQ,OAAO;IAEnB;IAEA,IAAI,QAAQ,CAAA,GAAA,wBAAU,EAAE,CAAA;QACtB,OAAO,OAAO,GAAG,GAAG,UAAU,OAAO;QACrC,QAAQ,OAAO;IACjB,GAAG;QAAC;KAAQ;IAEZ,OAAO;QAAC;QAAO;KAAM;AACvB","sources":["packages/@react-aria/utils/src/useValueEffect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Dispatch, RefObject, useCallback, useRef, useState} from 'react';\nimport {useLayoutEffect} from './';\n\ntype SetValueAction<S> = (prev: S) => Generator<any, void, unknown>;\n\n// This hook works like `useState`, but when setting the value, you pass a generator function\n// that can yield multiple values. Each yielded value updates the state and waits for the next\n// layout effect, then continues the generator. This allows sequential updates to state to be\n// written linearly.\nexport function useValueEffect<S>(defaultValue: S | (() => S)): [S, Dispatch<SetValueAction<S>>] {\n let [value, setValue] = useState(defaultValue);\n // Keep an up to date copy of value in a ref so we can access the current value in the generator.\n // This allows us to maintain a stable queue function.\n let currValue = useRef(value);\n let effect: RefObject<Generator<S> | null> = useRef<Generator<S> | null>(null);\n\n // Store the function in a ref so we can always access the current version\n // which has the proper `value` in scope.\n let nextRef = useRef(() => {\n if (!effect.current) {\n return;\n }\n // Run the generator to the next yield.\n let newValue = effect.current.next();\n\n // If the generator is done, reset the effect.\n if (newValue.done) {\n effect.current = null;\n return;\n }\n\n // If the value is the same as the current value,\n // then continue to the next yield. Otherwise,\n // set the value in state and wait for the next layout effect.\n if (currValue.current === newValue.value) {\n nextRef.current();\n } else {\n setValue(newValue.value);\n }\n });\n\n useLayoutEffect(() => {\n currValue.current = value;\n // If there is an effect currently running, continue to the next yield.\n if (effect.current) {\n nextRef.current();\n }\n });\n\n let queue = useCallback(fn => {\n effect.current = fn(currValue.current);\n nextRef.current();\n }, [nextRef]);\n\n return [value, queue];\n}\n"],"names":[],"version":3,"file":"useValueEffect.main.js.map"}
|
package/dist/useValueEffect.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.mjs";
|
|
2
1
|
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
|
|
3
|
-
import {useState as $fCAlL$useState, useRef as $fCAlL$useRef} from "react";
|
|
2
|
+
import {useState as $fCAlL$useState, useRef as $fCAlL$useRef, useCallback as $fCAlL$useCallback} from "react";
|
|
4
3
|
|
|
5
4
|
/*
|
|
6
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -16,10 +15,13 @@ import {useState as $fCAlL$useState, useRef as $fCAlL$useRef} from "react";
|
|
|
16
15
|
|
|
17
16
|
function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
|
|
18
17
|
let [value, setValue] = (0, $fCAlL$useState)(defaultValue);
|
|
18
|
+
// Keep an up to date copy of value in a ref so we can access the current value in the generator.
|
|
19
|
+
// This allows us to maintain a stable queue function.
|
|
20
|
+
let currValue = (0, $fCAlL$useRef)(value);
|
|
19
21
|
let effect = (0, $fCAlL$useRef)(null);
|
|
20
22
|
// Store the function in a ref so we can always access the current version
|
|
21
23
|
// which has the proper `value` in scope.
|
|
22
|
-
let nextRef = (0, $
|
|
24
|
+
let nextRef = (0, $fCAlL$useRef)(()=>{
|
|
23
25
|
if (!effect.current) return;
|
|
24
26
|
// Run the generator to the next yield.
|
|
25
27
|
let newValue = effect.current.next();
|
|
@@ -31,17 +33,20 @@ function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
|
|
|
31
33
|
// If the value is the same as the current value,
|
|
32
34
|
// then continue to the next yield. Otherwise,
|
|
33
35
|
// set the value in state and wait for the next layout effect.
|
|
34
|
-
if (
|
|
36
|
+
if (currValue.current === newValue.value) nextRef.current();
|
|
35
37
|
else setValue(newValue.value);
|
|
36
38
|
});
|
|
37
39
|
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
40
|
+
currValue.current = value;
|
|
38
41
|
// If there is an effect currently running, continue to the next yield.
|
|
39
|
-
if (effect.current) nextRef();
|
|
40
|
-
});
|
|
41
|
-
let queue = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)((fn)=>{
|
|
42
|
-
effect.current = fn(value);
|
|
43
|
-
nextRef();
|
|
42
|
+
if (effect.current) nextRef.current();
|
|
44
43
|
});
|
|
44
|
+
let queue = (0, $fCAlL$useCallback)((fn)=>{
|
|
45
|
+
effect.current = fn(currValue.current);
|
|
46
|
+
nextRef.current();
|
|
47
|
+
}, [
|
|
48
|
+
nextRef
|
|
49
|
+
]);
|
|
45
50
|
return [
|
|
46
51
|
value,
|
|
47
52
|
queue
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.module.js";
|
|
2
1
|
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
|
|
3
|
-
import {useState as $fCAlL$useState, useRef as $fCAlL$useRef} from "react";
|
|
2
|
+
import {useState as $fCAlL$useState, useRef as $fCAlL$useRef, useCallback as $fCAlL$useCallback} from "react";
|
|
4
3
|
|
|
5
4
|
/*
|
|
6
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -16,10 +15,13 @@ import {useState as $fCAlL$useState, useRef as $fCAlL$useRef} from "react";
|
|
|
16
15
|
|
|
17
16
|
function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
|
|
18
17
|
let [value, setValue] = (0, $fCAlL$useState)(defaultValue);
|
|
18
|
+
// Keep an up to date copy of value in a ref so we can access the current value in the generator.
|
|
19
|
+
// This allows us to maintain a stable queue function.
|
|
20
|
+
let currValue = (0, $fCAlL$useRef)(value);
|
|
19
21
|
let effect = (0, $fCAlL$useRef)(null);
|
|
20
22
|
// Store the function in a ref so we can always access the current version
|
|
21
23
|
// which has the proper `value` in scope.
|
|
22
|
-
let nextRef = (0, $
|
|
24
|
+
let nextRef = (0, $fCAlL$useRef)(()=>{
|
|
23
25
|
if (!effect.current) return;
|
|
24
26
|
// Run the generator to the next yield.
|
|
25
27
|
let newValue = effect.current.next();
|
|
@@ -31,17 +33,20 @@ function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
|
|
|
31
33
|
// If the value is the same as the current value,
|
|
32
34
|
// then continue to the next yield. Otherwise,
|
|
33
35
|
// set the value in state and wait for the next layout effect.
|
|
34
|
-
if (
|
|
36
|
+
if (currValue.current === newValue.value) nextRef.current();
|
|
35
37
|
else setValue(newValue.value);
|
|
36
38
|
});
|
|
37
39
|
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
40
|
+
currValue.current = value;
|
|
38
41
|
// If there is an effect currently running, continue to the next yield.
|
|
39
|
-
if (effect.current) nextRef();
|
|
40
|
-
});
|
|
41
|
-
let queue = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)((fn)=>{
|
|
42
|
-
effect.current = fn(value);
|
|
43
|
-
nextRef();
|
|
42
|
+
if (effect.current) nextRef.current();
|
|
44
43
|
});
|
|
44
|
+
let queue = (0, $fCAlL$useCallback)((fn)=>{
|
|
45
|
+
effect.current = fn(currValue.current);
|
|
46
|
+
nextRef.current();
|
|
47
|
+
}, [
|
|
48
|
+
nextRef
|
|
49
|
+
]);
|
|
45
50
|
return [
|
|
46
51
|
value,
|
|
47
52
|
queue
|