@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
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "react-native-harmony-tester",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "i": "cd ../ && npm i && npm run pack && cd ./example && npm i",
7
+ "reStart": "npm run install:pkg && npm run codegen && hdc rport tcp:8081 tcp:8081 && react-native start",
8
+ "start": "hdc rport tcp:8081 tcp:8081 && react-native start",
9
+ "codegen": "react-native codegen-harmony --rnoh-module-path ./harmony/entry/oh_modules/@rnoh/react-native-openharmony",
10
+ "pack:pkg": "cd ../ && npm pack && cd ./example",
11
+ "install:pkg": "npm uninstall @react-native-ohos/slider && npm run pack:pkg && npm i @react-native-ohos/slider@file:../react-native-ohos-slider-5.0.1-rc.1.tgz",
12
+ "dev": "npm run codegen && react-native bundle-harmony --dev --minify=false",
13
+ "prod": "npm run codegen && react-native bundle-harmony --dev=false --minify=true",
14
+ "postinstall": "node ./scripts/create-build-profile",
15
+ "fast:pkg": "cd ../ && npm i --legacy-peer-deps && npm pack && cd ./example && npm i && npm run dev"
16
+ },
17
+ "dependencies": {
18
+ "@react-native-ohos/slider": "file:../react-native-ohos-slider-5.0.1-rc.1.tgz",
19
+ "react": "18.3.1",
20
+ "react-native": "0.77.1",
21
+ "react-native-harmony": "file:../packages/rnoh-react-native-harmony-0.77.10.tgz"
22
+ },
23
+ "devDependencies": {
24
+ "@babel/core": "^7.25.2",
25
+ "@babel/preset-env": "^7.25.3",
26
+ "@babel/runtime": "^7.25.0",
27
+ "@react-native-community/cli": "15.0.1",
28
+ "@react-native-community/cli-platform-android": "15.0.1",
29
+ "@react-native-community/cli-platform-ios": "15.0.1",
30
+ "@react-native-community/eslint-config": "^3.2.0",
31
+ "@react-native/babel-preset": "0.77.1",
32
+ "@react-native/eslint-config": "0.77.1",
33
+ "@react-native/metro-config": "^0.77.1",
34
+ "@react-native/typescript-config": "0.77.1",
35
+ "@rnoh/react-native-harmony-cli": "file:../packages/rnoh-react-native-harmony-cli-0.77.10.tgz",
36
+ "@tsconfig/react-native": "^3.0.0",
37
+ "@types/d3-scale-chromatic": "^3.0.0",
38
+ "@types/jest": "^29.5.13",
39
+ "@types/react": "^18.2.6",
40
+ "@types/react-test-renderer": "^18.0.0",
41
+ "babel-jest": "^29.6.3",
42
+ "eslint": "^8.19.0",
43
+ "jest": "^29.7.0",
44
+ "metro-react-native-babel-preset": "0.76.8",
45
+ "prettier": "2.8.8",
46
+ "react-test-renderer": "18.3.1",
47
+ "typescript": "5.5.4"
48
+ },
49
+ "overrides": {
50
+ "@react-native-community/cli": "15.0.1"
51
+ },
52
+ "resolutions": {
53
+ "@react-native-community/cli": "15.0.1"
54
+ },
55
+ "engines": {
56
+ "node": ">=18"
57
+ }
58
+ }
@@ -0,0 +1,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
+ module.exports = {
8
+ project: {
9
+ },
10
+ assets: ['./assets/fonts/'],
11
+ };
@@ -0,0 +1,46 @@
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
+
8
+ const fs = require('fs');
9
+ const JSON5 = require('json5');
10
+ const path = require('path');
11
+
12
+ const templatePath = path.join(
13
+ __dirname,
14
+ '..',
15
+ 'harmony',
16
+ 'build-profile.template.json5',
17
+ );
18
+ const existingProfilePath = path.join(
19
+ __dirname,
20
+ '..',
21
+ 'harmony',
22
+ 'build-profile.json5',
23
+ );
24
+
25
+ if (fs.existsSync(existingProfilePath)) {
26
+ let existingProfile = JSON5.parse(
27
+ fs.readFileSync(existingProfilePath, 'utf-8'),
28
+ );
29
+ let template = JSON5.parse(fs.readFileSync(templatePath, 'utf-8'));
30
+ let signingConfigs =
31
+ existingProfile.app && existingProfile.app.signingConfigs;
32
+
33
+ existingProfile = {...template};
34
+
35
+ if (signingConfigs) {
36
+ existingProfile.app.signingConfigs = signingConfigs;
37
+ }
38
+
39
+ fs.writeFileSync(
40
+ existingProfilePath,
41
+ JSON5.stringify(existingProfile, null, 2),
42
+ );
43
+ } else {
44
+ // File doesn't exist, create a copy from the template
45
+ fs.copyFileSync(templatePath, existingProfilePath);
46
+ }
@@ -0,0 +1,22 @@
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 Slider from "@react-native-community/slider"
8
+ import { View } from 'react-native'
9
+
10
+ export default function SliderExample() {
11
+ return (
12
+ <View style={{ backgroundColor: 'red', width: 200, height: 100 ,margin:100 }}>
13
+ <Slider
14
+ style={{ width: 200, height: 40 }}
15
+ minimumValue={0}
16
+ maximumValue={1}
17
+ minimumTrackTintColor="#FFFFFF"
18
+ maximumTrackTintColor="#000000"
19
+ />
20
+ </View>
21
+ );
22
+ };
@@ -0,0 +1,20 @@
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
+ {
8
+ "extends": "@react-native/typescript-config/tsconfig.json",
9
+ "compilerOptions": {
10
+ "jsx": "react-native",
11
+ "paths": {
12
+ "react-native": [
13
+ "./node_modules/react-native-harmony"
14
+ ],
15
+ },
16
+ },
17
+ "exclude": [
18
+ "harmony"
19
+ ]
20
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "name": "@react-native-ohos/slider",
3
- "version": "5.0.1-rc.1",
4
- "description": "@react-native-community/slider for HarmonyOS",
5
- "main": "index.ets",
6
- "author": "Huawei",
7
- "license": "MIT",
8
- "dependencies": {
9
- "@rnoh/react-native-openharmony": "file:../react_native_openharmony.har"
10
- }
1
+ {
2
+ "name": "@react-native-ohos/slider",
3
+ "version": "5.0.1",
4
+ "description": "@react-native-community/slider for HarmonyOS",
5
+ "main": "index.ets",
6
+ "author": "Huawei",
7
+ "license": "MIT",
8
+ "dependencies": {
9
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony.har"
10
+ }
11
11
  }
Binary file
package/package.json CHANGED
@@ -1,98 +1,92 @@
1
- {
2
- "name": "@react-native-ohos/slider",
3
- "version": "5.0.1-rc.1",
4
- "license": "MIT",
5
- "author": "react-native-community",
6
- "homepage": "https://github.com/callstack/react-native-slider#readme",
7
- "description": "React Native component used to select a single value from a range of values.",
8
- "harmony": {
9
- "alias": "@react-native-community/slider"
10
- },
11
- "files": [
12
- "dist",
13
- "src",
14
- "typings",
15
- "harmony"
16
- ],
17
- "publishConfig": {
18
- "registry": "https://npm.pkg.github.com"
19
- },
20
- "main": "dist/Slider.js",
21
- "types": "typings/index.d.ts",
22
- "keywords": [
23
- "react-native",
24
- "react native",
25
- "slider"
26
- ],
27
- "scripts": {
28
- "prepare": "babel --extensions \".ts,.tsx\" --out-dir dist src",
29
- "lint": "npx eslint src",
30
- "test": "npx jest src"
31
- },
32
- "dependencies": {
33
- "@react-native-community/slider": "5.0.0"
34
- },
35
- "devDependencies": {
36
- "@babel/cli": "^7.8.4",
37
- "@babel/core": "^7.25.2",
38
- "@babel/preset-flow": "^7.9.0",
39
- "@babel/preset-typescript": "^7.18.6",
40
- "@babel/runtime": "^7.25.0",
41
- "@react-native-community/cli": "15.0.1",
42
- "@react-native-community/cli-platform-android": "15.0.1",
43
- "@react-native-community/cli-platform-ios": "15.0.1",
44
- "@react-native-community/eslint-config": "^3.2.0",
45
- "@react-native/babel-preset": "0.76.3",
46
- "@react-native/eslint-config": "0.76.3",
47
- "@react-native/metro-config": "0.76.3",
48
- "@react-native/typescript-config": "0.76.3",
49
- "@types/jest": "^28.1.8",
50
- "@types/react": "^18.2.6",
51
- "@types/react-test-renderer": "^18.0.0",
52
- "babel-jest": "^29.7.0",
53
- "babel-plugin-module-resolver": "5.0.0",
54
- "copyfiles": "^2.4.1",
55
- "eslint": "^8.19.0",
56
- "eslint-plugin-prettier": "4.2.1",
57
- "eslint-plugin-react": "^7.30.1",
58
- "eslint-plugin-react-native": "^4.0.0",
59
- "flow-bin": "^0.163.0",
60
- "jest": "^29.5.0",
61
- "prettier": "2.8.8",
62
- "react": "^18.3.1",
63
- "react-native": "^0.77.1",
64
- "react-native-windows": "^0.76.2",
65
- "react-test-renderer": "^18.3.1",
66
- "typescript": "^5.0.4"
67
- },
68
- "repository": {
69
- "type": "git",
70
- "url": "https://github.com/react-native-oh-library/react-native-slider.git"
71
- },
72
- "jest": {
73
- "preset": "react-native",
74
- "verbose": true,
75
- "modulePathIgnorePatterns": [
76
- "/e2e/"
77
- ]
78
- },
79
- "prettier": {
80
- "singleQuote": true,
81
- "trailingComma": "all",
82
- "bracketSpacing": false,
83
- "jsxBracketSameLine": true
84
- },
85
- "codegenConfig": {
86
- "name": "RNCSlider",
87
- "type": "components",
88
- "jsSrcsDir": "src",
89
- "android": {
90
- "javaPackageName": "com.reactnativecommunity.slider"
91
- },
92
- "ios": {
93
- "componentProvider": {
94
- "RNCSlider": "RNCSliderComponentView"
95
- }
96
- }
97
- }
98
- }
1
+ {
2
+ "name": "@react-native-ohos/slider",
3
+ "version": "5.0.1",
4
+ "license": "MIT",
5
+ "author": "react-native-community",
6
+ "homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-slider/tree/br_rnoh0.77#readme",
7
+ "description": "React Native component used to select a single value from a range of values.",
8
+ "harmony": {
9
+ "alias": "@react-native-community/slider"
10
+ },
11
+ "publishConfig": {
12
+ "registry": "https://npm.pkg.github.com"
13
+ },
14
+ "main": "dist/Slider.js",
15
+ "types": "typings/index.d.ts",
16
+ "keywords": [
17
+ "react-native",
18
+ "react native",
19
+ "slider"
20
+ ],
21
+ "scripts": {
22
+ "prepare": "babel --extensions \".ts,.tsx\" --out-dir dist src",
23
+ "lint": "npx eslint src",
24
+ "test": "npx jest src"
25
+ },
26
+ "dependencies": {
27
+ "@react-native-community/slider": "5.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@babel/cli": "^7.8.4",
31
+ "@babel/core": "^7.25.2",
32
+ "@babel/preset-flow": "^7.9.0",
33
+ "@babel/preset-typescript": "^7.18.6",
34
+ "@babel/runtime": "^7.25.0",
35
+ "@react-native-community/cli": "15.0.1",
36
+ "@react-native-community/cli-platform-android": "15.0.1",
37
+ "@react-native-community/cli-platform-ios": "15.0.1",
38
+ "@react-native-community/eslint-config": "^3.2.0",
39
+ "@react-native/babel-preset": "0.76.3",
40
+ "@react-native/eslint-config": "0.76.3",
41
+ "@react-native/metro-config": "0.76.3",
42
+ "@react-native/typescript-config": "0.76.3",
43
+ "@types/jest": "^28.1.8",
44
+ "@types/react": "^18.2.6",
45
+ "@types/react-test-renderer": "^18.0.0",
46
+ "babel-jest": "^29.7.0",
47
+ "babel-plugin-module-resolver": "5.0.0",
48
+ "copyfiles": "^2.4.1",
49
+ "eslint": "^8.19.0",
50
+ "eslint-plugin-prettier": "4.2.1",
51
+ "eslint-plugin-react": "^7.30.1",
52
+ "eslint-plugin-react-native": "^4.0.0",
53
+ "flow-bin": "^0.163.0",
54
+ "jest": "^29.5.0",
55
+ "prettier": "2.8.8",
56
+ "react": "^18.3.1",
57
+ "react-native": "^0.77.1",
58
+ "react-native-windows": "^0.76.2",
59
+ "react-test-renderer": "^18.3.1",
60
+ "typescript": "^5.0.4"
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-slider.git"
65
+ },
66
+ "jest": {
67
+ "preset": "react-native",
68
+ "verbose": true,
69
+ "modulePathIgnorePatterns": [
70
+ "/e2e/"
71
+ ]
72
+ },
73
+ "prettier": {
74
+ "singleQuote": true,
75
+ "trailingComma": "all",
76
+ "bracketSpacing": false,
77
+ "jsxBracketSameLine": true
78
+ },
79
+ "codegenConfig": {
80
+ "name": "RNCSlider",
81
+ "type": "components",
82
+ "jsSrcsDir": "src",
83
+ "android": {
84
+ "javaPackageName": "com.reactnativecommunity.slider"
85
+ },
86
+ "ios": {
87
+ "componentProvider": {
88
+ "RNCSlider": "RNCSliderComponentView"
89
+ }
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ android: {
5
+ libraryName: 'RNCSlider',
6
+ componentDescriptors: ['RNCSliderComponentDescriptor'],
7
+ cmakeListsPath: 'src/main/jni/CMakeLists.txt',
8
+ },
9
+ },
10
+ },
11
+ };
@@ -1,47 +1,53 @@
1
- import type {ColorValue, HostComponent, ViewProps} from 'react-native';
2
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
- //@ts-ignore
4
- import type {ImageSource} from 'react-native/Libraries/Image/ImageSource';
5
- import type {
6
- Float,
7
- WithDefault,
8
- DirectEventHandler,
9
- BubblingEventHandler,
10
- Double,
11
- } from 'react-native/Libraries/Types/CodegenTypes';
12
-
13
- type Event = Readonly<{
14
- value: Float;
15
- fromUser?: boolean;
16
- }>;
17
-
18
- export interface NativeProps extends ViewProps {
19
- accessibilityUnits?: string;
20
- accessibilityIncrements?: ReadonlyArray<string>;
21
- disabled?: WithDefault<boolean, false>;
22
- inverted?: WithDefault<boolean, false>;
23
- vertical?: WithDefault<boolean, false>;
24
- tapToSeek?: WithDefault<boolean, false>;
25
- maximumTrackImage?: ImageSource;
26
- maximumTrackTintColor?: ColorValue;
27
- maximumValue?: Double;
28
- minimumTrackImage?: ImageSource;
29
- minimumTrackTintColor?: ColorValue;
30
- minimumValue?: Double;
31
- onChange?: BubblingEventHandler<Event>;
32
- onRNCSliderSlidingStart?: DirectEventHandler<Event>;
33
- onRNCSliderSlidingComplete?: DirectEventHandler<Event>;
34
- onRNCSliderValueChange?: BubblingEventHandler<Event>;
35
- step?: Double;
36
- testID?: string;
37
- thumbImage?: ImageSource;
38
- thumbTintColor?: ColorValue;
39
- trackImage?: ImageSource;
40
- value?: Float;
41
- lowerLimit?: Float;
42
- upperLimit?: Float;
43
- }
44
-
45
- export default codegenNativeComponent<NativeProps>('RNCSlider', {
46
- interfaceOnly: true,
47
- }) as HostComponent<NativeProps>;
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 type {ColorValue, HostComponent, ViewProps} from 'react-native';
8
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
9
+ //@ts-ignore
10
+ import type {ImageSource} from 'react-native/Libraries/Image/ImageSource';
11
+ import type {
12
+ Float,
13
+ WithDefault,
14
+ DirectEventHandler,
15
+ BubblingEventHandler,
16
+ Double,
17
+ } from 'react-native/Libraries/Types/CodegenTypes';
18
+
19
+ type Event = Readonly<{
20
+ value: Float;
21
+ fromUser?: boolean;
22
+ }>;
23
+
24
+ export interface NativeProps extends ViewProps {
25
+ accessibilityUnits?: string;
26
+ accessibilityIncrements?: ReadonlyArray<string>;
27
+ disabled?: WithDefault<boolean, false>;
28
+ inverted?: WithDefault<boolean, false>;
29
+ vertical?: WithDefault<boolean, false>;
30
+ tapToSeek?: WithDefault<boolean, false>;
31
+ maximumTrackImage?: ImageSource;
32
+ maximumTrackTintColor?: ColorValue;
33
+ maximumValue?: Double;
34
+ minimumTrackImage?: ImageSource;
35
+ minimumTrackTintColor?: ColorValue;
36
+ minimumValue?: Double;
37
+ onChange?: BubblingEventHandler<Event>;
38
+ onRNCSliderSlidingStart?: DirectEventHandler<Event>;
39
+ onRNCSliderSlidingComplete?: DirectEventHandler<Event>;
40
+ onRNCSliderValueChange?: BubblingEventHandler<Event>;
41
+ step?: Double;
42
+ testID?: string;
43
+ thumbImage?: ImageSource;
44
+ thumbTintColor?: ColorValue;
45
+ trackImage?: ImageSource;
46
+ value?: Float;
47
+ lowerLimit?: Float;
48
+ upperLimit?: Float;
49
+ }
50
+
51
+ export default codegenNativeComponent<NativeProps>('RNCSlider', {
52
+ interfaceOnly: true,
53
+ }) as HostComponent<NativeProps>;