@pedidopago/ui 1.3.3 → 1.3.4
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/components/Alert/index.d.ts.map +1 -1
- package/dist/components/Alert/index.js +2 -3
- package/dist/components/Alert/styles.d.ts +1 -1
- package/dist/components/Alert/styles.d.ts.map +1 -1
- package/dist/components/Alert/styles.js +1 -3
- package/dist/components/Alert/types.d.ts +1 -1
- package/dist/components/Alert/types.d.ts.map +1 -1
- package/dist/components/Button/Button.test.js +1 -1
- package/dist/components/Button/index.d.ts +3 -4
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +14 -18
- package/dist/components/Button/styles.d.ts +3 -3
- package/dist/components/Button/styles.d.ts.map +1 -1
- package/dist/components/Button/styles.js +42 -43
- package/dist/components/Button/types.d.ts +10 -13
- package/dist/components/Button/types.d.ts.map +1 -1
- package/dist/components/Input/styles.d.ts.map +1 -1
- package/dist/components/Input/styles.js +2 -2
- package/dist/components/Modal/ModalExample.d.ts +4 -0
- package/dist/components/Modal/ModalExample.d.ts.map +1 -0
- package/dist/components/Modal/ModalExample.js +66 -0
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +11 -13
- package/dist/components/Modal/modal.test.js +11 -9
- package/dist/components/Pagination/index.d.ts.map +1 -1
- package/dist/components/Pagination/index.js +23 -10
- package/dist/components/Pagination/styles.js +3 -2
- package/dist/components/ReactPortal/index.d.ts +8 -0
- package/dist/components/ReactPortal/index.d.ts.map +1 -0
- package/dist/components/ReactPortal/index.js +58 -0
- package/dist/components/ReactPortal/reactPortal.test.d.ts +2 -0
- package/dist/components/ReactPortal/reactPortal.test.d.ts.map +1 -0
- package/dist/components/ReactPortal/reactPortal.test.js +26 -0
- package/dist/components/ReactPortal/utils/createWrapperAndApprendToBody.d.ts +2 -0
- package/dist/components/ReactPortal/utils/createWrapperAndApprendToBody.d.ts.map +1 -0
- package/dist/components/ReactPortal/utils/createWrapperAndApprendToBody.js +13 -0
- package/dist/components/Select/components/OptionsSelect/index.d.ts +4 -0
- package/dist/components/Select/components/OptionsSelect/index.d.ts.map +1 -0
- package/dist/components/Select/components/OptionsSelect/index.js +91 -0
- package/dist/components/Select/components/OptionsSelect/styles.d.ts +265 -0
- package/dist/components/Select/components/OptionsSelect/styles.d.ts.map +1 -0
- package/dist/components/Select/components/OptionsSelect/styles.js +32 -0
- package/dist/components/Select/components/OptionsSelect/types.d.ts +16 -0
- package/dist/components/Select/components/OptionsSelect/types.d.ts.map +1 -0
- package/dist/components/Select/components/OptionsSelect/types.js +1 -0
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +66 -37
- package/dist/components/Select/select.test.js +14 -0
- package/dist/components/Select/styles.d.ts +5 -7
- package/dist/components/Select/styles.d.ts.map +1 -1
- package/dist/components/Select/styles.js +26 -16
- package/dist/components/Select/types.d.ts +7 -2
- package/dist/components/Select/types.d.ts.map +1 -1
- package/dist/components/Table/styles.d.ts.map +1 -1
- package/dist/components/Table/styles.js +8 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/package.json +2 -1
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Modal =
|
|
7
|
-
|
|
8
|
-
var _styles = require("./styles");
|
|
6
|
+
exports.Modal = void 0;
|
|
9
7
|
|
|
10
8
|
var _react = require("react");
|
|
11
9
|
|
|
@@ -13,7 +11,9 @@ var _useDisableBodyScroll = require("../../shared/hooks/useDisableBodyScroll");
|
|
|
13
11
|
|
|
14
12
|
var _useKeyPress = require("../../shared/hooks/useKeyPress");
|
|
15
13
|
|
|
16
|
-
var
|
|
14
|
+
var _ReactPortal = require("../ReactPortal");
|
|
15
|
+
|
|
16
|
+
var _styles = require("./styles");
|
|
17
17
|
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
|
|
@@ -29,9 +29,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
29
29
|
|
|
30
30
|
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; }
|
|
31
31
|
|
|
32
|
-
function Modal(_ref) {
|
|
33
|
-
var _containerRef$current, _containerRef$current2;
|
|
34
|
-
|
|
32
|
+
var Modal = function Modal(_ref) {
|
|
35
33
|
var open = _ref.open,
|
|
36
34
|
_ref$left = _ref.left,
|
|
37
35
|
left = _ref$left === void 0 ? '50vw' : _ref$left,
|
|
@@ -56,9 +54,6 @@ function Modal(_ref) {
|
|
|
56
54
|
onClose = _ref.onClose,
|
|
57
55
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
58
56
|
|
|
59
|
-
var _useWindowSize = (0, _useWindowSize2.useWindowSize)(),
|
|
60
|
-
windowHeight = _useWindowSize.height;
|
|
61
|
-
|
|
62
57
|
var containerRef = (0, _react.useRef)(null);
|
|
63
58
|
(0, _useKeyPress.useKeyPress)('Escape', function () {
|
|
64
59
|
return onClose && onClose();
|
|
@@ -114,7 +109,8 @@ function Modal(_ref) {
|
|
|
114
109
|
return "translate(".concat(percentageX, "%, ").concat(percentageY, "%)");
|
|
115
110
|
}
|
|
116
111
|
|
|
117
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
112
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ReactPortal.ReactPortal, {
|
|
113
|
+
wrapperId: "portal-root",
|
|
118
114
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Overlay, {
|
|
119
115
|
style: {
|
|
120
116
|
opacity: open && !hideOverlay ? 0.1 : 0,
|
|
@@ -127,7 +123,7 @@ function Modal(_ref) {
|
|
|
127
123
|
ref: containerRef,
|
|
128
124
|
open: open,
|
|
129
125
|
maxWidth: typeof maxWidth === 'number' ? "".concat(maxWidth, "px") : maxWidth,
|
|
130
|
-
maxHeight:
|
|
126
|
+
maxHeight: typeof maxHeight === 'number' ? "".concat(maxHeight, "px") : maxHeight,
|
|
131
127
|
left: "calc(".concat(left, " + ").concat(offsetX, ")"),
|
|
132
128
|
top: "calc(".concat(top, " + ").concat(offsetY, ")"),
|
|
133
129
|
anchorTranslate: getAnchorTranslate(),
|
|
@@ -140,4 +136,6 @@ function Modal(_ref) {
|
|
|
140
136
|
}))
|
|
141
137
|
})]
|
|
142
138
|
});
|
|
143
|
-
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
exports.Modal = Modal;
|
|
@@ -17,12 +17,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
17
17
|
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; }
|
|
18
18
|
|
|
19
19
|
function setup(props) {
|
|
20
|
-
var
|
|
20
|
+
var _document$getElementB, _document$getElementB2;
|
|
21
|
+
|
|
22
|
+
(0, _testUtils.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeContext.PPUIThemeProvider, {
|
|
21
23
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Modal, _objectSpread({}, props))
|
|
22
24
|
}));
|
|
23
25
|
return {
|
|
24
|
-
overlay:
|
|
25
|
-
modal:
|
|
26
|
+
overlay: (_document$getElementB = document.getElementById('portal-root')) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.childNodes[0],
|
|
27
|
+
modal: (_document$getElementB2 = document.getElementById('portal-root')) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.childNodes[1]
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -98,7 +100,7 @@ describe('Modal', function () {
|
|
|
98
100
|
})
|
|
99
101
|
});
|
|
100
102
|
expect(modal.modal).toHaveStyle({
|
|
101
|
-
transform: 'translate(0%, -50%)
|
|
103
|
+
transform: 'translate(0%, -50%)'
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
106
|
it('should display modal with anchorX set to right', function () {
|
|
@@ -111,7 +113,7 @@ describe('Modal', function () {
|
|
|
111
113
|
})
|
|
112
114
|
});
|
|
113
115
|
expect(modal.modal).toHaveStyle({
|
|
114
|
-
transform: 'translate(-100%, -50%)
|
|
116
|
+
transform: 'translate(-100%, -50%)'
|
|
115
117
|
});
|
|
116
118
|
});
|
|
117
119
|
it('should display modal with anchorX set to center', function () {
|
|
@@ -124,7 +126,7 @@ describe('Modal', function () {
|
|
|
124
126
|
})
|
|
125
127
|
});
|
|
126
128
|
expect(modal.modal).toHaveStyle({
|
|
127
|
-
transform: 'translate(-50%, -50%)
|
|
129
|
+
transform: 'translate(-50%, -50%)'
|
|
128
130
|
});
|
|
129
131
|
});
|
|
130
132
|
it('should display modal with anchorY set to top', function () {
|
|
@@ -137,7 +139,7 @@ describe('Modal', function () {
|
|
|
137
139
|
})
|
|
138
140
|
});
|
|
139
141
|
expect(modal.modal).toHaveStyle({
|
|
140
|
-
transform: 'translate(-50%, 0%)
|
|
142
|
+
transform: 'translate(-50%, 0%)'
|
|
141
143
|
});
|
|
142
144
|
});
|
|
143
145
|
it('should display modal with anchorY set to bottom', function () {
|
|
@@ -150,7 +152,7 @@ describe('Modal', function () {
|
|
|
150
152
|
})
|
|
151
153
|
});
|
|
152
154
|
expect(modal.modal).toHaveStyle({
|
|
153
|
-
transform: 'translate(-50%, -100%)
|
|
155
|
+
transform: 'translate(-50%, -100%)'
|
|
154
156
|
});
|
|
155
157
|
});
|
|
156
158
|
it('should display modal with anchorY set to center', function () {
|
|
@@ -163,7 +165,7 @@ describe('Modal', function () {
|
|
|
163
165
|
})
|
|
164
166
|
});
|
|
165
167
|
expect(modal.modal).toHaveStyle({
|
|
166
|
-
transform: 'translate(-50%, -50%)
|
|
168
|
+
transform: 'translate(-50%, -50%)'
|
|
167
169
|
});
|
|
168
170
|
});
|
|
169
171
|
it('should display modal with maxWidth', function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/index.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,kBAAmC,EACnC,cAAgC,EAChC,UAAU,EACV,WAAW,EACX,IAAc,EACd,KAAiB,EACjB,OAAoB,EACpB,KAAK,GACN,EAAE,gBAAgB,sBA2HlB"}
|
|
@@ -11,11 +11,13 @@ var _Icon = _interopRequireDefault(require("../Icon"));
|
|
|
11
11
|
|
|
12
12
|
var _colorToGray = require("../../utils/colorToGray");
|
|
13
13
|
|
|
14
|
+
var _useColorMode2 = require("../../shared/theme/hooks/useColorMode");
|
|
15
|
+
|
|
14
16
|
var _usePagination = require("./hooks/usePagination");
|
|
15
17
|
|
|
16
18
|
var _styles = require("./styles");
|
|
17
19
|
|
|
18
|
-
var
|
|
20
|
+
var _theme = require("../../shared/theme");
|
|
19
21
|
|
|
20
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
23
|
|
|
@@ -70,7 +72,12 @@ function Pagination(_ref) {
|
|
|
70
72
|
nextButtonDisabled = _useState6[0],
|
|
71
73
|
setNextButtonDisabled = _useState6[1];
|
|
72
74
|
|
|
73
|
-
var
|
|
75
|
+
var _useTheme = (0, _theme.useTheme)(),
|
|
76
|
+
theme = _useTheme.theme;
|
|
77
|
+
|
|
78
|
+
var _useColorMode = (0, _useColorMode2.useColorMode)(),
|
|
79
|
+
colorMode = _useColorMode.colorMode;
|
|
80
|
+
|
|
74
81
|
(0, _react.useEffect)(function () {
|
|
75
82
|
if (activePage !== count) {
|
|
76
83
|
setNextButtonDisabled(false);
|
|
@@ -89,12 +96,18 @@ function Pagination(_ref) {
|
|
|
89
96
|
var themeColor = theme.colors.primary.default;
|
|
90
97
|
|
|
91
98
|
var _convertColor = (0, _colorToGray.convertColor)(color || themeColor),
|
|
92
|
-
|
|
99
|
+
neutral2 = _convertColor.neutral2,
|
|
100
|
+
neutral5 = _convertColor.neutral5;
|
|
101
|
+
|
|
102
|
+
var grayColorByTheme = {
|
|
103
|
+
dark: neutral5,
|
|
104
|
+
light: neutral2
|
|
105
|
+
}[colorMode] || neutral2;
|
|
93
106
|
|
|
94
|
-
var
|
|
95
|
-
h =
|
|
96
|
-
s =
|
|
97
|
-
l =
|
|
107
|
+
var _grayColorByTheme = _slicedToArray(grayColorByTheme, 3),
|
|
108
|
+
h = _grayColorByTheme[0],
|
|
109
|
+
s = _grayColorByTheme[1],
|
|
110
|
+
l = _grayColorByTheme[2];
|
|
98
111
|
|
|
99
112
|
var grayColor = "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)");
|
|
100
113
|
var saturationColor = "hsl(".concat(h, ", ", 12, "%, ", 39, "%)");
|
|
@@ -105,7 +118,7 @@ function Pagination(_ref) {
|
|
|
105
118
|
numberOfPageColor: numberOfPageColor,
|
|
106
119
|
themeColor: themeColor
|
|
107
120
|
};
|
|
108
|
-
}, [color]),
|
|
121
|
+
}, [color, theme]),
|
|
109
122
|
grayColor = _useMemo.grayColor,
|
|
110
123
|
numberOfPageColor = _useMemo.numberOfPageColor,
|
|
111
124
|
saturationColor = _useMemo.saturationColor,
|
|
@@ -179,7 +192,7 @@ function Pagination(_ref) {
|
|
|
179
192
|
disabled: previousButtonDisabled || isDisabled,
|
|
180
193
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
181
194
|
name: previousButtonIcon,
|
|
182
|
-
size:
|
|
195
|
+
size: 22
|
|
183
196
|
})
|
|
184
197
|
}), size === 'large' && LargeView(), size === 'small' && SmallView(), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.NextNavigationButton, {
|
|
185
198
|
shape: shape,
|
|
@@ -190,7 +203,7 @@ function Pagination(_ref) {
|
|
|
190
203
|
disabled: nextButtonDisabled || isDisabled,
|
|
191
204
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
192
205
|
name: nextButtonIcon,
|
|
193
|
-
size:
|
|
206
|
+
size: 22
|
|
194
207
|
})
|
|
195
208
|
})]
|
|
196
209
|
});
|
|
@@ -77,8 +77,9 @@ var NextNavigationButton = _styled.default.button(_templateObject16 || (_templat
|
|
|
77
77
|
exports.NextNavigationButton = NextNavigationButton;
|
|
78
78
|
|
|
79
79
|
var SmallPageInfo = _styled.default.span(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n font-weight: 600;\n display: block;\n min-width: 60px;\n font-size: 16px;\n line-height: 1.5;\n color: ", ";\n margin: 0 24px;\n"])), function (_ref7) {
|
|
80
|
-
var
|
|
81
|
-
|
|
80
|
+
var grayColor = _ref7.grayColor,
|
|
81
|
+
theme = _ref7.theme;
|
|
82
|
+
return grayColor || theme.colors.tertiary.default;
|
|
82
83
|
});
|
|
83
84
|
|
|
84
85
|
exports.SmallPageInfo = SmallPageInfo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface ReactPortalProps {
|
|
3
|
+
wrapperId: string;
|
|
4
|
+
children: ReactNode | ReactNode[] | JSX.Element | JSX.Element[];
|
|
5
|
+
}
|
|
6
|
+
export declare function ReactPortal({ children, wrapperId }: ReactPortalProps): import("react").ReactPortal | null;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ReactPortal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAI7D,UAAU,gBAAgB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACjE;AAED,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAyB,EAAE,EAAE,gBAAgB,sCAsBpF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ReactPortal = ReactPortal;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _reactDom = require("react-dom");
|
|
11
|
+
|
|
12
|
+
var _createWrapperAndApprendToBody = require("./utils/createWrapperAndApprendToBody");
|
|
13
|
+
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
+
|
|
18
|
+
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."); }
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
+
|
|
28
|
+
function ReactPortal(_ref) {
|
|
29
|
+
var children = _ref.children,
|
|
30
|
+
_ref$wrapperId = _ref.wrapperId,
|
|
31
|
+
wrapperId = _ref$wrapperId === void 0 ? 'portal-root' : _ref$wrapperId;
|
|
32
|
+
|
|
33
|
+
var _useState = (0, _react.useState)(null),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
wrapperElement = _useState2[0],
|
|
36
|
+
setWrapperElement = _useState2[1];
|
|
37
|
+
|
|
38
|
+
(0, _react.useLayoutEffect)(function () {
|
|
39
|
+
var element = document.getElementById(wrapperId);
|
|
40
|
+
var systemCreated = false;
|
|
41
|
+
|
|
42
|
+
if (!element) {
|
|
43
|
+
systemCreated = true;
|
|
44
|
+
element = (0, _createWrapperAndApprendToBody.createWrapperAndAppendToBody)(wrapperId);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setWrapperElement(element);
|
|
48
|
+
return function () {
|
|
49
|
+
if (systemCreated && element.parentNode) {
|
|
50
|
+
element.parentNode.removeChild(element);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}, [wrapperId]);
|
|
54
|
+
if (wrapperElement === null) return null;
|
|
55
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
56
|
+
children: children
|
|
57
|
+
}), wrapperElement);
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactPortal.test.d.ts","sourceRoot":"","sources":["../../../src/components/ReactPortal/reactPortal.test.tsx"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _testUtils = require("../../shared/tests/test-utils");
|
|
4
|
+
|
|
5
|
+
var _ = require(".");
|
|
6
|
+
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
|
|
11
|
+
function setup() {
|
|
12
|
+
(0, _testUtils.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_.ReactPortal, {
|
|
13
|
+
wrapperId: "portal-test",
|
|
14
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
15
|
+
children: "Teste"
|
|
16
|
+
})
|
|
17
|
+
}));
|
|
18
|
+
return document.body.querySelector('#portal-test');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('ReactPortal test', function () {
|
|
22
|
+
it('Should render a div inside body', function () {
|
|
23
|
+
var divPortal = setup();
|
|
24
|
+
expect(divPortal).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWrapperAndApprendToBody.d.ts","sourceRoot":"","sources":["../../../../src/components/ReactPortal/utils/createWrapperAndApprendToBody.ts"],"names":[],"mappings":"AAAA,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,kBAK7D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createWrapperAndAppendToBody = createWrapperAndAppendToBody;
|
|
7
|
+
|
|
8
|
+
function createWrapperAndAppendToBody(wrapperId) {
|
|
9
|
+
var wrapperElement = document.createElement('div');
|
|
10
|
+
wrapperElement.setAttribute('id', wrapperId);
|
|
11
|
+
document.body.appendChild(wrapperElement);
|
|
12
|
+
return wrapperElement;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Select/components/OptionsSelect/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,aAAa,+GAqDzB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OptionsSelect = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _useDisableBodyScroll = require("../../../../shared/hooks/useDisableBodyScroll");
|
|
11
|
+
|
|
12
|
+
var _useWindowSize2 = require("../../../../shared/hooks/useWindowSize");
|
|
13
|
+
|
|
14
|
+
var _styles = require("./styles");
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
+
|
|
20
|
+
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."); }
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
+
|
|
30
|
+
var OptionsSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
31
|
+
var open = _ref.open,
|
|
32
|
+
_ref$left = _ref.left,
|
|
33
|
+
left = _ref$left === void 0 ? '50vw' : _ref$left,
|
|
34
|
+
_ref$top = _ref.top,
|
|
35
|
+
top = _ref$top === void 0 ? '' : _ref$top,
|
|
36
|
+
_ref$offsetX = _ref.offsetX,
|
|
37
|
+
offsetX = _ref$offsetX === void 0 ? '0px' : _ref$offsetX,
|
|
38
|
+
_ref$disableScrollOnO = _ref.disableScrollOnOpen,
|
|
39
|
+
disableScrollOnOpen = _ref$disableScrollOnO === void 0 ? true : _ref$disableScrollOnO,
|
|
40
|
+
maxWidth = _ref.maxWidth,
|
|
41
|
+
children = _ref.children;
|
|
42
|
+
|
|
43
|
+
var _useWindowSize = (0, _useWindowSize2.useWindowSize)(),
|
|
44
|
+
windowHeight = _useWindowSize.height;
|
|
45
|
+
|
|
46
|
+
var optionsContainerRef = (0, _react.useRef)(null);
|
|
47
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
|
48
|
+
return optionsContainerRef.current;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
var _useState = (0, _react.useState)(function () {
|
|
52
|
+
var _optionsContainerRef$, _optionsContainerRef$2;
|
|
53
|
+
|
|
54
|
+
if (windowHeight - (((_optionsContainerRef$ = optionsContainerRef.current) === null || _optionsContainerRef$ === void 0 ? void 0 : (_optionsContainerRef$2 = _optionsContainerRef$.getBoundingClientRect()) === null || _optionsContainerRef$2 === void 0 ? void 0 : _optionsContainerRef$2.y) || 0) > 360) {
|
|
55
|
+
return '360px';
|
|
56
|
+
} else {
|
|
57
|
+
var _optionsContainerRef$3, _optionsContainerRef$4;
|
|
58
|
+
|
|
59
|
+
return "".concat(windowHeight - (((_optionsContainerRef$3 = optionsContainerRef.current) === null || _optionsContainerRef$3 === void 0 ? void 0 : (_optionsContainerRef$4 = _optionsContainerRef$3.getBoundingClientRect()) === null || _optionsContainerRef$4 === void 0 ? void 0 : _optionsContainerRef$4.y) || 0), "px");
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
positionElement = _useState2[0],
|
|
64
|
+
setPositionElement = _useState2[1];
|
|
65
|
+
|
|
66
|
+
(0, _react.useEffect)(function () {
|
|
67
|
+
setPositionElement(function () {
|
|
68
|
+
var _optionsContainerRef$5, _optionsContainerRef$6;
|
|
69
|
+
|
|
70
|
+
if (windowHeight - (((_optionsContainerRef$5 = optionsContainerRef.current) === null || _optionsContainerRef$5 === void 0 ? void 0 : (_optionsContainerRef$6 = _optionsContainerRef$5.getBoundingClientRect()) === null || _optionsContainerRef$6 === void 0 ? void 0 : _optionsContainerRef$6.y) || 0) > 360) {
|
|
71
|
+
return '360px';
|
|
72
|
+
} else {
|
|
73
|
+
var _optionsContainerRef$7, _optionsContainerRef$8;
|
|
74
|
+
|
|
75
|
+
return "".concat(windowHeight - (((_optionsContainerRef$7 = optionsContainerRef.current) === null || _optionsContainerRef$7 === void 0 ? void 0 : (_optionsContainerRef$8 = _optionsContainerRef$7.getBoundingClientRect()) === null || _optionsContainerRef$8 === void 0 ? void 0 : _optionsContainerRef$8.y) || 0), "px");
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
(0, _useDisableBodyScroll.useDisableBodyScroll)(open && disableScrollOnOpen);
|
|
80
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.OptionsContainer, {
|
|
81
|
+
ref: optionsContainerRef,
|
|
82
|
+
open: open,
|
|
83
|
+
maxWidth: typeof maxWidth === 'number' ? "".concat(maxWidth, "px") : maxWidth,
|
|
84
|
+
maxHeight: positionElement,
|
|
85
|
+
left: "calc(".concat(left, " + ").concat(offsetX, ")"),
|
|
86
|
+
top: top,
|
|
87
|
+
children: children
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
exports.OptionsSelect = OptionsSelect;
|
|
91
|
+
OptionsSelect.displayName = 'OptionsSelect';
|