react-native-ui-lib 8.4.2-snapshot.7918 → 8.4.2
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/lib/package.json +1 -1
- package/package.json +5 -4
- package/src/components/WheelPicker/usePresenter.d.ts +1 -0
- package/src/components/chipsInput/index.d.ts +0 -2
- package/src/components/colorPicker/ColorPickerPresenter.d.ts +1 -1
- package/src/components/floatingButton/index.js +5 -8
- package/src/components/textField/TextField.driver.new.js +12 -7
- package/src/components/textField/index.js +31 -9
- package/src/helpers/AvatarHelper.d.ts +1 -1
- package/src/incubator/slider/Thumb.js +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +0 -14
- package/src/testkit/Component.driver.d.ts +1 -0
- package/src/testkit/drivers/TestingLibraryDriver.d.ts +1 -0
package/lib/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-ui-lib",
|
|
3
|
-
"version": "8.4.2
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"author": "Ethan Sharabi <ethan.shar@gmail.com>",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"date-fns": "^2.29.3",
|
|
35
35
|
"deprecated-react-native-prop-types": "^2.3.0",
|
|
36
36
|
"hoist-non-react-statics": "^3.0.0",
|
|
37
|
-
"lodash": "4.
|
|
37
|
+
"lodash": "^4.17.21",
|
|
38
38
|
"memoize-one": "^5.0.5",
|
|
39
39
|
"prop-types": "^15.5.10",
|
|
40
40
|
"react-freeze": "^1.0.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@react-native/metro-config": "0.77.3",
|
|
67
67
|
"@react-native/typescript-config": "0.77.3",
|
|
68
68
|
"@shopify/flash-list": "1.7.6",
|
|
69
|
-
"@testing-library/react-native": "
|
|
69
|
+
"@testing-library/react-native": "^11.5.1",
|
|
70
70
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
71
71
|
"@types/jest": "^29.5.13",
|
|
72
72
|
"@types/lodash": "^4.0.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"light-date": "^1.2.0",
|
|
83
83
|
"moment": "^2.24.0",
|
|
84
84
|
"object-hash": "^3.0.0",
|
|
85
|
-
"postcss": "^8.
|
|
85
|
+
"postcss": "^8.4.21",
|
|
86
86
|
"postcss-js": "^4.0.0",
|
|
87
87
|
"prettier": "^3.2.5",
|
|
88
88
|
"react": "18.3.1",
|
|
@@ -112,6 +112,7 @@
|
|
|
112
112
|
"react-native": ">=0.77.3",
|
|
113
113
|
"react-native-gesture-handler": ">=2.24.0",
|
|
114
114
|
"react-native-reanimated": ">=3.17.5",
|
|
115
|
+
"react-native-safe-area-context": ">=5.6.2",
|
|
115
116
|
"uilib-native": "^5.0.1"
|
|
116
117
|
},
|
|
117
118
|
"jest": {
|
|
@@ -5,8 +5,6 @@ export declare enum ChipsInputChangeReason {
|
|
|
5
5
|
Added = "added",
|
|
6
6
|
Removed = "removed"
|
|
7
7
|
}
|
|
8
|
-
type ChipsInputChangeReasonUnion = `${ChipsInputChangeReason}`;
|
|
9
|
-
export type ChipsInputChangeReasonProps = ChipsInputChangeReasonUnion | ChipsInputChangeReason;
|
|
10
8
|
export type ChipsInputChipProps = ChipProps & {
|
|
11
9
|
invalid?: boolean;
|
|
12
10
|
};
|
|
@@ -12,5 +12,5 @@ export declare function getValidColorString(text?: string): {
|
|
|
12
12
|
valid: boolean;
|
|
13
13
|
hex?: undefined;
|
|
14
14
|
};
|
|
15
|
-
export declare function getHexString(color: HSLColor):
|
|
15
|
+
export declare function getHexString(color: HSLColor): string;
|
|
16
16
|
export declare function getTextColor(color: string): string;
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo } from 'react';
|
|
|
2
2
|
import { StyleSheet } from 'react-native';
|
|
3
3
|
import { asBaseComponent, Constants } from "../../commons/new";
|
|
4
4
|
import { LogService } from "../../services";
|
|
5
|
-
import { Colors, Shadows
|
|
5
|
+
import { Colors, Shadows } from "../../style";
|
|
6
6
|
import Button from "../button";
|
|
7
7
|
import ScreenFooter, { ScreenFooterLayouts, ScreenFooterBackgrounds, KeyboardBehavior, ItemsFit } from "../screenFooter";
|
|
8
8
|
export let FloatingButtonLayouts = /*#__PURE__*/function (FloatingButtonLayouts) {
|
|
@@ -35,19 +35,16 @@ const FloatingButton = props => {
|
|
|
35
35
|
// eslint-disable-next-line max-len
|
|
36
36
|
LogService.warn('RNUILib FloatingButton now uses ScreenFooter internally, which requires a SafeAreaProvider. If you experience safe area issues, please wrap your app (or the relevant screen) with <SafeAreaProvider>.');
|
|
37
37
|
}, []);
|
|
38
|
-
const isSecondaryOnly = !!secondaryButton && !button;
|
|
39
|
-
const isHorizontal = buttonLayout === FloatingButtonLayouts.HORIZONTAL || isSecondaryOnly;
|
|
40
38
|
const footerContentContainerStyle = useMemo(() => {
|
|
41
39
|
if (bottomMargin !== undefined) {
|
|
42
40
|
return {
|
|
43
41
|
paddingBottom: bottomMargin
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, [bottomMargin, secondaryButton, isSecondaryOnly, isHorizontal]);
|
|
44
|
+
return undefined;
|
|
45
|
+
}, [bottomMargin]);
|
|
46
|
+
const isSecondaryOnly = !!secondaryButton && !button;
|
|
47
|
+
const isHorizontal = buttonLayout === FloatingButtonLayouts.HORIZONTAL || isSecondaryOnly;
|
|
51
48
|
if (!button && !secondaryButton) {
|
|
52
49
|
return null;
|
|
53
50
|
}
|
|
@@ -9,6 +9,10 @@ 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);
|
|
12
16
|
const floatingPlaceholderDriver = TextDriver({
|
|
13
17
|
renderTree: props.renderTree,
|
|
14
18
|
testID: `${props.testID}.floatingPlaceholder`
|
|
@@ -41,30 +45,31 @@ export const TextFieldDriver = (props, options) => {
|
|
|
41
45
|
renderTree: props.renderTree,
|
|
42
46
|
testID: `${props.testID}.clearButton.container`
|
|
43
47
|
});
|
|
48
|
+
const getInputElement = () => inputDriver.queryElement() ?? driver.getElement();
|
|
44
49
|
const getValue = () => {
|
|
45
|
-
return
|
|
50
|
+
return getInputElement().props.value ?? getInputElement().props.defaultValue;
|
|
46
51
|
};
|
|
47
52
|
const changeText = text => {
|
|
48
|
-
fireEvent.changeText(
|
|
53
|
+
fireEvent.changeText(getInputElement(), text);
|
|
49
54
|
};
|
|
50
55
|
const focus = () => {
|
|
51
|
-
fireEvent(
|
|
56
|
+
fireEvent(getInputElement(), 'focus');
|
|
52
57
|
};
|
|
53
58
|
const blur = () => {
|
|
54
|
-
fireEvent(
|
|
59
|
+
fireEvent(getInputElement(), 'blur');
|
|
55
60
|
};
|
|
56
61
|
const isEnabled = () => {
|
|
57
|
-
return !
|
|
62
|
+
return !getInputElement().props.accessibilityState?.disabled;
|
|
58
63
|
};
|
|
59
64
|
const getPlaceholder = () => {
|
|
60
65
|
const exists = () => {
|
|
61
|
-
const hasPlaceholder = !!
|
|
66
|
+
const hasPlaceholder = !!getInputElement().props.placeholder;
|
|
62
67
|
const hasText = !!getValue();
|
|
63
68
|
return hasPlaceholder && (!hasText || hasText && floatingPlaceholderDriver.exists());
|
|
64
69
|
};
|
|
65
70
|
const getText = () => {
|
|
66
71
|
if (exists()) {
|
|
67
|
-
return
|
|
72
|
+
return getInputElement().props.placeholder;
|
|
68
73
|
}
|
|
69
74
|
};
|
|
70
75
|
return {
|
|
@@ -78,6 +78,8 @@ const TextField = props => {
|
|
|
78
78
|
readonly = false,
|
|
79
79
|
showMandatoryIndication,
|
|
80
80
|
clearButtonStyle,
|
|
81
|
+
testID,
|
|
82
|
+
accessibilityLabel: accessibilityLabelProp,
|
|
81
83
|
...others
|
|
82
84
|
} = usePreset(props);
|
|
83
85
|
const {
|
|
@@ -135,11 +137,31 @@ const TextField = props => {
|
|
|
135
137
|
const hasValue = fieldState.value !== undefined; // NOTE: not pressable if centered without a value (so can't center placeholder)
|
|
136
138
|
const inputStyle = useMemo(() => [typographyStyle, colorStyle, others.style, hasValue && centeredTextStyle], [typographyStyle, colorStyle, others.style, centeredTextStyle, hasValue]);
|
|
137
139
|
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;
|
|
138
160
|
return <FieldContext.Provider value={context}>
|
|
139
|
-
<View {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
|
|
161
|
+
<View {...containerProps} testID={testID} accessible accessibilityLabel={accessibilityLabel} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
|
|
140
162
|
<View row spread style={centeredContainerStyle}>
|
|
141
|
-
<Label label={label} labelColor={labelColor} labelStyle={_labelStyle} labelProps={labelProps} floatingPlaceholder={floatingPlaceholder} validationMessagePosition={validationMessagePosition} testID={`${
|
|
142
|
-
{validationMessagePosition === ValidationMessagePosition.TOP && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace && retainTopMessageSpace} testID={`${
|
|
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`} />}
|
|
143
165
|
{topTrailingAccessory && <View>{topTrailingAccessory}</View>}
|
|
144
166
|
</View>
|
|
145
167
|
<View style={[paddings, fieldStyle]} row centerV centerH={centered}>
|
|
@@ -158,26 +180,26 @@ const TextField = props => {
|
|
|
158
180
|
{Constants.isAndroid && centered && <Text marginR-s1 style={dummyPlaceholderStyle}>
|
|
159
181
|
{placeholder}
|
|
160
182
|
</Text>}
|
|
161
|
-
{floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${
|
|
183
|
+
{floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${testID}.floatingPlaceholder`} showMandatoryIndication={showMandatoryIndication} />}
|
|
162
184
|
<Input hitSlop={{
|
|
163
185
|
top: 20,
|
|
164
186
|
bottom: 20
|
|
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} />
|
|
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} />
|
|
166
188
|
</View>}
|
|
167
|
-
{showClearButton && <ClearButton onClear={onClear} testID={`${
|
|
189
|
+
{showClearButton && <ClearButton onClear={onClear} testID={`${testID}.clearButton`} onChangeText={onChangeText} clearButtonStyle={clearButtonStyle} />}
|
|
168
190
|
{trailingAccessory}
|
|
169
191
|
{/* </View> */}
|
|
170
192
|
</View>
|
|
171
193
|
<View row spread center={centered}>
|
|
172
194
|
<View flex={!centered} flexG={centered} marginR-s4={showCharCounter}>
|
|
173
|
-
{validationMessagePosition === ValidationMessagePosition.BOTTOM && <ValidationMessage enableErrors={enableErrors} validate={others.validate} validationMessage={others.validationMessage} validationIcon={validationIcon} validationMessageStyle={_validationMessageStyle} retainValidationSpace={retainValidationSpace} testID={`${
|
|
174
|
-
{helperText && <Text $textNeutralHeavy subtext marginT-s1 testID={`${
|
|
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`}>
|
|
175
197
|
{helperText}
|
|
176
198
|
</Text>}
|
|
177
199
|
{bottomAccessory}
|
|
178
200
|
</View>
|
|
179
201
|
<View>
|
|
180
|
-
{showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle} testID={`${
|
|
202
|
+
{showCharCounter && <CharCounter maxLength={others.maxLength} charCounterStyle={charCounterStyle} testID={`${testID}.charCounter`} />}
|
|
181
203
|
</View>
|
|
182
204
|
</View>
|
|
183
205
|
</View>
|
|
@@ -2,7 +2,7 @@ export declare function getInitialsTypography(size: number): import("react-nativ
|
|
|
2
2
|
export declare function hashStringToNumber(str?: string): number;
|
|
3
3
|
export declare function getAvatarColors(): string[];
|
|
4
4
|
export declare function getColorById(id: string, avatarColors?: string[]): string;
|
|
5
|
-
export declare function getInitials(name?: string, limit?: number):
|
|
5
|
+
export declare function getInitials(name?: string, limit?: number): string;
|
|
6
6
|
export declare function getBackgroundColor(name?: string, avatarColors?: string[], hashFunction?: (name?: string) => number, defaultColor?: string): string | undefined;
|
|
7
7
|
export declare function isGravatarUrl(url: string): boolean;
|
|
8
8
|
export declare function isBlankGravatarUrl(url: string): boolean;
|
|
@@ -40,7 +40,7 @@ const Thumb = props => {
|
|
|
40
40
|
height: THUMB_SIZE
|
|
41
41
|
});
|
|
42
42
|
const lastOffset = useSharedValue(0);
|
|
43
|
-
const gesture = Gesture.Pan().
|
|
43
|
+
const gesture = Gesture.Pan().onBegin(() => {
|
|
44
44
|
onSeekStart?.();
|
|
45
45
|
isPressed.value = true;
|
|
46
46
|
lastOffset.value = offset.value;
|
package/src/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { default as Button, ButtonProps, ButtonSize, ButtonAnimationDirection }
|
|
|
23
23
|
export { default as Card, CardProps, CardSectionProps, CardSelectionOptions } from './components/card';
|
|
24
24
|
export { default as Carousel, CarouselProps, PageControlPosition } from './components/carousel';
|
|
25
25
|
export { default as Checkbox, CheckboxProps, CheckboxRef } from './components/checkbox';
|
|
26
|
-
export { default as ChipsInput, ChipsInputProps, ChipsInputChipProps
|
|
26
|
+
export { default as ChipsInput, ChipsInputProps, ChipsInputChipProps } from './components/chipsInput';
|
|
27
27
|
export { default as Chip, ChipProps } from './components/chip';
|
|
28
28
|
export { default as ColorPicker, ColorPickerProps } from './components/colorPicker';
|
|
29
29
|
export { default as ColorPalette, ColorPaletteProps } from './components/colorPalette';
|
package/src/index.js
CHANGED
|
@@ -61,8 +61,6 @@ var _exportNames = {
|
|
|
61
61
|
ChipsInput: true,
|
|
62
62
|
ChipsInputProps: true,
|
|
63
63
|
ChipsInputChipProps: true,
|
|
64
|
-
ChipsInputChangeReason: true,
|
|
65
|
-
ChipsInputChangeReasonProps: true,
|
|
66
64
|
Chip: true,
|
|
67
65
|
ChipProps: true,
|
|
68
66
|
ColorPicker: true,
|
|
@@ -434,18 +432,6 @@ Object.defineProperty(exports, "ChipsInput", {
|
|
|
434
432
|
return _chipsInput().default;
|
|
435
433
|
}
|
|
436
434
|
});
|
|
437
|
-
Object.defineProperty(exports, "ChipsInputChangeReason", {
|
|
438
|
-
enumerable: true,
|
|
439
|
-
get: function () {
|
|
440
|
-
return _chipsInput().ChipsInputChangeReason;
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
Object.defineProperty(exports, "ChipsInputChangeReasonProps", {
|
|
444
|
-
enumerable: true,
|
|
445
|
-
get: function () {
|
|
446
|
-
return _chipsInput().ChipsInputChangeReasonProps;
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
435
|
Object.defineProperty(exports, "ChipsInputChipProps", {
|
|
450
436
|
enumerable: true,
|
|
451
437
|
get: function () {
|