@ledvance/base 1.2.1 → 1.2.3
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/api/native.d.ts +1 -0
- package/src/api/native.ts +3 -3
- package/src/components/DrawToolView.tsx +2 -1
- package/src/components/Stepper.d.ts +1 -0
- package/src/components/Stepper.tsx +2 -1
- package/src/i18n/strings.d.ts +29 -0
- package/src/i18n/strings.ts +725 -696
- package/src/models/modules/NativePropsSlice.d.ts +6 -4
- package/src/models/modules/NativePropsSlice.tsx +26 -1
- package/src/utils/TypeUtils.d.ts +3 -0
- package/src/utils/TypeUtils.ts +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Dispatch } from 'react';
|
|
2
2
|
import { DpsResult, Result } from './Result';
|
|
3
3
|
import { DevInfo, DpValue } from 'tuya-panel-kit';
|
|
4
|
+
import { PropertyValueTypes } from '../../utils/TypeUtils';
|
|
4
5
|
export interface NativeProps {
|
|
5
6
|
familyName: string;
|
|
6
7
|
role: 0 | 1 | 2 | 3;
|
|
@@ -8,6 +9,7 @@ export interface NativeProps {
|
|
|
8
9
|
uaGroupInfo: UAGroupInfo;
|
|
9
10
|
timeSchedule?: boolean;
|
|
10
11
|
energieverbrauch?: object;
|
|
12
|
+
moods: any[];
|
|
11
13
|
}
|
|
12
14
|
export interface DeviceInfo {
|
|
13
15
|
devId: string;
|
|
@@ -37,6 +39,7 @@ interface DpState {
|
|
|
37
39
|
}
|
|
38
40
|
declare const useDeviceInfo: () => DevInfo<DpState>;
|
|
39
41
|
declare const useTimeSchedule: () => [v: boolean | undefined, f: any];
|
|
42
|
+
declare const useMoods: () => [any[], (v: any[]) => void];
|
|
40
43
|
declare const useEnergieverbrauch: () => (object | undefined)[];
|
|
41
44
|
export declare const useEngergyGeneration: () => boolean;
|
|
42
45
|
export declare function useUAGroupInfo(): UAGroupInfo;
|
|
@@ -47,11 +50,10 @@ export declare function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Pro
|
|
|
47
50
|
* @param key
|
|
48
51
|
* @param dpKey
|
|
49
52
|
*/
|
|
50
|
-
export declare function useGroupConfigFeature<GC, GCPT extends
|
|
51
|
-
|
|
52
|
-
}[keyof GC]>(key: keyof GC, dpKey?: string): [GCPT | undefined, (value: GCPT, dpValue: any, extraDps?: any, extraConfig?: any) => Promise<Result<any>>];
|
|
53
|
+
export declare function useGroupConfigFeature<GC, GCPT extends PropertyValueTypes<GC>>(key: keyof GC, dpKey?: string): [GCPT | undefined, (value: GCPT, dpValue: any, extraDps?: any, extraConfig?: any) => Promise<Result<any>>];
|
|
54
|
+
export declare function useFeatureHook<GC, T extends PropertyValueTypes<GC>>(featureKey: keyof GC, defValue: T, valueMapToDpValue?: (v: T) => any, extraDps?: any, extraConfig?: any): [T, (value: T) => Promise<Result<any>>];
|
|
53
55
|
export declare const useFanMaxSpeed: () => 3 | 20;
|
|
54
56
|
export declare const isUVCFanDevice: () => boolean;
|
|
55
57
|
export declare const ldvModules: import("@reduxjs/toolkit").Reducer<NativeProps, import("@reduxjs/toolkit").AnyAction>;
|
|
56
58
|
export declare const setNativeProps: import("@reduxjs/toolkit").ActionCreatorWithPayload<NativeProps, string>, setGroupNativeProps: import("@reduxjs/toolkit").ActionCreatorWithPayload<NativeProps, string>, setDps: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setTimeSchedule: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setEnergieverbrauch: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
|
|
57
|
-
export { asyncSetDps, simpleSetDps, simpleSetDp, useDeviceId, useDeviceInfo, useDp, useScaledDp, useDps, useFamilyName, useRole, useTimeSchedule, useEnergieverbrauch, };
|
|
59
|
+
export { asyncSetDps, simpleSetDps, simpleSetDp, useDeviceId, useDeviceInfo, useDp, useScaledDp, useDps, useFamilyName, useRole, useTimeSchedule, useMoods, useEnergieverbrauch, };
|
|
@@ -7,6 +7,7 @@ import { NativeApi } from '../../api/native'
|
|
|
7
7
|
import { useDispatch } from 'react-redux'
|
|
8
8
|
import { GlobalParams } from '../GlobalParams'
|
|
9
9
|
import { isNumber, snakeCase } from 'lodash'
|
|
10
|
+
import { PropertyValueTypes } from '../../utils/TypeUtils'
|
|
10
11
|
|
|
11
12
|
export interface NativeProps {
|
|
12
13
|
familyName: string
|
|
@@ -15,6 +16,7 @@ export interface NativeProps {
|
|
|
15
16
|
uaGroupInfo: UAGroupInfo
|
|
16
17
|
timeSchedule?: boolean
|
|
17
18
|
energieverbrauch?: object
|
|
19
|
+
moods: any[]
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export interface DeviceInfo {
|
|
@@ -46,6 +48,7 @@ const initialState: NativeProps = {
|
|
|
46
48
|
},
|
|
47
49
|
timeSchedule: false,
|
|
48
50
|
energieverbrauch: {},
|
|
51
|
+
moods: [],
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
// energy generation
|
|
@@ -100,6 +103,9 @@ const nativePropsSlice = createSlice({
|
|
|
100
103
|
setEnergieverbrauch(state, action: PayloadAction<any>) {
|
|
101
104
|
state.energieverbrauch = action.payload
|
|
102
105
|
},
|
|
106
|
+
setMoods(state, action: PayloadAction<any>) {
|
|
107
|
+
state.moods = action.payload
|
|
108
|
+
},
|
|
103
109
|
},
|
|
104
110
|
})
|
|
105
111
|
|
|
@@ -201,6 +207,15 @@ const useTimeSchedule = (): [v: boolean | undefined, f: any] => {
|
|
|
201
207
|
return [dps, setTimeScheduleFn]
|
|
202
208
|
}
|
|
203
209
|
|
|
210
|
+
const useMoods = (): [any[], (v: any[]) => void] => {
|
|
211
|
+
const dps = useSelector(store => store.ldvModules.moods)
|
|
212
|
+
const dispatch = useDispatch()
|
|
213
|
+
const setTimeScheduleFn = (value: any[]) => {
|
|
214
|
+
dispatch(setTimeSchedule(value))
|
|
215
|
+
}
|
|
216
|
+
return [dps, setTimeScheduleFn]
|
|
217
|
+
}
|
|
218
|
+
|
|
204
219
|
const useEnergieverbrauch = () => {
|
|
205
220
|
const dps = useSelector(store => store.ldvModules.energieverbrauch)
|
|
206
221
|
const dispatch = useDispatch()
|
|
@@ -242,7 +257,7 @@ export function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Promise<Res
|
|
|
242
257
|
* @param key
|
|
243
258
|
* @param dpKey
|
|
244
259
|
*/
|
|
245
|
-
export function useGroupConfigFeature<GC, GCPT extends
|
|
260
|
+
export function useGroupConfigFeature<GC, GCPT extends PropertyValueTypes<GC>>
|
|
246
261
|
(key: keyof GC, dpKey?: string): [GCPT | undefined, (value: GCPT, dpValue: any, extraDps?: any, extraConfig?: any) => Promise<Result<any>>] {
|
|
247
262
|
const [groupConfig, setGroupConfig] = useGroupConfig<GC>()
|
|
248
263
|
const setGroupConfigFeature = async (value: GCPT, dpValue: any, extraDps?: any, extraConfig?: any) => {
|
|
@@ -261,6 +276,15 @@ export function useGroupConfigFeature<GC, GCPT extends { [K in keyof GC]: GC[K]
|
|
|
261
276
|
return [groupConfig[key] as (GCPT | undefined), setGroupConfigFeature]
|
|
262
277
|
}
|
|
263
278
|
|
|
279
|
+
export function useFeatureHook<GC, T extends PropertyValueTypes<GC>>(featureKey: keyof GC, defValue: T, valueMapToDpValue?: (v: T) => any, extraDps?: any, extraConfig?: any): [T, (value: T) => Promise<Result<any>>] {
|
|
280
|
+
const [featureHook, setFH] = useGroupConfigFeature<GC, T>(featureKey)
|
|
281
|
+
const setFeatureHook = useCallback(async (value: T) => {
|
|
282
|
+
const dpValue = valueMapToDpValue ? valueMapToDpValue(value) : value
|
|
283
|
+
return await setFH(value, dpValue, extraDps, extraConfig)
|
|
284
|
+
}, [setFH])
|
|
285
|
+
return [featureHook || defValue, setFeatureHook]
|
|
286
|
+
}
|
|
287
|
+
|
|
264
288
|
export const useFanMaxSpeed = () => {
|
|
265
289
|
const { productId } = useDeviceInfo()
|
|
266
290
|
return fanProductList.includes(productId) ? 20 : 3
|
|
@@ -293,5 +317,6 @@ export {
|
|
|
293
317
|
useFamilyName,
|
|
294
318
|
useRole,
|
|
295
319
|
useTimeSchedule,
|
|
320
|
+
useMoods,
|
|
296
321
|
useEnergieverbrauch,
|
|
297
322
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type PropertyValueTypes<T> = { [K in keyof T]: T[K] }[keyof T]
|