@dloizides/ui-forms 1.34.0 → 1.34.1

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/index.js CHANGED
@@ -2730,12 +2730,6 @@ var styles22 = reactNative.StyleSheet.create({
2730
2730
  sheetList: { maxHeight: SHEET_MAX_HEIGHT },
2731
2731
  empty: { padding: PANEL_PAD }
2732
2732
  });
2733
- var AFTER_SURFACE_UNMOUNT_MS = 0;
2734
- function useDeferredFocus(ref) {
2735
- return React2.useCallback(() => {
2736
- setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
2737
- }, [ref]);
2738
- }
2739
2733
  function useReducedMotion() {
2740
2734
  const [reduced, setReduced] = React2.useState(false);
2741
2735
  React2.useEffect(() => {
@@ -2751,6 +2745,13 @@ function useReducedMotion() {
2751
2745
  }, []);
2752
2746
  return reduced;
2753
2747
  }
2748
+ function useRefocusOnClose(open, ref) {
2749
+ const wasOpen = React2.useRef(false);
2750
+ React2.useEffect(() => {
2751
+ if (wasOpen.current && !open) ref.current?.focus();
2752
+ wasOpen.current = open;
2753
+ }, [open, ref]);
2754
+ }
2754
2755
 
2755
2756
  // src/SearchSelect/utils/searchSelectModel.ts
2756
2757
  var MIN_QUERY = 1;
@@ -2828,6 +2829,7 @@ function resolveSelectMotion(width, reducedMotion) {
2828
2829
  }
2829
2830
  var CHEVRON = "\u25BE";
2830
2831
  var VALUE_GAP = 8;
2832
+ var NOTHING_ON_CLOSE = () => void 0;
2831
2833
  function SearchSelect(props) {
2832
2834
  const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail } = props;
2833
2835
  const { theme } = uiFeedback.useUi();
@@ -2837,8 +2839,8 @@ function SearchSelect(props) {
2837
2839
  const { width } = reactNative.useWindowDimensions();
2838
2840
  const motion = resolveSelectMotion(width, useReducedMotion());
2839
2841
  const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
2840
- const refocus = useDeferredFocus(triggerRef);
2841
- const state = useSearchSelectState(options, recents, onChange, refocus);
2842
+ const state = useSearchSelectState(options, recents, onChange, NOTHING_ON_CLOSE);
2843
+ useRefocusOnClose(state.open, triggerRef);
2842
2844
  const selected = findOption(options, value);
2843
2845
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles23.anchor, children: [
2844
2846
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2891,6 +2893,12 @@ function useOutsidePress(ref, onOutside) {
2891
2893
  return () => document.removeEventListener("pointerdown", onPointerDown, true);
2892
2894
  }, [ref, onOutside]);
2893
2895
  }
2896
+ var AFTER_SURFACE_UNMOUNT_MS = 0;
2897
+ function useDeferredFocus(ref) {
2898
+ return React2.useCallback(() => {
2899
+ setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
2900
+ }, [ref]);
2901
+ }
2894
2902
 
2895
2903
  // src/CountryFlag/data/flagPalette.ts
2896
2904
  var FLAG_PALETTE = {