@proximus/lavender-switch-native 0.1.0-alpha.4 → 0.1.0-alpha.6

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/CHANGELOG.md CHANGED
@@ -3,53 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [0.1.0-alpha.4](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.3...@proximus/lavender-switch-native@0.1.0-alpha.4) (2025-09-19)
6
+ # [0.1.0-alpha.6](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.5...@proximus/lavender-switch-native@0.1.0-alpha.6) (2025-09-26)
7
7
 
8
8
  **Note:** Version bump only for package @proximus/lavender-switch-native
9
9
 
10
- # [0.1.0-alpha.3](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.2...@proximus/lavender-switch-native@0.1.0-alpha.3) (2025-09-12)
11
-
12
- **Note:** Version bump only for package @proximus/lavender-switch-native
13
-
14
- # [0.1.0-alpha.2](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.1...@proximus/lavender-switch-native@0.1.0-alpha.2) (2025-09-05)
15
-
16
- ### Features
17
-
18
- - **BCRI-4279213:** update token architecture and component styles ([#18](https://github.com/Pxs-Corporate/react-native-lavender/issues/18)) ([2fabf41](https://github.com/Pxs-Corporate/react-native-lavender/commit/2fabf416ce069e9756daa868c3012181db87e7f5))
19
-
20
- # [0.1.0-alpha.1](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.0...@proximus/lavender-switch-native@0.1.0-alpha.1) (2025-08-13)
21
-
22
- ### Bug Fixes
23
-
24
- - **BCRI-4210372:** fix types field in modules ([68ac126](https://github.com/Pxs-Corporate/react-native-lavender/commit/68ac12657112473ae9e0e683076b1d9172be9ce6))
25
-
26
- # 0.1.0-alpha.0 (2025-08-13)
10
+ # [0.1.0-alpha.5](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.4...@proximus/lavender-switch-native@0.1.0-alpha.5) (2025-09-25)
27
11
 
28
12
  ### Bug Fixes
29
13
 
30
- - **BCRI-000000:** switch using tokens ([0442cc0](https://github.com/Pxs-Corporate/react-native-lavender/commit/0442cc0aba3fcbbcb21938da0747ea593d413bf6))
31
- - **BCRI-00000:** mendix widgets ids for backward compatibility ([69e61fd](https://github.com/Pxs-Corporate/react-native-lavender/commit/69e61fde51b203b947ec7a1094f10067a1ecfdbb))
32
-
33
- ### Features
34
-
35
- - **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
36
- - **BCRI-3651771:** switch module ([d6f8151](https://github.com/Pxs-Corporate/react-native-lavender/commit/d6f81510e13ca3634f843caa0286c444373a039c))
37
- - **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
38
- - **BCRI-4002610:** update icon handling and remove deprecated font references ([4399fe4](https://github.com/Pxs-Corporate/react-native-lavender/commit/4399fe4bff06aa70f5c29705fcc89d5243b0e3e7))
39
- - **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
40
- - **BCRI-4210372:** fix bad version numbers ([bc6a8ba](https://github.com/Pxs-Corporate/react-native-lavender/commit/bc6a8ba48c15347442f2ac38dacae7ffba3d95eb))
41
-
42
- # (2025-08-13)
43
-
44
- ### Bug Fixes
45
-
46
- - **BCRI-000000:** switch using tokens ([0442cc0](https://github.com/Pxs-Corporate/react-native-lavender/commit/0442cc0aba3fcbbcb21938da0747ea593d413bf6))
47
- - **BCRI-00000:** mendix widgets ids for backward compatibility ([69e61fd](https://github.com/Pxs-Corporate/react-native-lavender/commit/69e61fde51b203b947ec7a1094f10067a1ecfdbb))
48
-
49
- ### Features
50
-
51
- - **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
52
- - **BCRI-3651771:** switch module ([d6f8151](https://github.com/Pxs-Corporate/react-native-lavender/commit/d6f81510e13ca3634f843caa0286c444373a039c))
53
- - **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
54
- - **BCRI-4002610:** update icon handling and remove deprecated font references ([4399fe4](https://github.com/Pxs-Corporate/react-native-lavender/commit/4399fe4bff06aa70f5c29705fcc89d5243b0e3e7))
55
- - **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
14
+ - **BCRI-000000:** no free space on gh runner during build ([#27](https://github.com/Pxs-Corporate/react-native-lavender/issues/27)) ([a7c8604](https://github.com/Pxs-Corporate/react-native-lavender/commit/a7c86043b5cefcb10fd768d449c5718fbabe87ec))
@@ -0,0 +1,130 @@
1
+ import React, { Component } from 'react';
2
+ import { Animated, StyleSheet, TouchableWithoutFeedback, View, } from 'react-native';
3
+ import { Directions, FlingGestureHandler, State, } from 'react-native-gesture-handler';
4
+ import { a11y, e2eID } from '@proximus/lavender-common-native';
5
+ import { ThemeContext, } from '@proximus/lavender-styling-native';
6
+ const defaults = {
7
+ circleSize: 20,
8
+ duration: 200,
9
+ interpolationRange: 100,
10
+ };
11
+ export class PxSwitch extends Component {
12
+ static defaultProps = {
13
+ disabled: false,
14
+ value: false,
15
+ type: 'primary',
16
+ };
17
+ static contextType = ThemeContext;
18
+ constructor(props) {
19
+ super(props);
20
+ const { value } = props;
21
+ this.state = {
22
+ containerBackgroundColor: new Animated.Value(value ? defaults.interpolationRange : -defaults.interpolationRange),
23
+ transformSwitch: new Animated.Value(value ? defaults.circleSize - 10 : -defaults.circleSize + 10),
24
+ value: value || false,
25
+ };
26
+ }
27
+ componentDidUpdate(prevProps) {
28
+ const { disabled, value } = this.props;
29
+ if (prevProps.value !== value && !disabled) {
30
+ this._animateSwitch(!!value);
31
+ this.setState({ value: !!value });
32
+ }
33
+ }
34
+ _handleSwitch = (activate) => {
35
+ const { onValueChange, disabled, lookOnlyProps } = this.props;
36
+ if (!disabled) {
37
+ if (lookOnlyProps) {
38
+ if (onValueChange) {
39
+ onValueChange(!this.props.value);
40
+ }
41
+ }
42
+ else {
43
+ const { value } = this.state;
44
+ this._animateSwitch(activate ?? !value);
45
+ this.setState({ value: activate ?? !value }, () => {
46
+ if (onValueChange) {
47
+ onValueChange(this.state.value);
48
+ }
49
+ });
50
+ }
51
+ }
52
+ };
53
+ _animateSwitch = (value) => {
54
+ Animated.parallel([
55
+ Animated.spring(this.state.transformSwitch, {
56
+ useNativeDriver: true,
57
+ toValue: value ? defaults.circleSize - 10 : -defaults.circleSize + 10,
58
+ }),
59
+ Animated.timing(this.state.containerBackgroundColor, {
60
+ duration: defaults.duration,
61
+ useNativeDriver: true,
62
+ toValue: value
63
+ ? defaults.interpolationRange
64
+ : -defaults.interpolationRange,
65
+ }),
66
+ ]).start();
67
+ };
68
+ render() {
69
+ const { containerBackgroundColor, value } = this.state;
70
+ const { testID, disabled, ...accessibilityProps } = this.props;
71
+ const containerBackground = containerBackgroundColor.interpolate({
72
+ inputRange: [-defaults.interpolationRange, defaults.interpolationRange],
73
+ outputRange: [
74
+ this.context?.theme?.t('ColorBackgroundContainerStrongDefault'),
75
+ this.context?.theme?.t('ColorBackgroundPurposeSuccessDefault'),
76
+ ],
77
+ });
78
+ return (React.createElement(FlingGestureHandler, { direction: Directions.LEFT, numberOfPointers: 1, onHandlerStateChange: ({ nativeEvent }) => {
79
+ if (nativeEvent.state === State.ACTIVE && value) {
80
+ this._handleSwitch(false);
81
+ }
82
+ } },
83
+ React.createElement(FlingGestureHandler, { direction: Directions.RIGHT, numberOfPointers: 1, onHandlerStateChange: ({ nativeEvent }) => {
84
+ if (nativeEvent.state === State.ACTIVE && !value) {
85
+ this._handleSwitch(true);
86
+ }
87
+ } },
88
+ React.createElement(View, { style: [this.props.containerStyle] },
89
+ React.createElement(TouchableWithoutFeedback, { disabled: disabled, onPress: () => this._handleSwitch(), accessible: false, ...e2eID(testID), ...a11y({
90
+ accessible: true,
91
+ accessibilityRole: 'switch',
92
+ accessibilityLabel: this.props.labelAccessibilityProp?.accessibilityLabel,
93
+ accessibilityHint: this.props.labelAccessibilityProp?.accessibilityHint,
94
+ accessibilityState: {
95
+ disabled,
96
+ selected: value,
97
+ },
98
+ ...accessibilityProps,
99
+ }) },
100
+ React.createElement(Animated.View, { style: [
101
+ styles.track,
102
+ {
103
+ backgroundColor: containerBackground,
104
+ borderRadius: this.context?.theme?.t('RadiusPill').number,
105
+ width: this.context?.theme?.t('SizeActionInputSwitchWidth').number,
106
+ padding: this.context?.theme?.t('Padding3xsMobile').number,
107
+ },
108
+ disabled && {
109
+ backgroundColor: this.context?.theme?.t('ColorBackgroundStateDisabledDefault'),
110
+ },
111
+ ] },
112
+ React.createElement(Animated.View, { style: [
113
+ {
114
+ width: this.context?.theme?.t('SizeIconM').number,
115
+ height: this.context?.theme?.t('SizeIconM').number,
116
+ borderRadius: this.context?.theme?.t('RadiusPill').number,
117
+ backgroundColor: disabled
118
+ ? this.context?.theme?.t('ColorBackgroundStateDisabledDefault')
119
+ : this.context?.theme?.t('ColorBackgroundContainerLightDefault'),
120
+ transform: [{ translateX: this.state.transformSwitch }],
121
+ },
122
+ ] })))))));
123
+ }
124
+ }
125
+ const styles = StyleSheet.create({
126
+ track: {
127
+ flexDirection: 'row',
128
+ justifyContent: 'center',
129
+ },
130
+ });
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@proximus/lavender-switch-native",
3
+ "version": "0.1.0-alpha.6",
4
+ "description": "Lavender react native switch component",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "type": "module",
8
+ "peerDependencies": {
9
+ "@proximus/lavender-common-native": "*",
10
+ "@proximus/lavender-icon-native": "*",
11
+ "@proximus/lavender-styling-native": "*",
12
+ "@proximus/lavender-texts-native": "*",
13
+ "react-native-gesture-handler": "*"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "lerna": {
19
+ "command": {
20
+ "publish": {
21
+ "assets": [
22
+ {
23
+ "from": "dist/far/away/package.json",
24
+ "to": "."
25
+ },
26
+ "dist/*.js",
27
+ "dist/*.d.ts",
28
+ "dist/*.d.ts.map",
29
+ "src",
30
+ "package.json"
31
+ ]
32
+ }
33
+ }
34
+ },
35
+ "gitHead": "e50a17526561b3eafb159e36c737173956093e0d"
36
+ }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './PxSwitch';
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@proximus/lavender-switch-native",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.6",
4
4
  "description": "Lavender react native switch component",
5
5
  "license": "MIT",
6
6
  "main": "src/index.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "clean": "rm -rf dist",
10
- "prepublish": "yarn clean && yarn build",
10
+ "transform-package-json": "node ../../../scripts/tranformPackageJson.js package.json dist/far/away",
11
+ "prepublish": "yarn clean && yarn transform-package-json && yarn build",
11
12
  "build": "npx tsc -p tsconfig.json"
12
13
  },
13
14
  "peerDependencies": {
@@ -18,10 +19,10 @@
18
19
  "react-native-gesture-handler": "*"
19
20
  },
20
21
  "devDependencies": {
21
- "@proximus/lavender-common-native": "0.1.0-alpha.4",
22
- "@proximus/lavender-icon-native": "0.1.0-alpha.4",
23
- "@proximus/lavender-styling-native": "0.1.0-alpha.3",
24
- "@proximus/lavender-texts-native": "0.1.0-alpha.4"
22
+ "@proximus/lavender-common-native": "0.1.0-alpha.6",
23
+ "@proximus/lavender-icon-native": "0.1.0-alpha.6",
24
+ "@proximus/lavender-styling-native": "0.1.0-alpha.5",
25
+ "@proximus/lavender-texts-native": "0.1.0-alpha.6"
25
26
  },
26
27
  "publishConfig": {
27
28
  "access": "public"
@@ -30,12 +31,18 @@
30
31
  "command": {
31
32
  "publish": {
32
33
  "assets": [
33
- "dist",
34
+ {
35
+ "from": "dist/far/away/package.json",
36
+ "to": "."
37
+ },
38
+ "dist/*.js",
39
+ "dist/*.d.ts",
40
+ "dist/*.d.ts.map",
34
41
  "src",
35
42
  "package.json"
36
43
  ]
37
44
  }
38
45
  }
39
46
  },
40
- "gitHead": "6e9252a716a08ededdfbfd6f5b1db70ab21e026e"
47
+ "gitHead": "e50a17526561b3eafb159e36c737173956093e0d"
41
48
  }
package/tsconfig.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "outDir": "dist"
5
5
  },
6
6
  "include": ["src","../../../lib.d.ts"],
7
- "exclude": ["dist", "node_modules", "src/**/*.test.ts", "src/**/*.spec.ts"]
7
+ "exclude": ["dist", "node_modules", "src/**/*.spec.tsx", "src/**/*.spec.ts"]
8
8
  }