@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.
- package/dist/HOCs/useDynamicStyles.js +99 -0
- package/dist/HOCs/useRipple.js +91 -0
- package/dist/build-index.js +8 -0
- package/dist/components/1.Introduction.stories.mdx +2 -1
- package/dist/components/2.Changelog.stories.mdx +7 -0
- package/dist/components/3.Guide.stories.mdx +56 -0
- package/dist/components/Accordion/Accordion.css +39 -1
- package/dist/components/Accordion/Accordion.js +84 -45
- package/dist/components/Accordion/Accordion.stories.js +4 -2
- package/dist/components/Accordion/AccordionOld.css +16 -0
- package/dist/components/Accordion/AccordionOld.js +115 -0
- package/dist/components/Accordion/DesignAccordion.stories.js +38 -0
- package/dist/components/Alert/Alert.css +5 -0
- package/dist/components/Alert/Alert.js +17 -6
- package/dist/components/Avatar/Avatar.css +3 -3
- package/dist/components/Avatar/Avatar.js +36 -20
- package/dist/components/Avatar/AvatarOld.js +138 -0
- package/dist/components/Avatar/DesignAvatar.stories.js +1 -1
- package/dist/components/Block/Block.js +17 -2
- package/dist/components/ButtonBasic/ButtonBasic.css +264 -20
- package/dist/components/ButtonBasic/ButtonBasic.js +85 -110
- package/dist/components/ButtonBasic/ButtonBasicOld.css +41 -0
- package/dist/components/ButtonBasic/ButtonBasicOld.js +231 -0
- package/dist/components/Checkbox/Checkbox.css +101 -22
- package/dist/components/Checkbox/Checkbox.js +119 -63
- package/dist/components/Checkbox/CheckboxOld.css +31 -0
- package/dist/components/Checkbox/CheckboxOld.js +112 -0
- package/dist/components/DragDrop/DragDrop.js +24 -9
- package/dist/components/DrawerPanel/DesignDrawerPanel.js +4 -2
- package/dist/components/DrawerPanel/DrawerPanel.css +76 -36
- package/dist/components/DrawerPanel/DrawerPanel.js +137 -115
- package/dist/components/DrawerPanel/DrawerPanelOld.css +56 -0
- package/dist/components/DrawerPanel/DrawerPanelOld.js +233 -0
- package/dist/components/DropDown/DesignDropDown.stories.js +146 -17
- package/dist/components/DropDown/DropDown.css +96 -1
- package/dist/components/DropDown/DropDown.js +363 -82
- package/dist/components/DropDown/DropDown.stories.js +1 -0
- package/dist/components/DropDown/DropDownOld.css +3 -0
- package/dist/components/DropDown/DropDownOld.js +186 -0
- package/dist/components/DropDown/PopoverPlayground.css +22 -0
- package/dist/components/DropDown/PopoverPlayground.js +235 -0
- package/dist/components/EnhancedTable/EnhancedTable.js +5 -6
- package/dist/components/FabButton/DesignFabButton.stories.js +3 -1
- package/dist/components/FabButton/FabButton.js +25 -5
- package/dist/components/Grid/DesignGrid.stories.js +9 -3
- package/dist/components/Grid/Grid.css +325 -0
- package/dist/components/Grid/Grid.js +57 -16
- package/dist/components/Grid/GridItem.js +31 -13
- package/dist/components/Grid/GridItemOld.js +43 -0
- package/dist/components/Grid/GridOld.css +0 -0
- package/dist/components/Grid/GridOld.js +53 -0
- package/dist/components/Header/Header.js +144 -115
- package/dist/components/IconButton/DesignIconButton.stories.js +37 -2
- package/dist/components/IconButton/IconButton.css +144 -0
- package/dist/components/IconButton/IconButton.js +177 -50
- package/dist/components/IconButton/IconButtonOld.css +0 -0
- package/dist/components/IconButton/IconButtonOld.js +138 -0
- package/dist/components/IconButtonSquare/IconButtonSquare.js +20 -90
- package/dist/components/IconButtonSquare/IconButtonSquareOld.css +43 -0
- package/dist/components/IconButtonSquare/IconButtonSquareOld.js +133 -0
- package/dist/components/InputAutocomplete/InputAutocomplete.css +109 -0
- package/dist/components/InputAutocomplete/InputAutocomplete.js +316 -77
- package/dist/components/InputAutocomplete/InputAutocomplete.stories.js +118 -6
- package/dist/components/InputAutocomplete/InputAutocompleteOld.css +5 -0
- package/dist/components/InputAutocomplete/InputAutocompleteOld.js +178 -0
- package/dist/components/InputPassword/InputPassword.js +10 -20
- package/dist/components/InputText/InputText.css +442 -1
- package/dist/components/InputText/InputText.js +298 -239
- package/dist/components/InputText/InputText.stories.js +12 -3
- package/dist/components/InputText/InputTextOld.css +10 -0
- package/dist/components/InputText/InputTextOld.js +340 -0
- package/dist/components/InputTextArea/DesignInputTextArea.stories.js +30 -4
- package/dist/components/InputTextArea/InputTextArea.js +13 -6
- package/dist/components/LoadingSection/LoadingSection.css +44 -2
- package/dist/components/LoadingSection/LoadingSection.js +63 -9
- package/dist/components/MenuItem/DesignMenuItem.stories.js +1 -0
- package/dist/components/MenuItem/MenuItem.css +31 -6
- package/dist/components/MenuItem/MenuItem.js +95 -50
- package/dist/components/MenuItem/MenuItemOld.js +139 -0
- package/dist/components/MenuLateralLeft/MenuLateralLeft.js +60 -40
- package/dist/components/MenuLateralRight/MenuLateralRight.js +32 -12
- package/dist/components/Modal/DesignModal.stories.js +54 -0
- package/dist/components/Modal/Modal.css +81 -2
- package/dist/components/Modal/Modal.js +112 -80
- package/dist/components/Modal/Modal.stories.js +13 -2
- package/dist/components/Modal/ModalOld.css +3 -0
- package/dist/components/Modal/ModalOld.js +230 -0
- package/dist/components/PaginationFooter/DesignPaginationFooter.stories.js +9 -1
- package/dist/components/PaginationFooter/PaginationFooter.css +73 -0
- package/dist/components/PaginationFooter/PaginationFooter.js +45 -87
- package/dist/components/RadioButton/Radio.css +115 -16
- package/dist/components/RadioButton/Radio.js +70 -94
- package/dist/components/RadioButton/Radio.stories.js +42 -18
- package/dist/components/RadioButton/RadioOld.css +31 -0
- package/dist/components/RadioButton/RadioOld.js +142 -0
- package/dist/components/Ripple/DesignRipple.js +77 -0
- package/dist/components/Ripple/Ripple.stories.js +45 -0
- package/dist/components/Scrollbar/Scrollbar.js +21 -6
- package/dist/components/SelectInput/DesignSelectInput.js +62 -23
- package/dist/components/SelectInput/SelectInput.css +128 -10
- package/dist/components/SelectInput/SelectInput.js +233 -246
- package/dist/components/SelectInput/SelectInputOld.css +17 -0
- package/dist/components/SelectInput/SelectInputOld.js +325 -0
- package/dist/components/Stars/Stars.css +28 -28
- package/dist/components/Stars/Stars.js +22 -12
- package/dist/components/Stepper/Stepper.css +1 -0
- package/dist/components/Stepper/Stepper.js +81 -24
- package/dist/components/Table/DesignTable.stories.js +1 -0
- package/dist/components/Table/Table.css +56 -53
- package/dist/components/Table/Table.js +55 -75
- package/dist/components/Table/TableOld.css +79 -0
- package/dist/components/Table/TableOld.js +165 -0
- package/dist/components/Tabs/DesignTabs.js +37 -12
- package/dist/components/Tabs/Tabs.css +39 -4
- package/dist/components/Tabs/Tabs.js +194 -30
- package/dist/components/Tabs/Tabs.stories.js +8 -1
- package/dist/components/Tabs/TabsOld.js +92 -0
- package/dist/components/Tag/Tag.js +19 -9
- package/dist/components/Toggle/Toggle.css +122 -3
- package/dist/components/Toggle/Toggle.js +95 -68
- package/dist/components/Tooltip/DesignTooltip.stories.js +48 -0
- package/dist/components/Tooltip/Tooltip.css +75 -0
- package/dist/components/Tooltip/Tooltip.js +126 -0
- package/dist/components/Tooltip/Tooltip.stories.js +40 -0
- package/dist/components/Typography/Typography.css +9 -0
- package/dist/components/Typography/Typography.js +30 -21
- package/dist/components/Typography/TypographyOld.js +132 -0
- package/dist/styles/colorConsts.css +24 -0
- package/dist/styles/main.css +41 -49
- package/dist/styles/scpacingConsts.css +26 -0
- package/dist/styles/zIndexConsts.css +9 -0
- 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("
|
|
12
|
+
var _reactDom = require("react-dom");
|
|
13
13
|
|
|
14
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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: '
|
|
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
|
};
|