@dloizides/ui-forms 1.37.0 → 1.38.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/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1316,8 +1316,9 @@ interface SearchSelectProps {
|
|
|
1316
1316
|
renderLeading?: (option: ControlOption) => React.ReactNode;
|
|
1317
1317
|
renderDetail?: (option: ControlOption) => React.ReactNode;
|
|
1318
1318
|
renderTrigger?: (trigger: SearchSelectTrigger) => React.ReactNode;
|
|
1319
|
+
onBlur?: () => void;
|
|
1319
1320
|
}
|
|
1320
|
-
/** A select you can type into to filter; `renderTrigger` swaps the field box for your own visual. */
|
|
1321
|
+
/** A select you can type into to filter; `renderTrigger` swaps the field box for your own visual; `onBlur` fires when focus leaves the closed field. */
|
|
1321
1322
|
declare function SearchSelect(props: SearchSelectProps): React.ReactElement;
|
|
1322
1323
|
|
|
1323
1324
|
/** How the option list opens: a sheet from below (phone) or a list unfolding under the field. */
|
|
@@ -1452,9 +1453,10 @@ interface CountryFieldProps {
|
|
|
1452
1453
|
testID: string;
|
|
1453
1454
|
countries?: readonly Country[];
|
|
1454
1455
|
noneLabel?: string;
|
|
1456
|
+
onBlur?: () => void;
|
|
1455
1457
|
}
|
|
1456
|
-
/** A searchable country field: flag, name and grey code; stores the ISO 3166-1 alpha-2 code, or '' for `noneLabel
|
|
1457
|
-
declare function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel }: CountryFieldProps): React.ReactElement;
|
|
1458
|
+
/** A searchable country field: flag, name and grey code; stores the ISO 3166-1 alpha-2 code, or '' for `noneLabel`; `onBlur` fires when focus leaves the closed field. */
|
|
1459
|
+
declare function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }: CountryFieldProps): React.ReactElement;
|
|
1458
1460
|
|
|
1459
1461
|
/** ISO 3166-1 alpha-2 countries (249) with English short names. */
|
|
1460
1462
|
declare const COUNTRIES: readonly Country[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1316,8 +1316,9 @@ interface SearchSelectProps {
|
|
|
1316
1316
|
renderLeading?: (option: ControlOption) => React.ReactNode;
|
|
1317
1317
|
renderDetail?: (option: ControlOption) => React.ReactNode;
|
|
1318
1318
|
renderTrigger?: (trigger: SearchSelectTrigger) => React.ReactNode;
|
|
1319
|
+
onBlur?: () => void;
|
|
1319
1320
|
}
|
|
1320
|
-
/** A select you can type into to filter; `renderTrigger` swaps the field box for your own visual. */
|
|
1321
|
+
/** A select you can type into to filter; `renderTrigger` swaps the field box for your own visual; `onBlur` fires when focus leaves the closed field. */
|
|
1321
1322
|
declare function SearchSelect(props: SearchSelectProps): React.ReactElement;
|
|
1322
1323
|
|
|
1323
1324
|
/** How the option list opens: a sheet from below (phone) or a list unfolding under the field. */
|
|
@@ -1452,9 +1453,10 @@ interface CountryFieldProps {
|
|
|
1452
1453
|
testID: string;
|
|
1453
1454
|
countries?: readonly Country[];
|
|
1454
1455
|
noneLabel?: string;
|
|
1456
|
+
onBlur?: () => void;
|
|
1455
1457
|
}
|
|
1456
|
-
/** A searchable country field: flag, name and grey code; stores the ISO 3166-1 alpha-2 code, or '' for `noneLabel
|
|
1457
|
-
declare function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel }: CountryFieldProps): React.ReactElement;
|
|
1458
|
+
/** A searchable country field: flag, name and grey code; stores the ISO 3166-1 alpha-2 code, or '' for `noneLabel`; `onBlur` fires when focus leaves the closed field. */
|
|
1459
|
+
declare function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }: CountryFieldProps): React.ReactElement;
|
|
1458
1460
|
|
|
1459
1461
|
/** ISO 3166-1 alpha-2 countries (249) with English short names. */
|
|
1460
1462
|
declare const COUNTRIES: readonly Country[];
|
package/dist/index.js
CHANGED
|
@@ -2872,7 +2872,7 @@ var VALUE_GAP = 8;
|
|
|
2872
2872
|
var MIN_TOUCH = 44;
|
|
2873
2873
|
var NOTHING_ON_CLOSE = () => void 0;
|
|
2874
2874
|
function SearchSelect(props) {
|
|
2875
|
-
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger } = props;
|
|
2875
|
+
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger, onBlur } = props;
|
|
2876
2876
|
const { theme } = uiFeedback.useUi();
|
|
2877
2877
|
const { colors } = theme;
|
|
2878
2878
|
const triggerRef = React2.useRef(null);
|
|
@@ -2884,6 +2884,11 @@ function SearchSelect(props) {
|
|
|
2884
2884
|
useRefocusOnClose(state.open, triggerRef);
|
|
2885
2885
|
const selected = findOption(options, value);
|
|
2886
2886
|
const onPress = state.open ? state.close : state.openList;
|
|
2887
|
+
const openRef = React2.useRef(state.open);
|
|
2888
|
+
openRef.current = state.open;
|
|
2889
|
+
const onTriggerBlur = React2.useCallback(() => {
|
|
2890
|
+
if (!openRef.current) onBlur?.();
|
|
2891
|
+
}, [onBlur]);
|
|
2887
2892
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles23.anchor, children: [
|
|
2888
2893
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2889
2894
|
reactNative.Pressable,
|
|
@@ -2895,6 +2900,7 @@ function SearchSelect(props) {
|
|
|
2895
2900
|
accessibilityState: { expanded: state.open },
|
|
2896
2901
|
style: renderTrigger === void 0 ? [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }] : styles23.customTrigger,
|
|
2897
2902
|
testID,
|
|
2903
|
+
onBlur: onTriggerBlur,
|
|
2898
2904
|
onPress,
|
|
2899
2905
|
children: renderTrigger !== void 0 ? renderTrigger({ open: state.open, selected, onPress, ref: triggerRef }) : /* @__PURE__ */ jsxRuntime.jsx(FieldBoxContent, { colors, placeholder: labels.placeholder, renderDetail, renderLeading, selected })
|
|
2900
2906
|
}
|
|
@@ -3690,7 +3696,7 @@ function toCountryValue(input) {
|
|
|
3690
3696
|
var CODE_FONT = 12;
|
|
3691
3697
|
var NO_COUNTRY2 = "";
|
|
3692
3698
|
var renderFlag = (option) => option.value === NO_COUNTRY2 ? null : /* @__PURE__ */ jsxRuntime.jsx(CountryFlag, { code: option.value });
|
|
3693
|
-
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel }) {
|
|
3699
|
+
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }) {
|
|
3694
3700
|
const { theme } = uiFeedback.useUi();
|
|
3695
3701
|
const { textSecondary } = theme.colors;
|
|
3696
3702
|
const options = React2.useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
|
|
@@ -3707,6 +3713,7 @@ function CountryField({ value, onChange, accessibilityLabel, accessibilityHint,
|
|
|
3707
3713
|
renderLeading: renderFlag,
|
|
3708
3714
|
testID,
|
|
3709
3715
|
value: toCountryValue(value),
|
|
3716
|
+
onBlur,
|
|
3710
3717
|
onChange
|
|
3711
3718
|
}
|
|
3712
3719
|
);
|