@councilbox/councilbox-ui 1.0.0 → 2.0.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.
Files changed (132) 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 +7 -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 +363 -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 +144 -115
  53. package/dist/components/IconButton/DesignIconButton.stories.js +37 -2
  54. package/dist/components/IconButton/IconButton.css +144 -0
  55. package/dist/components/IconButton/IconButton.js +177 -50
  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 +316 -77
  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 +31 -6
  78. package/dist/components/MenuItem/MenuItem.js +95 -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 +32 -12
  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 +233 -246
  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/package.json +2 -1
@@ -9,9 +9,9 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- require("../../styles/main.css");
12
+ var _reactDom = require("react-dom");
13
13
 
14
- var _Autocomplete = _interopRequireDefault(require("@mui/material/Autocomplete"));
14
+ require("../../styles/main.css");
15
15
 
16
16
  require("./InputAutocomplete.css");
17
17
 
@@ -19,7 +19,11 @@ var _InputText = _interopRequireDefault(require("../InputText/InputText"));
19
19
 
20
20
  var _MenuItem = _interopRequireDefault(require("../MenuItem/MenuItem"));
21
21
 
22
- var _excluded = ["width", "id", "className", "onChange", "label", "disabled", "error", "helper", "success", "helperText", "fullWidth", "sx", "endAdornment", "variant", "required"];
22
+ var _IconButton = _interopRequireDefault(require("../IconButton/IconButton"));
23
+
24
+ var _useDynamicStyles2 = _interopRequireDefault(require("../../HOCs/useDynamicStyles"));
25
+
26
+ var _excluded = ["children", "className", "onChange", "onInputChange", "label", "value", "inputValue", "style", "styles", "sx", "prefixClass", "options", "getOptionLabel", "getOptionSelected", "defaultValue", "filterOptions", "freeSolo", "clearOnBlur", "selectOnFocus"];
23
27
 
24
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
29
 
@@ -31,97 +35,332 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
31
35
 
32
36
  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; }
33
37
 
38
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
39
+
40
+ 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."); }
41
+
42
+ 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); }
43
+
44
+ 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; }
45
+
46
+ 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; }
47
+
48
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
49
+
34
50
  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; }
35
51
 
36
52
  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; }
37
53
 
