@vkontakte/vkui 8.1.0 → 8.1.2
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/dist/components/Flex/FlexItem/FlexItem.d.ts +1 -1
- package/dist/components/Flex/FlexItem/FlexItem.d.ts.map +1 -1
- package/dist/components/Flex/FlexItem/FlexItem.js +39 -8
- package/dist/components/Flex/FlexItem/FlexItem.js.map +1 -1
- package/dist/components/Search/Search.d.ts.map +1 -1
- package/dist/components/Search/Search.js +21 -12
- package/dist/components/Search/Search.js.map +1 -1
- package/dist/components.css +1 -1
- package/dist/components.css.map +1 -1
- package/dist/cssm/components/Flex/FlexItem/FlexItem.js +39 -9
- package/dist/cssm/components/Flex/FlexItem/FlexItem.js.map +1 -1
- package/dist/cssm/components/Search/Search.js +21 -12
- package/dist/cssm/components/Search/Search.js.map +1 -1
- package/dist/vkui.css +1 -1
- package/dist/vkui.css.map +1 -1
- package/package.json +1 -1
- package/src/components/Flex/FlexItem/FlexItem.tsx +38 -11
- package/src/components/Search/Search.tsx +27 -13
- package/dist/cssm/components/Flex/FlexItem/FlexItem.module.css +0 -17
- package/src/components/Flex/FlexItem/FlexItem.module.css +0 -17
- package/src/components/Flex/FlexItem/FlexItem.module.css.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
+
import { getRequiredValueByKey } from '../../../helpers/getValueByKey';
|
|
1
2
|
import { type LayoutProps, resolveLayoutProps } from '../../../lib/layouts';
|
|
2
3
|
import { warnOnce } from '../../../lib/warnOnce';
|
|
3
4
|
import { RootComponent } from '../../RootComponent/RootComponent';
|
|
4
5
|
import type { RootComponentProps } from '../../RootComponent/RootComponent';
|
|
5
|
-
import styles from './FlexItem.module.css';
|
|
6
|
-
|
|
7
|
-
const flexClassNames = {
|
|
8
|
-
grow: styles.flexGrow,
|
|
9
|
-
shrink: styles.flexShrink,
|
|
10
|
-
content: styles.flexContent,
|
|
11
|
-
fixed: styles.flexFixed,
|
|
12
|
-
};
|
|
13
6
|
|
|
14
7
|
export type FlexItemProps = RootComponentProps<HTMLElement> &
|
|
15
8
|
Pick<LayoutProps, 'alignSelf' | 'justifySelf' | 'flexBasis'> & {
|
|
@@ -24,14 +17,48 @@ export type FlexItemProps = RootComponentProps<HTMLElement> &
|
|
|
24
17
|
flex?: 'grow' | 'shrink' | 'content' | 'fixed' | undefined;
|
|
25
18
|
};
|
|
26
19
|
|
|
20
|
+
const resolveFlexProps = (flex: FlexItemProps['flex'], flexBasis: FlexItemProps['flexBasis']) => {
|
|
21
|
+
const overrideProps = flexBasis !== undefined ? { flexBasis } : {};
|
|
22
|
+
if (!flex) {
|
|
23
|
+
return overrideProps;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...getRequiredValueByKey<Pick<LayoutProps, 'flexGrow' | 'flexShrink' | 'flexBasis'>>(flex, {
|
|
27
|
+
grow: {
|
|
28
|
+
flexGrow: 1,
|
|
29
|
+
flexShrink: 0,
|
|
30
|
+
flexBasis: 'auto',
|
|
31
|
+
},
|
|
32
|
+
shrink: {
|
|
33
|
+
flexGrow: 0,
|
|
34
|
+
flexShrink: 1,
|
|
35
|
+
flexBasis: 'auto',
|
|
36
|
+
},
|
|
37
|
+
content: {
|
|
38
|
+
flexGrow: 1,
|
|
39
|
+
flexShrink: 1,
|
|
40
|
+
flexBasis: 'auto',
|
|
41
|
+
},
|
|
42
|
+
fixed: {
|
|
43
|
+
flexGrow: 0,
|
|
44
|
+
flexShrink: 0,
|
|
45
|
+
flexBasis: 'auto',
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
...overrideProps,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
27
52
|
const warn = warnOnce('Flex.Item');
|
|
28
53
|
|
|
29
|
-
export const FlexItem = ({ flex, ...restProps }: FlexItemProps): React.ReactNode => {
|
|
54
|
+
export const FlexItem = ({ flex, flexBasis, ...restProps }: FlexItemProps): React.ReactNode => {
|
|
30
55
|
if (process.env.NODE_ENV === 'development') {
|
|
31
56
|
warn('Компонент Flex.Item устарел, используйте компонент Box в качестве альтернативы.');
|
|
32
57
|
}
|
|
33
58
|
|
|
34
|
-
const
|
|
59
|
+
const flexProps = resolveFlexProps(flex, flexBasis);
|
|
60
|
+
|
|
61
|
+
const resolvedProps = resolveLayoutProps({ ...restProps, ...flexProps });
|
|
35
62
|
|
|
36
|
-
return <RootComponent
|
|
63
|
+
return <RootComponent {...resolvedProps} />;
|
|
37
64
|
};
|
|
@@ -288,17 +288,6 @@ export const Search = ({
|
|
|
288
288
|
[onIconClick],
|
|
289
289
|
);
|
|
290
290
|
|
|
291
|
-
const onIconCancelClickStart: React.PointerEventHandler<HTMLElement> = React.useCallback(
|
|
292
|
-
(e) => {
|
|
293
|
-
e.preventDefault();
|
|
294
|
-
inputRef.current?.focus();
|
|
295
|
-
if (touchEnabled()) {
|
|
296
|
-
onCancel();
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
[inputRef, onCancel],
|
|
300
|
-
);
|
|
301
|
-
|
|
302
291
|
useIsomorphicLayoutEffect(() => {
|
|
303
292
|
if (inputRest.value !== undefined) {
|
|
304
293
|
setHasValue(Boolean(inputRest.value));
|
|
@@ -328,6 +317,31 @@ export const Search = ({
|
|
|
328
317
|
iconProp || !hideClearButton || (adaptiveDensity.compact && onFindButtonClick),
|
|
329
318
|
);
|
|
330
319
|
|
|
320
|
+
const onClearPointerDown: React.PointerEventHandler<HTMLElement> = (e) => {
|
|
321
|
+
// Сначала вызываем внешний обработчик, затем локальную логику, чтобы можно было предотвратить обработку фокуса на поле ввода.
|
|
322
|
+
onClearButtonPointerDown?.(e);
|
|
323
|
+
|
|
324
|
+
e.preventDefault();
|
|
325
|
+
inputRef.current?.focus();
|
|
326
|
+
if (touchEnabled()) {
|
|
327
|
+
onCancel();
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const onClearClick: React.MouseEventHandler<HTMLElement> = (e) => {
|
|
332
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
333
|
+
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
|
|
334
|
+
HTMLInputElement.prototype,
|
|
335
|
+
'value',
|
|
336
|
+
)?.set;
|
|
337
|
+
nativeInputValueSetter?.call(inputRef.current, '');
|
|
338
|
+
|
|
339
|
+
const ev2 = new Event('input', { bubbles: true });
|
|
340
|
+
inputRef.current?.dispatchEvent(ev2);
|
|
341
|
+
|
|
342
|
+
onClearButtonClick?.(e);
|
|
343
|
+
};
|
|
344
|
+
|
|
331
345
|
return (
|
|
332
346
|
<RootComponent
|
|
333
347
|
baseClassName={classNames(
|
|
@@ -374,8 +388,8 @@ export const Search = ({
|
|
|
374
388
|
{!hideClearButton && (
|
|
375
389
|
<IconButton
|
|
376
390
|
hoverMode="opacity"
|
|
377
|
-
onPointerDown={
|
|
378
|
-
onClick={
|
|
391
|
+
onPointerDown={onClearPointerDown}
|
|
392
|
+
onClick={onClearClick}
|
|
379
393
|
tabIndex={hasValue ? undefined : -1}
|
|
380
394
|
disabled={inputRest.disabled}
|
|
381
395
|
data-testid={clearButtonTestId}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["./FlexItem.module.css"],"names":["flexGrow","flexShrink","flexContent","flexFixed"],"mappings":"AAAA;AAAA,E,aAEAA,U,WAFA;AAAA,E,aAMAC,Y,WANA;AAAA,E,aAUAC,a,WAVA;AAAA,E,aAcAC,W,WAdA;AAAA;AAAA","file":"FlexItem.module.css.d.ts","sourceRoot":""}
|