@snack-uikit/utils 3.1.0 → 3.2.1-preview-0a44b2fc.0
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/CHANGELOG.md +11 -0
- package/dist/components/ThemeProvider/ThemeProvider.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useValueControl.d.ts +7 -0
- package/dist/hooks/useValueControl.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +5 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useValueControl.ts +15 -0
- package/src/index.ts +1 -0
- package/src/types/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 3.2.0 (2023-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **FF-3729:** add utility type ValueOf ([73259c3](https://github.com/cloud-ru-tech/snack-uikit/commit/73259c3d30f6256388be02df3167f381ce95879e))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# 3.1.0 (2023-12-06)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -15,5 +15,5 @@ import { ThemeContext } from './contexts';
|
|
|
15
15
|
export function ThemeProvider(_a) {
|
|
16
16
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
17
17
|
const themeConfig = useThemeConfig(props);
|
|
18
|
-
return _jsx(ThemeContext.Provider,
|
|
18
|
+
return _jsx(ThemeContext.Provider, { value: themeConfig, children: children });
|
|
19
19
|
}
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type UseValueControl<TValue> = {
|
|
2
|
+
value?: TValue;
|
|
3
|
+
onChange?(value: TValue): void;
|
|
4
|
+
defaultValue?: TValue;
|
|
5
|
+
};
|
|
6
|
+
export declare function useValueControl<TValue>({ value, onChange, defaultValue }: UseValueControl<TValue>): readonly [TValue | undefined, (value: any, ...args: any[]) => any];
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useUncontrolledProp } from 'uncontrollable';
|
|
2
|
+
export function useValueControl({ value, onChange, defaultValue }) {
|
|
3
|
+
return useUncontrolledProp(value, defaultValue, (newValue) => {
|
|
4
|
+
const newState = typeof newValue === 'function' ? newValue(value) : newValue;
|
|
5
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newState);
|
|
6
|
+
});
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ValueOf<T> = T[keyof T];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Utils",
|
|
7
|
-
"version": "3.1.0",
|
|
7
|
+
"version": "3.2.1-preview-0a44b2fc.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -31,5 +31,8 @@
|
|
|
31
31
|
],
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
|
-
"
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"uncontrollable": "8.0.4"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "318167bcb09619d0d40263ec844b38b1014838f4"
|
|
35
38
|
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useUncontrolledProp } from 'uncontrollable';
|
|
2
|
+
|
|
3
|
+
type UseValueControl<TValue> = {
|
|
4
|
+
value?: TValue;
|
|
5
|
+
onChange?(value: TValue): void;
|
|
6
|
+
defaultValue?: TValue;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function useValueControl<TValue>({ value, onChange, defaultValue }: UseValueControl<TValue>) {
|
|
10
|
+
return useUncontrolledProp<TValue>(value, defaultValue, (newValue: TValue) => {
|
|
11
|
+
const newState = typeof newValue === 'function' ? newValue(value) : newValue;
|
|
12
|
+
|
|
13
|
+
onChange?.(newState);
|
|
14
|
+
});
|
|
15
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ValueOf<T> = T[keyof T];
|