@proximus/lavender-switch-native 0.1.0-alpha.6 → 0.1.0-beta.0
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/dist/PxSwitch.js +1 -1
- package/package.json +10 -37
- package/CHANGELOG.md +0 -14
- package/dist/far/away/package.json +0 -36
- package/src/PxSwitch.tsx +0 -233
- package/src/index.ts +0 -1
- package/tsconfig.json +0 -8
package/dist/PxSwitch.js
CHANGED
|
@@ -86,7 +86,7 @@ export class PxSwitch extends Component {
|
|
|
86
86
|
}
|
|
87
87
|
} },
|
|
88
88
|
React.createElement(View, { style: [this.props.containerStyle] },
|
|
89
|
-
React.createElement(TouchableWithoutFeedback, { disabled: disabled, onPress: () => this._handleSwitch(), accessible:
|
|
89
|
+
React.createElement(TouchableWithoutFeedback, { disabled: disabled, onPress: () => this._handleSwitch(), accessible: true, ...e2eID(testID), ...a11y({
|
|
90
90
|
accessible: true,
|
|
91
91
|
accessibilityRole: 'switch',
|
|
92
92
|
accessibilityLabel: this.props.labelAccessibilityProp?.accessibilityLabel,
|
package/package.json
CHANGED
|
@@ -1,48 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-switch-native",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
4
|
"description": "Lavender react native switch component",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
7
10
|
"type": "module",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"clean": "rm -rf dist",
|
|
10
|
-
"transform-package-json": "node ../../../scripts/tranformPackageJson.js package.json dist/far/away",
|
|
11
|
-
"prepublish": "yarn clean && yarn transform-package-json && yarn build",
|
|
12
|
-
"build": "npx tsc -p tsconfig.json"
|
|
13
|
-
},
|
|
14
11
|
"peerDependencies": {
|
|
15
|
-
"@proximus/lavender-common-native": "
|
|
16
|
-
"@proximus/lavender-icon-native": "
|
|
17
|
-
"@proximus/lavender-styling-native": "
|
|
18
|
-
"@proximus/lavender-texts-native": "
|
|
12
|
+
"@proximus/lavender-common-native": "*",
|
|
13
|
+
"@proximus/lavender-icon-native": "*",
|
|
14
|
+
"@proximus/lavender-styling-native": "*",
|
|
15
|
+
"@proximus/lavender-texts-native": "*",
|
|
19
16
|
"react-native-gesture-handler": "*"
|
|
20
17
|
},
|
|
21
|
-
"devDependencies": {
|
|
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"
|
|
26
|
-
},
|
|
27
18
|
"publishConfig": {
|
|
28
19
|
"access": "public"
|
|
29
|
-
}
|
|
30
|
-
"lerna": {
|
|
31
|
-
"command": {
|
|
32
|
-
"publish": {
|
|
33
|
-
"assets": [
|
|
34
|
-
{
|
|
35
|
-
"from": "dist/far/away/package.json",
|
|
36
|
-
"to": "."
|
|
37
|
-
},
|
|
38
|
-
"dist/*.js",
|
|
39
|
-
"dist/*.d.ts",
|
|
40
|
-
"dist/*.d.ts.map",
|
|
41
|
-
"src",
|
|
42
|
-
"package.json"
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"gitHead": "e50a17526561b3eafb159e36c737173956093e0d"
|
|
20
|
+
}
|
|
48
21
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
**Note:** Version bump only for package @proximus/lavender-switch-native
|
|
9
|
-
|
|
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)
|
|
11
|
-
|
|
12
|
-
### Bug Fixes
|
|
13
|
-
|
|
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))
|
|
@@ -1,36 +0,0 @@
|
|
|
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/src/PxSwitch.tsx
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
AccessibilityProps,
|
|
4
|
-
Animated,
|
|
5
|
-
StyleProp,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
TouchableWithoutFeedback,
|
|
8
|
-
View,
|
|
9
|
-
ViewStyle,
|
|
10
|
-
} from 'react-native';
|
|
11
|
-
import {
|
|
12
|
-
Directions,
|
|
13
|
-
FlingGestureHandler,
|
|
14
|
-
State,
|
|
15
|
-
} from 'react-native-gesture-handler';
|
|
16
|
-
|
|
17
|
-
import { a11y, e2eID } from '@proximus/lavender-common-native';
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
ITheme,
|
|
21
|
-
IThemeContext,
|
|
22
|
-
ThemeContext,
|
|
23
|
-
} from '@proximus/lavender-styling-native';
|
|
24
|
-
|
|
25
|
-
export interface ISwitchProps extends AccessibilityProps {
|
|
26
|
-
onValueChange: (value: boolean) => void;
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
lookOnlyProps?: boolean;
|
|
29
|
-
value?: boolean;
|
|
30
|
-
testID?: string;
|
|
31
|
-
labelAccessibilityProp?: AccessibilityProps;
|
|
32
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
33
|
-
hasLabel?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface IState {
|
|
37
|
-
value: boolean;
|
|
38
|
-
transformSwitch: Animated.Value;
|
|
39
|
-
containerBackgroundColor: Animated.Value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const defaults = {
|
|
43
|
-
circleSize: 20,
|
|
44
|
-
duration: 200,
|
|
45
|
-
interpolationRange: 100,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export class PxSwitch extends Component<ISwitchProps, IState> {
|
|
49
|
-
static defaultProps = {
|
|
50
|
-
disabled: false,
|
|
51
|
-
value: false,
|
|
52
|
-
type: 'primary',
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
static contextType = ThemeContext;
|
|
56
|
-
|
|
57
|
-
constructor(props: ISwitchProps) {
|
|
58
|
-
super(props);
|
|
59
|
-
|
|
60
|
-
const { value } = props;
|
|
61
|
-
this.state = {
|
|
62
|
-
containerBackgroundColor: new Animated.Value(
|
|
63
|
-
value ? defaults.interpolationRange : -defaults.interpolationRange
|
|
64
|
-
),
|
|
65
|
-
transformSwitch: new Animated.Value(
|
|
66
|
-
value ? defaults.circleSize - 10 : -defaults.circleSize + 10
|
|
67
|
-
),
|
|
68
|
-
value: value || false,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
componentDidUpdate(prevProps: ISwitchProps) {
|
|
73
|
-
const { disabled, value } = this.props;
|
|
74
|
-
|
|
75
|
-
if (prevProps.value !== value && !disabled) {
|
|
76
|
-
this._animateSwitch(!!value);
|
|
77
|
-
this.setState({ value: !!value });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
_handleSwitch = (activate?: boolean) => {
|
|
82
|
-
const { onValueChange, disabled, lookOnlyProps } = this.props;
|
|
83
|
-
|
|
84
|
-
if (!disabled) {
|
|
85
|
-
if (lookOnlyProps) {
|
|
86
|
-
if (onValueChange) {
|
|
87
|
-
onValueChange(!this.props.value);
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
const { value } = this.state;
|
|
91
|
-
this._animateSwitch(activate ?? !value);
|
|
92
|
-
this.setState({ value: activate ?? !value }, () => {
|
|
93
|
-
if (onValueChange) {
|
|
94
|
-
onValueChange(this.state.value);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
_animateSwitch = (value: boolean) => {
|
|
102
|
-
Animated.parallel([
|
|
103
|
-
Animated.spring(this.state.transformSwitch, {
|
|
104
|
-
useNativeDriver: true,
|
|
105
|
-
toValue: value ? defaults.circleSize - 10 : -defaults.circleSize + 10,
|
|
106
|
-
}),
|
|
107
|
-
Animated.timing(this.state.containerBackgroundColor, {
|
|
108
|
-
duration: defaults.duration,
|
|
109
|
-
useNativeDriver: true,
|
|
110
|
-
toValue: value
|
|
111
|
-
? defaults.interpolationRange
|
|
112
|
-
: -defaults.interpolationRange,
|
|
113
|
-
}),
|
|
114
|
-
]).start();
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
render() {
|
|
118
|
-
const { containerBackgroundColor, value } = this.state;
|
|
119
|
-
|
|
120
|
-
const { testID, disabled, ...accessibilityProps } = this.props;
|
|
121
|
-
|
|
122
|
-
const containerBackground = containerBackgroundColor.interpolate({
|
|
123
|
-
inputRange: [-defaults.interpolationRange, defaults.interpolationRange],
|
|
124
|
-
outputRange: [
|
|
125
|
-
((this.context as IThemeContext)?.theme as ITheme)?.t(
|
|
126
|
-
'ColorBackgroundContainerStrongDefault'
|
|
127
|
-
),
|
|
128
|
-
((this.context as IThemeContext)?.theme as ITheme)?.t(
|
|
129
|
-
'ColorBackgroundPurposeSuccessDefault'
|
|
130
|
-
),
|
|
131
|
-
],
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<FlingGestureHandler
|
|
136
|
-
direction={Directions.LEFT}
|
|
137
|
-
numberOfPointers={1}
|
|
138
|
-
onHandlerStateChange={({ nativeEvent }) => {
|
|
139
|
-
if (nativeEvent.state === State.ACTIVE && value) {
|
|
140
|
-
this._handleSwitch(false);
|
|
141
|
-
}
|
|
142
|
-
}}
|
|
143
|
-
>
|
|
144
|
-
<FlingGestureHandler
|
|
145
|
-
direction={Directions.RIGHT}
|
|
146
|
-
numberOfPointers={1}
|
|
147
|
-
onHandlerStateChange={({ nativeEvent }) => {
|
|
148
|
-
if (nativeEvent.state === State.ACTIVE && !value) {
|
|
149
|
-
this._handleSwitch(true);
|
|
150
|
-
}
|
|
151
|
-
}}
|
|
152
|
-
>
|
|
153
|
-
<View style={[this.props.containerStyle]}>
|
|
154
|
-
<TouchableWithoutFeedback
|
|
155
|
-
disabled={disabled}
|
|
156
|
-
onPress={() => this._handleSwitch()}
|
|
157
|
-
accessible={false}
|
|
158
|
-
{...e2eID(testID)}
|
|
159
|
-
{...a11y({
|
|
160
|
-
accessible: true,
|
|
161
|
-
accessibilityRole: 'switch',
|
|
162
|
-
accessibilityLabel:
|
|
163
|
-
this.props.labelAccessibilityProp?.accessibilityLabel,
|
|
164
|
-
accessibilityHint:
|
|
165
|
-
this.props.labelAccessibilityProp?.accessibilityHint,
|
|
166
|
-
accessibilityState: {
|
|
167
|
-
disabled,
|
|
168
|
-
selected: value,
|
|
169
|
-
},
|
|
170
|
-
...accessibilityProps,
|
|
171
|
-
})}
|
|
172
|
-
>
|
|
173
|
-
<Animated.View
|
|
174
|
-
style={[
|
|
175
|
-
styles.track,
|
|
176
|
-
{
|
|
177
|
-
backgroundColor: containerBackground,
|
|
178
|
-
borderRadius: (
|
|
179
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
180
|
-
)?.t('RadiusPill').number,
|
|
181
|
-
width: (
|
|
182
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
183
|
-
)?.t('SizeActionInputSwitchWidth').number,
|
|
184
|
-
padding: (
|
|
185
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
186
|
-
)?.t('Padding3xsMobile').number,
|
|
187
|
-
},
|
|
188
|
-
disabled && {
|
|
189
|
-
backgroundColor: (
|
|
190
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
191
|
-
)?.t('ColorBackgroundStateDisabledDefault'),
|
|
192
|
-
},
|
|
193
|
-
]}
|
|
194
|
-
>
|
|
195
|
-
<Animated.View
|
|
196
|
-
style={[
|
|
197
|
-
{
|
|
198
|
-
width: (
|
|
199
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
200
|
-
)?.t('SizeIconM').number,
|
|
201
|
-
height: (
|
|
202
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
203
|
-
)?.t('SizeIconM').number,
|
|
204
|
-
|
|
205
|
-
borderRadius: (
|
|
206
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
207
|
-
)?.t('RadiusPill').number,
|
|
208
|
-
backgroundColor: disabled
|
|
209
|
-
? ((this.context as IThemeContext)?.theme as ITheme)?.t(
|
|
210
|
-
'ColorBackgroundStateDisabledDefault'
|
|
211
|
-
)
|
|
212
|
-
: ((this.context as IThemeContext)?.theme as ITheme)?.t(
|
|
213
|
-
'ColorBackgroundContainerLightDefault'
|
|
214
|
-
),
|
|
215
|
-
transform: [{ translateX: this.state.transformSwitch }],
|
|
216
|
-
},
|
|
217
|
-
]}
|
|
218
|
-
></Animated.View>
|
|
219
|
-
</Animated.View>
|
|
220
|
-
</TouchableWithoutFeedback>
|
|
221
|
-
</View>
|
|
222
|
-
</FlingGestureHandler>
|
|
223
|
-
</FlingGestureHandler>
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const styles = StyleSheet.create({
|
|
229
|
-
track: {
|
|
230
|
-
flexDirection: 'row',
|
|
231
|
-
justifyContent: 'center',
|
|
232
|
-
},
|
|
233
|
-
});
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './PxSwitch';
|