@ledvance/base 1.1.13 → 1.1.15

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 (65) hide show
  1. package/.prettierrc.js +0 -0
  2. package/package.json +1 -1
  3. package/src/api/native.d.ts +5 -0
  4. package/src/api/native.ts +193 -160
  5. package/src/api/nativeEventEmitter.ts +54 -54
  6. package/src/components/Card.tsx +25 -25
  7. package/src/components/Cell.tsx +32 -32
  8. package/src/components/ColorAdjustView.tsx +44 -44
  9. package/src/components/ColorTempAdjustView.tsx +37 -37
  10. package/src/components/ColorsLine.d.ts +7 -0
  11. package/src/components/ColorsLine.tsx +48 -0
  12. package/src/components/DeleteButton.d.ts +1 -1
  13. package/src/components/DeleteButton.tsx +27 -27
  14. package/src/components/Dialog.tsx +28 -28
  15. package/src/components/FanAdjustView.tsx +115 -105
  16. package/src/components/InfoText.tsx +29 -29
  17. package/src/components/LampAdjustView.tsx +52 -52
  18. package/src/components/LinearGradientLine.tsx +53 -53
  19. package/src/components/MoodColorsLine.d.ts +9 -0
  20. package/src/components/MoodColorsLine.tsx +38 -0
  21. package/src/components/Page.tsx +34 -34
  22. package/src/components/Popup.tsx +17 -17
  23. package/src/components/Segmented.d.ts +2 -2
  24. package/src/components/Segmented.tsx +66 -65
  25. package/src/components/Spacer.tsx +5 -5
  26. package/src/components/Tag.tsx +42 -42
  27. package/src/components/TextButton.d.ts +1 -1
  28. package/src/components/TextButton.tsx +23 -23
  29. package/src/components/TextField.tsx +58 -58
  30. package/src/components/connect.tsx +10 -10
  31. package/src/components/ldvColorBrightness.tsx +12 -12
  32. package/src/components/ldvColorSlider.tsx +109 -109
  33. package/src/components/ldvPickerView.tsx +70 -70
  34. package/src/components/ldvPresetView.tsx +68 -68
  35. package/src/components/ldvSaturation.tsx +14 -14
  36. package/src/components/ldvSlider.d.ts +3 -3
  37. package/src/components/ldvSlider.tsx +93 -93
  38. package/src/components/ldvSwitch.tsx +35 -35
  39. package/src/components/ldvTemperatureSlider.tsx +120 -120
  40. package/src/components/ldvTopBar.tsx +50 -50
  41. package/src/components/ldvTopName.tsx +44 -44
  42. package/src/components/segmentControl.tsx +59 -59
  43. package/src/components/weekSelect.tsx +76 -76
  44. package/src/composeLayout.tsx +165 -165
  45. package/src/i18n/index.ts +12 -12
  46. package/src/i18n/strings.ts +11004 -11004
  47. package/src/main.tsx +4 -4
  48. package/src/models/GlobalParams.ts +7 -7
  49. package/src/models/TuyaApi.d.ts +3 -3
  50. package/src/models/TuyaApi.ts +61 -61
  51. package/src/models/combine.ts +7 -7
  52. package/src/models/configureStore.ts +14 -14
  53. package/src/models/index.ts +4 -4
  54. package/src/models/modules/NativePropsSlice.tsx +170 -169
  55. package/src/models/modules/Result.ts +8 -8
  56. package/src/models/modules/common.ts +90 -90
  57. package/src/res/index.ts +35 -35
  58. package/src/utils/ColorParser.ts +150 -150
  59. package/src/utils/ColorUtils.tsx +414 -414
  60. package/src/utils/Support.d.ts +9 -0
  61. package/src/utils/Support.ts +85 -0
  62. package/src/utils/cctUtils.d.ts +1 -0
  63. package/src/utils/cctUtils.ts +111 -0
  64. package/src/utils/common.ts +186 -174
  65. package/src/utils/index.ts +123 -123
@@ -1,41 +1,41 @@
1
- import { IconFont, Utils } from 'tuya-panel-kit'
2
- import { StyleProp, Text, TouchableOpacity, View, ViewStyle } from 'react-native'
1
+ import {IconFont, Utils} from 'tuya-panel-kit'
2
+ import {StyleProp, Text, TouchableOpacity, View, ViewStyle} from 'react-native'
3
3
  import React from 'react'
