react-native-ui-lib 8.4.1-snapshot.7915 → 8.4.2-snapshot.7918

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.4.1-snapshot.7915",
3
+ "version": "8.4.2-snapshot.7918",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -9,10 +9,6 @@ import { ButtonDriver } from "../button/Button.driver.new";
9
9
  import { ViewDriver } from "../view/View.driver.new";
10
10
  export const TextFieldDriver = (props, options) => {
11
11
  const driver = usePressableDriver(useComponentDriver(props, options));
12
- const inputDriver = useComponentDriver({
13
- renderTree: props.renderTree,
14
- testID: `${props.testID}.input`
15
- }, options);
16
12
  const floatingPlaceholderDriver = TextDriver({
17
13
  renderTree: props.renderTree,
18
14
  testID: `${props.testID}.floatingPlaceholder`
@@ -45,31 +41,30 @@ export const TextFieldDriver = (props, options) => {
45
41
  renderTree: props.renderTree,
46
42
  testID: `${props.testID}.clearButton.container`
47
43
  });
48
- const getInputElement = () => inputDriver.queryElement() ?? driver.getElement();
49
44
  const getValue = () => {
50
- return getInputElement().props.value ?? getInputElement().props.defaultValue;
45
+ return driver.getElement().props.value ?? driver.getElement().props.defaultValue;
51
46
  };
52
47
  const changeText = text => {
53
- fireEvent.changeText(getInputElement(), text);
48
+ fireEvent.changeText(driver.getElement(), text);
54
49
  };
55
50
  const focus = () => {
56
- fireEvent(getInputElement(), 'focus');
51
+ fireEvent(driver.getElement(), 'focus');
57
52
  };
58
53
  const blur = () => {
59
- fireEvent(getInputElement(), 'blur');
54
+ fireEvent(driver.getElement(), 'blur');
60
55
  };
61
56
  const isEnabled = () => {
62
- return !getInputElement().props.accessibilityState?.disabled;
57
+ return !driver.getElement().props.accessibilityState?.disabled;
63
58
  };
64
59
  const getPlaceholder = () => {
65
60
  const exists = () => {
66
- const hasPlaceholder = !!getInputElement().props.placeholder;
61
+ const hasPlaceholder = !!driver.getElement().props.placeholder;
67
62
  const hasText = !!getValue();
68
63
  return hasPlaceholder && (!hasText || hasText && floatingPlaceholderDriver.exists());
69
64
  };
70
65
  const getText = () => {
71
66
  if (exists()) {
72
- return getInputElement().props.placeholder;
67
+ return driver.getElement().props.placeholder;
73
68
  }
74
69
  };
75
70
  return {
@@ -78,8 +78,6 @@ const TextField = props => {
78
78
  readonly = false,
79
79
  showMandatoryIndication,
80
80
  clearButtonStyle,
81
- testID,
82
- accessibilityLabel: accessibilityLabelProp,
83
81
  ...others
84
82
  } = usePreset(props);
85
83
  const {
@@ -137,31 +135,11 @@ const TextField = props => {
137
135
  const hasValue = fieldState.value !== undefined; // NOTE: not pressable if centered without a value (so can't center placeholder)
138
136
  const inputStyle = useMemo(() => [typographyStyle, colorStyle, others.style, hasValue && centeredTextStyle], [typographyStyle, colorStyle, others.style, centeredTextStyle, hasValue]);
139
137
  const dummyPlaceholderStyle = useMemo(() => [inputStyle, styles.dummyPlaceholder], [inputStyle]);
140
- const defaultAccessibilityLabel = useMemo(() => {
141
- const parts = [];
142
- if (label) {
143
- parts.push(label);
144
- }
145
- if (context.isMandatory) {
146
- parts.push('required');
147
- }
148
- parts.push('textField');
149
- if (helperText) {
150
- parts.push(helperText);
151
- } else if (placeholder) {
152
- parts.push(placeholder);
153
- }
154
- if (showCharCounter && others.maxLength) {
155
- parts.push(`you can enter up to ${others.maxLength} characters`);
156
- }
157
- return parts.join(', ');
158
- }, [label, context.isMandatory, helperText, placeholder, showCharCounter, others.maxLength]);
159
- const accessibilityLabel = accessibilityLabelProp ?? defaultAccessibilityLabel;
160
138
  return <FieldContext.Provider value={context}>
161
- <View {...containerProps} testID={testID} accessible accessibilityLabel={accessibilityLabel} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
139
+ <View {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
162
140
  <View row spread style={centeredContainerStyle}>
163
- <Label label={label} labelColor={labelColor} labelStyle={_labelStyle} labelProps={labelProps} floatingPlaceholder={floatingPlaceholder} validationMessagePosition={validationMessagePosition} testID={`${testID}.label`} showMandatoryIndication={showMandatoryIndication} enableErrors={enableErrors} />
164
- {validationMessagePosition === ValidationMessagePosition.TOP && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace && retainTopMessageSpace} testID={`${testID}.validationMessage`} />}
141
+ <Label label={label} labelColor={labelColor} labelStyle={_labelStyle} labelProps={labelProps} floatingPlaceholder={floatingPlaceholder} validationMessagePosition={validationMessagePosition} testID={`${props.testID}.label`} showMandatoryIndication={showMandatoryIndication} enableErrors={enableErrors} />
142
+ {validationMessagePosition === ValidationMessagePosition.TOP && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace && retainTopMessageSpace} testID={`${props.testID}.validationMessage`} />}
165
143
  {topTrailingAccessory && <View>{topTrailingAccessory}</View>}
166
144
  </View>
167
145
  <View style={[paddings, fieldStyle]} row centerV centerH={centered}>
@@ -180,26 +158,26 @@ const TextField = props => {
180
158
  {Constants.isAndroid && centered && <Text marginR-s1 style={dummyPlaceholderStyle}>
181
159
  {placeholder}
182
160
  </Text>}
183
- {floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${testID}.floatingPlaceholder`} showMandatoryIndication={showMandatoryIndication} />}
161
+ {floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${props.testID}.floatingPlaceholder`} showMandatoryIndication={showMandatoryIndication} />}
184
162
  <Input hitSlop={{
185
163
  top: 20,
186
164
  bottom: 20
187
- }} placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor} value={fieldState.value} {...others} testID={`${testID}.input`} readonly={readonly} style={inputStyle} onFocus={onFocus} onBlur={onBlur} onChangeText={onChangeText} placeholder={placeholder} hint={hint} showMandatoryIndication={showMandatoryIndication && !label} />
165
+ }} placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor} value={fieldState.value} {...others} readonly={readonly} style={inputStyle} onFocus={onFocus} onBlur={onBlur} onChangeText={onChangeText} placeholder={placeholder} hint={hint} showMandatoryIndication={showMandatoryIndication && !label} />
188
166
  </View>}
