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