@progress/kendo-react-layout 16.2.0-develop.2 → 16.2.0-develop.20
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/EULA.pdf +0 -0
- package/EULA.rtf +2730 -0
- package/EULA.txt +292 -0
- package/dist/cdn/js/kendo-react-layout.js +1 -1
- package/expansionpanel/ExpansionPanel.js +1 -1
- package/expansionpanel/ExpansionPanel.mjs +77 -50
- package/expansionpanel/interfaces.d.ts +12 -0
- package/menu/components/Menu.js +1 -1
- package/menu/components/Menu.mjs +107 -100
- package/menu/components/MenuItemInternal.js +1 -1
- package/menu/components/MenuItemInternal.mjs +65 -67
- package/menu/components/MenuItemLink.js +1 -1
- package/menu/components/MenuItemLink.mjs +4 -4
- package/menu/models/MenuItemModel.d.ts +0 -1
- package/menu/utils/itemsIdsUtils.d.ts +0 -4
- package/menu/utils/itemsIdsUtils.js +1 -1
- package/menu/utils/itemsIdsUtils.mjs +27 -31
- package/menu/utils/prepareInputItemsForInternalWork.js +1 -1
- package/menu/utils/prepareInputItemsForInternalWork.mjs +19 -20
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +8 -13
- package/timeline/TimelineCard.js +1 -1
- package/timeline/TimelineCard.mjs +11 -11
|
@@ -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 j=require("react"),t=require("prop-types"),o=require("@progress/kendo-react-common"),B=require("@progress/kendo-react-animation"),C=require("@progress/kendo-svg-icons");function F(n){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const d=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(l,s,d.get?d:{enumerable:!0,get:()=>n[s]})}}return l.default=n,Object.freeze(l)}const e=F(j),q=300,p=e.forwardRef((n,l)=>{const s=e.useRef(null),[d,v]=e.useState(!1),x=o.useId(),b=e.useCallback(()=>({element:s.current}),[]);e.useImperativeHandle(l,b);const{expanded:a=!1,animation:f=!0,disabled:c,title:E,subtitle:I,onAction:r,expandIcon:u,collapseIcon:m,expandSVGIcon:y,collapseSVGIcon:N}=n,D=e.useCallback(i=>{o.dispatchEvent(r,i,b(),{expanded:a})},[r,a]),R=e.useCallback(i=>{(i.keyCode===o.Keys.enter||i.keyCode===o.Keys.space)&&(i.preventDefault(),o.dispatchEvent(r,i,b(),{expanded:a}))},[r,a]),S=e.useCallback(()=>{n.disabled||v(!0)},[n.disabled]),A=e.useCallback(()=>{n.disabled||v(!1)},[n.disabled]),{onFocus:O,onBlur:T}=o.useAsyncFocusBlur({onFocus:S,onBlur:A}),k=typeof f=="number"?f:q,g=f!==!1&&k>0,[w,h]=e.useState(!a);e.useEffect(()=>{a&&h(!1)},[a]);const P=e.useCallback(()=>{h(!0)},[]);return e.createElement("div",{ref:s,className:o.classNames("k-expander",n.className,{"k-expanded":a,"k-focus":d&&!c,"k-disabled":c}),onFocus:O,onBlur:T,style:n.style,id:n.id,dir:o.useRtl(s,n.dir),onKeyDown:c?void 0:R},e.createElement("div",{role:"button","aria-controls":n.ariaControls||x,"aria-expanded":a,"aria-disabled":c||void 0,tabIndex:o.getTabIndex(n.tabIndex,c),className:"k-expander-header",onClick:c?void 0:D},E!==void 0?e.createElement("div",{className:"k-expander-title"},E):void 0,e.createElement("span",{className:"k-spacer"}),I!==void 0?e.createElement("div",{className:"k-expander-sub-title"},I):void 0,e.createElement("span",{className:"k-expander-indicator"},e.createElement(o.IconWrap,{name:a?m?void 0:"chevron-up":u?void 0:"chevron-down",icon:a?!N&&!m?C.chevronUpIcon:N:!y&&!u?C.chevronDownIcon:y,className:o.classNames(a?{[String(m)]:!!m}:{[String(u)]:!!u})}))),e.createElement("div",{id:x,className:o.classNames("k-expander-content-wrapper",{"k-hidden":!a&&(!g||w)})},g?e.createElement(B.Reveal,{transitionEnterDuration:k,transitionExitDuration:k,unmountOnExit:!0,onAfterExited:P},a&&n.children):n.children))});p.propTypes={children:t.node,className:t.string,style:t.object,dir:t.string,id:t.string,tabIndex:t.number,title:t.node,subtitle:t.node,expandIcon:t.string,collapseIcon:t.string,expanded:t.bool,animation:t.oneOfType([t.bool,t.number]),disabled:t.bool,onAction:t.func};p.displayName="KendoReactExpansionPanel";exports.ExpansionPanel=p;
|
|
@@ -7,89 +7,115 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as e from "react";
|
|
9
9
|
import n from "prop-types";
|
|
10
|
-
import { useId as
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
e.
|
|
10
|
+
import { useId as K, dispatchEvent as y, Keys as h, useAsyncFocusBlur as O, useRtl as P, classNames as b, getTabIndex as U, IconWrap as G } from "@progress/kendo-react-common";
|
|
11
|
+
import { Reveal as V } from "@progress/kendo-react-animation";
|
|
12
|
+
import { chevronDownIcon as _, chevronUpIcon as j } from "@progress/kendo-svg-icons";
|
|
13
|
+
const L = 300, C = e.forwardRef((t, g) => {
|
|
14
|
+
const c = e.useRef(null), [A, f] = e.useState(!1), x = K(), r = e.useCallback(() => ({ element: c.current }), []);
|
|
15
|
+
e.useImperativeHandle(g, r);
|
|
15
16
|
const {
|
|
16
|
-
expanded:
|
|
17
|
+
expanded: a = !1,
|
|
18
|
+
animation: u = !0,
|
|
17
19
|
disabled: o,
|
|
18
20
|
title: k,
|
|
19
21
|
subtitle: p,
|
|
20
|
-
onAction:
|
|
21
|
-
expandIcon:
|
|
22
|
-
collapseIcon:
|
|
23
|
-
expandSVGIcon:
|
|
24
|
-
collapseSVGIcon:
|
|
25
|
-
} =
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
expanded:
|
|
22
|
+
onAction: i,
|
|
23
|
+
expandIcon: l,
|
|
24
|
+
collapseIcon: d,
|
|
25
|
+
expandSVGIcon: v,
|
|
26
|
+
collapseSVGIcon: E
|
|
27
|
+
} = t, D = e.useCallback(
|
|
28
|
+
(s) => {
|
|
29
|
+
y(i, s, r(), {
|
|
30
|
+
expanded: a
|
|
29
31
|
});
|
|
30
32
|
},
|
|
31
|
-
[
|
|
32
|
-
),
|
|
33
|
-
(
|
|
34
|
-
(
|
|
35
|
-
expanded:
|
|
33
|
+
[i, a]
|
|
34
|
+
), R = e.useCallback(
|
|
35
|
+
(s) => {
|
|
36
|
+
(s.keyCode === h.enter || s.keyCode === h.space) && (s.preventDefault(), y(i, s, r(), {
|
|
37
|
+
expanded: a
|
|
36
38
|
}));
|
|
37
39
|
},
|
|
38
|
-
[
|
|
39
|
-
),
|
|
40
|
-
|
|
41
|
-
}, [
|
|
42
|
-
|
|
43
|
-
}, [
|
|
40
|
+
[i, a]
|
|
41
|
+
), T = e.useCallback(() => {
|
|
42
|
+
t.disabled || f(!0);
|
|
43
|
+
}, [t.disabled]), w = e.useCallback(() => {
|
|
44
|
+
t.disabled || f(!1);
|
|
45
|
+
}, [t.disabled]), { onFocus: B, onBlur: F } = O({ onFocus: T, onBlur: w }), m = typeof u == "number" ? u : L, I = u !== !1 && m > 0, [S, N] = e.useState(!a);
|
|
46
|
+
e.useEffect(() => {
|
|
47
|
+
a && N(!1);
|
|
48
|
+
}, [a]);
|
|
49
|
+
const H = e.useCallback(() => {
|
|
50
|
+
N(!0);
|
|
51
|
+
}, []);
|
|
44
52
|
return /* @__PURE__ */ e.createElement(
|
|
45
53
|
"div",
|
|
46
54
|
{
|
|
47
|
-
ref:
|
|
48
|
-
className:
|
|
49
|
-
"k-expanded":
|
|
50
|
-
"k-focus":
|
|
55
|
+
ref: c,
|
|
56
|
+
className: b("k-expander", t.className, {
|
|
57
|
+
"k-expanded": a,
|
|
58
|
+
"k-focus": A && !o,
|
|
51
59
|
"k-disabled": o
|
|
52
60
|
}),
|
|
53
61
|
onFocus: B,
|
|
54
|
-
onBlur:
|
|
55
|
-
style:
|
|
56
|
-
id:
|
|
57
|
-
dir:
|
|
58
|
-
onKeyDown: o ? void 0 :
|
|
62
|
+
onBlur: F,
|
|
63
|
+
style: t.style,
|
|
64
|
+
id: t.id,
|
|
65
|
+
dir: P(c, t.dir),
|
|
66
|
+
onKeyDown: o ? void 0 : R
|
|
59
67
|
},
|
|
60
68
|
/* @__PURE__ */ e.createElement(
|
|
61
69
|
"div",
|
|
62
70
|
{
|
|
63
71
|
role: "button",
|
|
64
|
-
"aria-controls":
|
|
65
|
-
"aria-expanded":
|
|
72
|
+
"aria-controls": t.ariaControls || x,
|
|
73
|
+
"aria-expanded": a,
|
|
66
74
|
"aria-disabled": o || void 0,
|
|
67
|
-
tabIndex:
|
|
75
|
+
tabIndex: U(t.tabIndex, o),
|
|
68
76
|
className: "k-expander-header",
|
|
69
|
-
onClick: o ? void 0 :
|
|
77
|
+
onClick: o ? void 0 : D
|
|
70
78
|
},
|
|
71
79
|
k !== void 0 ? /* @__PURE__ */ e.createElement("div", { className: "k-expander-title" }, k) : void 0,
|
|
72
80
|
/* @__PURE__ */ e.createElement("span", { className: "k-spacer" }),
|
|
73
81
|
p !== void 0 ? /* @__PURE__ */ e.createElement("div", { className: "k-expander-sub-title" }, p) : void 0,
|
|
74
82
|
/* @__PURE__ */ e.createElement("span", { className: "k-expander-indicator" }, /* @__PURE__ */ e.createElement(
|
|
75
|
-
|
|
83
|
+
G,
|
|
76
84
|
{
|
|
77
|
-
name:
|
|
78
|
-
icon:
|
|
79
|
-
className:
|
|
80
|
-
|
|
81
|
-
[String(
|
|
85
|
+
name: a ? d ? void 0 : "chevron-up" : l ? void 0 : "chevron-down",
|
|
86
|
+
icon: a ? !E && !d ? j : E : !v && !l ? _ : v,
|
|
87
|
+
className: b(
|
|
88
|
+
a ? {
|
|
89
|
+
[String(d)]: !!d
|
|
82
90
|
} : {
|
|
83
|
-
[String(
|
|
91
|
+
[String(l)]: !!l
|
|
84
92
|
}
|
|
85
93
|
)
|
|
86
94
|
}
|
|
87
95
|
))
|
|
88
96
|
),
|
|
89
|
-
/* @__PURE__ */ e.createElement(
|
|
97
|
+
/* @__PURE__ */ e.createElement(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
id: x,
|
|
101
|
+
className: b("k-expander-content-wrapper", {
|
|
102
|
+
"k-hidden": !a && (!I || S)
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
I ? /* @__PURE__ */ e.createElement(
|
|
106
|
+
V,
|
|
107
|
+
{
|
|
108
|
+
transitionEnterDuration: m,
|
|
109
|
+
transitionExitDuration: m,
|
|
110
|
+
unmountOnExit: !0,
|
|
111
|
+
onAfterExited: H
|
|
112
|
+
},
|
|
113
|
+
a && t.children
|
|
114
|
+
) : t.children
|
|
115
|
+
)
|
|
90
116
|
);
|
|
91
117
|
});
|
|
92
|
-
|
|
118
|
+
C.propTypes = {
|
|
93
119
|
children: n.node,
|
|
94
120
|
className: n.string,
|
|
95
121
|
style: n.object,
|
|
@@ -101,10 +127,11 @@ y.propTypes = {
|
|
|
101
127
|
expandIcon: n.string,
|
|
102
128
|
collapseIcon: n.string,
|
|
103
129
|
expanded: n.bool,
|
|
130
|
+
animation: n.oneOfType([n.bool, n.number]),
|
|
104
131
|
disabled: n.bool,
|
|
105
132
|
onAction: n.func
|
|
106
133
|
};
|
|
107
|
-
|
|
134
|
+
C.displayName = "KendoReactExpansionPanel";
|
|
108
135
|
export {
|
|
109
|
-
|
|
136
|
+
C as ExpansionPanel
|
|
110
137
|
};
|
|
@@ -82,6 +82,18 @@ export interface ExpansionPanelProps {
|
|
|
82
82
|
* @default false
|
|
83
83
|
*/
|
|
84
84
|
expanded?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Enables the expand and collapse animation of the ExpansionPanel.
|
|
87
|
+
* Set a number to specify the animation duration in milliseconds.
|
|
88
|
+
*
|
|
89
|
+
* @default true
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```jsx
|
|
93
|
+
* <ExpansionPanel animation={200} />
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
animation?: boolean | number;
|
|
85
97
|
/**
|
|
86
98
|
* Sets the `disabled` state of the ExpansionPanel.
|
|
87
99
|
*
|
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 ee=require("react"),i=require("prop-types"),k=require("@progress/kendo-react-common"),t=require("../utils/itemsIdsUtils.js"),te=require("../utils/prepareInputItemsForInternalWork.js"),B=require("../utils/getNewItemIdUponKeyboardNavigation.js"),K=require("../utils/hoverDelay.js"),re=require("./MenuItemInternal.js"),ne=require("../utils/DirectionHolder.js"),oe=require("../utils/MouseOverHandler.js");function ce(o){const E=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(E,I,b.get?b:{enumerable:!0,get:()=>o[I]})}}return E.default=o,Object.freeze(E)}const n=ce(ee),U={focusedItemId:t.EMPTY_ID,hoveredItemId:t.EMPTY_ID,tabbableItemId:t.ZERO_LEVEL_ZERO_ITEM_ID},S=n.forwardRef((o,E)=>{const I=n.useRef(null),b=n.useRef(null),M=n.useRef(null),D=n.useRef(new ne.DirectionHolder),h=n.useRef([]),N=n.useRef([]),l=n.useRef(o);l.current=o;const[v,P]=n.useState({...U}),C=n.useRef(v);C.current=v;const w=n.useRef(()=>{}),T=n.useRef(new oe.MouseOverHandler(o.openOnClick,()=>w.current())),{items:j,inputItems:F}=te.prepareInputItemsForInternalWork(o.items,o.children);h.current=j,N.current=F,D.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),M.current&&(clearTimeout(M.current),M.current=null)},[]),H=n.useCallback(()=>{g(),P({...U})},[g]);w.current=H;const O=n.useRef({get element(){return I.current},reset:()=>w.current()});n.useImperativeHandle(E,()=>O.current,[]);const m=n.useCallback(e=>{P(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=>{P(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),[]),_=n.useCallback((e,r)=>{k.dispatchEvent(l.current.onSelect,e,O.current,{item:f(r),itemId:r})},[f]),L=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=h.current;if(r.focusedItemId!==t.EMPTY_ID){const u=t.getItemById(r.focusedItemId,s);let d=B.getNewItemIdUponKeyboardNavigation(s,u.id,e.keyCode,e.key,c.vertical,D.current.getIsDirectionRightToLeft());const y=t.getItemById(d,s);if(y!=null&&y.separator&&(d=B.getNewItemIdUponKeyboardNavigation(s,d,e.keyCode,e.key,c.vertical,D.current.getIsDirectionRightToLeft())),u.id!==d&&(e.preventDefault(),m(d)),(e.keyCode===k.Keys.enter||e.keyCode===k.Keys.space)&&!u.disabled&&(T.current.handleItemSelectedViaKeyboard(),_(e,u.id),!e.isDefaultPrevented()&&u.items.length===0&&u.url)){const R=k.sanitizeUrl(u.url);R&&window.location.assign(R)}if(e.keyCode===k.Keys.esc&&t.isIdZeroLevel(u.id)&&c.onClose){const R=f(u.id);c.onClose({target:O.current,item:R,itemId:u.id})}}},[m,_,f]),z=n.useCallback(e=>{const r=C.current,c=l.current,s=c.openOnClick&&!t.isIdZeroLevel(e)&&r.hoveredItemId!==t.EMPTY_ID;(T.current.IsMouseOverEnabled||s)&&(g(),b.current=window.setTimeout(()=>{a(e),b.current=null},K.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;(T.current.IsMouseOverEnabled||s)&&L(e)&&(g(),M.current=window.setTimeout(()=>{a(s?t.getDirectParentId(e):t.EMPTY_ID),M.current=null},K.getHoverCloseDelay(c)))},[g,L,a]),G=n.useCallback(e=>{C.current.hoveredItemId===t.EMPTY_ID?m(e):P(c=>({focusedItemId:e,hoveredItemId:c.hoveredItemId,tabbableItemId:t.getRootParentId(e)}))},[m]),$=n.useCallback((e,r)=>{const c=h.current,s=t.getItemById(r,c),u=C.current,d=l.current;if(!s.disabled){const y=t.isIdZeroLevel(r),R=!s.items||s.items.length===0;if(y?(m(r),R||d.openOnClick&&u.hoveredItemId!==t.EMPTY_ID&&t.getRootParentId(u.hoveredItemId)===r?a(t.EMPTY_ID):a(r)):R&&(m(r),a(t.EMPTY_ID)),_(e,r),!e.isDefaultPrevented()&&s.url){const Z=k.sanitizeUrl(s.url);Z&&window.location.assign(Z)}}},[m,a,_]),x=n.useCallback((e,r)=>{const c=l.current;c.onClose&&c.onClose({target:O.current,item:f(e),itemId:e,popupCloseEvent:r})},[f]),J=n.useCallback((e,r)=>{var s;const c=l.current;if(L(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:O.current,item:u,itemId:e})}},[L,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=D.current.hasDirectionChanged();(e||r)&&H(),T.current.OpenOnClick=o.openOnClick,q.current=o.vertical});const Q=()=>k.classNames("k-reset","k-header","k-menu",{"k-menu-horizontal":!o.vertical},{"k-menu-vertical":o.vertical},o.className);let p;v.hoveredItemId?p=v.hoveredItemId:v.focusedItemId?p=t.getDirectParentId(v.focusedItemId):p=t.EMPTY_ID;const X=o.animate!==void 0?o.animate:!0;return n.createElement("div",{id:o.id,onKeyDown:W,style:o.style,className:D.current.getIsDirectionRightToLeft()?"k-rtl":void 0,ref:I},n.createElement(re.MenuItemInternalsList,{className:Q(),"aria-orientation":o.vertical?"vertical":void 0,items:h.current,animate:X,isMenuVertical:o.vertical,isDirectionRightToLeft:D.current.getIsDirectionRightToLeft(),focusedItemId:v.focusedItemId,lastItemIdToBeOpened:p,tabbableItemId:v.tabbableItemId,itemRender:o.itemRender,linkRender:o.linkRender,menuGuid:o.id,onMouseLeave:A,onMouseOver:z,onFocus:G,onClick:$,onBlur:J,onOriginalItemNeeded:f,onPopupClose:x,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
|
@@ -7,180 +7,187 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as r from "react";
|
|
9
9
|
import u from "prop-types";
|
|
10
|
-
import { dispatchEvent as
|
|
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
|
|
10
|
+
import { dispatchEvent as se, Keys as B, sanitizeUrl as W, classNames as ue } from "@progress/kendo-react-common";
|
|
11
|
+
import { ZERO_LEVEL_ZERO_ITEM_ID as j, EMPTY_ID as i, getRootParentId as _, isIdEmptyOrZeroLevel as P, getItemById as S, isIdZeroLevel as D, getDirectParentId as Z } from "../utils/itemsIdsUtils.mjs";
|
|
12
|
+
import { prepareInputItemsForInternalWork as ie } from "../utils/prepareInputItemsForInternalWork.mjs";
|
|
13
|
+
import { getNewItemIdUponKeyboardNavigation as q } from "../utils/getNewItemIdUponKeyboardNavigation.mjs";
|
|
14
|
+
import { getHoverOpenDelay as le, getHoverCloseDelay as ae } from "../utils/hoverDelay.mjs";
|
|
15
|
+
import { MenuItemInternalsList as de } from "./MenuItemInternal.mjs";
|
|
16
|
+
import { DirectionHolder as me } from "../utils/DirectionHolder.mjs";
|
|
17
|
+
import { MouseOverHandler as fe } from "../utils/MouseOverHandler.mjs";
|
|
18
|
+
const A = {
|
|
19
19
|
focusedItemId: i,
|
|
20
20
|
hoveredItemId: i,
|
|
21
|
-
tabbableItemId:
|
|
22
|
-
},
|
|
23
|
-
const
|
|
21
|
+
tabbableItemId: j
|
|
22
|
+
}, z = r.forwardRef((o, x) => {
|
|
23
|
+
const g = r.useRef(null), h = r.useRef(null), y = r.useRef(null), v = r.useRef(new me()), L = r.useRef([]), F = r.useRef([]), l = r.useRef(o);
|
|
24
24
|
l.current = o;
|
|
25
|
-
const [
|
|
26
|
-
C.current =
|
|
25
|
+
const [I, p] = r.useState({ ...A }), C = r.useRef(I);
|
|
26
|
+
C.current = I;
|
|
27
27
|
const H = r.useRef(() => {
|
|
28
|
-
}),
|
|
28
|
+
}), T = r.useRef(new fe(o.openOnClick, () => H.current())), { items: G, inputItems: Y } = ie(
|
|
29
29
|
o.items,
|
|
30
30
|
o.children
|
|
31
31
|
);
|
|
32
|
-
|
|
33
|
-
function
|
|
34
|
-
return !!(l.current.dir !== void 0 ? l.current.dir === "rtl" :
|
|
32
|
+
L.current = G, F.current = Y, v.current.setIsDirectionRightToLeft($());
|
|
33
|
+
function $() {
|
|
34
|
+
return !!(l.current.dir !== void 0 ? l.current.dir === "rtl" : g.current && getComputedStyle(g.current).direction === "rtl");
|
|
35
35
|
}
|
|
36
36
|
const b = r.useCallback(() => {
|
|
37
|
-
|
|
37
|
+
h.current && (clearTimeout(h.current), h.current = null), y.current && (clearTimeout(y.current), y.current = null);
|
|
38
38
|
}, []), K = r.useCallback(() => {
|
|
39
|
-
b(),
|
|
39
|
+
b(), p({ ...A });
|
|
40
40
|
}, [b]);
|
|
41
41
|
H.current = K;
|
|
42
|
-
const
|
|
42
|
+
const O = r.useRef({
|
|
43
43
|
get element() {
|
|
44
|
-
return
|
|
44
|
+
return g.current;
|
|
45
45
|
},
|
|
46
46
|
reset: () => H.current()
|
|
47
47
|
});
|
|
48
|
-
r.useImperativeHandle(x, () =>
|
|
48
|
+
r.useImperativeHandle(x, () => O.current, []);
|
|
49
49
|
const m = r.useCallback((e) => {
|
|
50
|
-
|
|
50
|
+
p((t) => {
|
|
51
51
|
const n = e === i ? t.tabbableItemId : _(e);
|
|
52
52
|
return { hoveredItemId: e === i || P(t.hoveredItemId) && P(e) ? t.hoveredItemId : i, focusedItemId: e, tabbableItemId: n };
|
|
53
53
|
});
|
|
54
54
|
}, []), a = r.useCallback((e) => {
|
|
55
|
-
|
|
55
|
+
p((t) => P(e) && P(t.focusedItemId) ? {
|
|
56
56
|
hoveredItemId: e,
|
|
57
57
|
focusedItemId: t.focusedItemId,
|
|
58
58
|
tabbableItemId: t.tabbableItemId
|
|
59
|
-
} : { hoveredItemId: e, focusedItemId: i, tabbableItemId:
|
|
60
|
-
}, []),
|
|
59
|
+
} : { hoveredItemId: e, focusedItemId: i, tabbableItemId: j });
|
|
60
|
+
}, []), f = r.useCallback((e) => S(e, F.current), []), E = r.useCallback(
|
|
61
61
|
(e, t) => {
|
|
62
|
-
|
|
63
|
-
item:
|
|
62
|
+
se(l.current.onSelect, e, O.current, {
|
|
63
|
+
item: f(t),
|
|
64
64
|
itemId: t
|
|
65
65
|
});
|
|
66
66
|
},
|
|
67
|
-
[
|
|
68
|
-
),
|
|
67
|
+
[f]
|
|
68
|
+
), M = r.useCallback((e) => !l.current.customCloseItemIds || l.current.customCloseItemIds.indexOf(e) === -1, []), N = r.useCallback(
|
|
69
69
|
(e) => {
|
|
70
70
|
var c, s;
|
|
71
71
|
const t = l.current, n = C.current;
|
|
72
72
|
if (t.openOnClick && n.hoveredItemId !== i) {
|
|
73
73
|
const d = e.target;
|
|
74
|
-
((c =
|
|
74
|
+
((c = g.current) == null ? void 0 : c.contains(d)) === !1 && (t.id && ((s = d.closest) != null && s.call(d, `[id^="${t.id}_"]`)) || a(i));
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
[a]
|
|
78
|
-
),
|
|
78
|
+
), J = r.useCallback(
|
|
79
79
|
(e) => {
|
|
80
|
-
const t = C.current, n = l.current, c =
|
|
80
|
+
const t = C.current, n = l.current, c = L.current;
|
|
81
81
|
if (t.focusedItemId !== i) {
|
|
82
82
|
const s = S(t.focusedItemId, c);
|
|
83
|
-
let d =
|
|
83
|
+
let d = q(
|
|
84
84
|
c,
|
|
85
85
|
s.id,
|
|
86
86
|
e.keyCode,
|
|
87
87
|
e.key,
|
|
88
88
|
n.vertical,
|
|
89
|
-
|
|
89
|
+
v.current.getIsDirectionRightToLeft()
|
|
90
90
|
);
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
91
|
+
const R = S(d, c);
|
|
92
|
+
if (R != null && R.separator && (d = q(
|
|
93
93
|
c,
|
|
94
94
|
d,
|
|
95
95
|
e.keyCode,
|
|
96
96
|
e.key,
|
|
97
97
|
n.vertical,
|
|
98
|
-
|
|
99
|
-
)), s.id !== d && (e.preventDefault(), m(d)), (e.keyCode === B.enter || e.keyCode === B.space) && !s.disabled && (
|
|
100
|
-
const
|
|
98
|
+
v.current.getIsDirectionRightToLeft()
|
|
99
|
+
)), s.id !== d && (e.preventDefault(), m(d)), (e.keyCode === B.enter || e.keyCode === B.space) && !s.disabled && (T.current.handleItemSelectedViaKeyboard(), E(e, s.id), !e.isDefaultPrevented() && s.items.length === 0 && s.url)) {
|
|
100
|
+
const k = W(s.url);
|
|
101
|
+
k && window.location.assign(k);
|
|
102
|
+
}
|
|
103
|
+
if (e.keyCode === B.esc && D(s.id) && n.onClose) {
|
|
104
|
+
const k = f(s.id);
|
|
101
105
|
n.onClose({
|
|
102
|
-
target:
|
|
103
|
-
item:
|
|
106
|
+
target: O.current,
|
|
107
|
+
item: k,
|
|
104
108
|
itemId: s.id
|
|
105
109
|
});
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
},
|
|
109
|
-
[m,
|
|
110
|
-
),
|
|
113
|
+
[m, E, f]
|
|
114
|
+
), Q = r.useCallback(
|
|
111
115
|
(e) => {
|
|
112
|
-
const t = C.current, n = l.current, c = n.openOnClick && !
|
|
113
|
-
(
|
|
114
|
-
a(e),
|
|
115
|
-
},
|
|
116
|
+
const t = C.current, n = l.current, c = n.openOnClick && !D(e) && t.hoveredItemId !== i;
|
|
117
|
+
(T.current.IsMouseOverEnabled || c) && (b(), h.current = window.setTimeout(() => {
|
|
118
|
+
a(e), h.current = null;
|
|
119
|
+
}, le(n)));
|
|
116
120
|
},
|
|
117
121
|
[b, a]
|
|
118
|
-
),
|
|
122
|
+
), X = r.useCallback(
|
|
119
123
|
(e) => {
|
|
120
|
-
const t = C.current, n = l.current, c = n.openOnClick && !
|
|
121
|
-
(
|
|
122
|
-
a(c ?
|
|
123
|
-
},
|
|
124
|
+
const t = C.current, n = l.current, c = n.openOnClick && !D(e) && t.hoveredItemId !== i;
|
|
125
|
+
(T.current.IsMouseOverEnabled || c) && M(e) && (b(), y.current = window.setTimeout(() => {
|
|
126
|
+
a(c ? Z(e) : i), y.current = null;
|
|
127
|
+
}, ae(n)));
|
|
124
128
|
},
|
|
125
|
-
[b,
|
|
126
|
-
),
|
|
129
|
+
[b, M, a]
|
|
130
|
+
), ee = r.useCallback(
|
|
127
131
|
(e) => {
|
|
128
|
-
C.current.hoveredItemId === i ? m(e) :
|
|
132
|
+
C.current.hoveredItemId === i ? m(e) : p((n) => ({
|
|
129
133
|
focusedItemId: e,
|
|
130
134
|
hoveredItemId: n.hoveredItemId,
|
|
131
135
|
tabbableItemId: _(e)
|
|
132
136
|
}));
|
|
133
137
|
},
|
|
134
138
|
[m]
|
|
135
|
-
),
|
|
139
|
+
), te = r.useCallback(
|
|
136
140
|
(e, t) => {
|
|
137
|
-
const n =
|
|
141
|
+
const n = L.current, c = S(t, n), s = C.current, d = l.current;
|
|
138
142
|
if (!c.disabled) {
|
|
139
|
-
const
|
|
140
|
-
|
|
143
|
+
const R = D(t), k = !c.items || c.items.length === 0;
|
|
144
|
+
if (R ? (m(t), k ? a(i) : d.openOnClick && s.hoveredItemId !== i && _(s.hoveredItemId) === t ? a(i) : a(t)) : k && (m(t), a(i)), E(e, t), !e.isDefaultPrevented() && c.url) {
|
|
145
|
+
const V = W(c.url);
|
|
146
|
+
V && window.location.assign(V);
|
|
147
|
+
}
|
|
141
148
|
}
|
|
142
149
|
},
|
|
143
|
-
[m, a,
|
|
144
|
-
),
|
|
150
|
+
[m, a, E]
|
|
151
|
+
), re = r.useCallback(
|
|
145
152
|
(e, t) => {
|
|
146
153
|
const n = l.current;
|
|
147
154
|
n.onClose && n.onClose({
|
|
148
|
-
target:
|
|
149
|
-
item:
|
|
155
|
+
target: O.current,
|
|
156
|
+
item: f(e),
|
|
150
157
|
itemId: e,
|
|
151
158
|
popupCloseEvent: t
|
|
152
159
|
});
|
|
153
160
|
},
|
|
154
|
-
[
|
|
155
|
-
),
|
|
161
|
+
[f]
|
|
162
|
+
), ne = r.useCallback(
|
|
156
163
|
(e, t) => {
|
|
157
164
|
var c;
|
|
158
165
|
const n = l.current;
|
|
159
|
-
if (
|
|
166
|
+
if (M(e) && m(i), ((c = t.relatedTarget) == null ? void 0 : c.nodeName) === "LI") {
|
|
160
167
|
const s = t.relatedTarget.getAttribute("id");
|
|
161
168
|
if (s != null && s.includes(n.id))
|
|
162
169
|
return;
|
|
163
170
|
}
|
|
164
|
-
if (
|
|
165
|
-
const s =
|
|
171
|
+
if (D(e) && n.onClose) {
|
|
172
|
+
const s = f(e);
|
|
166
173
|
n.onClose({
|
|
167
|
-
target:
|
|
174
|
+
target: O.current,
|
|
168
175
|
item: s,
|
|
169
176
|
itemId: e
|
|
170
177
|
});
|
|
171
178
|
}
|
|
172
179
|
},
|
|
173
|
-
[
|
|
174
|
-
),
|
|
180
|
+
[M, m, f]
|
|
181
|
+
), U = r.useRef(o.vertical);
|
|
175
182
|
r.useEffect(() => () => {
|
|
176
183
|
b();
|
|
177
184
|
}, [b]), r.useEffect(() => (o.openOnClick && document.addEventListener("mousedown", N), () => {
|
|
178
185
|
document.removeEventListener("mousedown", N);
|
|
179
186
|
}), [o.openOnClick, N]), r.useEffect(() => {
|
|
180
|
-
const e = !!
|
|
181
|
-
(e || t) && K(),
|
|
187
|
+
const e = !!U.current != !!o.vertical, t = v.current.hasDirectionChanged();
|
|
188
|
+
(e || t) && K(), T.current.OpenOnClick = o.openOnClick, U.current = o.vertical;
|
|
182
189
|
});
|
|
183
|
-
const
|
|
190
|
+
const oe = () => ue(
|
|
184
191
|
"k-reset",
|
|
185
192
|
"k-header",
|
|
186
193
|
"k-menu",
|
|
@@ -188,46 +195,46 @@ const q = {
|
|
|
188
195
|
{ "k-menu-vertical": o.vertical },
|
|
189
196
|
o.className
|
|
190
197
|
);
|
|
191
|
-
let
|
|
192
|
-
|
|
193
|
-
const
|
|
198
|
+
let w;
|
|
199
|
+
I.hoveredItemId ? w = I.hoveredItemId : I.focusedItemId ? w = Z(I.focusedItemId) : w = i;
|
|
200
|
+
const ce = o.animate !== void 0 ? o.animate : !0;
|
|
194
201
|
return /* @__PURE__ */ r.createElement(
|
|
195
202
|
"div",
|
|
196
203
|
{
|
|
197
204
|
id: o.id,
|
|
198
|
-
onKeyDown:
|
|
205
|
+
onKeyDown: J,
|
|
199
206
|
style: o.style,
|
|
200
|
-
className:
|
|
201
|
-
ref:
|
|
207
|
+
className: v.current.getIsDirectionRightToLeft() ? "k-rtl" : void 0,
|
|
208
|
+
ref: g
|
|
202
209
|
},
|
|
203
210
|
/* @__PURE__ */ r.createElement(
|
|
204
|
-
|
|
211
|
+
de,
|
|
205
212
|
{
|
|
206
|
-
className:
|
|
213
|
+
className: oe(),
|
|
207
214
|
"aria-orientation": o.vertical ? "vertical" : void 0,
|
|
208
|
-
items:
|
|
209
|
-
animate:
|
|
215
|
+
items: L.current,
|
|
216
|
+
animate: ce,
|
|
210
217
|
isMenuVertical: o.vertical,
|
|
211
|
-
isDirectionRightToLeft:
|
|
212
|
-
focusedItemId:
|
|
213
|
-
lastItemIdToBeOpened:
|
|
214
|
-
tabbableItemId:
|
|
218
|
+
isDirectionRightToLeft: v.current.getIsDirectionRightToLeft(),
|
|
219
|
+
focusedItemId: I.focusedItemId,
|
|
220
|
+
lastItemIdToBeOpened: w,
|
|
221
|
+
tabbableItemId: I.tabbableItemId,
|
|
215
222
|
itemRender: o.itemRender,
|
|
216
223
|
linkRender: o.linkRender,
|
|
217
224
|
menuGuid: o.id,
|
|
218
|
-
onMouseLeave:
|
|
219
|
-
onMouseOver:
|
|
220
|
-
onFocus:
|
|
221
|
-
onClick:
|
|
222
|
-
onBlur:
|
|
223
|
-
onOriginalItemNeeded:
|
|
224
|
-
onPopupClose:
|
|
225
|
+
onMouseLeave: X,
|
|
226
|
+
onMouseOver: Q,
|
|
227
|
+
onFocus: ee,
|
|
228
|
+
onClick: te,
|
|
229
|
+
onBlur: ne,
|
|
230
|
+
onOriginalItemNeeded: f,
|
|
231
|
+
onPopupClose: re,
|
|
225
232
|
role: o.role
|
|
226
233
|
}
|
|
227
234
|
)
|
|
228
235
|
);
|
|
229
236
|
});
|
|
230
|
-
|
|
237
|
+
z.propTypes = {
|
|
231
238
|
vertical: u.bool,
|
|
232
239
|
items: u.arrayOf(u.object),
|
|
233
240
|
style: u.object,
|
|
@@ -249,7 +256,7 @@ j.propTypes = {
|
|
|
249
256
|
onClose: u.func,
|
|
250
257
|
role: u.string
|
|
251
258
|
};
|
|
252
|
-
|
|
259
|
+
z.displayName = "Menu";
|
|
253
260
|
export {
|
|
254
|
-
|
|
261
|
+
z as Menu
|
|
255
262
|
};
|