@react-aria/utils 3.17.0 → 3.19.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/import.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import {clamp as $4507461a1b870123$re_export$clamp, snapValueToStep as $4507461a1b870123$re_export$snapValueToStep} from "@react-stately/utils";
2
- import $12uGp$react, {useState as $12uGp$useState, useRef as $12uGp$useRef, useCallback as $12uGp$useCallback, useEffect as $12uGp$useEffect} from "react";
2
+ import $12uGp$react, {useState as $12uGp$useState, useRef as $12uGp$useRef, useCallback as $12uGp$useCallback, useEffect as $12uGp$useEffect, useMemo as $12uGp$useMemo} from "react";
3
3
  import {useSSRSafeId as $12uGp$useSSRSafeId} from "@react-aria/ssr";
4
4
  import $12uGp$clsx from "clsx";
5
5
 
@@ -35,7 +35,7 @@ import $12uGp$clsx from "clsx";
35
35
  * OF ANY KIND, either express or implied. See the License for the specific language
36
36
  * governing permissions and limitations under the License.
37
37
  */
38
- const $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof window !== "undefined" ? (0, $12uGp$react).useLayoutEffect : ()=>{};
38
+ const $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof document !== "undefined" ? (0, $12uGp$react).useLayoutEffect : ()=>{};
39
39
 
40
40
 
41
41
 
