@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.
- 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 +3 -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 +308 -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 +95 -116
- package/dist/components/IconButton/DesignIconButton.stories.js +22 -2
- package/dist/components/IconButton/IconButton.css +121 -1
- package/dist/components/IconButton/IconButton.js +98 -53
- 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 +382 -76
- 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 +35 -6
- package/dist/components/MenuItem/MenuItem.js +99 -50
- package/dist/components/MenuItem/MenuItemOld.js +139 -0
- package/dist/components/MenuLateralLeft/MenuLateralLeft.js +60 -40
- package/dist/components/MenuLateralRight/MenuLateralRight.js +23 -8
- 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 +265 -244
- 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/dist/testing/TestAutocomplete.js +369 -0
- package/dist/testing/TestComponents.js +3 -114
- package/dist/testing/TestDropdown.js +225 -0
- package/dist/utils/autoDetectScroll.js +127 -0
- package/dist/utils/index.js +141 -0
- package/package.json +2 -1
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
7
|
|
|
10
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
|
|
12
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
11
|
|
|
14
|
-
var
|
|
12
|
+
var _reactDom = require("react-dom");
|
|
15
13
|
|
|
16
14
|
var _ButtonBasic = _interopRequireDefault(require("../ButtonBasic/ButtonBasic"));
|
|
17
15
|
|
|
@@ -19,13 +17,13 @@ require("../../styles/main.css");
|
|
|
19
17
|
|
|
20
18
|
require("./DropDown.css");
|
|
21
19
|
|
|
22
|
-
var
|
|
20
|
+
var _useDynamicStyles2 = _interopRequireDefault(require("../../HOCs/useDynamicStyles"));
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
var _utils = require("../../utils");
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
var _excluded = ["text", "Component", "items", "id", "type", "open", "icon", "requestClose", "anchorOrigin", "transformOrigin", "styleComponent", "variantButton", "stylesButtonText", "sxButton", "forceClose", "sx", "style", "styles", "prefixClass", "setOpen", "className"];
|
|
27
25
|
|
|
28
|
-
function
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
27
|
|
|
30
28
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
31
29
|
|
|
@@ -51,73 +49,308 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
51
49
|
|
|
52
50
|
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; }
|
|
53
51
|
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
id = _ref.id,
|
|
59
|
-
type = _ref.type,
|
|
60
|
-
open = _ref.open,
|
|
61
|
-
icon = _ref.icon,
|
|
62
|
-
requestClose = _ref.requestClose,
|
|
52
|
+
var OUT_MARGIN = 1;
|
|
53
|
+
|
|
54
|
+
var getDefaultCoordinates = function getDefaultCoordinates(_ref) {
|
|
55
|
+
var transformOrigin = _ref.transformOrigin,
|
|
63
56
|
anchorOrigin = _ref.anchorOrigin,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
dropdownRect = _ref.dropdownRect,
|
|
58
|
+
anchorRect = _ref.anchorRect,
|
|
59
|
+
viewportHeight = _ref.viewportHeight,
|
|
60
|
+
viewportWidth = _ref.viewportWidth;
|
|
61
|
+
var anchorVertical = anchorRect[anchorOrigin.vertical !== 'center' ? anchorOrigin.vertical : 'top'];
|
|
62
|
+
var anchorHorizontal = anchorRect[anchorOrigin.horizontal !== 'center' ? anchorOrigin.horizontal : 'left'];
|
|
63
|
+
|
|
64
|
+
if (anchorOrigin.vertical === 'center') {
|
|
65
|
+
anchorVertical += anchorRect.height / 2;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (anchorOrigin.horizontal === 'center') {
|
|
69
|
+
anchorHorizontal += anchorRect.width / 2;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var transformVertical = 0;
|
|
73
|
+
var transformHorizontal = 0;
|
|
74
|
+
|
|
75
|
+
if (transformOrigin.vertical === 'center') {
|
|
76
|
+
transformVertical = dropdownRect.height / 2;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (transformOrigin.horizontal === 'center') {
|
|
80
|
+
transformHorizontal = dropdownRect.width / 2;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var top = null;
|
|
84
|
+
var left = null;
|
|
85
|
+
var right = null;
|
|
86
|
+
var bottom = null;
|
|
87
|
+
|
|
88
|
+
if (transformOrigin.vertical === 'top') {
|
|
89
|
+
top = anchorVertical - transformVertical;
|
|
90
|
+
|
|
91
|
+
if (top + dropdownRect.height > viewportHeight) {
|
|
92
|
+
top = null;
|
|
93
|
+
bottom = OUT_MARGIN;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (top < 0) {
|
|
97
|
+
top = OUT_MARGIN;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (transformOrigin.vertical === 'center') {
|
|
102
|
+
top = anchorVertical - transformVertical;
|
|
103
|
+
|
|
104
|
+
if (top + dropdownRect.height > viewportHeight) {
|
|
105
|
+
bottom = OUT_MARGIN;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (top < 0) {
|
|
109
|
+
top = OUT_MARGIN;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
78
112
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
113
|
+
if (transformOrigin.horizontal === 'left') {
|
|
114
|
+
left = anchorHorizontal - transformHorizontal;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (transformOrigin.horizontal === 'right') {
|
|
118
|
+
if (anchorOrigin.horizontal === 'center') {
|
|
119
|
+
right = anchorHorizontal - transformHorizontal;
|
|
82
120
|
} else {
|
|
83
|
-
|
|
121
|
+
right = viewportWidth - anchorRect[anchorOrigin.horizontal];
|
|
84
122
|
}
|
|
85
|
-
}, [open]);
|
|
86
123
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
124
|
+
if (right + dropdownRect.width > viewportWidth) {
|
|
125
|
+
left = OUT_MARGIN;
|
|
126
|
+
right = null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
90
129
|
|
|
91
|
-
|
|
92
|
-
|
|
130
|
+
if (transformOrigin.horizontal === 'center') {
|
|
131
|
+
left = anchorHorizontal - transformHorizontal;
|
|
132
|
+
|
|
133
|
+
if (left + dropdownRect.width > viewportWidth) {
|
|
134
|
+
right = OUT_MARGIN;
|
|
93
135
|
}
|
|
94
|
-
};
|
|
95
136
|
|
|
96
|
-
|
|
97
|
-
|
|
137
|
+
if (left < 0) {
|
|
138
|
+
left = OUT_MARGIN;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (left + dropdownRect.width > viewportWidth) {
|
|
143
|
+
right = OUT_MARGIN;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (left < 0) {
|
|
147
|
+
left = OUT_MARGIN;
|
|
148
|
+
}
|
|
98
149
|
|
|
99
|
-
|
|
100
|
-
|
|
150
|
+
if (transformOrigin.vertical === 'bottom') {
|
|
151
|
+
if (anchorOrigin.vertical === 'center') {
|
|
152
|
+
bottom = viewportHeight - anchorVertical;
|
|
153
|
+
} else {
|
|
154
|
+
bottom = viewportHeight - anchorRect[anchorOrigin.vertical];
|
|
101
155
|
}
|
|
102
156
|
|
|
103
|
-
|
|
157
|
+
if (bottom + dropdownRect.height > viewportHeight) {
|
|
158
|
+
top = OUT_MARGIN;
|
|
159
|
+
bottom = null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
top: top,
|
|
165
|
+
left: left,
|
|
166
|
+
right: right,
|
|
167
|
+
bottom: bottom
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
var DropDown = function DropDown(_ref2) {
|
|
172
|
+
var text = _ref2.text,
|
|
173
|
+
Component = _ref2.Component,
|
|
174
|
+
items = _ref2.items,
|
|
175
|
+
id = _ref2.id,
|
|
176
|
+
type = _ref2.type,
|
|
177
|
+
open = _ref2.open,
|
|
178
|
+
icon = _ref2.icon,
|
|
179
|
+
requestClose = _ref2.requestClose,
|
|
180
|
+
_ref2$anchorOrigin = _ref2.anchorOrigin,
|
|
181
|
+
anchorOrigin = _ref2$anchorOrigin === void 0 ? {
|
|
182
|
+
vertical: 'bottom',
|
|
183
|
+
horizontal: 'left'
|
|
184
|
+
} : _ref2$anchorOrigin,
|
|
185
|
+
_ref2$transformOrigin = _ref2.transformOrigin,
|
|
186
|
+
transformOrigin = _ref2$transformOrigin === void 0 ? {
|
|
187
|
+
vertical: 'top',
|
|
188
|
+
horizontal: 'left'
|
|
189
|
+
} : _ref2$transformOrigin,
|
|
190
|
+
styleComponent = _ref2.styleComponent,
|
|
191
|
+
variantButton = _ref2.variantButton,
|
|
192
|
+
stylesButtonText = _ref2.stylesButtonText,
|
|
193
|
+
sxButton = _ref2.sxButton,
|
|
194
|
+
forceClose = _ref2.forceClose,
|
|
195
|
+
sx = _ref2.sx,
|
|
196
|
+
style = _ref2.style,
|
|
197
|
+
styles = _ref2.styles,
|
|
198
|
+
propPrefixClass = _ref2.prefixClass,
|
|
199
|
+
setOpen = _ref2.setOpen,
|
|
200
|
+
className = _ref2.className,
|
|
201
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
202
|
+
|
|
203
|
+
var memoizedSx = _react.default.useMemo(function () {
|
|
204
|
+
return sx;
|
|
205
|
+
}, []);
|
|
206
|
+
|
|
207
|
+
var _useDynamicStyles = (0, _useDynamicStyles2.default)(memoizedSx),
|
|
208
|
+
stylesInLine = _useDynamicStyles.stylesInLine,
|
|
209
|
+
dynamicPrefixClass = _useDynamicStyles.prefixClass;
|
|
210
|
+
|
|
211
|
+
var prefixClass = propPrefixClass || dynamicPrefixClass;
|
|
212
|
+
|
|
213
|
+
var containerDropdownRef = _react.default.useRef(null);
|
|
214
|
+
|
|
215
|
+
var dropdownRef = _react.default.useRef(null);
|
|
216
|
+
|
|
217
|
+
var timeoutRef = _react.default.useRef(null);
|
|
218
|
+
|
|
219
|
+
var _React$useState = _react.default.useState(false),
|
|
220
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
221
|
+
isOpen = _React$useState2[0],
|
|
222
|
+
setIsOpenState = _React$useState2[1];
|
|
223
|
+
|
|
224
|
+
var _React$useState3 = _react.default.useState(false),
|
|
225
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
226
|
+
isVisible = _React$useState4[0],
|
|
227
|
+
setIsVisible = _React$useState4[1];
|
|
228
|
+
|
|
229
|
+
var _React$useState5 = _react.default.useState(null),
|
|
230
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
231
|
+
popoverStyles = _React$useState6[0],
|
|
232
|
+
setPopoverStyles = _React$useState6[1];
|
|
233
|
+
|
|
234
|
+
var setIsOpen = function setIsOpen(value) {
|
|
235
|
+
setIsOpenState(value);
|
|
104
236
|
|
|
105
237
|
if (setOpen) {
|
|
106
|
-
|
|
238
|
+
setOpen(value);
|
|
107
239
|
}
|
|
108
240
|
};
|
|
109
241
|
|
|
110
|
-
_react.default.
|
|
111
|
-
|
|
112
|
-
|
|
242
|
+
var handleClick = _react.default.useCallback(function (event) {
|
|
243
|
+
console.log('abre cabrón');
|
|
244
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
245
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
246
|
+
setIsOpen(true);
|
|
247
|
+
}, [setIsOpen]);
|
|
248
|
+
|
|
249
|
+
var closeDropdown = _react.default.useCallback(function (event) {
|
|
250
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
251
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
252
|
+
setTimeout(function () {
|
|
253
|
+
setIsOpen(false);
|
|
254
|
+
|
|
255
|
+
if (forceClose) {
|
|
256
|
+
forceClose(false);
|
|
257
|
+
}
|
|
258
|
+
}, 150);
|
|
259
|
+
}, [forceClose, setIsOpen]);
|
|
260
|
+
|
|
261
|
+
var adjustPopoverPosition = _react.default.useCallback(function () {
|
|
262
|
+
if (!containerDropdownRef.current || !dropdownRef.current) return;
|
|
263
|
+
var anchorRect = containerDropdownRef.current.getBoundingClientRect();
|
|
264
|
+
var dropdownRect = dropdownRef.current.getBoundingClientRect();
|
|
265
|
+
var viewportWidth = window.innerWidth;
|
|
266
|
+
var viewportHeight = window.innerHeight;
|
|
267
|
+
|
|
268
|
+
var _getDefaultCoordinate = getDefaultCoordinates({
|
|
269
|
+
transformOrigin: transformOrigin,
|
|
270
|
+
anchorOrigin: anchorOrigin,
|
|
271
|
+
dropdownRect: dropdownRect,
|
|
272
|
+
viewportWidth: viewportWidth,
|
|
273
|
+
viewportHeight: viewportHeight,
|
|
274
|
+
anchorRect: anchorRect,
|
|
275
|
+
printLogs: id === 'centro'
|
|
276
|
+
}),
|
|
277
|
+
top = _getDefaultCoordinate.top,
|
|
278
|
+
left = _getDefaultCoordinate.left,
|
|
279
|
+
right = _getDefaultCoordinate.right,
|
|
280
|
+
bottom = _getDefaultCoordinate.bottom;
|
|
281
|
+
|
|
282
|
+
setPopoverStyles(_objectSpread(_objectSpread(_objectSpread({
|
|
283
|
+
position: 'absolute'
|
|
284
|
+
}, bottom ? {
|
|
285
|
+
bottom: "".concat(bottom, "px")
|
|
286
|
+
} : {
|
|
287
|
+
top: "".concat(top, "px")
|
|
288
|
+
}), right ? {
|
|
289
|
+
right: "".concat(right, "px")
|
|
290
|
+
} : {
|
|
291
|
+
left: "".concat(left, "px")
|
|
292
|
+
}), {}, {
|
|
293
|
+
transformOrigin: "".concat(transformOrigin.vertical, " ").concat(transformOrigin.horizontal)
|
|
294
|
+
}));
|
|
295
|
+
}, [setPopoverStyles, containerDropdownRef.current]);
|
|
296
|
+
|
|
297
|
+
var debouncedAdjustPopoverPosition = _react.default.useCallback(function () {
|
|
298
|
+
if (timeoutRef.current) {
|
|
299
|
+
clearTimeout(timeoutRef.current);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
timeoutRef.current = setTimeout(function () {
|
|
303
|
+
adjustPopoverPosition();
|
|
304
|
+
}, 100);
|
|
305
|
+
}, [adjustPopoverPosition]);
|
|
306
|
+
|
|
307
|
+
_react.default.useLayoutEffect(function () {
|
|
308
|
+
if (isOpen) {
|
|
309
|
+
setIsVisible(true);
|
|
310
|
+
debouncedAdjustPopoverPosition();
|
|
311
|
+
window.addEventListener('resize', debouncedAdjustPopoverPosition);
|
|
312
|
+
} else {
|
|
313
|
+
setIsVisible(false);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return function () {
|
|
317
|
+
window.removeEventListener('resize', debouncedAdjustPopoverPosition);
|
|
318
|
+
|
|
319
|
+
if (timeoutRef.current) {
|
|
320
|
+
clearTimeout(timeoutRef.current);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}, [isOpen, adjustPopoverPosition, debouncedAdjustPopoverPosition, isVisible]);
|
|
324
|
+
|
|
325
|
+
var handleOptionClick = _react.default.useCallback(function (option, event) {
|
|
326
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
327
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
328
|
+
closeDropdown();
|
|
329
|
+
|
|
330
|
+
if (option) {
|
|
331
|
+
var _option$props, _option$props$onClick;
|
|
332
|
+
|
|
333
|
+
(_option$props = option.props) === null || _option$props === void 0 ? void 0 : (_option$props$onClick = _option$props.onClick) === null || _option$props$onClick === void 0 ? void 0 : _option$props$onClick.call(_option$props, event);
|
|
334
|
+
}
|
|
335
|
+
}, [closeDropdown]);
|
|
336
|
+
|
|
337
|
+
var enhancedItems = _react.default.useMemo(function () {
|
|
338
|
+
return (0, _utils.enhanceClickableChildren)(items, handleOptionClick);
|
|
339
|
+
}, [items, handleOptionClick]);
|
|
113
340
|
|
|
114
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
341
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
342
|
+
className: "cbx-dropdown-container ".concat(className),
|
|
343
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, styles), style), stylesInLine)
|
|
344
|
+
}, props), Component ? /*#__PURE__*/_react.default.createElement("div", {
|
|
115
345
|
onClick: handleClick,
|
|
116
346
|
id: id,
|
|
117
|
-
|
|
347
|
+
ref: containerDropdownRef,
|
|
348
|
+
className: prefixClass('cbx-dropdown-component-container'),
|
|
118
349
|
style: _objectSpread({}, styleComponent)
|
|
119
|
-
}, typeof Component === 'function' ? /*#__PURE__*/_react.default.createElement(Component, null) : Component) : /*#__PURE__*/_react.default.createElement(
|
|
120
|
-
|
|
350
|
+
}, typeof Component === 'function' ? /*#__PURE__*/_react.default.createElement(Component, null) : Component) : /*#__PURE__*/_react.default.createElement("div", {
|
|
351
|
+
ref: containerDropdownRef
|
|
352
|
+
}, /*#__PURE__*/_react.default.createElement(_ButtonBasic.default, {
|
|
353
|
+
variant: variantButton || 'tertiary',
|
|
121
354
|
type: type,
|
|
122
355
|
id: id,
|
|
123
356
|
onClick: handleClick,
|
|
@@ -125,31 +358,18 @@ var DropDown = function DropDown(_ref) {
|
|
|
125
358
|
text: text,
|
|
126
359
|
stylesButton: _objectSpread({}, stylesButtonText),
|
|
127
360
|
sx: _objectSpread({}, sxButton)
|
|
128
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}, anchorOrigin),
|
|
141
|
-
transformOrigin: transformOrigin,
|
|
142
|
-
sx: {
|
|
143
|
-
'& .MuiPopover-root .MuiButtonBase-root-MuiMenuItem-root:hover': {
|
|
144
|
-
background: 'var(--gray1)'
|
|
145
|
-
},
|
|
146
|
-
'& .MuiPopover-paper': {
|
|
147
|
-
boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.25)'
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}, props), /*#__PURE__*/_react.default.createElement("div", {
|
|
151
|
-
onClick: props.persistent ? function () {} : handleClose
|
|
152
|
-
}, items)));
|
|
361
|
+
})), isOpen && /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/_react.default.createElement("div", {
|
|
362
|
+
className: prefixClass('cbx-dropdown-presentation')
|
|
363
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
364
|
+
className: prefixClass('cbx-dropdown-backdrop'),
|
|
365
|
+
onClick: closeDropdown
|
|
366
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
367
|
+
className: prefixClass("cbx-dropdown-options-container ".concat(isVisible && popoverStyles ? 'cbx-dropdown-options-container-opened' : 'cbx-dropdown-options-container-closed')),
|
|
368
|
+
ref: dropdownRef,
|
|
369
|
+
style: popoverStyles
|
|
370
|
+
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
371
|
+
className: prefixClass('cbx-dropdown-options')
|
|
372
|
+
}, enhancedItems))), document.body));
|
|
153
373
|
};
|
|
154
374
|
|
|
155
375
|
DropDown.displayName = "DropDown";
|
|
@@ -176,9 +396,15 @@ DropDown.defaultProps = {
|
|
|
176
396
|
open: null,
|
|
177
397
|
icon: null,
|
|
178
398
|
requestClose: undefined,
|
|
179
|
-
anchorOrigin:
|
|
399
|
+
anchorOrigin: {
|
|
400
|
+
vertical: 'bottom',
|
|
401
|
+
horizontal: 'right'
|
|
402
|
+
},
|
|
180
403
|
paperPropsStyles: undefined,
|
|
181
|
-
transformOrigin:
|
|
404
|
+
transformOrigin: {
|
|
405
|
+
vertical: 'top',
|
|
406
|
+
horizontal: 'left'
|
|
407
|
+
},
|
|
182
408
|
styleComponent: undefined,
|
|
183
409
|
sxButton: undefined,
|
|
184
410
|
variantButton: ''
|
|
@@ -38,6 +38,7 @@ var TemplateDropDown = function TemplateDropDown(args) {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
TemplateDropDown.displayName = "TemplateDropDown";
|
|
41
|
+
// const TemplateDropDown = args => <PopoverPlayground {...args} />;
|
|
41
42
|
var DesignDropDownTemplate = TemplateDropDown.bind({});
|
|
42
43
|
exports.DesignDropDownTemplate = DesignDropDownTemplate;
|
|
43
44
|
DesignDropDownTemplate.parameters = {
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _Popover = _interopRequireDefault(require("@mui/material/Popover"));
|
|
15
|
+
|
|
16
|
+
var _ButtonBasic = _interopRequireDefault(require("../ButtonBasic/ButtonBasic"));
|
|
17
|
+
|
|
18
|
+
require("../../styles/main.css");
|
|
19
|
+
|
|
20
|
+
require("./DropDown.css");
|
|
21
|
+
|
|
22
|
+
var _excluded = ["text", "Component", "items", "id", "type", "open", "icon", "requestClose", "anchorOrigin", "paperPropsStyles", "transformOrigin", "styleComponent", "variantButton", "stylesButtonText", "sxButton", "forceClose"];
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
31
|
+
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
+
|
|
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; }
|
|
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
|
+
|
|
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; }
|
|
51
|
+
|
|
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; }
|
|
53
|
+
|
|
54
|
+
var DropDown = function DropDown(_ref) {
|
|
55
|
+
var text = _ref.text,
|
|
56
|
+
Component = _ref.Component,
|
|
57
|
+
items = _ref.items,
|
|
58
|
+
id = _ref.id,
|
|
59
|
+
type = _ref.type,
|
|
60
|
+
open = _ref.open,
|
|
61
|
+
icon = _ref.icon,
|
|
62
|
+
requestClose = _ref.requestClose,
|
|
63
|
+
anchorOrigin = _ref.anchorOrigin,
|
|
64
|
+
paperPropsStyles = _ref.paperPropsStyles,
|
|
65
|
+
transformOrigin = _ref.transformOrigin,
|
|
66
|
+
styleComponent = _ref.styleComponent,
|
|
67
|
+
variantButton = _ref.variantButton,
|
|
68
|
+
stylesButtonText = _ref.stylesButtonText,
|
|
69
|
+
sxButton = _ref.sxButton,
|
|
70
|
+
forceClose = _ref.forceClose,
|
|
71
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
72
|
+
|
|
73
|
+
var _React$useState = _react.default.useState(null),
|
|
74
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
75
|
+
anchorEl = _React$useState2[0],
|
|
76
|
+
setAnchorEl = _React$useState2[1];
|
|
77
|
+
|
|
78
|
+
_react.default.useEffect(function () {
|
|
79
|
+
if (open) {
|
|
80
|
+
setAnchorEl(open);
|
|
81
|
+
} else {
|
|
82
|
+
setAnchorEl(null);
|
|
83
|
+
}
|
|
84
|
+
}, [open]);
|
|
85
|
+
|
|
86
|
+
var handleClick = function handleClick(event) {
|
|
87
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
88
|
+
setAnchorEl(event === null || event === void 0 ? void 0 : event.currentTarget);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var handleClose = function handleClose(event) {
|
|
92
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
93
|
+
|
|
94
|
+
if (requestClose) {
|
|
95
|
+
requestClose();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
setAnchorEl(null);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
_react.default.useEffect(function () {
|
|
102
|
+
setAnchorEl(null);
|
|
103
|
+
}, [forceClose]);
|
|
104
|
+
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, Component ? /*#__PURE__*/_react.default.createElement("div", {
|
|
106
|
+
onClick: function onClick(e) {
|
|
107
|
+
return handleClick(e);
|
|
108
|
+
},
|
|
109
|
+
id: id,
|
|
110
|
+
className: "cbx-dropdown-component-container",
|
|
111
|
+
style: _objectSpread({}, styleComponent)
|
|
112
|
+
}, /*#__PURE__*/_react.default.createElement(Component, null)) : /*#__PURE__*/_react.default.createElement(_ButtonBasic.default, {
|
|
113
|
+
variant: variantButton,
|
|
114
|
+
type: type,
|
|
115
|
+
id: id,
|
|
116
|
+
onClick: function onClick(e) {
|
|
117
|
+
return handleClick(e);
|
|
118
|
+
},
|
|
119
|
+
icon: icon,
|
|
120
|
+
text: text,
|
|
121
|
+
stylesButton: _objectSpread({}, stylesButtonText),
|
|
122
|
+
sx: _objectSpread({}, sxButton)
|
|
123
|
+
}), /*#__PURE__*/_react.default.createElement(_Popover.default, _extends({
|
|
124
|
+
type: type,
|
|
125
|
+
PaperProps: {
|
|
126
|
+
style: _objectSpread({}, paperPropsStyles)
|
|
127
|
+
},
|
|
128
|
+
id: id,
|
|
129
|
+
open: Boolean(anchorEl),
|
|
130
|
+
anchorEl: anchorEl,
|
|
131
|
+
onClose: function onClose(e) {
|
|
132
|
+
return handleClose(e);
|
|
133
|
+
},
|
|
134
|
+
anchorOrigin: _objectSpread({
|
|
135
|
+
vertical: 'bottom',
|
|
136
|
+
horizontal: 'left'
|
|
137
|
+
}, anchorOrigin),
|
|
138
|
+
transformOrigin: transformOrigin,
|
|
139
|
+
sx: {
|
|
140
|
+
'& .MuiPopover-root .MuiButtonBase-root-MuiMenuItem-root:hover': {
|
|
141
|
+
background: 'var(--gray1)'
|
|
142
|
+
},
|
|
143
|
+
'& .MuiPopover-paper': {
|
|
144
|
+
boxShadow: '0px 4px 4px rgba(0, 0, 0, 0.25)'
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, props), /*#__PURE__*/_react.default.createElement("div", {
|
|
148
|
+
onClick: function onClick(e) {
|
|
149
|
+
return props.persistent ? function () {} : handleClose(e);
|
|
150
|
+
}
|
|
151
|
+
}, items)));
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
DropDown.displayName = "DropDown";
|
|
155
|
+
DropDown.propTypes = {
|
|
156
|
+
id: _propTypes.default.string,
|
|
157
|
+
text: _propTypes.default.node,
|
|
158
|
+
items: _propTypes.default.node,
|
|
159
|
+
type: _propTypes.default.string,
|
|
160
|
+
open: _propTypes.default.bool,
|
|
161
|
+
icon: _propTypes.default.node,
|
|
162
|
+
requestClose: _propTypes.default.func,
|
|
163
|
+
anchorOrigin: _propTypes.default.object,
|
|
164
|
+
paperPropsStyles: _propTypes.default.object,
|
|
165
|
+
transformOrigin: _propTypes.default.object,
|
|
166
|
+
styleComponent: _propTypes.default.object,
|
|
167
|
+
sxButton: _propTypes.default.object,
|
|
168
|
+
variantButton: _propTypes.default.string
|
|
169
|
+
};
|
|
170
|
+
DropDown.defaultProps = {
|
|
171
|
+
id: '',
|
|
172
|
+
text: null,
|
|
173
|
+
items: null,
|
|
174
|
+
type: '',
|
|
175
|
+
open: null,
|
|
176
|
+
icon: null,
|
|
177
|
+
requestClose: undefined,
|
|
178
|
+
anchorOrigin: undefined,
|
|
179
|
+
paperPropsStyles: undefined,
|
|
180
|
+
transformOrigin: undefined,
|
|
181
|
+
styleComponent: undefined,
|
|
182
|
+
sxButton: undefined,
|
|
183
|
+
variantButton: ''
|
|
184
|
+
};
|
|
185
|
+
var _default = DropDown;
|
|
186
|
+
exports.default = _default;
|