38
- var top100Films = [{
39
- label: 'The Shawshank Redemption The Shawshank Redemption',
40
- year: 1994
41
- }, {
42
- label: 'The Godfather',
43
- year: 1972
44
- }, {
45
- label: 'The Godfather: Part II',
46
- year: 1974
47
- }, {
48
- label: 'The Dark Knight',
49
- year: 2008
50
- }, {
51
- label: '12 Angry Men',
52
- year: 1957
53
- }, {
54
- label: "Schindler's List",
55
- year: 1993
56
- }, {
57
- label: 'Pulp Fiction',
58
- year: 1994
59
- }];
60
-
61
54
  var InputAutocomplete = function InputAutocomplete(_ref) {
62
- var width = _ref.width,
63
- id = _ref.id,
55
+ var children = _ref.children,
64
56
  className = _ref.className,
65
57
  onChange = _ref.onChange,
58
+ onInputChange = _ref.onInputChange,
66
59
  label = _ref.label,
67
- disabled = _ref.disabled,
68
- error = _ref.error,
69
- helper = _ref.helper,
70
- success = _ref.success,
71
- helperText = _ref.helperText,
72
- fullWidth = _ref.fullWidth,
60
+ value = _ref.value,
61
+ propInputValue = _ref.inputValue,
62
+ style = _ref.style,
63
+ styles = _ref.styles,
73
64
  sx = _ref.sx,
74
- endAdornment = _ref.endAdornment,
75
- variant = _ref.variant,
76
- required = _ref.required,
65
+ propPrefixClass = _ref.prefixClass,
66
+ options = _ref.options,
67
+ _ref$getOptionLabel = _ref.getOptionLabel,
68
+ getOptionLabel = _ref$getOptionLabel === void 0 ? function (option) {
69
+ return option.label || option.text || option.translation || option.value;
70
+ } : _ref$getOptionLabel,
71
+ _ref$getOptionSelecte = _ref.getOptionSelected,
72
+ getOptionSelected = _ref$getOptionSelecte === void 0 ? function (option, valueSelected) {
73
+ return option === valueSelected;
74
+ } : _ref$getOptionSelecte,
75
+ defaultValue = _ref.defaultValue,
76
+ filterOptions = _ref.filterOptions,
77
+ _ref$freeSolo = _ref.freeSolo,
78
+ freeSolo = _ref$freeSolo === void 0 ? false : _ref$freeSolo,
79
+ _ref$clearOnBlur = _ref.clearOnBlur,
80
+ clearOnBlur = _ref$clearOnBlur === void 0 ? true : _ref$clearOnBlur,
81
+ _ref$selectOnFocus = _ref.selectOnFocus,
82
+ selectOnFocus = _ref$selectOnFocus === void 0 ? false : _ref$selectOnFocus,
77
83
  props = _objectWithoutProperties(_ref, _excluded);
78
84
 
79
- return /*#__PURE__*/_react.default.createElement(_Autocomplete.default, _extends({
80
- id: id,
81
- className: "".concat(className || ''),
82
- onChange: onChange,
83
- disabled: disabled,
84
- sx: _objectSpread({
85
- minWidth: width || '15rem',
86
- '&.MuiAutocomplete-root .MuiOutlinedInput-root': {
87
- padding: '0'
88
- },
89
- '&.MuiAutocomplete-root .MuiFilledInput-root': {
90
- paddingTop: '0',
91
- paddingLeft: '0'
92
- },
93
- '&.MuiAutocomplete-root .MuiInput-root': {
94
- paddingBottom: '0!important'
95
- },
96
- '&.MuiAutocomplete-root .MuiAutocomplete-inputRoot .MuiAutocomplete-input': {
97
- paddingRight: '2.5rem!important'
85
+ var _useDynamicStyles = (0, _useDynamicStyles2.default)(sx),
86
+ stylesInLine = _useDynamicStyles.stylesInLine,
87
+ dynamicPrefixClass = _useDynamicStyles.prefixClass;
88
+
89
+ var prefixClass = propPrefixClass || dynamicPrefixClass;
90
+
91
+ var _React$useState = _react.default.useState(false),
92
+ _React$useState2 = _slicedToArray(_React$useState, 2),
93
+ isOpen = _React$useState2[0],
94
+ setIsOpen = _React$useState2[1];
95
+
96
+ var _React$useState3 = _react.default.useState(false),
97
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
98
+ isClosing = _React$useState4[0],
99
+ setIsClosing = _React$useState4[1];
100
+
101
+ var _React$useState5 = _react.default.useState(value || null),
102
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
103
+ selectedValue = _React$useState6[0],
104
+ setSelectedValue = _React$useState6[1];
105
+
106
+ var _React$useState7 = _react.default.useState(propInputValue || ''),
107
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
108
+ inputValue = _React$useState8[0],
109
+ setInputValue = _React$useState8[1];
110
+
111
+ var _React$useState9 = _react.default.useState(options),
112
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
113
+ filteredOptions = _React$useState10[0],
114
+ setFilteredOptions = _React$useState10[1];
115
+
116
+ var selectRef = _react.default.useRef(null);
117
+
118
+ var dropdownRef = _react.default.useRef(null);
119
+
120
+ var shouldShowDropdown = isOpen && filteredOptions.length > 0;
121
+
122
+ _react.default.useEffect(function () {
123
+ if (propInputValue !== undefined) {
124
+ setInputValue(propInputValue);
125
+ }
126
+ }, [propInputValue]);
127
+
128
+ _react.default.useEffect(function () {
129
+ setSelectedValue(value);
130
+ }, [value]);
131
+
132
+ _react.default.useEffect(function () {
133
+ var newFilteredOptions = options;
134
+
135
+ if (filterOptions) {
136
+ newFilteredOptions = filterOptions(options, {
137
+ inputValue: inputValue
138
+ });
139
+ } else {
140
+ newFilteredOptions = options.filter(function (option) {
141
+ var optionLabel = getOptionLabel(option);
142
+ return optionLabel.toLowerCase().includes(inputValue.toLowerCase());
143
+ });
144
+ }
145
+
146
+ setFilteredOptions(newFilteredOptions);
147
+ }, [inputValue, options]);
148
+
149
+ var closeDropdown = function closeDropdown() {
150
+ setIsClosing(true);
151
+ setTimeout(function () {
152
+ setIsOpen(false);
153
+ setIsClosing(false);
154
+ }, 150);
155
+ };
156
+
157
+ var handleOptionClick = function handleOptionClick(e, option) {
158
+ var optionLabel = getOptionLabel(option);
159
+
160
+ if (props.inputValue === undefined) {
161
+ setInputValue(optionLabel);
162
+ }
163
+
164
+ if (props.value === undefined) {
165
+ setSelectedValue(option);
166
+ }
167
+
168
+ if (onChange) {
169
+ onChange(e, option);
170
+ }
171
+
172
+ closeDropdown();
173
+ };
174
+
175
+ var handleInputChange = function handleInputChange(e) {
176
+ var newInputValue = e.target.value;
177
+
178
+ if (props.inputValue === undefined) {
179
+ setInputValue(newInputValue);
180
+ }
181
+
182
+ if (onInputChange) {
183
+ onInputChange(e, newInputValue);
184
+ }
185
+
186
+ setIsOpen(true);
187
+ };
188
+
189
+ var handleInputBlur = function handleInputBlur(e) {
190
+ if (!freeSolo) {
191
+ var matchedOption = options.find(function (option) {
192
+ return getOptionLabel(option).toLowerCase() === inputValue.toLowerCase();
193
+ });
194
+
195
+ if (matchedOption) {
196
+ if (props.value === undefined) {
197
+ setSelectedValue(matchedOption);
198
+ }
199
+
200
+ if (props.inputValue === undefined) {
201
+ setInputValue(getOptionLabel(matchedOption));
202
+ }
203
+
204
+ if (onChange) {
205
+ onChange(e, matchedOption);
206
+ }
207
+ } else if (props.inputValue === undefined) {
208
+ setInputValue(selectedValue ? getOptionLabel(selectedValue) : '');
209
+ }
210
+ }
211
+
212
+ if (clearOnBlur) {
213
+ closeDropdown();
214
+ }
215
+ };
216
+
217
+ var handleInputFocus = function handleInputFocus(e) {
218
+ if (selectOnFocus) {
219
+ e.target.select();
220
+ }
221
+
222
+ setIsOpen(true);
223
+ };
224
+
225
+ var updateDropdownPosition = function updateDropdownPosition() {
226
+ var _selectRef$current, _selectRef$current2, _selectRef$current2$c;
227
+
228
+ if (selectRef.current && selectRef !== null && selectRef !== void 0 && (_selectRef$current = selectRef.current) !== null && _selectRef$current !== void 0 && _selectRef$current.children[0] && selectRef !== null && selectRef !== void 0 && (_selectRef$current2 = selectRef.current) !== null && _selectRef$current2 !== void 0 && (_selectRef$current2$c = _selectRef$current2.children[0]) !== null && _selectRef$current2$c !== void 0 && _selectRef$current2$c.children[0] && dropdownRef.current) {
229
+ var _selectRef$current3, _selectRef$current3$c, _selectRef$current3$c2;
230
+
231
+ var selectRect = selectRef === null || selectRef === void 0 ? void 0 : (_selectRef$current3 = selectRef.current) === null || _selectRef$current3 === void 0 ? void 0 : (_selectRef$current3$c = _selectRef$current3.children[0]) === null || _selectRef$current3$c === void 0 ? void 0 : (_selectRef$current3$c2 = _selectRef$current3$c.children[0]) === null || _selectRef$current3$c2 === void 0 ? void 0 : _selectRef$current3$c2.getBoundingClientRect();
232
+ var dropdownHeight = dropdownRef.current.offsetHeight + 15;
233
+ var isOverflowingBelow = selectRect.bottom + dropdownHeight > window.innerHeight;
234
+ var topPosition = isOverflowingBelow ? window.innerHeight - dropdownHeight : selectRect.bottom;
235
+ dropdownRef.current.style.top = "".concat(topPosition, "px");
236
+ dropdownRef.current.style.left = "".concat(selectRect.left, "px");
237
+ dropdownRef.current.style.width = "".concat(selectRect.width, "px");
238
+ }
239
+ };
240
+
241
+ _react.default.useEffect(function () {
242
+ updateDropdownPosition();
243
+ }, [isOpen]);
244
+
245
+ _react.default.useEffect(function () {
246
+ var handleResize = function handleResize() {
247
+ if (isOpen) {
248
+ updateDropdownPosition();
249
+ }
250
+ };
251
+
252
+ window.addEventListener('resize', handleResize);
253
+ return function () {
254
+ window.removeEventListener('resize', handleResize);
255
+ };
256
+ }, [isOpen]);
257
+
258
+ return /*#__PURE__*/_react.default.createElement("div", {
259
+ className: prefixClass("cbx-inputAutocomplete-container ".concat(isOpen ? 'cbx-inputAutocomplete-container-open' : '')),
260
+ onClick: function onClick() {
261
+ if (isOpen && !inputValue) {
262
+ closeDropdown();
263
+ } else {
264
+ setIsOpen(true);
98
265
  }
99
- }, sx),
100
- freeSolo: true,
101
- options: top100Films,
102
- renderInput: function renderInput(params) {
103
- return /*#__PURE__*/_react.default.createElement(_InputText.default, _extends({}, params, {
104
- error: error,
105
- label: label,
106
- helper: helper,
107
- success: success,
108
- helperText: helperText,
109
- endAdornment: endAdornment,
110
- variant: variant,
111
- fullWidth: fullWidth,
112
- required: required,
113
- width: width
114
- }));
115
266
  },
116
- renderOption: function renderOption(propsOption) {
117
- return /*#__PURE__*/_react.default.createElement(_MenuItem.default, _extends({
118
- fullWidth: fullWidth
119
- }, propsOption), propsOption.key);
267
+ style: _objectSpread(_objectSpread(_objectSpread({
268
+ width: props.fullWidth && '100%'
269
+ }, styles), style), stylesInLine),
270
+ ref: selectRef
271
+ }, /*#__PURE__*/_react.default.createElement(_InputText.default, _extends({
272
+ label: label,
273
+ value: inputValue,
274
+ className: "".concat(className, " cbx-inputPassword-button-spacing"),
275
+ shrink: !!inputValue || !!selectedValue,
276
+ prefixClass: prefixClass,
277
+ fullWidth: props.fullWidth,
278
+ onChange: handleInputChange,
279
+ onFocus: handleInputFocus,
280
+ onBlur: handleInputBlur,
281
+ defaultValue: defaultValue,
282
+ InputProps: {
283
+ endAdornment: inputValue && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
284
+ prefixClass: prefixClass,
285
+ className: "cbx-inputAutocomplete-icon-button",
286
+ onClick: function onClick(e) {
287
+ e.stopPropagation();
288
+ e.preventDefault();
289
+ setFilteredOptions(options);
290
+
291
+ if (props.inputValue === undefined) {
292
+ setInputValue('');
293
+ }
294
+
295
+ if (onInputChange) {
296
+ onInputChange(e, '');
297
+ }
298
+ },
299
+ icon: /*#__PURE__*/_react.default.createElement("i", {
300
+ className: "ri-close-fill",
301
+ tabIndex: "-1"
302
+ })
303
+ })
120
304
  }
121
- }, props));
305
+ }, props, {
306
+ type: 'autocomplete'
307
+ })), isOpen && /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react.default.createElement("div", {
308
+ className: prefixClass('cbx-inputAutocomplete-presentation')
309
+ }, /*#__PURE__*/_react.default.createElement(OutsideClickHandler, {
310
+ excludedRefs: [selectRef, dropdownRef],
311
+ onOutsideClick: function onOutsideClick() {
312
+ closeDropdown();
313
+ }
314
+ }), /*#__PURE__*/_react.default.createElement("div", {
315
+ className: prefixClass("cbx-inputAutocomplete-options-container ".concat(shouldShowDropdown && !isClosing ? 'cbx-inputAutocomplete-options-container-open' : 'cbx-inputAutocomplete-options-container-close')),
316
+ ref: dropdownRef
317
+ }, /*#__PURE__*/_react.default.createElement("ul", {
318
+ className: prefixClass('cbx-inputAutocomplete-options')
319
+ }, filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.map(function (item, index) {
320
+ return /*#__PURE__*/_react.default.createElement(_MenuItem.default, _extends({}, item, {
321
+ value: item.value || getOptionLabel(item),
322
+ key: "".concat(item.value || getOptionLabel(item), "-").concat(index),
323
+ onClick: function onClick(e) {
324
+ handleOptionClick(e, item);
325
+ },
326
+ active: getOptionSelected(item, selectedValue),
327
+ fullWidth: props.fullWidth
328
+ }), getOptionLabel(item));
329
+ })))), document.body));
122
330
  };
