@ledvance/base 1.1.8 → 1.1.9
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
CHANGED
|
@@ -35,6 +35,15 @@ declare const useEnergieverbrauch: () => (object | undefined)[];
|
|
|
35
35
|
export declare const useEngergyGeneration: () => boolean;
|
|
36
36
|
export declare function useUAGroupInfo(): UAGroupInfo;
|
|
37
37
|
export declare function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Promise<Result<any>>];
|
|
38
|
+
/**
|
|
39
|
+
* @template GC GroupConfig
|
|
40
|
+
* @template GCPT GroupConfigPropertyType
|
|
41
|
+
* @param key
|
|
42
|
+
* @param extraDps
|
|
43
|
+
*/
|
|
44
|
+
export declare function useGroupConfigFeature<GC, GCPT extends {
|
|
45
|
+
[K in keyof GC]: GC[K];
|
|
46
|
+
}[keyof GC]>(key: keyof GC, extraDps?: any): [GCPT, (value: GCPT) => Promise<Result<any>>];
|
|
38
47
|
export declare const ldvModules: import("@reduxjs/toolkit").Reducer<NativeProps, import("@reduxjs/toolkit").AnyAction>;
|
|
39
48
|
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>;
|
|
40
49
|
export { simpleSetDps, simpleSetDp, useDeviceId, useDeviceInfo, useDp, useDps, useFamilyName, useTimeSchedule, useEnergieverbrauch, };
|
|
@@ -5,6 +5,8 @@ import {DpsResult, Result} from './Result'
|
|
|
5
5
|
import {DevInfo, DpValue} from 'tuya-panel-kit'
|
|
6
6
|
import {NativeApi} from '../../api/native'
|
|
7
7
|
import {useDispatch} from 'react-redux'
|
|
8
|
+
import {GlobalParams} from '../GlobalParams'
|
|
9
|
+
import {camelCase} from 'lodash'
|
|
8
10
|
|
|
9
11
|
export interface NativeProps {
|
|
10
12
|
familyName: string
|
|
@@ -212,6 +214,30 @@ export function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Promise<Res
|
|
|
212
214
|
return [config, setConfig]
|
|
213
215
|
}
|
|
214
216
|
|
|
217
|
+
/**
|
|
218
|
+
* @template GC GroupConfig
|
|
219
|
+
* @template GCPT GroupConfigPropertyType
|
|
220
|
+
* @param key
|
|
221
|
+
* @param extraDps
|
|
222
|
+
*/
|
|
223
|
+
export function useGroupConfigFeature<GC, GCPT extends { [K in keyof GC]: GC[K] }[keyof GC]>
|
|
224
|
+
(key: keyof GC, extraDps: any = {}): [GCPT, (value: GCPT) => Promise<Result<any>>] {
|
|
225
|
+
const [groupConfig, setGroupConfig] = useGroupConfig<GC>()
|
|
226
|
+
const setGroupConfigFeature = async (value: GCPT) => {
|
|
227
|
+
return await setGroupConfig(
|
|
228
|
+
{
|
|
229
|
+
[GlobalParams.dpSchemaMap[camelCase(key as string)].dp]: value,
|
|
230
|
+
...extraDps,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
...groupConfig,
|
|
234
|
+
[key]: value,
|
|
235
|
+
},
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
return [groupConfig[key] as GCPT, setGroupConfigFeature]
|
|
239
|
+
}
|
|
240
|
+
|
|
215
241
|
export const ldvModules = nativePropsSlice.reducer
|
|
216
242
|
|
|
217
243
|
export const {
|