react-native-ui-lib 8.1.7 → 8.1.8-snapshot.7616
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/package.json
CHANGED
|
@@ -30,12 +30,19 @@ const usePickerSelection = props => {
|
|
|
30
30
|
const newValue = _xor(multiDraftValue, itemAsArray);
|
|
31
31
|
setMultiDraftValue(newValue);
|
|
32
32
|
}, [multiDraftValue]);
|
|
33
|
-
const
|
|
33
|
+
const resetSelectionState = useCallback(() => {
|
|
34
34
|
setSearchValue('');
|
|
35
35
|
setMultiDraftValue(multiFinalValue);
|
|
36
|
+
}, [multiFinalValue]);
|
|
37
|
+
const onDismiss = useCallback(() => {
|
|
38
|
+
resetSelectionState();
|
|
39
|
+
topBarProps?.onCancel?.();
|
|
40
|
+
}, [resetSelectionState, topBarProps]);
|
|
41
|
+
const cancelSelect = useCallback(() => {
|
|
42
|
+
resetSelectionState();
|
|
36
43
|
pickerExpandableRef.current?.closeExpandable?.();
|
|
37
44
|
topBarProps?.onCancel?.();
|
|
38
|
-
}, [
|
|
45
|
+
}, [resetSelectionState, topBarProps]);
|
|
39
46
|
const availableItems = useMemo(() => {
|
|
40
47
|
return items?.filter(item => !item.disabled).map(item => item.value) || [];
|
|
41
48
|
}, [items]);
|
|
@@ -55,7 +62,8 @@ const usePickerSelection = props => {
|
|
|
55
62
|
cancelSelect,
|
|
56
63
|
areAllItemsSelected,
|
|
57
64
|
selectedCount,
|
|
58
|
-
toggleAllItemsSelection
|
|
65
|
+
toggleAllItemsSelection,
|
|
66
|
+
onDismiss
|
|
59
67
|
};
|
|
60
68
|
};
|
|
61
69
|
export default usePickerSelection;
|
|
@@ -95,7 +95,8 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
95
95
|
cancelSelect,
|
|
96
96
|
areAllItemsSelected,
|
|
97
97
|
selectedCount,
|
|
98
|
-
toggleAllItemsSelection
|
|
98
|
+
toggleAllItemsSelection,
|
|
99
|
+
onDismiss
|
|
99
100
|
} = usePickerSelection({
|
|
100
101
|
value,
|
|
101
102
|
onChange,
|
|
@@ -204,8 +205,12 @@ const Picker = React.forwardRef((props, ref) => {
|
|
|
204
205
|
{accessibleFilteredItems}
|
|
205
206
|
</PickerItemsList>;
|
|
206
207
|
}, [testID, mode, useDialog, selectedItemPosition, topBarProps, cancelSelect, onDoneSelecting, multiDraftValue, showSearch, searchStyle, searchPlaceholder, _onSearchChange, renderCustomSearch, renderHeader, listProps, accessibleFilteredItems, useSafeArea, useWheelPicker, items, showLoader]);
|
|
208
|
+
const dialogPropsWithDismiss = useMemo(() => ({
|
|
209
|
+
...DEFAULT_DIALOG_PROPS,
|
|
210
|
+
onDismiss
|
|
211
|
+
}), [onDismiss]);
|
|
207
212
|
return <PickerContext.Provider value={contextValue}>
|
|
208
|
-
{<ExpandableOverlay ref={pickerExpandable} useDialog={useDialog || useWheelPicker} dialogProps={
|
|
213
|
+
{<ExpandableOverlay ref={pickerExpandable} useDialog={useDialog || useWheelPicker} dialogProps={dialogPropsWithDismiss} expandableContent={expandableModalContent} renderCustomOverlay={renderOverlay ? _renderOverlay : undefined} onPress={onPress} testID={testID} {...customPickerProps} disabled={themeProps.editable === false}>
|
|
209
214
|
{renderTextField()}
|
|
210
215
|
</ExpandableOverlay>}
|
|
211
216
|
</PickerContext.Provider>;
|
|
@@ -78,6 +78,7 @@ const TextField = props => {
|
|
|
78
78
|
readonly = false,
|
|
79
79
|
showMandatoryIndication,
|
|
80
80
|
clearButtonStyle,
|
|
81
|
+
accessibilityLabel: accessibilityLabelProp,
|
|
81
82
|
...others
|
|
82
83
|
} = usePreset(props);
|
|
83
84
|
const {
|
|
@@ -135,8 +136,28 @@ const TextField = props => {
|
|
|
135
136
|
const hasValue = fieldState.value !== undefined; // NOTE: not pressable if centered without a value (so can't center placeholder)
|
|
136
137
|
const inputStyle = useMemo(() => [typographyStyle, colorStyle, others.style, hasValue && centeredTextStyle], [typographyStyle, colorStyle, others.style, centeredTextStyle, hasValue]);
|
|
137
138
|
const dummyPlaceholderStyle = useMemo(() => [inputStyle, styles.dummyPlaceholder], [inputStyle]);
|
|
139
|
+
const defaultAccessibilityLabel = useMemo(() => {
|
|
140
|
+
const parts = [];
|
|
141
|
+
if (label) {
|
|
142
|
+
parts.push(label);
|
|
143
|
+
}
|
|
144
|
+
if (context.isMandatory) {
|
|
145
|
+
parts.push('required');
|
|
146
|
+
}
|
|
147
|
+
parts.push('textField');
|
|
148
|
+
if (helperText) {
|
|
149
|
+
parts.push(helperText);
|
|
150
|
+
} else if (placeholder) {
|
|
151
|
+
parts.push(placeholder);
|
|
152
|
+
}
|
|
153
|
+
if (showCharCounter && others.maxLength) {
|
|
154
|
+
parts.push(`you can enter up to ${others.maxLength} characters`);
|
|
155
|
+
}
|
|
156
|
+
return parts.join(', ');
|
|
157
|
+
}, [label, context.isMandatory, helperText, placeholder, showCharCounter, others.maxLength]);
|
|
158
|
+
const accessibilityLabel = accessibilityLabelProp ?? defaultAccessibilityLabel;
|
|
138
159
|
return <FieldContext.Provider value={context}>
|
|
139
|
-
<View {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
|
|
160
|
+
<View {...containerProps} accessible accessibilityLabel={accessibilityLabel} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
|
|
140
161
|
<View row spread style={centeredContainerStyle}>
|
|
141
162
|
<Label label={label} labelColor={labelColor} labelStyle={_labelStyle} labelProps={labelProps} floatingPlaceholder={floatingPlaceholder} validationMessagePosition={validationMessagePosition} testID={`${props.testID}.label`} showMandatoryIndication={showMandatoryIndication} enableErrors={enableErrors} />
|
|
142
163
|
{validationMessagePosition === ValidationMessagePosition.TOP && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace && retainTopMessageSpace} testID={`${props.testID}.validationMessage`} />}
|