kui-complex 0.0.24 → 0.0.26

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.js CHANGED
@@ -168,7 +168,7 @@ var dropdownStyles = function (_a) {
168
168
  var isOpen = _a.isOpen;
169
169
  return react.css(templateObject_1$p || (templateObject_1$p = __makeTemplateObject(["\n width: 100%;\n max-height: 389px;\n display: ", ";\n position: absolute;\n background: ", ";\n z-index: 3;\n border: 1px solid ", ";\n top: 64px;\n box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.1);\n border-radius: 8px;\n overflow: auto;\n -ms-overflow-style: none;\n scrollbar-width: none;\n overflow-y: scroll;\n user-select: none;\n &::-webkit-scrollbar {\n width: 0px;\n },\n"], ["\n width: 100%;\n max-height: 389px;\n display: ", ";\n position: absolute;\n background: ", ";\n z-index: 3;\n border: 1px solid ", ";\n top: 64px;\n box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.1);\n border-radius: 8px;\n overflow: auto;\n -ms-overflow-style: none;\n scrollbar-width: none;\n overflow-y: scroll;\n user-select: none;\n &::-webkit-scrollbar {\n width: 0px;\n },\n"])), isOpen ? "flex" : "none", kuiBasic.theme.palette.grey.zero, kuiBasic.theme.palette.grey.fifteenB);
170
170
  };
