Skip to content

Commit

Permalink
Merge branch 'main' into textArea-size
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanVor authored Jul 3, 2024
2 parents 847f14e + 8bff882 commit 2fad9ad
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [6.20.1](https://github.com/gravity-ui/uikit/compare/v6.20.0...v6.20.1) (2024-07-01)


### Bug Fixes

* **Dialog:** move QA props to DialogOwnProps ([#1691](https://github.com/gravity-ui/uikit/issues/1691)) ([fc33ba7](https://github.com/gravity-ui/uikit/commit/fc33ba716559db6bfe532b64684f439e930daa89))
* **Text:** style property ([#1681](https://github.com/gravity-ui/uikit/issues/1681)) ([89048e4](https://github.com/gravity-ui/uikit/commit/89048e45e6f2d3512c5a70ed75ece530885e72da))

## [6.20.0](https://github.com/gravity-ui/uikit/compare/v6.19.0...v6.20.0) (2024-06-26)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gravity-ui/uikit",
"version": "6.20.0",
"version": "6.20.1",
"description": "Gravity UI base styling and components",
"keywords": [
"component",
Expand Down
1 change: 1 addition & 0 deletions src/components/Select/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ LANDING_BLOCK-->
| [multiple](#selecting-multiple-options) | Indicates that multiple options can be selected in the list | `boolean` | `false` |
| name | Name of the control | `string` | |
| onBlur | Handler that is called when the element loses focus. | `function` | |
| filter | Controlled filter value | `string` | `''` |
| onFilterChange | Fires every time after changing filter | `function` | |
| onFocus | Handler that is called when the element receives focus. | `function` | |
| onLoadMore | Fires when loading indicator gets visible. | `function` | |
Expand Down
18 changes: 9 additions & 9 deletions src/hooks/useControlledState/useControlledState.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from 'react';

export function useControlledState<T, C = T>(
export function useControlledState<T, C = T, Args extends any[] = []>(
value: Exclude<T, undefined>,
defaultValue: Exclude<T, undefined> | undefined,
onChange?: (v: C, ...args: any[]) => void,
): [T, (value: C) => void];
export function useControlledState<T, C = T>(
onChange?: (v: C, ...args: Args) => void,
): [T, (value: C, ...args: Args) => void];
export function useControlledState<T, C = T, Args extends any[] = []>(
value: Exclude<T, undefined> | undefined,
defaultValue: Exclude<T, undefined>,
onChange?: (v: C, ...args: any[]) => void,
): [T, (value: C) => void];
export function useControlledState<T, C extends T = T>(
onChange?: (v: C, ...args: Args) => void,
): [T, (value: C, ...args: Args) => void];
export function useControlledState<T, C extends T = T, Args extends any[] = []>(
value: T,
defaultValue: T,
onUpdate?: (value: C, ...args: any[]) => void,
onUpdate?: (value: C, ...args: Args) => void,
) {
const [innerValue, setInnerValue] = React.useState(value ?? defaultValue);

Expand All @@ -37,7 +37,7 @@ export function useControlledState<T, C extends T = T>(
// that we call `onUpdate` inside the callback function and onUpdate
// in a controlling component frequently calls setState itself,
// therefore we call `setState` while we're rendering a different component.
(newValue: C, ...args: any[]) => {
(newValue: C, ...args: Args) => {
if (!Object.is(currentValue, newValue)) {
onUpdate?.(newValue, ...args);
}
Expand Down
11 changes: 8 additions & 3 deletions src/hooks/useResizeObserver/useResizeObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import React from 'react';
interface UseResizeObserverProps<T> {
ref: React.RefObject<T | null | undefined> | undefined;
onResize: () => void;
box?: ResizeObserverBoxOptions;
}

export function useResizeObserver<T extends Element>({ref, onResize}: UseResizeObserverProps<T>) {
export function useResizeObserver<T extends Element>({
ref,
onResize,
box,
}: UseResizeObserverProps<T>) {
React.useEffect(() => {
const element = ref?.current;
if (!element) {
Expand All @@ -26,9 +31,9 @@ export function useResizeObserver<T extends Element>({ref, onResize}: UseResizeO
onResize();
});

observer.observe(element);
observer.observe(element, {box});
return () => {
observer.disconnect();
};
}, [ref, onResize]);
}, [ref, onResize, box]);
}

0 comments on commit 2fad9ad

Please sign in to comment.