@react-native-ohos/slider 5.1.2-rc.1 → 5.1.2-rc.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +187 -183
  2. package/COMMITTERS.md +5 -5
  3. package/LICENSE +8 -8
  4. package/OAT.xml +72 -72
  5. package/README.OpenSource +10 -10
  6. package/README.md +12 -12
  7. package/babel.config.json +3 -3
  8. package/dist/Slider.js +1 -1
  9. package/dist/components/StepNumber.js +1 -1
  10. package/dist/components/StepsIndicator.js +1 -1
  11. package/dist/components/TrackMark.js +1 -1
  12. package/dist/utils/styles.js +1 -1
  13. package/example/.eslintrc +18 -18
  14. package/example/.node-version +6 -6
  15. package/example/.prettierrc.js +7 -7
  16. package/example/.watchmanconfig +5 -5
  17. package/example/app.json +3 -3
  18. package/example/babel.config.js +9 -9
  19. package/example/contexts.ts +9 -9
  20. package/example/harmony/AppScope/app.json5 +10 -10
  21. package/example/harmony/AppScope/resources/base/element/string.json +8 -8
  22. package/example/harmony/build-profile.template.json5 +35 -35
  23. package/example/harmony/codelinter.json +32 -32
  24. package/example/harmony/entry/build-profile.json5 +21 -21
  25. package/example/harmony/entry/hvigorfile.ts +8 -8
  26. package/example/harmony/entry/oh-package.json5 +10 -10
  27. package/example/harmony/entry/src/main/cpp/CMakeLists.txt +41 -41
  28. package/example/harmony/entry/src/main/cpp/PackageProvider.cpp +16 -16
  29. package/example/harmony/entry/src/main/ets/RNPackagesFactory.ets +13 -13
  30. package/example/harmony/entry/src/main/ets/entryability/EntryAbility.ets +27 -27
  31. package/example/harmony/entry/src/main/ets/pages/Index.ets +125 -125
  32. package/example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets +135 -135
  33. package/example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets +43 -43
  34. package/example/harmony/entry/src/main/module.json5 +51 -51
  35. package/example/harmony/entry/src/main/resources/base/element/color.json +7 -7
  36. package/example/harmony/entry/src/main/resources/base/element/string.json +15 -15
  37. package/example/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -5
  38. package/example/harmony/format.ps1 +17 -17
  39. package/example/harmony/hvigor/hvigor-config.json5 +20 -20
  40. package/example/harmony/hvigorfile.ts +8 -8
  41. package/example/harmony/oh-package.json5 +11 -11
  42. package/example/index.js +10 -10
  43. package/example/jest.config.js +11 -11
  44. package/example/metro.config.js +30 -30
  45. package/example/package.json +58 -58
  46. package/example/react-native.config.js +11 -11
  47. package/example/scripts/create-build-profile.js +45 -45
  48. package/example/src/index.tsx +22 -22
  49. package/example/tsconfig.json +19 -19
  50. package/harmony/slider/oh-package.json5 +10 -10
  51. package/harmony/slider.har +0 -0
  52. package/package.json +92 -92
  53. package/react-native.config.js +11 -11
  54. package/src/RNCSliderNativeComponent.ts +51 -51
  55. package/src/Slider.tsx +356 -356
  56. package/src/components/StepNumber.tsx +23 -23
  57. package/src/components/StepsIndicator.tsx +89 -89
  58. package/src/components/TrackMark.tsx +59 -59
  59. package/src/index.ts +9 -9
  60. package/src/utils/constants.ts +17 -17
  61. package/src/utils/styles.ts +61 -61
  62. package/tsconfig.json +23 -23
  63. package/typings/index.d.ts +214 -214
  64. package/.github/Examples/Slider-Android-Example.gif +0 -0
  65. package/.github/Examples/Slider-Web-Example.gif +0 -0
  66. package/.github/Examples/Slider-Windows-Example.gif +0 -0
  67. package/.github/Examples/Slider-iOS-Example.gif +0 -0
  68. package/.github/ISSUE_TEMPLATE/BUG_REPORT.md +0 -38
  69. package/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +0 -14
  70. package/.github/ISSUE_TEMPLATE/QUESTION.md +0 -9
  71. package/.github/PULL_REQUEST_TEMPLATE.md +0 -11
  72. package/.github/workflows/ReactNativeSlider-CI.yml +0 -231
  73. package/harmony/slider/README.OpenSource +0 -11
