zcomponents-ui 1.0.0

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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -0
  3. package/dist/index.cjs.css +2 -0
  4. package/dist/index.cjs.css.map +1 -0
  5. package/dist/index.cjs.js +762 -0
  6. package/dist/index.cjs.js.map +1 -0
  7. package/dist/index.d.ts +228 -0
  8. package/dist/index.esm.css +2 -0
  9. package/dist/index.esm.css.map +1 -0
  10. package/dist/index.esm.js +760 -0
  11. package/dist/index.esm.js.map +1 -0
  12. package/dist/types/components/ZDrop/components/ZDropClearButton/index.d.ts +3 -0
  13. package/dist/types/components/ZDrop/components/ZDropInput/ZDropMultipleInput/index.d.ts +3 -0
  14. package/dist/types/components/ZDrop/components/ZDropInput/ZDropMultipleInputValue/index.d.ts +3 -0
  15. package/dist/types/components/ZDrop/components/ZDropInput/ZDropSingleInput/index.d.ts +3 -0
  16. package/dist/types/components/ZDrop/components/ZDropInput/ZDropSingleInputValue/index.d.ts +3 -0
  17. package/dist/types/components/ZDrop/components/ZDropInput/index.d.ts +3 -0
  18. package/dist/types/components/ZDrop/components/ZDropLabel/index.d.ts +3 -0
  19. package/dist/types/components/ZDrop/components/ZDropList/ZDropListItem/index.d.ts +3 -0
  20. package/dist/types/components/ZDrop/components/ZDropList/ZDropListNoData/index.d.ts +3 -0
  21. package/dist/types/components/ZDrop/components/ZDropList/ZDropListWrapper/index.d.ts +9 -0
  22. package/dist/types/components/ZDrop/components/ZDropList/index.d.ts +3 -0
  23. package/dist/types/components/ZDrop/components/ZDropListVisibilityToggle/index.d.ts +3 -0
  24. package/dist/types/components/ZDrop/helpers/checkIsClearHidden.d.ts +1 -0
  25. package/dist/types/components/ZDrop/helpers/checkIsValueEqualToOption.d.ts +2 -0
  26. package/dist/types/components/ZDrop/helpers/findOption.d.ts +2 -0
  27. package/dist/types/components/ZDrop/helpers/getCurrentMultipleValue.d.ts +2 -0
  28. package/dist/types/components/ZDrop/helpers/getElementOffsetTop.d.ts +6 -0
  29. package/dist/types/components/ZDrop/helpers/searchFilter.d.ts +2 -0
  30. package/dist/types/components/ZDrop/index.d.ts +3 -0
  31. package/dist/types/components/ZDrop/types/zDropTypes.d.ts +221 -0
  32. package/dist/types/helpers/checkIsClearHidden.d.ts +1 -0
  33. package/dist/types/helpers/checkIsEqual.d.ts +2 -0
  34. package/dist/types/helpers/classNames.d.ts +5 -0
  35. package/dist/types/helpers/findDefaultValue.d.ts +1 -0
  36. package/dist/types/helpers/removeOrReplaceCharacter.d.ts +1 -0
  37. package/dist/types/helpers/searchFilter.d.ts +2 -0
  38. package/dist/types/helpers/shrinkName.d.ts +1 -0
  39. package/dist/types/helpers/useOutsideClose.d.ts +6 -0
  40. package/dist/types/index.d.ts +2 -0
  41. package/dist/types/stories/ZComponents/ZDrop/staticData/numbers/zDropNumbersData.d.ts +6 -0
  42. package/dist/types/stories/ZComponents/ZDrop/staticData/objects/zDropObjectsData.d.ts +4 -0
  43. package/dist/types/stories/ZComponents/ZDrop/staticData/strings/ZDropStringsData.d.ts +6 -0
  44. package/dist/types/stories/ZComponents/ZDrop/staticData/zDropData.d.ts +1 -0
  45. package/dist/types/stories/ZComponents/ZDrop/store/loadingInitialState.d.ts +3 -0
  46. package/dist/types/stories/ZComponents/ZDrop/store/storageKeys.d.ts +1 -0
  47. package/dist/types/stories/ZComponents/ZDrop/store/zDropDefaultState.d.ts +27 -0
  48. package/dist/types/stories/ZComponents/ZDrop/store/zDropStore.d.ts +8 -0
  49. package/dist/types/stories/ZComponents/ZDrop/stories/basic/BasicCustomSearch.d.ts +5 -0
  50. package/dist/types/stories/ZComponents/ZDrop/stories/basic/BasicSurvivorsNumbers.d.ts +5 -0
  51. package/dist/types/stories/ZComponents/ZDrop/stories/basic/BasicWeaponsStrings.d.ts +5 -0
  52. package/dist/types/stories/ZComponents/ZDrop/stories/basic/BasicZombiesObjects.d.ts +5 -0
  53. package/dist/types/stories/ZComponents/ZDrop/stories/numbers/SurvivorsNumbers.d.ts +5 -0
  54. package/dist/types/stories/ZComponents/ZDrop/stories/numbers/WeaponsNumbers.d.ts +5 -0
  55. package/dist/types/stories/ZComponents/ZDrop/stories/numbers/ZombiesNumbers.d.ts +5 -0
  56. package/dist/types/stories/ZComponents/ZDrop/stories/objects/SurvivorsObjects.d.ts +5 -0
  57. package/dist/types/stories/ZComponents/ZDrop/stories/objects/WeaponsObjects.d.ts +5 -0
  58. package/dist/types/stories/ZComponents/ZDrop/stories/objects/ZombiesObjects.d.ts +5 -0
  59. package/dist/types/stories/ZComponents/ZDrop/stories/strings/SurvivorsStrings.d.ts +5 -0
  60. package/dist/types/stories/ZComponents/ZDrop/stories/strings/WeaponsStrings.d.ts +5 -0
  61. package/dist/types/stories/ZComponents/ZDrop/stories/strings/ZombiesStrings.d.ts +5 -0
  62. package/dist/types/stories/ZComponents/ZDrop/visualComponents/SbNotFound/index.d.ts +2 -0
  63. package/dist/types/stories/ZComponents/ZDrop/visualComponents/SbPoster/index.d.ts +11 -0
  64. package/dist/types/stories/ZComponents/ZDrop/visualComponents/SbSelection/SbSelectionElement/index.d.ts +8 -0
  65. package/dist/types/stories/ZComponents/ZDrop/visualComponents/SbSelection/index.d.ts +6 -0
  66. package/dist/types/stories/ZComponents/ZDrop/visualComponents/index.d.ts +7 -0
  67. package/dist/types/stories/ZDrop.stories.d.ts +901 -0
  68. package/dist/types/stories/storybookLinks.d.ts +2 -0
  69. package/dist/types/stories/types/visualComponentsTypes.d.ts +2 -0
  70. package/dist/types/stories/types/zDropStoriesStateTypes.d.ts +34 -0
  71. package/package.json +82 -0