4
4
 
5
5
  const cx = Utils.RatioUtils.convertX
6
6
 
7
7
  interface CellProps {
8
- title: string,
9
- value: string,
10
- onPress: () => void,
11
- style?: StyleProp<ViewStyle>
8
+ title: string,
9
+ value: string,
10
+ onPress: () => void,
11
+ style?: StyleProp<ViewStyle>
12
12
  }
13
13
 
14
14
  export default function Cell(props: CellProps) {
15
- return (
16
- <TouchableOpacity
17
- style={[{
18
- height: cx(50),
19
- paddingHorizontal: cx(24),
20
- justifyContent: 'center',
21
- }, props.style]}
22
- onPress={props.onPress}>
23
- <View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
24
- <Text style={{
25
- fontSize: cx(14),
26
- color: '#444',
27
- fontFamily: 'helvetica_neue_lt_std_roman',
28
- }}>{props.title}</Text>
29
- <View style={{ flexDirection: 'row', alignItems: 'center' }}>
30
- <Text style={{
31
- fontSize: cx(14),
32
- color: '#444',
33
- fontFamily: 'helvetica_neue_lt_std_roman',
34
- }}>{props.value}</Text>
35
- <View style={{ width: cx(4) }} />
36
- <IconFont color={'#444'} size={cx(11)} name="arrow" />
37
- </View>
38
- </View>
39
- </TouchableOpacity>
40
- )
15
+ return (
16
+ <TouchableOpacity
17
+ style={[{
18
+ height: cx(50),
19
+ paddingHorizontal: cx(24),
20
+ justifyContent: 'center',
21
+ }, props.style]}
22
+ onPress={props.onPress}>
23
+ <View style={{flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center'}}>
24
+ <Text style={{
25
+ fontSize: cx(14),
26
+ color: '#444',
27
+ fontFamily: 'helvetica_neue_lt_std_roman',
28
+ }}>{props.title}</Text>
29
+ <View style={{flexDirection: 'row', alignItems: 'center'}}>
30
+ <Text style={{
31
+ fontSize: cx(14),
32
+ color: '#444',
33
+ fontFamily: 'helvetica_neue_lt_std_roman',
34
+ }}>{props.value}</Text>
35
+ <View style={{width: cx(4)}}/>
36
+ <IconFont color={'#444'} size={cx(11)} name="arrow"/>
37
+ </View>
38
+ </View>
39
+ </TouchableOpacity>
40
+ )
41
41
  }
@@ -8,53 +8,53 @@ import LdvColorBrightness from './ldvColorBrightness'
8
8
  import I18n from '../i18n/index'
9
9
 
10
10
  export interface ColorAdjustViewProps {
11
- h: number
12
- s: number
13
- v: number
14
- onHSVChange?: (h: number, s: number, v: number) => void
15
- onHSVChangeComplete: (h: number, s: number, v: number) => void
11
+ h: number
12
+ s: number
13
+ v: number
14
+ onHSVChange?: (h: number, s: number, v: number) => void
15
+ onHSVChangeComplete: (h: number, s: number, v: number) => void
16
16
  }
17
17
 
18
18
  const ColorAdjustView = (props: ColorAdjustViewProps) => {
19
- return (
20
- <View>
21
- <LdvColorSlider
22
- type={'color'}
23
- title={I18n.getLang('light_sources_tile_sec_lighting_shade')}
24
- thumbColor={hsv2Hex(props.h, 100, 100)}
25
- value={props.h}
26
- onValueChange={hue => {
27
- props.onHSVChange && props.onHSVChange(hue, props.s, props.v)
28
- }}
29
- onSlidingComplete={hue => {
30
- props.onHSVChangeComplete(hue, props.s, props.v)
31
- }}/>
32
- <LdvPresetView
33
- type={'color'}
34
- onPress={(item) => {
35
- const hsv = hex2Hsv(item.color)
36
- if (hsv) {
37
- props.onHSVChangeComplete(hsv.h, hsv.s, hsv.v)
38
- }
39
- }}/>
40
- <LdvSaturation
41
- value={props.s}
42
- onValueChange={s => {
43
- props.onHSVChange && props.onHSVChange(props.h, s, props.v)
44
- }}
45
- onSlidingComplete={s => {
46
- props.onHSVChangeComplete(props.h, s, props.v)
47
- }}/>
48
- <LdvColorBrightness
49
- value={props.v}
50
- onValueChange={v => {
51
- props.onHSVChange && props.onHSVChange(props.h, props.s, v)
52
- }}
53
- onSlidingComplete={v => {
54
- props.onHSVChangeComplete(props.h, props.s, v)
55
- }}/>
56
- </View>
57
- )
19
+ return (
20
+ <View>
21
+ <LdvColorSlider
22
+ type={'color'}
23
+ title={I18n.getLang('light_sources_tile_sec_lighting_shade')}
24
+ thumbColor={hsv2Hex(props.h, 100, 100)}
25
+ value={props.h}
26
+ onValueChange={hue => {
27
+ props.onHSVChange && props.onHSVChange(hue, props.s, props.v)
28
+ }}
29
+ onSlidingComplete={hue => {
30
+ props.onHSVChangeComplete(hue, props.s, props.v)
31
+ }}/>
32
+ <LdvPresetView
33
+ type={'color'}
34
+ onPress={(item) => {
35
+ const hsv = hex2Hsv(item.color)
36
+ if (hsv) {
37
+ props.onHSVChangeComplete(hsv.h, hsv.s, hsv.v)
38
+ }
39
+ }}/>
40
+ <LdvSaturation
41
+ value={props.s}
42
+ onValueChange={s => {
43
+ props.onHSVChange && props.onHSVChange(props.h, s, props.v)
44
+ }}
45
+ onSlidingComplete={s => {
46
+ props.onHSVChangeComplete(props.h, s, props.v)
47
+ }}/>
48
+ <LdvColorBrightness
49
+ value={props.v}
50
+ onValueChange={v => {
51
+ props.onHSVChange && props.onHSVChange(props.h, props.s, v)
52
+ }}
53
+ onSlidingComplete={v => {
54
+ props.onHSVChangeComplete(props.h, props.s, v)
55
+ }}/>
56
+ </View>
57
+ )
58
58
  }
59
59
 
60
60
  export default ColorAdjustView
@@ -10,46 +10,46 @@ import I18n from '../i18n/index'
10
10
  const {convertX: cx} = Utils.RatioUtils
11
11
 
12
12
  export interface ColorTempAdjustViewProps {
13
- colorTemp: number
14
- brightness: number
15
- isSupportTemperature: boolean
16
- isSupportBrightness: boolean
17
- onCCTChange?: (cct: number) => void
18
- onCCTChangeComplete: (cct: number) => void
19
- onBrightnessChange?: (brightness: number) => void
20
- onBrightnessChangeComplete: (brightness: number) => void
13
+ colorTemp: number
14
+ brightness: number
15
+ isSupportTemperature: boolean
16
+ isSupportBrightness: boolean
17
+ onCCTChange?: (cct: number) => void
18
+ onCCTChangeComplete: (cct: number) => void
19
+ onBrightnessChange?: (brightness: number) => void
20
+ onBrightnessChangeComplete: (brightness: number) => void
21
21
  }
22
22
 
23
23
  const ColorTempAdjustView = (props: ColorTempAdjustViewProps) => {
24
- return (
25
- <View>
26
- {props.isSupportTemperature &&
27
- <>
28
- <LdvColorSlider
29
- type={'temperature'}
30
- title={I18n.getLang('light_sources_tile_main_lighting_shade')}
31
- thumbColor={'white'}
32
- value={props.colorTemp}
33
- onValueChange={props.onCCTChange}
34
- onSlidingComplete={props.onCCTChangeComplete}/>
35
- <Spacer height={cx(10)}/>
36
- <LdvPresetView
37
- type={'temperature'}
38
- style={{height: cx(60)}}
39
- onPress={item => {
40
- props.onCCTChangeComplete(item.value)
41
- }}/>
42
- <Spacer height={cx(10)}/>
43
- </>
44
- }
45
- {props.isSupportBrightness &&
46
- <LdvSlider
47
- title={I18n.getLang('light_sources_tile_rgb_lighting_brightness')}
48
- value={props.brightness}
49
- onValueChange={props.onBrightnessChange}
50
- onSlidingComplete={props.onBrightnessChangeComplete}/>}
51
- </View>
52
- )
24
+ return (
25
+ <View>
26
+ {props.isSupportTemperature &&
27
+ <>
28
+ <LdvColorSlider
29
+ type={'temperature'}
30
+ title={I18n.getLang('light_sources_tile_main_lighting_shade')}
31
+ thumbColor={'white'}
32
+ value={props.colorTemp}
33
+ onValueChange={props.onCCTChange}
34
+ onSlidingComplete={props.onCCTChangeComplete}/>
35
+ <Spacer height={cx(10)}/>
36
+ <LdvPresetView
37
+ type={'temperature'}
38
+ style={{height: cx(60)}}
39
+ onPress={item => {
40
+ props.onCCTChangeComplete(item.value)
41
+ }}/>
42
+ <Spacer height={cx(10)}/>
43
+ </>
44
+ }
45
+ {props.isSupportBrightness &&
46
+ <LdvSlider
47
+ title={I18n.getLang('light_sources_tile_rgb_lighting_brightness')}
48
+ value={props.brightness}
49
+ onValueChange={props.onBrightnessChange}
50
+ onSlidingComplete={props.onBrightnessChangeComplete}/>}
51
+ </View>
52
+ )
53
53
  }
54
54
 
55
55
  export default ColorTempAdjustView
@@ -0,0 +1,7 @@
1
+ import { StyleProp, ViewProps, ViewStyle } from 'react-native';
2
+ interface ColorsLineProps extends ViewProps {
3
+ colors: string[];
4
+ nodeStyle?: StyleProp<ViewStyle>;
5
+ }
6
+ declare const ColorsLine: (props: ColorsLineProps) => JSX.Element;
7
+ export default ColorsLine;
@@ -0,0 +1,48 @@
1
+ import {StyleProp, StyleSheet, View, ViewProps, ViewStyle} from 'react-native'
2
+ import React from 'react'
3
+ import {Utils} from 'tuya-panel-kit'
4
+
5
+ const cx = Utils.RatioUtils.convertX
6
+
7
+ interface ColorsLineProps extends ViewProps {
8
+ colors: string[]
9
+ nodeStyle?: StyleProp<ViewStyle>
10
+ }
11
+
12
+ const ColorsLine = (props: ColorsLineProps) => {
13
+ return (
14
+ <View style={[styles.root, props.style]}>
15
+ {
16
+ props.colors.map((color, index) => {
17
+ return (
18
+ <View
19
+ key={`${index}`}
20
+ style={[
21
+ styles.colorNode,
22
+ {
23
+ backgroundColor: color,
24
+ marginStart: index === 0 ? 0 : cx(5),
25
+ },
26
+ props.nodeStyle,
27
+ ]}/>
28
+ )
29
+ })
30
+ }
31
+ </View>
32
+ )
33
+ }
34
+
35
+ const styles = StyleSheet.create({
36
+ root: {
37
+ flexDirection: 'row',
38
+ width: cx(295),
39
+ height: cx(24),
40
+ },
41
+ colorNode: {
42
+ flex: 1,
43
+ height: cx(24),
44
+ borderRadius: cx(8),
45
+ },
46
+ })
47
+
48
+ export default ColorsLine
@@ -1,4 +1,4 @@
1
- import { StyleProp, ViewStyle, TextStyle } from 'react-native';
1
+ import { StyleProp, TextStyle, ViewStyle } from 'react-native';
2
2
  interface DeleteButtonProps {
3
3
  text: string;
4
4
  onPress: () => void;
@@ -1,36 +1,36 @@
1
- import React from "react";
2
- import { TouchableOpacity, Text, StyleProp, ViewStyle, TextStyle } from 'react-native'
3
- import { Utils } from 'tuya-panel-kit'
1
+ import React from 'react'
2
+ import {StyleProp, Text, TextStyle, TouchableOpacity, ViewStyle} from 'react-native'
3
+ import {Utils} from 'tuya-panel-kit'
4
4
 
5
5
  const cx = Utils.RatioUtils.convertX
6
+
6
7
  interface DeleteButtonProps {
7
- text: string,
8
- onPress: () => void,
9
- style?: StyleProp<ViewStyle>,
10
- textStyle?: StyleProp<TextStyle>
8
+ text: string,
9
+ onPress: () => void,
10
+ style?: StyleProp<ViewStyle>,
11
+ textStyle?: StyleProp<TextStyle>
11
12
  }
12
13
 
13
14
  const DeleteButton = (props: DeleteButtonProps) => {
14
- const { text, onPress, style, textStyle } = props
15
- return (
16
- <TouchableOpacity
17
- onPress={onPress}
18
- style={[{
19
- width: '100%',
20
- height: cx(50),
21
- backgroundColor: '#666',
22
- alignItems: 'center',
23
- justifyContent: 'center',
24
- borderRadius: cx(8)
25
- }, style]}
26
- >
27
- <Text style={[{
28
- color: '#fff',
29
- fontSize: cx(16),
30
- fontFamily: 'helvetica_neue_lt_std_bd'
31
- }, textStyle]}>{text}</Text>
32
- </TouchableOpacity>
33
- )
15
+ const {text, onPress, style, textStyle} = props
16
+ return (
17
+ <TouchableOpacity
18
+ onPress={onPress}
19
+ style={[{
20
+ width: '100%',
21
+ height: cx(50),
22
+ backgroundColor: '#666',
23
+ alignItems: 'center',
24
+ justifyContent: 'center',
25
+ borderRadius: cx(8),
26
+ }, style]}>
27
+ <Text style={[{
28
+ color: '#fff',
29
+ fontSize: cx(16),
30
+ fontFamily: 'helvetica_neue_lt_std_bd',
31
+ }, textStyle]}>{text}</Text>
32
+ </TouchableOpacity>
33
+ )
34
34
  }
35
35
 
36
36
  export default DeleteButton
@@ -1,39 +1,39 @@
1
- import React, { PropsWithChildren } from 'react'
2
- import { Modal, StyleSheet, TouchableOpacity, ViewProps } from 'react-native'
1
+ import React, {PropsWithChildren} from 'react'
2
+ import {Modal, StyleSheet, TouchableOpacity, ViewProps} from 'react-native'
3
3
 
4
4
  interface DialogProps extends PropsWithChildren<ViewProps> {
5
- show: boolean
6
- hideMask: boolean
7
- animationType?: 'none' | 'slide' | 'fade'
8
- onRequestClose: () => void
5
+ show: boolean
6
+ hideMask: boolean
7
+ animationType?: 'none' | 'slide' | 'fade'
8
+ onRequestClose: () => void
9
9
  }
10
10
 
11
11
  const Dialog = (props: DialogProps) => {
12
- return (
13
- <Modal
14
- transparent={true}
15
- visible={props.show}
16
- animationType={props.animationType || 'fade'}
17
- onRequestClose={props.onRequestClose}>
18
- <TouchableOpacity
19
- style={[
20
- styles.mask,
21
- {
22
- backgroundColor: props.hideMask ? 'rgba(0, 0, 0, 0)' : 'rgba(0, 0, 0, 0.7)',
23
- },
24
- ]}
25
- activeOpacity={1}
26
- onPress={props.onRequestClose}>
27
- {props.children}
28
- </TouchableOpacity>
29
- </Modal>
30
- )
12
+ return (
13
+ <Modal
14
+ transparent={true}
15
+ visible={props.show}
16
+ animationType={props.animationType || 'fade'}
17
+ onRequestClose={props.onRequestClose}>
18
+ <TouchableOpacity
19
+ style={[
20
+ styles.mask,
21
+ {
22
+ backgroundColor: props.hideMask ? 'rgba(0, 0, 0, 0)' : 'rgba(0, 0, 0, 0.7)',
23
+ },
24
+ ]}
25
+ activeOpacity={1}
26
+ onPress={props.onRequestClose}>
27
+ {props.children}
28
+ </TouchableOpacity>
29
+ </Modal>
30
+ )
31
31
  }
32
32
 
33
33
  const styles = StyleSheet.create({
34
- mask: {
35
- flex: 1,
36
- },
34
+ mask: {
35
+ flex: 1,
36
+ },
37
37
  })
38
38
 
39
39
  export default Dialog