@progress/kendo-react-grid 15.1.0-develop.3 → 15.1.0-develop.4
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.
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
9
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("react"),Q=require("@progress/kendo-react-popup"),d=require("@progress/kendo-react-common"),X=require("@progress/kendo-svg-icons"),w=require("../messages/index.js"),Y=require("@progress/kendo-react-intl"),Z=require("../utils/GridContext.js"),ee=require("./adaptiveContext/GridColumnMenuAdaptiveContext.js"),ne=require("./adaptiveContent/GridAdaptiveColumnMenu.js"),te=require("react-dom");function oe(r){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const l in r)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(r,l);Object.defineProperty(c,l,a.get?a:{enumerable:!0,get:()=>r[l]})}}return c.default=r,Object.freeze(c)}const t=oe(J),re=[".k-columnmenu-item-content",".k-filter-menu-container"].map(r=>d.FOCUSABLE_ELEMENTS.map(c=>`${r} ${c}`)),ce=[[".k-columnmenu-item"],...re],se=r=>{var A;const c=t.useContext(Z.GridContext),[l,a]=t.useState(!1),i=t.useRef(null),E=t.useRef(null),m=t.useRef(null),M=t.useRef(0),x=d.useDocument(i),{columnMenu:v,...b}=r,{column:f,columnMenuIcon:h,navigatable:y}=r,I=Y.useLocalization(),D=f.title||f.field,P=D?`${D} `:"",L="#",N=n=>{const e=d.getActiveElement(document);clearTimeout(M.current),M.current=window.setTimeout(()=>{!c.mobileMode&&e&&n.relatedTarget!==i.current&&E.current&&!E.current.contains(e)&&C()})},W=()=>{clearTimeout(M.current)},z=n=>{n.preventDefault(),l&&r.onCloseMenu&&r.onCloseMenu(),a(!l)},C=()=>{r.onCloseMenu&&r.onCloseMenu(),a(!1),!r.navigatable&&i.current&&i.current.focus()},B=n=>{var e;if(n.key==="Tab"){const o=n.target,u=o&&((e=o.closest(".k-grid"))==null?void 0:e.getElementsByClassName("k-grid-content")[0]);u&&u.scrollWidth>u.clientWidth&&o.scrollIntoView({inline:"center"})}},g=t.useMemo(()=>r.show!==void 0?r.show:l,[r.show,l]);t.useEffect(()=>{var G;if(!g||!i.current)return;const n=i.current,e=n.closest(".k-grid-header-wrap"),o=[];let u=n.closest(".k-grid");for(;u;){const s=(G=u.parentElement)==null?void 0:G.closest(".k-grid-content, .k-virtual-content");if(s)o.push(s),u=s.closest(".k-grid");else break}const p=()=>{a(!1),r.onCloseMenu&&r.onCloseMenu()},R=()=>{p()},T=()=>{const s=n.getBoundingClientRect();for(const j of o){const q=j.getBoundingClientRect();if(s.bottom<q.top||s.top>q.bottom){p();return}}};return e&&e.addEventListener("scroll",R),o.forEach(s=>{s.addEventListener("scroll",T)}),()=>{e&&e.removeEventListener("scroll",R),o.forEach(s=>{s.removeEventListener("scroll",T)})}},[g]);const F=n=>{var e;(e=m.current)==null||e.triggerKeyboardEvent(n)},K=n=>{var e;(e=m.current)==null||e.triggerMouseEvent(n)},_=(n,e,o)=>{o.preventDefault(),o.shiftKey?e.focusPrevious(n):e.focusNext(n)},$=(n,e,o)=>{n&&(o.preventDefault(),n.click())},O=(n,e,o)=>{o.preventDefault(),C()},V=(n,e,o)=>{e.focusElement(n)},H=n=>{!n.isAnchorClicked&&a(!1)},k=t.useCallback((n,e)=>{const o=[];if(!e||typeof e!="object")return!1;if(Array.isArray(e.filters)){for(const u of e.filters)if(k(n,u))return!0}return"field"in e&&typeof e.field=="string"&&o.push(e.field),o.includes(n)},[]),S=t.useCallback((n,e)=>!e||!Array.isArray(e)?!1:e.some(o=>o.field===n),[]),U=t.useMemo(()=>f.field&&(k(f.field,c.filter)||S(f.field,c.group)),[f.field,c.filter,c.group,k,S]);return t.useEffect(()=>(g&&E.current&&(m.current=new d.Navigation({tabIndex:0,root:E,selectors:ce,keyboardEvents:{keydown:{Tab:_,Enter:$,Escape:O}},mouseEvents:{mousedown:V}}),m.current.focusElement(m.current.first,null)),()=>{m.current&&(m.current=null)}),[g]),t.createElement(t.Fragment,null,t.createElement("a",{className:d.classNames("k-grid-header-menu k-grid-column-menu",{"k-active":U}),ref:i,onClick:z,onKeyDown:B,href:L,tabIndex:y?-1:void 0,"aria-label":`${y?"":P}${I.toLanguageString(w.columnMenu,w.messages[w.columnMenu])}`},h?t.createElement(d.IconWrap,{name:h.name,icon:h}):t.createElement(d.IconWrap,{name:"more-vertical",icon:X.moreVerticalIcon})),t.createElement(ee.GridColumnMenuAdaptiveProvider,null,c.mobileMode?t.createElement(t.Fragment,null,te.createPortal(t.createElement(ne.GridAdaptiveColumnMenu,{computedShow:g,ColumnMenu:v,closeMenu:C},v&&t.createElement(v,{...b,onCloseMenu:C})),(A=x())==null?void 0:A.body)):t.createElement(Q.Popup,{anchor:i.current,show:g,popupClass:"k-grid-columnmenu-popup",onMouseDownOutside:H},t.createElement("div",{ref:E,onBlur:N,onFocus:W,onMouseDown:K,onKeyDown:F,className:"k-column-menu k-column-menu-md"},v&&t.createElement(v,{...b,onCloseMenu:C})))))};exports.GridColumnMenuWrapper=se;
|
|
@@ -6,125 +6,161 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import * as
|
|
10
|
-
import { Popup as
|
|
11
|
-
import { useDocument as
|
|
12
|
-
import { moreVerticalIcon as
|
|
13
|
-
import { columnMenu as
|
|
14
|
-
import { useLocalization as
|
|
15
|
-
import { GridContext as
|
|
16
|
-
import { GridColumnMenuAdaptiveProvider as
|
|
17
|
-
import { GridAdaptiveColumnMenu as
|
|
18
|
-
import
|
|
19
|
-
const
|
|
20
|
-
var
|
|
21
|
-
const
|
|
22
|
-
const e =
|
|
23
|
-
clearTimeout(
|
|
24
|
-
!
|
|
9
|
+
import * as t from "react";
|
|
10
|
+
import { Popup as X } from "@progress/kendo-react-popup";
|
|
11
|
+
import { useDocument as Y, Navigation as Z, classNames as O, IconWrap as L, FOCUSABLE_ELEMENTS as j, getActiveElement as ee } from "@progress/kendo-react-common";
|
|
12
|
+
import { moreVerticalIcon as ne } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { columnMenu as x, messages as te } from "../messages/index.mjs";
|
|
14
|
+
import { useLocalization as oe } from "@progress/kendo-react-intl";
|
|
15
|
+
import { GridContext as re } from "../utils/GridContext.mjs";
|
|
16
|
+
import { GridColumnMenuAdaptiveProvider as ce } from "./adaptiveContext/GridColumnMenuAdaptiveContext.mjs";
|
|
17
|
+
import { GridAdaptiveColumnMenu as se } from "./adaptiveContent/GridAdaptiveColumnMenu.mjs";
|
|
18
|
+
import le from "react-dom";
|
|
19
|
+
const ue = [".k-columnmenu-item-content", ".k-filter-menu-container"].map((r) => j.map((l) => `${r} ${l}`)), ie = [[".k-columnmenu-item"], ...ue], Me = (r) => {
|
|
20
|
+
var D;
|
|
21
|
+
const l = t.useContext(re), [h, g] = t.useState(!1), u = t.useRef(null), f = t.useRef(null), i = t.useRef(null), v = t.useRef(0), G = Y(u), { columnMenu: d, ...p } = r, { column: a, columnMenuIcon: C, navigatable: w } = r, N = oe(), y = a.title || a.field, B = y ? `${y} ` : "", F = "#", I = (n) => {
|
|
22
|
+
const e = ee(document);
|
|
23
|
+
clearTimeout(v.current), v.current = window.setTimeout(() => {
|
|
24
|
+
!l.mobileMode && e && n.relatedTarget !== u.current && f.current && !f.current.contains(e) && E();
|
|
25
25
|
});
|
|
26
|
-
},
|
|
27
|
-
clearTimeout(
|
|
28
|
-
},
|
|
29
|
-
n.preventDefault(),
|
|
30
|
-
},
|
|
31
|
-
r.onCloseMenu && r.onCloseMenu(),
|
|
32
|
-
},
|
|
26
|
+
}, K = () => {
|
|
27
|
+
clearTimeout(v.current);
|
|
28
|
+
}, z = (n) => {
|
|
29
|
+
n.preventDefault(), h && r.onCloseMenu && r.onCloseMenu(), g(!h);
|
|
30
|
+
}, E = () => {
|
|
31
|
+
r.onCloseMenu && r.onCloseMenu(), g(!1), !r.navigatable && u.current && u.current.focus();
|
|
32
|
+
}, P = (n) => {
|
|
33
33
|
var e;
|
|
34
34
|
if (n.key === "Tab") {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const o = n.target, s = o && ((e = o.closest(".k-grid")) == null ? void 0 : e.getElementsByClassName("k-grid-content")[0]);
|
|
36
|
+
s && s.scrollWidth > s.clientWidth && o.scrollIntoView({ inline: "center" });
|
|
37
37
|
}
|
|
38
|
-
},
|
|
38
|
+
}, m = t.useMemo(() => r.show !== void 0 ? r.show : h, [r.show, h]);
|
|
39
|
+
t.useEffect(() => {
|
|
40
|
+
var R;
|
|
41
|
+
if (!m || !u.current)
|
|
42
|
+
return;
|
|
43
|
+
const n = u.current, e = n.closest(".k-grid-header-wrap"), o = [];
|
|
44
|
+
let s = n.closest(".k-grid");
|
|
45
|
+
for (; s; ) {
|
|
46
|
+
const c = (R = s.parentElement) == null ? void 0 : R.closest(".k-grid-content, .k-virtual-content");
|
|
47
|
+
if (c)
|
|
48
|
+
o.push(c), s = c.closest(".k-grid");
|
|
49
|
+
else
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
const k = () => {
|
|
53
|
+
g(!1), r.onCloseMenu && r.onCloseMenu();
|
|
54
|
+
}, A = () => {
|
|
55
|
+
k();
|
|
56
|
+
}, S = () => {
|
|
57
|
+
const c = n.getBoundingClientRect();
|
|
58
|
+
for (const Q of o) {
|
|
59
|
+
const T = Q.getBoundingClientRect();
|
|
60
|
+
if (c.bottom < T.top || c.top > T.bottom) {
|
|
61
|
+
k();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return e && e.addEventListener("scroll", A), o.forEach((c) => {
|
|
67
|
+
c.addEventListener("scroll", S);
|
|
68
|
+
}), () => {
|
|
69
|
+
e && e.removeEventListener("scroll", A), o.forEach((c) => {
|
|
70
|
+
c.removeEventListener("scroll", S);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}, [m]);
|
|
74
|
+
const W = (n) => {
|
|
39
75
|
var e;
|
|
40
|
-
(e =
|
|
41
|
-
},
|
|
76
|
+
(e = i.current) == null || e.triggerKeyboardEvent(n);
|
|
77
|
+
}, $ = (n) => {
|
|
42
78
|
var e;
|
|
43
|
-
(e =
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
n && (
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
},
|
|
79
|
+
(e = i.current) == null || e.triggerMouseEvent(n);
|
|
80
|
+
}, V = (n, e, o) => {
|
|
81
|
+
o.preventDefault(), o.shiftKey ? e.focusPrevious(n) : e.focusNext(n);
|
|
82
|
+
}, H = (n, e, o) => {
|
|
83
|
+
n && (o.preventDefault(), n.click());
|
|
84
|
+
}, _ = (n, e, o) => {
|
|
85
|
+
o.preventDefault(), E();
|
|
86
|
+
}, U = (n, e, o) => {
|
|
51
87
|
e.focusElement(n);
|
|
52
|
-
},
|
|
53
|
-
!n.isAnchorClicked &&
|
|
54
|
-
},
|
|
88
|
+
}, q = (n) => {
|
|
89
|
+
!n.isAnchorClicked && g(!1);
|
|
90
|
+
}, M = t.useCallback(
|
|
55
91
|
(n, e) => {
|
|
56
|
-
const
|
|
92
|
+
const o = [];
|
|
57
93
|
if (!e || typeof e != "object")
|
|
58
94
|
return !1;
|
|
59
95
|
if (Array.isArray(e.filters)) {
|
|
60
|
-
for (const
|
|
61
|
-
if (
|
|
96
|
+
for (const s of e.filters)
|
|
97
|
+
if (M(n, s))
|
|
62
98
|
return !0;
|
|
63
99
|
}
|
|
64
|
-
return "field" in e && typeof e.field == "string" &&
|
|
100
|
+
return "field" in e && typeof e.field == "string" && o.push(e.field), o.includes(n);
|
|
65
101
|
},
|
|
66
102
|
[]
|
|
67
|
-
),
|
|
68
|
-
return
|
|
103
|
+
), b = t.useCallback((n, e) => !e || !Array.isArray(e) ? !1 : e.some((o) => o.field === n), []), J = t.useMemo(() => a.field && (M(a.field, l.filter) || b(a.field, l.group)), [a.field, l.filter, l.group, M, b]);
|
|
104
|
+
return t.useEffect(() => (m && f.current && (i.current = new Z({
|
|
69
105
|
tabIndex: 0,
|
|
70
|
-
root:
|
|
71
|
-
selectors:
|
|
106
|
+
root: f,
|
|
107
|
+
selectors: ie,
|
|
72
108
|
keyboardEvents: {
|
|
73
|
-
keydown: { Tab:
|
|
109
|
+
keydown: { Tab: V, Enter: H, Escape: _ }
|
|
74
110
|
},
|
|
75
|
-
mouseEvents: { mousedown:
|
|
76
|
-
}),
|
|
77
|
-
|
|
78
|
-
}), [
|
|
111
|
+
mouseEvents: { mousedown: U }
|
|
112
|
+
}), i.current.focusElement(i.current.first, null)), () => {
|
|
113
|
+
i.current && (i.current = null);
|
|
114
|
+
}), [m]), /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
|
|
79
115
|
"a",
|
|
80
116
|
{
|
|
81
|
-
className:
|
|
82
|
-
"k-active":
|
|
117
|
+
className: O("k-grid-header-menu k-grid-column-menu", {
|
|
118
|
+
"k-active": J
|
|
83
119
|
}),
|
|
84
120
|
ref: u,
|
|
85
|
-
onClick:
|
|
86
|
-
onKeyDown:
|
|
87
|
-
href:
|
|
88
|
-
tabIndex:
|
|
89
|
-
"aria-label": `${
|
|
90
|
-
|
|
91
|
-
|
|
121
|
+
onClick: z,
|
|
122
|
+
onKeyDown: P,
|
|
123
|
+
href: F,
|
|
124
|
+
tabIndex: w ? -1 : void 0,
|
|
125
|
+
"aria-label": `${w ? "" : B}${N.toLanguageString(
|
|
126
|
+
x,
|
|
127
|
+
te[x]
|
|
92
128
|
)}`
|
|
93
129
|
},
|
|
94
|
-
|
|
95
|
-
), /* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
|
|
130
|
+
C ? /* @__PURE__ */ t.createElement(L, { name: C.name, icon: C }) : /* @__PURE__ */ t.createElement(L, { name: "more-vertical", icon: ne })
|
|
131
|
+
), /* @__PURE__ */ t.createElement(ce, null, l.mobileMode ? /* @__PURE__ */ t.createElement(t.Fragment, null, le.createPortal(
|
|
132
|
+
/* @__PURE__ */ t.createElement(
|
|
133
|
+
se,
|
|
98
134
|
{
|
|
99
|
-
computedShow:
|
|
100
|
-
ColumnMenu:
|
|
101
|
-
closeMenu:
|
|
135
|
+
computedShow: m,
|
|
136
|
+
ColumnMenu: d,
|
|
137
|
+
closeMenu: E
|
|
102
138
|
},
|
|
103
|
-
|
|
139
|
+
d && /* @__PURE__ */ t.createElement(d, { ...p, onCloseMenu: E })
|
|
104
140
|
),
|
|
105
|
-
(
|
|
106
|
-
)) : /* @__PURE__ */
|
|
107
|
-
|
|
141
|
+
(D = G()) == null ? void 0 : D.body
|
|
142
|
+
)) : /* @__PURE__ */ t.createElement(
|
|
143
|
+
X,
|
|
108
144
|
{
|
|
109
145
|
anchor: u.current,
|
|
110
|
-
show:
|
|
146
|
+
show: m,
|
|
111
147
|
popupClass: "k-grid-columnmenu-popup",
|
|
112
|
-
onMouseDownOutside:
|
|
148
|
+
onMouseDownOutside: q
|
|
113
149
|
},
|
|
114
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ t.createElement(
|
|
115
151
|
"div",
|
|
116
152
|
{
|
|
117
|
-
ref:
|
|
118
|
-
onBlur:
|
|
119
|
-
onFocus:
|
|
120
|
-
onMouseDown:
|
|
121
|
-
onKeyDown:
|
|
153
|
+
ref: f,
|
|
154
|
+
onBlur: I,
|
|
155
|
+
onFocus: K,
|
|
156
|
+
onMouseDown: $,
|
|
157
|
+
onKeyDown: W,
|
|
122
158
|
className: "k-column-menu k-column-menu-md"
|
|
123
159
|
},
|
|
124
|
-
|
|
160
|
+
d && /* @__PURE__ */ t.createElement(d, { ...p, onCloseMenu: E })
|
|
125
161
|
)
|
|
126
162
|
)));
|
|
127
163
|
};
|
|
128
164
|
export {
|
|
129
|
-
|
|
165
|
+
Me as GridColumnMenuWrapper
|
|
130
166
|
};
|