@councilbox/councilbox-ui 1.0.1 → 2.0.1

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 (137) hide show
  1. package/dist/HOCs/useDynamicStyles.js +99 -0
  2. package/dist/HOCs/useRipple.js +91 -0
  3. package/dist/build-index.js +8 -0
  4. package/dist/components/1.Introduction.stories.mdx +2 -1
  5. package/dist/components/2.Changelog.stories.mdx +3 -0
  6. package/dist/components/3.Guide.stories.mdx +56 -0
  7. package/dist/components/Accordion/Accordion.css +39 -1
  8. package/dist/components/Accordion/Accordion.js +84 -45
  9. package/dist/components/Accordion/Accordion.stories.js +4 -2
  10. package/dist/components/Accordion/AccordionOld.css +16 -0
  11. package/dist/components/Accordion/AccordionOld.js +115 -0
  12. package/dist/components/Accordion/DesignAccordion.stories.js +38 -0
  13. package/dist/components/Alert/Alert.css +5 -0
  14. package/dist/components/Alert/Alert.js +17 -6
  15. package/dist/components/Avatar/Avatar.css +3 -3
  16. package/dist/components/Avatar/Avatar.js +36 -20
  17. package/dist/components/Avatar/AvatarOld.js +138 -0
  18. package/dist/components/Avatar/DesignAvatar.stories.js +1 -1
  19. package/dist/components/Block/Block.js +17 -2
  20. package/dist/components/ButtonBasic/ButtonBasic.css +264 -20
  21. package/dist/components/ButtonBasic/ButtonBasic.js +85 -110
  22. package/dist/components/ButtonBasic/ButtonBasicOld.css +41 -0
  23. package/dist/components/ButtonBasic/ButtonBasicOld.js +231 -0
  24. package/dist/components/Checkbox/Checkbox.css +101 -22
  25. package/dist/components/Checkbox/Checkbox.js +119 -63
  26. package/dist/components/Checkbox/CheckboxOld.css +31 -0
  27. package/dist/components/Checkbox/CheckboxOld.js +112 -0
  28. package/dist/components/DragDrop/DragDrop.js +24 -9
  29. package/dist/components/DrawerPanel/DesignDrawerPanel.js +4 -2
  30. package/dist/components/DrawerPanel/DrawerPanel.css +76 -36
  31. package/dist/components/DrawerPanel/DrawerPanel.js +137 -115
  32. package/dist/components/DrawerPanel/DrawerPanelOld.css +56 -0
  33. package/dist/components/DrawerPanel/DrawerPanelOld.js +233 -0
  34. package/dist/components/DropDown/DesignDropDown.stories.js +146 -17
  35. package/dist/components/DropDown/DropDown.css +96 -1
  36. package/dist/components/DropDown/DropDown.js +308 -82
  37. package/dist/components/DropDown/DropDown.stories.js +1 -0
  38. package/dist/components/DropDown/DropDownOld.css +3 -0
  39. package/dist/components/DropDown/DropDownOld.js +186 -0
  40. package/dist/components/DropDown/PopoverPlayground.css +22 -0
  41. package/dist/components/DropDown/PopoverPlayground.js +235 -0
  42. package/dist/components/EnhancedTable/EnhancedTable.js +5 -6
  43. package/dist/components/FabButton/DesignFabButton.stories.js +3 -1
  44. package/dist/components/FabButton/FabButton.js +25 -5
  45. package/dist/components/Grid/DesignGrid.stories.js +9 -3
  46. package/dist/components/Grid/Grid.css +325 -0
  47. package/dist/components/Grid/Grid.js +57 -16
  48. package/dist/components/Grid/GridItem.js +31 -13
  49. package/dist/components/Grid/GridItemOld.js +43 -0
  50. package/dist/components/Grid/GridOld.css +0 -0
  51. package/dist/components/Grid/GridOld.js +53 -0
  52. package/dist/components/Header/Header.js +95 -116
  53. package/dist/components/IconButton/DesignIconButton.stories.js +22 -2
  54. package/dist/components/IconButton/IconButton.css +121 -1
  55. package/dist/components/IconButton/IconButton.js +98 -53
  56. package/dist/components/IconButton/IconButtonOld.css +0 -0
  57. package/dist/components/IconButton/IconButtonOld.js +138 -0
  58. package/dist/components/IconButtonSquare/IconButtonSquare.js +20 -90
  59. package/dist/components/IconButtonSquare/IconButtonSquareOld.css +43 -0
  60. package/dist/components/IconButtonSquare/IconButtonSquareOld.js +133 -0
  61. package/dist/components/InputAutocomplete/InputAutocomplete.css +109 -0
  62. package/dist/components/InputAutocomplete/InputAutocomplete.js +382 -76
  63. package/dist/components/InputAutocomplete/InputAutocomplete.stories.js +118 -6
  64. package/dist/components/InputAutocomplete/InputAutocompleteOld.css +5 -0
  65. package/dist/components/InputAutocomplete/InputAutocompleteOld.js +178 -0
  66. package/dist/components/InputPassword/InputPassword.js +10 -20
  67. package/dist/components/InputText/InputText.css +442 -1
  68. package/dist/components/InputText/InputText.js +298 -239
  69. package/dist/components/InputText/InputText.stories.js +12 -3
  70. package/dist/components/InputText/InputTextOld.css +10 -0
  71. package/dist/components/InputText/InputTextOld.js +340 -0
  72. package/dist/components/InputTextArea/DesignInputTextArea.stories.js +30 -4
  73. package/dist/components/InputTextArea/InputTextArea.js +13 -6
  74. package/dist/components/LoadingSection/LoadingSection.css +44 -2
  75. package/dist/components/LoadingSection/LoadingSection.js +63 -9
  76. package/dist/components/MenuItem/DesignMenuItem.stories.js +1 -0
  77. package/dist/components/MenuItem/MenuItem.css +35 -6
  78. package/dist/components/MenuItem/MenuItem.js +99 -50
  79. package/dist/components/MenuItem/MenuItemOld.js +139 -0
  80. package/dist/components/MenuLateralLeft/MenuLateralLeft.js +60 -40
  81. package/dist/components/MenuLateralRight/MenuLateralRight.js +23 -8
  82. package/dist/components/Modal/DesignModal.stories.js +54 -0
  83. package/dist/components/Modal/Modal.css +81 -2
  84. package/dist/components/Modal/Modal.js +112 -80
  85. package/dist/components/Modal/Modal.stories.js +13 -2
  86. package/dist/components/Modal/ModalOld.css +3 -0
  87. package/dist/components/Modal/ModalOld.js +230 -0
  88. package/dist/components/PaginationFooter/DesignPaginationFooter.stories.js +9 -1
  89. package/dist/components/PaginationFooter/PaginationFooter.css +73 -0
  90. package/dist/components/PaginationFooter/PaginationFooter.js +45 -87
  91. package/dist/components/RadioButton/Radio.css +115 -16
  92. package/dist/components/RadioButton/Radio.js +70 -94
  93. package/dist/components/RadioButton/Radio.stories.js +42 -18
  94. package/dist/components/RadioButton/RadioOld.css +31 -0
  95. package/dist/components/RadioButton/RadioOld.js +142 -0
  96. package/dist/components/Ripple/DesignRipple.js +77 -0
  97. package/dist/components/Ripple/Ripple.stories.js +45 -0
  98. package/dist/components/Scrollbar/Scrollbar.js +21 -6
  99. package/dist/components/SelectInput/DesignSelectInput.js +62 -23
  100. package/dist/components/SelectInput/SelectInput.css +128 -10
  101. package/dist/components/SelectInput/SelectInput.js +265 -244
  102. package/dist/components/SelectInput/SelectInputOld.css +17 -0
  103. package/dist/components/SelectInput/SelectInputOld.js +325 -0
  104. package/dist/components/Stars/Stars.css +28 -28
  105. package/dist/components/Stars/Stars.js +22 -12
  106. package/dist/components/Stepper/Stepper.css +1 -0
  107. package/dist/components/Stepper/Stepper.js +81 -24
  108. package/dist/components/Table/DesignTable.stories.js +1 -0
  109. package/dist/components/Table/Table.css +56 -53
  110. package/dist/components/Table/Table.js +55 -75
  111. package/dist/components/Table/TableOld.css +79 -0
  112. package/dist/components/Table/TableOld.js +165 -0
  113. package/dist/components/Tabs/DesignTabs.js +37 -12
  114. package/dist/components/Tabs/Tabs.css +39 -4
  115. package/dist/components/Tabs/Tabs.js +194 -30
  116. package/dist/components/Tabs/Tabs.stories.js +8 -1
  117. package/dist/components/Tabs/TabsOld.js +92 -0
  118. package/dist/components/Tag/Tag.js +19 -9
  119. package/dist/components/Toggle/Toggle.css +122 -3
  120. package/dist/components/Toggle/Toggle.js +95 -68
  121. package/dist/components/Tooltip/DesignTooltip.stories.js +48 -0
  122. package/dist/components/Tooltip/Tooltip.css +75 -0
  123. package/dist/components/Tooltip/Tooltip.js +126 -0
  124. package/dist/components/Tooltip/Tooltip.stories.js +40 -0
  125. package/dist/components/Typography/Typography.css +9 -0
  126. package/dist/components/Typography/Typography.js +30 -21
  127. package/dist/components/Typography/TypographyOld.js +132 -0
  128. package/dist/styles/colorConsts.css +24 -0
  129. package/dist/styles/main.css +41 -49
  130. package/dist/styles/scpacingConsts.css +26 -0
  131. package/dist/styles/zIndexConsts.css +9 -0
  132. package/dist/testing/TestAutocomplete.js +369 -0
  133. package/dist/testing/TestComponents.js +3 -114
  134. package/dist/testing/TestDropdown.js +225 -0
  135. package/dist/utils/autoDetectScroll.js +127 -0
  136. package/dist/utils/index.js +141 -0
  137. package/package.json +2 -1