@@ -0,0 +1,760 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useEffect, useState, useCallback, useRef } from 'react';
3
+
4
+ const classNames = (...params) => {
5
+ const classes = [];
6
+ params.forEach((param) => {
7
+ if (typeof param === "string" && param) {
8
+ classes.push(param);
9
+ }
10
+ else if (param && typeof param === "object") {
11
+ Object.entries(param).forEach(([key, value]) => {
12
+ if (value) {
13
+ classes.push(key);
14
+ }
15
+ });
16
+ }
17
+ });
18
+ return classes.join(" ");
19
+ };
20
+
21
+ const useOutsideClose = (ref, onOutsideClose) => {
22
+ useEffect(() => {
23
+ const handleClick = (e) => {
24
+ if (ref &&
25
+ ref.current &&
26
+ !ref.current.contains(e.target)) {
27
+ onOutsideClose(e);
28
+ }
29
+ };
30
+ const handleKey = (e) => {
31
+ if (e.key === "Escape") {
32
+ onOutsideClose(e);
33
+ }
34
+ };
35
+ document.addEventListener("click", handleClick);
36
+ document.addEventListener("keydown", handleKey);
37
+ return () => {
38
+ document.removeEventListener("click", handleClick);
39
+ document.removeEventListener("keydown", handleKey);
40
+ };
41
+ }, [onOutsideClose, ref]);
42
+ };
43
+
44
+ var styles = {"container":"ZDrop-module_container__FMb26","label":"ZDrop-module_label__WDDr6","inputField":"ZDrop-module_inputField__QPEyq","inputField--multiple":"ZDrop-module_inputField--multiple__ceTgA","inputField--disabled":"ZDrop-module_inputField--disabled__Iocv1","input":"ZDrop-module_input__k-MBA","inputSingle":"ZDrop-module_inputSingle__zZmCf","inputSingleSearch":"ZDrop-module_inputSingleSearch__oIk6K","inputMultiple":"ZDrop-module_inputMultiple__oF9wt","inputMultipleValue":"ZDrop-module_inputMultipleValue__lSYME","inputMultipleValueRemoveBtn":"ZDrop-module_inputMultipleValueRemoveBtn__gbFkS","inputMultipleValueRemoveBtnIcon":"ZDrop-module_inputMultipleValueRemoveBtnIcon__i4VBS","inputMultipleSearchWrapper":"ZDrop-module_inputMultipleSearchWrapper__vmS7x","inputMultipleSearch":"ZDrop-module_inputMultipleSearch__-lQrC","inputMultiplePlaceholder":"ZDrop-module_inputMultiplePlaceholder__GbBo7","inputClearBtnWrapper":"ZDrop-module_inputClearBtnWrapper__S3uiC","inputClearBtn":"ZDrop-module_inputClearBtn__JY5Gm","inputClearBtnIcon":"ZDrop-module_inputClearBtnIcon__PXRiJ","expandToggle":"ZDrop-module_expandToggle__zJYI1","expandToggleIcon":"ZDrop-module_expandToggleIcon__63Yog","expandToggleIcon--active":"ZDrop-module_expandToggleIcon--active__h2I5u","listWrapper":"ZDrop-module_listWrapper__FGHRj","list":"ZDrop-module_list__162r4","option":"ZDrop-module_option__ZfKFl","noData":"ZDrop-module_noData__-70Uu","option--active":"ZDrop-module_option--active__OXcv5"};
45
+
46
+ const ZDropLabel = (props) => {
47
+ const { name, label, className } = props;
48
+ const labelClasses = classNames(styles.label, className);
49
+ if (typeof label === "string") {
50
+ return (jsx("label", { htmlFor: name, className: labelClasses, children: label }));
51
+ }
52
+ return jsx("div", { className: className, children: label });
53
+ };
54
+
55
+ const ZDropListItem = (props) => {
56
+ const { option, index, labelKey, innerRef, onOptionClick, onOptionKeyDown, className, children, } = props;
57
+ const onListItemClick = (e) => {
58
+ onOptionClick(e, option);
59
+ };
60
+ const onListItemKeyDown = (e) => {
61
+ onOptionKeyDown(e, option, index);
62
+ };
63
+ return (jsx("li", { tabIndex: 0, ref: innerRef, className: className, onClick: onListItemClick, onKeyDown: onListItemKeyDown, children: children || (labelKey && option[labelKey]) || option }));
64
+ };
65
+
66
+ const ZDropListNoData = (props) => {
67
+ const { noDataContent, className } = props;
68
+ const noDataClasses = classNames(styles.noData, className);
69
+ return jsx("li", { className: noDataClasses, children: noDataContent });
70
+ };
71
+
72
+ const checkIsValueEqualToOption = (selectedValue, option, valueKey) => {
73
+ if (selectedValue === undefined || option === undefined) {
74
+ return false;
75
+ }
76
+ if (Array.isArray(selectedValue)) {
77
+ return selectedValue.some((value) => checkIsValueEqualToOption(value, option, valueKey));
78
+ }
79
+ const optionIsObject = typeof option === "object" && option !== null;
80
+ const selectedIsObject = typeof selectedValue === "object" && selectedValue !== null;
81
+ if (selectedValue === option) {
82
+ return true;
83
+ }
84
+ if (!selectedIsObject && optionIsObject) {
85
+ return selectedValue === option[valueKey];
86
+ }
87
+ if (selectedIsObject && optionIsObject) {
88
+ return selectedValue[valueKey] === option[valueKey];
89
+ }
90
+ return false;
91
+ };
92
+
93
+ const checkIsEqualMultiple = (checkIsInputValueEqualToOptionValue, value, option, valueKey) => value.some((value) => checkIsInputValueEqualToOptionValue(value, option, valueKey));
94
+ const ZDropList = (props) => {
95
+ const { options = [], selectedValue, valueKey, labelKey, optionsRef, optionRenderer, onOptionClick, onOptionKeyDown, noDataContent, currentSearchedValue, listStyleClasses, } = props;
96
+ const dropdownListClasses = classNames(styles.list, listStyleClasses === null || listStyleClasses === void 0 ? void 0 : listStyleClasses.list);
97
+ const getListItemClasses = (option) => {
98
+ if (Array.isArray(selectedValue)) {
99
+ return classNames(styles.option, listStyleClasses === null || listStyleClasses === void 0 ? void 0 : listStyleClasses.listItem, {
100
+ [styles["option--active"]]: checkIsEqualMultiple(checkIsValueEqualToOption, selectedValue, option, valueKey),
101
+ });
102
+ }
103
+ return classNames(styles.option, listStyleClasses === null || listStyleClasses === void 0 ? void 0 : listStyleClasses.listItem, {
104
+ [styles["option--active"]]: checkIsValueEqualToOption(selectedValue, option, valueKey),
105
+ });
106
+ };
107
+ if (options.length === 0) {
108
+ return (jsx(ZDropListNoData, { noDataContent: noDataContent, className: listStyleClasses === null || listStyleClasses === void 0 ? void 0 : listStyleClasses.noData }));
109
+ }
110
+ return (jsx("ul", { className: dropdownListClasses, children: options.map((option, index) => (jsx(ZDropListItem, { innerRef: (el) => {
111
+ optionsRef.current[index] = el;
112
+ }, option: option, index: index, labelKey: labelKey, onOptionClick: onOptionClick, onOptionKeyDown: onOptionKeyDown, className: getListItemClasses(option), children: optionRenderer === null || optionRenderer === void 0 ? void 0 : optionRenderer(option, Array.isArray(selectedValue)
113
+ ? checkIsEqualMultiple(checkIsValueEqualToOption, selectedValue, option, valueKey)
114
+ : checkIsValueEqualToOption(selectedValue, option, valueKey), currentSearchedValue) }, (option === null || option === void 0 ? void 0 : option[valueKey]) || index))) }));
115
+ };
116
+
117
+ const ZDropListVisibilityToggle = (props) => {
118
+ const { expandToggleRenderer, onClick, isListVisible, toggleStyleClasses } = props;
119
+ const toggleClasses = classNames(styles.expandToggle, toggleStyleClasses === null || toggleStyleClasses === void 0 ? void 0 : toggleStyleClasses.expandToggle);
120
+ const iconClasses = classNames(styles.expandToggleIcon, toggleStyleClasses === null || toggleStyleClasses === void 0 ? void 0 : toggleStyleClasses.expandToggleIcon, {
121
+ [styles["expandToggleIcon--active"]]: isListVisible,
122
+ });
123
+ return (jsx("div", { className: toggleClasses, onClick: onClick, children: expandToggleRenderer ? (jsx("span", { children: expandToggleRenderer(isListVisible) })) : (jsx("span", { className: iconClasses })) }));
124
+ };
125
+
126
+ const checkIsClearHidden = (hasValueChanged, currentSearchedValue, isListVisible, isClearableOnlyWhenChange, isClearableOnlyWhenSearch) => {
127
+ if (isClearableOnlyWhenChange && !isListVisible && hasValueChanged) {
128
+ return false;
129
+ }
130
+ if (isClearableOnlyWhenSearch && isListVisible && currentSearchedValue) {
131
+ return false;
132
+ }
133
+ if (!isClearableOnlyWhenChange &&
134
+ !isClearableOnlyWhenSearch &&
135
+ (currentSearchedValue || hasValueChanged)) {
136
+ return false;
137
+ }
138
+ return true;
139
+ };
140
+
141
+ const ZDropClearButton = (props) => {
142
+ const { hasValueChanged, currentSearchedValue, onInputClear, isListVisible, isClearableOnlyWhenChange, isClearableOnlyWhenSearch, className, clearIcon, } = props;
143
+ const clearButtonClasses = classNames(styles.inputClearBtn, className);
144
+ const onClear = (e) => {
145
+ e.preventDefault();
146
+ e.stopPropagation();
147
+ e.nativeEvent.stopImmediatePropagation();
148
+ onInputClear();
149
+ };
150
+ if (checkIsClearHidden(hasValueChanged, currentSearchedValue, isListVisible, isClearableOnlyWhenChange, isClearableOnlyWhenSearch)) {
151
+ return null;
152
+ }
153
+ return (jsx("div", { className: styles.inputClearBtnWrapper, children: jsx("button", { tabIndex: -1, className: clearButtonClasses, onClick: onClear, children: clearIcon || jsx("span", { className: styles.inputClearBtnIcon }) }) }));
154
+ };
155
+
156
+ const ZDropMultipleInputValue = (props) => {
157
+ const { option, labelType, onInputOptionRemove, valueRenderer, inputMultipleValueClassName, isDisabled, } = props;
158
+ const inputItemClasses = classNames(styles.inputMultipleValue, inputMultipleValueClassName);
159
+ if (option === null || option === undefined) {
160
+ return null;
161
+ }
162
+ if (valueRenderer) {
163
+ return (jsx("li", { tabIndex: 0, className: inputItemClasses, onKeyDown: (e) => {
164
+ if (["Enter", " "].includes(e.key)) {
165
+ onInputOptionRemove(e, option);
166
+ }
167
+ }, children: valueRenderer === null || valueRenderer === void 0 ? void 0 : valueRenderer({
168
+ option,
169
+ onRemove: (e) => onInputOptionRemove(e, option),
170
+ }) }));
171
+ }
172
+ return (jsxs("li", { tabIndex: -1, className: inputItemClasses, children: [jsx("span", { children: typeof option === "object" && option !== null
173
+ ? option[labelType] || option
174
+ : option }), onInputOptionRemove && !isDisabled && (jsx("button", { tabIndex: 0, className: styles.inputMultipleValueRemoveBtn, onClick: (e) => onInputOptionRemove(e, option), children: jsx("span", { className: styles.inputMultipleValueRemoveBtnIcon }) }))] }));
175
+ };
176
+
177
+ const ZDropMultipleInput = (props) => {
178
+ const { isListVisible, setIsListVisible, name, selectedValue, valueKey, labelKey, placeholder, isDisabled, isSearchable, currentSearchedValue, valueRenderer, inputRefMultipleValueRenderer, onInputClick, onInputKeyDown, onInputChange, onInputOptionRemove, inputClassName, inputMultipleValueClassName, inputMultipleSearchClassName, } = props;
179
+ const inputSelectClasses = classNames(styles.input, styles.inputMultiple, inputClassName);
180
+ const inputMultipleSearchClasses = classNames(styles.inputMultipleSearch);
181
+ const inputMultipleSearchWrapperClasses = classNames(styles.inputMultiple, styles.inputMultipleSearchWrapper, inputMultipleSearchClassName);
182
+ const onKeyDown = (e) => {
183
+ if (["Enter"].includes(e.key)) {
184
+ e.preventDefault();
185
+ }
186
+ };
187
+ const onPlaceholderClick = (e) => {
188
+ e.preventDefault();
189
+ e.stopPropagation();
190
+ setIsListVisible(true);
191
+ };
192
+ return (jsxs("ul", { tabIndex: 0, className: inputSelectClasses, onClick: onInputClick, onKeyDown: onInputKeyDown, ...(isDisabled && { style: { pointerEvents: "none" } }), children: [selectedValue.map((option) => (jsx(ZDropMultipleInputValue, { option: option, labelType: labelKey, onInputOptionRemove: onInputOptionRemove, valueRenderer: valueRenderer, inputMultipleValueClassName: inputMultipleValueClassName, isDisabled: isDisabled }, typeof option === "object" && !Array.isArray(option)
193
+ ? option[valueKey]
194
+ : option))), ((!isListVisible && selectedValue.length === 0) ||
195
+ ((selectedValue.length === 0 || !selectedValue) && !isSearchable)) && (jsx("span", { className: styles.inputMultiplePlaceholder, onClick: onPlaceholderClick, children: placeholder })), isSearchable && isListVisible && (jsx("li", { className: inputMultipleSearchWrapperClasses, children: jsx("input", { ref: inputRefMultipleValueRenderer, name: name, className: inputMultipleSearchClasses, placeholder: "search ...", value: currentSearchedValue, onChange: onInputChange, onKeyDown: onKeyDown }) }))] }));
196
+ };
197
+
198
+ const ZDropSingleInputValueRenderer = (props) => {
199
+ const { name, isInputItemVisible, isSearchable, selectedValue, selectedOption, valueRenderer, inputValue, isListVisible, placeholder, inputRefSingleValueRenderer, onChange, onInputItemClick, onInputOptionRemove, inputValueClassName, } = props;
200
+ const inputValueClasses = classNames(styles.inputSingleSearch, inputValueClassName);
201
+ return (jsxs(Fragment, { children: [isInputItemVisible && selectedOption !== undefined && (jsx("div", { onClick: onInputItemClick, children: valueRenderer({
202
+ option: selectedOption,
203
+ onRemove: (e) => onInputOptionRemove(e, selectedOption),
204
+ }) })), ((!isListVisible &&
205
+ !isSearchable &&
206
+ (typeof selectedValue === "undefined" || selectedValue === "")) ||
207
+ (isListVisible && !isSearchable)) &&
208
+ placeholder, isSearchable && !isInputItemVisible && (jsx("input", { ref: inputRefSingleValueRenderer, name: name, tabIndex: isInputItemVisible ? 0 : -1, value: inputValue, onChange: onChange, className: inputValueClasses, placeholder: placeholder }))] }));
209
+ };
210
+
211
+ const getLabelFromOption = (options, selectedValue, valueKey, labelKey) => {
212
+ const foundOption = options.find((option) => {
213
+ if (typeof option === "object" &&
214
+ option !== null &&
215
+ (typeof selectedValue === "string" || typeof selectedValue === "number")) {
216
+ return option[valueKey] === selectedValue;
217
+ }
218
+ if (typeof option === "object" &&
219
+ option !== null &&
220
+ typeof selectedValue === "object" &&
221
+ selectedValue !== null) {
222
+ return option[valueKey] === selectedValue[valueKey];
223
+ }
224
+ return option === selectedValue;
225
+ });
226
+ if (foundOption !== undefined && foundOption !== null) {
227
+ return typeof foundOption === "object"
228
+ ? foundOption[labelKey]
229
+ : foundOption;
230
+ }
231
+ return "";
232
+ };
233
+ const ZDropSingleInput = (props) => {
234
+ const { options, name, selectedValue, currentSearchedValue, setCurrentSearchedValue, valueKey, labelKey, isListVisible, placeholder, isDisabled, isSearchable = false, valueRenderer, inputRef, inputRefSingleValueRenderer, onInputClick, onInputItemClick, onInputKeyDown, onInputChange, onInputOptionRemove, isInputItemVisible, inputValueClassName, inputClassName, } = props;
235
+ const [inputValue, setInputValue] = useState(getLabelFromOption(options, selectedValue, valueKey, valueKey));
236
+ const inputSelectClasses = classNames(styles.input, inputClassName, {
237
+ [styles.inputSingle]: !!valueRenderer,
238
+ });
239
+ const selectedOption = options.find((option) => {
240
+ if (typeof option === "object" &&
241
+ option !== null &&
242
+ typeof selectedValue === "object" &&
243
+ selectedValue !== null) {
244
+ return option[valueKey] === selectedValue[valueKey];
245
+ }
246
+ if (typeof option === "object" &&
247
+ option !== null &&
248
+ selectedValue !== undefined &&
249
+ (typeof selectedValue === "string" || typeof selectedValue === "number")) {
250
+ return option[valueKey] === selectedValue;
251
+ }
252
+ return option === selectedValue;
253
+ });
254
+ const onClick = (e) => {
255
+ onInputClick(e);
256
+ if (isSearchable && !isListVisible) {
257
+ setInputValue("");
258
+ }
259
+ };
260
+ const onChange = (e) => {
261
+ onInputChange(e);
262
+ setInputValue(e.target.value);
263
+ setCurrentSearchedValue === null || setCurrentSearchedValue === void 0 ? void 0 : setCurrentSearchedValue(e.target.value);
264
+ };
265
+ useEffect(() => {
266
+ if (selectedValue !== undefined) {
267
+ setInputValue(getLabelFromOption(options, selectedValue, valueKey, labelKey));
268
+ }
269
+ }, [selectedValue]);
270
+ useEffect(() => {
271
+ if (!isListVisible && isSearchable) {
272
+ setInputValue(getLabelFromOption(options, selectedValue, valueKey, labelKey));
273
+ return;
274
+ }
275
+ currentSearchedValue !== undefined && setInputValue(currentSearchedValue);
276
+ }, [isListVisible]);
277
+ useEffect(() => {
278
+ if (currentSearchedValue === "") {
279
+ setInputValue("");
280
+ }
281
+ }, [currentSearchedValue]);
282
+ if (valueRenderer) {
283
+ return (jsx("div", { tabIndex: 0, className: inputSelectClasses, onClick: onInputClick, onKeyDown: onInputKeyDown, ...(isDisabled && {
284
+ style: { pointerEvents: "none" },
285
+ }), children: jsx(ZDropSingleInputValueRenderer, { name: name, isInputItemVisible: isInputItemVisible, isSearchable: isSearchable, selectedValue: selectedValue, selectedOption: selectedOption, valueRenderer: valueRenderer, inputValue: inputValue, isListVisible: isListVisible, placeholder: placeholder, inputRefSingleValueRenderer: inputRefSingleValueRenderer, onChange: onChange, onInputItemClick: onInputItemClick, onInputOptionRemove: onInputOptionRemove, inputValueClassName: inputValueClassName }) }));
286
+ }
287
+ return (jsx("input", { ref: inputRef, className: inputSelectClasses, name: name, type: "text", value: inputValue, placeholder: placeholder, disabled: isDisabled, onClick: onClick, onChange: onChange, onKeyDown: onInputKeyDown, readOnly: !isSearchable }));
288
+ };
289
+
290
+ const ZDropInput = (props) => {
291
+ const { name, options, selectedValue, currentSearchedValue, setCurrentSearchedValue, valueKey, labelKey, placeholder, isMultiple, isDisabled, isSearchable, isListVisible, setIsListVisible, isInputItemVisible, valueRenderer, inputRef, inputRefMultipleValueRenderer, inputRefSingleValueRenderer, onInputClick, onInputItemClick, onInputKeyDown, onInputChange, onInputOptionRemove, inputStyleClasses, } = props;
292
+ if (isMultiple && Array.isArray(selectedValue)) {
293
+ return (jsx(ZDropMultipleInput, { isListVisible: isListVisible, setIsListVisible: setIsListVisible, name: name, selectedValue: selectedValue, valueKey: valueKey, labelKey: labelKey, placeholder: placeholder, isDisabled: isDisabled, isSearchable: isSearchable, currentSearchedValue: currentSearchedValue, valueRenderer: valueRenderer, inputRefMultipleValueRenderer: inputRefMultipleValueRenderer, onInputClick: onInputClick, onInputKeyDown: onInputKeyDown, onInputChange: onInputChange, onInputOptionRemove: onInputOptionRemove, inputClassName: inputStyleClasses === null || inputStyleClasses === void 0 ? void 0 : inputStyleClasses.input, inputMultipleValueClassName: inputStyleClasses === null || inputStyleClasses === void 0 ? void 0 : inputStyleClasses.inputMultipleValue, inputMultipleSearchClassName: inputStyleClasses === null || inputStyleClasses === void 0 ? void 0 : inputStyleClasses.inputMultipleSearch }));
294
+ }
295
+ return (jsx(ZDropSingleInput, { options: options, name: name, selectedValue: selectedValue, currentSearchedValue: currentSearchedValue, setCurrentSearchedValue: setCurrentSearchedValue, valueKey: valueKey, labelKey: labelKey, isListVisible: isListVisible, placeholder: placeholder, isDisabled: isDisabled, isSearchable: isSearchable, valueRenderer: valueRenderer, isInputItemVisible: isInputItemVisible, inputRef: inputRef, inputRefSingleValueRenderer: inputRefSingleValueRenderer, onInputClick: onInputClick, onInputItemClick: onInputItemClick, onInputKeyDown: onInputKeyDown, onInputChange: onInputChange, onInputOptionRemove: onInputOptionRemove, inputClassName: inputStyleClasses === null || inputStyleClasses === void 0 ? void 0 : inputStyleClasses.input, inputValueClassName: inputStyleClasses === null || inputStyleClasses === void 0 ? void 0 : inputStyleClasses.inputValue }));
296
+ };
297
+
298
+ const isObj = (x) => typeof x === "object" && x !== null;
299
+ const findOption = (options = [], selected, valueKey) => {
300
+ const key = isObj(selected) && valueKey in selected ? selected[valueKey] : selected;
301
+ const found = options.find((option) => {
302
+ return isObj(option)
303
+ ? valueKey in option && option[valueKey] === key
304
+ : option === key;
305
+ });
306
+ return found;
307
+ };
308
+
309
+ const defaultSearchFilter = (props) => {
310
+ const { options, currentValue, labelKey } = props;
311
+ const searchedValue = currentValue || "";
312
+ if (options.every((option) => typeof option === "string" || typeof option === "number")) {
313
+ return options.filter((option) => option.toString().toLowerCase().includes(searchedValue.toLowerCase()));
314
+ }
315
+ return options === null || options === void 0 ? void 0 : options.filter((option) => {
316
+ var _a;
317
+ return typeof option === "object" &&
318
+ option !== null &&
319
+ ((_a = option[labelKey]) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().includes(searchedValue.toLowerCase()));
320
+ });
321
+ };
322
+
323
+ const getCurrentMultipleValue = (selected, selectedValue, options, valueKey) => {
324
+ const isSelectedValueArray = Array.isArray(selectedValue);
325
+ if (isSelectedValueArray &&
326
+ selectedValue.some((val) => val === findOption(selectedValue, selected, valueKey))) {
327
+ return selectedValue;
328
+ }
329
+ if (Array.isArray(selected)) {
330
+ return options.filter((option) => findOption(selected, option, valueKey) ||
331
+ findOption(selected, option, valueKey) === 0);
332
+ }
333
+ return [...(isSelectedValueArray ? selectedValue : []), selected];
334
+ };
335
+
336
+ const getElementOffsetTop = (element) => {
337
+ var _a, _b, _c;
338
+ if (!element)
339
+ return 0;
340
+ const rect = element.getBoundingClientRect();
341
+ const scrollTop = (_c = (_b = (_a = window.pageYOffset) !== null && _a !== void 0 ? _a : document.documentElement.scrollTop) !== null && _b !== void 0 ? _b : document.body.scrollTop) !== null && _c !== void 0 ? _c : 0;
342
+ return rect.top + scrollTop;
343
+ };
344
+ const getReferenceElementDimensions = (element, elementParentClass) => {
345
+ const parent = element === null || element === void 0 ? void 0 : element.parentElement;
346
+ if (!parent)
347
+ return;
348
+ if (parent.classList.contains(elementParentClass)) {
349
+ const top = getElementOffsetTop(parent);
350
+ const height = parent.scrollHeight;
351
+ return {
352
+ top,
353
+ bottom: top + height,
354
+ height,
355
+ };
356
+ }
357
+ return getReferenceElementDimensions(parent, elementParentClass);
358
+ };
359
+
360
+ const distanceGap = 0;
361
+ const marginTop = 10;
362
+ const minUsableHeight = 50;
363
+ const calculateHeightForTop = (scrollHeight, maxHeightLimiter, wrapperMaxHeight) => {
364
+ const currentHeightLimiter = maxHeightLimiter < wrapperMaxHeight ? maxHeightLimiter : wrapperMaxHeight;
365
+ return scrollHeight > currentHeightLimiter
366
+ ? currentHeightLimiter
367
+ : scrollHeight;
368
+ };
369
+ const ZDropListWrapper = (props) => {
370
+ const { referenceElementClassName, positionToReferenceElement = "bottom", listMaxHeightLimiter, children, } = props;
371
+ const [maxSpaceAbove, setMaxSpaceAbove] = useState(0);
372
+ const [maxSpaceBelow, setMaxSpaceBelow] = useState(0);
373
+ const [scrollHeight, setScrollHeight] = useState(0);
374
+ const hasTopSpace = maxSpaceAbove > minUsableHeight;
375
+ const hasBottomSpace = maxSpaceBelow > minUsableHeight;
376
+ let finalPosition;
377
+ if (positionToReferenceElement === "top") {
378
+ if (hasTopSpace) {
379
+ finalPosition = "top";
380
+ }
381
+ else if (hasBottomSpace) {
382
+ finalPosition = "bottom";
383
+ }
384
+ else {
385
+ finalPosition = maxSpaceAbove >= maxSpaceBelow ? "top" : "bottom";
386
+ }
387
+ }
388
+ else {
389
+ if (hasBottomSpace) {
390
+ finalPosition = "bottom";
391
+ }
392
+ else if (hasTopSpace) {
393
+ finalPosition = "top";
394
+ }
395
+ else {
396
+ finalPosition = maxSpaceBelow >= maxSpaceAbove ? "bottom" : "top";
397
+ }
398
+ }
399
+ const heightForBottom = Math.min(scrollHeight, maxSpaceBelow, listMaxHeightLimiter !== null && listMaxHeightLimiter !== void 0 ? listMaxHeightLimiter : maxSpaceBelow);
400
+ const heightForTop = calculateHeightForTop(scrollHeight, listMaxHeightLimiter !== null && listMaxHeightLimiter !== void 0 ? listMaxHeightLimiter : maxSpaceAbove, maxSpaceAbove);
401
+ const finalHeight = finalPosition === "top" ? heightForTop : heightForBottom;
402
+ const setWrapperMaxSpaces = (element, referenceElementClassName) => {
403
+ const wrapperListOffsetTop = getElementOffsetTop(element);
404
+ const referenceElement = getReferenceElementDimensions(element, referenceElementClassName);
405
+ if (referenceElement) {
406
+ const above = Math.max(wrapperListOffsetTop - referenceElement.top - distanceGap, 0);
407
+ const below = Math.max(referenceElement.bottom - wrapperListOffsetTop - distanceGap, 0);
408
+ setMaxSpaceAbove(above);
409
+ setMaxSpaceBelow(below);
410
+ const content = element.children[0];
411
+ setScrollHeight(content ? content.scrollHeight : 0);
412
+ }
413
+ };
414
+ const listWrapperRef = useCallback((node) => {
415
+ if (node) {
416
+ setWrapperMaxSpaces(node, referenceElementClassName);
417
+ }
418
+ }, [referenceElementClassName]);
419
+ const wrapperStyle = {
420
+ position: "absolute",
421
+ height: `${finalHeight}px`,
422
+ maxHeight: `${finalHeight}px`,
423
+ ...(finalPosition === "top"
424
+ ? { top: `-${finalHeight + marginTop}px` }
425
+ : { top: "100%" }),
426
+ };
427
+ return (jsx("div", { className: styles.listWrapper, ref: listWrapperRef, style: wrapperStyle, children: children }));
428
+ };
429
+
430
+ const deepEqual = (a, b) => {
431
+ if (a === b)
432
+ return true;
433
+ if (a == null || b == null)
434
+ return false;
435
+ if (typeof a !== "object" || typeof b !== "object")
436
+ return false;
437
+ if (Array.isArray(a) && Array.isArray(b)) {
438
+ if (a.length !== b.length)
439
+ return false;
440
+ return a.every((el, i) => deepEqual(el, b[i]));
441
+ }
442
+ const keysA = Object.keys(a);
443
+ const keysB = Object.keys(b);
444
+ if (keysA.length !== keysB.length)
445
+ return false;
446
+ return keysA.every((key) => deepEqual(a[key], b[key]));
447
+ };
448
+
449
+ const ZDrop = (props) => {
450
+ const { name, options = [], value, valueKey = "value", label, labelKey = "label", placeholder, isMultiple = false, isDisabled = false, isSearchable = false, clear = "none", searchFilterDelay, searchFilter = defaultSearchFilter, shouldReturnObjectOnChange = false, onChange, onClear, valueRenderer, optionRenderer, expandToggleRenderer, clearIcon, noDataContent, referenceElementClassName, positionToReferenceElement, listMaxHeightLimiter, styleClasses, } = props;
451
+ const containerRef = useRef(null);
452
+ const inputRef = useRef(null);
453
+ const inputRefSingleValueRenderer = useRef(null);
454
+ const inputRefMultipleValueRenderer = useRef(null);
455
+ const optionsRef = useRef([]);
456
+ const timerRef = useRef(null);
457
+ const isValueCorrect = value !== undefined && value !== null && value !== "";
458
+ const isClearable = ["always", "whenChanged", "whenSearched"].includes(clear);
459
+ const isClearableOnlyWhenChange = clear === "whenChanged";
460
+ const isClearableOnlyWhenSearch = clear === "whenSearched";
461
+ const [optionsData, setOptionsData] = useState([]);
462
+ const [selectedValue, setSelectedValue] = useState(isMultiple ? [] : "");
463
+ const [isListVisible, setIsListVisible] = useState(false);
464
+ const [isInputItemVisible, setIsInputItemVisible] = useState(isValueCorrect);
465
+ const [currentSearchedValue, setCurrentSearchedValue] = useState("");
466
+ const [hasValueChanged, setHasValueChanged] = useState(false);
467
+ const isSelectedValueCorrect = selectedValue !== undefined &&
468
+ selectedValue !== null &&
469
+ selectedValue !== "";
470
+ const containerClasses = classNames(styles.container, styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.container);
471
+ const inputFieldClasses = classNames(styles.inputField, styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.inputField, {
472
+ [styles["inputField--multiple"]]: isMultiple,
473
+ [styles["inputField--disabled"]]: isDisabled,
474
+ });
475
+ const updateOptionsDataBySearch = (options, currentValue, labelKey) => {
476
+ const searchResult = searchFilter({
477
+ options,
478
+ currentValue,
479
+ labelKey,
480
+ });
481
+ setOptionsData(searchResult ? searchResult : options);
482
+ };
483
+ const setCurrentValue = (selected) => {
484
+ if (isMultiple) {
485
+ const currentMultipleSelected = getCurrentMultipleValue(selected, selectedValue, options, valueKey);
486
+ setSelectedValue(currentMultipleSelected);
487
+ onChange === null || onChange === void 0 ? void 0 : onChange(currentMultipleSelected);
488
+ return;
489
+ }
490
+ setCurrentSearchedValue("");
491
+ setIsListVisible(false);
492
+ setOptionsData(options || []);
493
+ setSelectedValue(selected);
494
+ if (shouldReturnObjectOnChange && typeof selected === "object") {
495
+ onChange === null || onChange === void 0 ? void 0 : onChange(selected);
496
+ return;
497
+ }
498
+ onChange === null || onChange === void 0 ? void 0 : onChange((typeof selected === "object" && (selected === null || selected === void 0 ? void 0 : selected[valueKey])) ||
499
+ selected);
500
+ };
501
+ const defaultInputValue = useCallback((defaultValue) => {
502
+ var _a;
503
+ if (isMultiple && Array.isArray(defaultValue)) {
504
+ const multipleValues = options === null || options === void 0 ? void 0 : options.filter((option) => defaultValue.some((valueItem) => checkIsValueEqualToOption(valueItem, option, valueKey)));
505
+ return multipleValues || [];
506
+ }
507
+ return (_a = findOption(options, defaultValue, valueKey)) !== null && _a !== void 0 ? _a : "";
508
+ }, [isMultiple, options, value, selectedValue, valueKey]);
509
+ const onExpandToggleClick = (e) => {
510
+ e.preventDefault();
511
+ e.stopPropagation();
512
+ if (isDisabled) {
513
+ return;
514
+ }
515
+ setIsListVisible((prev) => !prev);
516
+ if (!isMultiple && isSelectedValueCorrect && valueRenderer) {
517
+ setIsInputItemVisible((prev) => !prev);
518
+ }
519
+ };
520
+ const onInputFieldClick = (e) => {
521
+ e.preventDefault();
522
+ e.stopPropagation();
523
+ if (e.target.tagName === "INPUT") {
524
+ return;
525
+ }
526
+ if (isDisabled) {
527
+ return;
528
+ }
529
+ if (isListVisible) {
530
+ setIsListVisible(false);
531
+ }
532
+ if (isListVisible &&
533
+ !isMultiple &&
534
+ valueRenderer &&
535
+ isSelectedValueCorrect) {
536
+ setIsInputItemVisible(true);
537
+ }
538
+ };
539
+ const onInputClick = (e) => {
540
+ e.preventDefault();
541
+ if (!isListVisible) {
542
+ setIsListVisible(true);
543
+ }
544
+ if (!isListVisible && !isMultiple && valueRenderer) {
545
+ setIsInputItemVisible(false);
546
+ }
547
+ if (!isListVisible && isSearchable && isSelectedValueCorrect) {
548
+ updateOptionsDataBySearch(options || [], currentSearchedValue, labelKey);
549
+ }
550
+ };
551
+ const onInputChange = useCallback((e) => {
552
+ const currentValue = e.target.value;
553
+ if (isSearchable) {
554
+ setCurrentSearchedValue(currentValue);
555
+ }
556
+ const inputSelectChange = (currentValue) => {
557
+ if (!isListVisible) {
558
+ setIsListVisible(true);
559
+ }
560
+ if (isSearchable) {
561
+ updateOptionsDataBySearch(options || [], currentValue, labelKey);
562
+ }
563
+ };
564
+ if (searchFilterDelay && searchFilterDelay > 0) {
565
+ if (timerRef.current)
566
+ clearTimeout(timerRef.current);
567
+ timerRef.current = setTimeout(() => inputSelectChange(currentValue), searchFilterDelay);
568
+ }
569
+ else {
570
+ inputSelectChange(currentValue);
571
+ }
572
+ }, [
573
+ selectedValue,
574
+ isMultiple,
575
+ isSearchable,
576
+ isListVisible,
577
+ labelKey,
578
+ options,
579
+ searchFilter,
580
+ searchFilterDelay,
581
+ ]);
582
+ const onInputKeyDown = (e) => {
583
+ var _a;
584
+ if (!isListVisible && ["Enter", " "].includes(e.key)) {
585
+ if (e.currentTarget !== e.target) {
586
+ return;
587
+ }
588
+ e.preventDefault();
589
+ setIsListVisible((prev) => !prev);
590
+ }
591
+ if (e.key === "ArrowDown" && isListVisible) {
592
+ e.preventDefault();
593
+ (_a = optionsRef.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
594
+ }
595
+ if (!isListVisible && isSearchable && !isMultiple && valueRenderer) {
596
+ setIsInputItemVisible(false);
597
+ }
598
+ };
599
+ const applyInputSelectFocus = useCallback(() => {
600
+ var _a, _b, _c;
601
+ if (isMultiple) {
602
+ (_a = inputRefMultipleValueRenderer.current) === null || _a === void 0 ? void 0 : _a.focus();
603
+ return;
604
+ }
605
+ if (valueRenderer) {
606
+ (_b = inputRefSingleValueRenderer.current) === null || _b === void 0 ? void 0 : _b.focus();
607
+ return;
608
+ }
609
+ (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.focus();
610
+ }, [isMultiple, valueRenderer]);
611
+ const onInputItemClick = (e) => {
612
+ e.preventDefault();
613
+ e.stopPropagation();
614
+ setIsInputItemVisible(false);
615
+ setIsListVisible(true);
616
+ };
617
+ const onInputOptionRemove = (e, option) => {
618
+ e.stopPropagation();
619
+ e.preventDefault();
620
+ e.nativeEvent.stopImmediatePropagation();
621
+ if (!isMultiple) {
622
+ setSelectedValue("");
623
+ onChange === null || onChange === void 0 ? void 0 : onChange("");
624
+ }
625
+ else {
626
+ const selectedOptions = [
627
+ ...selectedValue.filter((value) => value !== (option === null || option === void 0 ? void 0 : option[valueKey]) && value !== option),
628
+ ];
629
+ setSelectedValue(selectedOptions);
630
+ onChange === null || onChange === void 0 ? void 0 : onChange(selectedOptions);
631
+ }
632
+ if (!isListVisible) {
633
+ setIsListVisible(true);
634
+ }
635
+ if (isInputItemVisible) {
636
+ setIsInputItemVisible(false);
637
+ }
638
+ };
639
+ const onInputClear = (e) => {
640
+ if (isSearchable && options) {
641
+ setCurrentSearchedValue("");
642
+ setOptionsData(options);
643
+ applyInputSelectFocus();
644
+ }
645
+ if (valueRenderer) {
646
+ (clear === "always" || clear === "whenChanged") &&
647
+ setIsInputItemVisible(false);
648
+ }
649
+ if (!isListVisible) {
650
+ setIsListVisible(true);
651
+ }
652
+ if (isClearable && !isClearableOnlyWhenSearch) {
653
+ setSelectedValue(isMultiple ? [] : "");
654
+ setHasValueChanged(false);
655
+ onChange === null || onChange === void 0 ? void 0 : onChange(isMultiple ? [] : undefined);
656
+ }
657
+ onClear === null || onClear === void 0 ? void 0 : onClear();
658
+ };
659
+ const onOptionClick = (e, option) => {
660
+ var _a, _b, _c;
661
+ e.stopPropagation();
662
+ e.preventDefault();
663
+ e.nativeEvent.stopImmediatePropagation();
664
+ if ((_c = (_b = (_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.closest("div")) === null || _b === void 0 ? void 0 : _b.dataset) === null || _c === void 0 ? void 0 : _c.separator) {
665
+ return;
666
+ }
667
+ setCurrentValue(option);
668
+ setIsListVisible(false);
669
+ if (isClearable && !isClearableOnlyWhenSearch) {
670
+ setHasValueChanged(true);
671
+ }
672
+ if (valueRenderer) {
673
+ setIsInputItemVisible(true);
674
+ }
675
+ };
676
+ const onOptionKeyDown = (e, option, index) => {
677
+ var _a, _b, _c, _d;
678
+ if (["Enter", " "].includes(e.key)) {
679
+ e.preventDefault();
680
+ if ((_b = (_a = e.target.children[0]) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.separator) {
681
+ return;
682
+ }
683
+ setCurrentValue(option);
684
+ if (isClearable && !isClearableOnlyWhenSearch) {
685
+ setHasValueChanged(true);
686
+ }
687
+ if (valueRenderer) {
688
+ setIsInputItemVisible(true);
689
+ }
690
+ }
691
+ if (e.key === "ArrowUp" && index > 0) {
692
+ e.preventDefault();
693
+ (_c = optionsRef.current[index - 1]) === null || _c === void 0 ? void 0 : _c.focus();
694
+ }
695
+ if (e.key === "ArrowDown" && index < optionsData.length - 1) {
696
+ e.preventDefault();
697
+ (_d = optionsRef.current[index + 1]) === null || _d === void 0 ? void 0 : _d.focus();
698
+ }
699
+ if (e.key === "ArrowUp" && index === 0) {
700
+ e.preventDefault();
701
+ applyInputSelectFocus();
702
+ }
703
+ if (e.key === "Backspace") {
704
+ onInputOptionRemove(e, option);
705
+ }
706
+ };
707
+ useOutsideClose(containerRef, () => {
708
+ if (!isListVisible) {
709
+ return;
710
+ }
711
+ setIsListVisible(false);
712
+ if (isSearchable && !currentSearchedValue) {
713
+ setOptionsData(options || []);
714
+ }
715
+ if (valueRenderer && isSelectedValueCorrect) {
716
+ setIsInputItemVisible(true);
717
+ }
718
+ });
719
+ useEffect(() => {
720
+ if (options) {
721
+ setOptionsData(options);
722
+ }
723
+ }, [options]);
724
+ useEffect(() => {
725
+ if (optionsData) {
726
+ optionsRef.current = optionsRef.current.slice(0, optionsData === null || optionsData === void 0 ? void 0 : optionsData.length);
727
+ }
728
+ }, [optionsData]);
729
+ useEffect(() => {
730
+ if (isValueCorrect && !deepEqual(value, selectedValue)) {
731
+ setCurrentValue(defaultInputValue(value));
732
+ valueRenderer && setIsInputItemVisible(true);
733
+ }
734
+ }, []);
735
+ useEffect(() => {
736
+ if (isListVisible && isSearchable) {
737
+ applyInputSelectFocus();
738
+ }
739
+ }, [applyInputSelectFocus, isSearchable, isListVisible]);
740
+ const zDropList = (jsx(ZDropList, { options: optionsData, selectedValue: selectedValue, valueKey: valueKey, labelKey: labelKey, optionsRef: optionsRef, optionRenderer: optionRenderer, onOptionClick: onOptionClick, onOptionKeyDown: onOptionKeyDown, noDataContent: noDataContent, currentSearchedValue: currentSearchedValue, listStyleClasses: {
741
+ list: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.list,
742
+ listItem: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.listItem,
743
+ noData: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.noData,
744
+ } }));
745
+ return (jsxs("div", { ref: containerRef, className: containerClasses, children: [label && (jsx(ZDropLabel, { name: name, label: label, className: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.label })), jsxs("div", { className: inputFieldClasses, onClick: onInputFieldClick, children: [jsx(ZDropInput, { name: name, options: options, selectedValue: selectedValue, ...(isSearchable && {
746
+ currentSearchedValue: currentSearchedValue,
747
+ setCurrentSearchedValue: setCurrentSearchedValue,
748
+ }), valueKey: valueKey, labelKey: labelKey, placeholder: placeholder, isMultiple: isMultiple, isDisabled: isDisabled, isSearchable: isSearchable, isListVisible: isListVisible, setIsListVisible: setIsListVisible, isInputItemVisible: isInputItemVisible, valueRenderer: valueRenderer, onInputClick: onInputClick, onInputItemClick: onInputItemClick, onInputKeyDown: onInputKeyDown, onInputChange: onInputChange, onInputOptionRemove: onInputOptionRemove, inputRef: inputRef, inputRefMultipleValueRenderer: inputRefMultipleValueRenderer, inputRefSingleValueRenderer: inputRefSingleValueRenderer, inputStyleClasses: {
749
+ input: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.input,
750
+ inputValue: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.inputValue,
751
+ inputMultipleValue: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.inputMultipleValue,
752
+ inputMultipleSearch: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.inputMultipleSearch,
753
+ } }), isClearable && (jsx(ZDropClearButton, { hasValueChanged: hasValueChanged, currentSearchedValue: currentSearchedValue, onInputClear: onInputClear, isListVisible: isListVisible, isClearableOnlyWhenChange: isClearableOnlyWhenChange, isClearableOnlyWhenSearch: isClearableOnlyWhenSearch, className: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.clearButton, clearIcon: clearIcon })), jsx(ZDropListVisibilityToggle, { expandToggleRenderer: expandToggleRenderer, isListVisible: isListVisible, onClick: onExpandToggleClick, toggleStyleClasses: {
754
+ expandToggle: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.expandToggle,
755
+ expandToggleIcon: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.expandToggleIcon,
756
+ } })] }), isListVisible && !referenceElementClassName && zDropList, isListVisible && referenceElementClassName && (jsx(ZDropListWrapper, { referenceElementClassName: referenceElementClassName, positionToReferenceElement: positionToReferenceElement, listMaxHeightLimiter: listMaxHeightLimiter, children: zDropList }))] }));
757
+ };
758
+
759
+ export { ZDrop };
760
+ //# sourceMappingURL=index.esm.js.map