@hero-design/rn 8.102.0 → 8.103.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/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +12 -0
- package/es/index.js +5 -2
- package/lib/index.js +5 -2
- package/package.json +1 -1
- package/src/components/FAB/AnimatedFABIcon.tsx +3 -1
- package/src/components/Select/BaseOptionList.tsx +3 -3
- package/src/components/Select/MultiSelect/OptionList.tsx +3 -3
- package/src/components/Select/MultiSelect/index.tsx +6 -4
- package/src/components/Select/MultiSelect/utils.ts +2 -2
- package/src/components/Select/SingleSelect/OptionList.tsx +3 -3
- package/src/components/Select/SingleSelect/index.tsx +6 -4
- package/src/components/Select/helpers.tsx +11 -7
- package/src/components/Select/types.ts +6 -6
- package/src/components/Switch/SelectorSwitch/Option.tsx +2 -2
- package/src/components/Switch/SelectorSwitch/index.tsx +2 -2
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/TextInput/__tests__/index.spec.tsx +18 -7
- package/src/components/TextInput/index.tsx +3 -1
- package/src/types.ts +48 -2
- package/stats/8.103.0/rn-stats.html +4842 -0
- package/types/components/Alert/StyledAlert.d.ts +1 -1
- package/types/components/Avatar/StyledAvatar.d.ts +1 -1
- package/types/components/Badge/StyledBadge.d.ts +1 -1
- package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +4 -4
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +1 -1
- package/types/components/Carousel/StyledCarousel.d.ts +1 -1
- package/types/components/Checkbox/StyledCheckbox.d.ts +1 -1
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +1 -1
- package/types/components/FAB/StyledFAB.d.ts +1 -1
- package/types/components/PinInput/StyledPinInput.d.ts +2 -2
- package/types/components/Radio/StyledRadio.d.ts +1 -1
- package/types/components/Select/BaseOptionList.d.ts +3 -3
- package/types/components/Select/MultiSelect/OptionList.d.ts +3 -3
- package/types/components/Select/MultiSelect/index.d.ts +3 -3
- package/types/components/Select/MultiSelect/utils.d.ts +2 -2
- package/types/components/Select/SingleSelect/OptionList.d.ts +3 -3
- package/types/components/Select/SingleSelect/index.d.ts +3 -3
- package/types/components/Select/helpers.d.ts +6 -6
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +6 -6
- package/types/components/StatusScreens/Empty/StyledEmpty.d.ts +2 -2
- package/types/components/StatusScreens/Error/StyledError.d.ts +2 -2
- package/types/components/StatusScreens/Success/StyledSuccess.d.ts +2 -2
- package/types/components/Switch/SelectorSwitch/Option.d.ts +2 -2
- package/types/components/Switch/SelectorSwitch/index.d.ts +2 -2
- package/types/components/Tag/StyledTag.d.ts +1 -1
- package/types/components/TextInput/StyledTextInput.d.ts +4 -4
- package/types/components/Toast/StyledToast.d.ts +1 -1
- package/types/types.d.ts +22 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(node:
|
|
1
|
+
(node:3158) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
|
|
2
2
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
3
3
|
[36m
|
|
4
4
|
[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
@@ -15,9 +15,9 @@ node_modules/d3-selection/src/selection/index.js -> node_modules/d3-selection/sr
|
|
|
15
15
|
[7m [0m [91m ~~~~~~~~~~~~~~~~~~~[0m
|
|
16
16
|
[39m
|
|
17
17
|
[1m[33m(!) [plugin node-resolve] preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.[39m[22m
|
|
18
|
-
[32mcreated [1mlib/index.js, es/index.js[22m in [1m1m
|
|
18
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m1m 13.6s[22m[39m
|
|
19
19
|
[36m
|
|
20
20
|
[1m/home/runner/work/hero-design/hero-design/packages/rn/src/locales/en_AU.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/en_CA.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/index.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/types.ts[22m → [1m., .[22m...[39m
|
|
21
21
|
[1m[33m(!) Generated empty chunks[39m[22m
|
|
22
22
|
"locales/types" and "locales/types"
|
|
23
|
-
[32mcreated [1m., .[22m in [1m22.
|
|
23
|
+
[32mcreated [1m., .[22m in [1m22.8s[22m[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.103.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4006](https://github.com/Thinkei/hero-design/pull/4006) [`8ba84012be721c8a18a2ba9453b6cde66f8b3e49`](https://github.com/Thinkei/hero-design/commit/8ba84012be721c8a18a2ba9453b6cde66f8b3e49) Thanks [@hieuvo-eh](https://github.com/hieuvo-eh)! - Wrap StyledFABIcon with forwardRef
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#3980](https://github.com/Thinkei/hero-design/pull/3980) [`7e0859459ea48c43c9edcc01a64c80ab715b4d15`](https://github.com/Thinkei/hero-design/commit/7e0859459ea48c43c9edcc01a64c80ab715b4d15) Thanks [@cuongnguyeneh](https://github.com/cuongnguyeneh)! - [TextInput] Update testId of native text input
|
|
12
|
+
|
|
3
13
|
## 8.102.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -12,6 +22,8 @@
|
|
|
12
22
|
|
|
13
23
|
- [#3999](https://github.com/Thinkei/hero-design/pull/3999) [`28a6ab3090ec7d2a596de5c5838072b12f5c6104`](https://github.com/Thinkei/hero-design/commit/28a6ab3090ec7d2a596de5c5838072b12f5c6104) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [TextInput] Update internal border testID
|
|
14
24
|
|
|
25
|
+
- [#4002](https://github.com/Thinkei/hero-design/pull/4002) [`ffaa510e9dec7177e29a3afe1b2d07c012d14fd8`](https://github.com/Thinkei/hero-design/commit/ffaa510e9dec7177e29a3afe1b2d07c012d14fd8) Thanks [@ttkien](https://github.com/ttkien)! - export more types
|
|
26
|
+
|
|
15
27
|
## 8.101.3
|
|
16
28
|
|
|
17
29
|
### Patch Changes
|
package/es/index.js
CHANGED
|
@@ -20177,12 +20177,13 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref8, ref) {
|
|
|
20177
20177
|
}, [style, theme]),
|
|
20178
20178
|
backgroundColor = _useMemo2.backgroundColor,
|
|
20179
20179
|
styleWithoutBackgroundColor = _useMemo2.styleWithoutBackgroundColor;
|
|
20180
|
+
var nativeInputTestIDSuffix = testID ? "-".concat(testID) : '';
|
|
20180
20181
|
var nativeInputProps = _objectSpread2(_objectSpread2({
|
|
20181
20182
|
style: StyleSheet$1.flatten([{
|
|
20182
20183
|
backgroundColor: backgroundColor,
|
|
20183
20184
|
color: theme.__hd__.textInput.colors.text
|
|
20184
20185
|
}, textStyleWithoutBorderStyle]),
|
|
20185
|
-
testID:
|
|
20186
|
+
testID: "text-input".concat(nativeInputTestIDSuffix),
|
|
20186
20187
|
accessibilityState: {
|
|
20187
20188
|
disabled: state === 'disabled' || state === 'readonly'
|
|
20188
20189
|
},
|
|
@@ -22569,7 +22570,9 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
22569
22570
|
};
|
|
22570
22571
|
|
|
22571
22572
|
var _excluded$n = ["active"];
|
|
22572
|
-
var AnimatedIcons = Animated.createAnimatedComponent(
|
|
22573
|
+
var AnimatedIcons = Animated.createAnimatedComponent(/*#__PURE__*/React__default.forwardRef(function (props, _) {
|
|
22574
|
+
return /*#__PURE__*/React__default.createElement(StyledFABIcon, props);
|
|
22575
|
+
}));
|
|
22573
22576
|
var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
|
|
22574
22577
|
var active = _ref.active,
|
|
22575
22578
|
iconProps = _objectWithoutProperties(_ref, _excluded$n);
|
package/lib/index.js
CHANGED
|
@@ -20206,12 +20206,13 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
20206
20206
|
}, [style, theme]),
|
|
20207
20207
|
backgroundColor = _useMemo2.backgroundColor,
|
|
20208
20208
|
styleWithoutBackgroundColor = _useMemo2.styleWithoutBackgroundColor;
|
|
20209
|
+
var nativeInputTestIDSuffix = testID ? "-".concat(testID) : '';
|
|
20209
20210
|
var nativeInputProps = _objectSpread2(_objectSpread2({
|
|
20210
20211
|
style: reactNative.StyleSheet.flatten([{
|
|
20211
20212
|
backgroundColor: backgroundColor,
|
|
20212
20213
|
color: theme.__hd__.textInput.colors.text
|
|
20213
20214
|
}, textStyleWithoutBorderStyle]),
|
|
20214
|
-
testID:
|
|
20215
|
+
testID: "text-input".concat(nativeInputTestIDSuffix),
|
|
20215
20216
|
accessibilityState: {
|
|
20216
20217
|
disabled: state === 'disabled' || state === 'readonly'
|
|
20217
20218
|
},
|
|
@@ -22598,7 +22599,9 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
22598
22599
|
};
|
|
22599
22600
|
|
|
22600
22601
|
var _excluded$n = ["active"];
|
|
22601
|
-
var AnimatedIcons = reactNative.Animated.createAnimatedComponent(
|
|
22602
|
+
var AnimatedIcons = reactNative.Animated.createAnimatedComponent(/*#__PURE__*/React__namespace.default.forwardRef(function (props, _) {
|
|
22603
|
+
return /*#__PURE__*/React__namespace.default.createElement(StyledFABIcon, props);
|
|
22604
|
+
}));
|
|
22602
22605
|
var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
|
|
22603
22606
|
var active = _ref.active,
|
|
22604
22607
|
iconProps = _objectWithoutProperties(_ref, _excluded$n);
|
package/package.json
CHANGED
|
@@ -3,7 +3,9 @@ import { Animated, Platform, StyleSheet } from 'react-native';
|
|
|
3
3
|
import type { IconProps } from '../Icon';
|
|
4
4
|
import { StyledFABIcon } from './StyledFAB';
|
|
5
5
|
|
|
6
|
-
const AnimatedIcons = Animated.createAnimatedComponent(
|
|
6
|
+
const AnimatedIcons = Animated.createAnimatedComponent(
|
|
7
|
+
React.forwardRef((props: IconProps, _) => <StyledFABIcon {...props} />)
|
|
8
|
+
);
|
|
7
9
|
|
|
8
10
|
type Props = {
|
|
9
11
|
active?: boolean;
|
|
@@ -4,16 +4,16 @@ import { Dimensions, SectionList, SectionListProps, View } from 'react-native';
|
|
|
4
4
|
import SectionHeading from '../SectionHeading';
|
|
5
5
|
import Spinner from '../Spinner';
|
|
6
6
|
import { OptionSpacer, SectionSpacer, StyledSectionList } from './StyledSelect';
|
|
7
|
-
import type {
|
|
7
|
+
import type { SelectOptionType, SelectProps, SectionType } from './types';
|
|
8
8
|
|
|
9
|
-
export type BaseOptionListProps<V, T extends
|
|
9
|
+
export type BaseOptionListProps<V, T extends SelectOptionType<V>> = Pick<
|
|
10
10
|
SelectProps<V, T>,
|
|
11
11
|
'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange'
|
|
12
12
|
> & {
|
|
13
13
|
sectionListRef?: React.RefObject<SectionList<T, SectionType>>;
|
|
14
14
|
} & SectionListProps<T, SectionType>;
|
|
15
15
|
|
|
16
|
-
const BaseOptionList = <V, T extends
|
|
16
|
+
const BaseOptionList = <V, T extends SelectOptionType<V>>({
|
|
17
17
|
keyExtractor,
|
|
18
18
|
loading,
|
|
19
19
|
onEndReached,
|
|
@@ -3,11 +3,11 @@ import type { SectionListRenderItemInfo } from 'react-native';
|
|
|
3
3
|
import BaseOptionList, { BaseOptionListProps } from '../BaseOptionList';
|
|
4
4
|
import Option from './Option';
|
|
5
5
|
import type { MultiSelectProps } from '.';
|
|
6
|
-
import type {
|
|
6
|
+
import type { SelectOptionType, SectionType } from '../types';
|
|
7
7
|
import { isOptionSelected } from './utils';
|
|
8
8
|
import { deepCompareValue } from '../../../utils/helpers';
|
|
9
9
|
|
|
10
|
-
type OptionListProps<V, T extends
|
|
10
|
+
type OptionListProps<V, T extends SelectOptionType<V>> = Pick<
|
|
11
11
|
MultiSelectProps<V, T>,
|
|
12
12
|
| 'keyExtractor'
|
|
13
13
|
| 'loading'
|
|
@@ -19,7 +19,7 @@ type OptionListProps<V, T extends OptionType<V>> = Pick<
|
|
|
19
19
|
onPress: (value: V[]) => void;
|
|
20
20
|
} & BaseOptionListProps<V, T>;
|
|
21
21
|
|
|
22
|
-
const OptionList = <V, T extends
|
|
22
|
+
const OptionList = <V, T extends SelectOptionType<V>>({
|
|
23
23
|
keyExtractor,
|
|
24
24
|
loading,
|
|
25
25
|
onEndReached,
|
|
@@ -10,13 +10,15 @@ import TextInput from '../../TextInput';
|
|
|
10
10
|
import Footer from '../Footer';
|
|
11
11
|
import { getScrollParams, toFlatOptions, toSections } from '../helpers';
|
|
12
12
|
import { StyledSearchBar } from '../StyledSelect';
|
|
13
|
-
import type {
|
|
13
|
+
import type { SelectOptionType, SectionType, SelectProps } from '../types';
|
|
14
14
|
import OptionList from './OptionList';
|
|
15
15
|
import { isOptionSelected } from './utils';
|
|
16
16
|
import { useKeyboard } from '../../../utils/helpers';
|
|
17
17
|
|
|
18
|
-
export interface MultiSelectProps<
|
|
19
|
-
|
|
18
|
+
export interface MultiSelectProps<
|
|
19
|
+
V,
|
|
20
|
+
T extends SelectOptionType<V> = SelectOptionType<V>
|
|
21
|
+
> extends SelectProps<V, T> {
|
|
20
22
|
/**
|
|
21
23
|
* Current selected value.
|
|
22
24
|
*/
|
|
@@ -50,7 +52,7 @@ export interface MultiSelectProps<V, T extends OptionType<V> = OptionType<V>>
|
|
|
50
52
|
supportedOrientations?: ('portrait' | 'landscape')[];
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
function MultiSelect<V, T extends
|
|
55
|
+
function MultiSelect<V, T extends SelectOptionType<V>>({
|
|
54
56
|
footerLabel,
|
|
55
57
|
label,
|
|
56
58
|
loading = false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deepCompareValue } from '../../../utils/helpers';
|
|
2
|
-
import {
|
|
2
|
+
import { SelectOptionType } from '../types';
|
|
3
3
|
|
|
4
|
-
export const isOptionSelected = <V, T extends
|
|
4
|
+
export const isOptionSelected = <V, T extends SelectOptionType<V>>(
|
|
5
5
|
value?: V[],
|
|
6
6
|
option?: T
|
|
7
7
|
): boolean => {
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
} from 'react-native';
|
|
7
7
|
import type { SingleSelectProps } from '.';
|
|
8
8
|
import { BaseOptionListProps } from '../BaseOptionList';
|
|
9
|
-
import type {
|
|
9
|
+
import type { SelectOptionType, SectionType } from '../types';
|
|
10
10
|
import Option from './Option';
|
|
11
11
|
import { StyledOptionList } from './StyledSingleSelect';
|
|
12
12
|
import { deepCompareValue } from '../../../utils/helpers';
|
|
13
13
|
|
|
14
|
-
type OptionListProps<V, T extends
|
|
14
|
+
type OptionListProps<V, T extends SelectOptionType<V>> = Pick<
|
|
15
15
|
SingleSelectProps<V, T>,
|
|
16
16
|
| 'keyExtractor'
|
|
17
17
|
| 'loading'
|
|
@@ -24,7 +24,7 @@ type OptionListProps<V, T extends OptionType<V>> = Pick<
|
|
|
24
24
|
sectionListRef?: React.RefObject<SectionList<T, SectionType>>;
|
|
25
25
|
} & BaseOptionListProps<V, T>;
|
|
26
26
|
|
|
27
|
-
const OptionList = <V, T extends
|
|
27
|
+
const OptionList = <V, T extends SelectOptionType<V>>({
|
|
28
28
|
keyExtractor,
|
|
29
29
|
loading,
|
|
30
30
|
onEndReached,
|
|
@@ -8,12 +8,14 @@ import BottomSheet from '../../BottomSheet';
|
|
|
8
8
|
import TextInput from '../../TextInput';
|
|
9
9
|
import { getScrollParams, toFlatOptions, toSections } from '../helpers';
|
|
10
10
|
import { StyledSearchBar } from '../StyledSelect';
|
|
11
|
-
import type {
|
|
11
|
+
import type { SelectOptionType, SectionType, SelectProps } from '../types';
|
|
12
12
|
import OptionList from './OptionList';
|
|
13
13
|
import { deepCompareValue, useKeyboard } from '../../../utils/helpers';
|
|
14
14
|
|
|
15
|
-
export interface SingleSelectProps<
|
|
16
|
-
|
|
15
|
+
export interface SingleSelectProps<
|
|
16
|
+
V,
|
|
17
|
+
T extends SelectOptionType<V> = SelectOptionType<V>
|
|
18
|
+
> extends SelectProps<V, T> {
|
|
17
19
|
/**
|
|
18
20
|
* Current selected value.
|
|
19
21
|
*/
|
|
@@ -35,7 +37,7 @@ export interface SingleSelectProps<V, T extends OptionType<V> = OptionType<V>>
|
|
|
35
37
|
supportedOrientations?: ('portrait' | 'landscape')[];
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
const SingleSelect = <V, T extends
|
|
40
|
+
const SingleSelect = <V, T extends SelectOptionType<V>>({
|
|
39
41
|
label,
|
|
40
42
|
loading = false,
|
|
41
43
|
inputProps,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
SectionData,
|
|
3
|
+
CombinedOptionsType,
|
|
4
|
+
SelectOptionType,
|
|
5
|
+
} from './types';
|
|
2
6
|
|
|
3
|
-
export const getKey = <V, T extends
|
|
7
|
+
export const getKey = <V, T extends SelectOptionType<V>>(
|
|
4
8
|
option: T,
|
|
5
9
|
index: number,
|
|
6
10
|
keyExtractor?: (opt: T, i?: number) => string
|
|
@@ -17,7 +21,7 @@ export const getKey = <V, T extends OptionType<V>>(
|
|
|
17
21
|
return key;
|
|
18
22
|
};
|
|
19
23
|
|
|
20
|
-
export const isSections = <V, T extends
|
|
24
|
+
export const isSections = <V, T extends SelectOptionType<V>>(
|
|
21
25
|
options: CombinedOptionsType<V, T>
|
|
22
26
|
): options is SectionData<V, T>[] => {
|
|
23
27
|
const firstOption = options[0];
|
|
@@ -28,7 +32,7 @@ export const isSections = <V, T extends OptionType<V>>(
|
|
|
28
32
|
);
|
|
29
33
|
};
|
|
30
34
|
|
|
31
|
-
export const toSections = <V, T extends
|
|
35
|
+
export const toSections = <V, T extends SelectOptionType<V>>(
|
|
32
36
|
options: CombinedOptionsType<V, T>
|
|
33
37
|
): SectionData<V, T>[] => {
|
|
34
38
|
if (isSections(options)) {
|
|
@@ -38,9 +42,9 @@ export const toSections = <V, T extends OptionType<V>>(
|
|
|
38
42
|
return [{ category: '', data: options }];
|
|
39
43
|
};
|
|
40
44
|
|
|
41
|
-
export const toFlatOptions = <V, T extends
|
|
45
|
+
export const toFlatOptions = <V, T extends SelectOptionType<V>>(
|
|
42
46
|
options: CombinedOptionsType<V, T>
|
|
43
|
-
):
|
|
47
|
+
): SelectOptionType<V>[] => {
|
|
44
48
|
if (isSections(options)) {
|
|
45
49
|
return options.flatMap((opt) => opt.data);
|
|
46
50
|
}
|
|
@@ -53,7 +57,7 @@ export type ScrollParams = {
|
|
|
53
57
|
sectionIndex: number;
|
|
54
58
|
};
|
|
55
59
|
|
|
56
|
-
export const getScrollParams = <V, T extends
|
|
60
|
+
export const getScrollParams = <V, T extends SelectOptionType<V>>(
|
|
57
61
|
value: V,
|
|
58
62
|
sections: SectionData<V, T>[]
|
|
59
63
|
): ScrollParams => {
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
import { BottomSheetProps } from '../BottomSheet';
|
|
10
10
|
import type { TextInputProps } from '../TextInput';
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type SelectOptionType<V> = {
|
|
13
13
|
value: V;
|
|
14
14
|
text: string;
|
|
15
15
|
key?: string;
|
|
@@ -18,29 +18,29 @@ export type OptionType<V> = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export type SectionType = { category: string };
|
|
21
|
-
export type SectionData<V, T extends
|
|
21
|
+
export type SectionData<V, T extends SelectOptionType<V>> = SectionListData<
|
|
22
22
|
T,
|
|
23
23
|
SectionType
|
|
24
24
|
>;
|
|
25
25
|
|
|
26
|
-
export type CombinedOptionsType<V, T extends
|
|
26
|
+
export type CombinedOptionsType<V, T extends SelectOptionType<V>> =
|
|
27
27
|
| T[]
|
|
28
28
|
| SectionData<V, T>[];
|
|
29
29
|
|
|
30
30
|
export type ListRenderOptionInfo<
|
|
31
31
|
V,
|
|
32
|
-
T extends
|
|
32
|
+
T extends SelectOptionType<V>
|
|
33
33
|
> = ListRenderItemInfo<T> & { selected: boolean; onPress: () => void };
|
|
34
34
|
|
|
35
35
|
export type SectionListRenderOptionInfo<
|
|
36
36
|
V,
|
|
37
|
-
T extends
|
|
37
|
+
T extends SelectOptionType<V>
|
|
38
38
|
> = SectionListRenderItemInfo<T, SectionType> & {
|
|
39
39
|
selected: boolean;
|
|
40
40
|
onPress: () => void;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export interface SelectProps<V, T extends
|
|
43
|
+
export interface SelectProps<V, T extends SelectOptionType<V>>
|
|
44
44
|
extends Pick<TextInputProps, 'editable' | 'disabled' | 'error' | 'required'> {
|
|
45
45
|
/**
|
|
46
46
|
* An array of options to be selected.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import React, { useEffect, useRef } from 'react';
|
|
3
3
|
import { Animated, Easing, LayoutChangeEvent, Platform } from 'react-native';
|
|
4
|
-
import type { BadgeConfigType,
|
|
4
|
+
import type { BadgeConfigType, SwitchOptionType } from '.';
|
|
5
5
|
import { useTheme } from '../../../theme';
|
|
6
6
|
import Badge from '../../Badge';
|
|
7
7
|
import Icon from '../../Icon';
|
|
@@ -42,7 +42,7 @@ const Option = <T,>({
|
|
|
42
42
|
selected,
|
|
43
43
|
onLayout,
|
|
44
44
|
index = 0,
|
|
45
|
-
}: Pick<
|
|
45
|
+
}: Pick<SwitchOptionType<T>, 'text' | 'icon' | 'badge'> & {
|
|
46
46
|
selected: boolean;
|
|
47
47
|
onLayout?: (e: LayoutChangeEvent) => void;
|
|
48
48
|
index?: number;
|
|
@@ -23,7 +23,7 @@ type StatusBadgeType = {
|
|
|
23
23
|
};
|
|
24
24
|
export type BadgeConfigType = StatusBadgeType;
|
|
25
25
|
|
|
26
|
-
export type
|
|
26
|
+
export type SwitchOptionType<T> = {
|
|
27
27
|
value: T;
|
|
28
28
|
text: string;
|
|
29
29
|
icon: IconName;
|
|
@@ -34,7 +34,7 @@ export interface SelectorSwitchProps<T> {
|
|
|
34
34
|
/**
|
|
35
35
|
* Array of exactly TWO options to switch between.
|
|
36
36
|
*/
|
|
37
|
-
options: [
|
|
37
|
+
options: [SwitchOptionType<T>, SwitchOptionType<T>];
|
|
38
38
|
/**
|
|
39
39
|
* Current selected value.
|
|
40
40
|
*/
|
|
@@ -1185,7 +1185,7 @@ exports[`TextInput disabled renders correctly 1`] = `
|
|
|
1185
1185
|
},
|
|
1186
1186
|
]
|
|
1187
1187
|
}
|
|
1188
|
-
testID="text-input"
|
|
1188
|
+
testID="text-input-disabled-text-input"
|
|
1189
1189
|
themeVariant="text"
|
|
1190
1190
|
value="100"
|
|
1191
1191
|
/>
|
|
@@ -2320,7 +2320,7 @@ exports[`TextInput idle renders correctly 1`] = `
|
|
|
2320
2320
|
},
|
|
2321
2321
|
]
|
|
2322
2322
|
}
|
|
2323
|
-
testID="text-input"
|
|
2323
|
+
testID="text-input-idle-text-input"
|
|
2324
2324
|
themeVariant="text"
|
|
2325
2325
|
/>
|
|
2326
2326
|
</View>
|
|
@@ -54,7 +54,9 @@ describe('TextInput', () => {
|
|
|
54
54
|
expect(toJSON()).toMatchSnapshot();
|
|
55
55
|
expect(getByTestId('idle-text-input')).toBeTruthy();
|
|
56
56
|
expect(
|
|
57
|
-
within(getByTestId('idle-text-input')).queryAllByTestId(
|
|
57
|
+
within(getByTestId('idle-text-input')).queryAllByTestId(
|
|
58
|
+
'text-input-idle-text-input'
|
|
59
|
+
)
|
|
58
60
|
).toHaveLength(1);
|
|
59
61
|
expect(
|
|
60
62
|
within(getByTestId('idle-text-input')).queryAllByText('Amount (AUD)')
|
|
@@ -69,7 +71,9 @@ describe('TextInput', () => {
|
|
|
69
71
|
within(getByTestId('idle-text-input')).queryAllByTestId('input-suffix')
|
|
70
72
|
).toHaveLength(1);
|
|
71
73
|
|
|
72
|
-
expect(getByTestId('text-input').props.placeholder).toBe(
|
|
74
|
+
expect(getByTestId('text-input-idle-text-input').props.placeholder).toBe(
|
|
75
|
+
' '
|
|
76
|
+
);
|
|
73
77
|
});
|
|
74
78
|
|
|
75
79
|
it('should not render input-label if label is empty', () => {
|
|
@@ -104,7 +108,7 @@ describe('TextInput', () => {
|
|
|
104
108
|
);
|
|
105
109
|
|
|
106
110
|
const testInput = within(getByTestId('idle-text-input')).getByTestId(
|
|
107
|
-
'text-input'
|
|
111
|
+
'text-input-idle-text-input'
|
|
108
112
|
);
|
|
109
113
|
|
|
110
114
|
fireEvent.changeText(testInput, 'Thong Quach');
|
|
@@ -305,13 +309,18 @@ describe('TextInput', () => {
|
|
|
305
309
|
expect(toJSON()).toMatchSnapshot();
|
|
306
310
|
expect(queryAllByText('Amount (AUD)')).toHaveLength(1);
|
|
307
311
|
expect(queryAllByTestId('input-label')).toHaveLength(1);
|
|
308
|
-
expect(queryAllByTestId('text-input')).toHaveLength(
|
|
312
|
+
expect(queryAllByTestId('text-input-disabled-text-input')).toHaveLength(
|
|
313
|
+
1
|
|
314
|
+
);
|
|
309
315
|
expect(getByTestId('disabled-text-input')).toHaveProp(
|
|
310
316
|
'pointerEvents',
|
|
311
317
|
'none'
|
|
312
318
|
);
|
|
313
319
|
|
|
314
|
-
expect(getByTestId('text-input')).not.toHaveProp(
|
|
320
|
+
expect(getByTestId('text-input-disabled-text-input')).not.toHaveProp(
|
|
321
|
+
'multiline',
|
|
322
|
+
'true'
|
|
323
|
+
);
|
|
315
324
|
});
|
|
316
325
|
});
|
|
317
326
|
|
|
@@ -560,7 +569,7 @@ describe('renderInput', () => {
|
|
|
560
569
|
{renderInput({
|
|
561
570
|
variant: 'textarea',
|
|
562
571
|
nativeInputProps: {
|
|
563
|
-
testID: 'text-input',
|
|
572
|
+
testID: 'text-input-idle-text-input',
|
|
564
573
|
value: 'text input value',
|
|
565
574
|
},
|
|
566
575
|
theme,
|
|
@@ -568,7 +577,9 @@ describe('renderInput', () => {
|
|
|
568
577
|
</>
|
|
569
578
|
);
|
|
570
579
|
|
|
571
|
-
expect(wrapper.queryAllByTestId('text-input')).toHaveLength(
|
|
580
|
+
expect(wrapper.queryAllByTestId('text-input-idle-text-input')).toHaveLength(
|
|
581
|
+
1
|
|
582
|
+
);
|
|
572
583
|
expect(wrapper.queryAllByDisplayValue('text input value')).toHaveLength(1);
|
|
573
584
|
});
|
|
574
585
|
});
|
|
@@ -397,6 +397,8 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
|
|
|
397
397
|
};
|
|
398
398
|
}, [style, theme]);
|
|
399
399
|
|
|
400
|
+
const nativeInputTestIDSuffix = testID ? `-${testID}` : '';
|
|
401
|
+
|
|
400
402
|
const nativeInputProps: NativeTextInputProps = {
|
|
401
403
|
style: StyleSheet.flatten([
|
|
402
404
|
{
|
|
@@ -405,7 +407,7 @@ const TextInput = forwardRef<TextInputHandles, TextInputProps>(
|
|
|
405
407
|
},
|
|
406
408
|
textStyleWithoutBorderStyle,
|
|
407
409
|
]),
|
|
408
|
-
testID:
|
|
410
|
+
testID: `text-input${nativeInputTestIDSuffix}`,
|
|
409
411
|
accessibilityState: {
|
|
410
412
|
disabled: state === 'disabled' || state === 'readonly',
|
|
411
413
|
},
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BottomNavigationTabType } from './components/BottomNavigation';
|
|
2
|
-
import type { IconName } from './components/Icon';
|
|
2
|
+
import type { IconName, IconProps } from './components/Icon';
|
|
3
3
|
import type { SingleSelectProps, MultiSelectProps } from './components/Select';
|
|
4
4
|
import type { TabType } from './components/Tabs';
|
|
5
5
|
import type { TextInputProps, TextInputHandles } from './components/TextInput';
|
|
@@ -8,9 +8,10 @@ import type {
|
|
|
8
8
|
RichTextEditorProps,
|
|
9
9
|
} from './components/RichTextEditor';
|
|
10
10
|
import type { Theme } from './theme';
|
|
11
|
-
import
|
|
11
|
+
import {
|
|
12
12
|
ListRenderOptionInfo,
|
|
13
13
|
SectionListRenderOptionInfo,
|
|
14
|
+
SelectOptionType,
|
|
14
15
|
} from './components/Select/types';
|
|
15
16
|
import { SwipeableProps } from './components/Swipeable';
|
|
16
17
|
import { TextProps } from './components/Typography/Text';
|
|
@@ -20,21 +21,54 @@ import {
|
|
|
20
21
|
ActionGroupHandles,
|
|
21
22
|
ActionGroupProps,
|
|
22
23
|
} from './components/FAB/ActionGroup';
|
|
24
|
+
import type { ActionItemProps } from './components/FAB/ActionGroup/ActionItem';
|
|
23
25
|
import type { SliderRangeValue } from './components/Slider/RangeSlider';
|
|
24
26
|
import type { CalendarDateRange } from './components/Calendar/CalendarRange';
|
|
25
27
|
import { LocaleCode, LocaleValues, DateTimeFormats } from './locales/types';
|
|
26
28
|
import type { ColumnChartProps } from './components/Chart/ColumnChart';
|
|
27
29
|
import { LineChartProps } from './components/Chart/Line';
|
|
28
30
|
import type { Scale, SystemPalette } from './theme/global';
|
|
31
|
+
import type {
|
|
32
|
+
BrandSystemPalette,
|
|
33
|
+
GlobalSystemPalette,
|
|
34
|
+
} from './theme/global/colors/types';
|
|
35
|
+
import { ToolbarItemProps } from './components/Toolbar/ToolbarItem';
|
|
36
|
+
import type { CheckboxProps } from './components/Checkbox';
|
|
37
|
+
import type { SwitchOptionType } from './components/Switch/SelectorSwitch';
|
|
38
|
+
import type { BoxProps } from './components/Box';
|
|
39
|
+
import type { BodyProps } from './components/Typography/Body';
|
|
40
|
+
import type { ToolbarButtonName } from './components/RichTextEditor/types';
|
|
41
|
+
import type { ListItemProps } from './components/List/ListItem';
|
|
42
|
+
import type { IconButtonProps } from './components/Button/IconButton';
|
|
43
|
+
import type { BadgeProps } from './components/Badge';
|
|
44
|
+
import { ToastProps } from './components/Toast/types';
|
|
45
|
+
import { Space } from './theme/global/space';
|
|
46
|
+
import { CaptionProps } from './components/Typography/Caption';
|
|
47
|
+
import { Radii } from './theme/global/borders';
|
|
48
|
+
import { TitleProps } from './components/Typography/Title';
|
|
49
|
+
import { CarouselData, CarouselImageProps } from './components/Carousel/types';
|
|
50
|
+
import { PinInputHandler } from './components/PinInput';
|
|
51
|
+
import { ThemeScale } from './components/Box/types';
|
|
29
52
|
|
|
30
53
|
export type {
|
|
54
|
+
Space,
|
|
55
|
+
CaptionProps,
|
|
56
|
+
Radii,
|
|
57
|
+
TitleProps,
|
|
58
|
+
CarouselData,
|
|
59
|
+
CarouselImageProps,
|
|
60
|
+
PinInputHandler,
|
|
61
|
+
ThemeScale,
|
|
62
|
+
ToastProps,
|
|
31
63
|
ActionGroupProps,
|
|
64
|
+
ToolbarItemProps,
|
|
32
65
|
BottomNavigationTabType,
|
|
33
66
|
IconName,
|
|
34
67
|
SingleSelectProps,
|
|
35
68
|
MultiSelectProps,
|
|
36
69
|
ListRenderOptionInfo,
|
|
37
70
|
SectionListRenderOptionInfo,
|
|
71
|
+
SelectOptionType,
|
|
38
72
|
SwipeableProps,
|
|
39
73
|
RichTextEditorProps,
|
|
40
74
|
RichTextEditorRef,
|
|
@@ -46,6 +80,7 @@ export type {
|
|
|
46
80
|
CardCarouselHandles,
|
|
47
81
|
FABHandles,
|
|
48
82
|
ActionGroupHandles,
|
|
83
|
+
ActionItemProps,
|
|
49
84
|
SliderRangeValue,
|
|
50
85
|
CalendarDateRange,
|
|
51
86
|
LocaleCode,
|
|
@@ -55,4 +90,15 @@ export type {
|
|
|
55
90
|
LineChartProps,
|
|
56
91
|
Scale,
|
|
57
92
|
SystemPalette,
|
|
93
|
+
BrandSystemPalette,
|
|
94
|
+
GlobalSystemPalette,
|
|
95
|
+
IconProps,
|
|
96
|
+
CheckboxProps,
|
|
97
|
+
SwitchOptionType,
|
|
98
|
+
BoxProps,
|
|
99
|
+
BodyProps,
|
|
100
|
+
ToolbarButtonName,
|
|
101
|
+
ListItemProps,
|
|
102
|
+
IconButtonProps,
|
|
103
|
+
BadgeProps,
|
|
58
104
|
};
|