@react-native-ohos/slider 5.0.1-rc.1 → 5.0.1

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 (71) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/COMMITTERS.md +6 -0
  3. package/LICENSE +8 -8
  4. package/OAT.xml +73 -0
  5. package/README.OpenSource +10 -10
  6. package/README.md +12 -12
  7. package/babel.config.json +3 -0
  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/example/.eslintrc +19 -0
  13. package/example/.node-version +6 -0
  14. package/example/.prettierrc.js +7 -0
  15. package/example/.watchmanconfig +6 -0
  16. package/example/app.json +4 -0
  17. package/example/babel.config.js +9 -0
  18. package/example/contexts.ts +9 -0
  19. package/example/harmony/AppScope/app.json5 +10 -0
  20. package/example/harmony/AppScope/resources/base/element/string.json +8 -0
  21. package/example/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  22. package/example/harmony/build-profile.template.json5 +36 -0
  23. package/example/harmony/codelinter.json +32 -0
  24. package/example/harmony/entry/build-profile.json5 +22 -0
  25. package/example/harmony/entry/hvigorfile.ts +8 -0
  26. package/example/harmony/entry/oh-package.json5 +11 -0
  27. package/example/harmony/entry/src/main/cpp/CMakeLists.txt +41 -0
  28. package/example/harmony/entry/src/main/cpp/PackageProvider.cpp +17 -0
  29. package/example/harmony/entry/src/main/ets/RNPackagesFactory.ets +13 -0
  30. package/example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf +0 -0
  31. package/example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf +0 -0
  32. package/example/harmony/entry/src/main/ets/entryability/EntryAbility.ets +27 -0
  33. package/example/harmony/entry/src/main/ets/pages/Index.ets +125 -0
  34. package/example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets +135 -0
  35. package/example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets +44 -0
  36. package/example/harmony/entry/src/main/module.json5 +52 -0
  37. package/example/harmony/entry/src/main/resources/base/element/color.json +8 -0
  38. package/example/harmony/entry/src/main/resources/base/element/string.json +16 -0
  39. package/example/harmony/entry/src/main/resources/base/media/icon.png +0 -0
  40. package/example/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  41. package/example/harmony/entry/src/main/resources/rawfile/1.txt +1 -0
  42. package/example/harmony/format.ps1 +18 -0
  43. package/example/harmony/hvigor/hvigor-config.json5 +21 -0
  44. package/example/harmony/hvigorfile.ts +9 -0
  45. package/example/harmony/oh-package.json5 +12 -0
  46. package/example/index.js +11 -0
  47. package/example/jest.config.js +11 -0
  48. package/example/metro.config.js +30 -0
  49. package/example/package.json +58 -0
  50. package/example/react-native.config.js +11 -0
  51. package/example/scripts/create-build-profile.js +46 -0
  52. package/example/src/index.tsx +22 -0
  53. package/example/tsconfig.json +20 -0
  54. package/harmony/slider/oh-package.json5 +10 -10
  55. package/harmony/slider.har +0 -0
  56. package/package.json +92 -98
  57. package/react-native.config.js +11 -0
  58. package/src/RNCSliderNativeComponent.ts +53 -47
  59. package/src/Slider.tsx +356 -350
  60. package/src/components/StepNumber.tsx +23 -17
  61. package/src/components/StepsIndicator.tsx +89 -83
  62. package/src/components/TrackMark.tsx +56 -50
  63. package/src/index.ts +9 -3
  64. package/src/utils/constants.ts +17 -11
  65. package/src/utils/styles.ts +61 -55
  66. package/tsconfig.json +23 -0
  67. package/typings/index.d.ts +214 -208
  68. package/harmony/slider/.idea/misc.xml +0 -6
  69. package/harmony/slider/.idea/modules.xml +0 -8
  70. package/harmony/slider/.idea/slider.iml +0 -8
  71. package/harmony/slider/oh-package-lock.json5 +0 -18