@@ -9,23 +9,19 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _Select = _interopRequireDefault(require("@mui/material/Select"));
13
-
14
- var _InputLabel = _interopRequireDefault(require("@mui/material/InputLabel"));
15
-
16
- var _FormControl = _interopRequireDefault(require("@mui/material/FormControl"));
17
-
18
- var _material = require("@mui/material");
12
+ var _reactDom = require("react-dom");
19
13
 
20
14
  require("../../styles/main.css");
21
15
 
22
16
  require("./SelectInput.css");
23
17
 
24
- var _styled = _interopRequireDefault(require("@mui/material/styles/styled"));
18
+ var _InputText = _interopRequireDefault(require("../InputText/InputText"));
19
+
20
+ var _useDynamicStyles2 = _interopRequireDefault(require("../../HOCs/useDynamicStyles"));
25
21
 
26
- var _Typography = _interopRequireDefault(require("../Typography/Typography"));
22
+ var _utils = require("../../utils");
27
23
 
28
- var _excluded = ["id", "className", "onChange", "label", "disabled", "width", "fullWidth", "children", "error", "helperText", "helper", "variant", "endAdornment", "success", "sx", "sxFormControl", "propsFormControl"];
24
+ var _excluded = ["children", "onChange", "label", "value", "style", "sx", "multiple", "renderValue", "prefixClass", "fullWidth", "width", "disabled"];
29
25
 
