@memori.ai/memori-react 7.22.0 → 7.23.1
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 +51 -0
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js +85 -8
- package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/dist/components/Header/Header.css +1 -1
- package/dist/components/KnownFacts/KnownFacts.js +1 -1
- package/dist/components/KnownFacts/KnownFacts.js.map +1 -1
- package/dist/components/Typing/Typing.js +49 -47
- package/dist/components/Typing/Typing.js.map +1 -1
- package/dist/components/icons/Alert.d.ts +5 -0
- package/dist/components/icons/Alert.js +6 -0
- package/dist/components/icons/Alert.js.map +1 -0
- package/dist/components/icons/Info.d.ts +5 -0
- package/dist/components/icons/Info.js +6 -0
- package/dist/components/icons/Info.js.map +1 -0
- package/dist/components/icons/Warning.js +1 -1
- package/dist/components/icons/Warning.js.map +1 -1
- package/dist/components/ui/ConfirmDialog.css +42 -0
- package/dist/components/ui/ConfirmDialog.d.ts +11 -0
- package/dist/components/ui/ConfirmDialog.js +12 -0
- package/dist/components/ui/ConfirmDialog.js.map +1 -0
- package/dist/components/ui/Drawer.css +121 -96
- package/dist/components/ui/Drawer.d.ts +15 -6
- package/dist/components/ui/Drawer.js +44 -13
- package/dist/components/ui/Drawer.js.map +1 -1
- package/dist/helpers/error.js +1 -0
- package/dist/helpers/error.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/locales/de.json +8 -0
- package/dist/locales/en.json +8 -0
- package/dist/locales/es.json +19 -11
- package/dist/locales/fr.json +8 -0
- package/dist/locales/it.json +8 -0
- package/dist/styles.css +6 -4
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js +85 -8
- package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
- package/esm/components/Header/Header.css +1 -1
- package/esm/components/KnownFacts/KnownFacts.js +1 -1
- package/esm/components/KnownFacts/KnownFacts.js.map +1 -1
- package/esm/components/Typing/Typing.js +49 -47
- package/esm/components/Typing/Typing.js.map +1 -1
- package/esm/components/icons/Alert.d.ts +5 -0
- package/esm/components/icons/Alert.js +4 -0
- package/esm/components/icons/Alert.js.map +1 -0
- package/esm/components/icons/Info.d.ts +5 -0
- package/esm/components/icons/Info.js +4 -0
- package/esm/components/icons/Info.js.map +1 -0
- package/esm/components/icons/Warning.js +1 -1
- package/esm/components/icons/Warning.js.map +1 -1
- package/esm/components/ui/ConfirmDialog.css +42 -0
- package/esm/components/ui/ConfirmDialog.d.ts +11 -0
- package/esm/components/ui/ConfirmDialog.js +9 -0
- package/esm/components/ui/ConfirmDialog.js.map +1 -0
- package/esm/components/ui/Drawer.css +121 -96
- package/esm/components/ui/Drawer.d.ts +15 -6
- package/esm/components/ui/Drawer.js +45 -14
- package/esm/components/ui/Drawer.js.map +1 -1
- package/esm/helpers/error.js +1 -0
- package/esm/helpers/error.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/locales/de.json +8 -0
- package/esm/locales/en.json +8 -0
- package/esm/locales/es.json +19 -11
- package/esm/locales/fr.json +8 -0
- package/esm/locales/it.json +8 -0
- package/esm/styles.css +6 -4
- package/package.json +1 -1
- package/src/components/BlockedMemoriBadge/__snapshots__/BlockedMemoriBadge.test.tsx.snap +10 -0
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.stories.tsx +274 -21
- package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +117 -21
- package/src/components/CompletionProviderStatus/__snapshots__/CompletionProviderStatus.test.tsx.snap +39 -21
- package/src/components/Header/Header.css +1 -1
- package/src/components/KnownFacts/KnownFacts.tsx +1 -1
- package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +13 -7
- package/src/components/Typing/Typing.tsx +52 -47
- package/src/components/icons/Alert.tsx +31 -0
- package/src/components/icons/Info.tsx +31 -0
- package/src/components/icons/Warning.tsx +2 -1
- package/src/components/ui/ConfirmDialog.css +42 -0
- package/src/components/ui/ConfirmDialog.stories.tsx +216 -0
- package/src/components/ui/ConfirmDialog.test.tsx +124 -0
- package/src/components/ui/ConfirmDialog.tsx +58 -0
- package/src/components/ui/Drawer.css +121 -96
- package/src/components/ui/Drawer.stories.tsx +152 -67
- package/src/components/ui/Drawer.test.tsx +6 -2
- package/src/components/ui/Drawer.tsx +195 -89
- package/src/components/ui/__snapshots__/ConfirmDialog.test.tsx.snap +35 -0
- package/src/helpers/error.ts +1 -0
- package/src/index.tsx +1 -1
- package/src/locales/de.json +8 -0
- package/src/locales/en.json +8 -0
- package/src/locales/es.json +19 -11
- package/src/locales/fr.json +8 -0
- package/src/locales/it.json +8 -0
- package/src/styles.css +6 -4
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dialog, Transition } from '@headlessui/react';
|
|
3
|
+
import Button from './Button';
|
|
4
|
+
|
|
5
|
+
// Custom confirm dialog component
|
|
6
|
+
const ConfirmDialog: React.FC<{
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
onConfirm: () => void;
|
|
10
|
+
title: string;
|
|
11
|
+
message: string;
|
|
12
|
+
confirmText: string;
|
|
13
|
+
cancelText: string;
|
|
14
|
+
}> = ({
|
|
15
|
+
isOpen,
|
|
16
|
+
onClose,
|
|
17
|
+
onConfirm,
|
|
18
|
+
title,
|
|
19
|
+
message,
|
|
20
|
+
confirmText,
|
|
21
|
+
cancelText,
|
|
22
|
+
}) => {
|
|
23
|
+
return (
|
|
24
|
+
<Transition appear show={isOpen} as={React.Fragment}>
|
|
25
|
+
<Dialog as="div" className="memori-confirm-dialog" onClose={onClose}>
|
|
26
|
+
<div className="memori-confirm-dialog--backdrop" />
|
|
27
|
+
<div className="memori-confirm-dialog--container">
|
|
28
|
+
<Transition.Child
|
|
29
|
+
as={React.Fragment}
|
|
30
|
+
enter="ease-out duration-300"
|
|
31
|
+
enterFrom="opacity-0 scale-95"
|
|
32
|
+
enterTo="opacity-100 scale-100"
|
|
33
|
+
leave="ease-in duration-200"
|
|
34
|
+
leaveFrom="opacity-100 scale-100"
|
|
35
|
+
leaveTo="opacity-0 scale-95"
|
|
36
|
+
>
|
|
37
|
+
<Dialog.Panel className="memori-confirm-dialog--panel">
|
|
38
|
+
<Dialog.Title className="memori-confirm-dialog--title">
|
|
39
|
+
{title}
|
|
40
|
+
</Dialog.Title>
|
|
41
|
+
<Dialog.Description className="memori-confirm-dialog--message">
|
|
42
|
+
{message}
|
|
43
|
+
</Dialog.Description>
|
|
44
|
+
<div className="memori-confirm-dialog--actions">
|
|
45
|
+
<Button onClick={onClose}>{cancelText}</Button>
|
|
46
|
+
<Button primary onClick={onConfirm}>
|
|
47
|
+
{confirmText}
|
|
48
|
+
</Button>
|
|
49
|
+
</div>
|
|
50
|
+
</Dialog.Panel>
|
|
51
|
+
</Transition.Child>
|
|
52
|
+
</div>
|
|
53
|
+
</Dialog>
|
|
54
|
+
</Transition>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default ConfirmDialog;
|
|
@@ -1,180 +1,205 @@
|
|
|
1
1
|
.memori-drawer {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
position: relative;
|
|
3
|
+
z-index: 1001;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.memori-drawer--backdrop {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
position: fixed;
|
|
8
|
+
z-index: 1000;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.memori-drawer--container {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
position: fixed;
|
|
18
|
+
z-index: 1001;
|
|
19
|
+
top: 0;
|
|
20
|
+
right: 0;
|
|
21
|
+
bottom: 0;
|
|
22
|
+
left: 0;
|
|
23
|
+
overflow-y: auto;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.memori-drawer--container-scrollable {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
display: flex;
|
|
28
|
+
min-height: 100%;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.memori-drawer--panel {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
position: relative;
|
|
35
|
+
display: flex;
|
|
36
|
+
width: var(--memori-drawer--width, 100%);
|
|
37
|
+
max-width: 80vw;
|
|
38
|
+
height: 100%;
|
|
39
|
+
min-height: 100vh;
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
padding: 1rem 1.5rem 1.5rem;
|
|
43
|
+
margin-right: 0;
|
|
44
|
+
margin-left: auto;
|
|
45
|
+
background-color: #fff;
|
|
46
|
+
font-family: var(--memori-font-family);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
@media (min-width: 768px) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
.memori-drawer--panel {
|
|
51
|
+
width: var(--memori-drawer--width-md, 80%);
|
|
52
|
+
max-width: none;
|
|
53
|
+
padding-top: 1.5rem;
|
|
54
|
+
padding-right: 2rem;
|
|
55
|
+
padding-left: 2rem;
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
@media (min-width: 1024px) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
.memori-drawer--panel {
|
|
61
|
+
width: var(--memori-drawer--width-lg, 60%);
|
|
62
|
+
}
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
.memori-drawer--panel.memori-drawer--with-footer {
|
|
64
|
-
|
|
66
|
+
padding-bottom: 0;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
.memori-drawer--panel .memori-spin {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
display: flex;
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
flex: 1;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
overflow-y: auto;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
.memori-drawer--panel
|
|
75
|
-
|
|
78
|
+
.memori-drawer--panel > .memori-spin {
|
|
79
|
+
margin-top: -1.75rem;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
.memori-drawer--panel p {
|
|
79
|
-
|
|
83
|
+
margin: 0 0 1em;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
h2.memori-drawer--title {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
margin: 0 0 1rem;
|
|
88
|
+
font-size: 1.5rem;
|
|
89
|
+
font-weight: 700;
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
.memori-drawer--panel-left {
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
margin-right: auto;
|
|
94
|
+
margin-left: 0;
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
.memori-drawer--close {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
position: sticky;
|
|
99
|
+
z-index: 70;
|
|
100
|
+
top: 0;
|
|
101
|
+
left: 0;
|
|
102
|
+
padding: 0.5rem;
|
|
103
|
+
margin-top: -1.5rem;
|
|
104
|
+
margin-left: -5.5rem;
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
@media (max-width: 767px) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
.memori-drawer--close {
|
|
109
|
+
left: 0.5rem;
|
|
110
|
+
}
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
.memori-drawer--close button {
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
border-color: #fff;
|
|
115
|
+
color: #fff;
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
@media (max-width: 767px) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
.memori-drawer--close button {
|
|
120
|
+
color: #000;
|
|
121
|
+
}
|
|
118
122
|
}
|
|
119
123
|
|
|
120
124
|
.memori-drawer--panel-left .memori-drawer--close {
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
right: -3.5rem;
|
|
126
|
+
left: auto;
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
@media (max-width: 767px) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
.memori-drawer--panel-left .memori-drawer--close {
|
|
131
|
+
right: 0.5rem;
|
|
132
|
+
left: auto;
|
|
133
|
+
}
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
.memori-drawer--footer {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
position: sticky;
|
|
138
|
+
bottom: 0;
|
|
139
|
+
left: 0;
|
|
140
|
+
display: flex;
|
|
141
|
+
width: 100%;
|
|
142
|
+
justify-content: flex-end;
|
|
143
|
+
padding-top: 1rem;
|
|
144
|
+
padding-bottom: 1rem;
|
|
145
|
+
border-top: 1px solid rgba(0, 0, 0, 0.25);
|
|
146
|
+
margin-top: auto;
|
|
147
|
+
background-color: #fff;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.memori-drawer--footer-left-action {
|
|
151
|
+
margin-right: auto;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.memori-drawer--footer-actions {
|
|
155
|
+
display: flex;
|
|
156
|
+
gap: 0.5rem;
|
|
144
157
|
}
|
|
145
158
|
|
|
146
|
-
.memori-drawer--footer button+button {
|
|
147
|
-
|
|
159
|
+
.memori-drawer--footer button + button {
|
|
160
|
+
margin-left: 0.5em;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.memori-drawer--content{
|
|
164
|
+
flex: 1;
|
|
165
|
+
padding-top: 12px;
|
|
166
|
+
overflow-y: auto;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.memori-drawer--content--scrollable{
|
|
170
|
+
flex: 1;
|
|
171
|
+
overflow-y: auto;
|
|
148
172
|
}
|
|
149
173
|
|
|
174
|
+
/* Transition classes */
|
|
150
175
|
.ease-out {
|
|
151
|
-
|
|
176
|
+
transition-timing-function: ease-out;
|
|
152
177
|
}
|
|
153
178
|
|
|
154
179
|
.ease-in {
|
|
155
|
-
|
|
180
|
+
transition-timing-function: ease-in;
|
|
156
181
|
}
|
|
157
182
|
|
|
158
183
|
.duration-300 {
|
|
159
|
-
|
|
184
|
+
transition-duration: 300ms;
|
|
160
185
|
}
|
|
161
186
|
|
|
162
187
|
.duration-200 {
|
|
163
|
-
|
|
188
|
+
transition-duration: 200ms;
|
|
164
189
|
}
|
|
165
190
|
|
|
166
191
|
.opacity-0 {
|
|
167
|
-
|
|
192
|
+
opacity: 0;
|
|
168
193
|
}
|
|
169
194
|
|
|
170
195
|
.opacity-100 {
|
|
171
|
-
|
|
196
|
+
opacity: 1;
|
|
172
197
|
}
|
|
173
198
|
|
|
174
199
|
.max-w-0 {
|
|
175
|
-
|
|
200
|
+
max-width: 0;
|
|
176
201
|
}
|
|
177
202
|
|
|
178
203
|
.max-w-80 {
|
|
179
|
-
|
|
204
|
+
max-width: 80%;
|
|
180
205
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import { Meta, Story } from '@storybook/react';
|
|
3
3
|
import Drawer, { Props } from './Drawer';
|
|
4
4
|
import Button from './Button';
|
|
5
5
|
|
|
6
6
|
import './Drawer.css';
|
|
7
|
+
import I18nWrapper from '../../I18nWrapper';
|
|
7
8
|
|
|
8
9
|
const meta: Meta = {
|
|
9
10
|
title: 'UI/Drawer',
|
|
@@ -34,12 +35,27 @@ const meta: Meta = {
|
|
|
34
35
|
type: 'text',
|
|
35
36
|
},
|
|
36
37
|
},
|
|
37
|
-
|
|
38
|
+
placement: {
|
|
38
39
|
control: {
|
|
39
40
|
type: 'select',
|
|
40
41
|
options: ['left', 'right'],
|
|
41
42
|
},
|
|
42
43
|
},
|
|
44
|
+
width: {
|
|
45
|
+
control: {
|
|
46
|
+
type: 'text',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
animated: {
|
|
50
|
+
control: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
closable: {
|
|
55
|
+
control: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
43
59
|
},
|
|
44
60
|
parameters: {
|
|
45
61
|
controls: { expanded: true },
|
|
@@ -61,73 +77,29 @@ const content = (
|
|
|
61
77
|
<p>Nulla at urna diam.</p>
|
|
62
78
|
<h3>Suspendisse a sodales nulla, sed semper nisi.</h3>
|
|
63
79
|
<p>Proin tincidunt enim in felis aliquet, a ultricies purus bibendum.</p>
|
|
64
|
-
<ul>
|
|
65
|
-
<li>Quisque in ultrices lectus.</li>
|
|
66
|
-
<li>Quisque in ultrices lectus.</li>
|
|
67
|
-
<li>Quisque in ultrices lectus.</li>
|
|
68
|
-
</ul>
|
|
69
|
-
<p>Nulla at urna diam.</p>
|
|
70
|
-
<p>Nulla at urna diam.</p>
|
|
71
|
-
<h3>Suspendisse a sodales nulla, sed semper nisi.</h3>
|
|
72
|
-
<p>Proin tincidunt enim in felis aliquet, a ultricies purus bibendum.</p>
|
|
73
|
-
<ul>
|
|
74
|
-
<li>Quisque in ultrices lectus.</li>
|
|
75
|
-
<li>Quisque in ultrices lectus.</li>
|
|
76
|
-
<li>Quisque in ultrices lectus.</li>
|
|
77
|
-
</ul>
|
|
78
|
-
<p>Nulla at urna diam.</p>
|
|
79
80
|
</>
|
|
80
81
|
);
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
</>
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const Template: Story<Props> = args => {
|
|
90
|
-
const [isOpen, setIsOpen] = React.useState(!!args.open || false);
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<>
|
|
94
|
-
<Button onClick={() => setIsOpen(true)}>Click me</Button>
|
|
95
|
-
<Drawer
|
|
96
|
-
{...args}
|
|
97
|
-
open={isOpen}
|
|
98
|
-
onClose={() => setIsOpen(false)}
|
|
99
|
-
footer={args.footer}
|
|
100
|
-
>
|
|
101
|
-
{content}
|
|
102
|
-
</Drawer>
|
|
103
|
-
</>
|
|
104
|
-
);
|
|
83
|
+
// Create a proper footer object for the Drawer component
|
|
84
|
+
const simpleFooterObject = {
|
|
85
|
+
onSubmit: () => console.log('Submit clicked'),
|
|
86
|
+
loading: false,
|
|
105
87
|
};
|
|
106
88
|
|
|
107
|
-
const
|
|
89
|
+
const Template: Story<Props> = args => {
|
|
108
90
|
const [isOpen, setIsOpen] = React.useState(!!args.open || false);
|
|
109
91
|
|
|
110
92
|
return (
|
|
111
|
-
|
|
112
|
-
<Button onClick={() => setIsOpen(true)}>
|
|
113
|
-
<Drawer
|
|
114
|
-
{...args}
|
|
115
|
-
open={isOpen}
|
|
116
|
-
onClose={() => setIsOpen(false)}
|
|
117
|
-
footer={args.footer}
|
|
118
|
-
>
|
|
119
|
-
{content}
|
|
120
|
-
{content}
|
|
121
|
-
{content}
|
|
122
|
-
{content}
|
|
93
|
+
<I18nWrapper>
|
|
94
|
+
<Button onClick={() => setIsOpen(true)}>Open Drawer</Button>
|
|
95
|
+
<Drawer {...args} open={isOpen} onClose={() => setIsOpen(false)}>
|
|
123
96
|
{content}
|
|
124
97
|
</Drawer>
|
|
125
|
-
|
|
98
|
+
</I18nWrapper>
|
|
126
99
|
);
|
|
127
100
|
};
|
|
128
101
|
|
|
129
|
-
//
|
|
130
|
-
// https://storybook.js.org/docs/react/workflows/unit-testing
|
|
102
|
+
// Basic examples
|
|
131
103
|
export const Default = Template.bind({});
|
|
132
104
|
Default.args = {
|
|
133
105
|
open: false,
|
|
@@ -159,24 +131,137 @@ Loading.args = {
|
|
|
159
131
|
loading: true,
|
|
160
132
|
};
|
|
161
133
|
|
|
162
|
-
export const
|
|
163
|
-
|
|
134
|
+
export const WithSimpleFooter = Template.bind({});
|
|
135
|
+
WithSimpleFooter.args = {
|
|
164
136
|
open: true,
|
|
165
137
|
title: 'Drawer Title',
|
|
166
138
|
description: 'Drawer Description',
|
|
167
|
-
footer
|
|
139
|
+
footer: {
|
|
140
|
+
onSubmit: () => console.log('Submit'),
|
|
141
|
+
loading: false,
|
|
142
|
+
},
|
|
168
143
|
};
|
|
169
144
|
|
|
170
|
-
export const
|
|
171
|
-
|
|
145
|
+
export const PlacementLeft = Template.bind({});
|
|
146
|
+
PlacementLeft.args = {
|
|
172
147
|
open: true,
|
|
173
|
-
|
|
148
|
+
placement: 'left',
|
|
149
|
+
title: 'Left Drawer',
|
|
174
150
|
};
|
|
175
151
|
|
|
176
|
-
export const
|
|
177
|
-
|
|
152
|
+
export const CustomWidth = Template.bind({});
|
|
153
|
+
CustomWidth.args = {
|
|
178
154
|
open: true,
|
|
179
|
-
title: 'Drawer
|
|
180
|
-
|
|
181
|
-
|
|
155
|
+
title: 'Custom Width Drawer',
|
|
156
|
+
width: '50%',
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const NonAnimated = Template.bind({});
|
|
160
|
+
NonAnimated.args = {
|
|
161
|
+
open: true,
|
|
162
|
+
title: 'Non-Animated Drawer',
|
|
163
|
+
animated: false,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export const NonClosable = Template.bind({});
|
|
167
|
+
NonClosable.args = {
|
|
168
|
+
open: true,
|
|
169
|
+
title: 'Non-Closable Drawer',
|
|
170
|
+
closable: false,
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// Template for data detection
|
|
174
|
+
const DataTemplate: Story<Props> = args => {
|
|
175
|
+
const [isOpen, setIsOpen] = React.useState(!!args.open || false);
|
|
176
|
+
// Use static data for the story - don't try to update it which might cause issues
|
|
177
|
+
const staticData = { id: 1, name: 'John Doe' };
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<I18nWrapper>
|
|
181
|
+
<Button onClick={() => setIsOpen(true)}>Open Data Drawer</Button>
|
|
182
|
+
<Drawer
|
|
183
|
+
{...args}
|
|
184
|
+
open={isOpen}
|
|
185
|
+
data={staticData}
|
|
186
|
+
onClose={() => setIsOpen(false)}
|
|
187
|
+
>
|
|
188
|
+
<p>This drawer has data associated with it.</p>
|
|
189
|
+
<p>When you close it, the component will check for unsaved changes.</p>
|
|
190
|
+
<p>(For this demo, no actual changes are tracked)</p>
|
|
191
|
+
</Drawer>
|
|
192
|
+
</I18nWrapper>
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const WithDataDetection = DataTemplate.bind({});
|
|
197
|
+
WithDataDetection.args = {
|
|
198
|
+
open: true,
|
|
199
|
+
title: 'Data Change Detection',
|
|
200
|
+
description: 'This drawer demonstrates the data change detection feature',
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Improved ConfirmationDialog template with better state management
|
|
204
|
+
|
|
205
|
+
const ConfirmationDialogTemplate: Story<Props> = ({ open = true }: Props) => {
|
|
206
|
+
const [isOpen, setIsOpen] = useState(open);
|
|
207
|
+
const [data, setData] = useState({ id: 1, name: 'John Doe' });
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<I18nWrapper>
|
|
211
|
+
<Button onClick={() => setIsOpen(true)}>Open Confirmation Dialog</Button>
|
|
212
|
+
<Drawer
|
|
213
|
+
open={isOpen}
|
|
214
|
+
onClose={() => setIsOpen(false)}
|
|
215
|
+
data={data}
|
|
216
|
+
title="Confirmation Example"
|
|
217
|
+
confirmDialogTitle="Confirmation Example"
|
|
218
|
+
confirmDialogMessage="Are you sure you want to close this drawer?"
|
|
219
|
+
footer={{
|
|
220
|
+
onSubmit: () => {
|
|
221
|
+
console.log('Submitted with data:', data);
|
|
222
|
+
setIsOpen(false);
|
|
223
|
+
},
|
|
224
|
+
}}
|
|
225
|
+
>
|
|
226
|
+
<h3>Sample Form Content</h3>
|
|
227
|
+
<p>Current data: {JSON.stringify(data)}</p>
|
|
228
|
+
<Button onClick={() => setData({ id: 1, name: 'Jane Smith' })}>
|
|
229
|
+
Modify Data
|
|
230
|
+
</Button>
|
|
231
|
+
</Drawer>
|
|
232
|
+
</I18nWrapper>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export const WithConfirmationDialog = ConfirmationDialogTemplate.bind({});
|
|
237
|
+
WithConfirmationDialog.args = {
|
|
238
|
+
open: true,
|
|
239
|
+
title: 'Unsaved Changes Demo',
|
|
240
|
+
description:
|
|
241
|
+
'This drawer shows the confirmation dialog when closing with unsaved changes',
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// Fixed Template with lots of content and proper footer
|
|
245
|
+
const LongContentTemplate: Story<Props> = args => {
|
|
246
|
+
const [isOpen, setIsOpen] = React.useState(!!args.open || false);
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<I18nWrapper>
|
|
250
|
+
<Button onClick={() => setIsOpen(true)}>Open Long Content Drawer</Button>
|
|
251
|
+
<Drawer {...args} open={isOpen} onClose={() => setIsOpen(false)}>
|
|
252
|
+
{content}
|
|
253
|
+
{content}
|
|
254
|
+
{content}
|
|
255
|
+
{content}
|
|
256
|
+
</Drawer>
|
|
257
|
+
</I18nWrapper>
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export const WithLongContent = LongContentTemplate.bind({});
|
|
262
|
+
WithLongContent.args = {
|
|
263
|
+
open: true,
|
|
264
|
+
title: 'Long Content Drawer',
|
|
265
|
+
description: 'This drawer has a lot of content',
|
|
266
|
+
footer: simpleFooterObject, // Use the properly structured footer object
|
|
182
267
|
};
|
|
@@ -85,7 +85,11 @@ it('renders Drawer loading unchanged', () => {
|
|
|
85
85
|
|
|
86
86
|
it('renders Drawer with footer unchanged', () => {
|
|
87
87
|
const { container } = render(
|
|
88
|
-
<Drawer open={true} onClose={jest.fn()} footer={
|
|
88
|
+
<Drawer open={true} onClose={jest.fn()} footer={{
|
|
89
|
+
leftAction: <Button>Cancel</Button>,
|
|
90
|
+
onSubmit: jest.fn(),
|
|
91
|
+
loading: false
|
|
92
|
+
}}>
|
|
89
93
|
{content}
|
|
90
94
|
</Drawer>
|
|
91
95
|
);
|
|
@@ -103,7 +107,7 @@ it('renders Drawer non closable unchanged', () => {
|
|
|
103
107
|
|
|
104
108
|
it('renders Drawer side left unchanged', () => {
|
|
105
109
|
const { container } = render(
|
|
106
|
-
<Drawer open={true} onClose={jest.fn()}
|
|
110
|
+
<Drawer open={true} onClose={jest.fn()} placement="left">
|
|
107
111
|
{content}
|
|
108
112
|
</Drawer>
|
|
109
113
|
);
|