@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.
Files changed (99) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
  3. package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js +85 -8
  4. package/dist/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
  5. package/dist/components/Header/Header.css +1 -1
  6. package/dist/components/KnownFacts/KnownFacts.js +1 -1
  7. package/dist/components/KnownFacts/KnownFacts.js.map +1 -1
  8. package/dist/components/Typing/Typing.js +49 -47
  9. package/dist/components/Typing/Typing.js.map +1 -1
  10. package/dist/components/icons/Alert.d.ts +5 -0
  11. package/dist/components/icons/Alert.js +6 -0
  12. package/dist/components/icons/Alert.js.map +1 -0
  13. package/dist/components/icons/Info.d.ts +5 -0
  14. package/dist/components/icons/Info.js +6 -0
  15. package/dist/components/icons/Info.js.map +1 -0
  16. package/dist/components/icons/Warning.js +1 -1
  17. package/dist/components/icons/Warning.js.map +1 -1
  18. package/dist/components/ui/ConfirmDialog.css +42 -0
  19. package/dist/components/ui/ConfirmDialog.d.ts +11 -0
  20. package/dist/components/ui/ConfirmDialog.js +12 -0
  21. package/dist/components/ui/ConfirmDialog.js.map +1 -0
  22. package/dist/components/ui/Drawer.css +121 -96
  23. package/dist/components/ui/Drawer.d.ts +15 -6
  24. package/dist/components/ui/Drawer.js +44 -13
  25. package/dist/components/ui/Drawer.js.map +1 -1
  26. package/dist/helpers/error.js +1 -0
  27. package/dist/helpers/error.js.map +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/locales/de.json +8 -0
  31. package/dist/locales/en.json +8 -0
  32. package/dist/locales/es.json +19 -11
  33. package/dist/locales/fr.json +8 -0
  34. package/dist/locales/it.json +8 -0
  35. package/dist/styles.css +6 -4
  36. package/esm/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
  37. package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js +85 -8
  38. package/esm/components/CompletionProviderStatus/CompletionProviderStatus.js.map +1 -1
  39. package/esm/components/Header/Header.css +1 -1
  40. package/esm/components/KnownFacts/KnownFacts.js +1 -1
  41. package/esm/components/KnownFacts/KnownFacts.js.map +1 -1
  42. package/esm/components/Typing/Typing.js +49 -47
  43. package/esm/components/Typing/Typing.js.map +1 -1
  44. package/esm/components/icons/Alert.d.ts +5 -0
  45. package/esm/components/icons/Alert.js +4 -0
  46. package/esm/components/icons/Alert.js.map +1 -0
  47. package/esm/components/icons/Info.d.ts +5 -0
  48. package/esm/components/icons/Info.js +4 -0
  49. package/esm/components/icons/Info.js.map +1 -0
  50. package/esm/components/icons/Warning.js +1 -1
  51. package/esm/components/icons/Warning.js.map +1 -1
  52. package/esm/components/ui/ConfirmDialog.css +42 -0
  53. package/esm/components/ui/ConfirmDialog.d.ts +11 -0
  54. package/esm/components/ui/ConfirmDialog.js +9 -0
  55. package/esm/components/ui/ConfirmDialog.js.map +1 -0
  56. package/esm/components/ui/Drawer.css +121 -96
  57. package/esm/components/ui/Drawer.d.ts +15 -6
  58. package/esm/components/ui/Drawer.js +45 -14
  59. package/esm/components/ui/Drawer.js.map +1 -1
  60. package/esm/helpers/error.js +1 -0
  61. package/esm/helpers/error.js.map +1 -1
  62. package/esm/index.js +1 -1
  63. package/esm/index.js.map +1 -1
  64. package/esm/locales/de.json +8 -0
  65. package/esm/locales/en.json +8 -0
  66. package/esm/locales/es.json +19 -11
  67. package/esm/locales/fr.json +8 -0
  68. package/esm/locales/it.json +8 -0
  69. package/esm/styles.css +6 -4
  70. package/package.json +1 -1
  71. package/src/components/BlockedMemoriBadge/__snapshots__/BlockedMemoriBadge.test.tsx.snap +10 -0
  72. package/src/components/CompletionProviderStatus/CompletionProviderStatus.css +33 -23
  73. package/src/components/CompletionProviderStatus/CompletionProviderStatus.stories.tsx +274 -21
  74. package/src/components/CompletionProviderStatus/CompletionProviderStatus.tsx +117 -21
  75. package/src/components/CompletionProviderStatus/__snapshots__/CompletionProviderStatus.test.tsx.snap +39 -21
  76. package/src/components/Header/Header.css +1 -1
  77. package/src/components/KnownFacts/KnownFacts.tsx +1 -1
  78. package/src/components/StartPanel/__snapshots__/StartPanel.test.tsx.snap +13 -7
  79. package/src/components/Typing/Typing.tsx +52 -47
  80. package/src/components/icons/Alert.tsx +31 -0
  81. package/src/components/icons/Info.tsx +31 -0
  82. package/src/components/icons/Warning.tsx +2 -1
  83. package/src/components/ui/ConfirmDialog.css +42 -0
  84. package/src/components/ui/ConfirmDialog.stories.tsx +216 -0
  85. package/src/components/ui/ConfirmDialog.test.tsx +124 -0
  86. package/src/components/ui/ConfirmDialog.tsx +58 -0
  87. package/src/components/ui/Drawer.css +121 -96
  88. package/src/components/ui/Drawer.stories.tsx +152 -67
  89. package/src/components/ui/Drawer.test.tsx +6 -2
  90. package/src/components/ui/Drawer.tsx +195 -89
  91. package/src/components/ui/__snapshots__/ConfirmDialog.test.tsx.snap +35 -0
  92. package/src/helpers/error.ts +1 -0
  93. package/src/index.tsx +1 -1
  94. package/src/locales/de.json +8 -0
  95. package/src/locales/en.json +8 -0
  96. package/src/locales/es.json +19 -11
  97. package/src/locales/fr.json +8 -0
  98. package/src/locales/it.json +8 -0
  99. 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
