@pedidopago/ui 1.3.21 → 1.3.22
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/README.md +93 -93
- package/dist/components/DateInput/index.js +1 -1
- package/dist/components/Modal/ModalExample.d.ts +4 -0
- package/dist/components/Modal/ModalExample.d.ts.map +1 -1
- package/dist/components/Modal/ModalExample.js +26 -4
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/Select/components/OptionsSelect/index.js +1 -1
- package/dist/components/Toast/contexts/ToastProvider.js +2 -3
- package/dist/shared/hooks/useDisableBodyScroll.d.ts +1 -1
- package/dist/shared/hooks/useDisableBodyScroll.d.ts.map +1 -1
- package/dist/shared/hooks/useDisableBodyScroll.js +34 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
<h1 align="center">
|
|
2
|
-
<img src="https://user-images.githubusercontent.com/75874462/145101826-9244932f-7072-4727-9124-8c26620ad786.png" alt="Logo"/>
|
|
3
|
-
<br/>
|
|
4
|
-
</h1>
|
|
5
|
-
|
|
6
|
-
<div align="center">
|
|
7
|
-
<img src="https://img.shields.io/badge/React-v17.0.2-1DD195?style=for-the-badge&logo=react&link=http://google.com" />
|
|
8
|
-
<img src="https://img.shields.io/badge/Emotion-v11.3.0-1DD195?style=for-the-badge&logo=styled-components" />
|
|
9
|
-
<img src="https://img.shields.io/badge/Storybook-v6.3.7-1DD195?style=for-the-badge&logo=storybook" />
|
|
10
|
-
<img src="https://img.shields.io/badge/React Testing Library-v11.1.0-1DD195?style=for-the-badge&logo=testinglibrary" />
|
|
11
|
-
<img src="https://img.shields.io/badge/FrameMotion-v4.1.17-1DD195?style=for-the-badge&logo=framer" />
|
|
12
|
-
<img src="https://img.shields.io/badge/Typescript-v4.3.5-1DD195?style=for-the-badge&logo=typescript" />
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
<p align="center">
|
|
16
|
-
<a href="#iniciar-">Iniciar </a> |
|
|
17
|
-
<a href="#estrutura-de-codigo-">Estrutura de codigo </a> |
|
|
18
|
-
<a href="#roadmap-">Roadmap </a> |
|
|
19
|
-
<a href="#contribuir-">Contribuir </a>
|
|
20
|
-
</p>
|
|
21
|
-
|
|
22
|
-
## Iniciar 🚀
|
|
23
|
-
|
|
24
|
-
### Requisitos:
|
|
25
|
-
- [Nodejs](https://github.com/nodejs/node)
|
|
26
|
-
- [Yarn](https://github.com/yarnpkg/yarn)
|
|
27
|
-
|
|
28
|
-
### Instalação:
|
|
29
|
-
|
|
30
|
-
1. Clone o Repositorio
|
|
31
|
-
|
|
32
|
-
``` bash
|
|
33
|
-
git clone git@github.com:pedidopago/pedidopago-ui.git
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
2. Instalar as dependencias:
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
yarn
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Executar o projeto localmente:
|
|
43
|
-
|
|
44
|
-
Iniciar o projeto com o storybook:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
yarn storybook
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Para executar os testes use o script:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
yarn test
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
> Para mais detalhes dos scripts considere consultar o package.json na raiz do projeto.
|
|
57
|
-
|
|
58
|
-
#### 📌 Ira precisar tambem das variaveis de ambiente `CHROMATIC_PROJECT_TOKEN` e `SKIP_PREFLIGHT_CHECK`.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## Estrutura de codigo
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
> Ao entrar no projeto sempre entre em `packages/pedidopago-ui` para trabalhar/executar os scripts
|
|
66
|
-
|
|
67
|
-
## Roadmap 🌐
|
|
68
|
-
|
|
69
|
-
- [ ] Mudar a estrutura de pastas
|
|
70
|
-
|
|
71
|
-
- [ ] Sessão de novos componentes
|
|
72
|
-
|
|
73
|
-
- [ ] Atualização de pacotes
|
|
74
|
-
|
|
75
|
-
- [ ] Incrementação dos testes
|
|
76
|
-
|
|
77
|
-
- [ ] Melhorias na documentação
|
|
78
|
-
|
|
79
|
-
- [ ] Adicionar license
|
|
80
|
-
|
|
81
|
-
## Contribuir 💡
|
|
82
|
-
|
|
83
|
-
1. Crie uma branch apartir da **`dev`** com o prefixo **`lib`-[número da issue]-[nome da issue]**.
|
|
84
|
-
exemplo:
|
|
85
|
-
```bash
|
|
86
|
-
git checkout -b lib-99-buttom
|
|
87
|
-
```
|
|
88
|
-
2. Desenvolver
|
|
89
|
-
|
|
90
|
-
3. Criar a pull request
|
|
91
|
-
- Número da issue no inicio da pr.
|
|
92
|
-
- Descritivo com pontos importantes do que foi feito.
|
|
93
|
-
- Print dos tests no terminal e video de apresentação que pode ser feito via [loom](https://www.loom.com/).
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img src="https://user-images.githubusercontent.com/75874462/145101826-9244932f-7072-4727-9124-8c26620ad786.png" alt="Logo"/>
|
|
3
|
+
<br/>
|
|
4
|
+
</h1>
|
|
5
|
+
|
|
6
|
+
<div align="center">
|
|
7
|
+
<img src="https://img.shields.io/badge/React-v17.0.2-1DD195?style=for-the-badge&logo=react&link=http://google.com" />
|
|
8
|
+
<img src="https://img.shields.io/badge/Emotion-v11.3.0-1DD195?style=for-the-badge&logo=styled-components" />
|
|
9
|
+
<img src="https://img.shields.io/badge/Storybook-v6.3.7-1DD195?style=for-the-badge&logo=storybook" />
|
|
10
|
+
<img src="https://img.shields.io/badge/React Testing Library-v11.1.0-1DD195?style=for-the-badge&logo=testinglibrary" />
|
|
11
|
+
<img src="https://img.shields.io/badge/FrameMotion-v4.1.17-1DD195?style=for-the-badge&logo=framer" />
|
|
12
|
+
<img src="https://img.shields.io/badge/Typescript-v4.3.5-1DD195?style=for-the-badge&logo=typescript" />
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="#iniciar-">Iniciar </a> |
|
|
17
|
+
<a href="#estrutura-de-codigo-">Estrutura de codigo </a> |
|
|
18
|
+
<a href="#roadmap-">Roadmap </a> |
|
|
19
|
+
<a href="#contribuir-">Contribuir </a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
## Iniciar 🚀
|
|
23
|
+
|
|
24
|
+
### Requisitos:
|
|
25
|
+
- [Nodejs](https://github.com/nodejs/node)
|
|
26
|
+
- [Yarn](https://github.com/yarnpkg/yarn)
|
|
27
|
+
|
|
28
|
+
### Instalação:
|
|
29
|
+
|
|
30
|
+
1. Clone o Repositorio
|
|
31
|
+
|
|
32
|
+
``` bash
|
|
33
|
+
git clone git@github.com:pedidopago/pedidopago-ui.git
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2. Instalar as dependencias:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
yarn
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Executar o projeto localmente:
|
|
43
|
+
|
|
44
|
+
Iniciar o projeto com o storybook:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
yarn storybook
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Para executar os testes use o script:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
yarn test
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> Para mais detalhes dos scripts considere consultar o package.json na raiz do projeto.
|
|
57
|
+
|
|
58
|
+
#### 📌 Ira precisar tambem das variaveis de ambiente `CHROMATIC_PROJECT_TOKEN` e `SKIP_PREFLIGHT_CHECK`.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Estrutura de codigo
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
> Ao entrar no projeto sempre entre em `packages/pedidopago-ui` para trabalhar/executar os scripts
|
|
66
|
+
|
|
67
|
+
## Roadmap 🌐
|
|
68
|
+
|
|
69
|
+
- [ ] Mudar a estrutura de pastas
|
|
70
|
+
|
|
71
|
+
- [ ] Sessão de novos componentes
|
|
72
|
+
|
|
73
|
+
- [ ] Atualização de pacotes
|
|
74
|
+
|
|
75
|
+
- [ ] Incrementação dos testes
|
|
76
|
+
|
|
77
|
+
- [ ] Melhorias na documentação
|
|
78
|
+
|
|
79
|
+
- [ ] Adicionar license
|
|
80
|
+
|
|
81
|
+
## Contribuir 💡
|
|
82
|
+
|
|
83
|
+
1. Crie uma branch apartir da **`dev`** com o prefixo **`lib`-[número da issue]-[nome da issue]**.
|
|
84
|
+
exemplo:
|
|
85
|
+
```bash
|
|
86
|
+
git checkout -b lib-99-buttom
|
|
87
|
+
```
|
|
88
|
+
2. Desenvolver
|
|
89
|
+
|
|
90
|
+
3. Criar a pull request
|
|
91
|
+
- Número da issue no inicio da pr.
|
|
92
|
+
- Descritivo com pontos importantes do que foi feito.
|
|
93
|
+
- Print dos tests no terminal e video de apresentação que pode ser feito via [loom](https://www.loom.com/).
|
|
@@ -93,7 +93,7 @@ function DateInput(_ref) {
|
|
|
93
93
|
(0, _react.useEffect)(function () {
|
|
94
94
|
setCurrentValue(value);
|
|
95
95
|
}, [value]);
|
|
96
|
-
(0, _useDisableBodyScroll.useDisableBodyScroll)(datePickerOpen);
|
|
96
|
+
(0, _useDisableBodyScroll.useDisableBodyScroll)(datePickerOpen, 'child_element');
|
|
97
97
|
|
|
98
98
|
function handleRepositionModal() {
|
|
99
99
|
var _containerRef$current2;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ModalProps } from './types';
|
|
3
|
+
export declare const SelectOptionsPagination: {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
3
7
|
export declare function ModalExample(props: ModalProps): JSX.Element;
|
|
4
8
|
//# sourceMappingURL=ModalExample.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalExample.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/ModalExample.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ModalExample.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/ModalExample.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,uBAAuB;;;GAGnC,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,eA8B7C"}
|
|
@@ -4,14 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ModalExample = ModalExample;
|
|
7
|
+
exports.SelectOptionsPagination = void 0;
|
|
7
8
|
|
|
8
9
|
var _react = require("react");
|
|
9
10
|
|
|
10
11
|
var _ = require(".");
|
|
11
12
|
|
|
13
|
+
var _Flex = _interopRequireDefault(require("../Flex"));
|
|
14
|
+
|
|
12
15
|
var _Button = _interopRequireDefault(require("../Button"));
|
|
13
16
|
|
|
14
|
-
var
|
|
17
|
+
var _Select = _interopRequireDefault(require("../Select"));
|
|
18
|
+
|
|
19
|
+
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
15
20
|
|
|
16
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
22
|
|
|
@@ -35,6 +40,15 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
35
40
|
|
|
36
41
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
37
42
|
|
|
43
|
+
var SelectOptionsPagination = [{
|
|
44
|
+
label: 'Opcao01',
|
|
45
|
+
value: '1'
|
|
46
|
+
}, {
|
|
47
|
+
label: 'Opcao02',
|
|
48
|
+
value: '2'
|
|
49
|
+
}];
|
|
50
|
+
exports.SelectOptionsPagination = SelectOptionsPagination;
|
|
51
|
+
|
|
38
52
|
function ModalExample(props) {
|
|
39
53
|
var _useState = (0, _react.useState)(false),
|
|
40
54
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -53,13 +67,21 @@ function ModalExample(props) {
|
|
|
53
67
|
maxWidth: props.maxWidth || '350px',
|
|
54
68
|
open: props.open || modalOpen,
|
|
55
69
|
onClose: handleModal,
|
|
56
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Flex.default, {
|
|
71
|
+
direction: "column",
|
|
57
72
|
justifyContent: "center",
|
|
58
73
|
alignItems: "center",
|
|
59
74
|
style: {
|
|
60
|
-
height: '350px'
|
|
75
|
+
height: '350px',
|
|
76
|
+
padding: '1em'
|
|
61
77
|
},
|
|
62
|
-
children:
|
|
78
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
79
|
+
children: ["Eu sou um modal, com um select :", ")"]
|
|
80
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
|
|
81
|
+
placeholder: "Selecione uma op\xE7\xE3o",
|
|
82
|
+
options: SelectOptionsPagination,
|
|
83
|
+
sizeSelect: "md"
|
|
84
|
+
})]
|
|
63
85
|
})
|
|
64
86
|
}))]
|
|
65
87
|
});
|
|
@@ -58,7 +58,7 @@ var Modal = function Modal(_ref) {
|
|
|
58
58
|
(0, _useKeyPress.useKeyPress)('Escape', function () {
|
|
59
59
|
return onClose && onClose();
|
|
60
60
|
});
|
|
61
|
-
(0, _useDisableBodyScroll.useDisableBodyScroll)(open && disableScrollOnOpen);
|
|
61
|
+
(0, _useDisableBodyScroll.useDisableBodyScroll)(open && disableScrollOnOpen, 'modal');
|
|
62
62
|
|
|
63
63
|
function getAnchorTranslate() {
|
|
64
64
|
var percentageX = 0;
|
|
@@ -76,7 +76,7 @@ var OptionsSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
-
(0, _useDisableBodyScroll.useDisableBodyScroll)(open && disableScrollOnOpen);
|
|
79
|
+
(0, _useDisableBodyScroll.useDisableBodyScroll)(open && disableScrollOnOpen, 'child_element');
|
|
80
80
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.OptionsContainer, {
|
|
81
81
|
ref: optionsContainerRef,
|
|
82
82
|
open: open,
|
|
@@ -50,7 +50,7 @@ var ToastProvider = function ToastProvider(_ref) {
|
|
|
50
50
|
toasts = _useState2[0],
|
|
51
51
|
setToasts = _useState2[1];
|
|
52
52
|
|
|
53
|
-
var addToast = function
|
|
53
|
+
var addToast = (0, _react.useCallback)(function (options) {
|
|
54
54
|
var toastOptions = {
|
|
55
55
|
config: _objectSpread(_objectSpread({}, options), {}, {
|
|
56
56
|
icon: options.icon || 'info',
|
|
@@ -62,8 +62,7 @@ var ToastProvider = function ToastProvider(_ref) {
|
|
|
62
62
|
id: Math.random().toString(36).substring(2, 9)
|
|
63
63
|
};
|
|
64
64
|
setToasts([].concat(_toConsumableArray(toasts), [toastOptions]));
|
|
65
|
-
};
|
|
66
|
-
|
|
65
|
+
}, []);
|
|
67
66
|
var remoteToast = (0, _react.useCallback)(function (id) {
|
|
68
67
|
setToasts(function (prevState) {
|
|
69
68
|
var _filterToast$0$config, _filterToast$0$config2;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const useDisableBodyScroll: (disable: boolean) => void;
|
|
1
|
+
export declare const useDisableBodyScroll: (disable: boolean, type?: 'modal' | 'child_element') => void;
|
|
2
2
|
//# sourceMappingURL=useDisableBodyScroll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDisableBodyScroll.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useDisableBodyScroll.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDisableBodyScroll.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useDisableBodyScroll.tsx"],"names":[],"mappings":"AAaA,eAAO,MAAM,oBAAoB,YACtB,OAAO,SACV,OAAO,GAAG,eAAe,SAwBhC,CAAC"}
|
|
@@ -7,15 +7,42 @@ exports.useDisableBodyScroll = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
10
|
+
function disableBodyOverflow() {
|
|
11
|
+
var scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
12
|
+
document.body.style.paddingRight = "".concat(scrollBarWidth, "px");
|
|
13
|
+
document.body.style.overflow = 'hidden';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function enableBodyOverflow() {
|
|
17
|
+
document.body.style.overflow = '';
|
|
18
|
+
document.body.style.paddingRight = '';
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
var useDisableBodyScroll = function useDisableBodyScroll(disable) {
|
|
22
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'child_element';
|
|
11
23
|
(0, _react.useEffect)(function () {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
document.body.
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
// disable body scroll when type modal:
|
|
25
|
+
if (disable && type === 'modal') {
|
|
26
|
+
document.body.setAttribute('data-modal-open', 'true');
|
|
27
|
+
return disableBodyOverflow();
|
|
28
|
+
} // enable body scroll when type modal:
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if (!disable && type === 'modal') {
|
|
32
|
+
document.body.setAttribute('data-modal-open', 'false');
|
|
33
|
+
return enableBodyOverflow();
|
|
34
|
+
} // disable body scroll when type child_element:
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if (disable && type === 'child_element') {
|
|
38
|
+
if (document.body.getAttribute('data-modal-open') === 'true') return;
|
|
39
|
+
return disableBodyOverflow();
|
|
40
|
+
} // enable body scroll when type child_element:
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if (!disable && type === 'child_element') {
|
|
44
|
+
if (document.body.getAttribute('data-modal-open') === 'true') return;
|
|
45
|
+
return enableBodyOverflow();
|
|
19
46
|
}
|
|
20
47
|
}, [disable]);
|
|
21
48
|
};
|