@@ -1,17 +1,23 @@
1
- import React from 'react';
2
- import {StyleProp, Text, TextStyle, View} from 'react-native';
3
- import {styles} from '../utils/styles';
4
-
5
- export const StepNumber = ({
6
- i,
7
- style,
8
- }: {
9
- i: number;
10
- style: StyleProp<TextStyle>;
11
- }) => {
12
- return (
13
- <View style={styles.stepNumber}>
14
- <Text style={style}>{i}</Text>
15
- </View>
16
- );
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 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,83 +1,89 @@
1
- import React, {FC, Fragment, useCallback, useMemo} from 'react';
2
- import {View} from 'react-native';
3
- import {StepNumber} from './StepNumber';
4
- import {MarkerProps, SliderTrackMark} from './TrackMark';
5
- //@ts-ignore
6
- import type {ImageSource} from 'react-native/Libraries/Image/ImageSource';
7
- import {styles} from '../utils/styles';
8
- import {constants} from '../utils/constants';
9
-
10
- export const StepsIndicator = ({
11
- options,
12
- sliderWidth,
13
- currentValue,
14
- StepMarker,
15
- renderStepNumber,
16
- thumbImage,
17
- isLTR,
18
- }: {
19
- options: number[];
20
- sliderWidth: number;
21
- currentValue: number;
22
- StepMarker?: FC<MarkerProps>;
23
- renderStepNumber?: boolean;
24
- thumbImage?: ImageSource;
25
- isLTR?: boolean;
26
- }) => {
27
- const stepNumberFontStyle = useMemo(() => {
28
- return {
29
- fontSize:
30
- options.length > 9
31
- ? constants.STEP_NUMBER_TEXT_FONT_SMALL
32
- : constants.STEP_NUMBER_TEXT_FONT_BIG,
33
- };
34
- }, [options.length]);
35
- const values = isLTR ? options.reverse() : options;
36
-
37
- const renderStepIndicator = useCallback(
38
- (i: number, index: number) => {
39
- return (
40
- <Fragment key={index}>
41
- <View style={styles.stepIndicatorElement} key={`${index}-View`}>
42
- <SliderTrackMark
43
- key={`${index}-SliderTrackMark`}
44
- isTrue={currentValue === i}
45
- index={i}
46
- thumbImage={thumbImage}
47
- StepMarker={StepMarker}
48
- currentValue={currentValue}
49
- min={options[0]}
50
- max={options[options.length - 1]}
51
- />
52
- {renderStepNumber ? (
53
- <StepNumber
54
- i={i}
55
- style={stepNumberFontStyle}
56
- key={`${index}th-step`}
57
- />
58
- ) : null}
59
- </View>
60
- </Fragment>
61
- );
62
- },
63
- [
64
- currentValue,
65
- StepMarker,
66
- options,
67
- thumbImage,
68
- renderStepNumber,
69
- stepNumberFontStyle,
70
- ],
71
- );
72
-
73
- return (
74
- <View
75
- pointerEvents="none"
76
- style={[
77
- styles.stepsIndicator,
78
- {marginHorizontal: sliderWidth * constants.MARGIN_HORIZONTAL_PADDING},
79
- ]}>
80
- {values.map((i, index) => renderStepIndicator(i, index))}
81
- </View>
82
- );
83
- };
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,50 +1,56 @@
1
- import React, {FC} from 'react';
2
- import {Image, ImageURISource, View} from 'react-native';
3
- import {styles} from '../utils/styles';
4
-
5
- export type MarkerProps = {
6
- stepMarked: boolean;
7
- currentValue: number;
8
- index: number;
9
- min: number;
10
- max: number;
11
- };
12
-
13
- export type TrackMarksProps = {
14
- isTrue: boolean;
15
- index: number;
16
- thumbImage?: ImageURISource;
17
- StepMarker?: FC<MarkerProps>;
18
- currentValue: number;
19
- min: number;
20
- max: number;
21
- };
22
-
23
- export const SliderTrackMark = ({
24
- isTrue,
25
- index,
26
- thumbImage,
27
- StepMarker,
28
- currentValue,
29
- min,
30
- max,
31
- }: TrackMarksProps) => {
32
- return (
33
- <View style={styles.trackMarkContainer}>
34
- {StepMarker ? (
35
- <StepMarker
36
- stepMarked={isTrue}
37
- index={index}
38
- currentValue={currentValue}
39
- min={min}
40
- max={max}
41
- />
42
- ) : null}
43
- {thumbImage && isTrue ? (
44
- <View style={styles.thumbImageContainer}>
45
- <Image source={thumbImage} style={styles.thumbImage} />
46
- </View>
47
- ) : null}
48
- </View>
49
- );
50
- };
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, ImageURISource, 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?: ImageURISource;
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 source={thumbImage} style={styles.thumbImage} />
52
+ </View>
53
+ ) : null}
54
+ </View>
55
+ );
56
+ };
package/src/index.ts CHANGED
@@ -1,3 +1,9 @@
1
- const RNCSlider = require('./RNCSliderNativeComponent').default;
2
-
3
- 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,11 +1,17 @@
1
- import {Platform} from 'react-native';
2
-
3
- export const constants = {
4
- SLIDER_DEFAULT_INITIAL_VALUE: 0,
5
- MARGIN_HORIZONTAL_PADDING: 0.05,
6
- STEP_NUMBER_TEXT_FONT_SMALL: 8,
7
- STEP_NUMBER_TEXT_FONT_BIG: 12,
8
- LIMIT_MIN_VALUE: Number.MIN_SAFE_INTEGER,
9
- LIMIT_MAX_VALUE: Number.MAX_SAFE_INTEGER,
10
- DEFAULT_STEP_RESOLUTION: Platform.OS === 'android' ? 128 : 1000,
11
- };
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,55 +1,61 @@
1
- import {Platform, StyleSheet} from 'react-native';
2
-
3
- export const styles = StyleSheet.create({
4
- stepNumber: {
5
- marginTop: 20,
6
- alignItems: 'center',
7
- position: 'absolute',
8
- },
9
- sliderMainContainer: {zIndex: 1, width: '100%'},
10
- defaultSlideriOS: {
11
- height: 40,
12
- },
13
- defaultSlider: {},
14
- stepsIndicator: {
15
- flex: 1,
16
- flexDirection: 'row',
17
- justifyContent: 'space-between',
18
- top: Platform.OS === 'ios' ? 10 : 0,
19
- zIndex: 2,
20
- },
21
- trackMarkContainer: {
22
- alignItems: 'center',
23
- alignContent: 'center',
24
- alignSelf: 'center',
25
- justifyContent: 'center',
26
- position: 'absolute',
27
- zIndex: 3,
28
- },
29
- thumbImageContainer: {
30
- position: 'absolute',
31
- zIndex: 3,
32
- justifyContent: 'center',
33
- alignItems: 'center',
34
- alignContent: 'center',
35
- },
36
- thumbImage: {
37
- alignContent: 'center',
38
- alignItems: 'center',
39
- position: 'absolute',
40
- },
41
- stepIndicatorElement: {
42
- alignItems: 'center',
43
- alignContent: 'center',
44
- },
45
- defaultIndicatorMarked: {
46
- height: 20,
47
- width: 5,
48
- backgroundColor: '#CCCCCC',
49
- },
50
- defaultIndicatorIdle: {
51
- height: 10,
52
- width: 2,
53
- backgroundColor: '#C0C0C0',
54
- },
55
- });
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
+ });
package/tsconfig.json ADDED
@@ -0,0 +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
+ }