@progress/kendo-react-layout 14.4.1 → 14.5.0-develop.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/cdn/js/kendo-react-layout.js +1 -1
- package/menu/components/Menu.d.ts +14 -93
- package/menu/components/Menu.js +1 -1
- package/menu/components/Menu.mjs +223 -212
- package/menu/components/MenuItem.d.ts +4 -24
- package/menu/components/MenuItem.js +1 -1
- package/menu/components/MenuItem.mjs +16 -24
- package/menu/components/MenuItemArrow.d.ts +1 -16
- package/menu/components/MenuItemArrow.js +1 -1
- package/menu/components/MenuItemArrow.mjs +26 -35
- package/menu/components/MenuItemInternal.d.ts +2 -35
- package/menu/components/MenuItemInternal.js +1 -1
- package/menu/components/MenuItemInternal.mjs +174 -219
- package/menu/components/MenuItemLink.d.ts +1 -15
- package/menu/components/MenuItemLink.js +1 -1
- package/menu/components/MenuItemLink.mjs +17 -30
- package/menu/events.d.ts +4 -4
- package/menu/utils/DirectionHolder.js +1 -1
- package/menu/utils/DirectionHolder.mjs +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +8 -8
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { default as PropTypes } from 'prop-types';
|
|
9
8
|
import { MenuProps } from '../MenuProps';
|
|
10
9
|
import * as React from 'react';
|
|
11
10
|
/**
|
|
@@ -15,7 +14,19 @@ export interface MenuState {
|
|
|
15
14
|
focusedItemId: string;
|
|
16
15
|
hoveredItemId: string;
|
|
17
16
|
tabbableItemId: string;
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Represent the `ref` of the Menu component.
|
|
20
|
+
*/
|
|
21
|
+
export interface MenuHandle {
|
|
22
|
+
/**
|
|
23
|
+
* The current element or `null` if there is no one.
|
|
24
|
+
*/
|
|
25
|
+
element: HTMLDivElement | null;
|
|
26
|
+
/**
|
|
27
|
+
* Resets the selection and opening of Menu items.
|
|
28
|
+
*/
|
|
29
|
+
reset: () => void;
|
|
19
30
|
}
|
|
20
31
|
/**
|
|
21
32
|
* Represents the [KendoReact Menu component](https://www.telerik.com/kendo-react-ui/components/layout/menu).
|
|
@@ -39,94 +50,4 @@ export interface MenuState {
|
|
|
39
50
|
* }
|
|
40
51
|
* ```
|
|
41
52
|
*/
|
|
42
|
-
export declare
|
|
43
|
-
/**
|
|
44
|
-
* @hidden
|
|
45
|
-
*/
|
|
46
|
-
static propTypes: {
|
|
47
|
-
vertical: PropTypes.Requireable<boolean>;
|
|
48
|
-
items: PropTypes.Requireable<(object | null | undefined)[]>;
|
|
49
|
-
style: PropTypes.Requireable<object>;
|
|
50
|
-
animate: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
|
|
51
|
-
openDuration: PropTypes.Requireable<number>;
|
|
52
|
-
closeDuration: PropTypes.Requireable<number>;
|
|
53
|
-
}> | null | undefined>>;
|
|
54
|
-
dir: PropTypes.Requireable<string>;
|
|
55
|
-
hoverOpenDelay: PropTypes.Requireable<number>;
|
|
56
|
-
hoverCloseDelay: PropTypes.Requireable<number>;
|
|
57
|
-
openOnClick: PropTypes.Requireable<boolean>;
|
|
58
|
-
itemRender: PropTypes.Requireable<any>;
|
|
59
|
-
linkRender: PropTypes.Requireable<any>;
|
|
60
|
-
customCloseItemIds: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
61
|
-
onSelect: PropTypes.Requireable<(...args: any[]) => any>;
|
|
62
|
-
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
63
|
-
role: PropTypes.Requireable<string>;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* @hidden
|
|
67
|
-
*/
|
|
68
|
-
static defaultProps: {
|
|
69
|
-
vertical: boolean;
|
|
70
|
-
animate: boolean;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* @hidden
|
|
74
|
-
*/
|
|
75
|
-
readonly state: MenuState;
|
|
76
|
-
private itemHoverRequest;
|
|
77
|
-
private itemLeaveRequest;
|
|
78
|
-
private menuWrapperEl;
|
|
79
|
-
private get menuItemId();
|
|
80
|
-
private directionHolder;
|
|
81
|
-
private inputItems;
|
|
82
|
-
private items;
|
|
83
|
-
private mouseOverHandler;
|
|
84
|
-
/**
|
|
85
|
-
* The current element or `null` if there is no one.
|
|
86
|
-
*/
|
|
87
|
-
get element(): HTMLDivElement | null;
|
|
88
|
-
constructor(props: MenuProps);
|
|
89
|
-
protected get animate(): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* @hidden
|
|
92
|
-
*/
|
|
93
|
-
render(): React.JSX.Element;
|
|
94
|
-
/**
|
|
95
|
-
* @hidden
|
|
96
|
-
*/
|
|
97
|
-
componentDidMount(): void;
|
|
98
|
-
/**
|
|
99
|
-
* @hidden
|
|
100
|
-
*/
|
|
101
|
-
componentDidUpdate(prevProps: MenuProps): void;
|
|
102
|
-
/**
|
|
103
|
-
* @hidden
|
|
104
|
-
*/
|
|
105
|
-
componentWillUnmount(): void;
|
|
106
|
-
/**
|
|
107
|
-
* Resets the selection and opening of Menu items.
|
|
108
|
-
*/
|
|
109
|
-
reset: () => void;
|
|
110
|
-
private handleClickOutside;
|
|
111
|
-
private onKeyDown;
|
|
112
|
-
private onItemMouseOver;
|
|
113
|
-
private onItemMouseLeave;
|
|
114
|
-
private onItemFocus;
|
|
115
|
-
private onItemClick;
|
|
116
|
-
private onPopupClose;
|
|
117
|
-
private onItemBlur;
|
|
118
|
-
private getInputItem;
|
|
119
|
-
private setFocusedItemId;
|
|
120
|
-
private setHoveredItemId;
|
|
121
|
-
private getMenuClassName;
|
|
122
|
-
private clearItemHoverAndLeaveRequestsIfApplicable;
|
|
123
|
-
private isItemWithDefaultClose;
|
|
124
|
-
private checkIsDirectionRightToLeft;
|
|
125
|
-
private prepareItems;
|
|
126
|
-
private dispatchSelectEventIfWired;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Represent the `ref` of the Menu component.
|
|
130
|
-
*/
|
|
131
|
-
export interface MenuHandle extends Pick<Menu, keyof Menu> {
|
|
132
|
-
}
|
|
53
|
+
export declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<MenuHandle>>;
|
package/menu/components/Menu.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react"),i=require("prop-types"),M=require("@progress/kendo-react-common"),t=require("../utils/itemsIdsUtils.js"),ee=require("../utils/prepareInputItemsForInternalWork.js"),Z=require("../utils/getNewItemIdUponKeyboardNavigation.js"),B=require("../utils/hoverDelay.js"),te=require("./MenuItemInternal.js"),re=require("../utils/DirectionHolder.js"),ne=require("../utils/MouseOverHandler.js");function oe(o){const D=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const I in o)if(I!=="default"){const b=Object.getOwnPropertyDescriptor(o,I);Object.defineProperty(D,I,b.get?b:{enumerable:!0,get:()=>o[I]})}}return D.default=o,Object.freeze(D)}const n=oe(X),K={focusedItemId:t.EMPTY_ID,hoveredItemId:t.EMPTY_ID,tabbableItemId:t.ZERO_LEVEL_ZERO_ITEM_ID},S=n.forwardRef((o,D)=>{const I=n.useRef(null),b=n.useRef(null),y=n.useRef(null),R=n.useRef(new re.DirectionHolder),O=n.useRef([]),N=n.useRef([]),l=n.useRef(o);l.current=o;const[v,h]=n.useState({...K}),C=n.useRef(v);C.current=v;const w=n.useRef(()=>{}),P=n.useRef(new ne.MouseOverHandler(o.openOnClick,()=>w.current())),{items:j,inputItems:F}=ee.prepareInputItemsForInternalWork(o.items,o.children);O.current=j,N.current=F,R.current.setIsDirectionRightToLeft(V());function V(){return!!(l.current.dir!==void 0?l.current.dir==="rtl":I.current&&getComputedStyle(I.current).direction==="rtl")}const g=n.useCallback(()=>{b.current&&(clearTimeout(b.current),b.current=null),y.current&&(clearTimeout(y.current),y.current=null)},[]),H=n.useCallback(()=>{g(),h({...K})},[g]);w.current=H;const E=n.useRef({get element(){return I.current},reset:()=>w.current()});n.useImperativeHandle(D,()=>E.current,[]);const m=n.useCallback(e=>{h(r=>{const c=e===t.EMPTY_ID?r.tabbableItemId:t.getRootParentId(e);return{hoveredItemId:e===t.EMPTY_ID||t.isIdEmptyOrZeroLevel(r.hoveredItemId)&&t.isIdEmptyOrZeroLevel(e)?r.hoveredItemId:t.EMPTY_ID,focusedItemId:e,tabbableItemId:c}})},[]),a=n.useCallback(e=>{h(r=>t.isIdEmptyOrZeroLevel(e)&&t.isIdEmptyOrZeroLevel(r.focusedItemId)?{hoveredItemId:e,focusedItemId:r.focusedItemId,tabbableItemId:r.tabbableItemId}:{hoveredItemId:e,focusedItemId:t.EMPTY_ID,tabbableItemId:t.ZERO_LEVEL_ZERO_ITEM_ID})},[]),f=n.useCallback(e=>t.getItemById(e,N.current),[]),T=n.useCallback((e,r)=>{M.dispatchEvent(l.current.onSelect,e,E.current,{item:f(r),itemId:r})},[f]),_=n.useCallback(e=>!l.current.customCloseItemIds||l.current.customCloseItemIds.indexOf(e)===-1,[]),Y=n.useCallback(e=>{var s,u;const r=l.current,c=C.current;if(r.openOnClick&&c.hoveredItemId!==t.EMPTY_ID){const d=e.target;((s=I.current)==null?void 0:s.contains(d))===!1&&(r.id&&((u=d.closest)!=null&&u.call(d,`[id^="${r.id}_"]`))||a(t.EMPTY_ID))}},[a]),W=n.useCallback(e=>{const r=C.current,c=l.current,s=O.current;if(r.focusedItemId!==t.EMPTY_ID){const u=t.getItemById(r.focusedItemId,s);let d=Z.getNewItemIdUponKeyboardNavigation(s,u.id,e.keyCode,e.key,c.vertical,R.current.getIsDirectionRightToLeft());const k=t.getItemById(d,s);if(k!=null&&k.separator&&(d=Z.getNewItemIdUponKeyboardNavigation(s,d,e.keyCode,e.key,c.vertical,R.current.getIsDirectionRightToLeft())),u.id!==d&&(e.preventDefault(),m(d)),(e.keyCode===M.Keys.enter||e.keyCode===M.Keys.space)&&!u.disabled&&(P.current.handleItemSelectedViaKeyboard(),T(e,u.id),!e.isDefaultPrevented()&&u.items.length===0&&u.url&&window.location.assign(u.url)),e.keyCode===M.Keys.esc&&t.isIdZeroLevel(u.id)&&c.onClose){const p=f(u.id);c.onClose({target:E.current,item:p,itemId:u.id})}}},[m,T,f]),U=n.useCallback(e=>{const r=C.current,c=l.current,s=c.openOnClick&&!t.isIdZeroLevel(e)&&r.hoveredItemId!==t.EMPTY_ID;(P.current.IsMouseOverEnabled||s)&&(g(),b.current=window.setTimeout(()=>{a(e),b.current=null},B.getHoverOpenDelay(c)))},[g,a]),A=n.useCallback(e=>{const r=C.current,c=l.current,s=c.openOnClick&&!t.isIdZeroLevel(e)&&r.hoveredItemId!==t.EMPTY_ID;(P.current.IsMouseOverEnabled||s)&&_(e)&&(g(),y.current=window.setTimeout(()=>{a(s?t.getDirectParentId(e):t.EMPTY_ID),y.current=null},B.getHoverCloseDelay(c)))},[g,_,a]),z=n.useCallback(e=>{C.current.hoveredItemId===t.EMPTY_ID?m(e):h(c=>({focusedItemId:e,hoveredItemId:c.hoveredItemId,tabbableItemId:t.getRootParentId(e)}))},[m]),G=n.useCallback((e,r)=>{const c=O.current,s=t.getItemById(r,c),u=C.current,d=l.current;if(!s.disabled){const k=t.isIdZeroLevel(r),p=!s.items||s.items.length===0;k?(m(r),p||d.openOnClick&&u.hoveredItemId!==t.EMPTY_ID&&t.getRootParentId(u.hoveredItemId)===r?a(t.EMPTY_ID):a(r)):p&&(m(r),a(t.EMPTY_ID)),T(e,r),!e.isDefaultPrevented()&&s.url&&window.location.assign(s.url)}},[m,a,T]),$=n.useCallback((e,r)=>{const c=l.current;c.onClose&&c.onClose({target:E.current,item:f(e),itemId:e,popupCloseEvent:r})},[f]),x=n.useCallback((e,r)=>{var s;const c=l.current;if(_(e)&&m(t.EMPTY_ID),((s=r.relatedTarget)==null?void 0:s.nodeName)==="LI"){const u=r.relatedTarget.getAttribute("id");if(u!=null&&u.includes(c.id))return}if(t.isIdZeroLevel(e)&&c.onClose){const u=f(e);c.onClose({target:E.current,item:u,itemId:e})}},[_,m,f]),q=n.useRef(o.vertical);n.useEffect(()=>()=>{g()},[g]),n.useEffect(()=>(o.openOnClick&&document.addEventListener("mousedown",Y),()=>{document.removeEventListener("mousedown",Y)}),[o.openOnClick,Y]),n.useEffect(()=>{const e=!!q.current!=!!o.vertical,r=R.current.hasDirectionChanged();(e||r)&&H(),P.current.OpenOnClick=o.openOnClick,q.current=o.vertical});const J=()=>M.classNames("k-reset","k-header","k-menu",{"k-menu-horizontal":!o.vertical},{"k-menu-vertical":o.vertical},o.className);let L;v.hoveredItemId?L=v.hoveredItemId:v.focusedItemId?L=t.getDirectParentId(v.focusedItemId):L=t.EMPTY_ID;const Q=o.animate!==void 0?o.animate:!0;return n.createElement("div",{id:o.id,onKeyDown:W,style:o.style,className:R.current.getIsDirectionRightToLeft()?"k-rtl":void 0,ref:I},n.createElement(te.MenuItemInternalsList,{className:J(),"aria-orientation":o.vertical?"vertical":void 0,items:O.current,animate:Q,isMenuVertical:o.vertical,isDirectionRightToLeft:R.current.getIsDirectionRightToLeft(),focusedItemId:v.focusedItemId,lastItemIdToBeOpened:L,tabbableItemId:v.tabbableItemId,itemRender:o.itemRender,linkRender:o.linkRender,menuGuid:o.id,onMouseLeave:A,onMouseOver:U,onFocus:z,onClick:G,onBlur:x,onOriginalItemNeeded:f,onPopupClose:$,role:o.role}))});S.propTypes={vertical:i.bool,items:i.arrayOf(i.object),style:i.object,animate:i.oneOfType([i.bool,i.shape({openDuration:i.number,closeDuration:i.number})]),dir:i.string,hoverOpenDelay:i.number,hoverCloseDelay:i.number,openOnClick:i.bool,itemRender:i.any,linkRender:i.any,customCloseItemIds:i.arrayOf(i.string),onSelect:i.func,onClose:i.func,role:i.string};S.displayName="Menu";exports.Menu=S;
|
package/menu/components/Menu.mjs
CHANGED
|
@@ -5,240 +5,251 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import { ZERO_LEVEL_ZERO_ITEM_ID as
|
|
12
|
-
import { prepareInputItemsForInternalWork as
|
|
13
|
-
import { getNewItemIdUponKeyboardNavigation as
|
|
14
|
-
import { getHoverOpenDelay as
|
|
15
|
-
import { MenuItemInternalsList as
|
|
16
|
-
import { DirectionHolder as
|
|
17
|
-
import { MouseOverHandler as
|
|
18
|
-
const
|
|
19
|
-
focusedItemId:
|
|
20
|
-
hoveredItemId:
|
|
21
|
-
tabbableItemId:
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
import * as r from "react";
|
|
9
|
+
import u from "prop-types";
|
|
10
|
+
import { dispatchEvent as oe, Keys as B, classNames as ce } from "@progress/kendo-react-common";
|
|
11
|
+
import { ZERO_LEVEL_ZERO_ITEM_ID as A, EMPTY_ID as i, getRootParentId as _, isIdEmptyOrZeroLevel as P, getItemById as S, isIdZeroLevel as O, getDirectParentId as W } from "../utils/itemsIdsUtils.mjs";
|
|
12
|
+
import { prepareInputItemsForInternalWork as se } from "../utils/prepareInputItemsForInternalWork.mjs";
|
|
13
|
+
import { getNewItemIdUponKeyboardNavigation as Z } from "../utils/getNewItemIdUponKeyboardNavigation.mjs";
|
|
14
|
+
import { getHoverOpenDelay as ue, getHoverCloseDelay as ie } from "../utils/hoverDelay.mjs";
|
|
15
|
+
import { MenuItemInternalsList as le } from "./MenuItemInternal.mjs";
|
|
16
|
+
import { DirectionHolder as ae } from "../utils/DirectionHolder.mjs";
|
|
17
|
+
import { MouseOverHandler as de } from "../utils/MouseOverHandler.mjs";
|
|
18
|
+
const q = {
|
|
19
|
+
focusedItemId: i,
|
|
20
|
+
hoveredItemId: i,
|
|
21
|
+
tabbableItemId: A
|
|
22
|
+
}, j = r.forwardRef((o, x) => {
|
|
23
|
+
const R = r.useRef(null), g = r.useRef(null), h = r.useRef(null), k = r.useRef(new ae()), D = r.useRef([]), F = r.useRef([]), l = r.useRef(o);
|
|
24
|
+
l.current = o;
|
|
25
|
+
const [f, L] = r.useState({ ...q }), C = r.useRef(f);
|
|
26
|
+
C.current = f;
|
|
27
|
+
const H = r.useRef(() => {
|
|
28
|
+
}), p = r.useRef(new de(o.openOnClick, () => H.current())), { items: z, inputItems: G } = se(
|
|
29
|
+
o.items,
|
|
30
|
+
o.children
|
|
31
|
+
);
|
|
32
|
+
D.current = z, F.current = G, k.current.setIsDirectionRightToLeft(U());
|
|
33
|
+
function U() {
|
|
34
|
+
return !!(l.current.dir !== void 0 ? l.current.dir === "rtl" : R.current && getComputedStyle(R.current).direction === "rtl");
|
|
35
|
+
}
|
|
36
|
+
const b = r.useCallback(() => {
|
|
37
|
+
g.current && (clearTimeout(g.current), g.current = null), h.current && (clearTimeout(h.current), h.current = null);
|
|
38
|
+
}, []), K = r.useCallback(() => {
|
|
39
|
+
b(), L({ ...q });
|
|
40
|
+
}, [b]);
|
|
41
|
+
H.current = K;
|
|
42
|
+
const y = r.useRef({
|
|
43
|
+
get element() {
|
|
44
|
+
return R.current;
|
|
45
|
+
},
|
|
46
|
+
reset: () => H.current()
|
|
47
|
+
});
|
|
48
|
+
r.useImperativeHandle(x, () => y.current, []);
|
|
49
|
+
const m = r.useCallback((e) => {
|
|
50
|
+
L((t) => {
|
|
51
|
+
const n = e === i ? t.tabbableItemId : _(e);
|
|
52
|
+
return { hoveredItemId: e === i || P(t.hoveredItemId) && P(e) ? t.hoveredItemId : i, focusedItemId: e, tabbableItemId: n };
|
|
53
|
+
});
|
|
54
|
+
}, []), a = r.useCallback((e) => {
|
|
55
|
+
L((t) => P(e) && P(t.focusedItemId) ? {
|
|
56
|
+
hoveredItemId: e,
|
|
57
|
+
focusedItemId: t.focusedItemId,
|
|
58
|
+
tabbableItemId: t.tabbableItemId
|
|
59
|
+
} : { hoveredItemId: e, focusedItemId: i, tabbableItemId: A });
|
|
60
|
+
}, []), I = r.useCallback((e) => S(e, F.current), []), T = r.useCallback(
|
|
61
|
+
(e, t) => {
|
|
62
|
+
oe(l.current.onSelect, e, y.current, {
|
|
63
|
+
item: I(t),
|
|
64
|
+
itemId: t
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
[I]
|
|
68
|
+
), E = r.useCallback((e) => !l.current.customCloseItemIds || l.current.customCloseItemIds.indexOf(e) === -1, []), N = r.useCallback(
|
|
69
|
+
(e) => {
|
|
70
|
+
var c, s;
|
|
71
|
+
const t = l.current, n = C.current;
|
|
72
|
+
if (t.openOnClick && n.hoveredItemId !== i) {
|
|
73
|
+
const d = e.target;
|
|
74
|
+
((c = R.current) == null ? void 0 : c.contains(d)) === !1 && (t.id && ((s = d.closest) != null && s.call(d, `[id^="${t.id}_"]`)) || a(i));
|
|
31
75
|
}
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
76
|
+
},
|
|
77
|
+
[a]
|
|
78
|
+
), Y = r.useCallback(
|
|
79
|
+
(e) => {
|
|
80
|
+
const t = C.current, n = l.current, c = D.current;
|
|
81
|
+
if (t.focusedItemId !== i) {
|
|
82
|
+
const s = S(t.focusedItemId, c);
|
|
83
|
+
let d = Z(
|
|
84
|
+
c,
|
|
85
|
+
s.id,
|
|
38
86
|
e.keyCode,
|
|
39
87
|
e.key,
|
|
40
|
-
|
|
41
|
-
|
|
88
|
+
n.vertical,
|
|
89
|
+
k.current.getIsDirectionRightToLeft()
|
|
42
90
|
);
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
91
|
+
const v = S(d, c);
|
|
92
|
+
if (v != null && v.separator && (d = Z(
|
|
93
|
+
c,
|
|
94
|
+
d,
|
|
47
95
|
e.keyCode,
|
|
48
96
|
e.key,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)),
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
target:
|
|
55
|
-
item:
|
|
56
|
-
itemId:
|
|
97
|
+
n.vertical,
|
|
98
|
+
k.current.getIsDirectionRightToLeft()
|
|
99
|
+
)), s.id !== d && (e.preventDefault(), m(d)), (e.keyCode === B.enter || e.keyCode === B.space) && !s.disabled && (p.current.handleItemSelectedViaKeyboard(), T(e, s.id), !e.isDefaultPrevented() && s.items.length === 0 && s.url && window.location.assign(s.url)), e.keyCode === B.esc && O(s.id) && n.onClose) {
|
|
100
|
+
const w = I(s.id);
|
|
101
|
+
n.onClose({
|
|
102
|
+
target: y.current,
|
|
103
|
+
item: w,
|
|
104
|
+
itemId: s.id
|
|
57
105
|
});
|
|
58
106
|
}
|
|
59
107
|
}
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
108
|
+
},
|
|
109
|
+
[m, T, I]
|
|
110
|
+
), $ = r.useCallback(
|
|
111
|
+
(e) => {
|
|
112
|
+
const t = C.current, n = l.current, c = n.openOnClick && !O(e) && t.hoveredItemId !== i;
|
|
113
|
+
(p.current.IsMouseOverEnabled || c) && (b(), g.current = window.setTimeout(() => {
|
|
114
|
+
a(e), g.current = null;
|
|
115
|
+
}, ue(n)));
|
|
116
|
+
},
|
|
117
|
+
[b, a]
|
|
118
|
+
), J = r.useCallback(
|
|
119
|
+
(e) => {
|
|
120
|
+
const t = C.current, n = l.current, c = n.openOnClick && !O(e) && t.hoveredItemId !== i;
|
|
121
|
+
(p.current.IsMouseOverEnabled || c) && E(e) && (b(), h.current = window.setTimeout(() => {
|
|
122
|
+
a(c ? W(e) : i), h.current = null;
|
|
123
|
+
}, ie(n)));
|
|
124
|
+
},
|
|
125
|
+
[b, E, a]
|
|
126
|
+
), Q = r.useCallback(
|
|
127
|
+
(e) => {
|
|
128
|
+
C.current.hoveredItemId === i ? m(e) : L((n) => ({
|
|
72
129
|
focusedItemId: e,
|
|
73
|
-
hoveredItemId:
|
|
74
|
-
tabbableItemId:
|
|
130
|
+
hoveredItemId: n.hoveredItemId,
|
|
131
|
+
tabbableItemId: _(e)
|
|
75
132
|
}));
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
133
|
+
},
|
|
134
|
+
[m]
|
|
135
|
+
), X = r.useCallback(
|
|
136
|
+
(e, t) => {
|
|
137
|
+
const n = D.current, c = S(t, n), s = C.current, d = l.current;
|
|
138
|
+
if (!c.disabled) {
|
|
139
|
+
const v = O(t), w = !c.items || c.items.length === 0;
|
|
140
|
+
v ? (m(t), w ? a(i) : d.openOnClick && s.hoveredItemId !== i && _(s.hoveredItemId) === t ? a(i) : a(t)) : w && (m(t), a(i)), T(e, t), !e.isDefaultPrevented() && c.url && window.location.assign(c.url);
|
|
81
141
|
}
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
142
|
+
},
|
|
143
|
+
[m, a, T]
|
|
144
|
+
), ee = r.useCallback(
|
|
145
|
+
(e, t) => {
|
|
146
|
+
const n = l.current;
|
|
147
|
+
n.onClose && n.onClose({
|
|
148
|
+
target: y.current,
|
|
149
|
+
item: I(e),
|
|
86
150
|
itemId: e,
|
|
87
151
|
popupCloseEvent: t
|
|
88
152
|
});
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
153
|
+
},
|
|
154
|
+
[I]
|
|
155
|
+
), te = r.useCallback(
|
|
156
|
+
(e, t) => {
|
|
157
|
+
var c;
|
|
158
|
+
const n = l.current;
|
|
159
|
+
if (E(e) && m(i), ((c = t.relatedTarget) == null ? void 0 : c.nodeName) === "LI") {
|
|
160
|
+
const s = t.relatedTarget.getAttribute("id");
|
|
161
|
+
if (s != null && s.includes(n.id))
|
|
93
162
|
return;
|
|
94
163
|
}
|
|
95
|
-
if (
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
target:
|
|
99
|
-
item:
|
|
164
|
+
if (O(e) && n.onClose) {
|
|
165
|
+
const s = I(e);
|
|
166
|
+
n.onClose({
|
|
167
|
+
target: y.current,
|
|
168
|
+
item: s,
|
|
100
169
|
itemId: e
|
|
101
170
|
});
|
|
102
171
|
}
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
172
|
+
},
|
|
173
|
+
[E, m, I]
|
|
174
|
+
), V = r.useRef(o.vertical);
|
|
175
|
+
r.useEffect(() => () => {
|
|
176
|
+
b();
|
|
177
|
+
}, [b]), r.useEffect(() => (o.openOnClick && document.addEventListener("mousedown", N), () => {
|
|
178
|
+
document.removeEventListener("mousedown", N);
|
|
179
|
+
}), [o.openOnClick, N]), r.useEffect(() => {
|
|
180
|
+
const e = !!V.current != !!o.vertical, t = k.current.hasDirectionChanged();
|
|
181
|
+
(e || t) && K(), p.current.OpenOnClick = o.openOnClick, V.current = o.vertical;
|
|
182
|
+
});
|
|
183
|
+
const re = () => ce(
|
|
184
|
+
"k-reset",
|
|
185
|
+
"k-header",
|
|
186
|
+
"k-menu",
|
|
187
|
+
{ "k-menu-horizontal": !o.vertical },
|
|
188
|
+
{ "k-menu-vertical": o.vertical },
|
|
189
|
+
o.className
|
|
190
|
+
);
|
|
191
|
+
let M;
|
|
192
|
+
f.hoveredItemId ? M = f.hoveredItemId : f.focusedItemId ? M = W(f.focusedItemId) : M = i;
|
|
193
|
+
const ne = o.animate !== void 0 ? o.animate : !0;
|
|
194
|
+
return /* @__PURE__ */ r.createElement(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
id: o.id,
|
|
198
|
+
onKeyDown: Y,
|
|
199
|
+
style: o.style,
|
|
200
|
+
className: k.current.getIsDirectionRightToLeft() ? "k-rtl" : void 0,
|
|
201
|
+
ref: R
|
|
202
|
+
},
|
|
203
|
+
/* @__PURE__ */ r.createElement(
|
|
204
|
+
le,
|
|
125
205
|
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* @hidden
|
|
163
|
-
*/
|
|
164
|
-
componentDidMount() {
|
|
165
|
-
this.setState({ isFirstRender: !1 }), this.props.openOnClick && document.addEventListener("mousedown", this.handleClickOutside);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* @hidden
|
|
169
|
-
*/
|
|
170
|
-
componentDidUpdate(s) {
|
|
171
|
-
(!!s.vertical != !!this.props.vertical || this.directionHolder.hasDirectionChanged()) && this.reset(), this.mouseOverHandler.OpenOnClick = this.props.openOnClick, s.openOnClick !== this.props.openOnClick && (this.props.openOnClick ? document.addEventListener("mousedown", this.handleClickOutside) : document.removeEventListener("mousedown", this.handleClickOutside));
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* @hidden
|
|
175
|
-
*/
|
|
176
|
-
componentWillUnmount() {
|
|
177
|
-
this.clearItemHoverAndLeaveRequestsIfApplicable(), document.removeEventListener("mousedown", this.handleClickOutside);
|
|
178
|
-
}
|
|
179
|
-
setFocusedItemId(s) {
|
|
180
|
-
this.setState((e) => {
|
|
181
|
-
const t = s === r ? e.tabbableItemId : u(s);
|
|
182
|
-
return { hoveredItemId: s === r || m(e.hoveredItemId) && m(s) ? e.hoveredItemId : r, focusedItemId: s, tabbableItemId: t };
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
setHoveredItemId(s) {
|
|
186
|
-
this.setState((e) => m(s) && m(e.focusedItemId) ? {
|
|
187
|
-
hoveredItemId: s,
|
|
188
|
-
focusedItemId: e.focusedItemId,
|
|
189
|
-
tabbableItemId: e.tabbableItemId
|
|
190
|
-
} : { hoveredItemId: s, focusedItemId: r, tabbableItemId: g });
|
|
191
|
-
}
|
|
192
|
-
getMenuClassName() {
|
|
193
|
-
return C(
|
|
194
|
-
"k-reset",
|
|
195
|
-
"k-header",
|
|
196
|
-
"k-menu",
|
|
197
|
-
{ "k-menu-horizontal": !this.props.vertical },
|
|
198
|
-
{ "k-menu-vertical": this.props.vertical },
|
|
199
|
-
this.props.className
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
clearItemHoverAndLeaveRequestsIfApplicable() {
|
|
203
|
-
this.itemHoverRequest && (clearTimeout(this.itemHoverRequest), this.itemHoverRequest = null), this.itemLeaveRequest && (clearTimeout(this.itemLeaveRequest), this.itemLeaveRequest = null);
|
|
204
|
-
}
|
|
205
|
-
isItemWithDefaultClose(s) {
|
|
206
|
-
return !this.props.customCloseItemIds || this.props.customCloseItemIds.indexOf(s) === -1;
|
|
207
|
-
}
|
|
208
|
-
checkIsDirectionRightToLeft() {
|
|
209
|
-
return !!(this.props.dir !== void 0 ? this.props.dir === "rtl" : this.menuWrapperEl && getComputedStyle(this.menuWrapperEl).direction === "rtl");
|
|
210
|
-
}
|
|
211
|
-
prepareItems() {
|
|
212
|
-
const { items: s, inputItems: e } = O(this.props.items, this.props.children);
|
|
213
|
-
this.items = s, this.inputItems = e;
|
|
214
|
-
}
|
|
215
|
-
dispatchSelectEventIfWired(s, e) {
|
|
216
|
-
k(this.props.onSelect, s, this, { item: this.getInputItem(e), itemId: e });
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
h.propTypes = {
|
|
220
|
-
vertical: o.bool,
|
|
221
|
-
items: o.arrayOf(o.object),
|
|
222
|
-
style: o.object,
|
|
223
|
-
animate: o.oneOfType([
|
|
224
|
-
o.bool,
|
|
225
|
-
o.shape({
|
|
226
|
-
openDuration: o.number,
|
|
227
|
-
closeDuration: o.number
|
|
206
|
+
className: re(),
|
|
207
|
+
"aria-orientation": o.vertical ? "vertical" : void 0,
|
|
208
|
+
items: D.current,
|
|
209
|
+
animate: ne,
|
|
210
|
+
isMenuVertical: o.vertical,
|
|
211
|
+
isDirectionRightToLeft: k.current.getIsDirectionRightToLeft(),
|
|
212
|
+
focusedItemId: f.focusedItemId,
|
|
213
|
+
lastItemIdToBeOpened: M,
|
|
214
|
+
tabbableItemId: f.tabbableItemId,
|
|
215
|
+
itemRender: o.itemRender,
|
|
216
|
+
linkRender: o.linkRender,
|
|
217
|
+
menuGuid: o.id,
|
|
218
|
+
onMouseLeave: J,
|
|
219
|
+
onMouseOver: $,
|
|
220
|
+
onFocus: Q,
|
|
221
|
+
onClick: X,
|
|
222
|
+
onBlur: te,
|
|
223
|
+
onOriginalItemNeeded: I,
|
|
224
|
+
onPopupClose: ee,
|
|
225
|
+
role: o.role
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
);
|
|
229
|
+
});
|
|
230
|
+
j.propTypes = {
|
|
231
|
+
vertical: u.bool,
|
|
232
|
+
items: u.arrayOf(u.object),
|
|
233
|
+
style: u.object,
|
|
234
|
+
animate: u.oneOfType([
|
|
235
|
+
u.bool,
|
|
236
|
+
u.shape({
|
|
237
|
+
openDuration: u.number,
|
|
238
|
+
closeDuration: u.number
|
|
228
239
|
})
|
|
229
240
|
]),
|
|
230
|
-
dir:
|
|
231
|
-
hoverOpenDelay:
|
|
232
|
-
hoverCloseDelay:
|
|
233
|
-
openOnClick:
|
|
234
|
-
itemRender:
|
|
235
|
-
linkRender:
|
|
236
|
-
customCloseItemIds:
|
|
237
|
-
onSelect:
|
|
238
|
-
onClose:
|
|
239
|
-
role:
|
|
240
|
-
}
|
|
241
|
-
|
|
241
|
+
dir: u.string,
|
|
242
|
+
hoverOpenDelay: u.number,
|
|
243
|
+
hoverCloseDelay: u.number,
|
|
244
|
+
openOnClick: u.bool,
|
|
245
|
+
itemRender: u.any,
|
|
246
|
+
linkRender: u.any,
|
|
247
|
+
customCloseItemIds: u.arrayOf(u.string),
|
|
248
|
+
onSelect: u.func,
|
|
249
|
+
onClose: u.func,
|
|
250
|
+
role: u.string
|
|
251
|
+
};
|
|
252
|
+
j.displayName = "Menu";
|
|
242
253
|
export {
|
|
243
|
-
|
|
254
|
+
j as Menu
|
|
244
255
|
};
|