@ledvance/base 1.2.27 → 1.2.28
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/package.json +1 -1
- package/src/components/MoodColorsLine.tsx +3 -2
- package/src/components/Stepper.tsx +19 -15
- package/src/i18n/strings.ts +835 -226
- package/src/utils/index.ts +10 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import LinearGradientLine from './LinearGradientLine'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import {Utils} from 'tuya-panel-kit'
|
|
4
|
-
import {StyleSheet} from 'react-native'
|
|
4
|
+
import {StyleProp, StyleSheet, ViewStyle} from 'react-native'
|
|
5
5
|
import ColorsLine from './ColorsLine'
|
|
6
6
|
|
|
7
7
|
const cx = Utils.RatioUtils.convertX
|
|
@@ -13,13 +13,14 @@ interface MoodColorsLineProps {
|
|
|
13
13
|
height?: number
|
|
14
14
|
type: MoodColorsLineType
|
|
15
15
|
colors: string[]
|
|
16
|
+
nodeStyle?: StyleProp<ViewStyle>
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export default function MoodColorsLine(props: MoodColorsLineProps) {
|
|
19
20
|
const width = props.width || cx(295)
|
|
20
21
|
const height = props.height || cx(24)
|
|
21
22
|
if (props.type === 'separate' || props.colors.length < 2) {
|
|
22
|
-
return (<ColorsLine colors={props.colors} style={{width, height}}/>)
|
|
23
|
+
return (<ColorsLine colors={props.colors} style={{width, height}} nodeStyle={props.nodeStyle}/>)
|
|
23
24
|
} else {
|
|
24
25
|
return (
|
|
25
26
|
<LinearGradientLine
|
|
@@ -5,7 +5,7 @@ import React, { memo, useCallback } from "react";
|
|
|
5
5
|
import { TouchableOpacity, View, Image, TextInput, StyleSheet, StyleProp, ViewStyle } from "react-native";
|
|
6
6
|
import { Utils } from "tuya-panel-kit";
|
|
7
7
|
|
|
8
|
-
const { add, subtract, inMaxMin} = Utils.NumberUtils
|
|
8
|
+
const { add, subtract, inMaxMin } = Utils.NumberUtils
|
|
9
9
|
|
|
10
10
|
const { convertX: cx } = Utils.RatioUtils
|
|
11
11
|
|
|
@@ -14,6 +14,7 @@ export interface StepperProps {
|
|
|
14
14
|
stepValue?: number // 1
|
|
15
15
|
min?: number // 0
|
|
16
16
|
max?: number // 99
|
|
17
|
+
precision?: number
|
|
17
18
|
editable?: boolean
|
|
18
19
|
selectionColor?: string
|
|
19
20
|
isRealTime?: boolean
|
|
@@ -30,7 +31,8 @@ const Stepper = (props: StepperProps) => {
|
|
|
30
31
|
value: localeNumber(Number(props.value), 1) ?? 0,
|
|
31
32
|
stepValue: props.stepValue ?? 1,
|
|
32
33
|
min: props.min ?? 0,
|
|
33
|
-
max: props.max ?? 99
|
|
34
|
+
max: props.max ?? 99,
|
|
35
|
+
precision: props.precision ?? 0
|
|
34
36
|
})
|
|
35
37
|
|
|
36
38
|
const handlePress = useCallback((isAdd: boolean) => {
|
|
@@ -40,34 +42,36 @@ const Stepper = (props: StepperProps) => {
|
|
|
40
42
|
}, [])
|
|
41
43
|
|
|
42
44
|
|
|
43
|
-
const handleChangeText = useCallback((v: string) =>{
|
|
45
|
+
const handleChangeText = useCallback((v: string) => {
|
|
44
46
|
const newValue = exchangeNumber(v)
|
|
45
47
|
const idx = newValue.indexOf('.')
|
|
46
|
-
if(newValue[0] === '.' ||
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
if (newValue[0] === '.' ||
|
|
49
|
+
(newValue.length === 2 && newValue[0] === '0' && newValue[1] !== '.') ||
|
|
50
|
+
newValue.split('').filter(item => item === '.').length > 1 ||
|
|
51
|
+
(!props.isBeyond && (Number(newValue) > state.max || Number(newValue) < state.min)) ||
|
|
52
|
+
(idx !== -1 && newValue.length > idx + 2)) {
|
|
51
53
|
return
|
|
52
54
|
}
|
|
53
|
-
if(props.isRealTime){
|
|
55
|
+
if (props.isRealTime) {
|
|
54
56
|
if (typeof v === 'string' && !v.length) {
|
|
55
57
|
props.onValueChange && props.onValueChange(0)
|
|
56
|
-
}else{
|
|
57
|
-
|
|
58
|
+
} else {
|
|
59
|
+
const num = Number(exchangeNumber(v))
|
|
60
|
+
props.onValueChange && props.onValueChange(Number(num.toFixed(props.precision)))
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
state.value = v
|
|
61
64
|
}, [])
|
|
62
65
|
|
|
63
|
-
const handleEndText = useCallback(() =>{
|
|
66
|
+
const handleEndText = useCallback(() => {
|
|
64
67
|
if (typeof state.value === 'string' && !state.value.length) {
|
|
65
68
|
props.onValueChange && props.onValueChange(state.min)
|
|
66
69
|
state.value = state.min.toString()
|
|
67
|
-
}else{
|
|
68
|
-
|
|
70
|
+
} else {
|
|
71
|
+
const num = Number(exchangeNumber(state.value))
|
|
72
|
+
props.onValueChange && props.onValueChange(Number(num.toFixed(props.precision)))
|
|
69
73
|
}
|
|
70
|
-
|
|
74
|
+
|
|
71
75
|
}, [])
|
|
72
76
|
|
|
73
77
|
return (
|