kui-complex 0.0.54 → 0.0.55

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 (44) hide show
  1. package/ButtonSelect/cjs/index.js +44 -22
  2. package/ButtonSelect/cjs/index.js.map +1 -1
  3. package/ButtonSelect/index.js +45 -23
  4. package/ButtonSelect/index.js.map +1 -1
  5. package/CalendarHeaderWithSelect/cjs/index.js +46 -24
  6. package/CalendarHeaderWithSelect/cjs/index.js.map +1 -1
  7. package/CalendarHeaderWithSelect/index.js +47 -25
  8. package/CalendarHeaderWithSelect/index.js.map +1 -1
  9. package/InputDropdown/cjs/index.js +38 -10
  10. package/InputDropdown/cjs/index.js.map +1 -1
  11. package/InputDropdown/index.d.ts +1 -1
  12. package/InputDropdown/index.js +35 -11
  13. package/InputDropdown/index.js.map +1 -1
  14. package/InputSelect/cjs/index.js +43 -20
  15. package/InputSelect/cjs/index.js.map +1 -1
  16. package/InputSelect/index.js +44 -21
  17. package/InputSelect/index.js.map +1 -1
  18. package/InputSelectDropdown/cjs/index.js +37 -14
  19. package/InputSelectDropdown/cjs/index.js.map +1 -1
  20. package/InputSelectDropdown/index.d.ts +7 -7
  21. package/InputSelectDropdown/index.js +38 -15
  22. package/InputSelectDropdown/index.js.map +1 -1
  23. package/InputWithDatePicker/cjs/index.js +39 -17
  24. package/InputWithDatePicker/cjs/index.js.map +1 -1
  25. package/InputWithDatePicker/index.js +39 -17
  26. package/InputWithDatePicker/index.js.map +1 -1
  27. package/SelectMonth/cjs/index.js +44 -22
  28. package/SelectMonth/cjs/index.js.map +1 -1
  29. package/SelectMonth/index.js +45 -23
  30. package/SelectMonth/index.js.map +1 -1
  31. package/SelectYear/cjs/index.js +44 -22
  32. package/SelectYear/cjs/index.js.map +1 -1
  33. package/SelectYear/index.js +45 -23
  34. package/SelectYear/index.js.map +1 -1
  35. package/TestForm/cjs/index.js +39 -17
  36. package/TestForm/cjs/index.js.map +1 -1
  37. package/TestForm/index.js +40 -18
  38. package/TestForm/index.js.map +1 -1
  39. package/cjs/index.js +46 -24
  40. package/cjs/index.js.map +1 -1
  41. package/index.d.ts +7 -7
  42. package/index.js +47 -25
  43. package/index.js.map +1 -1
  44. package/package.json +1 -1
package/TestForm/index.js CHANGED
@@ -3,7 +3,7 @@ import { Controller, useController, useForm } from 'react-hook-form';
3
3
  import * as yup from 'yup';
4
4
  import { yupResolver } from '@hookform/resolvers/yup';
5
5
  import * as React from 'react';
6
- import { forwardRef, useRef, useEffect, useState } from 'react';
6
+ import { forwardRef, useState, useRef, useEffect } from 'react';
7
7
  import { InputWithAdornments, Grid, theme, Caption, InputWithMask as InputWithMask$1, Divider, Button, Modal, IconButton, InputWithCountryDropdown, Switch as Switch$1, LinearProgress } from 'kui-basic';
8
8
  import { jsx as jsx$1, jsxs, Fragment } from '@emotion/react/jsx-runtime';
9
9
  import styled from '@emotion/styled';
@@ -80,12 +80,9 @@ var InputWithController = forwardRef(function (_a, ref) {
80
80
  } }));
81
81
  });
82
82
 
