@progress/kendo-react-dropdowns 8.3.0-develop.6 → 8.3.0-develop.8
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/ComboBox/ComboBox.js +1 -1
- package/ComboBox/ComboBox.mjs +30 -30
- package/DropDownList/DropDownList.js +1 -1
- package/DropDownList/DropDownList.mjs +55 -55
- package/DropDownTree/DropDownTree.js +1 -1
- package/DropDownTree/DropDownTree.mjs +1 -1
- package/MultiSelect/MultiSelect.js +1 -1
- package/MultiSelect/MultiSelect.mjs +1 -1
- package/MultiSelectTree/MultiSelectTree.js +1 -1
- package/MultiSelectTree/MultiSelectTree.mjs +11 -11
- package/dist/cdn/js/kendo-react-dropdowns.js +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +9 -9
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as u from "react";
|
|
10
10
|
import C from "prop-types";
|
|
11
|
-
import { classNames as x, uDropDownList as D, Keys as I, validatePackage as ee, svgIconPropType as te, canUseDOM as B, getTabIndex as se, IconWrap as ie, uDropDownsActionSheet as
|
|
11
|
+
import { classNames as x, uDropDownList as D, Keys as I, validatePackage as ee, svgIconPropType as te, canUseDOM as B, getTabIndex as se, IconWrap as ie, uDropDownsActionSheet as K, createPropsContext as ae, withIdHOC as oe, withPropsContext as ne, withUnstyledHOC as re } from "@progress/kendo-react-common";
|
|
12
12
|
import { FloatingLabel as le } from "@progress/kendo-react-labels";
|
|
13
13
|
import { caretAltDownIcon as de, xIcon as pe } from "@progress/kendo-svg-icons";
|
|
14
14
|
import he from "../common/ListContainer.mjs";
|
|
@@ -23,8 +23,8 @@ import { Button as G } from "@progress/kendo-react-buttons";
|
|
|
23
23
|
import { provideLocalizationService as Ie } from "@progress/kendo-react-intl";
|
|
24
24
|
import { dropDownListArrowBtnAriaLabel as Y, messages as ye } from "../messages/index.mjs";
|
|
25
25
|
import { MOBILE_SMALL_DEVISE as $, MOBILE_MEDIUM_DEVISE as j } from "../common/constants.mjs";
|
|
26
|
-
import { ActionSheet as
|
|
27
|
-
const Ce = "Please select a value from the list!",
|
|
26
|
+
import { ActionSheet as we, ActionSheetHeader as Se, ActionSheetContent as xe } from "@progress/kendo-react-layout";
|
|
27
|
+
const Ce = "Please select a value from the list!", N = class N extends u.Component {
|
|
28
28
|
constructor(s) {
|
|
29
29
|
super(s), this.state = {}, this._element = null, this.base = new R(this), this.searchState = { word: "", last: "" }, this._select = null, this._skipFocusEvent = !1, this._filterInput = null, this._navigated = !1, this._lastKeypressIsFilter = !1, this.itemHeight = 0, this.focus = () => {
|
|
30
30
|
this.base.wrapper && this.base.wrapper.focus({ preventScroll: !0 });
|
|
@@ -70,8 +70,8 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
70
70
|
},
|
|
71
71
|
itemsCount: [i.length]
|
|
72
72
|
};
|
|
73
|
-
let { group:
|
|
74
|
-
return
|
|
73
|
+
let { group: w } = this.state;
|
|
74
|
+
return w === void 0 && n !== void 0 && (w = T(i[0], n)), /* @__PURE__ */ u.createElement(he, { ...r }, this.renderListFilter(), e && /* @__PURE__ */ u.createElement("div", { className: x(D.listHeader({ c: p })) }, e), /* @__PURE__ */ u.createElement(
|
|
75
75
|
"div",
|
|
76
76
|
{
|
|
77
77
|
className: x(
|
|
@@ -83,7 +83,7 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
83
83
|
)
|
|
84
84
|
},
|
|
85
85
|
this.renderDefaultItem(),
|
|
86
|
-
!b &&
|
|
86
|
+
!b && w && i.length !== 0 && /* @__PURE__ */ u.createElement(W, { group: w, groupMode: "modern", render: l }),
|
|
87
87
|
this.renderList()
|
|
88
88
|
), t && /* @__PURE__ */ u.createElement("div", { className: x(D.listFooter({ c: p })) }, t));
|
|
89
89
|
}, this.renderList = () => {
|
|
@@ -171,14 +171,14 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
171
171
|
clearTimeout(this._typingTimeout), this.props.filterable || (this._typingTimeout = window.setTimeout(() => this.searchState.word = "", this.props.delay), this.selectNext(e));
|
|
172
172
|
}, this.selectNext = (e) => {
|
|
173
173
|
const { dataItemKey: t } = this.props, o = E(this.props);
|
|
174
|
-
let h = o.map((F,
|
|
174
|
+
let h = o.map((F, L) => ({ item: F, itemIndex: L }));
|
|
175
175
|
const n = this.searchState.word, l = this.searchState.last, b = fe(n, l);
|
|
176
176
|
let d = h.length, i = Math.max(0, o.findIndex((F) => k(F, this.value, t))), c;
|
|
177
177
|
this.props.defaultItem && (c = { item: this.props.defaultItem, itemIndex: -1 }, d += 1, i += 1), i += b ? 1 : 0, h = ge(h, i, c);
|
|
178
178
|
let a, f, g, p = 0;
|
|
179
|
-
const { textField: r, ignoreCase:
|
|
179
|
+
const { textField: r, ignoreCase: w } = this.props;
|
|
180
180
|
for (; p < d; p++)
|
|
181
|
-
if (a = T(h[p].item, r), f = b && q(a, l,
|
|
181
|
+
if (a = T(h[p].item, r), f = b && q(a, l, w), g = q(a, n, w), f || g) {
|
|
182
182
|
p = h[p].itemIndex;
|
|
183
183
|
break;
|
|
184
184
|
}
|
|
@@ -198,23 +198,23 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
198
198
|
groupField: d = "",
|
|
199
199
|
textField: i,
|
|
200
200
|
skipDisabledItems: c = !0
|
|
201
|
-
} = this.props, a = E(this.props), f = this.value, g = a.findIndex((y) => k(y, f, b)), p = this.props.opened !== void 0 ? this.props.opened : this.state.opened, r = e.keyCode,
|
|
202
|
-
if (
|
|
203
|
-
if (
|
|
204
|
-
r === I.home ? l.skip !== 0 ? (this.base.triggerOnPageChange(
|
|
201
|
+
} = this.props, a = E(this.props), f = this.value, g = a.findIndex((y) => k(y, f, b)), p = this.props.opened !== void 0 ? this.props.opened : this.state.opened, r = e.keyCode, w = r === I.home || r === I.end, F = r === I.up || r === I.down, L = !p && (e.altKey && r === I.down || r === I.enter || r === I.space), _ = p && (e.altKey && r === I.up || r === I.esc), z = n && (r === I.left || r === I.right), P = F || z && !t || w, S = this.base.initState();
|
|
202
|
+
if (S.syntheticEvent = e, !o) {
|
|
203
|
+
if (w && this.base.vs.enabled)
|
|
204
|
+
r === I.home ? l.skip !== 0 ? (this.base.triggerOnPageChange(S, 0, l.pageSize), this._navigated = !0) : this.triggerOnChange(a[0], S) : l.skip < l.total - l.pageSize ? (this.base.triggerOnPageChange(S, l.total - l.pageSize, l.pageSize), this._navigated = !0) : this.triggerOnChange(a[a.length - 1], S);
|
|
205
205
|
else if (p && r === I.pageUp)
|
|
206
206
|
e.preventDefault(), this.base.scrollPopupByPageSize(-1);
|
|
207
207
|
else if (p && r === I.pageDown)
|
|
208
208
|
e.preventDefault(), this.base.scrollPopupByPageSize(1);
|
|
209
209
|
else if (p && r === I.enter) {
|
|
210
210
|
const y = this.getFocusedIndex();
|
|
211
|
-
this.haveFocusedItemAndDataNotEmpty(a, y) ? (this.triggerOnChange(null,
|
|
212
|
-
} else if (
|
|
213
|
-
_ && this.resetValueIfDisabledItem(), this.base.togglePopup(
|
|
214
|
-
else if (
|
|
211
|
+
this.haveFocusedItemAndDataNotEmpty(a, y) ? (this.triggerOnChange(null, S), this.applyState(S)) : this.handleItemSelect(y, S), this.base.togglePopup(S), e.preventDefault();
|
|
212
|
+
} else if (L || _)
|
|
213
|
+
_ && this.resetValueIfDisabledItem(), this.base.togglePopup(S), e.preventDefault();
|
|
214
|
+
else if (P) {
|
|
215
215
|
if (this._lastKeypressIsFilter = !1, d !== "" && i)
|
|
216
216
|
if (!c && p)
|
|
217
|
-
this.onNavigate(
|
|
217
|
+
this.onNavigate(S, r);
|
|
218
218
|
else {
|
|
219
219
|
let y;
|
|
220
220
|
if (r === I.down || r === I.right) {
|
|
@@ -231,17 +231,17 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
231
231
|
let m = v.pop();
|
|
232
232
|
for (; m && m.disabled; )
|
|
233
233
|
m = v.pop();
|
|
234
|
-
y = m && a.findIndex((
|
|
234
|
+
y = m && a.findIndex((M) => M[i] === m[i]);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
if (y !== void 0) {
|
|
238
238
|
const v = y - g;
|
|
239
|
-
this.onNavigate(
|
|
239
|
+
this.onNavigate(S, r, v);
|
|
240
240
|
} else
|
|
241
|
-
y === void 0 && a.findIndex((v) => v[i] === f[i]) === a.length - 1 && this.onNavigate(
|
|
241
|
+
y === void 0 && a.findIndex((v) => v[i] === f[i]) === a.length - 1 && this.onNavigate(S, r);
|
|
242
242
|
}
|
|
243
|
-
else if (!c && p ||
|
|
244
|
-
this.onNavigate(
|
|
243
|
+
else if (!c && p || w)
|
|
244
|
+
this.onNavigate(S, r);
|
|
245
245
|
else if (i) {
|
|
246
246
|
let y;
|
|
247
247
|
if (r === I.down || r === I.right) {
|
|
@@ -258,19 +258,19 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
258
258
|
let m = v.pop();
|
|
259
259
|
for (; m && m.disabled; )
|
|
260
260
|
m = v.pop();
|
|
261
|
-
y = m && a.findIndex((
|
|
261
|
+
y = m && a.findIndex((M) => M[i] === m[i]);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
if (y !== void 0) {
|
|
265
265
|
const v = y - g;
|
|
266
|
-
this.onNavigate(
|
|
266
|
+
this.onNavigate(S, r, v);
|
|
267
267
|
} else
|
|
268
|
-
y === void 0 && a.findIndex((v) => v[i] === f[i]) === a.length - 1 && this.onNavigate(
|
|
268
|
+
y === void 0 && a.findIndex((v) => v[i] === f[i]) === a.length - 1 && this.onNavigate(S, r);
|
|
269
269
|
} else
|
|
270
|
-
this.onNavigate(
|
|
270
|
+
this.onNavigate(S, r);
|
|
271
271
|
e.preventDefault();
|
|
272
272
|
}
|
|
273
|
-
this.applyState(
|
|
273
|
+
this.applyState(S);
|
|
274
274
|
}
|
|
275
275
|
}, this.handleItemClick = (e, t) => {
|
|
276
276
|
this.base.handleItemClick(e, t), this._valueDuringOnChange = void 0;
|
|
@@ -367,13 +367,13 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
get validityStyles() {
|
|
370
|
-
return this.props.validityStyles !== void 0 ? this.props.validityStyles :
|
|
370
|
+
return this.props.validityStyles !== void 0 ? this.props.validityStyles : N.defaultProps.validityStyles;
|
|
371
371
|
}
|
|
372
372
|
/**
|
|
373
373
|
* @hidden
|
|
374
374
|
*/
|
|
375
375
|
get required() {
|
|
376
|
-
return this.props.required !== void 0 ? this.props.required :
|
|
376
|
+
return this.props.required !== void 0 ? this.props.required : N.defaultProps.required;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
379
|
* @hidden
|
|
@@ -385,8 +385,8 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
385
385
|
this.base.vs.calcScrollElementHeight(), this.base.vs.reset();
|
|
386
386
|
else {
|
|
387
387
|
const f = this.value, g = s.value !== void 0 ? s.value : e.value;
|
|
388
|
-
let p = l.findIndex((
|
|
389
|
-
h !== "" && f && n && (p = (a = this.base.getGroupedDataModernMode(l, h)) == null ? void 0 : a.map((
|
|
388
|
+
let p = l.findIndex((w) => k(w, f, t));
|
|
389
|
+
h !== "" && f && n && (p = (a = this.base.getGroupedDataModernMode(l, h)) == null ? void 0 : a.map((w) => w[n]).indexOf(f[n]));
|
|
390
390
|
const r = !k(g, f, t);
|
|
391
391
|
c && o ? this.base.scrollToVirtualItem(o, p) : c && !o ? (this.onPopupOpened(), l && l.length !== 0 && this.base.resetGroupStickyHeader(l[0][h], this), this.base.scrollToItem(p)) : d && i && f && r && !this._navigated ? this.base.scrollToItem(p, this.base.vs.enabled) : d && i && this._navigated && (this._navigated && o && o.skip === 0 ? this.base.vs.reset() : this._navigated && o && o.skip === o.total - o.pageSize && this.base.vs.scrollToEnd());
|
|
392
392
|
}
|
|
@@ -408,17 +408,17 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
408
408
|
* @hidden
|
|
409
409
|
*/
|
|
410
410
|
render() {
|
|
411
|
-
const s = Ie(this).toLanguageString(Y, ye[Y]), { style: e, className: t, label: o, dir: h, virtual: n, size: l, rounded: b, fillMode: d, adaptive: i, unstyled: c } = this.props, { windowWidth: a = 0 } = this.state, f = this.props.opened !== void 0 ? this.props.opened : this.state.opened, g = this.value, p = T(g, this.props.textField), r = !this.validityStyles || this.validity.valid,
|
|
412
|
-
F.enabled = n !== void 0, n !== void 0 && (
|
|
411
|
+
const s = Ie(this).toLanguageString(Y, ye[Y]), { style: e, className: t, label: o, dir: h, virtual: n, size: l, rounded: b, fillMode: d, adaptive: i, unstyled: c } = this.props, { windowWidth: a = 0 } = this.state, f = this.props.opened !== void 0 ? this.props.opened : this.state.opened, g = this.value, p = T(g, this.props.textField), r = !this.validityStyles || this.validity.valid, w = this.base, F = w.vs, L = a <= j && i, _ = c && c.uDropDownList;
|
|
412
|
+
F.enabled = n !== void 0, n !== void 0 && (w.vs.skip = n.skip, w.vs.total = n.total, w.vs.pageSize = n.pageSize);
|
|
413
413
|
const {
|
|
414
414
|
dataItemKey: z,
|
|
415
|
-
disabled:
|
|
416
|
-
tabIndex:
|
|
415
|
+
disabled: P,
|
|
416
|
+
tabIndex: S,
|
|
417
417
|
loading: y,
|
|
418
418
|
iconClassName: v,
|
|
419
419
|
svgIcon: m,
|
|
420
|
-
valueRender:
|
|
421
|
-
} = this.props, J = E(this.props), { focused: Q } = this.state, X = J.findIndex((
|
|
420
|
+
valueRender: M
|
|
421
|
+
} = this.props, J = E(this.props), { focused: Q } = this.state, X = J.findIndex((O) => k(O, g, z)), H = /* @__PURE__ */ u.createElement("span", { id: this._inputId, className: x(D.input({ c: _ })) }, p && /* @__PURE__ */ u.createElement("span", { className: x(D.inputText({ c: _ })) }, p)), Z = M !== void 0 ? M.call(void 0, H, g) : H, V = /* @__PURE__ */ u.createElement(u.Fragment, null, /* @__PURE__ */ u.createElement(
|
|
422
422
|
"span",
|
|
423
423
|
{
|
|
424
424
|
ref: this.componentRef,
|
|
@@ -429,7 +429,7 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
429
429
|
rounded: b,
|
|
430
430
|
fillMode: d,
|
|
431
431
|
focused: Q,
|
|
432
|
-
disabled:
|
|
432
|
+
disabled: P,
|
|
433
433
|
invalid: !r,
|
|
434
434
|
loading: y,
|
|
435
435
|
required: this.required
|
|
@@ -438,19 +438,19 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
438
438
|
),
|
|
439
439
|
style: o ? { ...e, width: void 0 } : e,
|
|
440
440
|
dir: h,
|
|
441
|
-
onMouseDown: f ? (
|
|
442
|
-
|
|
441
|
+
onMouseDown: f ? (O) => {
|
|
442
|
+
O.target.nodeName !== "INPUT" && (this.focusElement(this.base.wrapper), O.preventDefault());
|
|
443
443
|
} : void 0,
|
|
444
444
|
onFocus: this.handleFocus,
|
|
445
445
|
onBlur: this.handleBlur,
|
|
446
|
-
tabIndex: se(
|
|
446
|
+
tabIndex: se(S, P),
|
|
447
447
|
accessKey: this.props.accessKey,
|
|
448
448
|
onKeyDown: this.handleKeyDown,
|
|
449
449
|
onKeyPress: this.handleKeyPress,
|
|
450
|
-
onClick:
|
|
450
|
+
onClick: P ? void 0 : this.handleWrapperClick,
|
|
451
451
|
role: "combobox",
|
|
452
452
|
"aria-required": this.required,
|
|
453
|
-
"aria-disabled":
|
|
453
|
+
"aria-disabled": P || void 0,
|
|
454
454
|
"aria-haspopup": "listbox",
|
|
455
455
|
"aria-expanded": f || !1,
|
|
456
456
|
"aria-owns": this._listboxId,
|
|
@@ -479,12 +479,12 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
479
479
|
themeColor: "base",
|
|
480
480
|
icon: v ? void 0 : "caret-alt-down",
|
|
481
481
|
svgIcon: m || de,
|
|
482
|
-
onMouseDown: (
|
|
482
|
+
onMouseDown: (O) => this.state.focused && O.preventDefault()
|
|
483
483
|
}
|
|
484
484
|
),
|
|
485
485
|
this.dummySelect(g),
|
|
486
|
-
!
|
|
487
|
-
),
|
|
486
|
+
!L && this.renderListContainer()
|
|
487
|
+
), L && this.renderAdaptiveListContainer());
|
|
488
488
|
return o ? /* @__PURE__ */ u.createElement(
|
|
489
489
|
le,
|
|
490
490
|
{
|
|
@@ -493,9 +493,9 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
493
493
|
editorValid: r,
|
|
494
494
|
editorDisabled: this.props.disabled,
|
|
495
495
|
style: { width: e ? e.width : void 0 },
|
|
496
|
-
children:
|
|
496
|
+
children: V
|
|
497
497
|
}
|
|
498
|
-
) :
|
|
498
|
+
) : V;
|
|
499
499
|
}
|
|
500
500
|
/**
|
|
501
501
|
* @hidden
|
|
@@ -522,13 +522,13 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
522
522
|
animation: !0,
|
|
523
523
|
onClose: (r) => this.handleWrapperClick(r),
|
|
524
524
|
animationStyles: s <= $ ? { top: 0, width: "100%", height: "100%" } : void 0,
|
|
525
|
-
className: x(
|
|
525
|
+
className: x(K.wrapper({
|
|
526
526
|
c: a,
|
|
527
527
|
isFullScreen: s <= $
|
|
528
528
|
}))
|
|
529
529
|
};
|
|
530
530
|
let { group: p } = this.state;
|
|
531
|
-
return p === void 0 && n !== void 0 && (p = T(i[0], n)), /* @__PURE__ */ u.createElement(
|
|
531
|
+
return p === void 0 && n !== void 0 && (p = T(i[0], n)), /* @__PURE__ */ u.createElement(we, { ...g }, /* @__PURE__ */ u.createElement(Se, { className: x(K.header({ c: f })) }, /* @__PURE__ */ u.createElement("div", { className: x(K.titleBar({ c: f })) }, /* @__PURE__ */ u.createElement("div", { className: x(K.title({ c: f })) }, /* @__PURE__ */ u.createElement("div", null, h)), /* @__PURE__ */ u.createElement("div", { className: x(K.actions({ c: f })) }, /* @__PURE__ */ u.createElement(
|
|
532
532
|
G,
|
|
533
533
|
{
|
|
534
534
|
tabIndex: 0,
|
|
@@ -540,7 +540,7 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
540
540
|
icon: "x",
|
|
541
541
|
svgIcon: pe
|
|
542
542
|
}
|
|
543
|
-
))), /* @__PURE__ */ u.createElement("div", { className: x(
|
|
543
|
+
))), /* @__PURE__ */ u.createElement("div", { className: x(K.titleBarGroup({ c: f })) }, this.renderListFilter())), /* @__PURE__ */ u.createElement(xe, { overflowHidden: !0 }, e && /* @__PURE__ */ u.createElement("div", { className: x(D.listHeader({ c: a })) }, e), /* @__PURE__ */ u.createElement(
|
|
544
544
|
"div",
|
|
545
545
|
{
|
|
546
546
|
className: x(
|
|
@@ -588,7 +588,7 @@ const Ce = "Please select a value from the list!", L = class L extends u.Compone
|
|
|
588
588
|
return e !== void 0 && e !== -1 && s && s.length > 0 && s[e].disabled;
|
|
589
589
|
}
|
|
590
590
|
};
|
|
591
|
-
|
|
591
|
+
N.displayName = "DropDownList", N.propTypes = {
|
|
592
592
|
delay: C.number,
|
|
593
593
|
ignoreCase: C.bool,
|
|
594
594
|
iconClassName: C.string,
|
|
@@ -609,7 +609,7 @@ L.displayName = "DropDownList", L.propTypes = {
|
|
|
609
609
|
skipDisabledItems: C.bool,
|
|
610
610
|
renderListFilterWrapper: C.bool,
|
|
611
611
|
...R.propTypes
|
|
612
|
-
},
|
|
612
|
+
}, N.defaultProps = {
|
|
613
613
|
delay: 500,
|
|
614
614
|
tabIndex: 0,
|
|
615
615
|
ignoreCase: !0,
|
|
@@ -620,7 +620,7 @@ L.displayName = "DropDownList", L.propTypes = {
|
|
|
620
620
|
fillMode: "solid",
|
|
621
621
|
groupMode: "modern"
|
|
622
622
|
};
|
|
623
|
-
let A =
|
|
623
|
+
let A = N;
|
|
624
624
|
const De = ae(), Ee = oe(ne(
|
|
625
625
|
De,
|
|
626
626
|
re(A)
|
|
@@ -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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("react"),n=require("prop-types"),r=require("@progress/kendo-react-common"),Je=require("@progress/kendo-react-popup"),Qe=require("@progress/kendo-react-intl"),we=require("@progress/kendo-react-treeview"),Xe=require("../package-metadata.js"),U=require("../common/utils.js"),Ye=require("./useDropdownWidth.js"),Ze=require("./ListNoData.js"),h=require("../messages/index.js"),et=require("@progress/kendo-react-labels"),xe=require("../common/ListFilter.js"),tt=require("@progress/kendo-react-buttons"),De=require("@progress/kendo-svg-icons"),nt=require("../common/AdaptiveMode.js"),at=require("@progress/kendo-react-layout"),ot=require("../common/constants.js");function rt(u){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(f,s,o.get?o:{enumerable:!0,get:()=>u[s]})}}return f.default=u,Object.freeze(f)}const t=rt(Ge),{sizeMap:st,roundedMap:it}=r.kendoThemeMaps,lt="Please select a value from the list!",ct=u=>t.createElement("span",{className:"k-input-value-text"},u.children),Ie=u=>u.split("_").map(f=>parseInt(f,10)),ut=(u,f)=>{const{validationMessage:s,valid:o,required:G}=u;return{customError:s!==void 0,valid:!!(o!==void 0?o:!G||f),valueMissing:!f}},oe={selectField:"selected",subItemsField:"items",popupSettings:{animate:!0,width:"200px",height:"200px"},data:[],required:!1,style:{},validityStyles:!0,size:"medium",rounded:"medium",fillMode:"solid"},Fe=r.createPropsContext(),re=t.forwardRef((u,f)=>{r.validatePackage(Xe.packageMetadata);const s=r.usePropsContext(Fe,u),o={...oe,...s},G=r.useId(),se=o.id||G,{data:M,dataItemKey:T,popupSettings:E={},style:N,opened:d,disabled:S,onOpen:P=r.noop,onClose:v=r.noop,placeholder:J,label:O,name:Se,selectField:H,subItemsField:V,validationMessage:_,valid:Re,required:Q,validityStyles:qe}=o,X=r.getTabIndex(o.tabIndex,S),i=t.useRef(null),g=t.useRef(null),R=t.useRef(null),Y=t.useRef(null),j=t.useRef(null),k=t.useRef(null),$=t.useRef(!1),[ie,Ke]=t.useState(void 0),w=o.value!==void 0,b=w?o.value:ie!==void 0?ie:o.defaultValue,L=U.isPresent(b),Z=L?U.getItemValue(b,o.textField):"",ee=ut({validationMessage:_,valid:Re,required:Q},L),Me=t.useCallback(()=>g.current&&g.current.focus(),[]);t.useImperativeHandle(i,()=>({props:o,element:g.current,focus:Me})),t.useImperativeHandle(f,()=>i.current);const x=r.useRtl(g,o.dir),Te={width:Ye.useDropdownWidth(g,oe,{...oe.popupSettings,...E},N),...x!==void 0?{direction:x}:{}},[Ne,le]=t.useState(!1),l=d!==void 0?d:Ne,[p,te]=t.useState(!1),[ne,Pe]=t.useState(),D=!!(ne&&ne<=ot.MOBILE_MEDIUM_DEVISE&&o.adaptive),[ce,Oe]=t.useState(""),Ve=t.useCallback(()=>{j.current&&j.current.setCustomValidity&&j.current.setCustomValidity(ee.valid?"":_===void 0?lt:_)},[_,ee]);t.useEffect(Ve),t.useEffect(()=>{const e=r.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver($e.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{document!=null&&document.body&&e&&e.disconnect()}},[]);const ue=t.useCallback(e=>{if(!l){if(P){const a={...e};P.call(void 0,a)}d===void 0&&le(!0)}},[l,d,P]),I=t.useCallback(e=>{if(l){if(v){const a={...e};v.call(void 0,a)}d===void 0&&(le(!1),D&&setTimeout(()=>{var a;y((a=Y.current)==null?void 0:a.element)},300))}},[l,d,v,D]),Le=t.useCallback(e=>{if(!e.isDefaultPrevented()&&i.current){te(!0);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};(l?I:ue)(a)}},[l,d,P,v]),q=t.useCallback(e=>{$.current=!0,e(),window.setTimeout(()=>$.current=!1,0)},[]),Be=t.useCallback(e=>{var F,ke;const{keyCode:a,altKey:c}=e,m=k.current&&k.current.element;if(!i.current||e.isDefaultPrevented()&&((F=R.current)==null?void 0:F.element)===e.target)return;const K={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(l)if(a===r.Keys.esc||c&&a===r.Keys.up)e.preventDefault(),I(K);else if(m&&m.querySelector(".k-focus")&&(a===r.Keys.up||a===r.Keys.down||a===r.Keys.left||a===r.Keys.right||a===r.Keys.home||a===r.Keys.end)){if(a===r.Keys.up&&((ke=R.current)!=null&&ke.element)){const A=Array.from(m.querySelectorAll(".k-treeview-item")),Ce=[...A].reverse().find(z=>!!(z&&z.querySelector(".k-focus")));if(Ce&&A.indexOf(Ce)===0)return q(()=>{var z;y((z=R.current)==null?void 0:z.element)})}q(r.noop)}else a===r.Keys.down&&q(()=>{var A;y(((A=R.current)==null?void 0:A.element)||m)});else c&&a===r.Keys.down?(e.preventDefault(),ue(K)):l||a===r.Keys.esc&&me(e)},[l,d,P,v]),de=t.useCallback(e=>{const{keyCode:a,altKey:c}=e;c||a!==r.Keys.up&&a!==r.Keys.down||(e.preventDefault(),q(a===r.Keys.up?()=>{y(g.current)}:()=>{y(k.current&&k.current.element)}))},[]),y=t.useCallback(e=>{e&&q(()=>e.focus())},[]),We=t.useCallback(()=>{var e;!p&&l&&!d?I({target:i.current}):s.filterable?y((e=R.current)==null?void 0:e.element):y(k.current&&k.current.element)},[v,s.filterable,p,d,l]),Ae=t.useCallback(()=>{p&&y(g.current)},[p]),ze=t.useCallback(e=>{if(!p&&!$.current&&(te(!0),s.onFocus&&i.current)){const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};s.onFocus.call(void 0,a)}},[p,s.onFocus]),He=t.useCallback(e=>{if(p&&!$.current&&i.current){te(!1);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(s.onBlur){const c={...a};s.onBlur.call(void 0,c)}D||I(a)}},[p,s.onBlur,l,d,v]),_e=t.useCallback(()=>{p&&q(r.noop),D&&setTimeout(()=>{var e;y((e=Y.current)==null?void 0:e.element)},300)},[p,D]),pe=t.useCallback((e,a,c)=>{if(s.onChange){const m={value:a,level:c?Ie(c):[],...e};s.onChange.call(void 0,m)}w||Ke(a)},[s.onChange,w]),fe=t.useCallback(e=>{if(U.areSame(e.item,b,T)||!i.current)return;const{item:a,itemHierarchicalIndex:c,nativeEvent:m,syntheticEvent:K}=e,F={syntheticEvent:K,nativeEvent:m,target:i.current};pe(F,a,c),I(F)},[w,b,s.onChange,T,l,d,v]),me=t.useCallback(e=>{if(!i.current)return;const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};pe(a,null),I(a),e.preventDefault()},[w,s.onChange,l,d,v]),ve=t.useCallback(e=>{if(e.syntheticEvent.stopPropagation(),s.onExpandChange&&i.current){const{item:a,itemHierarchicalIndex:c,nativeEvent:m,syntheticEvent:K}=e,F={level:Ie(c),item:a,nativeEvent:m,syntheticEvent:K,target:i.current};s.onExpandChange.call(void 0,F)}},[s.onExpandChange]),ge=t.useCallback(e=>{if(s.onFilterChange&&i.current){const c={filter:{field:s.textField,operator:"contains",value:e.target.value},syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,target:i.current};s.onFilterChange.call(void 0,c),s.filter===void 0&&Oe(e.target.value)}},[s.onFilterChange,s.filter,s.textField]),je=()=>{const e=o.filterable?t.createElement(xe,{value:o.filter===void 0?ce:o.filter,ref:Y,onChange:ge,onKeyDown:de,size:C,rounded:B,fillMode:W}):null,a={adaptiveTitle:o.adaptiveTitle,expand:l,onClose:c=>I(c),windowWidth:ne,mobileFilter:e};return t.createElement(nt.AdaptiveMode,{...a},t.createElement(at.ActionSheetContent,{className:"!k-overflow-hidden"},t.createElement("div",{className:"k-list-container"},t.createElement("div",{className:"k-list k-list-lg"},M.length>0?t.createElement(we.TreeView,{ref:k,tabIndex:X,data:be,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:fe,onExpandChange:ve,size:C,item:o.item,dir:x,animate:E.animate}):t.createElement(ye,null,ae.toLanguageString(h.nodata,h.messages[h.nodata]))))))},$e=t.useCallback(e=>{for(const a of e)Pe(a.target.clientWidth)},[]),be=t.useMemo(()=>w||!L?M:r.mapTree(M,V,e=>r.extendDataItem(e,V,{[H]:U.areSame(e,b,T)})),[M,b,w,L,H,V]),ye=o.listNoData||Ze.ListNoData,Ue=o.valueHolder||ct,ae=Qe.useLocalization(),he=!qe||ee.valid,{size:C,rounded:B,fillMode:W}=o,Ee=t.createElement(t.Fragment,null,t.createElement("span",{className:r.classNames("k-dropdowntree k-picker",o.className,{[`k-picker-${st[C]||C}`]:C,[`k-rounded-${it[B]||B}`]:B,[`k-picker-${W}`]:W,"k-focus":p,"k-invalid":!he,"k-loading":o.loading,"k-required":Q,"k-disabled":o.disabled}),tabIndex:X,accessKey:o.accessKey,id:se,style:O?{...N,width:void 0}:N,dir:x,ref:g,onKeyDown:S?void 0:Be,onMouseDown:_e,onClick:S?void 0:Le,onFocus:ze,onBlur:He,role:"combobox","aria-haspopup":"tree","aria-expanded":l,"aria-disabled":S,"aria-label":O,"aria-labelledby":o.ariaLabelledBy,"aria-describedby":o.ariaDescribedBy,"aria-required":Q},t.createElement("span",{className:"k-input-inner"},(Z||J)&&t.createElement(Ue,{item:b},Z||J)),o.loading&&t.createElement(r.IconWrap,{className:"k-input-loading-icon",name:"loading"}),L&&!S&&t.createElement("span",{onClick:me,className:"k-clear-value",title:ae.toLanguageString(h.clear,h.messages[h.clear]),role:"button",tabIndex:-1,onMouseDown:e=>e.preventDefault()},t.createElement(r.IconWrap,{name:"x",icon:De.xIcon})),t.createElement(tt.Button,{tabIndex:-1,type:"button","aria-label":"select",className:"k-input-button",size:C,fillMode:W,themeColor:"base",rounded:null,icon:"caret-alt-down",svgIcon:De.caretAltDownIcon}),t.createElement("select",{name:Se,ref:j,tabIndex:-1,"aria-hidden":!0,title:O,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},t.createElement("option",{value:o.valueMap?o.valueMap.call(void 0,b):b})),!D&&t.createElement(Je.Popup,{...E,className:r.classNames(E.className,{"k-rtl":x==="rtl"}),popupClass:r.classNames(E.popupClass,"k-dropdowntree-popup k-list-container"),style:Te,anchor:E.anchor||g.current,show:l,onOpen:We,onClose:Ae},o.filterable&&t.createElement(xe,{value:o.filter===void 0?ce:o.filter,ref:R,onChange:ge,onKeyDown:de,size:C,rounded:B,fillMode:W,renderListFilterWrapper:!0,renderPrefixSeparator:!0}),M.length>0?t.createElement(we.TreeView,{style:{height:E.height},ref:k,tabIndex:X,data:be,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:fe,onExpandChange:ve,size:C,item:o.item,dir:x,animate:E.animate}):t.createElement(ye,null,ae.toLanguageString(h.nodata,h.messages[h.nodata])))),D&&je());return O?t.createElement(et.FloatingLabel,{label:O,editorValue:Z,editorPlaceholder:J,editorValid:he,editorDisabled:S,editorId:se,style:{width:N?N.width:void 0},children:Ee,dir:x}):Ee}),dt={opened:n.bool,disabled:n.bool,dir:n.string,tabIndex:n.number,accessKey:n.string,data:n.array,value:n.any,valueMap:n.func,placeholder:n.string,dataItemKey:n.string.isRequired,textField:n.string.isRequired,selectField:n.string,expandField:n.string,subItemsField:n.string,className:n.string,style:n.object,label:n.string,validationMessage:n.string,validityStyles:n.bool,valid:n.bool,required:n.bool,name:n.string,id:n.string,ariaLabelledBy:n.string,ariaDescribedBy:n.string,filterable:n.bool,filter:n.string,loading:n.bool,popupSettings:n.shape({animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),popupClass:n.string,className:n.string,appendTo:n.any,width:n.oneOfType([n.string,n.number]),height:n.oneOfType([n.string,n.number])}),onOpen:n.func,onClose:n.func,onFocus:n.func,onBlur:n.func,onChange:n.func,onFilterChange:n.func,onExpandChange:n.func,item:n.func,valueHolder:n.func,listNoData:n.func,adaptiveTitle:n.string,adaptive:n.bool};re.displayName="KendoReactDropDownTree";re.propTypes=dt;exports.DropDownTree=re;exports.DropDownTreePropsContext=Fe;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("react"),n=require("prop-types"),r=require("@progress/kendo-react-common"),Je=require("@progress/kendo-react-popup"),Qe=require("@progress/kendo-react-intl"),we=require("@progress/kendo-react-treeview"),Xe=require("../package-metadata.js"),U=require("../common/utils.js"),Ye=require("./useDropdownWidth.js"),Ze=require("./ListNoData.js"),h=require("../messages/index.js"),et=require("@progress/kendo-react-labels"),xe=require("../common/ListFilter.js"),tt=require("@progress/kendo-react-buttons"),De=require("@progress/kendo-svg-icons"),nt=require("../common/AdaptiveMode.js"),at=require("@progress/kendo-react-layout"),ot=require("../common/constants.js");function rt(u){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const s in u)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(u,s);Object.defineProperty(f,s,o.get?o:{enumerable:!0,get:()=>u[s]})}}return f.default=u,Object.freeze(f)}const t=rt(Ge),{sizeMap:st,roundedMap:it}=r.kendoThemeMaps,lt="Please select a value from the list!",ct=u=>t.createElement("span",{className:"k-input-value-text"},u.children),Ie=u=>u.split("_").map(f=>parseInt(f,10)),ut=(u,f)=>{const{validationMessage:s,valid:o,required:G}=u;return{customError:s!==void 0,valid:!!(o!==void 0?o:!G||f),valueMissing:!f}},oe={selectField:"selected",subItemsField:"items",popupSettings:{animate:!0,width:"200px",height:"200px"},data:[],required:!1,style:{},validityStyles:!0,size:"medium",rounded:"medium",fillMode:"solid"},Fe=r.createPropsContext(),re=t.forwardRef((u,f)=>{r.validatePackage(Xe.packageMetadata);const s=r.usePropsContext(Fe,u),o={...oe,...s},G=r.useId(),se=o.id||G,{data:M,dataItemKey:T,popupSettings:E={},style:P,opened:d,disabled:S,onOpen:N=r.noop,onClose:v=r.noop,placeholder:J,label:O,name:Se,selectField:H,subItemsField:V,validationMessage:_,valid:Re,required:Q,validityStyles:qe}=o,X=r.getTabIndex(o.tabIndex,S),i=t.useRef(null),g=t.useRef(null),R=t.useRef(null),Y=t.useRef(null),j=t.useRef(null),k=t.useRef(null),$=t.useRef(!1),[ie,Ke]=t.useState(void 0),w=o.value!==void 0,b=w?o.value:ie!==void 0?ie:o.defaultValue,L=U.isPresent(b),Z=L?U.getItemValue(b,o.textField):"",ee=ut({validationMessage:_,valid:Re,required:Q},L),Me=t.useCallback(()=>g.current&&g.current.focus(),[]);t.useImperativeHandle(i,()=>({props:o,element:g.current,focus:Me})),t.useImperativeHandle(f,()=>i.current);const x=r.useRtl(g,o.dir),Te={width:Ye.useDropdownWidth(g,oe,{...oe.popupSettings,...E},P),...x!==void 0?{direction:x}:{}},[Pe,le]=t.useState(!1),l=d!==void 0?d:Pe,[p,te]=t.useState(!1),[ne,Ne]=t.useState(),D=!!(ne&&ne<=ot.MOBILE_MEDIUM_DEVISE&&o.adaptive),[ce,Oe]=t.useState(""),Ve=t.useCallback(()=>{j.current&&j.current.setCustomValidity&&j.current.setCustomValidity(ee.valid?"":_===void 0?lt:_)},[_,ee]);t.useEffect(Ve),t.useEffect(()=>{const e=r.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver($e.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{document!=null&&document.body&&e&&e.disconnect()}},[]);const ue=t.useCallback(e=>{if(!l){if(N){const a={...e};N.call(void 0,a)}d===void 0&&le(!0)}},[l,d,N]),I=t.useCallback(e=>{if(l){if(v){const a={...e};v.call(void 0,a)}d===void 0&&(le(!1),D&&setTimeout(()=>{var a;y((a=Y.current)==null?void 0:a.element)},300))}},[l,d,v,D]),Le=t.useCallback(e=>{if(!e.isDefaultPrevented()&&i.current){te(!0);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};(l?I:ue)(a)}},[l,d,N,v]),q=t.useCallback(e=>{$.current=!0,e(),window.setTimeout(()=>$.current=!1,0)},[]),Be=t.useCallback(e=>{var F,ke;const{keyCode:a,altKey:c}=e,m=k.current&&k.current.element;if(!i.current||e.isDefaultPrevented()&&((F=R.current)==null?void 0:F.element)===e.target)return;const K={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(l)if(a===r.Keys.esc||c&&a===r.Keys.up)e.preventDefault(),I(K);else if(m&&m.querySelector(".k-focus")&&(a===r.Keys.up||a===r.Keys.down||a===r.Keys.left||a===r.Keys.right||a===r.Keys.home||a===r.Keys.end)){if(a===r.Keys.up&&((ke=R.current)!=null&&ke.element)){const A=Array.from(m.querySelectorAll(".k-treeview-item")),Ce=[...A].reverse().find(z=>!!(z&&z.querySelector(".k-focus")));if(Ce&&A.indexOf(Ce)===0)return q(()=>{var z;y((z=R.current)==null?void 0:z.element)})}q(r.noop)}else a===r.Keys.down&&q(()=>{var A;y(((A=R.current)==null?void 0:A.element)||m)});else c&&a===r.Keys.down?(e.preventDefault(),ue(K)):l||a===r.Keys.esc&&me(e)},[l,d,N,v]),de=t.useCallback(e=>{const{keyCode:a,altKey:c}=e;c||a!==r.Keys.up&&a!==r.Keys.down||(e.preventDefault(),q(a===r.Keys.up?()=>{y(g.current)}:()=>{y(k.current&&k.current.element)}))},[]),y=t.useCallback(e=>{e&&q(()=>e.focus())},[]),We=t.useCallback(()=>{var e;!p&&l&&!d?I({target:i.current}):s.filterable?y((e=R.current)==null?void 0:e.element):y(k.current&&k.current.element)},[v,s.filterable,p,d,l]),Ae=t.useCallback(()=>{p&&y(g.current)},[p]),ze=t.useCallback(e=>{if(!p&&!$.current&&(te(!0),s.onFocus&&i.current)){const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};s.onFocus.call(void 0,a)}},[p,s.onFocus]),He=t.useCallback(e=>{if(p&&!$.current&&i.current){te(!1);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(s.onBlur){const c={...a};s.onBlur.call(void 0,c)}D||I(a)}},[p,s.onBlur,l,d,v]),_e=t.useCallback(()=>{p&&q(r.noop),D&&setTimeout(()=>{var e;y((e=Y.current)==null?void 0:e.element)},300)},[p,D]),pe=t.useCallback((e,a,c)=>{if(s.onChange){const m={value:a,level:c?Ie(c):[],...e};s.onChange.call(void 0,m)}w||Ke(a)},[s.onChange,w]),fe=t.useCallback(e=>{if(U.areSame(e.item,b,T)||!i.current)return;const{item:a,itemHierarchicalIndex:c,nativeEvent:m,syntheticEvent:K}=e,F={syntheticEvent:K,nativeEvent:m,target:i.current};pe(F,a,c),I(F)},[w,b,s.onChange,T,l,d,v]),me=t.useCallback(e=>{if(!i.current)return;const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};pe(a,null),I(a),e.preventDefault()},[w,s.onChange,l,d,v]),ve=t.useCallback(e=>{if(e.syntheticEvent.stopPropagation(),s.onExpandChange&&i.current){const{item:a,itemHierarchicalIndex:c,nativeEvent:m,syntheticEvent:K}=e,F={level:Ie(c),item:a,nativeEvent:m,syntheticEvent:K,target:i.current};s.onExpandChange.call(void 0,F)}},[s.onExpandChange]),ge=t.useCallback(e=>{if(s.onFilterChange&&i.current){const c={filter:{field:s.textField,operator:"contains",value:e.target.value},syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,target:i.current};s.onFilterChange.call(void 0,c),s.filter===void 0&&Oe(e.target.value)}},[s.onFilterChange,s.filter,s.textField]),je=()=>{const e=o.filterable?t.createElement(xe,{value:o.filter===void 0?ce:o.filter,ref:Y,onChange:ge,onKeyDown:de,size:C,rounded:B,fillMode:W}):null,a={adaptiveTitle:o.adaptiveTitle,expand:l,onClose:c=>I(c),windowWidth:ne,mobileFilter:e};return t.createElement(nt.AdaptiveMode,{...a},t.createElement(at.ActionSheetContent,{overflowHidden:!0},t.createElement("div",{className:"k-list-container"},t.createElement("div",{className:"k-list k-list-lg"},M.length>0?t.createElement(we.TreeView,{ref:k,tabIndex:X,data:be,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:fe,onExpandChange:ve,size:C,item:o.item,dir:x,animate:E.animate}):t.createElement(ye,null,ae.toLanguageString(h.nodata,h.messages[h.nodata]))))))},$e=t.useCallback(e=>{for(const a of e)Ne(a.target.clientWidth)},[]),be=t.useMemo(()=>w||!L?M:r.mapTree(M,V,e=>r.extendDataItem(e,V,{[H]:U.areSame(e,b,T)})),[M,b,w,L,H,V]),ye=o.listNoData||Ze.ListNoData,Ue=o.valueHolder||ct,ae=Qe.useLocalization(),he=!qe||ee.valid,{size:C,rounded:B,fillMode:W}=o,Ee=t.createElement(t.Fragment,null,t.createElement("span",{className:r.classNames("k-dropdowntree k-picker",o.className,{[`k-picker-${st[C]||C}`]:C,[`k-rounded-${it[B]||B}`]:B,[`k-picker-${W}`]:W,"k-focus":p,"k-invalid":!he,"k-loading":o.loading,"k-required":Q,"k-disabled":o.disabled}),tabIndex:X,accessKey:o.accessKey,id:se,style:O?{...P,width:void 0}:P,dir:x,ref:g,onKeyDown:S?void 0:Be,onMouseDown:_e,onClick:S?void 0:Le,onFocus:ze,onBlur:He,role:"combobox","aria-haspopup":"tree","aria-expanded":l,"aria-disabled":S,"aria-label":O,"aria-labelledby":o.ariaLabelledBy,"aria-describedby":o.ariaDescribedBy,"aria-required":Q},t.createElement("span",{className:"k-input-inner"},(Z||J)&&t.createElement(Ue,{item:b},Z||J)),o.loading&&t.createElement(r.IconWrap,{className:"k-input-loading-icon",name:"loading"}),L&&!S&&t.createElement("span",{onClick:me,className:"k-clear-value",title:ae.toLanguageString(h.clear,h.messages[h.clear]),role:"button",tabIndex:-1,onMouseDown:e=>e.preventDefault()},t.createElement(r.IconWrap,{name:"x",icon:De.xIcon})),t.createElement(tt.Button,{tabIndex:-1,type:"button","aria-label":"select",className:"k-input-button",size:C,fillMode:W,themeColor:"base",rounded:null,icon:"caret-alt-down",svgIcon:De.caretAltDownIcon}),t.createElement("select",{name:Se,ref:j,tabIndex:-1,"aria-hidden":!0,title:O,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},t.createElement("option",{value:o.valueMap?o.valueMap.call(void 0,b):b})),!D&&t.createElement(Je.Popup,{...E,className:r.classNames(E.className,{"k-rtl":x==="rtl"}),popupClass:r.classNames(E.popupClass,"k-dropdowntree-popup k-list-container"),style:Te,anchor:E.anchor||g.current,show:l,onOpen:We,onClose:Ae},o.filterable&&t.createElement(xe,{value:o.filter===void 0?ce:o.filter,ref:R,onChange:ge,onKeyDown:de,size:C,rounded:B,fillMode:W,renderListFilterWrapper:!0,renderPrefixSeparator:!0}),M.length>0?t.createElement(we.TreeView,{style:{height:E.height},ref:k,tabIndex:X,data:be,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:fe,onExpandChange:ve,size:C,item:o.item,dir:x,animate:E.animate}):t.createElement(ye,null,ae.toLanguageString(h.nodata,h.messages[h.nodata])))),D&&je());return O?t.createElement(et.FloatingLabel,{label:O,editorValue:Z,editorPlaceholder:J,editorValid:he,editorDisabled:S,editorId:se,style:{width:P?P.width:void 0},children:Ee,dir:x}):Ee}),dt={opened:n.bool,disabled:n.bool,dir:n.string,tabIndex:n.number,accessKey:n.string,data:n.array,value:n.any,valueMap:n.func,placeholder:n.string,dataItemKey:n.string.isRequired,textField:n.string.isRequired,selectField:n.string,expandField:n.string,subItemsField:n.string,className:n.string,style:n.object,label:n.string,validationMessage:n.string,validityStyles:n.bool,valid:n.bool,required:n.bool,name:n.string,id:n.string,ariaLabelledBy:n.string,ariaDescribedBy:n.string,filterable:n.bool,filter:n.string,loading:n.bool,popupSettings:n.shape({animate:n.oneOfType([n.bool,n.shape({openDuration:n.number,closeDuration:n.number})]),popupClass:n.string,className:n.string,appendTo:n.any,width:n.oneOfType([n.string,n.number]),height:n.oneOfType([n.string,n.number])}),onOpen:n.func,onClose:n.func,onFocus:n.func,onBlur:n.func,onChange:n.func,onFilterChange:n.func,onExpandChange:n.func,item:n.func,valueHolder:n.func,listNoData:n.func,adaptiveTitle:n.string,adaptive:n.bool};re.displayName="KendoReactDropDownTree";re.propTypes=dt;exports.DropDownTree=re;exports.DropDownTreePropsContext=Fe;
|
|
@@ -319,7 +319,7 @@ const { sizeMap: Ct, roundedMap: kt } = it, xt = "Please select a value from the
|
|
|
319
319
|
windowWidth: ne,
|
|
320
320
|
mobileFilter: e
|
|
321
321
|
};
|
|
322
|
-
return /* @__PURE__ */ t.createElement(ht, { ...a }, /* @__PURE__ */ t.createElement(yt, {
|
|
322
|
+
return /* @__PURE__ */ t.createElement(ht, { ...a }, /* @__PURE__ */ t.createElement(yt, { overflowHidden: !0 }, /* @__PURE__ */ t.createElement("div", { className: "k-list-container" }, /* @__PURE__ */ t.createElement("div", { className: "k-list k-list-lg" }, T.length > 0 ? /* @__PURE__ */ t.createElement(
|
|
323
323
|
Fe,
|
|
324
324
|
{
|
|
325
325
|
ref: h,
|
|
@@ -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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react"),v=require("prop-types"),h=require("@progress/kendo-react-common"),W=require("@progress/kendo-svg-icons"),U=require("@progress/kendo-react-labels"),G=require("../common/ListContainer.js"),j=require("../common/List.js"),Y=require("../common/GroupStickyHeader.js"),J=require("./TagList.js"),Q=require("../common/SearchBar.js"),K=require("../common/DropDownBase.js"),D=require("../common/settings.js"),m=require("../common/utils.js"),X=require("../package-metadata.js"),Z=require("../common/ClearButton.js"),ee=require("../common/AdaptiveMode.js"),te=require("@progress/kendo-react-layout"),se=require("../common/constants.js"),ie=require("@progress/kendo-react-intl"),S=require("../messages/index.js"),oe=require("../common/ListFilter.js"),E=require("../common/withCustomComponent.js");function ae(I){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(I){for(const t in I)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(I,t);Object.defineProperty(n,t,e.get?e:{enumerable:!0,get:()=>I[t]})}}return n.default=I,Object.freeze(n)}const f=ae($),{sizeMap:w,roundedMap:ne}=h.kendoThemeMaps,le="Please enter a valid value!",P=I=>I.preventDefault(),_=I=>I===2,b=class b extends f.Component{constructor(n){super(n),this.state={activedescendant:D.ActiveDescendant.PopupList,currentValue:[]},this._element=null,this._valueItemsDuringOnChange=null,this.base=new K(this),this._tags=[],this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._lastSelectedOrDeslectedItemIndex=null,this.itemHeight=0,this.scrollToFocused=!1,this.localization=null,this.focus=()=>{this._input&&this._input.focus()},this.handleItemSelect=(t,e)=>{const{dataItemKey:o,virtual:s}=this.props,a=m.getFilteredData(this.props),p=s?s.skip:0,u=a[t-p],r=this.value.findIndex(g=>m.areSame(g,u,o));this._lastSelectedOrDeslectedItemIndex=a.findIndex(g=>m.areSame(g,u,o));let i=[];r!==-1?(i=this.value,i.splice(r,1)):i=[...this.value,u],(this.props.filter!==void 0?this.props.filter:this.state.text)&&!this.mobileMode&&(this.state.text&&(e.data.text=""),this.base.filterChanged("",e)),this._adaptiveInput&&this._adaptiveInput.blur(),this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.triggerOnChange(i,e),this.base.triggerPageChangeCornerItems(u,e)},this.onTagDelete=(t,e)=>{const o=this.base.initState();o.syntheticEvent=e,this.opened&&this.base.togglePopup(o),!this.state.focused&&!this.mobileMode&&(o.data.focused=!0,this.focus());const s=this.value;m.removeDataItems(s,t,this.props.dataItemKey),this.triggerOnChange(s,o),this.applyState(o)},this.itemFocus=(t,e)=>{const{allowCustom:o,virtual:s}=this.props,a=m.getFilteredData(this.props),p=s?s.skip:0,u=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedIndex:r}=this.getFocusedState(),i=o&&u,d=a[t-p];d&&r!==t?this.state.focusedIndex!==t&&(e.data.focusedIndex=t,e.data.activedescendant=D.ActiveDescendant.PopupList):i&&t===-1&&this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.base.triggerPageChangeCornerItems(d,e)},this.componentRef=t=>{this._element=t,this.base.wrapper=t},this.searchbarRef=t=>{const e=this._input=t&&t.input;e&&this.state.focused&&window.setTimeout(()=>e.focus(),0)},this.onChangeHandler=t=>{const e=this.base.initState(),o=t.target.value;e.syntheticEvent=t,this.props.filter===void 0&&(e.data.text=o),e.data.focusedIndex=void 0,this.opened||(this.base.togglePopup(e),this.setState({currentValue:this.value})),this.base.filterChanged(o,e),this.applyState(e),this.setState({group:void 0})},this.clearButtonClick=t=>{const e=this.base.initState();e.syntheticEvent=t,t.stopPropagation(),this.value.length>0&&this.triggerOnChange([],e),this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(e);const o=this.props.filter!==void 0?this.props.filter:this.state.text;m.isPresent(o)&&o!==""&&this.base.filterChanged("",e),this.state.text&&(e.data.text=""),this._lastSelectedOrDeslectedItemIndex=null,this.applyState(e)},this.onInputKeyDown=t=>{const{textField:e,groupField:o}=this.props,s=m.getFilteredData(this.props),a=t.keyCode,p=this.props.filter!==void 0?this.props.filter:this.state.text,u=this.props.opened!==void 0?this.props.opened:this.state.opened,{focusedItem:r,focusedIndex:i}=this.getFocusedState(),d=this.base.initState();if(d.syntheticEvent=t,!p&&this.value.length>0&&(a===h.Keys.left||a===h.Keys.right||a===h.Keys.home||a===h.Keys.end||a===h.Keys.delete||a===h.Keys.backspace)&&!t.shiftKey)return this.onTagsNavigate(t,d);const g=()=>{t.preventDefault(),this.base.togglePopup(d),this.applyState(d)};if(this.opened)if(a===h.Keys.pageUp)t.preventDefault(),this.base.scrollPopupByPageSize(-1);else if(a===h.Keys.pageDown)t.preventDefault(),this.base.scrollPopupByPageSize(1);else if((t.ctrlKey||t.metaKey)&&t.code==="KeyA"){const c=(this.state.value&&this.state.value.length)===s.length?[]:s;this.updateStateOnKeyboardNavigation(c,d)}else if((t.ctrlKey||t.metaKey)&&t.shiftKey&&t.keyCode===h.Keys.end){const l=s.slice(this.getFocusedState().focusedIndex);this.itemFocus(s.length-1,d),this.updateStateOnKeyboardNavigation(l,d)}else if((t.ctrlKey||t.metaKey)&&t.shiftKey&&t.keyCode===h.Keys.home){const l=s.slice(0,this.getFocusedState().focusedIndex+1);this.itemFocus(0,d),this.updateStateOnKeyboardNavigation(l,d)}else if(t.shiftKey&&t.keyCode===h.Keys.up){let l;const c=this.getLastSelectedOrDeselectedIndex(1,i);c===null?l=i!==0?s.slice(i-1,i):[s[i]]:c===i?l=[s[c-1]]:i>=0&&(l=c>i?s.slice(i-1,c):s.slice(c-1,i)),l&&l.length>0&&(i>=1&&this.itemFocus(i-1,d),this.updateStateOnKeyboardNavigation(l,d))}else if(t.shiftKey&&t.keyCode===h.Keys.down){let l;const c=this.getLastSelectedOrDeselectedIndex(0,i);c===null?l=i!==s.length-1?s.slice(i,i+1):[s[i]]:c===i?l=s.slice(i,i+2):i>=0&&(l=c>i?s.slice(i+1,c+1):s.slice(c,i+2)),l&&l.length>=1&&(this.itemFocus(i+1,d),this.updateStateOnKeyboardNavigation(l,d))}else if(t.altKey&&a===h.Keys.up)g();else if(a===h.Keys.up||a===h.Keys.down){if(o!==""&&e)if(!this.props.skipDisabledItems&&u)this.onNavigate(d,a);else{let l=0;if(a===h.Keys.down||a===h.Keys.right){const c=s.slice(i+1).find(y=>!y.disabled&&y[e]);l=c&&s.findIndex(y=>y[e]===c[e])}else if(a===h.Keys.up||a===h.Keys.left){let c;if(i===-1)c=s,l=s.findIndex(y=>!y.disabled&&y[e]);else{c=s.slice(0,i);let y=c.pop();for(;y&&y.disabled;)y=c.pop();l=y&&s.findIndex(C=>C[e]===y[e])}}if(l){const c=l-i;this.onNavigate(d,a,c)}else l!==void 0&&this.onNavigate(d,a)}else if(!this.props.skipDisabledItems&&u)this.onNavigate(d,a);else{let l=null;if(a===h.Keys.down||a===h.Keys.right)l=s.slice(i+1).find(c=>!c.disabled);else if(a===h.Keys.up||a===h.Keys.left){const c=s.slice(0,i);for(l=c.pop();l&&l.disabled;)l=c.pop()}if(l){const c=l.id-i-1;this.onNavigate(d,a,c)}else this.onNavigate(d,a)}this.applyState(d),t.preventDefault()}else a===h.Keys.enter?(t.preventDefault(),this.props.allowCustom&&p&&r===null?this.customItemSelect(t):r&&r.disabled?g():this.selectFocusedItem(t)):a===h.Keys.esc&&g();else t.altKey&&a===h.Keys.down?g():a===h.Keys.esc&&this.clearButtonClick(t)},this.listContainerContent=()=>{const{header:t,footer:e,allowCustom:o,size:s,groupStickyHeaderItemRender:a,groupField:p,list:u}=this.props,r=m.getFilteredData(this.props),i=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedType:d}=this.getFocusedState(),g=o&&i&&f.createElement("div",{className:h.classNames("k-list",{[`k-list-${w[s]||s}`]:s}),key:"customitem",onClick:this.customItemSelect,onMouseDown:P},f.createElement("div",{className:h.classNames("k-list-item k-custom-item",{"k-focus":_(d)}),style:{fontStyle:"italic"}},i,f.createElement(h.IconWrap,{name:"plus",icon:W.plusIcon,style:{position:"absolute",right:"0.5em"}})));let{group:l}=this.state;return l===void 0&&p!==void 0&&(l=m.getItemValue(r[0],p)),f.createElement(f.Fragment,null,t&&f.createElement("div",{className:"k-list-header"},t),g,f.createElement("div",{className:h.classNames("k-list",{[`k-list-${this.mobileMode?"lg":w[s]||s}`]:s,"k-virtual-list":this.base.vs.enabled})},!u&&l&&r.length!==0&&f.createElement(Y,{group:l,groupMode:"modern",render:a}),this.renderList()),e&&f.createElement("div",{className:"k-list-footer"},e))},this.renderListContainer=()=>{const t=this.base,{dir:e}=this.props,o=m.getFilteredData(this.props),s=this.base.getPopupSettings(),a=s.width!==void 0?s.width:t.popupWidth,p={dir:e!==void 0?e:t.dirCalculated,width:a,popupSettings:{...s,popupClass:h.classNames(s.popupClass,"k-list-container","k-multiselect-popup"),anchor:s.anchor||this.element,show:this.opened,onOpen:this.onPopupOpened,onClose:this.onPopupClosed},itemsCount:[o.length,this.value.length]};return f.createElement(G,{...p},this.listContainerContent())},this.renderAdaptiveListContainer=()=>{const{adaptiveTitle:t,filterable:e,filter:o}=this.props,{windowWidth:s=0}=this.state,a=o!==void 0?o:this.state.text;this.localization=ie.provideLocalizationService(this);const p=e?f.createElement(oe,{value:a,ref:r=>this._adaptiveInput=r&&r.element,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode}):null,u={adaptiveTitle:t,expand:this.opened,onClose:r=>this.onCancel(r),windowWidth:s,mobileFilter:p,footer:{cancelText:this.localization.toLanguageString(S.adaptiveModeFooterCancel,S.messages[S.adaptiveModeFooterCancel]),onCancel:this.onCancel,applyText:this.localization.toLanguageString(S.adaptiveModeFooterApply,S.messages[S.adaptiveModeFooterApply]),onApply:this.closePopup}};return f.createElement(ee.AdaptiveMode,{...u},f.createElement(te.ActionSheetContent,{className:"!k-overflow-hidden"},f.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.closePopup=t=>{const e=this.base.initState();e.syntheticEvent=t,t.stopPropagation(),this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(e),e.events.push({type:"onClose"});const o=this.props.filter!==void 0?this.props.filter:this.state.text;m.isPresent(o)&&o!==""&&this.base.filterChanged("",e),this.state.text&&(e.data.text=""),this.applyState(e)},this.onCancel=t=>{const e=this.base.initState();e.syntheticEvent=t,t.stopPropagation(),this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(e),e.events.push({type:"onCancel"});const o=this.props.filter!==void 0?this.props.filter:this.state.text;m.isPresent(o)&&o!==""&&this.base.filterChanged("",e),this.state.text&&(e.data.text=""),this.applyState(e)},this.renderList=()=>{const{textField:t,listNoDataRender:e,itemRender:o,groupHeaderItemRender:s,dataItemKey:a,virtual:p={skip:0,total:void 0}}=this.props,u=m.getFilteredData(this.props),r=this.base.vs,{focusedIndex:i}=this.getFocusedState(),d=this.base.getPopupSettings(),g=`translateY(${r.translate}px)`;return f.createElement(j,{id:this.base.listBoxId,show:this.opened,data:u.slice(),focusedIndex:i-p.skip,value:this.value,textField:t,valueField:a,optionsGuid:this.base.guid,groupField:this.props.groupField,groupMode:"modern",listRef:l=>{r.list=this.base.list=l},wrapperStyle:this.mobileMode?{}:{maxHeight:d.height},wrapperCssClass:"k-list-content",listStyle:r.enabled?{transform:g}:void 0,key:"listKey",skip:p.skip,onClick:this.handleItemClick,itemRender:o,groupHeaderItemRender:s,noDataRender:e,onMouseDown:P,onBlur:this.handleBlur,onScroll:this.onScroll,wrapperRef:r.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:p.total})},this.onScroll=t=>{const{vs:e,list:o}=this.base;e.scrollHandler(t);const{groupField:s}=this.props;let a=m.getFilteredData(this.props);if(!(!s||!a.length)&&s){const p=this.itemHeight=this.itemHeight||(e.enabled?e.itemHeight:o?o.children[0].offsetHeight:0),r=t.target.scrollTop-e.skip*p;a=this.base.getGroupedDataModernMode(a,s);let i=a[0][s];for(let d=1;d<a.length&&!(p*d>r);d++)a[d]&&a[d][s]&&(i=a[d][s]);i!==this.state.group&&this.setState({group:i})}},this.customItemSelect=t=>{const e=this.props.filter!==void 0?this.props.filter:this.state.text,{textField:o}=this.props;if(!e)return;const s=this.base.initState();s.syntheticEvent=t;const a=o?{[o]:e}:e;this.state.text!==void 0&&(s.data.text=""),s.data.focusedIndex=void 0,this.base.filterChanged("",s);const p=[...this.value,a];this.triggerOnChange(p,s),this.base.togglePopup(s),this.applyState(s)},this.handleWrapperClick=t=>{const e=this._input;!this.opened&&e&&this.focusElement(e);const o=this.base.initState();o.syntheticEvent=t,!this.state.focused&&!this.mobileMode&&(o.events.push({type:"onFocus"}),o.data.focused=!0),this.mobileMode&&(this.setState({currentValue:this.tagsToRender}),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300)),this.base.togglePopup(o),this.applyState(o)},this.handleItemClick=(t,e)=>{const o=this.base.initState();o.syntheticEvent=e,this.handleItemSelect(t,o),this.props.autoClose&&!this.mobileMode&&this.base.togglePopup(o),e.stopPropagation(),this.applyState(o)},this.handleBlur=t=>{if(!this.state.focused||this._skipFocusEvent)return;const e=this.base.initState(),{allowCustom:o,filterable:s}=this.props;e.syntheticEvent=t,e.data.focused=!1,e.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(e.data.opened=!1),e.events.push({type:"onClose"})),!o&&!s&&this.state.text&&(e.data.text=""),this.applyState(e)},this.handleFocus=t=>{this._skipFocusEvent||this.base.handleFocus(t)},this.onPopupOpened=()=>{this._input&&this.state.focused&&!this.mobileMode&&this.focusElement(this._input)},this.onPopupClosed=()=>{this.state.focused&&window.setTimeout(()=>{this.state.focused&&this.focusElement(this._input)},0)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||le)},h.validatePackage(X.packageMetadata)}get _inputId(){return this.props.id}get document(){if(h.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get tagsToRender(){const{tags:n,textField:t}=this.props,e=[];return n===void 0?this.value.forEach(o=>{e.push({text:m.getItemValue(o,t),data:[o]})}):e.push(...n),e}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=se.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}get value(){const n=[];return this._valueItemsDuringOnChange?n.push(...this._valueItemsDuringOnChange):this.props.value?n.push(...this.props.value):this.state.value?n.push(...this.state.value):this.props.defaultValue&&n.push(...this.props.defaultValue),n}get name(){return this.props.name}get validity(){const n=this.props.validationMessage!==void 0,t=!this.required||this.value!==null&&this.value.length>0&&this.value!==void 0,e=this.props.valid!==void 0?this.props.valid:t;return{customError:n,valid:e,valueMissing:this.value===null}}get required(){return this.props.required!==void 0?this.props.required:b.defaultProps.required}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:b.defaultProps.validityStyles}componentDidUpdate(n,t){var g;const{virtual:e,groupField:o=""}=this.props,s=m.getFilteredData(this.props),a=e?e.skip:0,p=n.virtual?n.virtual.total:0,u=n.opened!==void 0?n.opened:t.opened,r=!u&&this.opened,i=u&&!this.opened,d=this.base.getPopupSettings();if(this.base.didUpdate(),!d.animate&&i&&this.onPopupClosed(),e&&e.total!==p)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{let{focusedItem:l,focusedIndex:c}=this.getFocusedState();o!==""&&(c=(g=this.base.getGroupedDataModernMode(s,o))==null?void 0:g.indexOf(l)),r&&e?this.base.scrollToVirtualItem(e,c-a):r&&!e?(s&&s.length!==0&&this.base.resetGroupStickyHeader(s[0][o],this),this.base.scrollToItem(c)):this.opened&&u&&l&&this.scrollToFocused&&this.base.scrollToItem(c-a)}this.scrollToFocused=!1,this.setValidity()}componentDidMount(){var n;this.observerResize=h.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(n=this.document)!=null&&n.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentWillUnmount(){var n;(n=this.document)!=null&&n.body&&this.observerResize&&this.observerResize.disconnect()}onNavigate(n,t,e){const{allowCustom:o}=this.props,s=m.getFilteredData(this.props),a=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedType:p,focusedIndex:u}=this.getFocusedState(),r=o&&a,i=_(p),d=this.base,g=d.vs;if(this.opened&&t===h.Keys.up&&i)this.state.focusedIndex!==void 0&&(n.data.focusedIndex=void 0);else{const l=d.navigation.navigate({keyCode:t,current:u,max:(g.enabled?g.total:s.length)-1,min:r?-1:0,skipItems:e||void 0});l!==void 0&&(this.itemFocus(l,n),this.scrollToFocused=!0)}this.applyState(n)}render(){const{style:n,className:t,label:e,dir:o,disabled:s,textField:a,dataItemKey:p,virtual:u,size:r,rounded:i,fillMode:d,loading:g,filter:l}=this.props,{text:c,focused:y,focusedTag:C,currentValue:q}=this.state,k=this.base.vs,T=this.props.id||this._inputId;k.enabled=u!==void 0,u!==void 0&&(k.skip=u.skip,k.total=u.total,k.pageSize=u.pageSize);const x=this.mobileMode&&this.opened?q:this.tagsToRender;this.setItems(this.tagsToRender,this._tags);const M=!this.validityStyles||this.validity.valid,L=!!(l!==void 0?l:c)||x&&x.length>0,[B,V]=E(this.props.prefix||f.Fragment),[z,A]=E(this.props.suffix||f.Fragment),O=f.createElement(f.Fragment,null,f.createElement("div",{ref:this.componentRef,className:h.classNames("k-multiselect k-input",t,{[`k-input-${w[r]||r}`]:r,[`k-rounded-${ne[i]||i}`]:i,[`k-input-${d}`]:d,"k-focus":y&&!s,"k-invalid":!M,"k-disabled":s,"k-loading":g,"k-required":this.required}),style:e?{...n,width:void 0}:n,dir:o,onFocus:this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick,onMouseDown:m.preventDefaultNonInputs},this.props.prefix&&f.createElement(B,{...V}),f.createElement("div",{className:h.classNames("k-input-values")},f.createElement("div",{className:h.classNames("k-chip-list",{[`k-chip-list-${w[r]||r}`]:r}),role:"listbox",id:"tagslist-"+this.base.guid},x&&x.length>0&&f.createElement(J,{tagRender:this.props.tagRender,onTagDelete:this.onTagDelete,data:x,guid:this.base.guid,focused:C?x.find(H=>m.matchTags(H,C,p)):void 0,size:r})),this.renderSearchBar(T)),g&&f.createElement(h.IconWrap,{className:"k-input-loading-icon",name:"loading"}),this.props.suffix&&f.createElement(z,{...A}),L&&f.createElement(Z,{onClick:this.clearButtonClick}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return e?f.createElement(U.FloatingLabel,{label:e,editorId:T,editorValue:c||m.getItemValue(this.value[0],a),editorValid:M,editorDisabled:s,style:{width:n?n.width:void 0},children:O}):O}renderSearchBar(n){const{activedescendant:t,focusedTag:e,currentValue:o}=this.state,{disabled:s,placeholder:a,ariaDescribedBy:p,ariaLabelledBy:u,ariaLabel:r}=this.props,i=!this.mobileMode&&(this.props.filter!==void 0?this.props.filter:this.state.text)||"",{focusedIndex:d}=this.getFocusedState(),g=this.value.length===0&&!i?a:void 0,l=o&&o.length>0?void 0:a,c=t===D.ActiveDescendant.TagsList&&e!==void 0?`tag-${this.base.guid}-${e.text.replace(/\s+/g,"-")}`:`option-${this.base.guid}-${d}`,y={accessKey:this.props.accessKey,tabIndex:this.props.tabIndex};return f.createElement(Q,{id:n,size:Math.max((g||"").length,i.length,1),placeholder:this.mobileMode&&this.opened?l:g,value:i,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,ref:this.searchbarRef,disabled:s,expanded:this.opened,owns:this.base.listBoxId,role:"combobox",activedescendant:c,ariaDescribedBy:`tagslist-${this.base.guid}${p?" "+p:""}`,ariaLabelledBy:u,ariaRequired:this.required,ariaLabel:r,...y})}onTagsNavigate(n,t){const e=n.keyCode,{focusedTag:o}=this.state,s=this._tags,a=this.props.dataItemKey;let p=o?s.findIndex(i=>m.matchTags(i,o,a)):-1,u;const r=p!==-1;if(e===h.Keys.left)r?p=Math.max(0,p-1):p=s.length-1,u=s[p];else if(e===h.Keys.right)p===s.length-1?u=void 0:r&&(p=Math.min(s.length-1,p+1),u=s[p]);else if(e===h.Keys.home&&!n.shiftKey)u=s[0];else if(e===h.Keys.end&&!n.shiftKey)u=s[s.length-1];else if(e===h.Keys.delete){if(r){const i=this.value;m.removeDataItems(i,s[p].data,a),this.triggerOnChange(i,t)}}else if(e===h.Keys.backspace){const i=this.value;if(r)m.removeDataItems(i,s[p].data,a),this.triggerOnChange(i,t);else if(!r&&s.length){const d=s.pop();m.removeDataItems(i,d.data,a),this.triggerOnChange(i,t)}}u!==o&&(t.data.focusedTag=u,t.data.activedescendant=D.ActiveDescendant.TagsList),this.applyState(t)}triggerOnChange(n,t){this.props.value===void 0&&(t.data.value=[...n]),this._valueItemsDuringOnChange=[],this.setItems(n,this._valueItemsDuringOnChange),t.events.push({type:"onChange"})}selectFocusedItem(n,t){const{virtual:e}=this.props,o=m.getFilteredData(this.props),{focusedIndex:s}=t||this.getFocusedState(),a=e?e.skip:0;o[s-a]!==void 0&&this.handleItemClick(s,n)}setItems(n,t){t.length=0,t.push(...n)}getFocusedState(){const{focusedIndex:n}=this.state,t=this.props.filter!==void 0?this.props.filter:this.state.text,{allowCustom:e,dataItemKey:o,virtual:s,textField:a,focusedItemIndex:p=m.itemIndexStartsWith,skipDisabledItems:u}=this.props,r=m.getFilteredData(this.props),i=s&&s.skip||0;let d;if(n!==void 0)return{focusedIndex:n,focusedItem:r[n-i],focusedType:1};const g=this.value;if(e&&t)return{focusedItem:null,focusedIndex:-1,focusedType:2};if(t)return d=p(r,t,a),{focusedItem:r[d],focusedIndex:d+i,focusedType:1};if(g.length){const l=g[g.length-1];return d=r.findIndex(c=>m.areSame(c,l,o)),r[d]!==void 0?{focusedIndex:d+i,focusedItem:r[d],focusedType:1}:{focusedType:0,focusedIndex:-1}}else if(u&&a&&!t&&i===0){const l=r.findIndex(c=>!c.disabled&&c[a]);return{focusedIndex:l,focusedItem:r[l-i],focusedType:1}}return i===0?{focusedItem:r[0],focusedIndex:0,focusedType:1}:{focusedType:0,focusedIndex:-1}}focusElement(n){this._skipFocusEvent=!0,n.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(n){this.base.applyState(n),this._valueItemsDuringOnChange=null}calculateMedia(n){for(const t of n)this.setState({windowWidth:t.target.clientWidth})}updateStateOnKeyboardNavigation(n,t){this.setState({value:n}),this.triggerOnChange(n,t),this.applyState(t)}getLastSelectedOrDeselectedIndex(n,t){return this._lastSelectedOrDeslectedItemIndex===null&&(this._lastSelectedOrDeslectedItemIndex=t),this._lastSelectedOrDeslectedItemIndex!==null?this._lastSelectedOrDeslectedItemIndex+n:null}};b.displayName="MultiSelect",b.propTypes={...K.propTypes,autoClose:v.bool,value:v.arrayOf(v.any),defaultValue:v.arrayOf(v.any),dataItemKey:v.string,placeholder:v.string,tags:v.arrayOf(v.shape({text:v.string,data:v.arrayOf(v.any)})),tagRender:v.func,id:v.string,ariaLabelledBy:v.string,ariaDescribedBy:v.string,groupField:v.string,list:v.any,adaptive:v.bool,adaptiveTitle:v.string,onCancel:v.func,skipDisabledItems:v.bool},b.defaultProps={...K.defaultProps,autoClose:!0,required:!1,size:"medium",rounded:"medium",fillMode:"solid",groupMode:"modern",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let F=b;const N=h.createPropsContext(),R=h.withIdHOC(h.withPropsContext(N,F));R.displayName="KendoReactMultiSelect";exports.MultiSelect=R;exports.MultiSelectPropsContext=N;exports.MultiSelectWithoutContext=F;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react"),v=require("prop-types"),h=require("@progress/kendo-react-common"),W=require("@progress/kendo-svg-icons"),U=require("@progress/kendo-react-labels"),G=require("../common/ListContainer.js"),j=require("../common/List.js"),Y=require("../common/GroupStickyHeader.js"),J=require("./TagList.js"),Q=require("../common/SearchBar.js"),K=require("../common/DropDownBase.js"),D=require("../common/settings.js"),m=require("../common/utils.js"),X=require("../package-metadata.js"),Z=require("../common/ClearButton.js"),ee=require("../common/AdaptiveMode.js"),te=require("@progress/kendo-react-layout"),se=require("../common/constants.js"),ie=require("@progress/kendo-react-intl"),S=require("../messages/index.js"),oe=require("../common/ListFilter.js"),E=require("../common/withCustomComponent.js");function ae(I){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(I){for(const t in I)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(I,t);Object.defineProperty(n,t,e.get?e:{enumerable:!0,get:()=>I[t]})}}return n.default=I,Object.freeze(n)}const f=ae($),{sizeMap:w,roundedMap:ne}=h.kendoThemeMaps,le="Please enter a valid value!",P=I=>I.preventDefault(),_=I=>I===2,b=class b extends f.Component{constructor(n){super(n),this.state={activedescendant:D.ActiveDescendant.PopupList,currentValue:[]},this._element=null,this._valueItemsDuringOnChange=null,this.base=new K(this),this._tags=[],this._input=null,this._adaptiveInput=null,this._skipFocusEvent=!1,this._lastSelectedOrDeslectedItemIndex=null,this.itemHeight=0,this.scrollToFocused=!1,this.localization=null,this.focus=()=>{this._input&&this._input.focus()},this.handleItemSelect=(t,e)=>{const{dataItemKey:o,virtual:s}=this.props,a=m.getFilteredData(this.props),p=s?s.skip:0,u=a[t-p],r=this.value.findIndex(g=>m.areSame(g,u,o));this._lastSelectedOrDeslectedItemIndex=a.findIndex(g=>m.areSame(g,u,o));let i=[];r!==-1?(i=this.value,i.splice(r,1)):i=[...this.value,u],(this.props.filter!==void 0?this.props.filter:this.state.text)&&!this.mobileMode&&(this.state.text&&(e.data.text=""),this.base.filterChanged("",e)),this._adaptiveInput&&this._adaptiveInput.blur(),this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.triggerOnChange(i,e),this.base.triggerPageChangeCornerItems(u,e)},this.onTagDelete=(t,e)=>{const o=this.base.initState();o.syntheticEvent=e,this.opened&&this.base.togglePopup(o),!this.state.focused&&!this.mobileMode&&(o.data.focused=!0,this.focus());const s=this.value;m.removeDataItems(s,t,this.props.dataItemKey),this.triggerOnChange(s,o),this.applyState(o)},this.itemFocus=(t,e)=>{const{allowCustom:o,virtual:s}=this.props,a=m.getFilteredData(this.props),p=s?s.skip:0,u=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedIndex:r}=this.getFocusedState(),i=o&&u,d=a[t-p];d&&r!==t?this.state.focusedIndex!==t&&(e.data.focusedIndex=t,e.data.activedescendant=D.ActiveDescendant.PopupList):i&&t===-1&&this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.base.triggerPageChangeCornerItems(d,e)},this.componentRef=t=>{this._element=t,this.base.wrapper=t},this.searchbarRef=t=>{const e=this._input=t&&t.input;e&&this.state.focused&&window.setTimeout(()=>e.focus(),0)},this.onChangeHandler=t=>{const e=this.base.initState(),o=t.target.value;e.syntheticEvent=t,this.props.filter===void 0&&(e.data.text=o),e.data.focusedIndex=void 0,this.opened||(this.base.togglePopup(e),this.setState({currentValue:this.value})),this.base.filterChanged(o,e),this.applyState(e),this.setState({group:void 0})},this.clearButtonClick=t=>{const e=this.base.initState();e.syntheticEvent=t,t.stopPropagation(),this.value.length>0&&this.triggerOnChange([],e),this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(e);const o=this.props.filter!==void 0?this.props.filter:this.state.text;m.isPresent(o)&&o!==""&&this.base.filterChanged("",e),this.state.text&&(e.data.text=""),this._lastSelectedOrDeslectedItemIndex=null,this.applyState(e)},this.onInputKeyDown=t=>{const{textField:e,groupField:o}=this.props,s=m.getFilteredData(this.props),a=t.keyCode,p=this.props.filter!==void 0?this.props.filter:this.state.text,u=this.props.opened!==void 0?this.props.opened:this.state.opened,{focusedItem:r,focusedIndex:i}=this.getFocusedState(),d=this.base.initState();if(d.syntheticEvent=t,!p&&this.value.length>0&&(a===h.Keys.left||a===h.Keys.right||a===h.Keys.home||a===h.Keys.end||a===h.Keys.delete||a===h.Keys.backspace)&&!t.shiftKey)return this.onTagsNavigate(t,d);const g=()=>{t.preventDefault(),this.base.togglePopup(d),this.applyState(d)};if(this.opened)if(a===h.Keys.pageUp)t.preventDefault(),this.base.scrollPopupByPageSize(-1);else if(a===h.Keys.pageDown)t.preventDefault(),this.base.scrollPopupByPageSize(1);else if((t.ctrlKey||t.metaKey)&&t.code==="KeyA"){const c=(this.state.value&&this.state.value.length)===s.length?[]:s;this.updateStateOnKeyboardNavigation(c,d)}else if((t.ctrlKey||t.metaKey)&&t.shiftKey&&t.keyCode===h.Keys.end){const l=s.slice(this.getFocusedState().focusedIndex);this.itemFocus(s.length-1,d),this.updateStateOnKeyboardNavigation(l,d)}else if((t.ctrlKey||t.metaKey)&&t.shiftKey&&t.keyCode===h.Keys.home){const l=s.slice(0,this.getFocusedState().focusedIndex+1);this.itemFocus(0,d),this.updateStateOnKeyboardNavigation(l,d)}else if(t.shiftKey&&t.keyCode===h.Keys.up){let l;const c=this.getLastSelectedOrDeselectedIndex(1,i);c===null?l=i!==0?s.slice(i-1,i):[s[i]]:c===i?l=[s[c-1]]:i>=0&&(l=c>i?s.slice(i-1,c):s.slice(c-1,i)),l&&l.length>0&&(i>=1&&this.itemFocus(i-1,d),this.updateStateOnKeyboardNavigation(l,d))}else if(t.shiftKey&&t.keyCode===h.Keys.down){let l;const c=this.getLastSelectedOrDeselectedIndex(0,i);c===null?l=i!==s.length-1?s.slice(i,i+1):[s[i]]:c===i?l=s.slice(i,i+2):i>=0&&(l=c>i?s.slice(i+1,c+1):s.slice(c,i+2)),l&&l.length>=1&&(this.itemFocus(i+1,d),this.updateStateOnKeyboardNavigation(l,d))}else if(t.altKey&&a===h.Keys.up)g();else if(a===h.Keys.up||a===h.Keys.down){if(o!==""&&e)if(!this.props.skipDisabledItems&&u)this.onNavigate(d,a);else{let l=0;if(a===h.Keys.down||a===h.Keys.right){const c=s.slice(i+1).find(y=>!y.disabled&&y[e]);l=c&&s.findIndex(y=>y[e]===c[e])}else if(a===h.Keys.up||a===h.Keys.left){let c;if(i===-1)c=s,l=s.findIndex(y=>!y.disabled&&y[e]);else{c=s.slice(0,i);let y=c.pop();for(;y&&y.disabled;)y=c.pop();l=y&&s.findIndex(C=>C[e]===y[e])}}if(l){const c=l-i;this.onNavigate(d,a,c)}else l!==void 0&&this.onNavigate(d,a)}else if(!this.props.skipDisabledItems&&u)this.onNavigate(d,a);else{let l=null;if(a===h.Keys.down||a===h.Keys.right)l=s.slice(i+1).find(c=>!c.disabled);else if(a===h.Keys.up||a===h.Keys.left){const c=s.slice(0,i);for(l=c.pop();l&&l.disabled;)l=c.pop()}if(l){const c=l.id-i-1;this.onNavigate(d,a,c)}else this.onNavigate(d,a)}this.applyState(d),t.preventDefault()}else a===h.Keys.enter?(t.preventDefault(),this.props.allowCustom&&p&&r===null?this.customItemSelect(t):r&&r.disabled?g():this.selectFocusedItem(t)):a===h.Keys.esc&&g();else t.altKey&&a===h.Keys.down?g():a===h.Keys.esc&&this.clearButtonClick(t)},this.listContainerContent=()=>{const{header:t,footer:e,allowCustom:o,size:s,groupStickyHeaderItemRender:a,groupField:p,list:u}=this.props,r=m.getFilteredData(this.props),i=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedType:d}=this.getFocusedState(),g=o&&i&&f.createElement("div",{className:h.classNames("k-list",{[`k-list-${w[s]||s}`]:s}),key:"customitem",onClick:this.customItemSelect,onMouseDown:P},f.createElement("div",{className:h.classNames("k-list-item k-custom-item",{"k-focus":_(d)}),style:{fontStyle:"italic"}},i,f.createElement(h.IconWrap,{name:"plus",icon:W.plusIcon,style:{position:"absolute",right:"0.5em"}})));let{group:l}=this.state;return l===void 0&&p!==void 0&&(l=m.getItemValue(r[0],p)),f.createElement(f.Fragment,null,t&&f.createElement("div",{className:"k-list-header"},t),g,f.createElement("div",{className:h.classNames("k-list",{[`k-list-${this.mobileMode?"lg":w[s]||s}`]:s,"k-virtual-list":this.base.vs.enabled})},!u&&l&&r.length!==0&&f.createElement(Y,{group:l,groupMode:"modern",render:a}),this.renderList()),e&&f.createElement("div",{className:"k-list-footer"},e))},this.renderListContainer=()=>{const t=this.base,{dir:e}=this.props,o=m.getFilteredData(this.props),s=this.base.getPopupSettings(),a=s.width!==void 0?s.width:t.popupWidth,p={dir:e!==void 0?e:t.dirCalculated,width:a,popupSettings:{...s,popupClass:h.classNames(s.popupClass,"k-list-container","k-multiselect-popup"),anchor:s.anchor||this.element,show:this.opened,onOpen:this.onPopupOpened,onClose:this.onPopupClosed},itemsCount:[o.length,this.value.length]};return f.createElement(G,{...p},this.listContainerContent())},this.renderAdaptiveListContainer=()=>{const{adaptiveTitle:t,filterable:e,filter:o}=this.props,{windowWidth:s=0}=this.state,a=o!==void 0?o:this.state.text;this.localization=ie.provideLocalizationService(this);const p=e?f.createElement(oe,{value:a,ref:r=>this._adaptiveInput=r&&r.element,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode}):null,u={adaptiveTitle:t,expand:this.opened,onClose:r=>this.onCancel(r),windowWidth:s,mobileFilter:p,footer:{cancelText:this.localization.toLanguageString(S.adaptiveModeFooterCancel,S.messages[S.adaptiveModeFooterCancel]),onCancel:this.onCancel,applyText:this.localization.toLanguageString(S.adaptiveModeFooterApply,S.messages[S.adaptiveModeFooterApply]),onApply:this.closePopup}};return f.createElement(ee.AdaptiveMode,{...u},f.createElement(te.ActionSheetContent,{overflowHidden:!0},f.createElement("div",{className:"k-list-container"},this.listContainerContent())))},this.closePopup=t=>{const e=this.base.initState();e.syntheticEvent=t,t.stopPropagation(),this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(e),e.events.push({type:"onClose"});const o=this.props.filter!==void 0?this.props.filter:this.state.text;m.isPresent(o)&&o!==""&&this.base.filterChanged("",e),this.state.text&&(e.data.text=""),this.applyState(e)},this.onCancel=t=>{const e=this.base.initState();e.syntheticEvent=t,t.stopPropagation(),this.state.focusedIndex!==void 0&&(e.data.focusedIndex=void 0),this.opened&&this.base.togglePopup(e),e.events.push({type:"onCancel"});const o=this.props.filter!==void 0?this.props.filter:this.state.text;m.isPresent(o)&&o!==""&&this.base.filterChanged("",e),this.state.text&&(e.data.text=""),this.applyState(e)},this.renderList=()=>{const{textField:t,listNoDataRender:e,itemRender:o,groupHeaderItemRender:s,dataItemKey:a,virtual:p={skip:0,total:void 0}}=this.props,u=m.getFilteredData(this.props),r=this.base.vs,{focusedIndex:i}=this.getFocusedState(),d=this.base.getPopupSettings(),g=`translateY(${r.translate}px)`;return f.createElement(j,{id:this.base.listBoxId,show:this.opened,data:u.slice(),focusedIndex:i-p.skip,value:this.value,textField:t,valueField:a,optionsGuid:this.base.guid,groupField:this.props.groupField,groupMode:"modern",listRef:l=>{r.list=this.base.list=l},wrapperStyle:this.mobileMode?{}:{maxHeight:d.height},wrapperCssClass:"k-list-content",listStyle:r.enabled?{transform:g}:void 0,key:"listKey",skip:p.skip,onClick:this.handleItemClick,itemRender:o,groupHeaderItemRender:s,noDataRender:e,onMouseDown:P,onBlur:this.handleBlur,onScroll:this.onScroll,wrapperRef:r.scrollerRef,scroller:this.base.renderScrollElement(),ariaSetSize:p.total})},this.onScroll=t=>{const{vs:e,list:o}=this.base;e.scrollHandler(t);const{groupField:s}=this.props;let a=m.getFilteredData(this.props);if(!(!s||!a.length)&&s){const p=this.itemHeight=this.itemHeight||(e.enabled?e.itemHeight:o?o.children[0].offsetHeight:0),r=t.target.scrollTop-e.skip*p;a=this.base.getGroupedDataModernMode(a,s);let i=a[0][s];for(let d=1;d<a.length&&!(p*d>r);d++)a[d]&&a[d][s]&&(i=a[d][s]);i!==this.state.group&&this.setState({group:i})}},this.customItemSelect=t=>{const e=this.props.filter!==void 0?this.props.filter:this.state.text,{textField:o}=this.props;if(!e)return;const s=this.base.initState();s.syntheticEvent=t;const a=o?{[o]:e}:e;this.state.text!==void 0&&(s.data.text=""),s.data.focusedIndex=void 0,this.base.filterChanged("",s);const p=[...this.value,a];this.triggerOnChange(p,s),this.base.togglePopup(s),this.applyState(s)},this.handleWrapperClick=t=>{const e=this._input;!this.opened&&e&&this.focusElement(e);const o=this.base.initState();o.syntheticEvent=t,!this.state.focused&&!this.mobileMode&&(o.events.push({type:"onFocus"}),o.data.focused=!0),this.mobileMode&&(this.setState({currentValue:this.tagsToRender}),this.mobileMode&&window.setTimeout(()=>this._adaptiveInput&&this._adaptiveInput.focus(),300)),this.base.togglePopup(o),this.applyState(o)},this.handleItemClick=(t,e)=>{const o=this.base.initState();o.syntheticEvent=e,this.handleItemSelect(t,o),this.props.autoClose&&!this.mobileMode&&this.base.togglePopup(o),e.stopPropagation(),this.applyState(o)},this.handleBlur=t=>{if(!this.state.focused||this._skipFocusEvent)return;const e=this.base.initState(),{allowCustom:o,filterable:s}=this.props;e.syntheticEvent=t,e.data.focused=!1,e.events.push({type:"onBlur"}),this.opened&&!this.mobileMode&&(this.state.opened&&(e.data.opened=!1),e.events.push({type:"onClose"})),!o&&!s&&this.state.text&&(e.data.text=""),this.applyState(e)},this.handleFocus=t=>{this._skipFocusEvent||this.base.handleFocus(t)},this.onPopupOpened=()=>{this._input&&this.state.focused&&!this.mobileMode&&this.focusElement(this._input)},this.onPopupClosed=()=>{this.state.focused&&window.setTimeout(()=>{this.state.focused&&this.focusElement(this._input)},0)},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||le)},h.validatePackage(X.packageMetadata)}get _inputId(){return this.props.id}get document(){if(h.canUseDOM)return this.element&&this.element.ownerDocument||document}get element(){return this._element}get opened(){return!!(this.props.opened!==void 0?this.props.opened:this.state.opened)}get tagsToRender(){const{tags:n,textField:t}=this.props,e=[];return n===void 0?this.value.forEach(o=>{e.push({text:m.getItemValue(o,t),data:[o]})}):e.push(...n),e}get mobileMode(){return!!(this.state.windowWidth&&this.state.windowWidth<=se.MOBILE_MEDIUM_DEVISE&&this.props.adaptive)}get value(){const n=[];return this._valueItemsDuringOnChange?n.push(...this._valueItemsDuringOnChange):this.props.value?n.push(...this.props.value):this.state.value?n.push(...this.state.value):this.props.defaultValue&&n.push(...this.props.defaultValue),n}get name(){return this.props.name}get validity(){const n=this.props.validationMessage!==void 0,t=!this.required||this.value!==null&&this.value.length>0&&this.value!==void 0,e=this.props.valid!==void 0?this.props.valid:t;return{customError:n,valid:e,valueMissing:this.value===null}}get required(){return this.props.required!==void 0?this.props.required:b.defaultProps.required}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:b.defaultProps.validityStyles}componentDidUpdate(n,t){var g;const{virtual:e,groupField:o=""}=this.props,s=m.getFilteredData(this.props),a=e?e.skip:0,p=n.virtual?n.virtual.total:0,u=n.opened!==void 0?n.opened:t.opened,r=!u&&this.opened,i=u&&!this.opened,d=this.base.getPopupSettings();if(this.base.didUpdate(),!d.animate&&i&&this.onPopupClosed(),e&&e.total!==p)this.base.vs.calcScrollElementHeight(),this.base.vs.reset();else{let{focusedItem:l,focusedIndex:c}=this.getFocusedState();o!==""&&(c=(g=this.base.getGroupedDataModernMode(s,o))==null?void 0:g.indexOf(l)),r&&e?this.base.scrollToVirtualItem(e,c-a):r&&!e?(s&&s.length!==0&&this.base.resetGroupStickyHeader(s[0][o],this),this.base.scrollToItem(c)):this.opened&&u&&l&&this.scrollToFocused&&this.base.scrollToItem(c-a)}this.scrollToFocused=!1,this.setValidity()}componentDidMount(){var n;this.observerResize=h.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(this.calculateMedia.bind(this)),this.base.didMount(),this.setValidity(),(n=this.document)!=null&&n.body&&this.observerResize&&this.observerResize.observe(this.document.body)}componentWillUnmount(){var n;(n=this.document)!=null&&n.body&&this.observerResize&&this.observerResize.disconnect()}onNavigate(n,t,e){const{allowCustom:o}=this.props,s=m.getFilteredData(this.props),a=this.props.filter!==void 0?this.props.filter:this.state.text,{focusedType:p,focusedIndex:u}=this.getFocusedState(),r=o&&a,i=_(p),d=this.base,g=d.vs;if(this.opened&&t===h.Keys.up&&i)this.state.focusedIndex!==void 0&&(n.data.focusedIndex=void 0);else{const l=d.navigation.navigate({keyCode:t,current:u,max:(g.enabled?g.total:s.length)-1,min:r?-1:0,skipItems:e||void 0});l!==void 0&&(this.itemFocus(l,n),this.scrollToFocused=!0)}this.applyState(n)}render(){const{style:n,className:t,label:e,dir:o,disabled:s,textField:a,dataItemKey:p,virtual:u,size:r,rounded:i,fillMode:d,loading:g,filter:l}=this.props,{text:c,focused:y,focusedTag:C,currentValue:q}=this.state,k=this.base.vs,T=this.props.id||this._inputId;k.enabled=u!==void 0,u!==void 0&&(k.skip=u.skip,k.total=u.total,k.pageSize=u.pageSize);const x=this.mobileMode&&this.opened?q:this.tagsToRender;this.setItems(this.tagsToRender,this._tags);const M=!this.validityStyles||this.validity.valid,L=!!(l!==void 0?l:c)||x&&x.length>0,[B,V]=E(this.props.prefix||f.Fragment),[z,A]=E(this.props.suffix||f.Fragment),O=f.createElement(f.Fragment,null,f.createElement("div",{ref:this.componentRef,className:h.classNames("k-multiselect k-input",t,{[`k-input-${w[r]||r}`]:r,[`k-rounded-${ne[i]||i}`]:i,[`k-input-${d}`]:d,"k-focus":y&&!s,"k-invalid":!M,"k-disabled":s,"k-loading":g,"k-required":this.required}),style:e?{...n,width:void 0}:n,dir:o,onFocus:this.handleFocus,onBlur:this.handleBlur,onClick:this.handleWrapperClick,onMouseDown:m.preventDefaultNonInputs},this.props.prefix&&f.createElement(B,{...V}),f.createElement("div",{className:h.classNames("k-input-values")},f.createElement("div",{className:h.classNames("k-chip-list",{[`k-chip-list-${w[r]||r}`]:r}),role:"listbox",id:"tagslist-"+this.base.guid},x&&x.length>0&&f.createElement(J,{tagRender:this.props.tagRender,onTagDelete:this.onTagDelete,data:x,guid:this.base.guid,focused:C?x.find(H=>m.matchTags(H,C,p)):void 0,size:r})),this.renderSearchBar(T)),g&&f.createElement(h.IconWrap,{className:"k-input-loading-icon",name:"loading"}),this.props.suffix&&f.createElement(z,{...A}),L&&f.createElement(Z,{onClick:this.clearButtonClick}),!this.mobileMode&&this.renderListContainer()),this.mobileMode&&this.renderAdaptiveListContainer());return e?f.createElement(U.FloatingLabel,{label:e,editorId:T,editorValue:c||m.getItemValue(this.value[0],a),editorValid:M,editorDisabled:s,style:{width:n?n.width:void 0},children:O}):O}renderSearchBar(n){const{activedescendant:t,focusedTag:e,currentValue:o}=this.state,{disabled:s,placeholder:a,ariaDescribedBy:p,ariaLabelledBy:u,ariaLabel:r}=this.props,i=!this.mobileMode&&(this.props.filter!==void 0?this.props.filter:this.state.text)||"",{focusedIndex:d}=this.getFocusedState(),g=this.value.length===0&&!i?a:void 0,l=o&&o.length>0?void 0:a,c=t===D.ActiveDescendant.TagsList&&e!==void 0?`tag-${this.base.guid}-${e.text.replace(/\s+/g,"-")}`:`option-${this.base.guid}-${d}`,y={accessKey:this.props.accessKey,tabIndex:this.props.tabIndex};return f.createElement(Q,{id:n,size:Math.max((g||"").length,i.length,1),placeholder:this.mobileMode&&this.opened?l:g,value:i,onChange:this.onChangeHandler,onKeyDown:this.onInputKeyDown,ref:this.searchbarRef,disabled:s,expanded:this.opened,owns:this.base.listBoxId,role:"combobox",activedescendant:c,ariaDescribedBy:`tagslist-${this.base.guid}${p?" "+p:""}`,ariaLabelledBy:u,ariaRequired:this.required,ariaLabel:r,...y})}onTagsNavigate(n,t){const e=n.keyCode,{focusedTag:o}=this.state,s=this._tags,a=this.props.dataItemKey;let p=o?s.findIndex(i=>m.matchTags(i,o,a)):-1,u;const r=p!==-1;if(e===h.Keys.left)r?p=Math.max(0,p-1):p=s.length-1,u=s[p];else if(e===h.Keys.right)p===s.length-1?u=void 0:r&&(p=Math.min(s.length-1,p+1),u=s[p]);else if(e===h.Keys.home&&!n.shiftKey)u=s[0];else if(e===h.Keys.end&&!n.shiftKey)u=s[s.length-1];else if(e===h.Keys.delete){if(r){const i=this.value;m.removeDataItems(i,s[p].data,a),this.triggerOnChange(i,t)}}else if(e===h.Keys.backspace){const i=this.value;if(r)m.removeDataItems(i,s[p].data,a),this.triggerOnChange(i,t);else if(!r&&s.length){const d=s.pop();m.removeDataItems(i,d.data,a),this.triggerOnChange(i,t)}}u!==o&&(t.data.focusedTag=u,t.data.activedescendant=D.ActiveDescendant.TagsList),this.applyState(t)}triggerOnChange(n,t){this.props.value===void 0&&(t.data.value=[...n]),this._valueItemsDuringOnChange=[],this.setItems(n,this._valueItemsDuringOnChange),t.events.push({type:"onChange"})}selectFocusedItem(n,t){const{virtual:e}=this.props,o=m.getFilteredData(this.props),{focusedIndex:s}=t||this.getFocusedState(),a=e?e.skip:0;o[s-a]!==void 0&&this.handleItemClick(s,n)}setItems(n,t){t.length=0,t.push(...n)}getFocusedState(){const{focusedIndex:n}=this.state,t=this.props.filter!==void 0?this.props.filter:this.state.text,{allowCustom:e,dataItemKey:o,virtual:s,textField:a,focusedItemIndex:p=m.itemIndexStartsWith,skipDisabledItems:u}=this.props,r=m.getFilteredData(this.props),i=s&&s.skip||0;let d;if(n!==void 0)return{focusedIndex:n,focusedItem:r[n-i],focusedType:1};const g=this.value;if(e&&t)return{focusedItem:null,focusedIndex:-1,focusedType:2};if(t)return d=p(r,t,a),{focusedItem:r[d],focusedIndex:d+i,focusedType:1};if(g.length){const l=g[g.length-1];return d=r.findIndex(c=>m.areSame(c,l,o)),r[d]!==void 0?{focusedIndex:d+i,focusedItem:r[d],focusedType:1}:{focusedType:0,focusedIndex:-1}}else if(u&&a&&!t&&i===0){const l=r.findIndex(c=>!c.disabled&&c[a]);return{focusedIndex:l,focusedItem:r[l-i],focusedType:1}}return i===0?{focusedItem:r[0],focusedIndex:0,focusedType:1}:{focusedType:0,focusedIndex:-1}}focusElement(n){this._skipFocusEvent=!0,n.focus(),window.setTimeout(()=>this._skipFocusEvent=!1,0)}applyState(n){this.base.applyState(n),this._valueItemsDuringOnChange=null}calculateMedia(n){for(const t of n)this.setState({windowWidth:t.target.clientWidth})}updateStateOnKeyboardNavigation(n,t){this.setState({value:n}),this.triggerOnChange(n,t),this.applyState(t)}getLastSelectedOrDeselectedIndex(n,t){return this._lastSelectedOrDeslectedItemIndex===null&&(this._lastSelectedOrDeslectedItemIndex=t),this._lastSelectedOrDeslectedItemIndex!==null?this._lastSelectedOrDeslectedItemIndex+n:null}};b.displayName="MultiSelect",b.propTypes={...K.propTypes,autoClose:v.bool,value:v.arrayOf(v.any),defaultValue:v.arrayOf(v.any),dataItemKey:v.string,placeholder:v.string,tags:v.arrayOf(v.shape({text:v.string,data:v.arrayOf(v.any)})),tagRender:v.func,id:v.string,ariaLabelledBy:v.string,ariaDescribedBy:v.string,groupField:v.string,list:v.any,adaptive:v.bool,adaptiveTitle:v.string,onCancel:v.func,skipDisabledItems:v.bool},b.defaultProps={...K.defaultProps,autoClose:!0,required:!1,size:"medium",rounded:"medium",fillMode:"solid",groupMode:"modern",skipDisabledItems:!0,prefix:void 0,suffix:void 0};let F=b;const N=h.createPropsContext(),R=h.withIdHOC(h.withPropsContext(N,F));R.displayName="KendoReactMultiSelect";exports.MultiSelect=R;exports.MultiSelectPropsContext=N;exports.MultiSelectWithoutContext=F;
|
|
@@ -223,7 +223,7 @@ const { sizeMap: D, roundedMap: yt } = st, bt = "Please enter a valid value!", $
|
|
|
223
223
|
onApply: this.closePopup
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
|
-
return /* @__PURE__ */ f.createElement(ft, { ...c }, /* @__PURE__ */ f.createElement(gt, {
|
|
226
|
+
return /* @__PURE__ */ f.createElement(ft, { ...c }, /* @__PURE__ */ f.createElement(gt, { overflowHidden: !0 }, /* @__PURE__ */ f.createElement("div", { className: "k-list-container" }, this.listContainerContent())));
|
|
227
227
|
}, this.closePopup = (e) => {
|
|
228
228
|
const t = this.base.initState();
|
|
229
229
|
t.syntheticEvent = e, e.stopPropagation(), this.state.focusedIndex !== void 0 && (t.data.focusedIndex = void 0), this.opened && this.base.togglePopup(t), t.events.push({ type: "onClose" });
|
|
@@ -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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("react"),a=require("prop-types"),i=require("@progress/kendo-react-common"),et=require("@progress/kendo-react-popup"),tt=require("@progress/kendo-react-intl"),we=require("@progress/kendo-react-treeview"),nt=require("../package-metadata.js"),ee=require("../common/utils.js"),at=require("../DropDownTree/useDropdownWidth.js"),rt=require("../DropDownTree/ListNoData.js"),m=require("../messages/index.js"),it=require("@progress/kendo-react-labels"),st=require("../MultiSelect/TagList.js"),ot=require("../common/ClearButton.js"),Ie=require("../common/ListFilter.js"),lt=require("../common/AdaptiveMode.js"),ct=require("@progress/kendo-react-layout"),ut=require("../common/constants.js");function dt(h){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const n in h)if(n!=="default"){const I=Object.getOwnPropertyDescriptor(h,n);Object.defineProperty(b,n,I.get?I:{enumerable:!0,get:()=>h[n]})}}return b.default=h,Object.freeze(b)}const t=dt(Ze),pt="Please select a value from the list!",{sizeMap:Te,roundedMap:ft}=i.kendoThemeMaps,gt=h=>h.split("_").map(b=>parseInt(b,10)),vt=(h,b)=>{const{validationMessage:n,valid:I,required:T}=h;return{customError:n!==void 0,valid:!!(I!==void 0?I:!T||b),valueMissing:!b}},E={checkField:"checkField",checkIndeterminateField:"checkIndeterminateField",subItemsField:"items",popupSettings:{animate:!0,width:"200px",height:"200px"},size:"medium",rounded:"medium",fillMode:"solid",required:!1,validityStyles:!0},Me=i.createPropsContext(),ce=t.forwardRef((h,b)=>{const n=i.usePropsContext(Me,h);i.validatePackage(nt.packageMetadata);const I=i.useId(),T=n.id||I,{data:B=[],dataItemKey:M,style:L={},placeholder:ue,label:V,name:Ke,validationMessage:W,valid:Re,tags:de,value:g,opened:K,disabled:x,popupSettings:N=E.popupSettings,checkField:pe=E.checkField,checkIndeterminateField:fe=E.checkIndeterminateField,subItemsField:ge=E.subItemsField,size:y=E.size,rounded:A=E.rounded,fillMode:z=E.fillMode,required:ve=E.required,validityStyles:De=E.validityStyles,onOpen:te=i.noop,onClose:_=i.noop}=n,j=i.getTabIndex(n.tabIndex,x),o=t.useRef(null),F=t.useRef(null),R=t.useRef(null),ne=t.useRef(null),$=t.useRef(null),S=t.useRef(null),H=t.useRef(!1),G=t.useRef([]),U=t.useRef(null),[O,qe]=t.useState(),[Ne,me]=t.useState(!1),[d,ae]=t.useState(!1),[re,Oe]=t.useState(),[Pe,Le]=t.useState([]),[he,Ve]=t.useState(""),P=!!(re&&re<=ut.MOBILE_MEDIUM_DEVISE&&n.adaptive),l=K!==void 0?K:Ne,ie=!!(Array.isArray(g)&&g.length),se=vt({validationMessage:W,valid:Re,required:ve},ie),D=i.useRtl(F,n.dir),Ae={width:at.useDropdownWidth(F,E,N,L),...D!==void 0?{direction:D}:{}},Be=t.useCallback(()=>F.current&&F.current.focus(),[]);G.current=de===void 0?(g||[]).map(e=>({text:ee.getItemValue(e,n.textField),data:[e]})):[...de],t.useImperativeHandle(o,()=>({props:n,element:F.current,focus:Be})),t.useImperativeHandle(b,()=>o.current);const We=t.useCallback(()=>{$.current&&$.current.setCustomValidity&&$.current.setCustomValidity(se.valid?"":W===void 0?pt:W)},[W,se]);t.useEffect(We),t.useEffect(()=>{const e=i.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(Xe.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{e&&e.disconnect()}},[]),t.useEffect(()=>{U.current&&l&&U.current.setPosition(U.current._popup)},[g,l]);const w=t.useCallback((e,r,s)=>{if(n.onChange){const k={items:r,operation:s,...e};n.onChange.call(void 0,k)}},[n.onChange]),J=t.useCallback(e=>{if(ee.areSame(e.item,g,M)||!o.current)return;const{item:r,nativeEvent:s,syntheticEvent:k}=e,q={syntheticEvent:k,nativeEvent:s,target:o.current};w(q,[r],"toggle")},[g,M,w]),Q=t.useCallback(e=>{if(!l){if(te){const r={...e};te.call(void 0,r)}K===void 0&&(me(!0),Le(g||[]),P&&setTimeout(()=>{var r;u((r=ne.current)==null?void 0:r.element)},300))}},[l,K,te,P,ne]),v=t.useCallback(e=>{if(l){if(_){const r={...e};_.call(void 0,r)}K===void 0&&me(!1)}},[l,K,_]),C=t.useCallback(e=>{H.current=!0,e(),window.setTimeout(()=>H.current=!1,0)},[]),u=t.useCallback(e=>{e&&C(()=>e.focus())},[C]),ze=t.useCallback(()=>{var e;!d&&l?v({target:o.current}):n.filterable?u((e=R.current)==null?void 0:e.element):u(S.current&&S.current.element)},[d,l,u,v,n.filterable]),_e=t.useCallback(()=>{d&&u(F.current)},[d,u]),je=t.useCallback(e=>{if(!d&&!H.current&&(ae(!0),n.onFocus&&o.current)){const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};n.onFocus.call(void 0,r)}},[d,n.onFocus]),$e=t.useCallback(e=>{if(d&&!H.current&&o.current){ae(!1);const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};if(n.onBlur){const s={...r};n.onBlur.call(void 0,s)}P||v(r)}},[d,n.onBlur,l,K,_]),He=t.useCallback(()=>{d&&C(i.noop)},[d,C]),Ge=t.useCallback(e=>{if(!e.isDefaultPrevented()&&o.current){ae(!0);const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};l||Q(r)}},[l,Q]),Ue=t.useCallback(e=>{var Z,Se;const{keyCode:r,altKey:s}=e,k=S.current&&S.current.element;if(!o.current||e.isDefaultPrevented()&&((Z=R.current)==null?void 0:Z.element)===e.target)return;const q={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};if(g&&g.length>0&&(r===i.Keys.left||r===i.Keys.right||r===i.Keys.home||r===i.Keys.end||r===i.Keys.delete)){const c=G.current;let p=O?c.findIndex(Ye=>ee.matchTags(Ye,O,M)):-1,f;const le=p!==-1;r===i.Keys.left?(le?p=Math.max(0,p-1):p=c.length-1,f=c[p]):r===i.Keys.right?p===c.length-1?f=void 0:le&&(p=Math.min(c.length-1,p+1),f=c[p]):r===i.Keys.home?f=c[0]:r===i.Keys.end?f=c[c.length-1]:r===i.Keys.delete&&le&&w(q,c[p].data,"delete"),f!==O&&qe(f)}if(l)if(r===i.Keys.esc||s&&r===i.Keys.up)e.preventDefault(),v(q);else if(k&&k.querySelector(".k-focus")&&(r===i.Keys.up||r===i.Keys.down||r===i.Keys.left||r===i.Keys.right||r===i.Keys.home||r===i.Keys.end)){if(r===i.Keys.up&&((Se=R.current)!=null&&Se.element)){const c=Array.from(k.querySelectorAll(".k-treeview-item")),p=[...c].reverse().find(f=>!!(f&&f.querySelector(".k-focus")));if(p&&c.indexOf(p)===0)return C(()=>{var f;u((f=R.current)==null?void 0:f.element)})}C(i.noop)}else r===i.Keys.down&&C(()=>{var c;u(((c=R.current)==null?void 0:c.element)||k)});else s&&r===i.Keys.down&&(e.preventDefault(),Q(q))},[l,v,u,C,Q,O,M,g,w]),ye=t.useCallback(e=>{const{keyCode:r,altKey:s}=e;s||r!==i.Keys.up&&r!==i.Keys.down||(e.preventDefault(),C(r===i.Keys.up?()=>{u(F.current)}:()=>{u(S.current&&S.current.element)}))},[u,C]),oe=t.useCallback(e=>{if(!o.current)return;const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};w(r,[],"clear"),v(r),e.preventDefault()},[w,v]),Je=t.useCallback((e,r)=>{var s;v({target:o.current}),d||u((s=R.current)==null?void 0:s.element),w({syntheticEvent:r,nativeEvent:r.nativeEvent,target:o.current},e,"delete")},[w,v,u,d]),be=t.useCallback(e=>{if(n.onExpandChange&&o.current){const{item:r,itemHierarchicalIndex:s,nativeEvent:k,syntheticEvent:q}=e,Z={level:gt(s),item:r,nativeEvent:k,syntheticEvent:q,target:o.current};n.onExpandChange.call(void 0,Z)}},[n.onExpandChange]),Ce=t.useCallback(e=>{if(n.onFilterChange&&o.current){const s={filter:{field:n.textField,operator:"contains",value:e.target.value},syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,target:o.current};n.onFilterChange.call(void 0,s),n.filter===void 0&&Ve(e.target.value)}},[n.onFilterChange,n.filter,n.textField]),ke=t.useCallback(e=>{if(!o.current)return;const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};n.onCancel&&n.onCancel.call(void 0,r),v(r),e.preventDefault()},[n.onCancel,v]),Qe=()=>{const e=n.filterable?t.createElement(Ie,{value:n.filter===void 0?he:n.filter,ref:ne,onChange:Ce,onKeyDown:ye,size:y,rounded:A,fillMode:z}):null,r={adaptiveTitle:n.adaptiveTitle,expand:l,onClose:s=>n.onCancel?ke(s):oe(s),windowWidth:re,mobileFilter:e,footer:{cancelText:X.toLanguageString(m.adaptiveModeFooterCancel,m.messages[m.adaptiveModeFooterCancel]),onCancel:s=>n.onCancel?ke(s):oe(s),applyText:X.toLanguageString(m.adaptiveModeFooterApply,m.messages[m.adaptiveModeFooterApply]),onApply:s=>v(s)}};return t.createElement(lt.AdaptiveMode,{...r},t.createElement(ct.ActionSheetContent,{className:"!k-overflow-hidden"},t.createElement("div",{className:"k-list-container"},t.createElement("div",{className:"k-list k-list-lg"},B.length>0?t.createElement(we.TreeView,{ref:S,tabIndex:j,data:B,focusIdField:M,textField:n.textField,checkField:pe,checkIndeterminateField:fe,expandField:n.expandField,childrenField:ge,expandIcons:!0,onItemClick:J,onCheckChange:J,onExpandChange:be,checkboxes:!0,size:y,item:n.item,dir:D}):t.createElement(Ee,null,X.toLanguageString(m.nodata,m.messages[m.nodata]))))))},Xe=t.useCallback(e=>{for(let r of e)Oe(r.target.clientWidth)},[]),Ee=n.listNoData||rt.ListNoData,X=tt.useLocalization(),Fe=!De||se.valid,Y=P&&l?Pe:G.current,xe=t.createElement(t.Fragment,null,t.createElement("span",{className:i.classNames("k-multiselecttree k-input",n.className,{[`k-input-${Te[y]||y}`]:y,[`k-rounded-${ft[A]||A}`]:A,[`k-input-${z}`]:z,"k-focus":d&&!x,"k-invalid":!Fe,"k-disabled":x,"k-loading":n.loading,"k-required":ve}),tabIndex:j,accessKey:n.accessKey,id:T,style:V?{...L,width:void 0}:L,dir:D,ref:F,onKeyDown:x?void 0:Ue,onMouseDown:He,onFocus:je,onBlur:$e,role:"combobox","aria-haspopup":"tree","aria-expanded":l,"aria-disabled":x,"aria-label":V,"aria-labelledby":n.ariaLabelledBy,"aria-describedby":n.ariaDescribedBy?n.ariaDescribedBy:"tagslist-"+T,"aria-required":n.required,onClick:x?void 0:Ge},t.createElement("div",{id:"tagslist-"+T,className:i.classNames("k-input-values k-chip-list",{[`k-chip-list-${Te[y]||y}`]:y})},Y.length>0&&t.createElement(st,{tag:n.tag,onTagDelete:Je,data:Y,guid:T,focused:O?G.current.find(e=>ee.matchTags(e,O,M)):void 0,size:y})),t.createElement("span",{className:"k-input-inner"},Y.length===0&&t.createElement("span",{className:"k-input-value-text"},ue)),n.loading&&t.createElement(i.IconWrap,{className:"k-input-loading-icon",name:"loading"}),ie&&!x&&Y.length>0&&t.createElement(ot,{onClick:oe}),t.createElement("select",{name:Ke,ref:$,tabIndex:-1,"aria-hidden":!0,title:V,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},t.createElement("option",{value:n.valueMap?n.valueMap.call(void 0,g):g})),!P&&t.createElement(et.Popup,{...N,popupClass:i.classNames(N.popupClass,"k-multiselecttree-popup"),className:i.classNames(N.className,{"k-rtl":D==="rtl"}),style:Ae,anchor:N.anchor||F.current,show:l,onOpen:ze,onClose:_e,ref:U},n.filterable&&t.createElement(Ie,{value:n.filter===void 0?he:n.filter,ref:R,onChange:Ce,onKeyDown:ye,tabIndex:j,size:y,rounded:A,fillMode:z,renderListFilterWrapper:!0,renderPrefixSeparator:!0}),B.length>0?t.createElement(we.TreeView,{style:{height:N.height},ref:S,tabIndex:j,data:B,focusIdField:M,textField:n.textField,checkField:pe,checkIndeterminateField:fe,expandField:n.expandField,childrenField:ge,expandIcons:!0,onItemClick:J,onCheckChange:J,onExpandChange:be,checkboxes:!0,size:y,item:n.item,dir:D}):t.createElement(Ee,null,X.toLanguageString(m.nodata,m.messages[m.nodata])))),P&&Qe());return V?t.createElement(it.FloatingLabel,{label:V,editorValue:ie,editorPlaceholder:ue,editorValid:Fe,editorDisabled:x,editorId:T,style:{width:L?L.width:void 0},children:xe,dir:D}):xe}),mt={opened:a.bool,disabled:a.bool,dir:a.string,tabIndex:a.number,accessKey:a.string,data:a.array,value:a.any,valueMap:a.func,placeholder:a.string,dataItemKey:a.string.isRequired,textField:a.string.isRequired,checkField:a.string,checkIndeterminateField:a.string,expandField:a.string,subItemsField:a.string,className:a.string,style:a.object,label:a.string,validationMessage:a.string,validityStyles:a.bool,valid:a.bool,required:a.bool,name:a.string,id:a.string,ariaLabelledBy:a.string,ariaDescribedBy:a.string,filterable:a.bool,filter:a.string,loading:a.bool,tags:a.arrayOf(a.shape({text:a.string,data:a.arrayOf(a.any)})),popupSettings:a.shape({animate:a.oneOfType([a.bool,a.shape({openDuration:a.number,closeDuration:a.number})]),popupClass:a.string,className:a.string,appendTo:a.any,width:a.oneOfType([a.string,a.number]),height:a.oneOfType([a.string,a.number])}),onOpen:a.func,onClose:a.func,onFocus:a.func,onBlur:a.func,onChange:a.func,onFilterChange:a.func,onExpandChange:a.func,onCancel:a.func,item:a.func,listNoData:a.func,adaptiveTitle:a.string,adaptive:a.bool};ce.displayName="KendoReactMultiSelectTree";ce.propTypes=mt;exports.MultiSelectTree=ce;exports.MultiSelectTreePropsContext=Me;
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("react"),a=require("prop-types"),i=require("@progress/kendo-react-common"),et=require("@progress/kendo-react-popup"),tt=require("@progress/kendo-react-intl"),we=require("@progress/kendo-react-treeview"),nt=require("../package-metadata.js"),ee=require("../common/utils.js"),at=require("../DropDownTree/useDropdownWidth.js"),rt=require("../DropDownTree/ListNoData.js"),m=require("../messages/index.js"),it=require("@progress/kendo-react-labels"),st=require("../MultiSelect/TagList.js"),ot=require("../common/ClearButton.js"),Ie=require("../common/ListFilter.js"),lt=require("../common/AdaptiveMode.js"),ct=require("@progress/kendo-react-layout"),ut=require("../common/constants.js");function dt(h){const b=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const n in h)if(n!=="default"){const I=Object.getOwnPropertyDescriptor(h,n);Object.defineProperty(b,n,I.get?I:{enumerable:!0,get:()=>h[n]})}}return b.default=h,Object.freeze(b)}const t=dt(Ze),pt="Please select a value from the list!",{sizeMap:Te,roundedMap:ft}=i.kendoThemeMaps,gt=h=>h.split("_").map(b=>parseInt(b,10)),vt=(h,b)=>{const{validationMessage:n,valid:I,required:T}=h;return{customError:n!==void 0,valid:!!(I!==void 0?I:!T||b),valueMissing:!b}},E={checkField:"checkField",checkIndeterminateField:"checkIndeterminateField",subItemsField:"items",popupSettings:{animate:!0,width:"200px",height:"200px"},size:"medium",rounded:"medium",fillMode:"solid",required:!1,validityStyles:!0},Me=i.createPropsContext(),ce=t.forwardRef((h,b)=>{const n=i.usePropsContext(Me,h);i.validatePackage(nt.packageMetadata);const I=i.useId(),T=n.id||I,{data:B=[],dataItemKey:M,style:L={},placeholder:ue,label:V,name:Ke,validationMessage:W,valid:Re,tags:de,value:g,opened:K,disabled:x,popupSettings:N=E.popupSettings,checkField:pe=E.checkField,checkIndeterminateField:fe=E.checkIndeterminateField,subItemsField:ge=E.subItemsField,size:y=E.size,rounded:A=E.rounded,fillMode:z=E.fillMode,required:ve=E.required,validityStyles:De=E.validityStyles,onOpen:te=i.noop,onClose:_=i.noop}=n,j=i.getTabIndex(n.tabIndex,x),o=t.useRef(null),F=t.useRef(null),R=t.useRef(null),ne=t.useRef(null),H=t.useRef(null),S=t.useRef(null),$=t.useRef(!1),G=t.useRef([]),U=t.useRef(null),[O,qe]=t.useState(),[Ne,me]=t.useState(!1),[d,ae]=t.useState(!1),[re,Oe]=t.useState(),[Pe,Le]=t.useState([]),[he,Ve]=t.useState(""),P=!!(re&&re<=ut.MOBILE_MEDIUM_DEVISE&&n.adaptive),l=K!==void 0?K:Ne,ie=!!(Array.isArray(g)&&g.length),se=vt({validationMessage:W,valid:Re,required:ve},ie),D=i.useRtl(F,n.dir),Ae={width:at.useDropdownWidth(F,E,N,L),...D!==void 0?{direction:D}:{}},Be=t.useCallback(()=>F.current&&F.current.focus(),[]);G.current=de===void 0?(g||[]).map(e=>({text:ee.getItemValue(e,n.textField),data:[e]})):[...de],t.useImperativeHandle(o,()=>({props:n,element:F.current,focus:Be})),t.useImperativeHandle(b,()=>o.current);const We=t.useCallback(()=>{H.current&&H.current.setCustomValidity&&H.current.setCustomValidity(se.valid?"":W===void 0?pt:W)},[W,se]);t.useEffect(We),t.useEffect(()=>{const e=i.canUseDOM&&window.ResizeObserver&&new window.ResizeObserver(Xe.bind(void 0));return document!=null&&document.body&&e&&e.observe(document.body),()=>{e&&e.disconnect()}},[]),t.useEffect(()=>{U.current&&l&&U.current.setPosition(U.current._popup)},[g,l]);const w=t.useCallback((e,r,s)=>{if(n.onChange){const k={items:r,operation:s,...e};n.onChange.call(void 0,k)}},[n.onChange]),J=t.useCallback(e=>{if(ee.areSame(e.item,g,M)||!o.current)return;const{item:r,nativeEvent:s,syntheticEvent:k}=e,q={syntheticEvent:k,nativeEvent:s,target:o.current};w(q,[r],"toggle")},[g,M,w]),Q=t.useCallback(e=>{if(!l){if(te){const r={...e};te.call(void 0,r)}K===void 0&&(me(!0),Le(g||[]),P&&setTimeout(()=>{var r;u((r=ne.current)==null?void 0:r.element)},300))}},[l,K,te,P,ne]),v=t.useCallback(e=>{if(l){if(_){const r={...e};_.call(void 0,r)}K===void 0&&me(!1)}},[l,K,_]),C=t.useCallback(e=>{$.current=!0,e(),window.setTimeout(()=>$.current=!1,0)},[]),u=t.useCallback(e=>{e&&C(()=>e.focus())},[C]),ze=t.useCallback(()=>{var e;!d&&l?v({target:o.current}):n.filterable?u((e=R.current)==null?void 0:e.element):u(S.current&&S.current.element)},[d,l,u,v,n.filterable]),_e=t.useCallback(()=>{d&&u(F.current)},[d,u]),je=t.useCallback(e=>{if(!d&&!$.current&&(ae(!0),n.onFocus&&o.current)){const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};n.onFocus.call(void 0,r)}},[d,n.onFocus]),He=t.useCallback(e=>{if(d&&!$.current&&o.current){ae(!1);const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};if(n.onBlur){const s={...r};n.onBlur.call(void 0,s)}P||v(r)}},[d,n.onBlur,l,K,_]),$e=t.useCallback(()=>{d&&C(i.noop)},[d,C]),Ge=t.useCallback(e=>{if(!e.isDefaultPrevented()&&o.current){ae(!0);const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};l||Q(r)}},[l,Q]),Ue=t.useCallback(e=>{var Z,Se;const{keyCode:r,altKey:s}=e,k=S.current&&S.current.element;if(!o.current||e.isDefaultPrevented()&&((Z=R.current)==null?void 0:Z.element)===e.target)return;const q={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};if(g&&g.length>0&&(r===i.Keys.left||r===i.Keys.right||r===i.Keys.home||r===i.Keys.end||r===i.Keys.delete)){const c=G.current;let p=O?c.findIndex(Ye=>ee.matchTags(Ye,O,M)):-1,f;const le=p!==-1;r===i.Keys.left?(le?p=Math.max(0,p-1):p=c.length-1,f=c[p]):r===i.Keys.right?p===c.length-1?f=void 0:le&&(p=Math.min(c.length-1,p+1),f=c[p]):r===i.Keys.home?f=c[0]:r===i.Keys.end?f=c[c.length-1]:r===i.Keys.delete&&le&&w(q,c[p].data,"delete"),f!==O&&qe(f)}if(l)if(r===i.Keys.esc||s&&r===i.Keys.up)e.preventDefault(),v(q);else if(k&&k.querySelector(".k-focus")&&(r===i.Keys.up||r===i.Keys.down||r===i.Keys.left||r===i.Keys.right||r===i.Keys.home||r===i.Keys.end)){if(r===i.Keys.up&&((Se=R.current)!=null&&Se.element)){const c=Array.from(k.querySelectorAll(".k-treeview-item")),p=[...c].reverse().find(f=>!!(f&&f.querySelector(".k-focus")));if(p&&c.indexOf(p)===0)return C(()=>{var f;u((f=R.current)==null?void 0:f.element)})}C(i.noop)}else r===i.Keys.down&&C(()=>{var c;u(((c=R.current)==null?void 0:c.element)||k)});else s&&r===i.Keys.down&&(e.preventDefault(),Q(q))},[l,v,u,C,Q,O,M,g,w]),ye=t.useCallback(e=>{const{keyCode:r,altKey:s}=e;s||r!==i.Keys.up&&r!==i.Keys.down||(e.preventDefault(),C(r===i.Keys.up?()=>{u(F.current)}:()=>{u(S.current&&S.current.element)}))},[u,C]),oe=t.useCallback(e=>{if(!o.current)return;const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};w(r,[],"clear"),v(r),e.preventDefault()},[w,v]),Je=t.useCallback((e,r)=>{var s;v({target:o.current}),d||u((s=R.current)==null?void 0:s.element),w({syntheticEvent:r,nativeEvent:r.nativeEvent,target:o.current},e,"delete")},[w,v,u,d]),be=t.useCallback(e=>{if(n.onExpandChange&&o.current){const{item:r,itemHierarchicalIndex:s,nativeEvent:k,syntheticEvent:q}=e,Z={level:gt(s),item:r,nativeEvent:k,syntheticEvent:q,target:o.current};n.onExpandChange.call(void 0,Z)}},[n.onExpandChange]),Ce=t.useCallback(e=>{if(n.onFilterChange&&o.current){const s={filter:{field:n.textField,operator:"contains",value:e.target.value},syntheticEvent:e.syntheticEvent,nativeEvent:e.nativeEvent,target:o.current};n.onFilterChange.call(void 0,s),n.filter===void 0&&Ve(e.target.value)}},[n.onFilterChange,n.filter,n.textField]),ke=t.useCallback(e=>{if(!o.current)return;const r={syntheticEvent:e,nativeEvent:e.nativeEvent,target:o.current};n.onCancel&&n.onCancel.call(void 0,r),v(r),e.preventDefault()},[n.onCancel,v]),Qe=()=>{const e=n.filterable?t.createElement(Ie,{value:n.filter===void 0?he:n.filter,ref:ne,onChange:Ce,onKeyDown:ye,size:y,rounded:A,fillMode:z}):null,r={adaptiveTitle:n.adaptiveTitle,expand:l,onClose:s=>n.onCancel?ke(s):oe(s),windowWidth:re,mobileFilter:e,footer:{cancelText:X.toLanguageString(m.adaptiveModeFooterCancel,m.messages[m.adaptiveModeFooterCancel]),onCancel:s=>n.onCancel?ke(s):oe(s),applyText:X.toLanguageString(m.adaptiveModeFooterApply,m.messages[m.adaptiveModeFooterApply]),onApply:s=>v(s)}};return t.createElement(lt.AdaptiveMode,{...r},t.createElement(ct.ActionSheetContent,{overflowHidden:!0},t.createElement("div",{className:"k-list-container"},t.createElement("div",{className:"k-list k-list-lg"},B.length>0?t.createElement(we.TreeView,{ref:S,tabIndex:j,data:B,focusIdField:M,textField:n.textField,checkField:pe,checkIndeterminateField:fe,expandField:n.expandField,childrenField:ge,expandIcons:!0,onItemClick:J,onCheckChange:J,onExpandChange:be,checkboxes:!0,size:y,item:n.item,dir:D}):t.createElement(Ee,null,X.toLanguageString(m.nodata,m.messages[m.nodata]))))))},Xe=t.useCallback(e=>{for(let r of e)Oe(r.target.clientWidth)},[]),Ee=n.listNoData||rt.ListNoData,X=tt.useLocalization(),Fe=!De||se.valid,Y=P&&l?Pe:G.current,xe=t.createElement(t.Fragment,null,t.createElement("span",{className:i.classNames("k-multiselecttree k-input",n.className,{[`k-input-${Te[y]||y}`]:y,[`k-rounded-${ft[A]||A}`]:A,[`k-input-${z}`]:z,"k-focus":d&&!x,"k-invalid":!Fe,"k-disabled":x,"k-loading":n.loading,"k-required":ve}),tabIndex:j,accessKey:n.accessKey,id:T,style:V?{...L,width:void 0}:L,dir:D,ref:F,onKeyDown:x?void 0:Ue,onMouseDown:$e,onFocus:je,onBlur:He,role:"combobox","aria-haspopup":"tree","aria-expanded":l,"aria-disabled":x,"aria-label":V,"aria-labelledby":n.ariaLabelledBy,"aria-describedby":n.ariaDescribedBy?n.ariaDescribedBy:"tagslist-"+T,"aria-required":n.required,onClick:x?void 0:Ge},t.createElement("div",{id:"tagslist-"+T,className:i.classNames("k-input-values k-chip-list",{[`k-chip-list-${Te[y]||y}`]:y})},Y.length>0&&t.createElement(st,{tag:n.tag,onTagDelete:Je,data:Y,guid:T,focused:O?G.current.find(e=>ee.matchTags(e,O,M)):void 0,size:y})),t.createElement("span",{className:"k-input-inner"},Y.length===0&&t.createElement("span",{className:"k-input-value-text"},ue)),n.loading&&t.createElement(i.IconWrap,{className:"k-input-loading-icon",name:"loading"}),ie&&!x&&Y.length>0&&t.createElement(ot,{onClick:oe}),t.createElement("select",{name:Ke,ref:H,tabIndex:-1,"aria-hidden":!0,title:V,style:{opacity:0,width:1,border:0,zIndex:-1,position:"absolute",left:"50%"}},t.createElement("option",{value:n.valueMap?n.valueMap.call(void 0,g):g})),!P&&t.createElement(et.Popup,{...N,popupClass:i.classNames(N.popupClass,"k-multiselecttree-popup"),className:i.classNames(N.className,{"k-rtl":D==="rtl"}),style:Ae,anchor:N.anchor||F.current,show:l,onOpen:ze,onClose:_e,ref:U},n.filterable&&t.createElement(Ie,{value:n.filter===void 0?he:n.filter,ref:R,onChange:Ce,onKeyDown:ye,tabIndex:j,size:y,rounded:A,fillMode:z,renderListFilterWrapper:!0,renderPrefixSeparator:!0}),B.length>0?t.createElement(we.TreeView,{style:{height:N.height},ref:S,tabIndex:j,data:B,focusIdField:M,textField:n.textField,checkField:pe,checkIndeterminateField:fe,expandField:n.expandField,childrenField:ge,expandIcons:!0,onItemClick:J,onCheckChange:J,onExpandChange:be,checkboxes:!0,size:y,item:n.item,dir:D}):t.createElement(Ee,null,X.toLanguageString(m.nodata,m.messages[m.nodata])))),P&&Qe());return V?t.createElement(it.FloatingLabel,{label:V,editorValue:ie,editorPlaceholder:ue,editorValid:Fe,editorDisabled:x,editorId:T,style:{width:L?L.width:void 0},children:xe,dir:D}):xe}),mt={opened:a.bool,disabled:a.bool,dir:a.string,tabIndex:a.number,accessKey:a.string,data:a.array,value:a.any,valueMap:a.func,placeholder:a.string,dataItemKey:a.string.isRequired,textField:a.string.isRequired,checkField:a.string,checkIndeterminateField:a.string,expandField:a.string,subItemsField:a.string,className:a.string,style:a.object,label:a.string,validationMessage:a.string,validityStyles:a.bool,valid:a.bool,required:a.bool,name:a.string,id:a.string,ariaLabelledBy:a.string,ariaDescribedBy:a.string,filterable:a.bool,filter:a.string,loading:a.bool,tags:a.arrayOf(a.shape({text:a.string,data:a.arrayOf(a.any)})),popupSettings:a.shape({animate:a.oneOfType([a.bool,a.shape({openDuration:a.number,closeDuration:a.number})]),popupClass:a.string,className:a.string,appendTo:a.any,width:a.oneOfType([a.string,a.number]),height:a.oneOfType([a.string,a.number])}),onOpen:a.func,onClose:a.func,onFocus:a.func,onBlur:a.func,onChange:a.func,onFilterChange:a.func,onExpandChange:a.func,onCancel:a.func,item:a.func,listNoData:a.func,adaptiveTitle:a.string,adaptive:a.bool};ce.displayName="KendoReactMultiSelectTree";ce.propTypes=mt;exports.MultiSelectTree=ce;exports.MultiSelectTreePropsContext=Me;
|