- position: relative;
3
- z-index: 10000;
2
+ position: relative;
3
+ z-index: 1001;
4
4
  }
5
5
 
6
6
  .memori-drawer--backdrop {
7
- position: fixed;
8
- z-index: 40;
9
- top: 0;
10
- left: 0;
11
- width: 100%;
12
- height: 100%;
13
- background-color: rgba(0, 0, 0, 0.3);
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
- position: fixed;
18
- z-index: 50;
19
- top: 0;
20
- right: 0;
21
- bottom: 0;
22
- left: 0;
23
- overflow-y: auto;
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
- display: flex;
28
- min-height: 100%;
29
- align-items: center;
30
- justify-content: center;
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
- position: relative;
35
- width: var(--memori-drawer--width, 100%);
36
- max-width: 80vw;
37
- height: 100%;
38
- min-height: 100vh;
39
- box-sizing: border-box;
40
- padding: 1rem 1.5rem 1.5rem;
41
- margin-right: 0;
42
- margin-left: auto;
43
- background-color: #fff;
44
- font-family: var(--memori-font-family);
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
- .memori-drawer--panel {
49
- width: var(--memori-drawer--width--md, 80%);
50
- max-width: none;
51
- padding-top: 1.5rem;
52
- padding-right: 2rem;
53
- padding-left: 2rem;
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
- .memori-drawer--panel {
59
- width: var(--memori-drawer--width--lg, 60%);
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
- padding-bottom: 0;
66
+ padding-bottom: 0;
65
67
  }
66
68
 
67
69
  .memori-drawer--panel .memori-spin {
68
- display: flex;
69
- width: 100%;
70
- height: 100%;
71
- flex-direction: column;
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>.memori-spin {
75
- margin-top: -1.75rem;
78
+ .memori-drawer--panel > .memori-spin {
79
+ margin-top: -1.75rem;
76
80
  }
77
81
 
78
82
  .memori-drawer--panel p {
79
- margin: 0 0 1em;
83
+ margin: 0 0 1em;
80
84
  }
81
85
 
82
86
  h2.memori-drawer--title {
83
- margin: 0 0 1rem;
84
- font-size: 1.5rem;
85
- font-weight: 700;
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
- margin-right: auto;
90
- margin-left: 0;
93
+ margin-right: auto;
94
+ margin-left: 0;
91
95
  }
92
96
 
93
97
  .memori-drawer--close {
94
- position: sticky;
95
- z-index: 70;
96
- top: 0;
97
- left: 0;
98
- padding: 0.5rem;
99
- margin-top: -1.5rem;
100
- margin-left: -5.5rem;
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
- .memori-drawer--close {
105
- left: 0.5rem;
106
- }
108
+ .memori-drawer--close {
109
+ left: 0.5rem;
110
+ }
107
111
  }
108
112
 
109
113
  .memori-drawer--close button {
110
- border-color: #fff;
111
- color: #fff;
114
+ border-color: #fff;
115
+ color: #fff;
112
116
  }
113
117
 
114
118
  @media (max-width: 767px) {
115
- .memori-drawer--close button {
116
- color: #000;
117
- }
119
+ .memori-drawer--close button {
120
+ color: #000;
121
+ }
118
122
  }
119
123
 
120
124
  .memori-drawer--panel-left .memori-drawer--close {
121
- right: -3.5rem;
122
- left: auto;
125
+ right: -3.5rem;
126
+ left: auto;
123
127
  }
124
128
 
125
129
  @media (max-width: 767px) {
126
- .memori-drawer--panel-left .memori-drawer--close {
127
- right: 0.5rem;
128
- left: auto;
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
- position: sticky;
134
- bottom: 0;
135
- left: 0;
136
- display: flex;
137
- width: 100%;
138
- justify-content: flex-end;
139
- padding-top: 1rem;
140
- padding-bottom: 1rem;
141
- border-top: 1px solid rgba(0, 0, 0, 0.25);
142
- margin-top: auto;
143
- background-color: #fff;
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
- margin-left: 0.5em;
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
- transition-timing-function: ease-out;
176
+ transition-timing-function: ease-out;
152
177
  }
153
178
 
154
179
  .ease-in {
155
- transition-timing-function: ease-in;
180
+ transition-timing-function: ease-in;
156
181
  }
157
182
 
158
183
  .duration-300 {
159
- transition-duration: 300ms;
184
+ transition-duration: 300ms;
160
185
  }
161
186
 
162
187
  .duration-200 {
163
- transition-duration: 200ms;
188
+ transition-duration: 200ms;
164
189
  }
165
190
 
166
191
  .opacity-0 {
167
- opacity: 0;
192
+ opacity: 0;
168
193
  }
169
194
 
170
195
  .opacity-100 {
171
- opacity: 1;
196
+ opacity: 1;
172
197
  }
173
198
 
174
199
  .max-w-0 {
175
- max-width: 0;
200
+ max-width: 0;
176
201
  }
177
202
 
178
203
  .max-w-80 {
179
- max-width: 80%;
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
- side: {
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
- const footer = (
83
- <>
84
- <Button primary>OK</Button>
85
- <Button>Cancel</Button>
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 TemplateWithALotOfContent: Story<Props> = args => {
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)}>Click me</Button>
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
- // By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
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 WithFooter = Template.bind({});
163
- WithFooter.args = {
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 SideLeft = Template.bind({});
171
- SideLeft.args = {
145
+ export const PlacementLeft = Template.bind({});
146
+ PlacementLeft.args = {
172
147
  open: true,
173
- side: 'left',
148
+ placement: 'left',
149
+ title: 'Left Drawer',
174
150
  };
175
151
 
176
- export const WithALotOfContent = TemplateWithALotOfContent.bind({});
177
- WithALotOfContent.args = {
152
+ export const CustomWidth = Template.bind({});
153
+ CustomWidth.args = {
178
154
  open: true,
179
- title: 'Drawer Title',
180
- description: 'Drawer Description',
181
- footer,
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={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()} side="left">
110
+ <Drawer open={true} onClose={jest.fn()} placement="left">
107
111
  {content}
108
112
  </Drawer>
109
113
  );