@react-native-ohos/slider 4.4.4-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 (86) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/COMMITTERS.md +6 -0
  3. package/LICENSE +9 -0
  4. package/OAT.xml +73 -0
  5. package/README.OpenSource +11 -0
  6. package/README.md +13 -0
  7. package/babel.config.json +1 -1
  8. package/dist/RNCSliderNativeComponent.js +1 -1
  9. package/dist/Slider.js +1 -1
  10. package/dist/components/StepNumber.js +1 -0
  11. package/dist/components/StepsIndicator.js +1 -0
  12. package/dist/components/TrackMark.js +1 -0
  13. package/dist/utils/constants.js +1 -0
  14. package/dist/utils/styles.js +1 -0
  15. package/example/.eslintrc +19 -0
  16. package/example/.node-version +6 -0
  17. package/example/.prettierrc.js +7 -0
  18. package/example/.watchmanconfig +6 -0
  19. package/example/app.json +4 -0
  20. package/example/babel.config.js +9 -0
  21. package/example/contexts.ts +9 -0
  22. package/example/harmony/AppScope/app.json5 +10 -0
  23. package/example/harmony/AppScope/resources/base/element/string.json +8 -0
  24. package/example/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  25. package/example/harmony/build-profile.template.json5 +36 -0
  26. package/example/harmony/codelinter.json +32 -0
  27. package/example/harmony/entry/build-profile.json5 +22 -0
  28. package/example/harmony/entry/hvigorfile.ts +8 -0
  29. package/example/harmony/entry/oh-package.json5 +11 -0
  30. package/example/harmony/entry/src/main/cpp/CMakeLists.txt +41 -0
  31. package/example/harmony/entry/src/main/cpp/PackageProvider.cpp +17 -0
  32. package/example/harmony/entry/src/main/ets/RNPackagesFactory.ets +13 -0
  33. package/example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf +0 -0
  34. package/example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf +0 -0
  35. package/example/harmony/entry/src/main/ets/entryability/EntryAbility.ets +27 -0
  36. package/example/harmony/entry/src/main/ets/pages/Index.ets +125 -0
  37. package/example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets +135 -0
  38. package/example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets +44 -0
  39. package/example/harmony/entry/src/main/module.json5 +52 -0
  40. package/example/harmony/entry/src/main/resources/base/element/color.json +8 -0
  41. package/example/harmony/entry/src/main/resources/base/element/string.json +16 -0
  42. package/example/harmony/entry/src/main/resources/base/media/icon.png +0 -0
  43. package/example/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  44. package/example/harmony/entry/src/main/resources/rawfile/1.txt +1 -0
  45. package/example/harmony/format.ps1 +18 -0
  46. package/example/harmony/hvigor/hvigor-config.json5 +21 -0
  47. package/example/harmony/hvigorfile.ts +9 -0
  48. package/example/harmony/oh-package.json5 +12 -0
  49. package/example/index.js +11 -0
  50. package/example/jest.config.js +11 -0
  51. package/example/metro.config.js +30 -0
  52. package/example/package.json +58 -0
  53. package/example/react-native.config.js +11 -0
  54. package/example/scripts/create-build-profile.js +46 -0
  55. package/example/src/index.tsx +22 -0
  56. package/example/tsconfig.json +20 -0
  57. package/harmony/slider/OAT.xml +42 -0
  58. package/harmony/slider/index.ets +1 -2
  59. package/harmony/slider/oh-package.json5 +2 -2
  60. package/harmony/slider/src/main/cpp/ComponentDescriptor.h +2 -4
  61. package/harmony/slider/src/main/cpp/EventEmitters.cpp +13 -13
  62. package/harmony/slider/src/main/cpp/EventEmitters.h +15 -9
  63. package/harmony/slider/src/main/cpp/Props.cpp +9 -5
  64. package/harmony/slider/src/main/cpp/Props.h +15 -10
  65. package/harmony/slider/src/main/cpp/ShadowNodes.cpp +1 -1
  66. package/harmony/slider/src/main/cpp/ShadowNodes.h +6 -6
  67. package/harmony/slider/src/main/cpp/SliderEventEmiRequestHandler.h +28 -31
  68. package/harmony/slider/src/main/cpp/SliderJSIBinder.h +8 -12
  69. package/harmony/slider/src/main/cpp/SliderNapiBinder.h +2 -6
  70. package/harmony/slider/src/main/cpp/SliderPackage.h +6 -12
  71. package/harmony/slider.har +0 -0
  72. package/package.json +38 -24
  73. package/react-native.config.js +11 -0
  74. package/src/RNCSliderNativeComponent.ts +13 -6
  75. package/src/Slider.tsx +133 -72
  76. package/src/components/StepNumber.tsx +23 -0
  77. package/src/components/StepsIndicator.tsx +89 -0
  78. package/src/components/TrackMark.tsx +56 -0
  79. package/src/index.ts +7 -1
  80. package/src/utils/constants.ts +17 -0
  81. package/src/utils/styles.ts +61 -0
  82. package/tsconfig.json +3 -2
  83. package/typings/index.d.ts +35 -1
  84. package/.eslintrc.json +0 -20
  85. package/.flowconfig +0 -66
  86. package/harmony/slider/src/main/ets/SliderPackage.ets +0 -34
@@ -0,0 +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
+ });
package/tsconfig.json CHANGED
@@ -6,10 +6,11 @@
6
6
 
7
7
  /* Language and Environment */
8
8
  "target": "ESNext",
9
- "lib": ["ESNext"],
9
+ "lib": ["ESNext", "dom"],
10
10
 
