@react-native-segmented-control/segmented-control 2.4.2 → 2.5.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/README.md CHANGED
@@ -6,8 +6,6 @@ React Native SegmentedControl library. Use SegmentedControl to render a UISegmen
6
6
 
7
7
  For Android and Web, it has a js implementation that mocks iOS 13 style of UISegmentedControl.
8
8
 
9
- **For Expo Users:** Expo SDK 38 or later is required for this package.
10
-
11
9
  | iOS | Android | Web |
12
10
  | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
13
11
  | <img src="https://user-images.githubusercontent.com/6936373/71608757-dc6ef680-2bc6-11ea-85be-aa31f25ecf36.png" width="320" /> | <img src="https://user-images.githubusercontent.com/6936373/79550655-9edd9d00-80d3-11ea-98bf-8b7c0b0798d3.png" width="320" /> | <img src="https://user-images.githubusercontent.com/6936373/79590620-3f52b200-8112-11ea-863b-236c4465fba6.png" width="640"/> |
@@ -23,13 +21,22 @@ This module is NOT supported in the Expo Go app on iOS, because it requires cust
23
21
 
24
22
  ## Getting started
25
23
 
26
- Install the library using either Yarn:
24
+ Install the library using your package manager:
25
+
26
+ pnpm:
27
+
28
+ ```
29
+ pnpm install --save @react-native-segmented-control/segmented-control
30
+ ```
31
+
32
+
33
+ yarn:
27
34
 
28
35
  ```
29
36
  yarn add @react-native-segmented-control/segmented-control
30
37
  ```
31
38
 
32
- or npm:
39
+ npm:
33
40
 
