Comparing version 0.9.30 to 0.9.31
# leva | ||
## 0.9.31 | ||
### Patch Changes | ||
- 466f307: feat: `useControls` returns a `get` function | ||
## 0.9.30 | ||
@@ -100,3 +106,3 @@ | ||
## 1.0.0 | ||
## 0.9.14 | ||
@@ -103,0 +109,0 @@ ### Minor Changes |
@@ -10,4 +10,5 @@ /// <reference types="react" /> | ||
(value: { | ||
[K in keyof Partial<SchemaToValues<S, true>>]: any; | ||
}) => void | ||
[K in keyof Partial<SchemaToValues<S, true>>]: SchemaToValues<S, true>[K]; | ||
}) => void, | ||
<T extends keyof SchemaToValues<S, true>>(path: T) => SchemaToValues<S, true>[T] | ||
]; | ||
@@ -14,0 +15,0 @@ declare type ReturnType<F extends SchemaOrFn> = F extends SchemaOrFn<infer S> ? F extends Function ? FunctionReturnType<S> : SchemaToValues<S> : never; |
@@ -2399,2 +2399,3 @@ import { p as pick, _ as _objectSpread2, o as omit, s as styled, u as useInputContext, R as Row, L as Label, V as ValueInput, P as Portal, O as Overlay, c as createInternalPlugin, a as Vector, g as getVectorPlugin, b as useTransform, d as useTh, e as useDrag, f as _extends, m as multiplyStep, h as clamp, i as _objectWithoutProperties, n as normalizeKeyedNumberSettings, j as invertedRange, k as sanitizeStep, r as range, l as RangeWrapper, q as Range, I as Indicator, S as Scrubber, t as getUid, v as SpecialInputs, w as warn, x as LevaErrors, y as updateInput, z as normalizeInput, A as StyledTitle, C as Chevron, B as useInputSetters, D as Plugins, E as InputContext, F as StyledInputWrapper, G as useStoreContext, H as useCanvas2d, J as useInput, K as log, M as StyledWrapper, N as StyledContent, Q as StyledFolder, T as StyledInputRow, U as debounce, W as globalStyles, X as PanelSettingsContext, Y as StoreContext, Z as mergeTheme, $ as ThemeContext, a0 as register, a1 as LevaInputs, a2 as select, a3 as number$1, a4 as string, a5 as boolean } from './vector-plugin-fa777510.esm.js'; | ||
}, [store, mappedPaths]); | ||
const get = useCallback(path => store.get(mappedPaths[path].path), [store, mappedPaths]); | ||
useEffect(() => { | ||
@@ -2434,3 +2435,3 @@ const shouldOverrideSettings = !firstRender.current && depsChanged.current; | ||
}, [onEditStartPaths, onEditEndPaths, store]); | ||
if (schemaIsFunction) return [values, set]; | ||
if (schemaIsFunction) return [values, set, get]; | ||
return values; | ||
@@ -2437,0 +2438,0 @@ } |
{ | ||
"name": "leva", | ||
"version": "0.9.30", | ||
"version": "0.9.31", | ||
"main": "dist/leva.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/leva.esm.js", |
@@ -23,6 +23,10 @@ /* eslint-disable react-hooks/rules-of-hooks */ | ||
expectType<{ a: number; b: string }>(useControls({ a: 3, b: { value: '#fff', onChange: () => {}, transient: false } })) | ||
expectType<[{ a: number }, (value: { a?: number }) => void]>(useControls(() => ({ a: 3 }))) | ||
expectType<[{ a: number }, (value: { a?: number; color?: string }) => void]>( | ||
useControls(() => ({ a: 3, color: { value: '#fff', onChange: () => {} } })) | ||
) | ||
expectType<[{ a: number }, (value: { a?: number }) => void, (path: 'a') => number]>(useControls(() => ({ a: 3 }))) | ||
expectType< | ||
[ | ||
{ a: number }, | ||
(value: { a?: number; color?: string }) => void, | ||
<T extends 'a' | 'color'>(path: T) => { a: number; color: string }[T] | ||
] | ||
>(useControls(() => ({ a: 3, color: { value: '#fff', onChange: () => {} } }))) | ||
@@ -29,0 +33,0 @@ /** |
@@ -15,4 +15,5 @@ import { useEffect, useMemo, useCallback, useState, useRef } from 'react' | ||
(value: { | ||
[K in keyof Partial<SchemaToValues<S, true>>]: any | ||
}) => void | ||
[K in keyof Partial<SchemaToValues<S, true>>]: SchemaToValues<S, true>[K] | ||
}) => void, | ||
<T extends keyof SchemaToValues<S, true>>(path: T) => SchemaToValues<S, true>[T] | ||
] | ||
@@ -183,2 +184,4 @@ | ||
const get = useCallback((path: string) => store.get(mappedPaths[path].path), [store, mappedPaths]) | ||
useEffect(() => { | ||
@@ -230,4 +233,4 @@ // We initialize the store with the initialData in useEffect. | ||
if (schemaIsFunction) return [values, set] as any | ||
if (schemaIsFunction) return [values, set, get] as any | ||
return values as any | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
870148
28601