@ttoss/components 1.15.2 → 1.18.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/README.md +5 -5
- package/dist/esm/index.js +57 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +58 -2
- package/package.json +9 -4
- package/src/components/Modal/Modal.docs.md +56 -0
- package/src/components/Modal/Modal.tsx +62 -0
- package/src/index.spec.tsx +6 -3
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# @ttoss/components
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## About
|
|
4
4
|
|
|
5
|
-
<strong>@ttoss/components</strong> is a set of React components that you can use to build your apps.
|
|
5
|
+
<strong>@ttoss/components</strong> is a set of React components that you can use to build your apps using ttoss technologies.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Getting Started
|
|
8
8
|
|
|
9
9
|
### Install @ttoss/components
|
|
10
10
|
|
|
11
11
|
```shell
|
|
12
|
-
$ yarn add @ttoss/components
|
|
12
|
+
$ yarn add @ttoss/{components,ui}
|
|
13
13
|
# or
|
|
14
|
-
$ npm install @ttoss/components
|
|
14
|
+
$ npm install @ttoss/{components,ui}
|
|
15
15
|
```
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
// tsup.inject.js
|
|
2
4
|
import * as React from "react";
|
|
3
5
|
|
|
@@ -58,6 +60,60 @@ var InstallPwa = () => {
|
|
|
58
60
|
onInstall
|
|
59
61
|
});
|
|
60
62
|
};
|
|
63
|
+
|
|
64
|
+
// src/components/Modal/Modal.tsx
|
|
65
|
+
import { useResponsiveValue, useTheme } from "@ttoss/ui";
|
|
66
|
+
import ReactModal from "react-modal";
|
|
67
|
+
ReactModal.defaultStyles = {
|
|
68
|
+
overlay: {},
|
|
69
|
+
content: {}
|
|
70
|
+
};
|
|
71
|
+
var Modal = (props) => {
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
73
|
+
const { theme } = useTheme();
|
|
74
|
+
const padding = useResponsiveValue([
|
|
75
|
+
(_a = theme.space) == null ? void 0 : _a[2],
|
|
76
|
+
(_b = theme.space) == null ? void 0 : _b[3],
|
|
77
|
+
(_c = theme.space) == null ? void 0 : _c[4]
|
|
78
|
+
]) || 0;
|
|
79
|
+
const style = {
|
|
80
|
+
overlay: {
|
|
81
|
+
position: "fixed",
|
|
82
|
+
top: 0,
|
|
83
|
+
left: 0,
|
|
84
|
+
right: 0,
|
|
85
|
+
bottom: 0,
|
|
86
|
+
backgroundColor: "rgba(255, 255, 255, 0.5)",
|
|
87
|
+
display: "flex",
|
|
88
|
+
justifyContent: "center",
|
|
89
|
+
alignItems: "center",
|
|
90
|
+
padding,
|
|
91
|
+
...(_d = props.style) == null ? void 0 : _d.overlay
|
|
92
|
+
},
|
|
93
|
+
content: {
|
|
94
|
+
background: ((_f = (_e = theme.rawColors) == null ? void 0 : _e.background) == null ? void 0 : _f.toString()) || "#fff",
|
|
95
|
+
padding,
|
|
96
|
+
WebkitOverflowScrolling: "touch",
|
|
97
|
+
overflow: "auto",
|
|
98
|
+
position: "relative",
|
|
99
|
+
top: "0px",
|
|
100
|
+
left: "0px",
|
|
101
|
+
right: "0px",
|
|
102
|
+
bottom: "0px",
|
|
103
|
+
border: "1px solid #ccc",
|
|
104
|
+
display: "flex",
|
|
105
|
+
flexDirection: "column",
|
|
106
|
+
alignItems: "center",
|
|
107
|
+
...(_g = props.style) == null ? void 0 : _g.content
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return /* @__PURE__ */ React.createElement(ReactModal, {
|
|
111
|
+
...props,
|
|
112
|
+
style
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
Modal.setAppElement = ReactModal.setAppElement;
|
|
61
116
|
export {
|
|
62
|
-
InstallPwa
|
|
117
|
+
InstallPwa,
|
|
118
|
+
Modal
|
|
63
119
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import ReactModal from 'react-modal';
|
|
2
|
+
|
|
1
3
|
declare const InstallPwa: () => JSX.Element | null;
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
declare type ModalProps = ReactModal.Props;
|
|
6
|
+
declare const Modal: {
|
|
7
|
+
(props: ModalProps): JSX.Element;
|
|
8
|
+
setAppElement: typeof ReactModal.setAppElement;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { InstallPwa, Modal, ModalProps };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -22,7 +23,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
23
|
// src/index.ts
|
|
23
24
|
var src_exports = {};
|
|
24
25
|
__export(src_exports, {
|
|
25
|
-
InstallPwa: () => InstallPwa
|
|
26
|
+
InstallPwa: () => InstallPwa,
|
|
27
|
+
Modal: () => Modal
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(src_exports);
|
|
28
30
|
|
|
@@ -86,7 +88,61 @@ var InstallPwa = () => {
|
|
|
86
88
|
onInstall
|
|
87
89
|
});
|
|
88
90
|
};
|
|
91
|
+
|
|
92
|
+
// src/components/Modal/Modal.tsx
|
|
93
|
+
var import_ui2 = require("@ttoss/ui");
|
|
94
|
+
var import_react_modal = __toESM(require("react-modal"));
|
|
95
|
+
import_react_modal.default.defaultStyles = {
|
|
96
|
+
overlay: {},
|
|
97
|
+
content: {}
|
|
98
|
+
};
|
|
99
|
+
var Modal = (props) => {
|
|
100
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
101
|
+
const { theme } = (0, import_ui2.useTheme)();
|
|
102
|
+
const padding = (0, import_ui2.useResponsiveValue)([
|
|
103
|
+
(_a = theme.space) == null ? void 0 : _a[2],
|
|
104
|
+
(_b = theme.space) == null ? void 0 : _b[3],
|
|
105
|
+
(_c = theme.space) == null ? void 0 : _c[4]
|
|
106
|
+
]) || 0;
|
|
107
|
+
const style = {
|
|
108
|
+
overlay: {
|
|
109
|
+
position: "fixed",
|
|
110
|
+
top: 0,
|
|
111
|
+
left: 0,
|
|
112
|
+
right: 0,
|
|
113
|
+
bottom: 0,
|
|
114
|
+
backgroundColor: "rgba(255, 255, 255, 0.5)",
|
|
115
|
+
display: "flex",
|
|
116
|
+
justifyContent: "center",
|
|
117
|
+
alignItems: "center",
|
|
118
|
+
padding,
|
|
119
|
+
...(_d = props.style) == null ? void 0 : _d.overlay
|
|
120
|
+
},
|
|
121
|
+
content: {
|
|
122
|
+
background: ((_f = (_e = theme.rawColors) == null ? void 0 : _e.background) == null ? void 0 : _f.toString()) || "#fff",
|
|
123
|
+
padding,
|
|
124
|
+
WebkitOverflowScrolling: "touch",
|
|
125
|
+
overflow: "auto",
|
|
126
|
+
position: "relative",
|
|
127
|
+
top: "0px",
|
|
128
|
+
left: "0px",
|
|
129
|
+
right: "0px",
|
|
130
|
+
bottom: "0px",
|
|
131
|
+
border: "1px solid #ccc",
|
|
132
|
+
display: "flex",
|
|
133
|
+
flexDirection: "column",
|
|
134
|
+
alignItems: "center",
|
|
135
|
+
...(_g = props.style) == null ? void 0 : _g.content
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ React.createElement(import_react_modal.default, {
|
|
139
|
+
...props,
|
|
140
|
+
style
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
Modal.setAppElement = import_react_modal.default.setAppElement;
|
|
89
144
|
// Annotate the CommonJS export names for ESM import in node:
|
|
90
145
|
0 && (module.exports = {
|
|
91
|
-
InstallPwa
|
|
146
|
+
InstallPwa,
|
|
147
|
+
Modal
|
|
92
148
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "React components.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,14 +31,19 @@
|
|
|
31
31
|
"dev": "yarn workspace @docs/storybook run dev"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@
|
|
34
|
+
"@types/react-modal": "^3.13.1",
|
|
35
|
+
"react-modal": "^3.15.1"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
38
|
+
"@ttoss/ui": "^1.16.5",
|
|
37
39
|
"react": ">=16.8.0"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"@ttoss/config": "^1.15.2",
|
|
41
|
-
"@ttoss/test-utils": "^1.15.2"
|
|
43
|
+
"@ttoss/test-utils": "^1.15.2",
|
|
44
|
+
"@ttoss/ui": "^1.18.0",
|
|
45
|
+
"@types/jest": "^28.1.5",
|
|
46
|
+
"jest": "^28.1.3"
|
|
42
47
|
},
|
|
43
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "38d76661c6302b6447804375cd0193be9056b446"
|
|
44
49
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Modal
|
|
2
|
+
|
|
3
|
+
This components uses [react-modal package](http://reactcommunity.org/react-modal) as a base and apply [@ttoss/ui](/docs/modules/packages/ui/) styles.
|
|
4
|
+
|
|
5
|
+
## Storybook
|
|
6
|
+
|
|
7
|
+
[Modal Stories](https://storybook.ttoss.dev/?path=/story/components-modal)
|
|
8
|
+
|
|
9
|
+
## Example
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
import { Modal } from "@ttoss/components";
|
|
13
|
+
import { Box, Flex, Text } from "@ttoss/ui";
|
|
14
|
+
|
|
15
|
+
const Component = () => {
|
|
16
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Box>
|
|
20
|
+
<Modal
|
|
21
|
+
isOpen={isOpen}
|
|
22
|
+
onRequestClose={() => {
|
|
23
|
+
setIsOpen(false);
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<Flex
|
|
27
|
+
sx={{
|
|
28
|
+
flexDirection: "column",
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<Text>This is a modal.</Text>
|
|
33
|
+
<Button
|
|
34
|
+
onClick={() => {
|
|
35
|
+
setIsOpen(false);
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
Close Modal
|
|
39
|
+
</Button>
|
|
40
|
+
</Flex>
|
|
41
|
+
</Modal>
|
|
42
|
+
<Button
|
|
43
|
+
onClick={() => {
|
|
44
|
+
setIsOpen(true);
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
Open Modal
|
|
48
|
+
</Button>
|
|
49
|
+
</Box>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
This components extends the API of [react-modal package](http://reactcommunity.org/react-modal/#usage).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useResponsiveValue, useTheme } from '@ttoss/ui';
|
|
2
|
+
import ReactModal from 'react-modal';
|
|
3
|
+
|
|
4
|
+
ReactModal.defaultStyles = {
|
|
5
|
+
overlay: {},
|
|
6
|
+
content: {},
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type ModalProps = ReactModal.Props;
|
|
10
|
+
|
|
11
|
+
export const Modal = (props: ModalProps) => {
|
|
12
|
+
const { theme } = useTheme();
|
|
13
|
+
|
|
14
|
+
const padding =
|
|
15
|
+
useResponsiveValue([
|
|
16
|
+
theme.space?.[2],
|
|
17
|
+
theme.space?.[3],
|
|
18
|
+
theme.space?.[4],
|
|
19
|
+
]) || 0;
|
|
20
|
+
|
|
21
|
+
const style: ReactModal.Styles = {
|
|
22
|
+
overlay: {
|
|
23
|
+
position: 'fixed',
|
|
24
|
+
top: 0,
|
|
25
|
+
left: 0,
|
|
26
|
+
right: 0,
|
|
27
|
+
bottom: 0,
|
|
28
|
+
backgroundColor: 'rgba(255, 255, 255, 0.5)',
|
|
29
|
+
display: 'flex',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
padding,
|
|
33
|
+
...props.style?.overlay,
|
|
34
|
+
},
|
|
35
|
+
content: {
|
|
36
|
+
/**
|
|
37
|
+
* Theme
|
|
38
|
+
*/
|
|
39
|
+
background: theme.rawColors?.background?.toString() || '#fff',
|
|
40
|
+
padding,
|
|
41
|
+
/**
|
|
42
|
+
* General
|
|
43
|
+
*/
|
|
44
|
+
WebkitOverflowScrolling: 'touch',
|
|
45
|
+
overflow: 'auto',
|
|
46
|
+
position: 'relative',
|
|
47
|
+
top: '0px',
|
|
48
|
+
left: '0px',
|
|
49
|
+
right: '0px',
|
|
50
|
+
bottom: '0px',
|
|
51
|
+
border: '1px solid #ccc',
|
|
52
|
+
display: 'flex',
|
|
53
|
+
flexDirection: 'column',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
...props.style?.content,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return <ReactModal {...props} style={style} />;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
Modal.setAppElement = ReactModal.setAppElement;
|
package/src/index.spec.tsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as componentsModule from './index';
|
|
2
2
|
|
|
3
|
-
test(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
test.each([componentsModule.InstallPwa, componentsModule.Modal])(
|
|
4
|
+
'should export components %#',
|
|
5
|
+
(Component) => {
|
|
6
|
+
expect(Component).toBeDefined();
|
|
7
|
+
}
|
|
8
|
+
);
|
package/src/index.ts
CHANGED