30
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
27
 
@@ -37,273 +33,296 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
37
33
 
38
34
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
39
35
 
36
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
37
+
38
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
39
+
40
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
41
+
42
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
43
+
44
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
45
+
46
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
47
+
48
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
49
+
50
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
51
+
52
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
53
+
54
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
55
+
40
56
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
41
57
 
42
58
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
43
59
 
44
- var CssSelect = (0, _styled.default)(_Select.default)(function () {
45
- return {
46
- '& .MuiInput-underline:after': {
47
- borderBottomColor: 'var(--gray5)',
48
- borderWidth: '2px'
49
- },
50
- '& .MuiSelect-nativeInput': {
51
- height: '3rem',
52
- lineHeight: 'var(--spacing12)',
53
- padding: 'var(--spacing12)',
54
- paddingRight: 'var(--spacing8)'
55
- },
56
- '&.MuiInputBase-root.Mui-error': {
57
- color: 'var(--error)'
58
- },
59
- '&.MuiInputBase-root.Mui-error input, &.MuiInputBase-root.Mui-error div, .MuiOutlinedInput-input.Mui-disabled': {
60
- color: 'var(--gray5)',
61
- WebkitTextFillColor: 'unset'
62
- },
63
- '&.Mui-disabled svg': {
64
- display: 'none'
65
- },
66
- '& .MuiOutlinedInput-notchedOutline': {
67
- color: 'var(--gray5)',
68
- paddingRight: 'var(--spacing8)',
69
- '& fieldset': {
70
- borderColor: 'var(--gray3)',
71
- borderWidth: '1px',
72
- '& legend': {
73
- '& span': {
74
- paddingLeft: 'var(--spacing4)',
75
- paddingRight: 'var(--spacing4)'
76
- }
77
- }
78
- },
79
- '&:hover fieldset': {
80
- borderColor: 'var(--gray3)',
81
- borderWidth: '2px'
82
- },
83
- '&:active fieldset': {
84
- borderColor: 'var(--gray3)',
85
- borderWidth: '2px'
86
- },
87
- '&.Mui-focused fieldset': {
88
- borderColor: 'var(--primary)',
89
- borderWidth: '2px'
90
- },
91
- '&:focus-visible': {
92
- outline: 'none',
93
- '& fieldset': {
94
- outline: 'none',
95
- boxShadow: '0 0 0 3px white, 0 0 7px 4px var(--primary)',
96
- border: '2px solid var(--gray4)'
97
- }
98
- }
99
- },
100
- '&.MuiOutlinedInput-root.Mui-disabled .MuiOutlinedInput-notchedOutline': {
101
- border: '1px dashed var(--gray2)'
102
- },
103
- '&.MuiInputLabel-root.Mui-disabled': {
104
- color: 'var(--gray3)'
105
- },
106
- '&.MuiFormHelperText-root.Mui-focused div h6': {
107
- color: 'var(--primary)'
108
- },
109
- '&.MuiInputBase-root.MuiOutlinedInput-root': {
110
- color: 'var(--gray5)'
111
- },
112
- '&.MuiFilledInput-root .MuiSelect-nativeInput': {
113
- height: '3rem',
114
- lineHeight: 'var(--spacing12)',
115
- padding: 'var(--spacing12)',
116
- paddingRight: 'var(--spacing8)'
117
- },
118
- '& .MuiSelect-filled.MuiFilledInput-input': {
119
- paddingTop: 'var(--spacing12)',
120
- padding: 'var(--spacing12) var(--spacing12) var(--spacing12) 0!important'
121
- },
122
- '& .MuiSelect-select.MuiSelect-standard': {
123
- paddingBottom: 'var(--spacing12)',
124
- padding: 'var(--spacing12) var(--spacing12) var(--spacing12) 0!important',
125
- paddingRight: 'var(--spacing8)!important'
126
- },
127
- '&.MuiInputBase-root': {
128
- marginTop: '0'
129
- },
130
- '&.Mui-focused .MuiOutlinedInput-notchedOutline': {
131
- borderColor: 'var(--primary)'
132
- }
133
- };
134
- });
135
-
136
60
  var SelectInput = function SelectInput(_ref) {
137
- var id = _ref.id,
138
- className = _ref.className,
61
+ var children = _ref.children,
139
62
  onChange = _ref.onChange,
140
63
  label = _ref.label,
141
- disabled = _ref.disabled,
142
- width = _ref.width,
143
- fullWidth = _ref.fullWidth,
144
- children = _ref.children,
145
- error = _ref.error,
146
- helperText = _ref.helperText,
147
- helper = _ref.helper,
148
- variant = _ref.variant,
149
- endAdornment = _ref.endAdornment,
150
- success = _ref.success,
64
+ value = _ref.value,
65
+ style = _ref.style,
151
66
  sx = _ref.sx,
152
- sxFormControl = _ref.sxFormControl,
153
- propsFormControl = _ref.propsFormControl,
67
+ _ref$multiple = _ref.multiple,
68
+ multiple = _ref$multiple === void 0 ? false : _ref$multiple,
69
+ _ref$renderValue = _ref.renderValue,
70
+ renderValue = _ref$renderValue === void 0 ? null : _ref$renderValue,
71
+ propPrefixClass = _ref.prefixClass,
72
+ fullWidth = _ref.fullWidth,
73
+ width = _ref.width,
74
+ disabled = _ref.disabled,
154
75
  props = _objectWithoutProperties(_ref, _excluded);
155
76
 
156
- var value = props.value;
77
+ var getDefaultValue = function getDefaultValue() {
78
+ if (value !== undefined) return value;
79
+ if (multiple) return [];
80
+ return '';
81
+ };
82
+
83
+ var _useDynamicStyles = (0, _useDynamicStyles2.default)(sx),
84
+ stylesInLine = _useDynamicStyles.stylesInLine,
85
+ dynamicPrefixClass = _useDynamicStyles.prefixClass;
157
86
 
158
- var getIcon = function getIcon() {
159
- var icon = /*#__PURE__*/_react.default.createElement("i", {
160
- className: "cbx-inputText-endAdornment ".concat(endAdornment)
161
- });
87
+ var prefixClass = propPrefixClass || dynamicPrefixClass;
162
88
 
163
- if (success) {
164
- icon = /*#__PURE__*/_react.default.createElement("i", {
165
- className: "cbx-inputText-endAdornment ri-check-line",
166
- style: {
167
- color: 'var(--success)'
168
- }
89
+ var _React$useState = _react.default.useState(false),
90
+ _React$useState2 = _slicedToArray(_React$useState, 2),
91
+ isOpen = _React$useState2[0],
92
+ setIsOpen = _React$useState2[1];
93
+
94
+ var _React$useState3 = _react.default.useState(false),
95
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
96
+ isClosing = _React$useState4[0],
97
+ setIsClosing = _React$useState4[1];
98
+
99
+ var _React$useState5 = _react.default.useState(getDefaultValue()),
100
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
101
+ internalValue = _React$useState6[0],
102
+ setInternalValue = _React$useState6[1];
103
+
104
+ var selectRef = _react.default.useRef(null);
105
+
106
+ var dropdownRef = _react.default.useRef(null);
107
+
108
+ var optionContainerRef = _react.default.useRef(null);
109
+
110
+ var _useKeyItemNavigation = (0, _utils.useKeyItemNavigation)({
111
+ containerRef: optionContainerRef,
112
+ canLoop: false
113
+ }),
114
+ handleKeyDown = _useKeyItemNavigation.handleKeyDown;
115
+
116
+ if (width === '100%') {
117
+ fullWidth = true;
118
+ }
119
+
120
+ var closeDropdown = function closeDropdown() {
121
+ setIsClosing(true);
122
+ setTimeout(function () {
123
+ setIsOpen(false);
124
+ setIsClosing(false);
125
+ }, 150);
126
+ };
127
+
128
+ var handleOptionClick = function handleOptionClick(option) {
129
+ var optionValue = option.props.value;
130
+ var optionText = option.props.children;
131
+
132
+ if (multiple) {
133
+ var newSelected;
134
+
135
+ if (internalValue.some(function (opt) {
136
+ return opt.value === optionValue;
137
+ })) {
138
+ newSelected = internalValue.filter(function (opt) {
139
+ return opt.value !== optionValue;
140
+ });
141
+ } else {
142
+ newSelected = [].concat(_toConsumableArray(internalValue), [{
143
+ value: optionValue,
144
+ text: optionText
145
+ }]);
146
+ }
147
+
148
+ setInternalValue(newSelected);
149
+
150
+ if (onChange) {
151
+ onChange({
152
+ target: {
153
+ value: newSelected.map(function (opt) {
154
+ return opt.value;
155
+ })
156
+ }
157
+ });
158
+ }
159
+ } else {
160
+ setInternalValue({
161
+ value: optionValue,
162
+ text: optionText
169
163
  });
164
+
165
+ if (onChange) {
166
+ onChange({
167
+ target: {
168
+ value: optionValue
169
+ }
170
+ });
171
+ }
172
+
173
+ closeDropdown();
170
174
  }
175
+ };
171
176
 
172
- if (error) {
173
- icon = /*#__PURE__*/_react.default.createElement("i", {
174
- className: 'cbx-inputText-endAdornment ri-information-line',
175
- style: {
176
- color: 'var(--error)'
177
- }
178
- });
177
+ var updateDropdownPosition = function updateDropdownPosition() {
178
+ if (selectRef.current && dropdownRef.current) {
179
+ var _selectRef$current$cl;
180
+
181
+ var inputText = selectRef.current;
182
+ var inputRect = inputText.getBoundingClientRect();
183
+ var dropdownHeight = dropdownRef.current.offsetHeight;
184
+ var isOverflowingBelow = inputRect.bottom + dropdownHeight > window.innerHeight;
185
+ var topPosition = isOverflowingBelow ? window.innerHeight - dropdownHeight : inputRect.bottom;
186
+ var containerRect = ((_selectRef$current$cl = selectRef.current.closest('.cbx-selectInput-options-container')) === null || _selectRef$current$cl === void 0 ? void 0 : _selectRef$current$cl.getBoundingClientRect()) || {
187
+ top: 0,
188
+ left: 0
189
+ };
190
+ dropdownRef.current.style.top = "".concat(topPosition - containerRect.top, "px");
191
+ dropdownRef.current.style.left = "".concat(inputRect.left - containerRect.left, "px");
192
+ dropdownRef.current.style.width = "".concat(inputRect.width, "px");
179
193
  }
194
+ };
180
195
 
181
- if (helper) {
182
- icon = /*#__PURE__*/_react.default.createElement("i", {
183
- className: 'cbx-inputText-endAdornment ri-information-line'
184
- });
196
+ _react.default.useEffect(function () {
197
+ updateDropdownPosition();
198
+ }, [isOpen]);
199
+
200
+ _react.default.useEffect(function () {
201
+ var handleResize = function handleResize() {
202
+ if (isOpen) {
203
+ updateDropdownPosition();
204
+ }
205
+ };
206
+
207
+ window.addEventListener('resize', handleResize);
208
+ return function () {
209
+ window.removeEventListener('resize', handleResize);
210
+ };
211
+ }, [isOpen]);
212
+
213
+ var checkSelectedOptions = function checkSelectedOptions(optionValue) {
214
+ if (multiple) {
215
+ return (value === null || value === void 0 ? void 0 : value.includes(optionValue)) || (internalValue === null || internalValue === void 0 ? void 0 : internalValue.includes(optionValue));
185
216
  }
186
217
 
187
- return icon;
218
+ return String(optionValue) === String(value !== undefined ? value : internalValue);
188
219
  };
189
220
 
190
- var getVariant = function getVariant() {
191
- var variantInput = 'outlined';
221
+ var enhancedChildren = _react.default.Children.map(children, function (child, index) {
222
+ if ( /*#__PURE__*/_react.default.isValidElement(child)) {
223
+ return /*#__PURE__*/_react.default.cloneElement(child, {
224
+ key: child.key || "".concat(child.props.value, "-").concat(index),
225
+ active: checkSelectedOptions(child.props.value),
226
+ selected: checkSelectedOptions(child.props.value),
227
+ onClick: function onClick() {
228
+ return handleOptionClick(child);
229
+ },
230
+ fullWidth: fullWidth
231
+ });
232
+ }
233
+
234
+ return child;
235
+ });
236
+
237
+ var getSelectedOptions = function getSelectedOptions() {
238
+ var _React$Children$toArr;
239
+
240
+ if (multiple) {
241
+ return _react.default.Children.toArray(children).reduce(function (acc, curr) {
242
+ if (checkSelectedOptions(curr.props.value)) {
243
+ acc.push(curr.props);
244
+ }
192
245
 
193
- if (variant === 'outlined') {
194
- variantInput = variant;
246
+ return acc;
247
+ }, []);
195
248
  }
196
249
 
197
- if (variant === 'filled') {
198
- variantInput = variant;
250
+ return ((_React$Children$toArr = _react.default.Children.toArray(children).find(function (child) {
251
+ return checkSelectedOptions(child.props.value);
252
+ })) === null || _React$Children$toArr === void 0 ? void 0 : _React$Children$toArr.props) || {};
253
+ };
254
+
255
+ var selectedOption = getSelectedOptions();
256
+
257
+ var getRenderValue = function getRenderValue() {
258
+ if (renderValue) {
259
+ return renderValue(value);
199
260
  }
200
261
 
201
- if (variant === 'standard') {
202
- variantInput = variant;
262
+ if (multiple && Array.isArray(selectedOption)) {
263
+ return value.join(', ');
203
264
  }
204
265
 
205
- return variantInput;
266
+ return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.children) || '';
206
267
  };
207
268
 
208
- if (Object.hasOwn(props, 'value') && props.value === undefined) {
209
- value = '';
210
- }
269
+ return /*#__PURE__*/_react.default.createElement("div", {
270
+ className: prefixClass("cbx-selectInput-container ".concat(isOpen ? 'cbx-selectInput-container-open' : '', " ").concat(fullWidth ? 'cbx-selectInput-container-fullWidth' : '', " ").concat(disabled ? 'cbx-selectInput-container-disabled' : '')),
271
+ onClick: function onClick(e) {
272
+ e.preventDefault();
273
+ e.stopPropagation();
274
+ setIsOpen(!disabled);
275
+ selectRef.current.focus();
276
+ },
277
+ style: _objectSpread(_objectSpread({
278
+ width: width !== '100%' && width
279
+ }, style), stylesInLine),
280
+ ref: selectRef
281
+ }, /*#__PURE__*/_react.default.createElement(_InputText.default, _extends({
282
+ label: label,
283
+ renderValue: getRenderValue(),
284
+ value: getRenderValue(),
285
+ shrink: !!selectedOption,
286
+ readOnly: true,
287
+ prefixClass: prefixClass,
288
+ fullWidth: fullWidth || width !== '100%',
289
+ disabled: disabled
290
+ }, props, {
291
+ onKeyDown: function onKeyDown(e) {
292
+ e.preventDefault();
293
+ e.stopPropagation();
211
294
 
212
- return /*#__PURE__*/_react.default.createElement(_FormControl.default, _extends({
213
- fullWidth: fullWidth,
214
- sx: _objectSpread(_objectSpread({
215
- minWidth: width || '15rem'
216
- }, width ? {
217
- width: width || ''
218
- } : {}), {}, {
219
- minHeight: '3rem'
220
- }, sxFormControl)
221
- }, propsFormControl), label && /*#__PURE__*/_react.default.createElement(_InputLabel.default, {
222
- variant: getVariant(),
223
- disabled: disabled,
224
- error: error,
225
- sx: {
226
- '&.MuiInputLabel-root': {
227
- color: 'var(--gray5)'
228
- },
229
- '&.MuiInputLabel-root.Mui-focused': {
230
- top: '0',
231
- color: 'var(--primary)'
232
- },
233
- '&.MuiInputLabel-root.Mui-error': {
234
- color: 'var(--error)'
235
- },
236
- '&.MuiInputLabel-root.Mui-disabled': {
237
- color: 'var(--gray3)'
238
- },
239
- '&.MuiInputLabel-filled.MuiInputLabel-shrink': {
240
- transform: 'translate(0 ,-0.625rem) scale(0.75)!important'
241
- },
242
- '&.MuiInputLabel-outlined.MuiFormLabel-root:not(.MuiInputLabel-shrink)': {
243
- transform: 'translate(0.875rem ,0.75rem) scale(1)!important'
244
- },
245
- '&.MuiInputLabel-outlined.MuiFormLabel-root.MuiInputLabel-shrink': {
246
- transform: 'translate(0.875rem ,-0.625rem) scale(0.75)!important'
247
- },
248
- '&.MuiFormLabel-root.MuiInputLabel-root.MuiInputLabel-formControl.MuiInputLabel-animated.MuiInputLabel-filled:not(.MuiInputLabel-shrink)': {
249
- transform: 'translate(0 ,0.75rem) scale(1)!important'
250
- },
251
- '&.MuiFormLabel-root.MuiInputLabel-root.MuiInputLabel-formControl.MuiInputLabel-animated.MuiInputLabel-standard:not(.MuiInputLabel-shrink)': {
252
- transform: 'translate(0 ,0.75rem) scale(1)!important'
253
- },
254
- '&.MuiInputLabel-shrink': {
255
- transform: 'translate(0 ,-0.625rem) scale(0.75)!important',
256
- zIndex: '1'
295
+ if (e.key === 'ArrowDown') {
296
+ setIsOpen(true);
257
297
  }
258
- }
259
- }, label), /*#__PURE__*/_react.default.createElement(CssSelect, _extends({
260
- id: id,
261
- className: className,
262
- sx: _objectSpread(_objectSpread({
263
- minWidth: width || '15rem'
264
- }, width ? {
265
- width: width || ''
266
- } : {}), {}, {
267
- maxHeight: '3rem',
268
- height: '3rem',
269
- '& .MuiOutlinedInput-notchedOutline': {
270
- '& legend': {
271
- width: label ? 'auto' : '0px'
272
- }
298
+
299
+ if (e.key === 'ArrowUp') {
300
+ e.preventDefault();
301
+ setIsOpen(true);
273
302
  }
274
- }, sx),
275
- variant: getVariant(),
276
- label: label,
277
- fullWidth: fullWidth,
278
- onChange: onChange,
279
- disabled: disabled,
280
- error: error,
281
- MenuProps: {
282
- PaperProps: {
283
- className: fullWidth ? 'cbx-selectInput-fullwidth' : ''
303
+
304
+ if (e.key === 'Escape') {
305
+ closeDropdown();
284
306
  }
307
+
308
+ handleKeyDown(e);
309
+ },
310
+ type: 'select'
311
+ })), isOpen && /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react.default.createElement("div", {
312
+ className: prefixClass('cbx-selectInput-presentation'),
313
+ onKeyDown: handleKeyDown
314
+ }, /*#__PURE__*/_react.default.createElement("div", {
315
+ className: prefixClass('cbx-selectInput-backdrop'),
316
+ onClick: function onClick() {
317
+ closeDropdown();
285
318
  }
286
- }, props, {
287
- value: value,
288
- InputProps: {
289
- endAdornment: getIcon()
290
- }
291
- }), children), /*#__PURE__*/_react.default.createElement(_material.FormHelperText, {
292
- sx: {
293
- marginLeft: '0',
294
- marginRight: '0px'
295
- }
296
- }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, helperText, error ? /*#__PURE__*/_react.default.createElement("div", {
297
- className: "cbx-selectInput-items-center"
298
- }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
299
- variant: "XS",
300
- color: 'var(--error)'
301
- }, error)) : helper && /*#__PURE__*/_react.default.createElement("div", {
302
- className: "cbx-inputText-items-center"
303
- }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
304
- color: !disabled ? 'var(--gray4)' : 'var(--gray3)',
305
- variant: "XS"
306
- }, helper)))));
319
+ }), /*#__PURE__*/_react.default.createElement("div", {
320
+ className: prefixClass("cbx-selectInput-options-container ".concat(isOpen && !isClosing ? 'cbx-selectInput-options-container-open' : 'cbx-selectInput-options-container-close')),
321
+ ref: dropdownRef
322
+ }, /*#__PURE__*/_react.default.createElement("ul", {
323
+ className: prefixClass('cbx-selectInput-options'),
324
+ ref: optionContainerRef
325
+ }, enhancedChildren))), document.body));
307
326
  };
308
327
 
309
328
  SelectInput.displayName = "SelectInput";
@@ -317,7 +336,8 @@ SelectInput.propTypes = {
317
336
  children: _propTypes.default.node,
318
337
  helperText: _propTypes.default.node,
319
338
  error: _propTypes.default.node,
320
- helper: _propTypes.default.node
339
+ helper: _propTypes.default.node,
340
+ fullWidth: _propTypes.default.bool
321
341
  };
322
342
  SelectInput.defaultProps = {
323
343
  label: '',
@@ -329,7 +349,8 @@ SelectInput.defaultProps = {
329
349
  children: [],
330
350
  helperText: '',
331
351
  error: '',
332
- helper: ''
352
+ helper: '',
353
+ fullWidth: false
333
354
  };
334
355
  var _default = SelectInput;
335
356
  exports.default = _default;
@@ -0,0 +1,17 @@
1
+ .cbx-selectInput-items-center {
2
+ display: flex;
3
+ align-items: center;
4
+ }
5
+
6
+ .cbx-selectInput-infoBtn {
7
+ margin-right: var(--spacing4);
8
+ height: 0.875rem;
9
+ line-height: 1.1;
10
+ font-size: 0.875rem;
11
+ }
12
+
13
+ .cbx-selectInput-fullwidth ul li {
14
+ width: 100%!important;
15
+ min-width: 100%!important;
16
+ max-width: 100%!important;
17
+ }