@@ -429,7 +429,7 @@ function $bbed8b41f857bcc0$export$24490316f764c430(fn) {
429
429
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
430
430
  * OF ANY KIND, either express or implied. See the License for the specific language
431
431
  * governing permissions and limitations under the License.
432
- */
432
+ */ /* eslint-disable rulesdir/pure-render */
433
433
 
434
434
  // Keep track of elements that we are currently handling dragging for via useDrag1D.
435
435
  // If there's an ancestor and a descendant both using useDrag1D(), and the user starts
@@ -620,8 +620,8 @@ function $313b98861ee5dd6c$export$d6875122194c7b44(props, defaultLabel) {
620
620
  id = (0, $bdb11010cef70236$export$f680877a34711e37)(id);
621
621
  if (labelledBy && label) {
622
622
  let ids = new Set([
623
- ...labelledBy.trim().split(/\s+/),
624
- id
623
+ id,
624
+ ...labelledBy.trim().split(/\s+/)
625
625
  ]);
626
626
  labelledBy = [
627
627
  ...ids
@@ -648,25 +648,20 @@ function $313b98861ee5dd6c$export$d6875122194c7b44(props, defaultLabel) {
648
648
  * OF ANY KIND, either express or implied. See the License for the specific language
649
649
  * governing permissions and limitations under the License.
650
650
  */
651
-
652
651
  function $df56164dff5785e2$export$4338b53315abf666(forwardedRef) {
653
652
  const objRef = (0, $12uGp$useRef)();
654
- /**
655
- * We're using `useLayoutEffect` here instead of `useEffect` because we want
656
- * to make sure that the `ref` value is up to date before other places in the
657
- * the execution cycle try to read it.
658
- */ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
659
- if (!forwardedRef) return;
660
- if (typeof forwardedRef === "function") forwardedRef(objRef.current);
661
- else forwardedRef.current = objRef.current;
662
- return ()=>{
663
- if (typeof forwardedRef === "function") forwardedRef(null);
664
- else forwardedRef.current = null;
665
- };
666
- }, [
653
+ return (0, $12uGp$useMemo)(()=>({
654
+ get current () {
655
+ return objRef.current;
656
+ },
657
+ set current (value){
658
+ objRef.current = value;
659
+ if (typeof forwardedRef === "function") forwardedRef(value);
660
+ else if (forwardedRef) forwardedRef.current = value;
661
+ }
662
+ }), [
667
663
  forwardedRef
668
664
  ]);
669
- return objRef;
670
665
  }
671
666
 
672
667
 
@@ -683,9 +678,17 @@ function $df56164dff5785e2$export$4338b53315abf666(forwardedRef) {
683
678
  */
684
679
  function $4f58c5f72bcf79f7$export$496315a1608d9602(effect, dependencies) {
685
680
  const isInitialMount = (0, $12uGp$useRef)(true);
681
+ const lastDeps = (0, $12uGp$useRef)(null);
682
+ (0, $12uGp$useEffect)(()=>{
683
+ isInitialMount.current = true;
684
+ return ()=>{
685
+ isInitialMount.current = false;
686
+ };
687
+ }, []);
686
688
  (0, $12uGp$useEffect)(()=>{
687
689
  if (isInitialMount.current) isInitialMount.current = false;
688
- else effect();
690
+ else if (!lastDeps.current || dependencies.some((dep, i)=>!Object.is(dep, lastDeps[i]))) effect();
691
+ lastDeps.current = dependencies;
689
692
  // eslint-disable-next-line react-hooks/exhaustive-deps
690
693
  }, dependencies);
691
694
  }
@@ -782,7 +785,7 @@ function $62d8ded9296f3872$export$2bb74740c4e19def(node) {
782
785
  * governing permissions and limitations under the License.
783
786
  */
784
787
  // @ts-ignore
785
- let $5df64b3807dc15ee$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
788
+ let $5df64b3807dc15ee$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
786
789
  function $5df64b3807dc15ee$export$d699905dd57c73ca() {
787
790
  let [size, setSize] = (0, $12uGp$useState)(()=>$5df64b3807dc15ee$var$getViewportSize());
788
791
  (0, $12uGp$useEffect)(()=>{
@@ -917,23 +920,48 @@ function $c87311424ea30a05$export$a11b0059900ceec8() {
917
920
  * OF ANY KIND, either express or implied. See the License for the specific language
918
921
  * governing permissions and limitations under the License.
919
922
  */
923
+ /*
924
+ * Copyright 2023 Adobe. All rights reserved.
925
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
926
+ * you may not use this file except in compliance with the License. You may obtain a copy
927
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
928
+ *
929
+ * Unless required by applicable law or agreed to in writing, software distributed under
930
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
931
+ * OF ANY KIND, either express or implied. See the License for the specific language
932
+ * governing permissions and limitations under the License.
933
+ */
934
+
935
+ function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
936
+ const ref = (0, $12uGp$useRef)(null);
937
+ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
938
+ ref.current = fn;
939
+ }, [
940
+ fn
941
+ ]);
942
+ return (0, $12uGp$useCallback)((...args)=>{
943
+ const f = ref.current;
944
+ return f(...args);
945
+ }, []);
946
+ }
947
+
948
+
920
949
  function $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler, options) {
921
- let handlerRef = (0, $12uGp$useRef)(handler);
922
- handlerRef.current = handler;
950
+ let handleEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(handler);
923
951
  let isDisabled = handler == null;
924
952
  (0, $12uGp$useEffect)(()=>{
925
953
  if (isDisabled) return;
926
954
  let element = ref.current;
927
- let handler = (e)=>handlerRef.current.call(this, e);
928
- element.addEventListener(event, handler, options);
955
+ element.addEventListener(event, handleEvent, options);
929
956
  return ()=>{
930
- element.removeEventListener(event, handler, options);
957
+ element.removeEventListener(event, handleEvent, options);
931
958
  };
932
959
  }, [
933
960
  ref,
934
961
  event,
935
962
  options,
936
- isDisabled
963
+ isDisabled,
964
+ handleEvent
937
965
  ]);
938
966
  }
939
967
 
@@ -1061,6 +1089,28 @@ function $6a7db85432448f7f$export$29bf1b5f2c56cf63(event) {
1061
1089
  }
1062
1090
 
1063
1091
 
1092
+
1093
+ /*
1094
+ * Copyright 2023 Adobe. All rights reserved.
1095
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1096
+ * you may not use this file except in compliance with the License. You may obtain a copy
1097
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
1098
+ *
1099
+ * Unless required by applicable law or agreed to in writing, software distributed under
1100
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1101
+ * OF ANY KIND, either express or implied. See the License for the specific language
1102
+ * governing permissions and limitations under the License.
1103
+ */ /* eslint-disable rulesdir/pure-render */
1104
+ function $5a387cc49350e6db$export$722debc0e56fea39(value, isEqual) {
1105
+ // Using a ref during render is ok here because it's only an optimization – both values are equivalent.
1106
+ // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.
1107
+ let lastValue = (0, $12uGp$useRef)(null);
1108
+ if (value && lastValue.current && isEqual(value, lastValue.current)) value = lastValue.current;
1109
+ lastValue.current = value;
1110
+ return value;
1111
+ }
1112
+
1113
+
1064
1114
  /*
1065
1115
  * Copyright 2023 Adobe. All rights reserved.
1066
1116
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1073,21 +1123,26 @@ function $6a7db85432448f7f$export$29bf1b5f2c56cf63(event) {
1073
1123
  * governing permissions and limitations under the License.
1074
1124
  */
1075
1125
 
1076
- function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
1077
- const ref = (0, $12uGp$useRef)(null);
1078
- (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
1079
- ref.current = fn;
1126
+ function $99facab73266f662$export$5add1d006293d136(ref, initialValue, onReset) {
1127
+ let resetValue = (0, $12uGp$useRef)(initialValue);
1128
+ let handleReset = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(()=>{
1129
+ if (onReset) onReset(resetValue.current);
1130
+ });
1131
+ (0, $12uGp$useEffect)(()=>{
1132
+ var _ref_current;
1133
+ let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
1134
+ form === null || form === void 0 ? void 0 : form.addEventListener("reset", handleReset);
1135
+ return ()=>{
1136
+ form === null || form === void 0 ? void 0 : form.removeEventListener("reset", handleReset);
1137
+ };
1080
1138
  }, [
1081
- fn
1139
+ ref,
1140
+ handleReset
1082
1141
  ]);
1083
- return (0, $12uGp$useCallback)((...args)=>{
1084
- const f = ref.current;
1085
- return f(...args);
1086
- }, []);
1087
1142
  }
1088
1143
 
1089
1144
 
1090
1145
 
1091
1146
 
1092
- export {$bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId, $ff5963eb1fccf552$export$e08e3b67e392101e as chain, $3ef42575df84b30b$export$9d1611c77c2fe928 as mergeProps, $5dc95899b306f630$export$c9058316764c140e as mergeRefs, $65484d02dcb7eb3e$export$457c3d6518dd4c6f as filterDOMProps, $7215afc6de606d6b$export$de79e2c695e052f3 as focusWithoutScrolling, $ab71dadb03a6fb2e$export$622cea445a1c5b7d as getOffset, $bbed8b41f857bcc0$export$24490316f764c430 as runAfterTransition, $9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D, $03deb23ff14920c4$export$4eaf04e54aa8eed6 as useGlobalListeners, $313b98861ee5dd6c$export$d6875122194c7b44 as useLabels, $df56164dff5785e2$export$4338b53315abf666 as useObjectRef, $4f58c5f72bcf79f7$export$496315a1608d9602 as useUpdateEffect, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c as useLayoutEffect, $9daab02d461809db$export$683480f191c0e3ea as useResizeObserver, $e7801be82b4b2a53$export$4debdb1a3f0fa79e as useSyncRef, $62d8ded9296f3872$export$cfa2225e87938781 as getScrollParent, $62d8ded9296f3872$export$2bb74740c4e19def as isScrollable, $5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize, $ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription, $c87311424ea30a05$export$9ac100e40613ea10 as isMac, $c87311424ea30a05$export$186c6964ca17d99 as isIPhone, $c87311424ea30a05$export$7bef049ce92e4224 as isIPad, $c87311424ea30a05$export$fedb369cb70207f1 as isIOS, $c87311424ea30a05$export$e1865c3bedcd822b as isAppleDevice, $c87311424ea30a05$export$78551043582a6a98 as isWebKit, $c87311424ea30a05$export$6446a186d09e379e as isChrome, $c87311424ea30a05$export$a11b0059900ceec8 as isAndroid, $e9faafb641e167db$export$90fc3a17d93f704c as useEvent, $1dbecbe27a04f9af$export$14d238f342723f25 as useValueEffect, $2f04cbc44ee30ce0$export$53a0910f038337bd as scrollIntoView, $2f04cbc44ee30ce0$export$c826860796309d1b as scrollIntoViewport, $4507461a1b870123$re_export$clamp as clamp, $4507461a1b870123$re_export$snapValueToStep as snapValueToStep, $6a7db85432448f7f$export$60278871457622de as isVirtualClick, $6a7db85432448f7f$export$29bf1b5f2c56cf63 as isVirtualPointerEvent, $8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent};
1147
+ export {$bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId, $ff5963eb1fccf552$export$e08e3b67e392101e as chain, $3ef42575df84b30b$export$9d1611c77c2fe928 as mergeProps, $5dc95899b306f630$export$c9058316764c140e as mergeRefs, $65484d02dcb7eb3e$export$457c3d6518dd4c6f as filterDOMProps, $7215afc6de606d6b$export$de79e2c695e052f3 as focusWithoutScrolling, $ab71dadb03a6fb2e$export$622cea445a1c5b7d as getOffset, $bbed8b41f857bcc0$export$24490316f764c430 as runAfterTransition, $9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D, $03deb23ff14920c4$export$4eaf04e54aa8eed6 as useGlobalListeners, $313b98861ee5dd6c$export$d6875122194c7b44 as useLabels, $df56164dff5785e2$export$4338b53315abf666 as useObjectRef, $4f58c5f72bcf79f7$export$496315a1608d9602 as useUpdateEffect, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c as useLayoutEffect, $9daab02d461809db$export$683480f191c0e3ea as useResizeObserver, $e7801be82b4b2a53$export$4debdb1a3f0fa79e as useSyncRef, $62d8ded9296f3872$export$cfa2225e87938781 as getScrollParent, $62d8ded9296f3872$export$2bb74740c4e19def as isScrollable, $5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize, $ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription, $c87311424ea30a05$export$9ac100e40613ea10 as isMac, $c87311424ea30a05$export$186c6964ca17d99 as isIPhone, $c87311424ea30a05$export$7bef049ce92e4224 as isIPad, $c87311424ea30a05$export$fedb369cb70207f1 as isIOS, $c87311424ea30a05$export$e1865c3bedcd822b as isAppleDevice, $c87311424ea30a05$export$78551043582a6a98 as isWebKit, $c87311424ea30a05$export$6446a186d09e379e as isChrome, $c87311424ea30a05$export$a11b0059900ceec8 as isAndroid, $e9faafb641e167db$export$90fc3a17d93f704c as useEvent, $1dbecbe27a04f9af$export$14d238f342723f25 as useValueEffect, $2f04cbc44ee30ce0$export$53a0910f038337bd as scrollIntoView, $2f04cbc44ee30ce0$export$c826860796309d1b as scrollIntoViewport, $4507461a1b870123$re_export$clamp as clamp, $4507461a1b870123$re_export$snapValueToStep as snapValueToStep, $6a7db85432448f7f$export$60278871457622de as isVirtualClick, $6a7db85432448f7f$export$29bf1b5f2c56cf63 as isVirtualPointerEvent, $8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent, $5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo, $99facab73266f662$export$5add1d006293d136 as useFormReset};
1093
1148
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -49,6 +49,8 @@ $parcel$export(module.exports, "snapValueToStep", () => $1Yh1N$reactstatelyutils
49
49
  $parcel$export(module.exports, "isVirtualClick", () => $577e795361f19be9$export$60278871457622de);
50
50
  $parcel$export(module.exports, "isVirtualPointerEvent", () => $577e795361f19be9$export$29bf1b5f2c56cf63);
51
51
  $parcel$export(module.exports, "useEffectEvent", () => $1254e5bb94ac8761$export$7f54fc3180508a52);
52
+ $parcel$export(module.exports, "useDeepMemo", () => $20e6e72fbf5dc81e$export$722debc0e56fea39);
53
+ $parcel$export(module.exports, "useFormReset", () => $1f205e845604a423$export$5add1d006293d136);
52
54
  /*
53
55
  * Copyright 2020 Adobe. All rights reserved.
54
56
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -81,7 +83,7 @@ $parcel$export(module.exports, "useEffectEvent", () => $1254e5bb94ac8761$export$
81
83
  * OF ANY KIND, either express or implied. See the License for the specific language
82
84
  * governing permissions and limitations under the License.
83
85
  */
84
- const $78605a5d7424e31b$export$e5c5a5f917a5871c = typeof window !== "undefined" ? (0, ($parcel$interopDefault($1Yh1N$react))).useLayoutEffect : ()=>{};
86
+ const $78605a5d7424e31b$export$e5c5a5f917a5871c = typeof document !== "undefined" ? (0, ($parcel$interopDefault($1Yh1N$react))).useLayoutEffect : ()=>{};
85
87
 
86
88
 
87
89
 
@@ -475,7 +477,7 @@ function $e8117ebcab55be6a$export$24490316f764c430(fn) {
475
477
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
476
478
  * OF ANY KIND, either express or implied. See the License for the specific language
477
479
  * governing permissions and limitations under the License.
478
- */
480
+ */ /* eslint-disable rulesdir/pure-render */
479
481
 
480
482
  // Keep track of elements that we are currently handling dragging for via useDrag1D.
481
483
  // If there's an ancestor and a descendant both using useDrag1D(), and the user starts
@@ -666,8 +668,8 @@ function $6ec78bde395c477d$export$d6875122194c7b44(props, defaultLabel) {
666
668
  id = (0, $8c61827343eed941$export$f680877a34711e37)(id);
667
669
  if (labelledBy && label) {
668
670
  let ids = new Set([
669
- ...labelledBy.trim().split(/\s+/),
670
- id
671
+ id,
672
+ ...labelledBy.trim().split(/\s+/)
671
673
  ]);
672
674
  labelledBy = [
673
675
  ...ids
@@ -694,25 +696,20 @@ function $6ec78bde395c477d$export$d6875122194c7b44(props, defaultLabel) {
694
696
  * OF ANY KIND, either express or implied. See the License for the specific language
695
697
  * governing permissions and limitations under the License.
696
698
  */
697
-
698
699
  function $475b35fe72ba49b3$export$4338b53315abf666(forwardedRef) {
699
700
  const objRef = (0, $1Yh1N$react.useRef)();
700
- /**
701
- * We're using `useLayoutEffect` here instead of `useEffect` because we want
702
- * to make sure that the `ref` value is up to date before other places in the
703
- * the execution cycle try to read it.
704
- */ (0, $78605a5d7424e31b$export$e5c5a5f917a5871c)(()=>{
705
- if (!forwardedRef) return;
706
- if (typeof forwardedRef === "function") forwardedRef(objRef.current);
707
- else forwardedRef.current = objRef.current;
708
- return ()=>{
709
- if (typeof forwardedRef === "function") forwardedRef(null);
710
- else forwardedRef.current = null;
711
- };
712
- }, [
701
+ return (0, $1Yh1N$react.useMemo)(()=>({
702
+ get current () {
703
+ return objRef.current;
704
+ },
705
+ set current (value){
706
+ objRef.current = value;
707
+ if (typeof forwardedRef === "function") forwardedRef(value);
708
+ else if (forwardedRef) forwardedRef.current = value;
709
+ }
710
+ }), [
713
711
  forwardedRef
714
712
  ]);
715
- return objRef;
716
713
  }
717
714
 
718
715
 
@@ -729,9 +726,17 @@ function $475b35fe72ba49b3$export$4338b53315abf666(forwardedRef) {
729
726
  */
730
727
  function $29293a6f5c75b37e$export$496315a1608d9602(effect, dependencies) {
731
728
  const isInitialMount = (0, $1Yh1N$react.useRef)(true);
729
+ const lastDeps = (0, $1Yh1N$react.useRef)(null);
730
+ (0, $1Yh1N$react.useEffect)(()=>{
731
+ isInitialMount.current = true;
732
+ return ()=>{
733
+ isInitialMount.current = false;
734
+ };
735
+ }, []);
732
736
  (0, $1Yh1N$react.useEffect)(()=>{
733
737
  if (isInitialMount.current) isInitialMount.current = false;
734
- else effect();
738
+ else if (!lastDeps.current || dependencies.some((dep, i)=>!Object.is(dep, lastDeps[i]))) effect();
739
+ lastDeps.current = dependencies;
735
740
  // eslint-disable-next-line react-hooks/exhaustive-deps
736
741
  }, dependencies);
737
742
  }
@@ -828,7 +833,7 @@ function $d796e7157ac96470$export$2bb74740c4e19def(node) {
828
833
  * governing permissions and limitations under the License.
829
834
  */
830
835
  // @ts-ignore
831
- let $8b24bab62f5c65ad$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
836
+ let $8b24bab62f5c65ad$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
832
837
  function $8b24bab62f5c65ad$export$d699905dd57c73ca() {
833
838
  let [size, setSize] = (0, $1Yh1N$react.useState)(()=>$8b24bab62f5c65ad$var$getViewportSize());
834
839
  (0, $1Yh1N$react.useEffect)(()=>{
@@ -963,23 +968,48 @@ function $9e20cff0af27e8cc$export$a11b0059900ceec8() {
963
968
  * OF ANY KIND, either express or implied. See the License for the specific language
964
969
  * governing permissions and limitations under the License.
965
970
  */
971
+ /*
972
+ * Copyright 2023 Adobe. All rights reserved.
973
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
974
+ * you may not use this file except in compliance with the License. You may obtain a copy
975
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
976
+ *
977
+ * Unless required by applicable law or agreed to in writing, software distributed under
978
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
979
+ * OF ANY KIND, either express or implied. See the License for the specific language
980
+ * governing permissions and limitations under the License.
981
+ */
982
+
983
+ function $1254e5bb94ac8761$export$7f54fc3180508a52(fn) {
984
+ const ref = (0, $1Yh1N$react.useRef)(null);
985
+ (0, $78605a5d7424e31b$export$e5c5a5f917a5871c)(()=>{
986
+ ref.current = fn;
987
+ }, [
988
+ fn
989
+ ]);
990
+ return (0, $1Yh1N$react.useCallback)((...args)=>{
991
+ const f = ref.current;
992
+ return f(...args);
993
+ }, []);
994
+ }
995
+
996
+
966
997
  function $2a8c0bb1629926c8$export$90fc3a17d93f704c(ref, event, handler, options) {
967
- let handlerRef = (0, $1Yh1N$react.useRef)(handler);
968
- handlerRef.current = handler;
998
+ let handleEvent = (0, $1254e5bb94ac8761$export$7f54fc3180508a52)(handler);
969
999
  let isDisabled = handler == null;
970
1000
  (0, $1Yh1N$react.useEffect)(()=>{
971
1001
  if (isDisabled) return;
972
1002
  let element = ref.current;
973
- let handler = (e)=>handlerRef.current.call(this, e);
974
- element.addEventListener(event, handler, options);
1003
+ element.addEventListener(event, handleEvent, options);
975
1004
  return ()=>{
976
- element.removeEventListener(event, handler, options);
1005
+ element.removeEventListener(event, handleEvent, options);
977
1006
  };
978
1007
  }, [
979
1008
  ref,
980
1009
  event,
981
1010
  options,
982
- isDisabled
1011
+ isDisabled,
1012
+ handleEvent
983
1013
  ]);
984
1014
  }
985
1015
 
@@ -1107,6 +1137,28 @@ function $577e795361f19be9$export$29bf1b5f2c56cf63(event) {
1107
1137
  }
1108
1138
 
1109
1139
 
1140
+
1141
+ /*
1142
+ * Copyright 2023 Adobe. All rights reserved.
1143
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1144
+ * you may not use this file except in compliance with the License. You may obtain a copy
1145
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
1146
+ *
1147
+ * Unless required by applicable law or agreed to in writing, software distributed under
1148
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1149
+ * OF ANY KIND, either express or implied. See the License for the specific language
1150
+ * governing permissions and limitations under the License.
1151
+ */ /* eslint-disable rulesdir/pure-render */
1152
+ function $20e6e72fbf5dc81e$export$722debc0e56fea39(value, isEqual) {
1153
+ // Using a ref during render is ok here because it's only an optimization – both values are equivalent.
1154
+ // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.
1155
+ let lastValue = (0, $1Yh1N$react.useRef)(null);
1156
+ if (value && lastValue.current && isEqual(value, lastValue.current)) value = lastValue.current;
1157
+ lastValue.current = value;
1158
+ return value;
1159
+ }
1160
+
1161
+
1110
1162
  /*
1111
1163
  * Copyright 2023 Adobe. All rights reserved.
1112
1164
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1119,17 +1171,22 @@ function $577e795361f19be9$export$29bf1b5f2c56cf63(event) {
1119
1171
  * governing permissions and limitations under the License.
1120
1172
  */
1121
1173
 
1122
- function $1254e5bb94ac8761$export$7f54fc3180508a52(fn) {
1123
- const ref = (0, $1Yh1N$react.useRef)(null);
1124
- (0, $78605a5d7424e31b$export$e5c5a5f917a5871c)(()=>{
1125
- ref.current = fn;
1174
+ function $1f205e845604a423$export$5add1d006293d136(ref, initialValue, onReset) {
1175
+ let resetValue = (0, $1Yh1N$react.useRef)(initialValue);
1176
+ let handleReset = (0, $1254e5bb94ac8761$export$7f54fc3180508a52)(()=>{
1177
+ if (onReset) onReset(resetValue.current);
1178
+ });
1179
+ (0, $1Yh1N$react.useEffect)(()=>{
1180
+ var _ref_current;
1181
+ let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
1182
+ form === null || form === void 0 ? void 0 : form.addEventListener("reset", handleReset);
1183
+ return ()=>{
1184
+ form === null || form === void 0 ? void 0 : form.removeEventListener("reset", handleReset);
1185
+ };
1126
1186
  }, [
1127
- fn
1187
+ ref,
1188
+ handleReset
1128
1189
  ]);
1129
- return (0, $1Yh1N$react.useCallback)((...args)=>{
1130
- const f = ref.current;
1131
- return f(...args);
1132
- }, []);
1133
1190
  }
1134
1191
 
1135
1192