189
- {showClearButton && <ClearButton onClear={onClear} testID={`${testID}.clearButton`} onChangeText={onChangeText} clearButtonStyle={clearButtonStyle} />}
167
+ {showClearButton && <ClearButton onClear={onClear} testID={`${props.testID}.clearButton`} onChangeText={onChangeText} clearButtonStyle={clearButtonStyle} />}
190
168
  {trailingAccessory}
191
169
  {/* </View> */}
192
170
  </View>
193
171
  <View row spread center={centered}>
194
172
  <View flex={!centered} flexG={centered} marginR-s4={showCharCounter}>
195
- {validationMessagePosition === ValidationMessagePosition.BOTTOM && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationIcon={validationIcon} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace} testID={`${testID}.validationMessage`} />}
196
- {helperText && <Text $textNeutralHeavy subtext marginT-s1 testID={`${testID}.helperText`}>
173
+ {validationMessagePosition === ValidationMessagePosition.BOTTOM && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationIcon={validationIcon} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace} testID={`${props.testID}.validationMessage`} />}
174
+ {helperText && <Text $textNeutralHeavy subtext marginT-s1 testID={`${props.testID}.helperText`}>
197
175
  {helperText}
198
176
  </Text>}
199
177
  {bottomAccessory}
200
178
  </View>
201
179
  <View>
202
- {showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle} testID={`${testID}.charCounter`} />}
180
+ {showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle} testID={`${props.testID}.charCounter`} />}
203
181
  </View>
204
182
  </View>
205
183
  </View>