11
11
  /* Modules */
12
- "module": "esnext",
12
+ "module": "NodeNext",
13
+ "moduleResolution": "NodeNext",
13
14
 
14
15
  /* Interop Constraints */
15
16
  "esModuleInterop": true,
@@ -1,5 +1,13 @@
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
+
1
7
  import * as React from 'react';
8
+ import { FC } from 'react';
2
9
  import * as ReactNative from 'react-native';
10
+ import { ImageURISource } from 'react-native';
3
11
 
4
12
  type Constructor<T> = new (...args: any[]) => T;
5
13
 
@@ -18,6 +26,22 @@ export interface SliderRef {
18
26
  updateValue(value: number): void;
19
27
  }
20
28
 
29
+ export type TrackMarksProps = {
30
+ isTrue: boolean;
31
+ index: number;
32
+ thumbImage?: ImageURISource;
33
+ StepMarker?: FC<MarkerProps> | boolean;
34
+ currentValue: number;
35
+ };
36
+
37
+ export type MarkerProps = {
38
+ stepMarked: boolean;
39
+ currentValue: number;
40
+ index: number;
41
+ min: number;
42
+ max: number;
43
+ };
44
+
21
45
  export interface SliderPropsIOS extends ReactNative.ViewProps {
22
46
  /**
23
47
  * Assigns a maximum track image. Only static images are supported.
@@ -148,6 +172,16 @@ export interface SliderProps
148
172
  */
149
173
  inverted?: boolean;
150
174
 
175
+ /**
176
+ * Component to be rendered for each step indicator.
177
+ */
178
+ StepMarker?: FC<MarkerProps>;
179
+
180
+ /**
181
+ *
182
+ */
183
+ renderStepNumber?: boolean;
184
+
151
185
  /**
152
186
  * A string of one or more words to be announced by the screen reader.
153
187
  * Otherwise, it will announce the value as a percentage.
@@ -177,4 +211,4 @@ declare class SliderComponent extends React.Component<SliderProps> {}
177
211
  declare const SliderBase: Constructor<ReactNative.NativeMethods> &
178
212
  typeof SliderComponent;
179
213
  export default class Slider extends SliderBase {}
180
- export type SliderIOS = Slider;
214
+ export type SliderIOS = Slider;
package/.eslintrc.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "extends": "@react-native-community",
3
- "env": {
4
- "es6": true,
5
- "jest": true
6
- },
7
- "globals": {
8
- "it": true,
9
- "expect": true,
10
- "element": true,
11
- "describe": true,
12
- "by": true,
13
- "device": true,
14
- "beforeAll": true,
15
- "beforeEach": true,
16
- "afterAll": true,
17
- "jest": true,
18
- "jasmine": true
19
- }
20
- }
package/.flowconfig DELETED
@@ -1,66 +0,0 @@
1
- [ignore]
2
- ; We fork some components by platform
3
- .*/*[.]android.js
4
-
5
- ; Ignore "BUCK" generated dirs
6
- <PROJECT_ROOT>/\.buckd/
7
-
8
- ; Ignore node_modules
9
- <PROJECT_ROOT>/node_modules/.*
10
-
11
- ; Flow doesn't support platforms
12
- .*/Libraries/Utilities/LoadingView.js
13
-
14
- .*/Libraries/Utilities/HMRLoadingView.js
15
-
16
- [untyped]
17
- .*/node_modules/@react-native-community/cli/.*/.*
18
-
19
- [include]
20
-
21
- [libs]
22
- node_modules/react-native/interface.js
23
- node_modules/react-native/flow/
24
-
25
- [options]
26
- module.system.node.resolve_dirname=node_modules
27
- module.system.node.resolve_dirname=src
28
- emoji=true
29
-
30
- module.file_ext=.js
31
- module.file_ext=.json
32
- module.file_ext=.ios.js
33
-
34
- munge_underscores=true
35
-
36
- module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
37
- module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
38
-
39
- suppress_type=$FlowIssue
40
- suppress_type=$FlowFixMe
41
- suppress_type=$FlowFixMeProps
42
- suppress_type=$FlowFixMeState
43
-
44
- [lints]
45
- sketchy-null-number=warn
46
- sketchy-null-mixed=warn
47
- sketchy-number=warn
48
- untyped-type-import=warn
49
- nonstrict-import=warn
50
- deprecated-type=warn
51
- unsafe-getters-setters=warn
52
- unnecessary-invariant=warn
53
- signature-verification-failure=warn
54
- deprecated-utility=error
55
-
56
- [strict]
57
- deprecated-type
58
- nonstrict-import
59
- sketchy-null
60
- unclear-type
61
- unsafe-getters-setters
62
- untyped-import
63
- untyped-type-import
64
-
65
- [version]
66
- ^0.163.0
@@ -1,34 +0,0 @@
1
- /**
2
- * MIT License
3
- *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
- import { RNOHPackage, ComponentBuilderContext } from '@rnoh/react-native-openharmony';
25
- import { RNCSlider } from './Slider';
26
- @Builder
27
- function buildSlider(ctx: ComponentBuilderContext) {
28
- RNCSlider({ ctx: ctx.rnComponentContext, tag: ctx.tag, })
29
- }
30
- export class SliderPackage extends RNOHPackage {
31
- createWrappedCustomRNComponentBuilderByComponentNameMap(): Map<string, WrappedBuilder<[ComponentBuilderContext]>> {
32
- return new Map().set("RNCSlider", wrapBuilder(buildSlider))
33
- }
34
- }