34
41
  ```
35
42
  npm install --save @react-native-segmented-control/segmented-control
package/index.d.ts CHANGED
@@ -134,9 +134,7 @@ export interface SegmentedControlProps extends ViewProps {
134
134
  * ````
135
135
  */
136
136
 
137
- declare class SegmentedControlComponent extends React.Component<
138
- SegmentedControlProps
139
- > {}
137
+ declare class SegmentedControlComponent extends React.Component<SegmentedControlProps> {}
140
138
  declare const SegmentedControlBase: Constructor<NativeMethods> &
141
139
  typeof SegmentedControlComponent;
142
140
  export default class SegmentedControl extends SegmentedControlBase {}
@@ -60,15 +60,6 @@
60
60
  __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
61
61
  if (@available(iOS 13.0, *)) {
62
62
  [self setSelectedSegmentTintColor:tintColor];
63
- NSDictionary *attributes = [NSDictionary
64
- dictionaryWithObjectsAndKeys:tintColor, NSForegroundColorAttributeName,
65
- nil];
66
- NSDictionary *activeAttributes = [NSDictionary
67
- dictionaryWithObjectsAndKeys:UIColor.labelColor,
68
- NSForegroundColorAttributeName, nil];
69
- [self setTitleTextAttributes:attributes forState:UIControlStateNormal];
70
- [self setTitleTextAttributes:activeAttributes
71
- forState:UIControlStateSelected];
72
63
  }
73
64
  #endif
74
65
  }
@@ -55,13 +55,8 @@ class SegmentedControlIOS extends React.Component<Props> {
55
55
  };
56
56
 
57
57
  render() {
58
- const {
59
- forwardedRef,
60
- fontStyle,
61
- activeFontStyle,
62
- values,
63
- ...props
64
- } = this.props;
58
+ const {forwardedRef, fontStyle, activeFontStyle, values, ...props} =
59
+ this.props;
65
60
  return (
66
61
  <RNCSegmentedControlNativeComponent
67
62
  fontStyle={
@@ -36,6 +36,7 @@ const SegmentedControl = ({
36
36
  fontStyle,
37
37
  activeFontStyle,
38
38
  appearance,
39
+ accessibilityHintSeperator = 'out of',
39
40
  }: SegmentedControlProps): React.Node => {
40
41
  const colorSchemeHook = useColorScheme();
41
42
  const colorScheme = appearance || colorSchemeHook;
@@ -99,6 +100,7 @@ const SegmentedControl = ({
99
100
  <SegmentedControlTab
100
101
  enabled={enabled}
101
102
  selected={selectedIndex === index}
103
+ accessibilityHint={`${index + 1} ${accessibilityHintSeperator} ${values.length}`}
102
104
  key={index}
103
105
  value={value}
104
106
  tintColor={tintColor}
@@ -120,6 +122,7 @@ const SegmentedControl = ({
120
122
  {
121
123
  transform: [{translateX: animation}],
122
124
  width: segmentWidth - 4,
125
+ zIndex: -1,
123
126
  backgroundColor:
124
127
  tintColor || (colorScheme === 'dark' ? '#636366' : 'white'),
125
128
  },
@@ -27,10 +27,12 @@ type Props = $ReadOnly<{|
27
27
  activeFontStyle?: FontStyle,
28
28
  tabStyle?: ViewStyle,
29
29
  appearance?: 'dark' | 'light' | null,
30
+ accessibilityHint?: string,
30
31
  |}>;
31
32
 
32
33
  function isBase64(str) {
33
- const regex = /^data:image\/(?:gif|png|jpeg|bmp|webp)(?:;charset=utf-8)?;base64,(?:[A-Za-z0-9]|[+/])+={0,2}/;
34
+ const regex =
35
+ /^data:image\/(?:gif|png|jpeg|bmp|webp)(?:;charset=utf-8)?;base64,(?:[A-Za-z0-9]|[+/])+={0,2}/;
34
36
  return str && regex.test(str);
35
37
  }
36
38
 
@@ -44,6 +46,7 @@ export const SegmentedControlTab = ({
44
46
  activeFontStyle = {},
45
47
  appearance,
46
48
  tabStyle,
49
+ accessibilityHint,
47
50
  }: Props): React.Node => {
48
51
  const colorSchemeHook = useColorScheme();
49
52
  const colorScheme = appearance || colorSchemeHook;
@@ -87,6 +90,8 @@ export const SegmentedControlTab = ({
87
90
  style={[styles.container, tabStyle]}
88
91
  disabled={!enabled}
89
92
  onPress={onSelect}
93
+ accessibilityHint={accessibilityHint}
94
+ accessibilityRole="button"
90
95
  accessibilityState={{selected: selected, disabled: !enabled}}>
91
96
  <View style={styles.default}>
92
97
  {typeof value === 'number' || typeof value === 'object' ? (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-segmented-control/segmented-control",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "React Native SegmentedControlIOS library",
5
5
  "main": "js/index.js",
6
6
  "types": "index.d.ts",
@@ -12,14 +12,14 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "start": "react-native start",
15
- "test": "yarn flow && yarn lint",
15
+ "test": "pnpm flow && pnpm lint",
16
16
  "ios": "cd example && react-native run-ios",
17
17
  "web": "expo web",
18
18
  "android": "react-native run-android",
19
19
  "flow": "flow",
20
20
  "lint": "eslint . --cache",
21
21
  "tsc": "tsc --noEmit",
22
- "ci:publish": "yarn semantic-release"
22
+ "ci:publish": "pnpm semantic-release"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=16.0",
@@ -28,30 +28,31 @@
28
28
  "devDependencies": {
29
29
  "@babel/core": "^7.10.2",
30
30
  "@babel/runtime": "^7.10.2",
31
- "@expo/webpack-config": "^0.17.2",
32
- "@react-native-community/eslint-config": "^3.0.0",
31
+ "@expo/webpack-config": "^18.0.4",
32
+ "@react-native-community/eslint-config": "^3.2.0",
33
33
  "@semantic-release/git": "^10.0.1",
34
34
  "@types/react": "^17.0.0",
35
35
  "@types/react-native": "^0.64.4",
36
36
  "babel-eslint": "^10.1.0",
37
37
  "babel-jest": "^29.0.3",
38
38
  "babel-preset-expo": "^9.2.0",
39
- "eslint": "7",
40
- "eslint-plugin-prettier": "^4.2.1",
39
+ "eslint": "8",
40
+ "eslint-plugin-prettier": "^5.0.0",
41
+ "prettier": "^3.0.0",
41
42
  "expo": "^46.0.16",
42
43
  "flow-bin": "^0.142.0",
43
44
  "husky": "^8.0.1",
44
45
  "jest": "^29.2.1",
45
46
  "metro-react-native-babel-preset": "0.73.3",
46
- "react": "16.13.1",
47
- "react-dom": "16.13.1",
47
+ "react": "17.0.2",
48
+ "react-dom": "17.0.2",
48
49
  "react-native": "0.63.4",
49
50
  "react-native-test-app": "1.4.6",
50
51
  "react-native-web": "^0.14.10",
51
- "react-test-renderer": "16.13.1",
52
+ "react-test-renderer": "17.0.2",
52
53
  "rimraf": "^3.0.2",
53
54
  "semantic-release": "^19.0.5",
54
- "typescript": "^4.1.5"
55
+ "typescript": "^4"
55
56
  },
56
57
  "resolutions": {
57
58
  "@react-native-community/cli": "4.10.0"