@ledvance/base 1.3.78 → 1.3.79
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/localazy.json +4 -1
- package/package.json +1 -1
- package/src/components/AdvanceCard.tsx +3 -1
- package/src/components/Card.tsx +1 -1
- package/src/components/Cell.tsx +2 -0
- package/src/components/ColorAdjustView.tsx +1 -1
- package/src/components/ColorTempAdjustView.tsx +3 -3
- package/src/components/DeleteButton.tsx +4 -1
- package/src/components/DrawToolView.tsx +1 -0
- package/src/components/HybridSwitchView.tsx +3 -0
- package/src/components/OptionGroup.tsx +6 -1
- package/src/components/OsramFanAdjustView.tsx +93 -0
- package/src/components/Page.tsx +5 -1
- package/src/components/Popup.tsx +2 -0
- package/src/components/Segmented.tsx +3 -0
- package/src/components/SocketItem.tsx +9 -1
- package/src/components/Stepper.tsx +6 -0
- package/src/components/StripAdjustView.tsx +2 -0
- package/src/components/Tag.tsx +12 -8
- package/src/components/TextButton.tsx +3 -1
- package/src/components/TextField.tsx +3 -2
- package/src/components/TextFieldStyleButton.tsx +2 -2
- package/src/components/UATabs.tsx +3 -0
- package/src/components/ldvColorBrightness.tsx +4 -1
- package/src/components/ldvColorSlider.tsx +2 -1
- package/src/components/ldvPickerView.tsx +4 -0
- package/src/components/ldvPresetView.tsx +3 -1
- package/src/components/ldvSaturation.tsx +3 -1
- package/src/components/ldvSlider.tsx +8 -3
- package/src/components/ldvSwitch.tsx +2 -2
- package/src/components/ldvTemperatureSlider.tsx +4 -2
- package/src/components/ldvTopBar.tsx +3 -1
- package/src/components/ldvTopName.tsx +1 -0
- package/src/components/rect-color-and-bright-picker/ColourPicker.tsx +2 -0
- package/src/components/rect-color-and-bright-picker/RectPicker.tsx +7 -0
- package/src/components/rect-color-and-bright-picker/Slider.tsx +3 -1
- package/src/components/rect-color-and-bright-picker/WhitePicker.tsx +50 -1
- package/src/components/rect-color-and-bright-picker/utils/storage.ts +97 -0
- package/src/components/segmentControl.tsx +11 -4
- package/src/components/weekSelect.tsx +3 -0
- package/src/i18n/strings.ts +116 -32
- package/src/utils/interface.ts +1 -1
- package/translateKey.txt +4 -1
- package/src/components/ShowSelect.d.ts +0 -1
- package/src/components/ShowSelect.tsx +0 -159
|
@@ -82,6 +82,8 @@ interface IProps extends DefaultProps {
|
|
|
82
82
|
valueToCoor: (value: any, originCoor?: Point, validBound?: ValidBound) => Point;
|
|
83
83
|
valueToColor: (value: any) => string;
|
|
84
84
|
initData: (validBound?: ValidBound) => void;
|
|
85
|
+
accessibilityLabel?: string;
|
|
86
|
+
accessibilityHint?: string;
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
interface IState {
|
|
@@ -377,10 +379,15 @@ export default class RectPicker extends Component<IProps, IState> {
|
|
|
377
379
|
disabled,
|
|
378
380
|
thumbSize,
|
|
379
381
|
thumbImg,
|
|
382
|
+
accessibilityLabel,
|
|
383
|
+
accessibilityHint
|
|
380
384
|
} = this.props;
|
|
381
385
|
const { showPicker, pickerHeight, pickerWidth, thumbPosition } = this;
|
|
382
386
|
return (
|
|
383
387
|
<View
|
|
388
|
+
accessibilityLabel={accessibilityLabel}
|
|
389
|
+
accessibilityHint={accessibilityHint}
|
|
390
|
+
accessibilityRole={'adjustable'}
|
|
384
391
|
style={[{ flex: 1 }, style]}
|
|
385
392
|
{...this._panResponder.panHandlers}
|
|
386
393
|
pointerEvents="box-only"
|
|
@@ -504,7 +504,9 @@ export default class Slider extends React.Component<IProps, IState> {
|
|
|
504
504
|
return (
|
|
505
505
|
<View
|
|
506
506
|
style={containerStyle}
|
|
507
|
-
accessibilityLabel="
|
|
507
|
+
accessibilityLabel="ReactColorPickerSlider"
|
|
508
|
+
accessibilityHint={`${this.brightWidth}`}
|
|
509
|
+
accessibilityRole={'adjustable'}
|
|
508
510
|
onLayout={this.handleLayout}
|
|
509
511
|
pointerEvents="box-only"
|
|
510
512
|
{...this._panResponder.panHandlers}
|
|
@@ -10,6 +10,7 @@ import RectPicker, {
|
|
|
10
10
|
} from './RectPicker';
|
|
11
11
|
import Slider, { IBrightOption } from './Slider';
|
|
12
12
|
import ColorUtils from './utils/color';
|
|
13
|
+
import StorageUtils from './utils/storage';
|
|
13
14
|
|
|
14
15
|
export interface IWhite {
|
|
15
16
|
brightness: number;
|
|
@@ -52,20 +53,38 @@ const defaultProps = {
|
|
|
52
53
|
onRelease(_v: any, _option?: { isChangeBright: boolean }) {},
|
|
53
54
|
onPress(_v: any, _option?: { isChangeBright: boolean }) {},
|
|
54
55
|
};
|
|
56
|
+
|
|
57
|
+
interface TempStorageData {
|
|
58
|
+
temperature: number;
|
|
59
|
+
position: Point;
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
type DefaultProps = {
|
|
56
63
|
style?: ViewStyle;
|
|
57
64
|
rectStyle?: ViewStyle;
|
|
65
|
+
storageKey?: string;
|
|
58
66
|
} & Readonly<typeof defaultProps>;
|
|
59
67
|
|
|
60
68
|
type WhiteProps = DefaultProps;
|
|
61
69
|
|
|
70
|
+
let storageKeyIndex = 0;
|
|
71
|
+
|
|
62
72
|
export default class WhitePicker extends Component<WhiteProps, IWhite> {
|
|
63
73
|
static defaultProps = defaultProps;
|
|
64
74
|
|
|
65
75
|
constructor(props: WhiteProps) {
|
|
66
76
|
super(props);
|
|
67
|
-
|
|
77
|
+
// 是否定义了storageKey
|
|
78
|
+
const {
|
|
79
|
+
storageKey,
|
|
80
|
+
value: { brightness, temperature },
|
|
81
|
+
} = this.props;
|
|
68
82
|
this.state = { brightness, temperature };
|
|
83
|
+
if (!storageKey) {
|
|
84
|
+
this.storageKey = `temperature_key_${storageKeyIndex++}`;
|
|
85
|
+
} else {
|
|
86
|
+
this.storageKey = storageKey;
|
|
87
|
+
}
|
|
69
88
|
}
|
|
70
89
|
|
|
71
90
|
componentDidUpdate(prevProps: WhiteProps) {
|
|
@@ -199,7 +218,26 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
|
|
|
199
218
|
}
|
|
200
219
|
|
|
201
220
|
initData = async (validBound: ValidBound) => {
|
|
221
|
+
let cacheEnabled = true;
|
|
222
|
+
// 尺寸有变化时,不使用缓存
|
|
223
|
+
if (!_.isEqual(validBound, this.pickerBound)) {
|
|
224
|
+
cacheEnabled = false;
|
|
225
|
+
}
|
|
226
|
+
|
|
202
227
|
const { temperature } = this.state;
|
|
228
|
+
|
|
229
|
+
// 获取当前positon的值
|
|
230
|
+
const data = (await StorageUtils.getDevItem(this.storageKey)) as TempStorageData;
|
|
231
|
+
// 是否相同色温,相同使用缓存坐标展示
|
|
232
|
+
if (data && data.temperature === temperature && cacheEnabled) {
|
|
233
|
+
this.thumbPosition = data.position;
|
|
234
|
+
this.currentTemperature = temperature;
|
|
235
|
+
} else {
|
|
236
|
+
// 根据色温计算位置
|
|
237
|
+
this.thumbPosition = this.autoTemperaturePosition(temperature, validBound);
|
|
238
|
+
this.currentTemperature = temperature;
|
|
239
|
+
}
|
|
240
|
+
|
|
203
241
|
// 根据色温计算位置
|
|
204
242
|
this.thumbPosition = this.autoTemperaturePosition(temperature, validBound);
|
|
205
243
|
this.currentTemperature = temperature;
|
|
@@ -217,6 +255,8 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
|
|
|
217
255
|
validBound
|
|
218
256
|
);
|
|
219
257
|
}
|
|
258
|
+
|
|
259
|
+
StorageUtils.setDevItem(this.storageKey, { temperature, position });
|
|
220
260
|
return position;
|
|
221
261
|
}
|
|
222
262
|
|
|
@@ -242,6 +282,7 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
|
|
|
242
282
|
x: normal.x * length + normalVector.originX,
|
|
243
283
|
y: normal.y * length + normalVector.originY,
|
|
244
284
|
};
|
|
285
|
+
StorageUtils.setDevItem(this.storageKey, { temperature, position });
|
|
245
286
|
return position;
|
|
246
287
|
}
|
|
247
288
|
|
|
@@ -263,6 +304,11 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
|
|
|
263
304
|
}
|
|
264
305
|
return this.handleTemperaturePosition(temperature, validBound);
|
|
265
306
|
}
|
|
307
|
+
|
|
308
|
+
StorageUtils.setDevItem(this.storageKey, {
|
|
309
|
+
temperature,
|
|
310
|
+
position: origin,
|
|
311
|
+
});
|
|
266
312
|
this.currentTemperature = temperature;
|
|
267
313
|
this.thumbPosition = origin;
|
|
268
314
|
return origin;
|
|
@@ -281,6 +327,7 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
|
|
|
281
327
|
private currentTemperature: number;
|
|
282
328
|
private pickerRef: RectPicker | null;
|
|
283
329
|
private pickerBound: ValidBound;
|
|
330
|
+
private storageKey: string;
|
|
284
331
|
|
|
285
332
|
handlePickerGrant = () => {
|
|
286
333
|
const { temperature, brightness } = this.state;
|
|
@@ -325,6 +372,8 @@ export default class WhitePicker extends Component<WhiteProps, IWhite> {
|
|
|
325
372
|
ref={(ref: RectPicker) => {
|
|
326
373
|
this.pickerRef = ref;
|
|
327
374
|
}}
|
|
375
|
+
accessibilityLabel={"ReactWhitePicker"}
|
|
376
|
+
accessibilityHint={`${ Math.round(temperature / 10)}`}
|
|
328
377
|
coorToValue={this.coorToValue}
|
|
329
378
|
valueToColor={this.valueToColor}
|
|
330
379
|
valueToCoor={this.valueToCoor}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
|
+
import { AsyncStorage } from 'react-native';
|
|
3
|
+
import { TYSdk } from 'tuya-panel-kit';
|
|
4
|
+
|
|
5
|
+
const getDevKey = (name: string) => {
|
|
6
|
+
const { devId } = TYSdk.devInfo;
|
|
7
|
+
return `${devId}_${name}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const getPidKey = (name: string) => {
|
|
11
|
+
const { productId } = TYSdk.devInfo;
|
|
12
|
+
return `${productId}_${name}`;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getUiKey = (name: string) => {
|
|
16
|
+
const { uiId } = TYSdk.devInfo;
|
|
17
|
+
return `${uiId}_${name}`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
async setItem(key: string, value: any) {
|
|
22
|
+
const data = { value, type: typeof value };
|
|
23
|
+
const jsonValue = JSON.stringify(data);
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
AsyncStorage.setItem(key, jsonValue, err => {
|
|
26
|
+
if (err) {
|
|
27
|
+
reject(err);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
resolve('');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
async setDevItem(name: string, value: any) {
|
|
35
|
+
const key = getDevKey(name);
|
|
36
|
+
return this.setItem(key, value);
|
|
37
|
+
},
|
|
38
|
+
async setPidItem(name: string, value: any) {
|
|
39
|
+
const key = getPidKey(name);
|
|
40
|
+
return this.setItem(key, value);
|
|
41
|
+
},
|
|
42
|
+
async setUiItem(name: string, value: any) {
|
|
43
|
+
const key = getUiKey(name);
|
|
44
|
+
return this.setItem(key, value);
|
|
45
|
+
},
|
|
46
|
+
async getItem(key: string) {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
AsyncStorage.getItem(key, (err, data) => {
|
|
49
|
+
if (err) {
|
|
50
|
+
reject(err);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (data) {
|
|
54
|
+
resolve(JSON.parse(data).value);
|
|
55
|
+
}
|
|
56
|
+
resolve(null);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
async getDevItem(name: string) {
|
|
61
|
+
const key = getDevKey(name);
|
|
62
|
+
return this.getItem(key);
|
|
63
|
+
},
|
|
64
|
+
async getPidItem(name: string) {
|
|
65
|
+
const key = getPidKey(name);
|
|
66
|
+
return this.getItem(key);
|
|
67
|
+
},
|
|
68
|
+
async getUiItem(name: string) {
|
|
69
|
+
const key = getUiKey(name);
|
|
70
|
+
return this.getItem(key);
|
|
71
|
+
},
|
|
72
|
+
async removeItem(key: string) {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
AsyncStorage.removeItem(key, err => {
|
|
75
|
+
if (err) {
|
|
76
|
+
reject(err);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
resolve('');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
async removeDevItem(name: string) {
|
|
85
|
+
const key = getDevKey(name);
|
|
86
|
+
return this.removeItem(key);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
async removePidItem(name: string) {
|
|
90
|
+
const key = getDevKey(name);
|
|
91
|
+
return this.removeItem(key);
|
|
92
|
+
},
|
|
93
|
+
async removeUiItem(name: string) {
|
|
94
|
+
const key = getUiKey(name);
|
|
95
|
+
return this.removeItem(key);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
@@ -17,8 +17,11 @@ const SegmentControl = (props) => {
|
|
|
17
17
|
borderRadius: convertX(8.9),
|
|
18
18
|
flexDirection: 'row',
|
|
19
19
|
}, style]}>
|
|
20
|
-
<TouchableOpacity
|
|
21
|
-
|
|
20
|
+
<TouchableOpacity
|
|
21
|
+
accessibilityLabel={"SegmentControl"}
|
|
22
|
+
accessibilityHint={title1}
|
|
23
|
+
accessibilityState={{checked: isFirst}}
|
|
24
|
+
style={[{
|
|
22
25
|
flex: 1,
|
|
23
26
|
justifyContent: 'center',
|
|
24
27
|
alignItems: 'center',
|
|
@@ -26,8 +29,9 @@ const SegmentControl = (props) => {
|
|
|
26
29
|
borderRadius: convertX(6.9),
|
|
27
30
|
}, isFirst ?
|
|
28
31
|
{backgroundColor: props.theme?.segment.active, margin: convertX(2), borderRadius: 6.9} :
|
|
29
|
-
{backgroundColor: props.theme?.segment.background}, tabStyle]
|
|
30
|
-
|
|
32
|
+
{backgroundColor: props.theme?.segment.background}, tabStyle]}
|
|
33
|
+
onPress={() => setIsFirst(true)}
|
|
34
|
+
>
|
|
31
35
|
<Text
|
|
32
36
|
style={{
|
|
33
37
|
color: props.theme?.segment.fontColor,
|
|
@@ -39,6 +43,9 @@ const SegmentControl = (props) => {
|
|
|
39
43
|
</Text>
|
|
40
44
|
</TouchableOpacity>
|
|
41
45
|
<TouchableOpacity
|
|
46
|
+
accessibilityLabel={"SegmentControl"}
|
|
47
|
+
accessibilityHint={title2}
|
|
48
|
+
accessibilityState={{checked: !isFirst}}
|
|
42
49
|
style={
|
|
43
50
|
[{
|
|
44
51
|
flex: 1,
|
|
@@ -64,6 +64,9 @@ const WeekSelect = (props) => {
|
|
|
64
64
|
{dataSource.map(period => {
|
|
65
65
|
return (
|
|
66
66
|
<TouchableOpacity
|
|
67
|
+
accessibilityLabel={"WeekSelect"}
|
|
68
|
+
accessibilityHint={`${period.index}`}
|
|
69
|
+
accessibilityState={{checked: period.enabled}}
|
|
67
70
|
key={period.index}
|
|
68
71
|
onPress={() => {
|
|
69
72
|
onSelect(period.index)
|