@progress/kendo-react-dropdowns 7.2.4-develop.3 → 7.3.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AutoComplete/AutoComplete.js +8 -0
- package/AutoComplete/AutoComplete.mjs +458 -0
- package/ComboBox/ComboBox.js +8 -0
- package/ComboBox/ComboBox.mjs +618 -0
- package/DropDownList/DropDownList.js +8 -0
- package/DropDownList/DropDownList.mjs +630 -0
- package/DropDownTree/DropDownTree.js +8 -0
- package/DropDownTree/DropDownTree.mjs +550 -0
- package/DropDownTree/ListNoData.js +8 -0
- package/DropDownTree/ListNoData.mjs +13 -0
- package/DropDownTree/useDropdownWidth.js +8 -0
- package/DropDownTree/useDropdownWidth.mjs +25 -0
- package/MultiColumnComboBox/MultiColumnComboBox.js +8 -0
- package/MultiColumnComboBox/MultiColumnComboBox.mjs +186 -0
- package/MultiSelect/MultiSelect.js +8 -0
- package/MultiSelect/MultiSelect.mjs +694 -0
- package/MultiSelect/TagList.js +8 -0
- package/MultiSelect/TagList.mjs +48 -0
- package/MultiSelectTree/MultiSelectTree.js +8 -0
- package/MultiSelectTree/MultiSelectTree.mjs +590 -0
- package/MultiSelectTree/utils.js +8 -0
- package/MultiSelectTree/utils.mjs +74 -0
- package/common/AdaptiveMode.js +8 -0
- package/common/AdaptiveMode.mjs +73 -0
- package/common/ClearButton.js +8 -0
- package/common/ClearButton.mjs +38 -0
- package/common/DropDownBase.js +8 -0
- package/common/DropDownBase.mjs +194 -0
- package/common/GroupStickyHeader.js +8 -0
- package/common/GroupStickyHeader.mjs +22 -0
- package/common/List.js +8 -0
- package/common/List.mjs +117 -0
- package/common/ListContainer.js +8 -0
- package/common/ListContainer.mjs +33 -0
- package/common/ListDefaultItem.js +8 -0
- package/common/ListDefaultItem.mjs +36 -0
- package/common/ListFilter.js +8 -0
- package/common/ListFilter.mjs +49 -0
- package/common/ListGroupItem.js +8 -0
- package/common/ListGroupItem.mjs +32 -0
- package/common/ListItem.js +8 -0
- package/common/ListItem.mjs +49 -0
- package/common/MultiColumnList.js +8 -0
- package/common/MultiColumnList.mjs +28 -0
- package/common/Navigation.js +8 -0
- package/common/Navigation.mjs +29 -0
- package/common/SearchBar.js +8 -0
- package/common/SearchBar.mjs +65 -0
- package/common/VirtualScroll.js +8 -0
- package/common/VirtualScroll.mjs +75 -0
- package/common/constants.js +8 -0
- package/common/constants.mjs +13 -0
- package/common/settings.js +8 -0
- package/common/settings.mjs +12 -0
- package/common/utils.js +8 -0
- package/common/utils.mjs +109 -0
- package/common/withCustomComponent.js +8 -0
- package/common/withCustomComponent.mjs +13 -0
- package/dist/cdn/js/kendo-react-dropdowns.js +8 -5
- package/index.d.mts +4098 -5
- package/index.d.ts +4098 -31
- package/index.js +8 -5
- package/index.mjs +55 -4429
- package/messages/index.js +8 -0
- package/messages/index.mjs +27 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +9 -9
- package/AutoComplete/AutoComplete.d.ts +0 -236
- package/AutoComplete/AutoCompleteProps.d.ts +0 -254
- package/ComboBox/ComboBox.d.ts +0 -254
- package/ComboBox/ComboBoxProps.d.ts +0 -324
- package/DropDownList/DropDownList.d.ts +0 -264
- package/DropDownList/DropDownListProps.d.ts +0 -329
- package/DropDownTree/DropDownTree.d.ts +0 -74
- package/DropDownTree/DropDownTreeProps.d.ts +0 -297
- package/DropDownTree/ListNoData.d.ts +0 -10
- package/DropDownTree/useDropdownWidth.d.ts +0 -10
- package/MultiColumnComboBox/MultiColumnComboBox.d.ts +0 -300
- package/MultiSelect/MultiSelect.d.ts +0 -262
- package/MultiSelect/MultiSelectProps.d.ts +0 -325
- package/MultiSelect/TagList.d.ts +0 -42
- package/MultiSelectTree/MultiSelectTree.d.ts +0 -85
- package/MultiSelectTree/MultiSelectTreeProps.d.ts +0 -324
- package/MultiSelectTree/utils.d.ts +0 -21
- package/common/AdaptiveMode.d.ts +0 -25
- package/common/ClearButton.d.ts +0 -18
- package/common/DropDownBase.d.ts +0 -180
- package/common/GroupStickyHeader.d.ts +0 -28
- package/common/List.d.ts +0 -50
- package/common/ListContainer.d.ts +0 -22
- package/common/ListDefaultItem.d.ts +0 -20
- package/common/ListFilter.d.ts +0 -23
- package/common/ListGroupItem.d.ts +0 -37
- package/common/ListItem.d.ts +0 -65
- package/common/MultiColumnList.d.ts +0 -9
- package/common/Navigation.d.ts +0 -17
- package/common/SearchBar.d.ts +0 -47
- package/common/VirtualScroll.d.ts +0 -45
- package/common/constants.d.ts +0 -8
- package/common/events.d.ts +0 -76
- package/common/filterDescriptor.d.ts +0 -45
- package/common/settings.d.ts +0 -109
- package/common/utils.d.ts +0 -70
- package/common/withCustomComponent.d.ts +0 -11
- package/messages/index.d.ts +0 -44
- package/package-metadata.d.ts +0 -9
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as h from "react";
|
|
10
|
+
import S from "prop-types";
|
|
11
|
+
import { classNames as P, Keys as v, validatePackage as J, svgIconPropType as Q, canUseDOM as A, getTabIndex as X, IconWrap as Z, createPropsContext as ee, withIdHOC as te, withPropsContext as se, kendoThemeMaps as ie } from "@progress/kendo-react-common";
|
|
12
|
+
import { FloatingLabel as ae } from "@progress/kendo-react-labels";
|
|
13
|
+
import { caretAltDownIcon as oe, xIcon as ne } from "@progress/kendo-svg-icons";
|
|
14
|
+
import le from "../common/ListContainer.mjs";
|
|
15
|
+
import re from "../common/ListFilter.mjs";
|
|
16
|
+
import H from "../common/GroupStickyHeader.mjs";
|
|
17
|
+
import de from "../common/ListDefaultItem.mjs";
|
|
18
|
+
import pe from "../common/List.mjs";
|
|
19
|
+
import O from "../common/DropDownBase.mjs";
|
|
20
|
+
import { areSame as C, getItemValue as K, sameCharsOnly as he, shuffleData as ce, matchText as B, isPresent as q, itemIndexStartsWith as ue } from "../common/utils.mjs";
|
|
21
|
+
import { packageMetadata as me } from "../package-metadata.mjs";
|
|
22
|
+
import { Button as W } from "@progress/kendo-react-buttons";
|
|
23
|
+
import { provideLocalizationService as fe } from "@progress/kendo-react-intl";
|
|
24
|
+
import { dropDownListArrowBtnAriaLabel as U, messages as ge } from "../messages/index.mjs";
|
|
25
|
+
import { MOBILE_MEDIUM_DEVISE as G, MOBILE_SMALL_DEVISE as $ } from "../common/constants.mjs";
|
|
26
|
+
import { ActionSheet as ve, ActionSheetHeader as be, ActionSheetContent as Ie } from "@progress/kendo-react-layout";
|
|
27
|
+
const ye = "Please select a value from the list!", { sizeMap: z, roundedMap: ke } = ie, E = class E extends h.Component {
|
|
28
|
+
constructor(s) {
|
|
29
|
+
super(s), this.state = {}, this._element = null, this.base = new O(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
|
+
this.base.wrapper && this.base.wrapper.focus();
|
|
31
|
+
}, this.handleItemSelect = (e, t) => {
|
|
32
|
+
const { data: a = [], virtual: r, dataItemKey: o, defaultItem: n } = this.props, c = r ? r.skip : 0, d = e === -1 && n !== void 0 ? n : a[e - c], p = !C(d, this.value, o);
|
|
33
|
+
this.triggerOnChange(d, t), p && this.base.triggerPageChangeCornerItems(d, t);
|
|
34
|
+
}, this.componentRef = (e) => {
|
|
35
|
+
this._element = e, this.base.wrapper = e;
|
|
36
|
+
}, this.dummySelect = (e) => /* @__PURE__ */ h.createElement(
|
|
37
|
+
"select",
|
|
38
|
+
{
|
|
39
|
+
name: this.props.name,
|
|
40
|
+
ref: (t) => {
|
|
41
|
+
this._select = t;
|
|
42
|
+
},
|
|
43
|
+
tabIndex: -1,
|
|
44
|
+
"aria-hidden": !0,
|
|
45
|
+
title: this.props.label,
|
|
46
|
+
style: { opacity: 0, width: 1, border: 0, zIndex: -1, position: "absolute", left: "50%" }
|
|
47
|
+
},
|
|
48
|
+
/* @__PURE__ */ h.createElement(
|
|
49
|
+
"option",
|
|
50
|
+
{
|
|
51
|
+
value: this.props.valueMap ? this.props.valueMap.call(void 0, e) : e
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
), this.renderListContainer = () => {
|
|
55
|
+
const { header: e, footer: t, dir: a, data: r = [], size: o, groupField: n, groupStickyHeaderItemRender: c, list: d } = this.props, p = this.base, i = p.getPopupSettings(), g = this.props.opened !== void 0 ? this.props.opened : this.state.opened, b = i.width !== void 0 ? i.width : p.popupWidth, y = {
|
|
56
|
+
dir: a !== void 0 ? a : p.dirCalculated,
|
|
57
|
+
width: b,
|
|
58
|
+
popupSettings: {
|
|
59
|
+
...i,
|
|
60
|
+
popupClass: P(
|
|
61
|
+
i.popupClass,
|
|
62
|
+
"k-list-container",
|
|
63
|
+
"k-dropdownlist-popup"
|
|
64
|
+
),
|
|
65
|
+
anchor: i.anchor || this.element,
|
|
66
|
+
show: g,
|
|
67
|
+
onOpen: this.onPopupOpened,
|
|
68
|
+
onClose: this.onPopupClosed
|
|
69
|
+
},
|
|
70
|
+
itemsCount: [r.length]
|
|
71
|
+
};
|
|
72
|
+
let { group: m } = this.state;
|
|
73
|
+
return m === void 0 && n !== void 0 && (m = K(r[0], n)), /* @__PURE__ */ h.createElement(le, { ...y }, this.renderListFilter(), e && /* @__PURE__ */ h.createElement("div", { className: "k-list-header" }, e), /* @__PURE__ */ h.createElement(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
className: P(
|
|
77
|
+
"k-list",
|
|
78
|
+
{
|
|
79
|
+
[`k-list-${z[o] || o}`]: o,
|
|
80
|
+
"k-virtual-list": this.base.vs.enabled
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
},
|
|
84
|
+
this.renderDefaultItem(),
|
|
85
|
+
!d && m && r.length !== 0 && /* @__PURE__ */ h.createElement(H, { group: m, groupMode: "modern", render: c }),
|
|
86
|
+
this.renderList()
|
|
87
|
+
), t && /* @__PURE__ */ h.createElement("div", { className: "k-list-footer" }, t));
|
|
88
|
+
}, this.renderList = () => {
|
|
89
|
+
const {
|
|
90
|
+
data: e = [],
|
|
91
|
+
textField: t,
|
|
92
|
+
dataItemKey: a,
|
|
93
|
+
virtual: r = { skip: 0, total: void 0 },
|
|
94
|
+
groupHeaderItemRender: o,
|
|
95
|
+
listNoDataRender: n,
|
|
96
|
+
itemRender: c
|
|
97
|
+
} = this.props, d = this.base.vs, p = r.skip, i = this.props.opened !== void 0 ? this.props.opened : this.state.opened, g = this.base.getPopupSettings(), b = `translateY(${d.translate}px)`;
|
|
98
|
+
return /* @__PURE__ */ h.createElement(
|
|
99
|
+
pe,
|
|
100
|
+
{
|
|
101
|
+
id: this._listboxId,
|
|
102
|
+
show: i,
|
|
103
|
+
data: e.slice(),
|
|
104
|
+
focusedIndex: this.getFocusedIndex(),
|
|
105
|
+
value: this.value,
|
|
106
|
+
textField: t,
|
|
107
|
+
valueField: a,
|
|
108
|
+
optionsGuid: this._guid,
|
|
109
|
+
groupField: this.props.groupField,
|
|
110
|
+
groupMode: "modern",
|
|
111
|
+
listRef: (y) => d.list = this.base.list = y,
|
|
112
|
+
wrapperStyle: { maxHeight: g.height },
|
|
113
|
+
wrapperCssClass: "k-list-content",
|
|
114
|
+
listStyle: d.enabled ? { transform: b } : void 0,
|
|
115
|
+
key: "listkey",
|
|
116
|
+
skip: p,
|
|
117
|
+
onClick: this.handleItemClick,
|
|
118
|
+
itemRender: c,
|
|
119
|
+
groupHeaderItemRender: o,
|
|
120
|
+
noDataRender: n,
|
|
121
|
+
onScroll: this.onScroll,
|
|
122
|
+
wrapperRef: d.scrollerRef,
|
|
123
|
+
scroller: this.base.renderScrollElement(),
|
|
124
|
+
ariaSetSize: r.total
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}, this.onScroll = (e) => {
|
|
128
|
+
const { vs: t, list: a } = this.base;
|
|
129
|
+
t.scrollHandler(e);
|
|
130
|
+
const { groupField: r } = this.props;
|
|
131
|
+
let { data: o = [] } = this.props;
|
|
132
|
+
if (!(!r || !o.length) && r) {
|
|
133
|
+
const n = this.itemHeight = this.itemHeight || (t.enabled ? t.itemHeight : a ? a.children[0].offsetHeight : 0), d = e.target.scrollTop - t.skip * n;
|
|
134
|
+
o = this.base.getGroupedDataModernMode(o, r);
|
|
135
|
+
let p = o[0][r];
|
|
136
|
+
for (let i = 1; i < o.length && !(n * i > d); i++)
|
|
137
|
+
o[i] && o[i][r] && (p = o[i][r]);
|
|
138
|
+
p !== this.state.group && this.setState({
|
|
139
|
+
group: p
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}, this.renderListFilter = () => {
|
|
143
|
+
const e = this.props.filter !== void 0 ? this.props.filter : this.state.text;
|
|
144
|
+
return this.props.filterable && /* @__PURE__ */ h.createElement(
|
|
145
|
+
re,
|
|
146
|
+
{
|
|
147
|
+
value: e,
|
|
148
|
+
ref: (t) => this._filterInput = t && t.element,
|
|
149
|
+
onChange: this.handleListFilterChange,
|
|
150
|
+
onKeyDown: this.handleKeyDown,
|
|
151
|
+
size: this.props.size,
|
|
152
|
+
rounded: this.props.rounded,
|
|
153
|
+
fillMode: this.props.fillMode
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}, this.renderDefaultItem = () => {
|
|
157
|
+
const { textField: e, defaultItem: t, dataItemKey: a } = this.props;
|
|
158
|
+
return t !== void 0 && /* @__PURE__ */ h.createElement(
|
|
159
|
+
de,
|
|
160
|
+
{
|
|
161
|
+
defaultItem: t,
|
|
162
|
+
textField: e,
|
|
163
|
+
selected: C(this.value, t, a),
|
|
164
|
+
key: "defaultitemkey",
|
|
165
|
+
onClick: this.handleDefaultItemClick
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}, this.search = (e) => {
|
|
169
|
+
clearTimeout(this._typingTimeout), this.props.filterable || (this._typingTimeout = window.setTimeout(() => this.searchState.word = "", this.props.delay), this.selectNext(e));
|
|
170
|
+
}, this.selectNext = (e) => {
|
|
171
|
+
const { data: t = [], dataItemKey: a } = this.props;
|
|
172
|
+
let r = t.map((w, N) => ({ item: w, itemIndex: N }));
|
|
173
|
+
const o = this.searchState.word, n = this.searchState.last, c = he(o, n);
|
|
174
|
+
let d = r.length, p = Math.max(0, t.findIndex((w) => C(w, this.value, a))), i;
|
|
175
|
+
this.props.defaultItem && (i = { item: this.props.defaultItem, itemIndex: -1 }, d += 1, p += 1), p += c ? 1 : 0, r = ce(r, p, i);
|
|
176
|
+
let g, b, y, m = 0;
|
|
177
|
+
const { textField: l, ignoreCase: x } = this.props;
|
|
178
|
+
for (; m < d; m++)
|
|
179
|
+
if (g = K(r[m].item, l), b = c && B(g, n, x), y = B(g, o, x), b || y) {
|
|
180
|
+
m = r[m].itemIndex;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
if (m !== d) {
|
|
184
|
+
const w = this.base.initState();
|
|
185
|
+
w.syntheticEvent = e, this.handleItemSelect(m, w), this.applyState(w), this._valueDuringOnChange = void 0;
|
|
186
|
+
}
|
|
187
|
+
}, this.handleKeyDown = (e) => {
|
|
188
|
+
e && e.target instanceof Element && e.target.nodeName === "INPUT" && e.stopPropagation && e.stopPropagation();
|
|
189
|
+
const {
|
|
190
|
+
data: t = [],
|
|
191
|
+
filterable: a,
|
|
192
|
+
disabled: r,
|
|
193
|
+
defaultItem: o,
|
|
194
|
+
leftRightKeysNavigation: n = !0,
|
|
195
|
+
virtual: c = { skip: 0, total: 0, pageSize: 0 },
|
|
196
|
+
dataItemKey: d,
|
|
197
|
+
groupField: p = "",
|
|
198
|
+
textField: i,
|
|
199
|
+
skipDisabledItems: g = !0
|
|
200
|
+
} = this.props, b = this.value, y = t.findIndex((I) => C(I, b, d)), m = this.props.opened !== void 0 ? this.props.opened : this.state.opened, l = e.keyCode, x = l === v.home || l === v.end, w = l === v.up || l === v.down, N = !m && (e.altKey && l === v.down || l === v.enter || l === v.space), M = m && (e.altKey && l === v.up || l === v.esc), D = n && (l === v.left || l === v.right), L = w || D && !a || x, k = this.base.initState();
|
|
201
|
+
if (k.syntheticEvent = e, !r) {
|
|
202
|
+
if (x && this.base.vs.enabled)
|
|
203
|
+
l === v.home ? c.skip !== 0 ? (this.base.triggerOnPageChange(k, 0, c.pageSize), this._navigated = !0) : this.triggerOnChange(t[0], k) : c.skip < c.total - c.pageSize ? (this.base.triggerOnPageChange(k, c.total - c.pageSize, c.pageSize), this._navigated = !0) : this.triggerOnChange(t[t.length - 1], k);
|
|
204
|
+
else if (m && l === v.pageUp)
|
|
205
|
+
this.base.scrollPopupByPageSize(-1);
|
|
206
|
+
else if (m && l === v.pageDown)
|
|
207
|
+
this.base.scrollPopupByPageSize(1);
|
|
208
|
+
else if (m && l === v.enter) {
|
|
209
|
+
const I = this.getFocusedIndex();
|
|
210
|
+
this.haveFocusedItemAndDataNotEmpty(t, I) ? (this.triggerOnChange(null, k), this.applyState(k)) : this.handleItemSelect(I, k), this.base.togglePopup(k), e.preventDefault();
|
|
211
|
+
} else if (N || M)
|
|
212
|
+
M && this.resetValueIfDisabledItem(), this.base.togglePopup(k), e.preventDefault();
|
|
213
|
+
else if (L) {
|
|
214
|
+
if (this._lastKeypressIsFilter = !1, p !== "" && i)
|
|
215
|
+
if (!g && m)
|
|
216
|
+
this.onNavigate(k, l);
|
|
217
|
+
else {
|
|
218
|
+
let I;
|
|
219
|
+
if (l === v.down || l === v.right) {
|
|
220
|
+
const f = t.slice(y + 1).find((u) => !u.disabled && u[i]);
|
|
221
|
+
I = f && t.findIndex((u) => u[i] === f[i]);
|
|
222
|
+
} else if (l === v.up || l === v.left) {
|
|
223
|
+
let f;
|
|
224
|
+
if (y === 0 && o)
|
|
225
|
+
I = -1;
|
|
226
|
+
else if (y === -1)
|
|
227
|
+
f = t, I = t.findIndex((u) => !u.disabled && u[i]);
|
|
228
|
+
else {
|
|
229
|
+
f = t.slice(0, y);
|
|
230
|
+
let u = f.pop();
|
|
231
|
+
for (; u && u.disabled; )
|
|
232
|
+
u = f.pop();
|
|
233
|
+
I = u && t.findIndex((F) => F[i] === u[i]);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (I !== void 0) {
|
|
237
|
+
const f = I - y;
|
|
238
|
+
this.onNavigate(k, l, f);
|
|
239
|
+
} else
|
|
240
|
+
I === void 0 && t.findIndex((f) => f[i] === b[i]) === t.length - 1 && this.onNavigate(k, l);
|
|
241
|
+
}
|
|
242
|
+
else if (!g && m || x)
|
|
243
|
+
this.onNavigate(k, l);
|
|
244
|
+
else if (i) {
|
|
245
|
+
let I;
|
|
246
|
+
if (l === v.down || l === v.right) {
|
|
247
|
+
const f = t.slice(y + 1).find((u) => !u.disabled && u[i]);
|
|
248
|
+
I = f && t.findIndex((u) => u[i] === f[i]);
|
|
249
|
+
} else if (l === v.up || l === v.left) {
|
|
250
|
+
let f;
|
|
251
|
+
if (y === 0 && o)
|
|
252
|
+
I = -1;
|
|
253
|
+
else if (y === -1)
|
|
254
|
+
f = t, I = t.find((u) => !u.disabled && u[i]);
|
|
255
|
+
else {
|
|
256
|
+
f = t.slice(0, y);
|
|
257
|
+
let u = f.pop();
|
|
258
|
+
for (; u && u.disabled; )
|
|
259
|
+
u = f.pop();
|
|
260
|
+
I = u && t.findIndex((F) => F[i] === u[i]);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (I !== void 0) {
|
|
264
|
+
const f = I - y;
|
|
265
|
+
this.onNavigate(k, l, f);
|
|
266
|
+
} else
|
|
267
|
+
I === void 0 && t.findIndex((f) => f[i] === b[i]) === t.length - 1 && this.onNavigate(k, l);
|
|
268
|
+
} else
|
|
269
|
+
this.onNavigate(k, l);
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
}
|
|
272
|
+
this.applyState(k);
|
|
273
|
+
}
|
|
274
|
+
}, this.handleItemClick = (e, t) => {
|
|
275
|
+
this.base.handleItemClick(e, t), this._valueDuringOnChange = void 0;
|
|
276
|
+
}, this.handleFocus = (e) => {
|
|
277
|
+
this._skipFocusEvent || this.base.handleFocus(e);
|
|
278
|
+
}, this.handleBlur = (e) => {
|
|
279
|
+
if (this._skipFocusEvent || !this.state.focused)
|
|
280
|
+
return;
|
|
281
|
+
const t = this.props.opened !== void 0 ? this.props.opened : this.state.opened, { adaptive: a } = this.props, { windowWidth: r = 0 } = this.state, o = r <= G && a, n = this.base.initState();
|
|
282
|
+
n.syntheticEvent = e, n.data.focused = !1, n.events.push({ type: "onBlur" }), t && this.resetValueIfDisabledItem(), t && !o && this.base.togglePopup(n), this.applyState(n);
|
|
283
|
+
}, this.handleDefaultItemClick = (e) => {
|
|
284
|
+
const t = this.base.initState();
|
|
285
|
+
t.syntheticEvent = e, this.base.togglePopup(t), this.triggerOnChange(this.props.defaultItem, t), this.applyState(t);
|
|
286
|
+
}, this.handleWrapperClick = (e) => {
|
|
287
|
+
if (e.isPropagationStopped())
|
|
288
|
+
return;
|
|
289
|
+
const t = this.base.initState();
|
|
290
|
+
t.syntheticEvent = e, this.state.focused || (t.data.focused = !0), this.resetValueIfDisabledItem(), this.base.togglePopup(t), this.applyState(t);
|
|
291
|
+
}, this.handleKeyPress = (e) => {
|
|
292
|
+
if (this.props.filterable || e.which === 0 || e.keyCode === v.enter)
|
|
293
|
+
return;
|
|
294
|
+
let t = String.fromCharCode(e.charCode || e.keyCode);
|
|
295
|
+
this.props.ignoreCase && (t = t.toLowerCase()), t === " " && e.preventDefault(), this.searchState = {
|
|
296
|
+
word: this.searchState.word + t,
|
|
297
|
+
last: this.searchState.last + t
|
|
298
|
+
}, this.search(e);
|
|
299
|
+
}, this.handleListFilterChange = (e) => {
|
|
300
|
+
const t = this.base.initState();
|
|
301
|
+
t.syntheticEvent = e.syntheticEvent, this.props.filter === void 0 && (t.data.text = e.target.value), this.base.filterChanged(e.target.value, t), this._lastKeypressIsFilter = !0, this.applyState(t), this.setState({ group: void 0 });
|
|
302
|
+
}, this.onPopupOpened = () => {
|
|
303
|
+
this._filterInput && this.focusElement(this._filterInput), this.props.adaptive && setTimeout(() => {
|
|
304
|
+
this._filterInput && this.focusElement(this._filterInput);
|
|
305
|
+
}, 300);
|
|
306
|
+
}, this.onPopupClosed = () => {
|
|
307
|
+
this.state.focused && window.setTimeout(
|
|
308
|
+
() => {
|
|
309
|
+
this.state.focused && this.base.wrapper && this.focusElement(this.base.wrapper);
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}, this.setValidity = () => {
|
|
313
|
+
this._select && this._select.setCustomValidity && this._select.setCustomValidity(
|
|
314
|
+
this.validity.valid ? "" : this.props.validationMessage || ye
|
|
315
|
+
);
|
|
316
|
+
}, J(me);
|
|
317
|
+
}
|
|
318
|
+
get _inputId() {
|
|
319
|
+
return this.props.id + "-accessibility-id";
|
|
320
|
+
}
|
|
321
|
+
get _listboxId() {
|
|
322
|
+
return this.props.id + "-listbox-id";
|
|
323
|
+
}
|
|
324
|
+
get _guid() {
|
|
325
|
+
return this.props.id + "-guid";
|
|
326
|
+
}
|
|
327
|
+
get document() {
|
|
328
|
+
if (A)
|
|
329
|
+
return this.element && this.element.ownerDocument || document;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* @hidden
|
|
333
|
+
*/
|
|
334
|
+
get element() {
|
|
335
|
+
return this._element;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* The value of the DropDownList.
|
|
339
|
+
*/
|
|
340
|
+
get value() {
|
|
341
|
+
let s;
|
|
342
|
+
return this._valueDuringOnChange !== void 0 ? s = this._valueDuringOnChange : this.props.value !== void 0 ? s = this.props.value : this.state.value !== void 0 ? s = this.state.value : this.props.defaultValue !== void 0 && (s = this.props.defaultValue), !q(s) && this.props.defaultItem !== void 0 && (s = this.props.defaultItem), s;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* The index of the selected item.
|
|
346
|
+
*/
|
|
347
|
+
get index() {
|
|
348
|
+
const { data: s = [], dataItemKey: e } = this.props, t = this.value;
|
|
349
|
+
return s.findIndex((a) => C(a, t, e));
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Gets the `name` property of the DropDownList.
|
|
353
|
+
*/
|
|
354
|
+
get name() {
|
|
355
|
+
return this.props.name;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Represents the validity state into which the DropDownList is set.
|
|
359
|
+
*/
|
|
360
|
+
get validity() {
|
|
361
|
+
const s = this.props.validationMessage !== void 0, e = !this.required || this.value !== null && this.value !== "" && this.value !== void 0, t = this.props.valid !== void 0 ? this.props.valid : e;
|
|
362
|
+
return {
|
|
363
|
+
customError: s,
|
|
364
|
+
valid: t,
|
|
365
|
+
valueMissing: this.value === null
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
get validityStyles() {
|
|
369
|
+
return this.props.validityStyles !== void 0 ? this.props.validityStyles : E.defaultProps.validityStyles;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* @hidden
|
|
373
|
+
*/
|
|
374
|
+
get required() {
|
|
375
|
+
return this.props.required !== void 0 ? this.props.required : E.defaultProps.required;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* @hidden
|
|
379
|
+
*/
|
|
380
|
+
componentDidUpdate(s, e) {
|
|
381
|
+
var g;
|
|
382
|
+
const { dataItemKey: t, virtual: a, groupField: r = "", textField: o } = this.props, { data: n = [] } = this.props, c = s.virtual ? s.virtual.total : 0, d = this.props.opened !== void 0 ? this.props.opened : this.state.opened, p = s.opened !== void 0 ? s.opened : e.opened, i = !p && d;
|
|
383
|
+
if (this.base.getPopupSettings().animate || i && this.onPopupOpened(), a && a.total !== c)
|
|
384
|
+
this.base.vs.calcScrollElementHeight(), this.base.vs.reset();
|
|
385
|
+
else {
|
|
386
|
+
const b = this.value, y = s.value !== void 0 ? s.value : e.value;
|
|
387
|
+
let m = n.findIndex((x) => C(x, b, t));
|
|
388
|
+
r !== "" && b && o && (m = (g = this.base.getGroupedDataModernMode(n, r)) == null ? void 0 : g.map((x) => x[o]).indexOf(b[o]));
|
|
389
|
+
const l = !C(y, b, t);
|
|
390
|
+
i && a ? this.base.scrollToVirtualItem(a, m) : i && !a ? (this.onPopupOpened(), n && n.length !== 0 && this.base.resetGroupStickyHeader(n[0][r], this), this.base.scrollToItem(m)) : d && p && b && l && !this._navigated ? this.base.scrollToItem(m) : d && p && this._navigated && (this._navigated && a && a.skip === 0 ? this.base.vs.reset() : this._navigated && a && a.skip === a.total - a.pageSize && this.base.vs.scrollToEnd());
|
|
391
|
+
}
|
|
392
|
+
this._navigated = !1, this.setValidity();
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* @hidden
|
|
396
|
+
*/
|
|
397
|
+
componentDidMount() {
|
|
398
|
+
var s;
|
|
399
|
+
this.observerResize = A && window.ResizeObserver && new window.ResizeObserver(this.calculateMedia.bind(this)), this.base.didMount(), this.setValidity(), (s = this.document) != null && s.body && this.observerResize && this.observerResize.observe(this.document.body);
|
|
400
|
+
}
|
|
401
|
+
/** @hidden */
|
|
402
|
+
componentWillUnmount() {
|
|
403
|
+
var s;
|
|
404
|
+
(s = this.document) != null && s.body && this.observerResize && this.observerResize.disconnect();
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* @hidden
|
|
408
|
+
*/
|
|
409
|
+
render() {
|
|
410
|
+
const s = fe(this).toLanguageString(U, ge[U]), { style: e, className: t, label: a, dir: r, virtual: o, size: n, rounded: c, fillMode: d, adaptive: p } = this.props, { windowWidth: i = 0 } = this.state, g = this.props.opened !== void 0 ? this.props.opened : this.state.opened, b = this.value, y = K(b, this.props.textField), m = !this.validityStyles || this.validity.valid, l = this.base, x = l.vs, w = i <= G && p;
|
|
411
|
+
x.enabled = o !== void 0, o !== void 0 && (l.vs.skip = o.skip, l.vs.total = o.total, l.vs.pageSize = o.pageSize);
|
|
412
|
+
const {
|
|
413
|
+
dataItemKey: N,
|
|
414
|
+
data: M = [],
|
|
415
|
+
disabled: D,
|
|
416
|
+
tabIndex: L,
|
|
417
|
+
loading: k,
|
|
418
|
+
iconClassName: I,
|
|
419
|
+
svgIcon: f,
|
|
420
|
+
valueRender: u
|
|
421
|
+
} = this.props, { focused: F } = this.state, Y = M.findIndex((_) => C(_, b, N)), R = /* @__PURE__ */ h.createElement("span", { id: this._inputId, className: "k-input-inner" }, /* @__PURE__ */ h.createElement("span", { className: "k-input-value-text" }, y)), j = u !== void 0 ? u.call(void 0, R, b) : R, V = /* @__PURE__ */ h.createElement(h.Fragment, null, /* @__PURE__ */ h.createElement(
|
|
422
|
+
"span",
|
|
423
|
+
{
|
|
424
|
+
ref: this.componentRef,
|
|
425
|
+
className: P(
|
|
426
|
+
"k-dropdownlist k-picker",
|
|
427
|
+
t,
|
|
428
|
+
{
|
|
429
|
+
[`k-picker-${z[n] || n}`]: n,
|
|
430
|
+
[`k-rounded-${ke[c] || c}`]: c,
|
|
431
|
+
[`k-picker-${d}`]: d,
|
|
432
|
+
"k-focus": F,
|
|
433
|
+
"k-disabled": D,
|
|
434
|
+
"k-invalid": !m,
|
|
435
|
+
"k-loading": k,
|
|
436
|
+
"k-required": this.required
|
|
437
|
+
}
|
|
438
|
+
),
|
|
439
|
+
style: a ? { ...e, width: void 0 } : e,
|
|
440
|
+
dir: r,
|
|
441
|
+
onMouseDown: g ? (_) => {
|
|
442
|
+
_.target.nodeName !== "INPUT" && (this.focusElement(this.base.wrapper), _.preventDefault());
|
|
443
|
+
} : void 0,
|
|
444
|
+
onFocus: this.handleFocus,
|
|
445
|
+
onBlur: this.handleBlur,
|
|
446
|
+
tabIndex: X(L, D),
|
|
447
|
+
accessKey: this.props.accessKey,
|
|
448
|
+
onKeyDown: this.handleKeyDown,
|
|
449
|
+
onKeyPress: this.handleKeyPress,
|
|
450
|
+
onClick: D ? void 0 : this.handleWrapperClick,
|
|
451
|
+
role: "combobox",
|
|
452
|
+
"aria-required": this.required,
|
|
453
|
+
"aria-disabled": D || void 0,
|
|
454
|
+
"aria-haspopup": "listbox",
|
|
455
|
+
"aria-expanded": g || !1,
|
|
456
|
+
"aria-owns": this._listboxId,
|
|
457
|
+
"aria-activedescendant": g ? "option-" + this._guid + "-" + (Y + (o ? o.skip : 0)) : void 0,
|
|
458
|
+
"aria-label": this.props.ariaLabel || this.props.label,
|
|
459
|
+
"aria-labelledby": this.props.ariaLabelledBy,
|
|
460
|
+
"aria-describedby": this.props.ariaDescribedBy || this._inputId,
|
|
461
|
+
id: this.props.id,
|
|
462
|
+
title: this.props.title
|
|
463
|
+
},
|
|
464
|
+
j,
|
|
465
|
+
k && /* @__PURE__ */ h.createElement(Z, { className: "k-input-loading-icon", name: "loading" }),
|
|
466
|
+
/* @__PURE__ */ h.createElement(
|
|
467
|
+
W,
|
|
468
|
+
{
|
|
469
|
+
tabIndex: -1,
|
|
470
|
+
type: "button",
|
|
471
|
+
"aria-label": s,
|
|
472
|
+
"aria-hidden": !0,
|
|
473
|
+
size: n,
|
|
474
|
+
fillMode: d,
|
|
475
|
+
iconClass: I,
|
|
476
|
+
className: "k-input-button",
|
|
477
|
+
rounded: null,
|
|
478
|
+
themeColor: "base",
|
|
479
|
+
icon: I ? void 0 : "caret-alt-down",
|
|
480
|
+
svgIcon: f || oe,
|
|
481
|
+
onMouseDown: (_) => this.state.focused && _.preventDefault()
|
|
482
|
+
}
|
|
483
|
+
),
|
|
484
|
+
this.dummySelect(b),
|
|
485
|
+
!w && this.renderListContainer()
|
|
486
|
+
), w && this.renderAdaptiveListContainer());
|
|
487
|
+
return a ? /* @__PURE__ */ h.createElement(
|
|
488
|
+
ae,
|
|
489
|
+
{
|
|
490
|
+
label: a,
|
|
491
|
+
editorValue: y,
|
|
492
|
+
editorValid: m,
|
|
493
|
+
editorDisabled: this.props.disabled,
|
|
494
|
+
style: { width: e ? e.width : void 0 },
|
|
495
|
+
children: V
|
|
496
|
+
}
|
|
497
|
+
) : V;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* @hidden
|
|
501
|
+
*/
|
|
502
|
+
onNavigate(s, e, t) {
|
|
503
|
+
const {
|
|
504
|
+
data: a = [],
|
|
505
|
+
defaultItem: r,
|
|
506
|
+
dataItemKey: o,
|
|
507
|
+
virtual: n = { skip: 0, total: 0, pageSize: 0 }
|
|
508
|
+
} = this.props, c = this.base.vs, d = this.value, p = a.findIndex((g) => C(g, d, o)), i = this.base.navigation.navigate({
|
|
509
|
+
current: n.skip + p,
|
|
510
|
+
max: (c.enabled ? n.total : a.length) - 1,
|
|
511
|
+
min: r !== void 0 ? -1 : 0,
|
|
512
|
+
keyCode: e,
|
|
513
|
+
skipItems: t || void 0
|
|
514
|
+
});
|
|
515
|
+
i !== void 0 && this.handleItemSelect(i, s), this.applyState(s);
|
|
516
|
+
}
|
|
517
|
+
renderAdaptiveListContainer() {
|
|
518
|
+
const { windowWidth: s = 0 } = this.state, { header: e, footer: t, size: a, adaptiveTitle: r, groupField: o, groupStickyHeaderItemRender: n, list: c, data: d = [] } = this.props, p = this.props.opened !== void 0 ? this.props.opened : this.state.opened, i = {
|
|
519
|
+
navigatable: !1,
|
|
520
|
+
navigatableElements: [],
|
|
521
|
+
expand: p,
|
|
522
|
+
animation: !0,
|
|
523
|
+
onClose: (b) => this.handleWrapperClick(b),
|
|
524
|
+
animationStyles: s <= $ ? { top: 0, width: "100%", height: "100%" } : void 0,
|
|
525
|
+
className: s <= $ ? "k-adaptive-actionsheet k-actionsheet-fullscreen" : "k-adaptive-actionsheet k-actionsheet-bottom"
|
|
526
|
+
};
|
|
527
|
+
let { group: g } = this.state;
|
|
528
|
+
return g === void 0 && o !== void 0 && (g = K(d[0], o)), /* @__PURE__ */ h.createElement(ve, { ...i }, /* @__PURE__ */ h.createElement(be, { className: "k-text-center" }, /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-titlebar-group k-hbox" }, /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-title" }, /* @__PURE__ */ h.createElement("div", null, r)), /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-actions" }, /* @__PURE__ */ h.createElement(
|
|
529
|
+
W,
|
|
530
|
+
{
|
|
531
|
+
tabIndex: 0,
|
|
532
|
+
"aria-label": "Cancel",
|
|
533
|
+
"aria-disabled": "false",
|
|
534
|
+
type: "button",
|
|
535
|
+
fillMode: "flat",
|
|
536
|
+
onClick: this.handleWrapperClick,
|
|
537
|
+
icon: "x",
|
|
538
|
+
svgIcon: ne
|
|
539
|
+
}
|
|
540
|
+
))), /* @__PURE__ */ h.createElement("div", { className: "k-actionsheet-titlebar-group k-actionsheet-filter" }, this.renderListFilter())), /* @__PURE__ */ h.createElement(Ie, { className: "!k-overflow-hidden" }, e && /* @__PURE__ */ h.createElement("div", { className: "k-list-header" }, e), /* @__PURE__ */ h.createElement(
|
|
541
|
+
"div",
|
|
542
|
+
{
|
|
543
|
+
className: P(
|
|
544
|
+
"k-list",
|
|
545
|
+
{
|
|
546
|
+
[`k-list-${z[a] || a}`]: a,
|
|
547
|
+
"k-virtual-list": this.base.vs.enabled
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
},
|
|
551
|
+
this.renderDefaultItem(),
|
|
552
|
+
!c && g && d.length !== 0 && /* @__PURE__ */ h.createElement(H, { group: g, groupMode: "modern", render: n }),
|
|
553
|
+
this.renderList()
|
|
554
|
+
), t && /* @__PURE__ */ h.createElement("div", { className: "k-list-footer" }, t)));
|
|
555
|
+
}
|
|
556
|
+
getFocusedIndex() {
|
|
557
|
+
const s = this.value, {
|
|
558
|
+
data: e = [],
|
|
559
|
+
textField: t,
|
|
560
|
+
dataItemKey: a,
|
|
561
|
+
virtual: r = { skip: 0 },
|
|
562
|
+
focusedItemIndex: o = ue,
|
|
563
|
+
filterable: n,
|
|
564
|
+
skipDisabledItems: c = !0
|
|
565
|
+
} = this.props, d = this.props.filter ? this.props.filter : this.state.text;
|
|
566
|
+
return c && t && !d && !s ? e.findIndex((p) => !p.disabled && p[t]) : q(s) && d === void 0 || n && d === "" ? e.findIndex((p) => C(p, s, a)) : d ? this._lastKeypressIsFilter ? o(e, d, t) : e.findIndex((p) => C(p, s, a)) : r.skip === 0 ? 0 : -1;
|
|
567
|
+
}
|
|
568
|
+
focusElement(s) {
|
|
569
|
+
this._skipFocusEvent = !0, s.focus(), window.setTimeout(() => this._skipFocusEvent = !1, 30);
|
|
570
|
+
}
|
|
571
|
+
triggerOnChange(s, e) {
|
|
572
|
+
C(this.value, s, this.props.dataItemKey) || (this.props.value === void 0 && (e.data.value = s), this._valueDuringOnChange = s, e.events.push({ type: "onChange" }));
|
|
573
|
+
}
|
|
574
|
+
applyState(s) {
|
|
575
|
+
this.base.applyState(s), this._valueDuringOnChange = void 0;
|
|
576
|
+
}
|
|
577
|
+
calculateMedia(s) {
|
|
578
|
+
for (const e of s)
|
|
579
|
+
this.setState({ windowWidth: e.target.clientWidth });
|
|
580
|
+
}
|
|
581
|
+
resetValueIfDisabledItem() {
|
|
582
|
+
const { data: s = [] } = this.props, e = this.base.initState(), t = this.getFocusedIndex();
|
|
583
|
+
this.haveFocusedItemAndDataNotEmpty(s, t) && (this.triggerOnChange(null, e), this.applyState(e));
|
|
584
|
+
}
|
|
585
|
+
haveFocusedItemAndDataNotEmpty(s, e) {
|
|
586
|
+
return e !== void 0 && e !== -1 && s && s.length > 0 && s[e].disabled;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
E.displayName = "DropDownList", E.propTypes = {
|
|
590
|
+
delay: S.number,
|
|
591
|
+
ignoreCase: S.bool,
|
|
592
|
+
iconClassName: S.string,
|
|
593
|
+
svgIcon: Q,
|
|
594
|
+
defaultItem: S.any,
|
|
595
|
+
valueRender: S.func,
|
|
596
|
+
valueMap: S.func,
|
|
597
|
+
validationMessage: S.string,
|
|
598
|
+
required: S.bool,
|
|
599
|
+
id: S.string,
|
|
600
|
+
ariaLabelledBy: S.string,
|
|
601
|
+
ariaDescribedBy: S.string,
|
|
602
|
+
ariaLabel: S.string,
|
|
603
|
+
leftRightKeysNavigation: S.bool,
|
|
604
|
+
title: S.string,
|
|
605
|
+
groupField: S.string,
|
|
606
|
+
list: S.any,
|
|
607
|
+
skipDisabledItems: S.bool,
|
|
608
|
+
...O.propTypes
|
|
609
|
+
}, E.defaultProps = {
|
|
610
|
+
delay: 500,
|
|
611
|
+
tabIndex: 0,
|
|
612
|
+
ignoreCase: !0,
|
|
613
|
+
...O.defaultProps,
|
|
614
|
+
required: !1,
|
|
615
|
+
size: "medium",
|
|
616
|
+
rounded: "medium",
|
|
617
|
+
fillMode: "solid",
|
|
618
|
+
groupMode: "modern"
|
|
619
|
+
};
|
|
620
|
+
let T = E;
|
|
621
|
+
const Se = ee(), xe = te(se(
|
|
622
|
+
Se,
|
|
623
|
+
T
|
|
624
|
+
));
|
|
625
|
+
xe.displayName = "KendoReactDropDownList";
|
|
626
|
+
export {
|
|
627
|
+
xe as DropDownList,
|
|
628
|
+
Se as DropDownListPropsContext,
|
|
629
|
+
T as DropDownListWithoutContext
|
|
630
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
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"),Ce=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"),we=require("../common/ListFilter.js"),tt=require("@progress/kendo-react-buttons"),xe=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),De=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}},Ie={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(),ne=t.forwardRef((u,f)=>{r.validatePackage(Xe.packageMetadata);const s=r.usePropsContext(Fe,u),o={...Ie,...s},G=r.useId(),ae=o.id||G,{data:M,dataItemKey:T,popupSettings:F={},style:N,opened:d,disabled:S,onOpen:P=r.noop,onClose:m=r.noop,placeholder:oe,label:O,name:Se,selectField:H,subItemsField:V,validationMessage:_,valid:Re,required:J,validityStyles:qe}=o,Q=r.getTabIndex(o.tabIndex,S),i=t.useRef(null),g=t.useRef(null),R=t.useRef(null),X=t.useRef(null),j=t.useRef(null),E=t.useRef(null),$=t.useRef(!1),[re,Ke]=t.useState(void 0),C=o.value!==void 0,b=C?o.value:re!==void 0?re:o.defaultValue,L=U.isPresent(b),se=L?U.getItemValue(b,o.textField):"",Y=ut({validationMessage:_,valid:Re,required:J},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 w=r.useRtl(g,o.dir),Te={width:Ye.useDropdownWidth(g,Ie,F,N),...w!==void 0?{direction:w}:{}},[Ne,ie]=t.useState(!1),l=d!==void 0?d:Ne,[p,Z]=t.useState(!1),[ee,Pe]=t.useState(),x=!!(ee&&ee<=ot.MOBILE_MEDIUM_DEVISE&&o.adaptive),[le,Oe]=t.useState(""),Ve=t.useCallback(()=>{j.current&&j.current.setCustomValidity&&j.current.setCustomValidity(Y.valid?"":_===void 0?lt:_)},[_,Y]);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 ce=t.useCallback(e=>{if(!l){if(P){const a={...e};P.call(void 0,a)}d===void 0&&ie(!0)}},[l,d,P]),D=t.useCallback(e=>{if(l){if(m){const a={...e};m.call(void 0,a)}d===void 0&&(ie(!1),x&&setTimeout(()=>{var a;y((a=X.current)==null?void 0:a.element)},300))}},[l,d,m,x]),Le=t.useCallback(e=>{if(!e.isDefaultPrevented()&&i.current){Z(!0);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};(l?D:ce)(a)}},[l,d,P,m]),q=t.useCallback(e=>{$.current=!0,e(),window.setTimeout(()=>$.current=!1,0)},[]),Be=t.useCallback(e=>{var I,Ee;const{keyCode:a,altKey:c}=e,v=E.current&&E.current.element;if(!i.current||e.isDefaultPrevented()&&((I=R.current)==null?void 0:I.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(),D(K);else if(v&&v.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&&((Ee=R.current)!=null&&Ee.element)){const A=Array.from(v.querySelectorAll(".k-treeview-item")),ke=[...A].reverse().find(z=>!!(z&&z.querySelector(".k-focus")));if(ke&&A.indexOf(ke)===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)||v)});else c&&a===r.Keys.down?(e.preventDefault(),ce(K)):l||a===r.Keys.esc&&fe(e)},[l,d,P,m]),ue=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(E.current&&E.current.element)}))},[]),y=t.useCallback(e=>{e&&q(()=>e.focus())},[]),We=t.useCallback(()=>{var e;!p&&l&&!d?D({target:i.current}):s.filterable?y((e=R.current)==null?void 0:e.element):y(E.current&&E.current.element)},[m,s.filterable,p,d,l]),Ae=t.useCallback(()=>{p&&y(g.current)},[p]),ze=t.useCallback(e=>{if(!p&&!$.current&&(Z(!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){Z(!1);const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};if(s.onBlur){const c={...a};s.onBlur.call(void 0,c)}x||D(a)}},[p,s.onBlur,l,d,m]),_e=t.useCallback(()=>{p&&q(r.noop),x&&setTimeout(()=>{var e;y((e=X.current)==null?void 0:e.element)},300)},[p,x]),de=t.useCallback((e,a,c)=>{if(s.onChange){const v={value:a,level:c?De(c):[],...e};s.onChange.call(void 0,v)}C||Ke(a)},[s.onChange,C]),pe=t.useCallback(e=>{if(U.areSame(e.item,b,T)||!i.current)return;const{item:a,itemHierarchicalIndex:c,nativeEvent:v,syntheticEvent:K}=e,I={syntheticEvent:K,nativeEvent:v,target:i.current};de(I,a,c),D(I)},[C,b,s.onChange,T,l,d,m]),fe=t.useCallback(e=>{if(!i.current)return;const a={syntheticEvent:e,nativeEvent:e.nativeEvent,target:i.current};de(a,null),D(a),e.preventDefault()},[C,s.onChange,l,d,m]),ve=t.useCallback(e=>{if(e.syntheticEvent.stopPropagation(),s.onExpandChange&&i.current){const{item:a,itemHierarchicalIndex:c,nativeEvent:v,syntheticEvent:K}=e,I={level:De(c),item:a,nativeEvent:v,syntheticEvent:K,target:i.current};s.onExpandChange.call(void 0,I)}},[s.onExpandChange]),me=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(we,{value:o.filter===void 0?le:o.filter,ref:X,onChange:me,onKeyDown:ue,size:k,rounded:B,fillMode:W}):null,a={adaptiveTitle:o.adaptiveTitle,expand:l,onClose:c=>D(c),windowWidth:ee,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(Ce.TreeView,{ref:E,tabIndex:Q,data:ge,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:pe,onExpandChange:ve,size:k,item:o.item,dir:w}):t.createElement(be,null,te.toLanguageString(h.nodata,h.messages[h.nodata]))))))},$e=t.useCallback(e=>{for(let a of e)Pe(a.target.clientWidth)},[]),ge=t.useMemo(()=>C||!L?M:r.mapTree(M,V,e=>r.extendDataItem(e,V,{[H]:U.areSame(e,b,T)})),[M,b,C,L,H,V]),be=o.listNoData||Ze.ListNoData,Ue=o.valueHolder||ct,te=Qe.useLocalization(),ye=!qe||Y.valid,{size:k,rounded:B,fillMode:W}=o,he=t.createElement(t.Fragment,null,t.createElement("span",{className:r.classNames("k-dropdowntree k-picker",o.className,{[`k-picker-${st[k]||k}`]:k,[`k-rounded-${it[B]||B}`]:B,[`k-picker-${W}`]:W,"k-focus":p,"k-invalid":!ye,"k-loading":o.loading,"k-required":J,"k-disabled":o.disabled}),tabIndex:Q,accessKey:o.accessKey,id:ae,style:O?{...N,width:void 0}:N,dir:w,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":J},t.createElement("span",{className:"k-input-inner"},t.createElement(Ue,{item:b},se||oe)),o.loading&&t.createElement(r.IconWrap,{className:"k-input-loading-icon",name:"loading"}),L&&!S&&t.createElement("span",{onClick:fe,className:"k-clear-value",title:te.toLanguageString(h.clear,h.messages[h.clear]),role:"button",tabIndex:-1,onMouseDown:e=>e.preventDefault()},t.createElement(r.IconWrap,{name:"x",icon:xe.xIcon})),t.createElement(tt.Button,{tabIndex:-1,type:"button","aria-label":"select",className:"k-input-button",size:k,fillMode:W,themeColor:"base",rounded:null,icon:"caret-alt-down",svgIcon:xe.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})),!x&&t.createElement(Je.Popup,{...F,className:r.classNames(F.className,{"k-rtl":w==="rtl"}),popupClass:r.classNames(F.popupClass,"k-dropdowntree-popup"),style:Te,anchor:F.anchor||g.current,show:l,onOpen:We,onClose:Ae},o.filterable&&t.createElement(we,{value:o.filter===void 0?le:o.filter,ref:R,onChange:me,onKeyDown:ue,size:k,rounded:B,fillMode:W}),M.length>0?t.createElement(Ce.TreeView,{style:{height:F.height},ref:E,tabIndex:Q,data:ge,focusIdField:T,textField:o.textField,selectField:H,expandField:o.expandField,childrenField:V,expandIcons:!0,onItemClick:pe,onExpandChange:ve,size:k,item:o.item,dir:w}):t.createElement(be,null,te.toLanguageString(h.nodata,h.messages[h.nodata])))),x&&je());return O?t.createElement(et.FloatingLabel,{label:O,editorValue:se,editorPlaceholder:oe,editorValid:ye,editorDisabled:S,editorId:ae,style:{width:N?N.width:void 0},children:he,dir:w}):he}),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};ne.displayName="KendoReactDropDownTree";ne.propTypes=dt;exports.DropDownTree=ne;exports.DropDownTreePropsContext=Fe;
|