@@ -1,23 +1,23 @@
1
- /*
2
- * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import React from 'react';
8
- import {StyleProp, Text, TextStyle, View} from 'react-native';
9
- import {styles} from '../utils/styles';
10
-
11
- export const StepNumber = ({
12
- i,
13
- style,
14
- }: {
15
- i: number;
16
- style: StyleProp<TextStyle>;
17
- }) => {
18
- return (
19
- <View style={styles.stepNumber}>
20
- <Text style={style}>{i}</Text>
21
- </View>
22
- );
23
- };
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import React from 'react';
8
+ import {StyleProp, Text, TextStyle, View} from 'react-native';
9
+ import {styles} from '../utils/styles';
10
+
11
+ export const StepNumber = ({
12
+ i,
13
+ style,
14
+ }: {
15
+ i: number;
16
+ style: StyleProp<TextStyle>;
17
+ }) => {
18
+ return (
19
+ <View style={styles.stepNumber}>
20
+ <Text style={style}>{i}</Text>
21
+ </View>
22
+ );
23
+ };
@@ -1,89 +1,89 @@
1
- /*
2
- * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import React, {FC, Fragment, useCallback, useMemo} from 'react';
8
- import {View} from 'react-native';
9
- import {StepNumber} from './StepNumber';
10
- import {MarkerProps, SliderTrackMark} from './TrackMark';
11
- //@ts-ignore
12
- import type {ImageSource} from 'react-native/Libraries/Image/ImageSource';
13
- import {styles} from '../utils/styles';
14
- import {constants} from '../utils/constants';
15
-
16
- export const StepsIndicator = ({
17
- options,
18
- sliderWidth,
19
- currentValue,
20
- StepMarker,
21
- renderStepNumber,
22
- thumbImage,
23
- isLTR,
24
- }: {
25
- options: number[];
26
- sliderWidth: number;
27
- currentValue: number;
28
- StepMarker?: FC<MarkerProps>;
29
- renderStepNumber?: boolean;
30
- thumbImage?: ImageSource;
31
- isLTR?: boolean;
32
- }) => {
33
- const stepNumberFontStyle = useMemo(() => {
34
- return {
35
- fontSize:
36
- options.length > 9
37
- ? constants.STEP_NUMBER_TEXT_FONT_SMALL
38
- : constants.STEP_NUMBER_TEXT_FONT_BIG,
39
- };
40
- }, [options.length]);
41
- const values = isLTR ? options.reverse() : options;
42
-
43
- const renderStepIndicator = useCallback(
44
- (i: number, index: number) => {
45
- return (
46
- <Fragment key={index}>
47
- <View style={styles.stepIndicatorElement} key={`${index}-View`}>
48
- <SliderTrackMark
49
- key={`${index}-SliderTrackMark`}
50
- isTrue={currentValue === i}
51
- index={i}
52
- thumbImage={thumbImage}
53
- StepMarker={StepMarker}
54
- currentValue={currentValue}
55
- min={options[0]}
56
- max={options[options.length - 1]}
57
- />
58
- {renderStepNumber ? (
59
- <StepNumber
60
- i={i}
61
- style={stepNumberFontStyle}
62
- key={`${index}th-step`}
63
- />
64
- ) : null}
65
- </View>
66
- </Fragment>
67
- );
68
- },
69
- [
70
- currentValue,
71
- StepMarker,
72
- options,
73
- thumbImage,
74
- renderStepNumber,
75
- stepNumberFontStyle,
76
- ],
77
- );
78
-
79
- return (
80
- <View
81
- pointerEvents="none"
82
- style={[
83
- styles.stepsIndicator,
84
- {marginHorizontal: sliderWidth * constants.MARGIN_HORIZONTAL_PADDING},
85
- ]}>
86
- {values.map((i, index) => renderStepIndicator(i, index))}
87
- </View>
88
- );
89
- };
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import React, {FC, Fragment, useCallback, useMemo} from 'react';
8
+ import {View} from 'react-native';
9
+ import {StepNumber} from './StepNumber';
10
+ import {MarkerProps, SliderTrackMark} from './TrackMark';
11
+ //@ts-ignore
12
+ import type {ImageSource} from 'react-native/Libraries/Image/ImageSource';
13
+ import {styles} from '../utils/styles';
14
+ import {constants} from '../utils/constants';
15
+
16
+ export const StepsIndicator = ({
17
+ options,
18
+ sliderWidth,
19
+ currentValue,
20
+ StepMarker,
21
+ renderStepNumber,
22
+ thumbImage,
23
+ isLTR,
24
+ }: {
25
+ options: number[];
26
+ sliderWidth: number;
27
+ currentValue: number;
28
+ StepMarker?: FC<MarkerProps>;
29
+ renderStepNumber?: boolean;
30
+ thumbImage?: ImageSource;
31
+ isLTR?: boolean;
32
+ }) => {
33
+ const stepNumberFontStyle = useMemo(() => {
34
+ return {
35
+ fontSize:
36
+ options.length > 9
37
+ ? constants.STEP_NUMBER_TEXT_FONT_SMALL
38
+ : constants.STEP_NUMBER_TEXT_FONT_BIG,
39
+ };
40
+ }, [options.length]);
41
+ const values = isLTR ? options.reverse() : options;
42
+
43
+ const renderStepIndicator = useCallback(
44
+ (i: number, index: number) => {
45
+ return (
46
+ <Fragment key={index}>
47
+ <View style={styles.stepIndicatorElement} key={`${index}-View`}>
48
+ <SliderTrackMark
49
+ key={`${index}-SliderTrackMark`}
50
+ isTrue={currentValue === i}
51
+ index={i}
52
+ thumbImage={thumbImage}
53
+ StepMarker={StepMarker}
54
+ currentValue={currentValue}
55
+ min={options[0]}
56
+ max={options[options.length - 1]}
57
+ />
58
+ {renderStepNumber ? (
59
+ <StepNumber
60
+ i={i}
61
+ style={stepNumberFontStyle}
62
+ key={`${index}th-step`}
63
+ />
64
+ ) : null}
65
+ </View>
66
+ </Fragment>
67
+ );
68
+ },
69
+ [
70
+ currentValue,
71
+ StepMarker,
72
+ options,
73
+ thumbImage,
74
+ renderStepNumber,
75
+ stepNumberFontStyle,
76
+ ],
77
+ );
78
+
79
+ return (
80
+ <View
81
+ pointerEvents="none"
82
+ style={[
83
+ styles.stepsIndicator,
84
+ {marginHorizontal: sliderWidth * constants.MARGIN_HORIZONTAL_PADDING},
85
+ ]}>
86
+ {values.map((i, index) => renderStepIndicator(i, index))}
87
+ </View>
88
+ );
89
+ };
@@ -1,59 +1,59 @@
1
- /*
2
- * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import React, {FC} from 'react';
8
- import {Image, ImageSource, ImageSourcePropType, View} from 'react-native';
9
- import {styles} from '../utils/styles';
10
-
11
- export type MarkerProps = {
12
- stepMarked: boolean;
13
- currentValue: number;
14
- index: number;
15
- min: number;
16
- max: number;
17
- };
18
-
19
- export type TrackMarksProps = {
20
- isTrue: boolean;
21
- index: number;
22
- thumbImage?: ImageSource;
23
- StepMarker?: FC<MarkerProps>;
24
- currentValue: number;
25
- min: number;
26
- max: number;
27
- };
28
-
29
- export const SliderTrackMark = ({
30
- isTrue,
31
- index,
32
- thumbImage,
33
- StepMarker,
34
- currentValue,
35
- min,
36
- max,
37
- }: TrackMarksProps) => {
38
- return (
39
- <View style={styles.trackMarkContainer}>
40
- {StepMarker ? (
41
- <StepMarker
42
- stepMarked={isTrue}
43
- index={index}
44
- currentValue={currentValue}
45
- min={min}
46
- max={max}
47
- />
48
- ) : null}
49
- {thumbImage && isTrue ? (
50
- <View style={styles.thumbImageContainer}>
51
- <Image
52
- source={thumbImage as ImageSourcePropType}
53
- style={styles.thumbImage}
54
- />
55
- </View>
56
- ) : null}
57
- </View>
58
- );
59
- };
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import React, {FC} from 'react';
8
+ import {Image, ImageSource, ImageSourcePropType, View} from 'react-native';
9
+ import {styles} from '../utils/styles';
10
+
11
+ export type MarkerProps = {
12
+ stepMarked: boolean;
13
+ currentValue: number;
14
+ index: number;
15
+ min: number;
16
+ max: number;
17
+ };
18
+
19
+ export type TrackMarksProps = {
20
+ isTrue: boolean;
21
+ index: number;
22
+ thumbImage?: ImageSource;
23
+ StepMarker?: FC<MarkerProps>;
24
+ currentValue: number;
25
+ min: number;
26
+ max: number;
27
+ };
28
+
29
+ export const SliderTrackMark = ({
30
+ isTrue,
31
+ index,
32
+ thumbImage,
33
+ StepMarker,
34
+ currentValue,
35
+ min,
36
+ max,
37
+ }: TrackMarksProps) => {
38
+ return (
39
+ <View style={styles.trackMarkContainer}>
40
+ {StepMarker ? (
41
+ <StepMarker
42
+ stepMarked={isTrue}
43
+ index={index}
44
+ currentValue={currentValue}
45
+ min={min}
46
+ max={max}
47
+ />
48
+ ) : null}
49
+ {thumbImage && isTrue ? (
50
+ <View style={styles.thumbImageContainer}>
51
+ <Image
52
+ source={thumbImage as ImageSourcePropType}
53
+ style={styles.thumbImage}
54
+ />
55
+ </View>
56
+ ) : null}
57
+ </View>
58
+ );
59
+ };
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
- /*
2
- * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- const RNCSlider = require('./RNCSliderNativeComponent').default;
8
-
9
- export default RNCSlider;
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ const RNCSlider = require('./RNCSliderNativeComponent').default;
8
+
9
+ export default RNCSlider;
@@ -1,17 +1,17 @@
1
- /*
2
- * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import {Platform} from 'react-native';
8
-
9
- export const constants = {
10
- SLIDER_DEFAULT_INITIAL_VALUE: 0,
11
- MARGIN_HORIZONTAL_PADDING: 0.05,
12
- STEP_NUMBER_TEXT_FONT_SMALL: 8,
13
- STEP_NUMBER_TEXT_FONT_BIG: 12,
14
- LIMIT_MIN_VALUE: Number.MIN_SAFE_INTEGER,
15
- LIMIT_MAX_VALUE: Number.MAX_SAFE_INTEGER,
16
- DEFAULT_STEP_RESOLUTION: Platform.OS === 'android' ? 128 : 1000,
17
- };
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import {Platform} from 'react-native';
8
+
9
+ export const constants = {
10
+ SLIDER_DEFAULT_INITIAL_VALUE: 0,
11
+ MARGIN_HORIZONTAL_PADDING: 0.05,
12
+ STEP_NUMBER_TEXT_FONT_SMALL: 8,
13
+ STEP_NUMBER_TEXT_FONT_BIG: 12,
14
+ LIMIT_MIN_VALUE: Number.MIN_SAFE_INTEGER,
15
+ LIMIT_MAX_VALUE: Number.MAX_SAFE_INTEGER,
16
+ DEFAULT_STEP_RESOLUTION: Platform.OS === 'android' ? 128 : 1000,
17
+ };
@@ -1,61 +1,61 @@
1
- /*
2
- * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import {Platform, StyleSheet} from 'react-native';
8
-
9
- export const styles = StyleSheet.create({
10
- stepNumber: {
11
- marginTop: 20,
12
- alignItems: 'center',
13
- position: 'absolute',
14
- },
15
- sliderMainContainer: {zIndex: 1, width: '100%'},
16
- defaultSlideriOS: {
17
- height: 40,
18
- },
19
- defaultSlider: {},
20
- stepsIndicator: {
21
- flex: 1,
22
- flexDirection: 'row',
23
- justifyContent: 'space-between',
24
- top: Platform.OS === 'ios' ? 10 : 0,
25
- zIndex: 2,
26
- },
27
- trackMarkContainer: {
28
- alignItems: 'center',
29
- alignContent: 'center',
30
- alignSelf: 'center',
31
- justifyContent: 'center',
32
- position: 'absolute',
33
- zIndex: 3,
34
- },
35
- thumbImageContainer: {
36
- position: 'absolute',
37
- zIndex: 3,
38
- justifyContent: 'center',
39
- alignItems: 'center',
40
- alignContent: 'center',
41
- },
42
- thumbImage: {
43
- alignContent: 'center',
44
- alignItems: 'center',
45
- position: 'absolute',
46
- },
47
- stepIndicatorElement: {
48
- alignItems: 'center',
49
- alignContent: 'center',
50
- },
51
- defaultIndicatorMarked: {
52
- height: 20,
53
- width: 5,
54
- backgroundColor: '#CCCCCC',
55
- },
56
- defaultIndicatorIdle: {
57
- height: 10,
58
- width: 2,
59
- backgroundColor: '#C0C0C0',
60
- },
61
- });
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import {Platform, StyleSheet} from 'react-native';
8
+
9
+ export const styles = StyleSheet.create({
10
+ stepNumber: {
11
+ marginTop: 20,
12
+ alignItems: 'center',
13
+ position: 'absolute',
14
+ },
15
+ sliderMainContainer: {zIndex: 1, width: '100%'},
16
+ defaultSlideriOS: {
17
+ height: 40,
18
+ },
19
+ defaultSlider: {},
20
+ stepsIndicator: {
21
+ flex: 1,
22
+ flexDirection: 'row',
23
+ justifyContent: 'space-between',
24
+ top: Platform.OS === 'ios' || Platform.OS === 'harmony' ? 10 : 0,
25
+ zIndex: 2,
26
+ },
27
+ trackMarkContainer: {
28
+ alignItems: 'center',
29
+ alignContent: 'center',
30
+ alignSelf: 'center',
31
+ justifyContent: 'center',
32
+ position: 'absolute',
33
+ zIndex: 3,
34
+ },
35
+ thumbImageContainer: {
36
+ position: 'absolute',
37
+ zIndex: 3,
38
+ justifyContent: 'center',
39
+ alignItems: 'center',
40
+ alignContent: 'center',
41
+ },
42
+ thumbImage: {
43
+ alignContent: 'center',
44
+ alignItems: 'center',
45
+ position: 'absolute',
46
+ },
47
+ stepIndicatorElement: {
48
+ alignItems: 'center',
49
+ alignContent: 'center',
50
+ },
51
+ defaultIndicatorMarked: {
52
+ height: 20,
53
+ width: 5,
54
+ backgroundColor: '#CCCCCC',
55
+ },
56
+ defaultIndicatorIdle: {
57
+ height: 10,
58
+ width: 2,
59
+ backgroundColor: '#C0C0C0',
60
+ },
61
+ });
package/tsconfig.json CHANGED
@@ -1,23 +1,23 @@
1
- {
2
- "include": ["./src/**/*"],
3
-
4
- "compilerOptions": {
5
- "jsx": "react",
6
-
7
- /* Language and Environment */
8
- "target": "ESNext",
9
- "lib": ["ESNext", "dom"],
10
-
11
- /* Modules */
12
- "module": "NodeNext",
13
- "moduleResolution": "NodeNext",
14
-
15
- /* Interop Constraints */
16
- "esModuleInterop": true,
17
- "forceConsistentCasingInFileNames": true,
18
-
19
- /* Type Checking */
20
- "strict": true,
21
- "skipLibCheck": true
22
- }
23
- }
1
+ {
2
+ "include": ["./src/**/*"],
3
+
4
+ "compilerOptions": {
5
+ "jsx": "react",
6
+
7
+ /* Language and Environment */
8
+ "target": "ESNext",
9
+ "lib": ["ESNext", "dom"],
10
+
11
+ /* Modules */
12
+ "module": "NodeNext",
13
+ "moduleResolution": "NodeNext",
14
+
15
+ /* Interop Constraints */
16
+ "esModuleInterop": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+
19
+ /* Type Checking */
20
+ "strict": true,
21
+ "skipLibCheck": true
22
+ }
23
+ }