@saas-ui/modals 0.1.1 → 0.2.3

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.
@@ -1,158 +0,0 @@
1
- import * as React from 'react'
2
- import { Stack, Container } from '@chakra-ui/react'
3
- import { ModalsProvider, useModals } from '../src/provider'
4
-
5
- import { Button } from '@saas-ui/button'
6
-
7
- const CustomModal: React.FC<{ title: string }> = ({ title, children }) => (
8
- <div>
9
- {title} - {children}
10
- </div>
11
- )
12
-
13
- const modals = {
14
- custom: CustomModal,
15
- }
16
-
17
- export default {
18
- title: 'Components/Overlay/Modals',
19
- decorators: [
20
- (Story: any) => (
21
- <Container mt="40px">
22
- <ModalsProvider modals={modals}>
23
- <Story />
24
- </ModalsProvider>
25
- </Container>
26
- ),
27
- ],
28
- }
29
-
30
- export const basic = () => {
31
- const modals = useModals()
32
-
33
- return (
34
- <Stack>
35
- <Button
36
- onClick={() => {
37
- const id = modals.open({
38
- title: 'My Modal',
39
- body: <>My modal</>,
40
- footer: <Button onClick={() => modals.close(id)} label="Close" />,
41
- })
42
- }}
43
- >
44
- Open modal
45
- </Button>
46
- <Button
47
- onClick={() =>
48
- modals.alert({
49
- title: 'Import finished',
50
- body: 'Your import has finish and can now be used.',
51
- })
52
- }
53
- >
54
- Open alert dialog
55
- </Button>
56
- <Button
57
- onClick={() =>
58
- modals.confirm({
59
- title: 'Delete user?',
60
- body: 'Are you sure you want to delete this user?',
61
- confirmProps: {
62
- colorScheme: 'red',
63
- label: 'Delete',
64
- },
65
- })
66
- }
67
- >
68
- Open confirm dialog
69
- </Button>
70
- <Button
71
- onClick={() =>
72
- modals.drawer({
73
- title: 'My drawer',
74
- body: (
75
- <Stack>
76
- <Button
77
- onClick={() =>
78
- modals.confirm({
79
- title: 'Delete user?',
80
- body: 'Are you sure you want to delete this user?',
81
- confirmProps: {
82
- colorScheme: 'red',
83
- label: 'Delete',
84
- },
85
- })
86
- }
87
- >
88
- Open confirm dialog
89
- </Button>
90
- <Button
91
- onClick={() =>
92
- modals.drawer({
93
- title: 'Subdrawer',
94
- body: (
95
- <>
96
- <Button
97
- onClick={() => modals.closeAll()}
98
- label="Close all"
99
- >
100
- Close all
101
- </Button>
102
- </>
103
- ),
104
- })
105
- }
106
- >
107
- Open drawer
108
- </Button>
109
- </Stack>
110
- ),
111
- })
112
- }
113
- >
114
- Open drawer
115
- </Button>
116
- </Stack>
117
- )
118
- }
119
-
120
- export const custom = () => {
121
- const modals = useModals()
122
-
123
- return (
124
- <Button
125
- onClick={() =>
126
- modals.open({
127
- title: 'My Modal',
128
- body: <>My modal</>,
129
- type: 'custom',
130
- })
131
- }
132
- >
133
- Open modal
134
- </Button>
135
- )
136
- }
137
-
138
- export const onClose = () => {
139
- const modals = useModals()
140
-
141
- return (
142
- <Button
143
- onClick={() =>
144
- modals.open({
145
- title: 'My Modal',
146
- body: <>My modal</>,
147
- onClose: () => {
148
- modals.confirm({
149
- title: 'You closed the modal',
150
- })
151
- },
152
- })
153
- }
154
- >
155
- Open modal
156
- </Button>
157
- )
158
- }
@@ -1 +0,0 @@
1
- import { Modal } from '../src'
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "include": ["src"],
4
- "exclude": [
5
- "src/tests",
6
- "**/*.spec.ts",
7
- "**/*.spec.tsx",
8
- "**/*.test.ts",
9
- "**/*.test.tsx",
10
- "**/*/*.stories.tsx"
11
- ]
12
- }