@vkontakte/vkui 6.3.0 → 6.3.1
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/cjs/components/Cell/Cell.d.ts.map +1 -1
- package/dist/cjs/components/Cell/Cell.js +5 -3
- package/dist/cjs/components/Cell/Cell.js.map +1 -1
- package/dist/cjs/components/CustomSelect/CustomSelect.js +7 -2
- package/dist/cjs/components/CustomSelect/CustomSelect.js.map +1 -1
- package/dist/cjs/components/Popover/Popover.d.ts +2 -2
- package/dist/cjs/components/Popover/Popover.d.ts.map +1 -1
- package/dist/cjs/components/Popover/Popover.js +4 -2
- package/dist/cjs/components/Popover/Popover.js.map +1 -1
- package/dist/cjs/lib/floating/useFloatingWithInteractions/types.d.ts +4 -0
- package/dist/cjs/lib/floating/useFloatingWithInteractions/types.d.ts.map +1 -1
- package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts +1 -1
- package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
- package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +6 -2
- package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
- package/dist/components/Cell/Cell.d.ts.map +1 -1
- package/dist/components/Cell/Cell.js +5 -3
- package/dist/components/Cell/Cell.js.map +1 -1
- package/dist/components/CustomSelect/CustomSelect.js +7 -2
- package/dist/components/CustomSelect/CustomSelect.js.map +1 -1
- package/dist/components/Popover/Popover.d.ts +2 -2
- package/dist/components/Popover/Popover.d.ts.map +1 -1
- package/dist/components/Popover/Popover.js +4 -2
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components.css +1 -1
- package/dist/components.css.map +1 -1
- package/dist/components.js.tmp +21 -9
- package/dist/cssm/components/Cell/Cell.d.ts.map +1 -1
- package/dist/cssm/components/Cell/Cell.js +7 -1
- package/dist/cssm/components/Cell/Cell.js.map +1 -1
- package/dist/cssm/components/CustomSelect/CustomSelect.js +7 -2
- package/dist/cssm/components/CustomSelect/CustomSelect.js.map +1 -1
- package/dist/cssm/components/ModalDismissButton/ModalDismissButton.module.css +3 -3
- package/dist/cssm/components/Popover/Popover.d.ts +2 -2
- package/dist/cssm/components/Popover/Popover.d.ts.map +1 -1
- package/dist/cssm/components/Popover/Popover.js +3 -2
- package/dist/cssm/components/Popover/Popover.js.map +1 -1
- package/dist/cssm/lib/floating/useFloatingWithInteractions/types.d.ts +4 -0
- package/dist/cssm/lib/floating/useFloatingWithInteractions/types.d.ts.map +1 -1
- package/dist/cssm/lib/floating/useFloatingWithInteractions/types.js.map +1 -1
- package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts +1 -1
- package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
- package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +7 -3
- package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
- package/dist/lib/floating/useFloatingWithInteractions/types.d.ts +4 -0
- package/dist/lib/floating/useFloatingWithInteractions/types.d.ts.map +1 -1
- package/dist/lib/floating/useFloatingWithInteractions/types.js.map +1 -1
- package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts +1 -1
- package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
- package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +7 -3
- package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
- package/dist/vkui.css +1 -1
- package/dist/vkui.css.map +1 -1
- package/dist/vkui.js.tmp +21 -9
- package/package.json +1 -1
- package/src/components/Cell/Cell.tsx +5 -1
- package/src/components/CustomSelect/CustomSelect.tsx +4 -4
- package/src/components/ModalDismissButton/ModalDismissButton.module.css +3 -3
- package/src/components/Popover/Popover.tsx +3 -0
- package/src/lib/floating/useFloatingWithInteractions/types.ts +4 -0
- package/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts +6 -2
package/dist/vkui.js.tmp
CHANGED
|
@@ -13331,7 +13331,7 @@ var whileElementsMounted = function() {
|
|
|
13331
13331
|
placement, placementProp = tmp === void 0 ? 'bottom' : tmp, middlewares = param.middlewares, _param_hoverDelay = param.hoverDelay, hoverDelay = _param_hoverDelay === void 0 ? 0 : _param_hoverDelay, _param_closeAfterClick = param.closeAfterClick, closeAfterClick = _param_closeAfterClick === void 0 ? false : _param_closeAfterClick, _param_disabled = param.// disables
|
|
13332
13332
|
disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, _param_disableInteractive = param.disableInteractive, disableInteractive = _param_disableInteractive === void 0 ? false : _param_disableInteractive, _param_disableCloseOnClickOutside = param.disableCloseOnClickOutside, disableCloseOnClickOutside = _param_disableCloseOnClickOutside === void 0 ? false : _param_disableCloseOnClickOutside, _param_disableCloseOnEscKey = param.disableCloseOnEscKey, disableCloseOnEscKey = _param_disableCloseOnEscKey === void 0 ? false : _param_disableCloseOnEscKey, _param_defaultShown = param.// uncontrolled
|
|
13333
13333
|
defaultShown, defaultShown = _param_defaultShown === void 0 ? false : _param_defaultShown, // controlled
|
|
13334
|
-
shownProp = param.shown, onShownChangeProp = param.onShownChange;
|
|
13334
|
+
shownProp = param.shown, onShownChangeProp = param.onShownChange, onShownChangedProp = param.onShownChanged;
|
|
13335
13335
|
var memoizedValue = React.useMemo(function() {
|
|
13336
13336
|
return shownProp !== undefined ? {
|
|
13337
13337
|
shown: shownProp
|
|
@@ -13352,6 +13352,7 @@ var whileElementsMounted = function() {
|
|
|
13352
13352
|
}
|
|
13353
13353
|
})
|
|
13354
13354
|
}), 2), shownLocalState = _useCustomEnsuredControl[0], setShownLocalState = _useCustomEnsuredControl[1];
|
|
13355
|
+
var onShownChanged = useStableCallback(onShownChangedProp ? onShownChangedProp : noop);
|
|
13355
13356
|
var _React_useState = useFloatingWithInteractions_sliced_to_array(React.useState(function() {
|
|
13356
13357
|
return shownLocalState.shown;
|
|
13357
13358
|
}), 2), shownFinalState = _React_useState[0], setShownFinalState = _React_useState[1];
|
|
@@ -13479,6 +13480,7 @@ var whileElementsMounted = function() {
|
|
|
13479
13480
|
if (willBeHide) {
|
|
13480
13481
|
setShownFinalState(false);
|
|
13481
13482
|
setWillBeHide(false);
|
|
13483
|
+
onShownChanged(false, shownLocalState.reason);
|
|
13482
13484
|
}
|
|
13483
13485
|
};
|
|
13484
13486
|
var handleOnClose = React.useCallback(function() {
|
|
@@ -13537,6 +13539,7 @@ var whileElementsMounted = function() {
|
|
|
13537
13539
|
}
|
|
13538
13540
|
if (shownLocalState.shown) {
|
|
13539
13541
|
setShownFinalState(true);
|
|
13542
|
+
onShownChanged(true, shownLocalState.reason);
|
|
13540
13543
|
} else if (hasCSSAnimation.current && !willBeHide) {
|
|
13541
13544
|
setWillBeHide(true);
|
|
13542
13545
|
} else {
|
|
@@ -13548,7 +13551,8 @@ var whileElementsMounted = function() {
|
|
|
13548
13551
|
}, [
|
|
13549
13552
|
shownLocalState,
|
|
13550
13553
|
shownFinalState,
|
|
13551
|
-
willBeHide
|
|
13554
|
+
willBeHide,
|
|
13555
|
+
onShownChanged
|
|
13552
13556
|
]);
|
|
13553
13557
|
var referencePropsRef = React.useRef({});
|
|
13554
13558
|
var floatingPropsRef = React.useRef({
|
|
@@ -27030,12 +27034,14 @@ function Cell_unsupported_iterable_to_array(o, minLen) {
|
|
|
27030
27034
|
var simpleCellDisabled = draggable && !selectable || removable && !restProps.onClick || disabled;
|
|
27031
27035
|
var hasActive = !simpleCellDisabled && !dragging;
|
|
27032
27036
|
var cellClasses = classNames_classNames("vkuiCell", dragging && "vkuiCell--dragging", platform === 'ios' && "vkuiCell--ios", removable && "vkuiCell--removable", Component === 'label' && "vkuiCell--selectable", disabled && "vkuiCell--disabled");
|
|
27033
|
-
var simpleCellProps = Cell_object_spread_props(Cell_object_spread({
|
|
27037
|
+
var simpleCellProps = Cell_object_spread_props(Cell_object_spread(Cell_object_spread_props(Cell_object_spread({
|
|
27034
27038
|
hasActive: hasActive,
|
|
27035
27039
|
hasHover: hasActive && !removable
|
|
27036
27040
|
}, restProps), {
|
|
27037
|
-
className: "vkuiCell__content"
|
|
27038
|
-
|
|
27041
|
+
className: "vkuiCell__content"
|
|
27042
|
+
}), Component && {
|
|
27043
|
+
Component: Component
|
|
27044
|
+
}), {
|
|
27039
27045
|
before: /*#__PURE__*/ react.createElement(react.Fragment, null, draggable && platform !== 'ios' && dragger, selectable && checkbox, before),
|
|
27040
27046
|
after: /*#__PURE__*/ react.createElement(react.Fragment, null, draggable && platform === 'ios' && dragger, after)
|
|
27041
27047
|
});
|
|
@@ -40494,6 +40500,7 @@ var CustomSelect_defaultOptions = (/* unused pure expression or super */ null &&
|
|
|
40494
40500
|
var handleRootRef = useExternRef(containerRef, getRootRef);
|
|
40495
40501
|
var scrollBoxRef = React.useRef(null);
|
|
40496
40502
|
var selectElRef = useExternRef(getRef);
|
|
40503
|
+
var optionsWrapperRef = React.useRef(null);
|
|
40497
40504
|
var _React_useState1 = CustomSelect_sliced_to_array(React.useState(-1), 2), focusedOptionIndex = _React_useState1[0], setFocusedOptionIndex = _React_useState1[1];
|
|
40498
40505
|
var _React_useState2 = CustomSelect_sliced_to_array(React.useState(props.value !== undefined), 2), isControlledOutside = _React_useState2[0], setIsControlledOutside = _React_useState2[1];
|
|
40499
40506
|
var _React_useState3 = CustomSelect_sliced_to_array(React.useState(''), 2), inputValue = _React_useState3[0], setInputValue = _React_useState3[1];
|
|
@@ -40547,7 +40554,8 @@ var CustomSelect_defaultOptions = (/* unused pure expression or super */ null &&
|
|
|
40547
40554
|
var scrollToElement = React.useCallback(function(index) {
|
|
40548
40555
|
var center = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
40549
40556
|
var dropdown = scrollBoxRef.current;
|
|
40550
|
-
var
|
|
40557
|
+
var optionsWrapper = optionsWrapperRef.current;
|
|
40558
|
+
var item = dropdown && optionsWrapper ? optionsWrapper.children[index] : null;
|
|
40551
40559
|
if (!item || !dropdown) {
|
|
40552
40560
|
return;
|
|
40553
40561
|
}
|
|
@@ -40887,7 +40895,9 @@ var CustomSelect_defaultOptions = (/* unused pure expression or super */ null &&
|
|
|
40887
40895
|
popupAriaId
|
|
40888
40896
|
]);
|
|
40889
40897
|
var resolvedContent = React.useMemo(function() {
|
|
40890
|
-
var defaultDropdownContent = (options === null || options === void 0 ? void 0 : options.length) > 0 ?
|
|
40898
|
+
var defaultDropdownContent = (options === null || options === void 0 ? void 0 : options.length) > 0 ? /*#__PURE__*/ React.createElement("div", {
|
|
40899
|
+
ref: optionsWrapperRef
|
|
40900
|
+
}, options.map(renderOption)) : /*#__PURE__*/ React.createElement(Footnote, {
|
|
40891
40901
|
className: "vkuiCustomSelect__empty"
|
|
40892
40902
|
}, emptyText);
|
|
40893
40903
|
if (typeof renderDropdown === 'function') {
|
|
@@ -46162,7 +46172,7 @@ function Popover_unsupported_iterable_to_array(o, minLen) {
|
|
|
46162
46172
|
var // UsePopoverProps
|
|
46163
46173
|
withArrow = _param.arrow, _param_arrowHeight = _param.arrowHeight, arrowHeight = _param_arrowHeight === void 0 ? DEFAULT_ARROW_HEIGHT : _param_arrowHeight, _param_arrowPadding = _param.arrowPadding, arrowPadding = _param_arrowPadding === void 0 ? DEFAULT_ARROW_PADDING : _param_arrowPadding, tmp = _param.placement, expectedPlacement = tmp === void 0 ? 'bottom-start' : tmp, onPlacementChange = _param.onPlacementChange, _param_disableFlipMiddleware = _param.disableFlipMiddleware, disableFlipMiddleware = _param_disableFlipMiddleware === void 0 ? false : _param_disableFlipMiddleware, _param_trigger = _param.trigger, trigger = _param_trigger === void 0 ? 'click' : _param_trigger, content = _param.content, _param_hoverDelay = _param.hoverDelay, hoverDelay = _param_hoverDelay === void 0 ? 150 : _param_hoverDelay, closeAfterClick = _param.closeAfterClick, _param_offsetByMainAxis = _param.offsetByMainAxis, offsetByMainAxis = _param_offsetByMainAxis === void 0 ? 8 : _param_offsetByMainAxis, _param_offsetByCrossAxis = _param.offsetByCrossAxis, offsetByCrossAxis = _param_offsetByCrossAxis === void 0 ? 0 : _param_offsetByCrossAxis, sameWidth = _param.sameWidth, hideWhenReferenceHidden = _param.hideWhenReferenceHidden, disabled = _param.disabled, disableInteractive = _param.disableInteractive, disableCloseOnClickOutside = _param.disableCloseOnClickOutside, disableCloseOnEscKey = _param.disableCloseOnEscKey, _param_keepMounted = _param.keepMounted, keepMounted = _param_keepMounted === void 0 ? false : _param_keepMounted, customMiddlewares = _param.customMiddlewares, _param_defaultShown = _param.// uncontrolled
|
|
46164
46174
|
defaultShown, defaultShown = _param_defaultShown === void 0 ? false : _param_defaultShown, // controlled
|
|
46165
|
-
shownProp = _param.shown, onShownChange = _param.onShownChange, _param_usePortal = _param.// Для AppRootPortal
|
|
46175
|
+
shownProp = _param.shown, onShownChange = _param.onShownChange, onShownChanged = _param.onShownChanged, _param_usePortal = _param.// Для AppRootPortal
|
|
46166
46176
|
usePortal, usePortal = _param_usePortal === void 0 ? true : _param_usePortal, // Для FloatingArrow
|
|
46167
46177
|
arrowProps = _param.arrowProps, _param_ArrowIcon = _param.ArrowIcon, ArrowIcon = _param_ArrowIcon === void 0 ? DefaultIcon : _param_ArrowIcon, _param_autoFocus = _param.// FocusTrapProps
|
|
46168
46178
|
autoFocus, autoFocus = _param_autoFocus === void 0 ? true : _param_autoFocus, _param_restoreFocus = _param.restoreFocus, restoreFocus = _param_restoreFocus === void 0 ? true : _param_restoreFocus, className = _param.className, children = _param.children, _param_noStyling = _param.noStyling, noStyling = _param_noStyling === void 0 ? false : _param_noStyling, _param_zIndex = _param.zIndex, zIndex = _param_zIndex === void 0 ? 'var(--vkui--z_index_popout)' : _param_zIndex, _param_role = _param.// a11y
|
|
@@ -46190,6 +46200,7 @@ function Popover_unsupported_iterable_to_array(o, minLen) {
|
|
|
46190
46200
|
"defaultShown",
|
|
46191
46201
|
"shown",
|
|
46192
46202
|
"onShownChange",
|
|
46203
|
+
"onShownChanged",
|
|
46193
46204
|
"usePortal",
|
|
46194
46205
|
"arrowProps",
|
|
46195
46206
|
"ArrowIcon",
|
|
@@ -46227,7 +46238,8 @@ function Popover_unsupported_iterable_to_array(o, minLen) {
|
|
|
46227
46238
|
disableCloseOnEscKey: disableCloseOnEscKey,
|
|
46228
46239
|
defaultShown: defaultShown,
|
|
46229
46240
|
shown: shownProp,
|
|
46230
|
-
onShownChange: onShownChange
|
|
46241
|
+
onShownChange: onShownChange,
|
|
46242
|
+
onShownChanged: onShownChanged
|
|
46231
46243
|
}), resolvedPlacement = _useFloatingWithInteractions.placement, shown = _useFloatingWithInteractions.shown, willBeHide = _useFloatingWithInteractions.willBeHide, refs = _useFloatingWithInteractions.refs, referenceProps = _useFloatingWithInteractions.referenceProps, floatingProps = _useFloatingWithInteractions.floatingProps, middlewareData = _useFloatingWithInteractions.middlewareData, onClose = _useFloatingWithInteractions.onClose, onRestoreFocus = _useFloatingWithInteractions.onRestoreFocus, onEscapeKeyDown = _useFloatingWithInteractions.onEscapeKeyDown;
|
|
46232
46244
|
usePlacementChangeCallback(expectedPlacement, resolvedPlacement, onPlacementChange);
|
|
46233
46245
|
var _usePatchChildren = Popover_sliced_to_array(usePatchChildren(children, injectAriaExpandedPropByRole(referenceProps, shown, role), refs.setReference), 2), child = _usePatchChildren[1];
|
package/package.json
CHANGED
|
@@ -125,7 +125,11 @@ export const Cell: React.FC<CellProps> & {
|
|
|
125
125
|
hasHover: hasActive && !removable,
|
|
126
126
|
...restProps,
|
|
127
127
|
className: styles['Cell__content'],
|
|
128
|
-
|
|
128
|
+
// чтобы свойство, если не определено, не присутствовало в
|
|
129
|
+
// restProps явно как {'Component': undefined} и ниже не переопределяло
|
|
130
|
+
// возможное значение commonProps.Component = 'a' при слиянии двух объектов, как
|
|
131
|
+
// {...commonProps, ...restProps}
|
|
132
|
+
...(Component && { Component }),
|
|
129
133
|
before: (
|
|
130
134
|
<React.Fragment>
|
|
131
135
|
{draggable && platform !== 'ios' && dragger}
|
|
@@ -282,6 +282,7 @@ export function CustomSelect<OptionInterfaceT extends CustomSelectOptionInterfac
|
|
|
282
282
|
const handleRootRef = useExternRef(containerRef, getRootRef);
|
|
283
283
|
const scrollBoxRef = React.useRef<HTMLDivElement | null>(null);
|
|
284
284
|
const selectElRef = useExternRef(getRef);
|
|
285
|
+
const optionsWrapperRef = React.useRef<HTMLDivElement>(null);
|
|
285
286
|
|
|
286
287
|
const [focusedOptionIndex, setFocusedOptionIndex] = React.useState<number | undefined>(-1);
|
|
287
288
|
const [isControlledOutside, setIsControlledOutside] = React.useState(props.value !== undefined);
|
|
@@ -334,10 +335,9 @@ export function CustomSelect<OptionInterfaceT extends CustomSelectOptionInterfac
|
|
|
334
335
|
|
|
335
336
|
const scrollToElement = React.useCallback((index: number, center = false) => {
|
|
336
337
|
const dropdown = scrollBoxRef.current;
|
|
338
|
+
const optionsWrapper = optionsWrapperRef.current;
|
|
337
339
|
const item =
|
|
338
|
-
dropdown &&
|
|
339
|
-
? (dropdown.firstElementChild.children[index] as HTMLElement)
|
|
340
|
-
: null;
|
|
340
|
+
dropdown && optionsWrapper ? (optionsWrapper.children[index] as HTMLElement) : null;
|
|
341
341
|
|
|
342
342
|
if (!item || !dropdown) {
|
|
343
343
|
return;
|
|
@@ -704,7 +704,7 @@ export function CustomSelect<OptionInterfaceT extends CustomSelectOptionInterfac
|
|
|
704
704
|
const resolvedContent = React.useMemo(() => {
|
|
705
705
|
const defaultDropdownContent =
|
|
706
706
|
options?.length > 0 ? (
|
|
707
|
-
options.map(renderOption)
|
|
707
|
+
<div ref={optionsWrapperRef}>{options.map(renderOption)}</div>
|
|
708
708
|
) : (
|
|
709
709
|
<Footnote className={styles['CustomSelect__empty']}>{emptyText}</Footnote>
|
|
710
710
|
);
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
padding: 18px;
|
|
8
8
|
box-sizing: border-box;
|
|
9
9
|
color: var(--vkui--color_icon_contrast);
|
|
10
|
-
transition: opacity 0.15s ease-out;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
.ModalDismissButton::before {
|
|
@@ -17,6 +16,7 @@
|
|
|
17
16
|
background: var(--vkui--color_overlay_secondary);
|
|
18
17
|
border-radius: 50%;
|
|
19
18
|
position: absolute;
|
|
19
|
+
transition: background-color 0.15s ease-out;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/* stylelint-disable-next-line selector-pseudo-class-disallowed-list -- fixes icon misplacement on Safari in some cases */
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
.ModalDismissButton--hover::before {
|
|
28
|
-
|
|
28
|
+
background: var(--vkui--color_overlay_secondary--hover);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
.ModalDismissButton--active::before {
|
|
32
|
-
|
|
32
|
+
background: var(--vkui--color_overlay_secondary--active);
|
|
33
33
|
}
|
|
@@ -62,6 +62,7 @@ type AllowedFloatingComponentProps = Pick<
|
|
|
62
62
|
| 'defaultShown'
|
|
63
63
|
| 'shown'
|
|
64
64
|
| 'onShownChange'
|
|
65
|
+
| 'onShownChanged'
|
|
65
66
|
| 'usePortal'
|
|
66
67
|
| 'sameWidth'
|
|
67
68
|
| 'hideWhenReferenceHidden'
|
|
@@ -152,6 +153,7 @@ export const Popover = ({
|
|
|
152
153
|
// controlled
|
|
153
154
|
shown: shownProp,
|
|
154
155
|
onShownChange,
|
|
156
|
+
onShownChanged,
|
|
155
157
|
|
|
156
158
|
// Для AppRootPortal
|
|
157
159
|
usePortal = true,
|
|
@@ -209,6 +211,7 @@ export const Popover = ({
|
|
|
209
211
|
defaultShown,
|
|
210
212
|
shown: shownProp,
|
|
211
213
|
onShownChange,
|
|
214
|
+
onShownChanged,
|
|
212
215
|
});
|
|
213
216
|
|
|
214
217
|
usePlacementChangeCallback(expectedPlacement, resolvedPlacement, onPlacementChange);
|
|
@@ -80,6 +80,10 @@ export interface UseFloatingWithInteractionsProps {
|
|
|
80
80
|
* Вызывается при каждом изменении видимости всплывающего элемента.
|
|
81
81
|
*/
|
|
82
82
|
onShownChange?: OnShownChange;
|
|
83
|
+
/**
|
|
84
|
+
* Вызывается при каждом изменении видимости всплывающего элемента, но после завершении анимации.
|
|
85
|
+
*/
|
|
86
|
+
onShownChanged?: OnShownChange;
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
export type ReferenceProps<T = HTMLElement> = Omit<
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { debounce } from '@vkontakte/vkjs';
|
|
2
|
+
import { debounce, noop } from '@vkontakte/vkjs';
|
|
3
3
|
import { getWindow, isHTMLElement } from '@vkontakte/vkui-floating-ui/utils/dom';
|
|
4
4
|
import { useCustomEnsuredControl } from '../../../hooks/useEnsuredControl';
|
|
5
5
|
import { useGlobalOnClickOutside } from '../../../hooks/useGlobalOnClickOutside';
|
|
@@ -49,6 +49,7 @@ export const useFloatingWithInteractions = <T extends HTMLElement = HTMLElement>
|
|
|
49
49
|
// controlled
|
|
50
50
|
shown: shownProp,
|
|
51
51
|
onShownChange: onShownChangeProp,
|
|
52
|
+
onShownChanged: onShownChangedProp,
|
|
52
53
|
}: UseFloatingWithInteractionsProps): UseFloatingWithInteractionsReturn<T> => {
|
|
53
54
|
const memoizedValue = React.useMemo(
|
|
54
55
|
() => (shownProp !== undefined ? { shown: shownProp } : undefined),
|
|
@@ -64,6 +65,7 @@ export const useFloatingWithInteractions = <T extends HTMLElement = HTMLElement>
|
|
|
64
65
|
}
|
|
65
66
|
}),
|
|
66
67
|
});
|
|
68
|
+
const onShownChanged = useStableCallback(onShownChangedProp ? onShownChangedProp : noop);
|
|
67
69
|
const [shownFinalState, setShownFinalState] = React.useState(() => shownLocalState.shown);
|
|
68
70
|
const [willBeHide, setWillBeHide] = React.useState(false);
|
|
69
71
|
|
|
@@ -215,6 +217,7 @@ export const useFloatingWithInteractions = <T extends HTMLElement = HTMLElement>
|
|
|
215
217
|
if (willBeHide) {
|
|
216
218
|
setShownFinalState(false);
|
|
217
219
|
setWillBeHide(false);
|
|
220
|
+
onShownChanged(false, shownLocalState.reason);
|
|
218
221
|
}
|
|
219
222
|
};
|
|
220
223
|
|
|
@@ -288,6 +291,7 @@ export const useFloatingWithInteractions = <T extends HTMLElement = HTMLElement>
|
|
|
288
291
|
|
|
289
292
|
if (shownLocalState.shown) {
|
|
290
293
|
setShownFinalState(true);
|
|
294
|
+
onShownChanged(true, shownLocalState.reason);
|
|
291
295
|
} else if (hasCSSAnimation.current && !willBeHide) {
|
|
292
296
|
setWillBeHide(true);
|
|
293
297
|
} else {
|
|
@@ -298,7 +302,7 @@ export const useFloatingWithInteractions = <T extends HTMLElement = HTMLElement>
|
|
|
298
302
|
clearTimeout(blurTimeoutRef.current);
|
|
299
303
|
};
|
|
300
304
|
},
|
|
301
|
-
[shownLocalState, shownFinalState, willBeHide],
|
|
305
|
+
[shownLocalState, shownFinalState, willBeHide, onShownChanged],
|
|
302
306
|
);
|
|
303
307
|
|
|
304
308
|
const referencePropsRef = React.useRef<ReferenceProps>({});
|