react-native-ui-lib 8.1.8 → 8.2.0-snapshot.7650

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ui-lib",
3
- "version": "8.1.8",
3
+ "version": "8.2.0-snapshot.7650",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -12,5 +12,6 @@ declare const usePickerSelection: (props: UsePickerSelectionProps) => {
12
12
  areAllItemsSelected: boolean;
13
13
  selectedCount: number;
14
14
  toggleAllItemsSelection: (selectAll: boolean) => void;
15
+ onDismiss: () => void;
15
16
  };
16
17
  export default usePickerSelection;
@@ -30,12 +30,19 @@ const usePickerSelection = props => {
30
30
  const newValue = _xor(multiDraftValue, itemAsArray);
31
31
  setMultiDraftValue(newValue);
32
32
  }, [multiDraftValue]);
33
- const cancelSelect = useCallback(() => {
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
- }, [multiFinalValue, topBarProps]);
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={DEFAULT_DIALOG_PROPS} expandableContent={expandableModalContent} renderCustomOverlay={renderOverlay ? _renderOverlay : undefined} onPress={onPress} testID={testID} {...customPickerProps} disabled={themeProps.editable === false}>
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>;
@@ -15,8 +15,17 @@ interface Props {
15
15
  fullWidth?: boolean;
16
16
  /**
17
17
  * Override container style
18
+ * @deprecated Use containerStyle instead
18
19
  */
19
20
  style?: StyleProp<ViewStyle>;
21
+ /**
22
+ * Override container style
23
+ */
24
+ containerStyle?: StyleProp<ViewStyle>;
25
+ /**
26
+ * Override progress style
27
+ */
28
+ progressStyle?: StyleProp<ViewStyle>;
20
29
  /**
21
30
  * Progress color
22
31
  */
@@ -105,7 +105,9 @@ class ProgressBar extends PureComponent {
105
105
  render() {
106
106
  const {
107
107
  style,
108
- testID
108
+ containerStyle,
109
+ testID,
110
+ progressStyle
109
111
  } = this.props;
110
112
  const {
111
113
  containerWidth = 0
@@ -115,12 +117,13 @@ class ProgressBar extends PureComponent {
115
117
  inputRange: [0, 100],
116
118
  outputRange
117
119
  });
118
- return <View onLayout={this.getContainerWidth} style={[styles.container, this.getContainerStyle(), style]} {...this.getAccessibilityProps()} testID={testID}>
119
- {!!containerWidth && <Animated.View style={[styles.progress, this.getProgressStyle(), {
120
- transform: [{
121
- translateX: newProgress
122
- }]
123
- }]}>
120
+ const animatedStyle = {
121
+ transform: [{
122
+ translateX: newProgress
123
+ }]
124
+ };
125
+ return <View onLayout={this.getContainerWidth} style={[styles.container, this.getContainerStyle(), style, containerStyle]} {...this.getAccessibilityProps()} testID={testID}>
126
+ {!!containerWidth && <Animated.View style={[styles.progress, this.getProgressStyle(), progressStyle, animatedStyle]}>
124
127
  {this.renderCustomElement()}
125
128
  </Animated.View>}
126
129
  </View>;
@@ -16,10 +16,15 @@
16
16
  "description": "FullWidth Ui preset"
17
17
  },
18
18
  {
19
- "name": "style",
19
+ "name": "containerStyle",
20
20
  "type": "ViewStyle",
21
21
  "description": "Override container style"
22
22
  },
23
+ {
24
+ "name": "progressStyle",
25
+ "type": "ViewStyle",
26
+ "description": "Override progress style"
27
+ },
23
28
  {
24
29
  "name": "progressColor",
25
30
  "type": "string",
@@ -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`} />}