zcomponents-ui 1.1.5 → 1.2.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.
- package/dist/{index-BM8rL7xh.js → index-CfSBwowY.js} +255 -120
- package/dist/index-CfSBwowY.js.map +1 -0
- package/dist/{index-CR39mAMA.js → index-DC_KVC71.js} +254 -122
- package/dist/index-DC_KVC71.js.map +1 -0
- package/dist/index.cjs.js +315 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +80 -3
- package/dist/index.esm.js +319 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/react-hook-form.cjs.js +1 -1
- package/dist/react-hook-form.d.ts +38 -13
- package/dist/react-hook-form.esm.js +1 -1
- package/dist/types/components/ZDrop/components/ZDropList/ZDropListAutoHeightWrapper/index.d.ts +3 -0
- package/dist/types/components/ZDrop/components/ZDropList/ZDropListWrapper/index.d.ts +2 -8
- package/dist/types/components/ZDrop/helpers/checkIsClearButtonHidden.d.ts +1 -0
- package/dist/types/components/ZDrop/helpers/checkIsOptionSelected.d.ts +12 -0
- package/dist/types/components/ZDrop/helpers/checkIsValueEqualToSelectedValue.d.ts +2 -0
- package/dist/types/components/ZDrop/helpers/getLabelFromOption.d.ts +2 -0
- package/dist/types/components/ZDrop/helpers/searchFilter.d.ts +2 -2
- package/dist/types/components/ZDrop/types/zDropTypes.d.ts +37 -12
- package/dist/types/components/ZDropButton/components/ZDropButtonContent/index.d.ts +3 -0
- package/dist/types/components/ZDropButton/components/ZDropButtonList/index.d.ts +3 -0
- package/dist/types/components/ZDropButton/components/ZDropButtonListItem/index.d.ts +3 -0
- package/dist/types/components/ZDropButton/components/ZDropButtonSearch/index.d.ts +3 -0
- package/dist/types/components/ZDropButton/components/ZDropButtonToggle/index.d.ts +3 -0
- package/dist/types/components/ZDropButton/index.d.ts +10 -0
- package/dist/types/components/ZDropButton/types/zDropButtonTypes.d.ts +69 -0
- package/dist/types/helpers/classNames.d.ts +1 -1
- package/dist/types/helpers/getAvailableSpace.d.ts +6 -0
- package/dist/types/{helpers → hooks}/useOutsideClose.d.ts +4 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/zcomponents-ui.css +1 -1
- package/dist/zcomponents-ui.css.map +1 -1
- package/package.json +1 -1
- package/dist/index-BM8rL7xh.js.map +0 -1
- package/dist/index-CR39mAMA.js.map +0 -1
- package/dist/types/components/ZDrop/helpers/checkIsClearHidden.d.ts +0 -1
- package/dist/types/helpers/checkIsClearHidden.d.ts +0 -1
- package/dist/types/helpers/checkIsEqual.d.ts +0 -2
- package/dist/types/helpers/findDefaultValue.d.ts +0 -1
- package/dist/types/helpers/removeOrReplaceCharacter.d.ts +0 -1
- package/dist/types/helpers/searchFilter.d.ts +0 -2
- package/dist/types/helpers/shrinkName.d.ts +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
|
-
import { useEffect, useState,
|
|
3
|
+
import { useEffect, useState, useRef, useLayoutEffect, useCallback } from 'react';
|
|
4
4
|
|
|
5
5
|
const classNames = (...params) => {
|
|
6
6
|
const classes = [];
|
|
@@ -10,7 +10,7 @@ const classNames = (...params) => {
|
|
|
10
10
|
}
|
|
11
11
|
else if (param && typeof param === "object") {
|
|
12
12
|
Object.entries(param).forEach(([key, value]) => {
|
|
13
|
-
if (value) {
|
|
13
|
+
if (typeof key === "string" && key !== "undefined" && value) {
|
|
14
14
|
classes.push(key);
|
|
15
15
|
}
|
|
16
16
|
});
|
|
@@ -19,7 +19,9 @@ const classNames = (...params) => {
|
|
|
19
19
|
return classes.join(" ");
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const useOutsideClose = (ref, onOutsideClose) => {
|
|
22
|
+
const useOutsideClose = (ref, onOutsideClose, settings) => {
|
|
23
|
+
var _a;
|
|
24
|
+
const isActive = (_a = settings === null || settings === void 0 ? void 0 : settings.isActive) !== null && _a !== void 0 ? _a : true;
|
|
23
25
|
useEffect(() => {
|
|
24
26
|
const handleClick = (e) => {
|
|
25
27
|
if (ref &&
|
|
@@ -33,20 +35,26 @@ const useOutsideClose = (ref, onOutsideClose) => {
|
|
|
33
35
|
onOutsideClose(e);
|
|
34
36
|
}
|
|
35
37
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
if (isActive) {
|
|
39
|
+
document.addEventListener("click", handleClick);
|
|
40
|
+
document.addEventListener("keydown", handleKey);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
document.removeEventListener("click", handleClick);
|
|
44
|
+
document.removeEventListener("keydown", handleKey);
|
|
45
|
+
}
|
|
38
46
|
return () => {
|
|
39
47
|
document.removeEventListener("click", handleClick);
|
|
40
48
|
document.removeEventListener("keydown", handleKey);
|
|
41
49
|
};
|
|
42
|
-
}, [onOutsideClose, ref]);
|
|
50
|
+
}, [onOutsideClose, ref, isActive]);
|
|
43
51
|
};
|
|
44
52
|
|
|
45
|
-
var styles = {"
|
|
53
|
+
var styles = {"zd__container":"ZDrop-module_zd__container__IrQTk","zd__label":"ZDrop-module_zd__label__keSwp","zd__input-field":"ZDrop-module_zd__input-field__Ne8t8","zd__input-field--multiple":"ZDrop-module_zd__input-field--multiple__kDSP5","zd__input-field--disabled":"ZDrop-module_zd__input-field--disabled__LOUpU","zd__input":"ZDrop-module_zd__input__r3qdf","zd__input-single":"ZDrop-module_zd__input-single__tM76E","zd__input-single-search":"ZDrop-module_zd__input-single-search__j4zof","zd__input-multiple":"ZDrop-module_zd__input-multiple__AzD1G","zd__input-multiple-value":"ZDrop-module_zd__input-multiple-value__4ZAHf","zd__input-multiple-value-remove-btn":"ZDrop-module_zd__input-multiple-value-remove-btn__gSzGH","zd__input-multiple-value-remove-btn-icon":"ZDrop-module_zd__input-multiple-value-remove-btn-icon__23GYv","zd__input-multiple-search-wrapper":"ZDrop-module_zd__input-multiple-search-wrapper__va0lS","zd__input-multiple-search":"ZDrop-module_zd__input-multiple-search__5K3Z9","zd__input-multiple-placeholder":"ZDrop-module_zd__input-multiple-placeholder__tx34F","zd__input-clear-btn-wrapper":"ZDrop-module_zd__input-clear-btn-wrapper__drnqP","zd__input-clear-btn":"ZDrop-module_zd__input-clear-btn__wqpAG","zd__input-clear-btn-icon":"ZDrop-module_zd__input-clear-btn-icon__4wsoa","zd__expand-toggle":"ZDrop-module_zd__expand-toggle__5-2LH","zd__expand-toggle-icon":"ZDrop-module_zd__expand-toggle-icon__Vznjq","zd__expand-toggle-icon--active":"ZDrop-module_zd__expand-toggle-icon--active__I4ZEa","zd__list":"ZDrop-module_zd__list__q8lwW","zd__list-wrapper":"ZDrop-module_zd__list-wrapper__dWpmK","zd__list-auto-height-wrapper":"ZDrop-module_zd__list-auto-height-wrapper__UxW3X","zd__list--auto-height-enabled":"ZDrop-module_zd__list--auto-height-enabled__qwsev","zd__list--reference-wrapper-enabled":"ZDrop-module_zd__list--reference-wrapper-enabled__Ufhb0","zd__option":"ZDrop-module_zd__option__Zf2Fo","zd__no-data":"ZDrop-module_zd__no-data__7cCZK","zd__option--active":"ZDrop-module_zd__option--active__u-S9s","zd__error-message":"ZDrop-module_zd__error-message__XL-DS"};
|
|
46
54
|
|
|
47
55
|
const ZDropLabel = (props) => {
|
|
48
56
|
const { name, label, className } = props;
|
|
49
|
-
const labelClasses = classNames(styles
|
|
57
|
+
const labelClasses = classNames(styles["zd__label"], className);
|
|
50
58
|
if (typeof label === "string") {
|
|
51
59
|
return (jsx("label", { htmlFor: name, className: labelClasses, children: label }));
|
|
52
60
|
}
|
|
@@ -66,7 +74,7 @@ const ZDropListItem = (props) => {
|
|
|
66
74
|
|
|
67
75
|
const ZDropListNoData = (props) => {
|
|
68
76
|
const { noDataContent, className } = props;
|
|
69
|
-
const noDataClasses = classNames(styles
|
|
77
|
+
const noDataClasses = classNames(styles["zd__no-data"], className);
|
|
70
78
|
return jsx("div", { className: noDataClasses, children: noDataContent });
|
|
71
79
|
};
|
|
72
80
|
|
|
@@ -91,43 +99,49 @@ const checkIsValueEqualToOption = (selectedValue, option, valueKey) => {
|
|
|
91
99
|
return false;
|
|
92
100
|
};
|
|
93
101
|
|
|
94
|
-
const
|
|
102
|
+
const checkIsOptionSelected = (checkIsInputValueEqualToOptionValue, value, option, valueKey) => value.some((value) => checkIsInputValueEqualToOptionValue(value, option, valueKey));
|
|
103
|
+
|
|
95
104
|
const ZDropList = (props) => {
|
|
96
|
-
const { options = [], selectedValue, valueKey, labelKey, optionsRef, optionRenderer, onOptionClick, onOptionKeyDown, noDataContent, currentSearchedValue, listStyleClasses, isListWrapperEnabled, } = props;
|
|
97
|
-
const dropdownListClasses = classNames(
|
|
98
|
-
[styles["
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
const { options = [], selectedValue, valueKey, labelKey, optionsRef, optionRenderer, onOptionClick, onOptionKeyDown, noDataContent, currentSearchedValue, listStyleClasses, isListWrapperEnabled, isAutoHeightEnabled, } = props;
|
|
106
|
+
const dropdownListClasses = classNames({
|
|
107
|
+
[styles["zd__list"]]: !isAutoHeightEnabled,
|
|
108
|
+
[styles["zd__list--auto-height-enabled"]]: isAutoHeightEnabled,
|
|
109
|
+
[styles["zd__list--reference-wrapper-enabled"]]: isListWrapperEnabled,
|
|
110
|
+
}, listStyleClasses === null || listStyleClasses === void 0 ? void 0 : listStyleClasses.list);
|
|
111
|
+
console.log("render list", dropdownListClasses, isAutoHeightEnabled);
|
|
112
|
+
const getListItemClasses = (option, isOptionSelected) => {
|
|
101
113
|
if (Array.isArray(selectedValue)) {
|
|
102
|
-
return classNames(styles
|
|
103
|
-
[styles["
|
|
104
|
-
});
|
|
114
|
+
return classNames(styles["zd__option"], {
|
|
115
|
+
[styles["zd__option--active"]]: isOptionSelected,
|
|
116
|
+
}, listStyleClasses === null || listStyleClasses === void 0 ? void 0 : listStyleClasses.listItem);
|
|
105
117
|
}
|
|
106
|
-
return classNames(styles
|
|
107
|
-
[styles["
|
|
108
|
-
});
|
|
118
|
+
return classNames(styles["zd__option"], {
|
|
119
|
+
[styles["zd__option--active"]]: isOptionSelected,
|
|
120
|
+
}, listStyleClasses === null || listStyleClasses === void 0 ? void 0 : listStyleClasses.listItem);
|
|
109
121
|
};
|
|
110
122
|
if (options.length === 0) {
|
|
111
123
|
return (jsx(ZDropListNoData, { noDataContent: noDataContent, className: listStyleClasses === null || listStyleClasses === void 0 ? void 0 : listStyleClasses.noData }));
|
|
112
124
|
}
|
|
113
|
-
return (jsx("ul", { className: dropdownListClasses, children: options.map((option, index) =>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
return (jsx("ul", { className: dropdownListClasses, children: options.map((option, index) => {
|
|
126
|
+
const isOptionSelected = Array.isArray(selectedValue)
|
|
127
|
+
? checkIsOptionSelected(checkIsValueEqualToOption, selectedValue, option, valueKey)
|
|
128
|
+
: checkIsValueEqualToOption(selectedValue, option, valueKey);
|
|
129
|
+
return (jsx(ZDropListItem, { innerRef: (el) => {
|
|
130
|
+
optionsRef.current[index] = el;
|
|
131
|
+
}, option: option, index: index, labelKey: labelKey, onOptionClick: onOptionClick, onOptionKeyDown: onOptionKeyDown, className: getListItemClasses(option, isOptionSelected), children: optionRenderer === null || optionRenderer === void 0 ? void 0 : optionRenderer(option, isOptionSelected, currentSearchedValue) }, (option === null || option === void 0 ? void 0 : option[valueKey]) || index));
|
|
132
|
+
}) }));
|
|
118
133
|
};
|
|
119
134
|
|
|
120
135
|
const ZDropListVisibilityToggle = (props) => {
|
|
121
136
|
const { expandToggleRenderer, onClick, isListVisible, toggleStyleClasses } = props;
|
|
122
|
-
const toggleClasses = classNames(styles
|
|
123
|
-
const iconClasses = classNames(styles
|
|
124
|
-
[styles["
|
|
125
|
-
});
|
|
126
|
-
console.log(iconClasses);
|
|
137
|
+
const toggleClasses = classNames(styles["zd__expand-toggle"], toggleStyleClasses === null || toggleStyleClasses === void 0 ? void 0 : toggleStyleClasses.expandToggle);
|
|
138
|
+
const iconClasses = classNames(styles["zd__expand-toggle-icon"], {
|
|
139
|
+
[styles["zd__expand-toggle-icon--active"]]: isListVisible,
|
|
140
|
+
}, toggleStyleClasses === null || toggleStyleClasses === void 0 ? void 0 : toggleStyleClasses.expandToggleIcon);
|
|
127
141
|
return (jsx("div", { className: toggleClasses, onClick: onClick, children: expandToggleRenderer ? (jsx("span", { children: expandToggleRenderer(isListVisible) })) : (jsx("span", { className: iconClasses })) }));
|
|
128
142
|
};
|
|
129
143
|
|
|
130
|
-
const
|
|
144
|
+
const checkIsClearButtonHidden = (hasValueChanged, currentSearchedValue, isListVisible, isClearableOnlyWhenChange, isClearableOnlyWhenSearch) => {
|
|
131
145
|
if (isClearableOnlyWhenChange && !isListVisible && hasValueChanged) {
|
|
132
146
|
return false;
|
|
133
147
|
}
|
|
@@ -144,22 +158,22 @@ const checkIsClearHidden = (hasValueChanged, currentSearchedValue, isListVisible
|
|
|
144
158
|
|
|
145
159
|
const ZDropClearButton = (props) => {
|
|
146
160
|
const { hasValueChanged, currentSearchedValue, onInputClear, isListVisible, isClearableOnlyWhenChange, isClearableOnlyWhenSearch, className, clearIcon, } = props;
|
|
147
|
-
const clearButtonClasses = classNames(styles
|
|
161
|
+
const clearButtonClasses = classNames(styles["zd__input-clear-btn"], className);
|
|
148
162
|
const onClear = (e) => {
|
|
149
163
|
e.preventDefault();
|
|
150
164
|
e.stopPropagation();
|
|
151
165
|
e.nativeEvent.stopImmediatePropagation();
|
|
152
166
|
onInputClear();
|
|
153
167
|
};
|
|
154
|
-
if (
|
|
168
|
+
if (checkIsClearButtonHidden(hasValueChanged, currentSearchedValue, isListVisible, isClearableOnlyWhenChange, isClearableOnlyWhenSearch)) {
|
|
155
169
|
return null;
|
|
156
170
|
}
|
|
157
|
-
return (jsx("div", { className: styles
|
|
171
|
+
return (jsx("div", { className: styles["zd__input-clear-btn-wrapper"], children: jsx("button", { tabIndex: -1, className: clearButtonClasses, onClick: onClear, children: clearIcon || jsx("span", { className: styles["zd__input-clear-btn-icon"] }) }) }));
|
|
158
172
|
};
|
|
159
173
|
|
|
160
174
|
const ZDropMultipleInputValue = (props) => {
|
|
161
175
|
const { option, labelType, onInputOptionRemove, valueRenderer, inputMultipleValueClassName, isDisabled, } = props;
|
|
162
|
-
const inputItemClasses = classNames(styles
|
|
176
|
+
const inputItemClasses = classNames(styles["zd__input-multiple-value"], inputMultipleValueClassName);
|
|
163
177
|
if (option === null || option === undefined) {
|
|
164
178
|
return null;
|
|
165
179
|
}
|
|
@@ -175,14 +189,14 @@ const ZDropMultipleInputValue = (props) => {
|
|
|
175
189
|
}
|
|
176
190
|
return (jsxs("li", { tabIndex: -1, className: inputItemClasses, children: [jsx("span", { children: typeof option === "object" && option !== null
|
|
177
191
|
? option[labelType] || option
|
|
178
|
-
: option }), onInputOptionRemove && !isDisabled && (jsx("button", { tabIndex: 0, className: styles
|
|
192
|
+
: option }), onInputOptionRemove && !isDisabled && (jsx("button", { tabIndex: 0, className: styles["zd__input-multiple-value-remove-btn"], onClick: (e) => onInputOptionRemove(e, option), children: jsx("span", { className: styles["zd__input-multiple-value-remove-btn-icon"] }) }))] }));
|
|
179
193
|
};
|
|
180
194
|
|
|
181
195
|
const ZDropMultipleInput = (props) => {
|
|
182
196
|
const { isListVisible, setIsListVisible, name, selectedValue, valueKey, labelKey, placeholder, isDisabled, isSearchable, currentSearchedValue, valueRenderer, inputRefMultipleValueRenderer, onInputClick, onInputKeyDown, onInputChange, onInputOptionRemove, inputClassName, inputMultipleValueClassName, inputMultipleSearchClassName, } = props;
|
|
183
|
-
const inputSelectClasses = classNames(styles
|
|
184
|
-
const inputMultipleSearchClasses = classNames(styles
|
|
185
|
-
const inputMultipleSearchWrapperClasses = classNames(styles
|
|
197
|
+
const inputSelectClasses = classNames(styles["zd__input"], styles["zd__input-multiple"], inputClassName);
|
|
198
|
+
const inputMultipleSearchClasses = classNames(styles["zd__input-multiple-search"]);
|
|
199
|
+
const inputMultipleSearchWrapperClasses = classNames(styles["zd__input-multiple"], styles["zd__input-multiple-search-wrapper"], inputMultipleSearchClassName);
|
|
186
200
|
const onKeyDown = (e) => {
|
|
187
201
|
if (["Enter"].includes(e.key)) {
|
|
188
202
|
e.preventDefault();
|
|
@@ -196,12 +210,12 @@ const ZDropMultipleInput = (props) => {
|
|
|
196
210
|
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)
|
|
197
211
|
? option[valueKey]
|
|
198
212
|
: option))), ((!isListVisible && selectedValue.length === 0) ||
|
|
199
|
-
((selectedValue.length === 0 || !selectedValue) && !isSearchable)) && (jsx("span", { className: styles
|
|
213
|
+
((selectedValue.length === 0 || !selectedValue) && !isSearchable)) && (jsx("span", { className: styles["zd__input-multiple-placeholder"], 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 }) }))] }));
|
|
200
214
|
};
|
|
201
215
|
|
|
202
216
|
const ZDropSingleInputValueRenderer = (props) => {
|
|
203
217
|
const { name, isInputItemVisible, isSearchable, selectedValue, selectedOption, valueRenderer, inputValue, isListVisible, placeholder, inputRefSingleValueRenderer, onChange, onInputItemClick, onInputOptionRemove, inputValueClassName, } = props;
|
|
204
|
-
const inputValueClasses = classNames(styles
|
|
218
|
+
const inputValueClasses = classNames(styles["zd__input-single-search"], inputValueClassName);
|
|
205
219
|
return (jsxs(Fragment, { children: [isInputItemVisible && selectedOption !== undefined && (jsx("div", { onClick: onInputItemClick, children: valueRenderer({
|
|
206
220
|
option: selectedOption,
|
|
207
221
|
onRemove: (e) => onInputOptionRemove(e, selectedOption),
|
|
@@ -234,12 +248,13 @@ const getLabelFromOption = (options, selectedValue, valueKey, labelKey) => {
|
|
|
234
248
|
}
|
|
235
249
|
return "";
|
|
236
250
|
};
|
|
251
|
+
|
|
237
252
|
const ZDropSingleInput = (props) => {
|
|
238
253
|
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;
|
|
239
254
|
const [inputValue, setInputValue] = useState(getLabelFromOption(options, selectedValue, valueKey, valueKey));
|
|
240
|
-
const inputSelectClasses = classNames(styles
|
|
241
|
-
[styles
|
|
242
|
-
});
|
|
255
|
+
const inputSelectClasses = classNames(styles["zd__input"], {
|
|
256
|
+
[styles["zd__input-single"]]: !!valueRenderer,
|
|
257
|
+
}, inputClassName);
|
|
243
258
|
const selectedOption = options.find((option) => {
|
|
244
259
|
if (typeof option === "object" &&
|
|
245
260
|
option !== null &&
|
|
@@ -337,28 +352,15 @@ const getCurrentMultipleValue = (selected, selectedValue, options, valueKey) =>
|
|
|
337
352
|
return [...(isSelectedValueArray ? selectedValue : []), selected];
|
|
338
353
|
};
|
|
339
354
|
|
|
340
|
-
const getElementOffsetTop = (element) => {
|
|
341
|
-
var _a, _b, _c;
|
|
342
|
-
if (!element)
|
|
343
|
-
return 0;
|
|
344
|
-
const rect = element.getBoundingClientRect();
|
|
345
|
-
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;
|
|
346
|
-
return rect.top + scrollTop;
|
|
347
|
-
};
|
|
355
|
+
const getElementOffsetTop = (element) => { var _a; return element ? element.getBoundingClientRect().top + ((_a = window.scrollY) !== null && _a !== void 0 ? _a : 0) : 0; };
|
|
348
356
|
const getReferenceElementDimensions = (element, elementParentClass) => {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
return {
|
|
356
|
-
top,
|
|
357
|
-
bottom: top + height,
|
|
358
|
-
height,
|
|
359
|
-
};
|
|
357
|
+
for (let el = element === null || element === void 0 ? void 0 : element.parentElement; el; el = el.parentElement) {
|
|
358
|
+
if (el.classList.contains(elementParentClass)) {
|
|
359
|
+
const top = getElementOffsetTop(el);
|
|
360
|
+
const height = el.scrollHeight;
|
|
361
|
+
return { top, bottom: top + height, height };
|
|
362
|
+
}
|
|
360
363
|
}
|
|
361
|
-
return getReferenceElementDimensions(parent, elementParentClass);
|
|
362
364
|
};
|
|
363
365
|
|
|
364
366
|
const distanceGap = 0;
|
|
@@ -375,51 +377,29 @@ const ZDropListWrapper = (props) => {
|
|
|
375
377
|
const [maxSpaceAbove, setMaxSpaceAbove] = useState(0);
|
|
376
378
|
const [maxSpaceBelow, setMaxSpaceBelow] = useState(0);
|
|
377
379
|
const [scrollHeight, setScrollHeight] = useState(0);
|
|
380
|
+
const listWrapperRef = useRef(null);
|
|
378
381
|
const hasTopSpace = maxSpaceAbove > minUsableHeight;
|
|
379
382
|
const hasBottomSpace = maxSpaceBelow > minUsableHeight;
|
|
380
383
|
let finalPosition;
|
|
381
384
|
if (positionToReferenceElement === "top") {
|
|
382
|
-
if (hasTopSpace)
|
|
385
|
+
if (hasTopSpace)
|
|
383
386
|
finalPosition = "top";
|
|
384
|
-
|
|
385
|
-
else if (hasBottomSpace) {
|
|
387
|
+
else if (hasBottomSpace)
|
|
386
388
|
finalPosition = "bottom";
|
|
387
|
-
|
|
388
|
-
else {
|
|
389
|
+
else
|
|
389
390
|
finalPosition = maxSpaceAbove >= maxSpaceBelow ? "top" : "bottom";
|
|
390
|
-
}
|
|
391
391
|
}
|
|
392
392
|
else {
|
|
393
|
-
if (hasBottomSpace)
|
|
393
|
+
if (hasBottomSpace)
|
|
394
394
|
finalPosition = "bottom";
|
|
395
|
-
|
|
396
|
-
else if (hasTopSpace) {
|
|
395
|
+
else if (hasTopSpace)
|
|
397
396
|
finalPosition = "top";
|
|
398
|
-
|
|
399
|
-
else {
|
|
397
|
+
else
|
|
400
398
|
finalPosition = maxSpaceBelow >= maxSpaceAbove ? "bottom" : "top";
|
|
401
|
-
}
|
|
402
399
|
}
|
|
403
400
|
const heightForBottom = Math.min(scrollHeight, maxSpaceBelow, listMaxHeightLimiter !== null && listMaxHeightLimiter !== void 0 ? listMaxHeightLimiter : maxSpaceBelow);
|
|
404
401
|
const heightForTop = calculateHeightForTop(scrollHeight, listMaxHeightLimiter !== null && listMaxHeightLimiter !== void 0 ? listMaxHeightLimiter : maxSpaceAbove, maxSpaceAbove);
|
|
405
402
|
const finalHeight = finalPosition === "top" ? heightForTop : heightForBottom;
|
|
406
|
-
const setWrapperMaxSpaces = (element, referenceElementClassName) => {
|
|
407
|
-
const wrapperListOffsetTop = getElementOffsetTop(element);
|
|
408
|
-
const referenceElement = getReferenceElementDimensions(element, referenceElementClassName);
|
|
409
|
-
if (referenceElement) {
|
|
410
|
-
const above = Math.max(wrapperListOffsetTop - referenceElement.top - distanceGap, 0);
|
|
411
|
-
const below = Math.max(referenceElement.bottom - wrapperListOffsetTop - distanceGap, 0);
|
|
412
|
-
setMaxSpaceAbove(above);
|
|
413
|
-
setMaxSpaceBelow(below);
|
|
414
|
-
const content = element.children[0];
|
|
415
|
-
setScrollHeight(content ? content.scrollHeight : 0);
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
const listWrapperRef = useCallback((node) => {
|
|
419
|
-
if (node) {
|
|
420
|
-
setWrapperMaxSpaces(node, referenceElementClassName);
|
|
421
|
-
}
|
|
422
|
-
}, [referenceElementClassName]);
|
|
423
403
|
const wrapperStyle = {
|
|
424
404
|
position: "absolute",
|
|
425
405
|
height: `${finalHeight}px`,
|
|
@@ -428,30 +408,168 @@ const ZDropListWrapper = (props) => {
|
|
|
428
408
|
? { top: `-${finalHeight + marginTop}px` }
|
|
429
409
|
: { top: "100%" }),
|
|
430
410
|
};
|
|
431
|
-
|
|
411
|
+
const setWrapperMaxSpaces = (listWrapper, referenceClassName) => {
|
|
412
|
+
const anchor = listWrapper.parentElement;
|
|
413
|
+
if (!anchor) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const reference = getReferenceElementDimensions(anchor, referenceClassName);
|
|
417
|
+
if (!reference) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const anchorTop = getElementOffsetTop(anchor);
|
|
421
|
+
const anchorBottom = anchorTop + anchor.offsetHeight;
|
|
422
|
+
const above = Math.max(anchorTop - reference.top - distanceGap, 0);
|
|
423
|
+
const below = Math.max(reference.bottom - anchorBottom - distanceGap, 0);
|
|
424
|
+
setMaxSpaceAbove(above);
|
|
425
|
+
setMaxSpaceBelow(below);
|
|
426
|
+
const content = listWrapper.children[0];
|
|
427
|
+
setScrollHeight(content ? content.scrollHeight : 0);
|
|
428
|
+
};
|
|
429
|
+
useLayoutEffect(() => {
|
|
430
|
+
if (!(listWrapperRef === null || listWrapperRef === void 0 ? void 0 : listWrapperRef.current)) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
setWrapperMaxSpaces(listWrapperRef.current, referenceElementClassName);
|
|
434
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
435
|
+
}, [
|
|
436
|
+
referenceElementClassName,
|
|
437
|
+
positionToReferenceElement,
|
|
438
|
+
listMaxHeightLimiter,
|
|
439
|
+
children,
|
|
440
|
+
]);
|
|
441
|
+
return (jsx("div", { className: styles["zd__list-wrapper"], ref: listWrapperRef, style: wrapperStyle, children: children }));
|
|
432
442
|
};
|
|
433
443
|
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
444
|
+
const checkIsValueEqualToSelectedValue = (value, selectedValue) => {
|
|
445
|
+
if (value === selectedValue)
|
|
436
446
|
return true;
|
|
437
|
-
if (
|
|
447
|
+
if (value == null || selectedValue == null)
|
|
438
448
|
return false;
|
|
439
|
-
if (typeof
|
|
449
|
+
if (typeof value !== "object" || typeof selectedValue !== "object")
|
|
440
450
|
return false;
|
|
441
|
-
if (Array.isArray(
|
|
442
|
-
if (
|
|
451
|
+
if (Array.isArray(value) && Array.isArray(selectedValue)) {
|
|
452
|
+
if (value.length !== selectedValue.length)
|
|
443
453
|
return false;
|
|
444
|
-
return
|
|
454
|
+
return value.every((valueItem, i) => checkIsValueEqualToSelectedValue(valueItem, selectedValue[i]));
|
|
445
455
|
}
|
|
446
|
-
const keysA = Object.keys(
|
|
447
|
-
const keysB = Object.keys(
|
|
456
|
+
const keysA = Object.keys(value);
|
|
457
|
+
const keysB = Object.keys(selectedValue);
|
|
448
458
|
if (keysA.length !== keysB.length)
|
|
449
459
|
return false;
|
|
450
|
-
return keysA.every((key) =>
|
|
460
|
+
return keysA.every((key) => checkIsValueEqualToSelectedValue(value[key], selectedValue[key]));
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
const getAvailableSpace = (element) => {
|
|
464
|
+
if (!element)
|
|
465
|
+
return { top: 0, bottom: 0 };
|
|
466
|
+
const rect = element.getBoundingClientRect();
|
|
467
|
+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
468
|
+
const spaceTop = Math.max(0, rect.top);
|
|
469
|
+
const spaceBottom = Math.max(0, viewportHeight - rect.bottom);
|
|
470
|
+
return {
|
|
471
|
+
top: spaceTop,
|
|
472
|
+
bottom: spaceBottom,
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
const ZDropListAutoHeightWrapper = (props) => {
|
|
477
|
+
const { containerRef, position = "bottom", children } = props;
|
|
478
|
+
const contentRef = useRef(null);
|
|
479
|
+
const [forcedPositionY, setForcedPositionY] = useState();
|
|
480
|
+
const [contentHeightValue, setContentHeightValue] = useState();
|
|
481
|
+
console.log(contentHeightValue);
|
|
482
|
+
const positionStyles = {
|
|
483
|
+
position: "absolute",
|
|
484
|
+
...(position.includes("top") ? { bottom: "100%" } : { top: "100%" }),
|
|
485
|
+
...(forcedPositionY && { ...forcedPositionY }),
|
|
486
|
+
...(contentHeightValue && { maxHeight: contentHeightValue + "px" }),
|
|
487
|
+
};
|
|
488
|
+
const calculateContentHeight = useCallback(() => {
|
|
489
|
+
var _a, _b;
|
|
490
|
+
if ((contentRef === null || contentRef === void 0 ? void 0 : contentRef.current) && (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current)) {
|
|
491
|
+
const { top, bottom } = getAvailableSpace(containerRef.current);
|
|
492
|
+
console.log({ position, top, bottom });
|
|
493
|
+
const availableTop = Math.max(0, top);
|
|
494
|
+
const availableBottom = Math.max(0, bottom);
|
|
495
|
+
const liElementHeight = (_b = (_a = contentRef === null || contentRef === void 0 ? void 0 : contentRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("li")) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().height;
|
|
496
|
+
if (!liElementHeight) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const approvedHeight = liElementHeight * 2;
|
|
500
|
+
if (position.includes("top") && availableTop > approvedHeight) {
|
|
501
|
+
setContentHeightValue(availableTop);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (position.includes("top") && availableTop <= approvedHeight) {
|
|
505
|
+
setContentHeightValue(availableBottom);
|
|
506
|
+
setForcedPositionY({ top: "100%", bottom: "auto" });
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (position.includes("bottom") && availableBottom > approvedHeight) {
|
|
510
|
+
setContentHeightValue(availableBottom);
|
|
511
|
+
console.log("bottom available");
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
if (position.includes("bottom") && availableBottom <= approvedHeight) {
|
|
515
|
+
setContentHeightValue(availableTop);
|
|
516
|
+
setForcedPositionY({ top: "auto", bottom: "100%" });
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}, [containerRef, position]);
|
|
520
|
+
const preventFromOverflowY = useCallback(() => {
|
|
521
|
+
if (!(containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) || !contentRef.current) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const dropdownHeight = containerRef.current.scrollHeight;
|
|
525
|
+
const dropdownPositionY = containerRef.current.getBoundingClientRect().y;
|
|
526
|
+
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
527
|
+
const isOverFlowTop = dropdownPositionY < contentRef.current.scrollHeight;
|
|
528
|
+
console.log({ dropdownPositionY, dropdownHeight, viewportHeight });
|
|
529
|
+
const isOverFlowBottom = dropdownPositionY + dropdownHeight + contentRef.current.clientHeight >
|
|
530
|
+
viewportHeight;
|
|
531
|
+
console.log({ isOverFlowTop, isOverFlowBottom });
|
|
532
|
+
if (!isOverFlowTop && !isOverFlowBottom) {
|
|
533
|
+
setForcedPositionY(undefined);
|
|
534
|
+
setContentHeightValue(undefined);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
if (!isOverFlowTop && isOverFlowBottom) {
|
|
538
|
+
setForcedPositionY({ top: "auto", bottom: "100%" });
|
|
539
|
+
setContentHeightValue(undefined);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
if (isOverFlowTop && !isOverFlowBottom) {
|
|
543
|
+
setForcedPositionY({ top: "100%", bottom: "auto" });
|
|
544
|
+
setContentHeightValue(undefined);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (isOverFlowTop && isOverFlowBottom) {
|
|
548
|
+
calculateContentHeight();
|
|
549
|
+
}
|
|
550
|
+
}, [containerRef, calculateContentHeight]);
|
|
551
|
+
useLayoutEffect(() => {
|
|
552
|
+
preventFromOverflowY();
|
|
553
|
+
}, [containerRef]);
|
|
554
|
+
useLayoutEffect(() => {
|
|
555
|
+
let timeId;
|
|
556
|
+
const onResize = () => {
|
|
557
|
+
clearTimeout(timeId);
|
|
558
|
+
timeId = setTimeout(() => {
|
|
559
|
+
preventFromOverflowY();
|
|
560
|
+
}, 50);
|
|
561
|
+
};
|
|
562
|
+
window.addEventListener("resize", onResize);
|
|
563
|
+
return () => {
|
|
564
|
+
clearTimeout(timeId);
|
|
565
|
+
window.removeEventListener("resize", onResize);
|
|
566
|
+
};
|
|
567
|
+
}, [preventFromOverflowY]);
|
|
568
|
+
return (jsx("div", { className: styles["zd__list-auto-height-wrapper"], style: positionStyles, ref: contentRef, children: children }));
|
|
451
569
|
};
|
|
452
570
|
|
|
453
571
|
const ZDrop = (props) => {
|
|
454
|
-
const { name, options, value, valueKey = "value", label, labelKey = "label", placeholder, isMultiple = false, isDisabled = false, isSearchable = false, clear = "none", searchFilterDelay, searchFilter = defaultSearchFilter, shouldReturnObjectOnChange = false, onChange, onBlur, onClear, valueRenderer, optionRenderer, expandToggleRenderer, clearIcon, noDataContent, referenceElementClassName, positionToReferenceElement, listMaxHeightLimiter, styleClasses, } = props;
|
|
572
|
+
const { name, options, value, valueKey = "value", label, labelKey = "label", placeholder, isMultiple = false, isDisabled = false, isSearchable = false, clear = "none", searchFilterDelay, searchFilter = defaultSearchFilter, shouldReturnObjectOnChange = false, onChange, onBlur, onClear, valueRenderer, optionRenderer, expandToggleRenderer, clearIcon, noDataContent, referenceElementClassName, positionToReferenceElement, autoHeightPosition, isAutoHeightEnabled, listMaxHeightLimiter, styleClasses, } = props;
|
|
455
573
|
const containerRef = useRef(null);
|
|
456
574
|
const inputRef = useRef(null);
|
|
457
575
|
const inputRefSingleValueRenderer = useRef(null);
|
|
@@ -471,11 +589,11 @@ const ZDrop = (props) => {
|
|
|
471
589
|
const isSelectedValueCorrect = selectedValue !== undefined &&
|
|
472
590
|
selectedValue !== null &&
|
|
473
591
|
selectedValue !== "";
|
|
474
|
-
const containerClasses = classNames(styles
|
|
475
|
-
const inputFieldClasses = classNames(styles
|
|
476
|
-
[styles["
|
|
477
|
-
[styles["
|
|
478
|
-
});
|
|
592
|
+
const containerClasses = classNames(styles["zd__container"], styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.container);
|
|
593
|
+
const inputFieldClasses = classNames(styles["zd__input-field"], {
|
|
594
|
+
[styles["zd__input-field--multiple"]]: isMultiple,
|
|
595
|
+
[styles["zd__input-field--disabled"]]: isDisabled,
|
|
596
|
+
}, styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.inputField);
|
|
479
597
|
const updateOptionsDataBySearch = (options, currentValue, labelKey) => {
|
|
480
598
|
const searchResult = searchFilter({
|
|
481
599
|
options,
|
|
@@ -584,7 +702,7 @@ const ZDrop = (props) => {
|
|
|
584
702
|
searchFilterDelay,
|
|
585
703
|
]);
|
|
586
704
|
const onInputKeyDown = (e) => {
|
|
587
|
-
var _a;
|
|
705
|
+
var _a, _b;
|
|
588
706
|
if (!isListVisible && ["Enter", " "].includes(e.key)) {
|
|
589
707
|
if (e.currentTarget !== e.target) {
|
|
590
708
|
return;
|
|
@@ -596,6 +714,10 @@ const ZDrop = (props) => {
|
|
|
596
714
|
e.preventDefault();
|
|
597
715
|
(_a = optionsRef.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
598
716
|
}
|
|
717
|
+
if (e.key === "ArrowUp" && isListVisible) {
|
|
718
|
+
e.preventDefault();
|
|
719
|
+
(_b = optionsRef.current[optionsRef.current.length - 1]) === null || _b === void 0 ? void 0 : _b.focus();
|
|
720
|
+
}
|
|
599
721
|
if (!isListVisible && isSearchable && !isMultiple && valueRenderer) {
|
|
600
722
|
setIsInputItemVisible(false);
|
|
601
723
|
}
|
|
@@ -700,6 +822,10 @@ const ZDrop = (props) => {
|
|
|
700
822
|
e.preventDefault();
|
|
701
823
|
(_d = optionsRef.current[index + 1]) === null || _d === void 0 ? void 0 : _d.focus();
|
|
702
824
|
}
|
|
825
|
+
if (e.key === "ArrowDown" && index === optionsData.length - 1) {
|
|
826
|
+
e.preventDefault();
|
|
827
|
+
applyInputSelectFocus();
|
|
828
|
+
}
|
|
703
829
|
if (e.key === "ArrowUp" && index === 0) {
|
|
704
830
|
e.preventDefault();
|
|
705
831
|
applyInputSelectFocus();
|
|
@@ -709,9 +835,6 @@ const ZDrop = (props) => {
|
|
|
709
835
|
}
|
|
710
836
|
};
|
|
711
837
|
useOutsideClose(containerRef, () => {
|
|
712
|
-
if (!isListVisible) {
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
838
|
setIsListVisible(false);
|
|
716
839
|
if (isSearchable && !currentSearchedValue) {
|
|
717
840
|
setOptionsData(options || []);
|
|
@@ -719,6 +842,8 @@ const ZDrop = (props) => {
|
|
|
719
842
|
if (valueRenderer && isSelectedValueCorrect) {
|
|
720
843
|
setIsInputItemVisible(true);
|
|
721
844
|
}
|
|
845
|
+
}, {
|
|
846
|
+
isActive: isListVisible,
|
|
722
847
|
});
|
|
723
848
|
useEffect(() => {
|
|
724
849
|
if (options) {
|
|
@@ -731,7 +856,8 @@ const ZDrop = (props) => {
|
|
|
731
856
|
}
|
|
732
857
|
}, [optionsData]);
|
|
733
858
|
useEffect(() => {
|
|
734
|
-
if (isValueCorrect &&
|
|
859
|
+
if (isValueCorrect &&
|
|
860
|
+
!checkIsValueEqualToSelectedValue(value, selectedValue)) {
|
|
735
861
|
setCurrentValue(defaultInputValue(value));
|
|
736
862
|
valueRenderer && setIsInputItemVisible(true);
|
|
737
863
|
}
|
|
@@ -745,7 +871,7 @@ const ZDrop = (props) => {
|
|
|
745
871
|
list: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.list,
|
|
746
872
|
listItem: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.listItem,
|
|
747
873
|
noData: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.noData,
|
|
748
|
-
}, isListWrapperEnabled: !!referenceElementClassName }));
|
|
874
|
+
}, isListWrapperEnabled: !!referenceElementClassName, isAutoHeightEnabled: isAutoHeightEnabled }));
|
|
749
875
|
return (jsxs("div", { ref: containerRef, className: containerClasses, onBlur: onBlur, 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 && {
|
|
750
876
|
currentSearchedValue: currentSearchedValue,
|
|
751
877
|
setCurrentSearchedValue: setCurrentSearchedValue,
|
|
@@ -757,12 +883,15 @@ const ZDrop = (props) => {
|
|
|
757
883
|
} }), 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: {
|
|
758
884
|
expandToggle: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.expandToggle,
|
|
759
885
|
expandToggleIcon: styleClasses === null || styleClasses === void 0 ? void 0 : styleClasses.expandToggleIcon,
|
|
760
|
-
} })] }), isListVisible &&
|
|
886
|
+
} })] }), isListVisible &&
|
|
887
|
+
!referenceElementClassName &&
|
|
888
|
+
!isAutoHeightEnabled &&
|
|
889
|
+
zDropList, isListVisible && referenceElementClassName && (jsx(ZDropListWrapper, { referenceElementClassName: referenceElementClassName, positionToReferenceElement: positionToReferenceElement, listMaxHeightLimiter: listMaxHeightLimiter, children: zDropList })), isListVisible && isAutoHeightEnabled && !referenceElementClassName && (jsx(ZDropListAutoHeightWrapper, { containerRef: containerRef, position: autoHeightPosition, children: zDropList }))] }));
|
|
761
890
|
};
|
|
762
891
|
|
|
763
892
|
function ZDropField(props) {
|
|
764
893
|
const { control, name, rules, onChangeTransform, valueSelector, errorClassName, errorRenderer, ...zDropProps } = props;
|
|
765
|
-
const errorMessageClasses = classNames(styles
|
|
894
|
+
const errorMessageClasses = classNames(styles["zd__error-message"], errorClassName);
|
|
766
895
|
return (jsx(Controller, { control: control, name: name, rules: rules, render: ({ field, fieldState }) => {
|
|
767
896
|
var _a;
|
|
768
897
|
const { onChange, value, name: fieldName, onBlur } = field;
|
|
@@ -772,11 +901,14 @@ function ZDropField(props) {
|
|
|
772
901
|
? onChangeTransform(newValue)
|
|
773
902
|
: newValue);
|
|
774
903
|
};
|
|
775
|
-
|
|
904
|
+
const { isAutoHeightEnabled, autoHeightPosition, referenceElementClassName, positionToReferenceElement, ...rest } = zDropProps;
|
|
905
|
+
return (jsxs(Fragment, { children: [jsx(ZDrop, { name: fieldName, value: zDropValue, onChange: handleChange, onBlur: onBlur, ...(isAutoHeightEnabled
|
|
906
|
+
? { isAutoHeightEnabled, autoHeightPosition }
|
|
907
|
+
: { referenceElementClassName, positionToReferenceElement }), ...rest }), ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) && (jsx("div", { className: errorMessageClasses, children: errorRenderer
|
|
776
908
|
? errorRenderer(fieldState.error.message)
|
|
777
909
|
: fieldState.error.message }))] }));
|
|
778
910
|
} }));
|
|
779
911
|
}
|
|
780
912
|
|
|
781
|
-
export {
|
|
782
|
-
//# sourceMappingURL=index-
|
|
913
|
+
export { ZDropField as Z, ZDrop as a, classNames as c, getAvailableSpace as g, useOutsideClose as u };
|
|
914
|
+
//# sourceMappingURL=index-DC_KVC71.js.map
|