@saas-ui/modals 0.2.1 → 0.2.2
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/CHANGELOG.md +8 -0
- package/package.json +6 -2
- package/.turbo/turbo-build.log +0 -6
- package/stories/menu.stories.tsx +0 -139
- package/stories/modals.stories.tsx +0 -175
- package/tests/modal.test.tsx +0 -1
- package/tsconfig.json +0 -12
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@saas-ui/modals",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.2",
|
4
4
|
"description": "A modal manager for Chakra UI",
|
5
5
|
"source": "src/index.ts",
|
6
6
|
"exports": {
|
@@ -22,6 +22,10 @@
|
|
22
22
|
"lint:staged": "lint-staged --allow-empty --config ../../lint-staged.config.js",
|
23
23
|
"typecheck": "tsc --noEmit"
|
24
24
|
},
|
25
|
+
"files": [
|
26
|
+
"dist",
|
27
|
+
"src"
|
28
|
+
],
|
25
29
|
"sideEffects": false,
|
26
30
|
"publishConfig": {
|
27
31
|
"access": "public"
|
@@ -52,7 +56,7 @@
|
|
52
56
|
"url": "https://storybook.saas-ui.dev"
|
53
57
|
},
|
54
58
|
"dependencies": {
|
55
|
-
"@saas-ui/button": "0.2.
|
59
|
+
"@saas-ui/button": "0.2.1"
|
56
60
|
},
|
57
61
|
"peerDependencies": {
|
58
62
|
"@chakra-ui/react": ">=1.8.0",
|
package/.turbo/turbo-build.log
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
[34m@saas-ui/modals:build: [0mcache hit, replaying output [2m743c784647c8ec82[0m
|
2
|
-
[34m@saas-ui/modals:build: [0mBuild "@saas-ui/modals" to dist:
|
3
|
-
[34m@saas-ui/modals:build: [0m 2.22 kB: index.js.gz
|
4
|
-
[34m@saas-ui/modals:build: [0m 1.98 kB: index.js.br
|
5
|
-
[34m@saas-ui/modals:build: [0m 2.17 kB: index.modern.js.gz
|
6
|
-
[34m@saas-ui/modals:build: [0m 1.94 kB: index.modern.js.br
|
package/stories/menu.stories.tsx
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
import * as React from 'react'
|
2
|
-
import {
|
3
|
-
Stack,
|
4
|
-
Container,
|
5
|
-
MenuItem,
|
6
|
-
MenuGroup,
|
7
|
-
useDisclosure,
|
8
|
-
} from '@chakra-ui/react'
|
9
|
-
|
10
|
-
import { MenuDialog, MenuDialogList } from '../src/menu'
|
11
|
-
|
12
|
-
import { FiArchive, FiTag, FiUsers, FiSettings } from 'react-icons/fi'
|
13
|
-
|
14
|
-
import { Button } from '@saas-ui/button'
|
15
|
-
|
16
|
-
export default {
|
17
|
-
title: 'Components/Overlay/MenuDialog',
|
18
|
-
decorators: [
|
19
|
-
(Story: any) => (
|
20
|
-
<Container mt="40px">
|
21
|
-
<Story />
|
22
|
-
</Container>
|
23
|
-
),
|
24
|
-
],
|
25
|
-
}
|
26
|
-
|
27
|
-
export const basic = () => {
|
28
|
-
const disclosure = useDisclosure()
|
29
|
-
|
30
|
-
return (
|
31
|
-
<Stack>
|
32
|
-
<Button
|
33
|
-
onClick={() => {
|
34
|
-
disclosure.onOpen()
|
35
|
-
}}
|
36
|
-
>
|
37
|
-
Open menu
|
38
|
-
</Button>
|
39
|
-
|
40
|
-
<MenuDialog title="Menu" {...disclosure}>
|
41
|
-
<MenuDialogList>
|
42
|
-
<MenuItem>Item 1</MenuItem>
|
43
|
-
<MenuItem>Item 2</MenuItem>
|
44
|
-
<MenuItem>Item 3</MenuItem>
|
45
|
-
</MenuDialogList>
|
46
|
-
</MenuDialog>
|
47
|
-
</Stack>
|
48
|
-
)
|
49
|
-
}
|
50
|
-
|
51
|
-
export const iconAndCommand = () => {
|
52
|
-
const disclosure = useDisclosure()
|
53
|
-
|
54
|
-
return (
|
55
|
-
<Stack>
|
56
|
-
<Button
|
57
|
-
onClick={() => {
|
58
|
-
disclosure.onOpen()
|
59
|
-
}}
|
60
|
-
>
|
61
|
-
Open menu
|
62
|
-
</Button>
|
63
|
-
|
64
|
-
<MenuDialog title="Commands" {...disclosure}>
|
65
|
-
<MenuDialogList>
|
66
|
-
<MenuItem icon={<FiUsers />} command="A">
|
67
|
-
Assign
|
68
|
-
</MenuItem>
|
69
|
-
<MenuItem icon={<FiTag />} command="L">
|
70
|
-
Add label
|
71
|
-
</MenuItem>
|
72
|
-
<MenuItem icon={<FiArchive />} command="C">
|
73
|
-
Close
|
74
|
-
</MenuItem>
|
75
|
-
</MenuDialogList>
|
76
|
-
</MenuDialog>
|
77
|
-
</Stack>
|
78
|
-
)
|
79
|
-
}
|
80
|
-
|
81
|
-
export const menuGroup = () => {
|
82
|
-
const disclosure = useDisclosure()
|
83
|
-
|
84
|
-
return (
|
85
|
-
<Stack>
|
86
|
-
<Button
|
87
|
-
onClick={() => {
|
88
|
-
disclosure.onOpen()
|
89
|
-
}}
|
90
|
-
>
|
91
|
-
Open menu
|
92
|
-
</Button>
|
93
|
-
|
94
|
-
<MenuDialog title="Commands" {...disclosure}>
|
95
|
-
<MenuDialogList>
|
96
|
-
<MenuGroup title="Message">
|
97
|
-
<MenuItem icon={<FiUsers />} command="A">
|
98
|
-
Assign
|
99
|
-
</MenuItem>
|
100
|
-
<MenuItem icon={<FiTag />} command="L">
|
101
|
-
Add label
|
102
|
-
</MenuItem>
|
103
|
-
<MenuItem icon={<FiArchive />} command="C">
|
104
|
-
Close
|
105
|
-
</MenuItem>
|
106
|
-
</MenuGroup>
|
107
|
-
<MenuGroup title="Settings">
|
108
|
-
<MenuItem icon={<FiSettings />}>Change theme</MenuItem>
|
109
|
-
</MenuGroup>
|
110
|
-
</MenuDialogList>
|
111
|
-
</MenuDialog>
|
112
|
-
</Stack>
|
113
|
-
)
|
114
|
-
}
|
115
|
-
|
116
|
-
export const overflow = () => {
|
117
|
-
const disclosure = useDisclosure()
|
118
|
-
|
119
|
-
const items = []
|
120
|
-
for (let i = 0; i < 50; i++) {
|
121
|
-
items.push(<MenuItem key={i}>Item {i}</MenuItem>)
|
122
|
-
}
|
123
|
-
|
124
|
-
return (
|
125
|
-
<Stack>
|
126
|
-
<Button
|
127
|
-
onClick={() => {
|
128
|
-
disclosure.onOpen()
|
129
|
-
}}
|
130
|
-
>
|
131
|
-
Open menu
|
132
|
-
</Button>
|
133
|
-
|
134
|
-
<MenuDialog title="Menu" {...disclosure}>
|
135
|
-
<MenuDialogList>{items}</MenuDialogList>
|
136
|
-
</MenuDialog>
|
137
|
-
</Stack>
|
138
|
-
)
|
139
|
-
}
|
@@ -1,175 +0,0 @@
|
|
1
|
-
import * as React from 'react'
|
2
|
-
import { Stack, Container, MenuItem } from '@chakra-ui/react'
|
3
|
-
import { ModalsProvider, useModals } from '../src/provider'
|
4
|
-
|
5
|
-
import { MenuDialogList } from '../src/menu'
|
6
|
-
|
7
|
-
import { Button } from '@saas-ui/button'
|
8
|
-
|
9
|
-
const CustomModal: React.FC<{ title: string }> = ({ title, children }) => (
|
10
|
-
<div>
|
11
|
-
{title} - {children}
|
12
|
-
</div>
|
13
|
-
)
|
14
|
-
|
15
|
-
const modals = {
|
16
|
-
custom: CustomModal,
|
17
|
-
}
|
18
|
-
|
19
|
-
export default {
|
20
|
-
title: 'Components/Overlay/Modals',
|
21
|
-
decorators: [
|
22
|
-
(Story: any) => (
|
23
|
-
<Container mt="40px">
|
24
|
-
<ModalsProvider modals={modals}>
|
25
|
-
<Story />
|
26
|
-
</ModalsProvider>
|
27
|
-
</Container>
|
28
|
-
),
|
29
|
-
],
|
30
|
-
}
|
31
|
-
|
32
|
-
export const basic = () => {
|
33
|
-
const modals = useModals()
|
34
|
-
|
35
|
-
return (
|
36
|
-
<Stack>
|
37
|
-
<Button
|
38
|
-
onClick={() => {
|
39
|
-
const id = modals.open({
|
40
|
-
title: 'My Modal',
|
41
|
-
body: <>My modal</>,
|
42
|
-
footer: <Button onClick={() => modals.close(id)} label="Close" />,
|
43
|
-
})
|
44
|
-
}}
|
45
|
-
>
|
46
|
-
Open modal
|
47
|
-
</Button>
|
48
|
-
<Button
|
49
|
-
onClick={() =>
|
50
|
-
modals.alert({
|
51
|
-
title: 'Import finished',
|
52
|
-
body: 'Your import has finish and can now be used.',
|
53
|
-
})
|
54
|
-
}
|
55
|
-
>
|
56
|
-
Open alert dialog
|
57
|
-
</Button>
|
58
|
-
<Button
|
59
|
-
onClick={() =>
|
60
|
-
modals.confirm({
|
61
|
-
title: 'Delete user?',
|
62
|
-
body: 'Are you sure you want to delete this user?',
|
63
|
-
confirmProps: {
|
64
|
-
colorScheme: 'red',
|
65
|
-
label: 'Delete',
|
66
|
-
},
|
67
|
-
})
|
68
|
-
}
|
69
|
-
>
|
70
|
-
Open confirm dialog
|
71
|
-
</Button>
|
72
|
-
<Button
|
73
|
-
onClick={() =>
|
74
|
-
modals.drawer({
|
75
|
-
title: 'My drawer',
|
76
|
-
body: (
|
77
|
-
<Stack>
|
78
|
-
<Button
|
79
|
-
onClick={() =>
|
80
|
-
modals.confirm({
|
81
|
-
title: 'Delete user?',
|
82
|
-
body: 'Are you sure you want to delete this user?',
|
83
|
-
confirmProps: {
|
84
|
-
colorScheme: 'red',
|
85
|
-
label: 'Delete',
|
86
|
-
},
|
87
|
-
})
|
88
|
-
}
|
89
|
-
>
|
90
|
-
Open confirm dialog
|
91
|
-
</Button>
|
92
|
-
<Button
|
93
|
-
onClick={() =>
|
94
|
-
modals.drawer({
|
95
|
-
title: 'Subdrawer',
|
96
|
-
body: (
|
97
|
-
<>
|
98
|
-
<Button
|
99
|
-
onClick={() => modals.closeAll()}
|
100
|
-
label="Close all"
|
101
|
-
>
|
102
|
-
Close all
|
103
|
-
</Button>
|
104
|
-
</>
|
105
|
-
),
|
106
|
-
})
|
107
|
-
}
|
108
|
-
>
|
109
|
-
Open drawer
|
110
|
-
</Button>
|
111
|
-
</Stack>
|
112
|
-
),
|
113
|
-
})
|
114
|
-
}
|
115
|
-
>
|
116
|
-
Open drawer
|
117
|
-
</Button>
|
118
|
-
<Button
|
119
|
-
onClick={() =>
|
120
|
-
modals.menu({
|
121
|
-
title: 'Menu',
|
122
|
-
body: (
|
123
|
-
<MenuDialogList>
|
124
|
-
<MenuItem>Item 1</MenuItem>
|
125
|
-
<MenuItem>Item 1</MenuItem>
|
126
|
-
</MenuDialogList>
|
127
|
-
),
|
128
|
-
})
|
129
|
-
}
|
130
|
-
>
|
131
|
-
Open menu
|
132
|
-
</Button>
|
133
|
-
</Stack>
|
134
|
-
)
|
135
|
-
}
|
136
|
-
|
137
|
-
export const custom = () => {
|
138
|
-
const modals = useModals()
|
139
|
-
|
140
|
-
return (
|
141
|
-
<Button
|
142
|
-
onClick={() =>
|
143
|
-
modals.open({
|
144
|
-
title: 'My Modal',
|
145
|
-
body: <>My modal</>,
|
146
|
-
type: 'custom',
|
147
|
-
})
|
148
|
-
}
|
149
|
-
>
|
150
|
-
Open modal
|
151
|
-
</Button>
|
152
|
-
)
|
153
|
-
}
|
154
|
-
|
155
|
-
export const onClose = () => {
|
156
|
-
const modals = useModals()
|
157
|
-
|
158
|
-
return (
|
159
|
-
<Button
|
160
|
-
onClick={() =>
|
161
|
-
modals.open({
|
162
|
-
title: 'My Modal',
|
163
|
-
body: <>My modal</>,
|
164
|
-
onClose: () => {
|
165
|
-
modals.confirm({
|
166
|
-
title: 'You closed the modal',
|
167
|
-
})
|
168
|
-
},
|
169
|
-
})
|
170
|
-
}
|
171
|
-
>
|
172
|
-
Open modal
|
173
|
-
</Button>
|
174
|
-
)
|
175
|
-
}
|
package/tests/modal.test.tsx
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import { Modal } from '../src'
|