171
- var InputDropdown = function (_a) {
171
+ var InputDropdown = React.forwardRef(function (_a, ref) {
172
172
  var isOpen = _a.isOpen, handleClose = _a.handleClose, buttonRef = _a.buttonRef, children = _a.children, otherProps = __rest(_a, ["isOpen", "handleClose", "buttonRef", "children"]);
173
173
  var dropdownRef = React.useRef(null);
174
174
  var closePopUp = function (e) {
@@ -188,20 +188,35 @@ var InputDropdown = function (_a) {
188
188
  if (!isOpen) {
189
189
  return null;
190
190
  }
191
- return (jsxRuntime$1.jsx(kuiBasic.Grid, __assign({ "data-testid": "input_dropdown", container: true, ref: dropdownRef, css: dropdownStyles({ isOpen: isOpen }) }, otherProps, { children: children })));
192
- };
191
+ var forwardedRef = function (elem) {
192
+ if (typeof ref === "function")
193
+ ref(elem);
194
+ else if (ref)
195
+ ref.current = elem;
196
+ dropdownRef.current = elem;
197
+ };
198
+ return (jsxRuntime$1.jsx(kuiBasic.Grid, __assign({ "data-testid": "input_dropdown", container: true, ref: forwardedRef, css: dropdownStyles({ isOpen: isOpen }) }, otherProps, { children: children })));
199
+ });
193
200
  var templateObject_1$p;
194
201
 
195
202
  var InputSelectDropdown = function (_a) {
196
203
  var options = _a.options, inputRef = _a.inputRef, isOpenDropdown = _a.isOpenDropdown, handleCloseDropdown = _a.handleCloseDropdown, handleSelect = _a.handleSelect, selectedValue = _a.selectedValue;
204
+ var dropdownRef = React.useRef(null);
197
205
  React.useEffect(function () {
198
206
  var _a;
199
207
  if (isOpenDropdown) {
200
- (_a = document
201
- .querySelector("[data-value=autocomplete_option_".concat(selectedValue, "]"))) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
208
+ var element = document.querySelector("[data-value=autocomplete_option_".concat(selectedValue, "]"));
209
+ var coordinates = element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
210
+ if (coordinates && inputRef.current && element) {
211
+ (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
212
+ top: coordinates.top -
213
+ inputRef.current.clientHeight -
214
+ element.clientHeight,
215
+ });
216
+ }
202
217
  }
203
218
  }, [isOpenDropdown]);
204
- return (jsxRuntime$1.jsx(InputDropdown, __assign({ buttonRef: inputRef, isOpen: isOpenDropdown, handleClose: handleCloseDropdown, css: {
219
+ return (jsxRuntime$1.jsx(InputDropdown, __assign({ ref: dropdownRef, buttonRef: inputRef, isOpen: isOpenDropdown, handleClose: handleCloseDropdown, css: {
205
220
  maxHeight: "142px",
206
221
  padding: "4px",
207
222
  } }, { children: options.map(function (option, key) { return (jsxRuntime$1.jsx(OptionWrapper, __assign({ onClick: function () { return handleSelect(option); }, "data-value": "autocomplete_option_".concat(option.value), "data-testid": "autocomplete_option_".concat(key) }, { children: jsxRuntime$1.jsx(StyledOption, __assign({ css: selectedValue === option.value && selectedStyles }, { children: jsxRuntime$1.jsx(kuiBasic.Caption, __assign({ size: "sm", weight: 500 }, { children: option.label })) })) }), option.label)); }) })));
@@ -242,7 +257,6 @@ var InputSelect = React.forwardRef(function (props, ref) {
242
257
  var inputRef = React.useRef(null);
243
258
  var selectedLabel = (_a = options === null || options === void 0 ? void 0 : options.find(function (option) { return String(option.value) === String(value); })) === null || _a === void 0 ? void 0 : _a.label;
244
259
  var register = form === null || form === void 0 ? void 0 : form.register(name);
245
- console.log(value, selectedLabel, register, other);
246
260
  var handleOpenDropdown = function () {
247
261
  var _a, _b, _c, _d;
248
262
  if ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement) {
@@ -958,10 +972,11 @@ var StyledWrapper = styled__default["default"].div(templateObject_1$1 || (templa
958
972
  var templateObject_1$1;
959
973
 
960
974
  var ButtonSelect = React.forwardRef(function (props, ref) {
975
+ var _a;
961
976
  var options = props.options, otherProps = __rest(props, ["options"]);
962
- return (jsxRuntime.jsx(StyledInputSelect, __assign({ value: options === null || options === void 0 ? void 0 : options[0].value, options: options, iconProps: { width: 9, height: 5 } }, otherProps, { ref: ref })));
977
+ return (jsxRuntime.jsx(StyledInputSelect, __assign({ value: (_a = options === null || options === void 0 ? void 0 : options[0]) === null || _a === void 0 ? void 0 : _a.value, options: options, iconProps: { width: 9, height: 5 } }, otherProps, { ref: ref })));
963
978
  });
964
- var StyledInputSelect = styled__default["default"](InputSelect)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n &.KUI-Input_container {\n height: 40px;\n width: fit-content;\n input {\n height: 40px;\n border-radius: 66px;\n padding: 0 12px;\n transform: none;\n font-size: 12px;\n line-height: 14px;\n margin: 0 !important;\n width: auto !important;\n }\n }\n & + div {\n top: 40px;\n }\n"], ["\n &.KUI-Input_container {\n height: 40px;\n width: fit-content;\n input {\n height: 40px;\n border-radius: 66px;\n padding: 0 12px;\n transform: none;\n font-size: 12px;\n line-height: 14px;\n margin: 0 !important;\n width: auto !important;\n }\n }\n & + div {\n top: 40px;\n }\n"])));
979
+ var StyledInputSelect = styled__default["default"](InputSelect)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n &.KUI-Input_container {\n height: 40px;\n width: fit-content;\n input {\n height: 40px;\n border-radius: 66px;\n padding: 0 12px;\n transform: none;\n font-size: 12px;\n line-height: 14px;\n margin: 0 !important;\n width: auto !important;\n }\n }\n & + div {\n top: 48px;\n }\n"], ["\n &.KUI-Input_container {\n height: 40px;\n width: fit-content;\n input {\n height: 40px;\n border-radius: 66px;\n padding: 0 12px;\n transform: none;\n font-size: 12px;\n line-height: 14px;\n margin: 0 !important;\n width: auto !important;\n }\n }\n & + div {\n top: 48px;\n }\n"])));
965
980
  var templateObject_1;
966
981
 
967
982
  exports.Avatar = Avatar;