123
331
 
124
332
  InputAutocomplete.displayName = "InputAutocomplete";
333
+
334
+ var OutsideClickHandler = function OutsideClickHandler(_ref2) {
335
+ var children = _ref2.children,
336
+ excludedRefs = _ref2.excludedRefs,
337
+ onOutsideClick = _ref2.onOutsideClick;
338
+
339
+ var wrapperRef = _react.default.useRef(null);
340
+
341
+ _react.default.useEffect(function () {
342
+ var handleClickOutside = function handleClickOutside(event) {
343
+ var clickedExcluded = excludedRefs.some(function (ref) {
344
+ return ref.current && ref.current.contains(event.target);
345
+ });
346
+
347
+ if (wrapperRef.current && !wrapperRef.current.contains(event.target) && !clickedExcluded) {
348
+ onOutsideClick();
349
+ }
350
+ };
351
+
352
+ document.addEventListener('mousedown', handleClickOutside);
353
+ return function () {
354
+ document.removeEventListener('mousedown', handleClickOutside);
355
+ };
356
+ }, [excludedRefs, onOutsideClick]);
357
+
358
+ return /*#__PURE__*/_react.default.createElement("div", {
359
+ ref: wrapperRef
360
+ }, children);
361
+ };
362
+
363
+ OutsideClickHandler.displayName = "OutsideClickHandler";
125
364
  InputAutocomplete.propTypes = {
126
365
  label: _propTypes.default.string,
127
366
  helper: _propTypes.default.string,
@@ -49,29 +49,141 @@ Template.displayName = "Template";
49
49
  var Default = Template.bind({});
50
50
  exports.Default = Default;
51
51
  Default.args = {
52
- variant: 'outlined'
52
+ variant: 'outlined',
53
+ options: [{
54
+ translation: 'Todo',
55
+ value: 'all'
56
+ }, {
57
+ translation: '4',
58
+ value: 'statute_4166'
59
+ }, {
60
+ translation: '5',
61
+ value: 'statute_4167'
62
+ }, {
63
+ translation: 'DemoTrámite',
64
+ value: 'statute_4194'
65
+ }, {
66
+ translation: 'editado para docu required',
67
+ value: 'statute_4136'
68
+ }, {
69
+ translation: 'Gestión de prueba para tener un ejemplo',
70
+ value: 'statute_4226'
71
+ }, {
72
+ translation: 'ghjghjghj',
73
+ value: 'statute_4243'
74
+ }],
75
+ label: 'procedures'
53
76
  };
54
77
  var Helper = Template.bind({});
55
78
  exports.Helper = Helper;
56
79
  Helper.args = {
57
- value: 'Occaecat',
58
- helper: 'Helper'
80
+ value: 'The Godfather',
81
+ helper: 'Helper',
82
+ variant: 'outlined',
83
+ options: [{
84
+ label: 'The Shawshank Redemption The Shawshank Redemption',
85
+ value: 1994
86
+ }, {
87
+ label: 'The Godfather',
88
+ value: 1972
89
+ }, {
90
+ label: 'The Godfather: Part II',
91
+ value: 1974
92
+ }, {
93
+ label: 'The Dark Knight',
94
+ value: 2008
95
+ }, {
96
+ label: '12 Angry Men',
97
+ value: 1957
98
+ }, {
99
+ label: "Schindler's List",
100
+ value: 1993
101
+ }, {
102
+ label: 'Pulp Fiction',
103
+ value: 1994
104
+ }]
59
105
  };
60
106
  var Success = Template.bind({});
61
107
  exports.Success = Success;
62
108
  Success.args = {
63
109
  value: 'Occaecat',
64
- success: true
110
+ success: true,
111
+ options: [{
112
+ label: 'The Shawshank Redemption The Shawshank Redemption',
113
+ value: 1994
114
+ }, {
115
+ label: 'The Godfather',
116
+ value: 1972
117
+ }, {
118
+ label: 'The Godfather: Part II',
119
+ value: 1974
120
+ }, {
121
+ label: 'The Dark Knight',
122
+ value: 2008
123
+ }, {
124
+ label: '12 Angry Men',
125
+ value: 1957
126
+ }, {
127
+ label: "Schindler's List",
128
+ value: 1993
129
+ }, {
130
+ label: 'Pulp Fiction',
131
+ value: 1994
132
+ }]
65
133
  };
66
134
  var Disabled = Template.bind({});
67
135
  exports.Disabled = Disabled;
68
136
  Disabled.args = {
69
137
  value: 'Occaecat',
70
- disabled: true
138
+ disabled: true,
139
+ options: [{
140
+ label: 'The Shawshank Redemption The Shawshank Redemption',
141
+ value: 1994
142
+ }, {
143
+ label: 'The Godfather',
144
+ value: 1972
145
+ }, {
146
+ label: 'The Godfather: Part II',
147
+ value: 1974
148
+ }, {
149
+ label: 'The Dark Knight',
150
+ value: 2008
151
+ }, {
152
+ label: '12 Angry Men',
153
+ value: 1957
154
+ }, {
155
+ label: "Schindler's List",
156
+ value: 1993
157
+ }, {
158
+ label: 'Pulp Fiction',
159
+ value: 1994
160
+ }]
71
161
  };
72
162
  var ErrorTemplate = Template.bind({});
73
163
  exports.ErrorTemplate = ErrorTemplate;
74
164
  ErrorTemplate.args = {
75
165
  value: 'Occaecat',
76
- error: 'Error'
166
+ error: 'Error',
167
+ options: [{
168
+ label: 'The Shawshank Redemption The Shawshank Redemption',
169
+ value: 1994
170
+ }, {
171
+ label: 'The Godfather',
172
+ value: 1972
173
+ }, {
174
+ label: 'The Godfather: Part II',
175
+ value: 1974
176
+ }, {
177
+ label: 'The Dark Knight',
178
+ value: 2008
179
+ }, {
180
+ label: '12 Angry Men',
181
+ value: 1957
182
+ }, {
183
+ label: "Schindler's List",
184
+ value: 1993
185
+ }, {
186
+ label: 'Pulp Fiction',
187
+ value: 1994
188
+ }]
77
189
  };
@@ -0,0 +1,5 @@
1
+ .cbx-inputAutocomplete-fullwidth ul li {
2
+ width: 100%!important;
3
+ min-width: 100%!important;
4
+ max-width: 100%!important;
5
+ }