83
- var dropdownStyles = function (_a) {
84
- var isOpen = _a.isOpen;
85
- return css(templateObject_1$d || (templateObject_1$d = __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", theme.palette.grey.zero, theme.palette.grey.fifteenB);
86
- };
87
- var InputDropdown = forwardRef(function (_a, ref) {
88
- var isOpen = _a.isOpen, handleClose = _a.handleClose, buttonRef = _a.buttonRef, children = _a.children, otherProps = __rest(_a, ["isOpen", "handleClose", "buttonRef", "children"]);
83
+ var InputDropdown = forwardRef(function (props, ref) {
84
+ var isOpen = props.isOpen, handleClose = props.handleClose, buttonRef = props.buttonRef, children = props.children, otherProps = __rest(props, ["isOpen", "handleClose", "buttonRef", "children"]);
85
+ var _a = useState(false), isScrollable = _a[0], setIsScrollable = _a[1];
89
86
  var dropdownRef = useRef(null);
90
87
  var closePopUp = function (e) {
91
88
  if (dropdownRef.current && buttonRef && buttonRef.current) {
@@ -101,6 +98,22 @@ var InputDropdown = forwardRef(function (_a, ref) {
101
98
  document.removeEventListener("click", closePopUp);
102
99
  };
103
100
  });
101
+ useEffect(function () {
102
+ var _a;
103
+ if (buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) {
104
+ if (isOpen) {
105
+ buttonRef.current.style.zIndex = "4";
106
+ var scrollContainer = (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.children[0];
107
+ if (scrollContainer) {
108
+ var hasScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;
109
+ setIsScrollable(hasScroll);
110
+ }
111
+ }
112
+ else {
113
+ buttonRef.current.style.zIndex = "1";
114
+ }
115
+ }
116
+ }, [isOpen]);
104
117
  if (!isOpen) {
105
118
  return null;
106
119
  }
@@ -111,9 +124,20 @@ var InputDropdown = forwardRef(function (_a, ref) {
111
124
  ref.current = elem;
112
125
  dropdownRef.current = elem;
113
126
  };
114
- return (jsx$1(Grid, __assign({ "data-testid": "input_dropdown", container: true, ref: forwardedRef, css: dropdownStyles({ isOpen: isOpen }) }, otherProps, { children: children })));
127
+ return (jsx(StyledDropdown$1, __assign({ "data-testid": "input_dropdown", container: true, ref: forwardedRef, isOpen: isOpen, isScrollable: isScrollable }, otherProps, { children: jsx(ScrollingContainer, __assign({ isScrollable: isScrollable, className: "KUI-InputDropdown_scroll" }, { children: children })) })));
128
+ });
129
+ var StyledDropdown$1 = styled(Grid)(templateObject_1$d || (templateObject_1$d = __makeTemplateObject(["\n width: 100%;\n display: ", ";\n position: absolute;\n background: ", ";\n z-index: 3;\n top: 50px;\n box-shadow: 0px 26px 34px 0px #0000001a;\n border-radius: 0 0 8px 8px;\n user-select: none;\n padding: ", ";\n"], ["\n width: 100%;\n display: ", ";\n position: absolute;\n background: ", ";\n z-index: 3;\n top: 50px;\n box-shadow: 0px 26px 34px 0px #0000001a;\n border-radius: 0 0 8px 8px;\n user-select: none;\n padding: ", ";\n"])), function (_a) {
130
+ var isOpen = _a.isOpen;
131
+ return (isOpen ? "flex" : "none");
132
+ }, theme.palette.grey.zero, function (_a) {
133
+ var isScrollable = _a.isScrollable;
134
+ return isScrollable ? "14px 8px 8px 0" : "14px 0px 8px 0";
115
135
  });
116
- var templateObject_1$d;
136
+ var ScrollingContainer = styled.div(templateObject_2$7 || (templateObject_2$7 = __makeTemplateObject(["\n width: 100%;\n max-height: 389px;\n z-index: 3;\n overflow: auto;\n -ms-overflow-style: none;\n overflow-y: scroll;\n user-select: none;\n ::-webkit-scrollbar {\n width: ", ";\n position: absolute;\n right: 8px;\n }\n ::-webkit-scrollbar-track,\n ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n transition: all ease-out 0.3s;\n }\n\n ::-webkit-resizer,\n ::-webkit-scrollbar-button,\n ::-webkit-scrollbar-corner {\n display: none;\n }\n ::-webkit-scrollbar-track {\n background: ", ";\n }\n\n ::-webkit-scrollbar-thumb {\n background: ", ";\n }\n"], ["\n width: 100%;\n max-height: 389px;\n z-index: 3;\n overflow: auto;\n -ms-overflow-style: none;\n overflow-y: scroll;\n user-select: none;\n ::-webkit-scrollbar {\n width: ", ";\n position: absolute;\n right: 8px;\n }\n ::-webkit-scrollbar-track,\n ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n transition: all ease-out 0.3s;\n }\n\n ::-webkit-resizer,\n ::-webkit-scrollbar-button,\n ::-webkit-scrollbar-corner {\n display: none;\n }\n ::-webkit-scrollbar-track {\n background: ", ";\n }\n\n ::-webkit-scrollbar-thumb {\n background: ", ";\n }\n"])), function (_a) {
137
+ var isScrollable = _a.isScrollable;
138
+ return (isScrollable ? "4px" : "0px");
139
+ }, theme.palette.grey.fifteenB, theme.palette.grey.thirty);
140
+ var templateObject_1$d, templateObject_2$7;
117
141
 
118
142
  var InputSelectDropdown = forwardRef(function (_a, ref) {
119
143
  var options = _a.options, inputRef = _a.inputRef, isOpenDropdown = _a.isOpenDropdown, handleCloseDropdown = _a.handleCloseDropdown, handleSelect = _a.handleSelect, selectedValue = _a.selectedValue;
@@ -141,15 +165,13 @@ var InputSelectDropdown = forwardRef(function (_a, ref) {
141
165
  }
142
166
  dropdownRef.current = elem;
143
167
  };
144
- return (jsx$1(InputDropdown, __assign({ ref: forwardedRef, buttonRef: inputRef, isOpen: isOpenDropdown, handleClose: handleCloseDropdown, css: {
145
- maxHeight: "142px",
146
- padding: "4px",
147
- } }, { children: options.map(function (option, key) { return (jsx$1(OptionWrapper, __assign({ onClick: function () { return handleSelect(option); }, "data-value": "autocomplete_option_".concat(option.value), "data-testid": "autocomplete_option_".concat(key) }, { children: jsx$1(StyledOption, __assign({ css: selectedValue === option.value && selectedStyles }, { children: jsx$1(Caption, __assign({ size: "sm", weight: 500 }, { children: option.label })) })) }), option.label)); }) })));
168
+ return (jsx$1(StyledDropdown, __assign({ ref: forwardedRef, buttonRef: inputRef, isOpen: isOpenDropdown, handleClose: handleCloseDropdown }, { children: options.map(function (option, key) { return (jsx$1(OptionWrapper, __assign({ onClick: function () { return handleSelect(option); }, "data-value": "autocomplete_option_".concat(option.value), "data-testid": "autocomplete_option_".concat(key) }, { children: jsx$1(StyledOption, __assign({ css: selectedValue === option.value && selectedStyles }, { children: jsx$1(Caption, __assign({ size: "sm", weight: 500 }, { children: option.label })) })) }), option.label)); }) })));
148
169
  });
149
170
  var OptionWrapper = styled.div(templateObject_1$c || (templateObject_1$c = __makeTemplateObject(["\n width: 100%;\n padding: 2px 0;\n cursor: pointer;\n"], ["\n width: 100%;\n padding: 2px 0;\n cursor: pointer;\n"])));
150
171
  var StyledOption = styled.div(templateObject_2$6 || (templateObject_2$6 = __makeTemplateObject(["\n padding: 8px;\n transition: all ease-out 0.3s;\n border-radius: 4px;\n &:hover {\n background-color: ", ";\n }\n"], ["\n padding: 8px;\n transition: all ease-out 0.3s;\n border-radius: 4px;\n &:hover {\n background-color: ", ";\n }\n"])), theme.palette.background.light1);
151
172
  var selectedStyles = css(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n background-color: ", ";\n"], ["\n background-color: ", ";\n"])), theme.palette.background.light1);
152
- var templateObject_1$c, templateObject_2$6, templateObject_3$3;
173
+ var StyledDropdown = styled(InputDropdown)(templateObject_4$2 || (templateObject_4$2 = __makeTemplateObject(["\n .KUI-InputDropdown_scroll {\n max-height: 142px;\n padding: 0 4px;\n }\n"], ["\n .KUI-InputDropdown_scroll {\n max-height: 142px;\n padding: 0 4px;\n }\n"])));
174
+ var templateObject_1$c, templateObject_2$6, templateObject_3$3, templateObject_4$2;
153
175
 
154
176
  var getFormValue = function (name, form) {
155
177
  var names = name === null || name === void 0 ? void 0 : name.split(".");
@@ -174,10 +196,10 @@ var getFormError = function (name, form) {
174
196
  };
175
197
 
176
198
  var InputSelect = forwardRef(function (props, ref) {
177
- var _a, _b, _c;
199
+ var _a, _b;
178
200
  var options = props.options, name = props.name, handleChange = props.handleChange, form = props.form, iconProps = props.iconProps, defaultValue = props.value, other = __rest(props, ["options", "name", "handleChange", "form", "iconProps", "value"]);
179
- var _d = useState(false), isOpenDropdown = _d[0], setIsOpenDropDown = _d[1];
180
- var _e = useState(defaultValue || getFormValue(name, form)), value = _e[0], setValue = _e[1];
201
+ var _c = useState(false), isOpenDropdown = _c[0], setIsOpenDropDown = _c[1];
202
+ var _d = useState(defaultValue || getFormValue(name, form)), value = _d[0], setValue = _d[1];
181
203
  var error = getFormError(name, form);
182
204
  var inputRef = useRef(null);
183
205
  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;
@@ -219,7 +241,7 @@ var InputSelect = forwardRef(function (props, ref) {
219
241
  { transition: "all linear .2s" },
220
242
  isOpenDropdown && { transform: "rotate(180deg)" },
221
243
  ] }, iconProps))) }, register, { ref: forwardedRef })), options && options.length > 0 && !props.disabled && (jsx$1(InputSelectDropdown, { options: options, inputRef: {
222
- current: (_c = (_b = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _b === void 0 ? void 0 : _b.parentElement) === null || _c === void 0 ? void 0 : _c.parentElement,
244
+ current: (_b = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _b === void 0 ? void 0 : _b.parentElement,
223
245
  }, isOpenDropdown: isOpenDropdown, handleCloseDropdown: handleCloseDropdown, handleSelect: handleSelect, selectedValue: value }))] }));
224
246
  });
225
247
  var Wrapper$4 = styled.div(templateObject_1$b || (templateObject_1$b = __makeTemplateObject(["\n position: relative;\n text-align: left;\n width: fit-content;\n"], ["\n position: relative;\n text-align: left;\n width: fit-content;\n"])));