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