@memori.ai/ui 1.0.0-alpha
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 +105 -0
- package/dist/components/Alert/Alert.d.ts +18 -0
- package/dist/components/Alert/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +27 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/ButtonBase/ButtonBase.d.ts +28 -0
- package/dist/components/ButtonBase/index.d.ts +3 -0
- package/dist/components/Card/Card.d.ts +13 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +11 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +12 -0
- package/dist/components/ConfirmDialog/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.d.ts +32 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/Dropdown/Dropdown.d.ts +11 -0
- package/dist/components/Dropdown/index.d.ts +2 -0
- package/dist/components/Expandable/Expandable.d.ts +15 -0
- package/dist/components/Expandable/helpers.d.ts +3 -0
- package/dist/components/Expandable/index.d.ts +2 -0
- package/dist/components/InputBase/InputBase.d.ts +49 -0
- package/dist/components/InputBase/index.d.ts +3 -0
- package/dist/components/Modal/Modal.d.ts +16 -0
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +16 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Slider/Slider.d.ts +12 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Spin/Spin.d.ts +9 -0
- package/dist/components/Spin/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/i18n/I18nWrapper.d.ts +6 -0
- package/dist/icons/AI.d.ts +5 -0
- package/dist/icons/Alert.d.ts +5 -0
- package/dist/icons/ArrowUp.d.ts +5 -0
- package/dist/icons/Bug.d.ts +5 -0
- package/dist/icons/Chat.d.ts +5 -0
- package/dist/icons/ChevronDown.d.ts +5 -0
- package/dist/icons/ChevronLeft.d.ts +5 -0
- package/dist/icons/ChevronRight.d.ts +5 -0
- package/dist/icons/ChevronUp.d.ts +5 -0
- package/dist/icons/Clear.d.ts +5 -0
- package/dist/icons/Close.d.ts +6 -0
- package/dist/icons/Code.d.ts +5 -0
- package/dist/icons/Copy.d.ts +5 -0
- package/dist/icons/DeepThought.d.ts +5 -0
- package/dist/icons/Delete.d.ts +5 -0
- package/dist/icons/Document.d.ts +5 -0
- package/dist/icons/Download.d.ts +5 -0
- package/dist/icons/Edit.d.ts +5 -0
- package/dist/icons/Expand.d.ts +5 -0
- package/dist/icons/Eye.d.ts +5 -0
- package/dist/icons/EyeInvisible.d.ts +5 -0
- package/dist/icons/Facebook.d.ts +5 -0
- package/dist/icons/Feedback.d.ts +5 -0
- package/dist/icons/File.d.ts +5 -0
- package/dist/icons/FileExcel.d.ts +5 -0
- package/dist/icons/FilePdf.d.ts +5 -0
- package/dist/icons/FileWord.d.ts +5 -0
- package/dist/icons/Fullscreen.d.ts +5 -0
- package/dist/icons/FullscreenExit.d.ts +5 -0
- package/dist/icons/Group.d.ts +5 -0
- package/dist/icons/History.d.ts +6 -0
- package/dist/icons/Image.d.ts +4 -0
- package/dist/icons/Info.d.ts +5 -0
- package/dist/icons/Link.d.ts +5 -0
- package/dist/icons/Linkedin.d.ts +5 -0
- package/dist/icons/Loading.d.ts +6 -0
- package/dist/icons/Logout.d.ts +5 -0
- package/dist/icons/Mail.d.ts +5 -0
- package/dist/icons/MapMarker.d.ts +5 -0
- package/dist/icons/MenuHorizontal.d.ts +6 -0
- package/dist/icons/MenuVertical.d.ts +6 -0
- package/dist/icons/Message.d.ts +5 -0
- package/dist/icons/Microphone.d.ts +5 -0
- package/dist/icons/Minus.d.ts +5 -0
- package/dist/icons/MinusCircle.d.ts +5 -0
- package/dist/icons/PaperClip.d.ts +5 -0
- package/dist/icons/Picture.d.ts +5 -0
- package/dist/icons/Plus.d.ts +5 -0
- package/dist/icons/Preview.d.ts +4 -0
- package/dist/icons/Print.d.ts +6 -0
- package/dist/icons/QuestionHelp.d.ts +5 -0
- package/dist/icons/Refresh.d.ts +5 -0
- package/dist/icons/SelectIcon.d.ts +5 -0
- package/dist/icons/Send.d.ts +5 -0
- package/dist/icons/Setting.d.ts +5 -0
- package/dist/icons/Share.d.ts +5 -0
- package/dist/icons/Sound.d.ts +5 -0
- package/dist/icons/SoundDeactivated.d.ts +5 -0
- package/dist/icons/Telegram.d.ts +5 -0
- package/dist/icons/ThumbDown.d.ts +5 -0
- package/dist/icons/ThumbUp.d.ts +5 -0
- package/dist/icons/Translation.d.ts +5 -0
- package/dist/icons/Twitter.d.ts +5 -0
- package/dist/icons/Upload.d.ts +4 -0
- package/dist/icons/User.d.ts +5 -0
- package/dist/icons/Warning.d.ts +5 -0
- package/dist/icons/WhatsApp.d.ts +5 -0
- package/dist/index.d.ts +13 -0
- package/dist/memori-ai-ui.css +2 -0
- package/dist/memori-ai-ui.es.js +6400 -0
- package/dist/memori-ai-ui.umd.js +23 -0
- package/package.json +97 -0
- package/src/components/Alert/Alert.css +95 -0
- package/src/components/Alert/Alert.stories.tsx +156 -0
- package/src/components/Alert/Alert.test.tsx +122 -0
- package/src/components/Alert/Alert.tsx +124 -0
- package/src/components/Alert/__snapshots__/Alert.test.tsx.snap +67 -0
- package/src/components/Alert/index.tsx +2 -0
- package/src/components/Button/Button.css +173 -0
- package/src/components/Button/Button.stories.tsx +173 -0
- package/src/components/Button/Button.test.tsx +80 -0
- package/src/components/Button/Button.tsx +104 -0
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +204 -0
- package/src/components/Button/index.tsx +2 -0
- package/src/components/ButtonBase/ButtonBase.stories.tsx +194 -0
- package/src/components/ButtonBase/ButtonBase.tsx +84 -0
- package/src/components/ButtonBase/index.tsx +3 -0
- package/src/components/ButtonBase/styles.module.css +135 -0
- package/src/components/Card/Card.css +67 -0
- package/src/components/Card/Card.stories.tsx +104 -0
- package/src/components/Card/Card.test.tsx +67 -0
- package/src/components/Card/Card.tsx +58 -0
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +321 -0
- package/src/components/Card/index.tsx +2 -0
- package/src/components/Checkbox/Checkbox.css +114 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +77 -0
- package/src/components/Checkbox/Checkbox.test.tsx +50 -0
- package/src/components/Checkbox/Checkbox.tsx +61 -0
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +131 -0
- package/src/components/Checkbox/index.tsx +2 -0
- package/src/components/ConfirmDialog/ConfirmDialog.css +44 -0
- package/src/components/ConfirmDialog/ConfirmDialog.stories.tsx +235 -0
- package/src/components/ConfirmDialog/ConfirmDialog.test.tsx +129 -0
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +73 -0
- package/src/components/ConfirmDialog/__snapshots__/ConfirmDialog.test.tsx.snap +11 -0
- package/src/components/ConfirmDialog/index.tsx +2 -0
- package/src/components/Details/Details.css +66 -0
- package/src/components/Details/Details.stories.tsx +67 -0
- package/src/components/Drawer/Drawer.css +210 -0
- package/src/components/Drawer/Drawer.stories.tsx +275 -0
- package/src/components/Drawer/Drawer.test.tsx +158 -0
- package/src/components/Drawer/Drawer.tsx +242 -0
- package/src/components/Drawer/__snapshots__/Drawer.test.tsx.snap +21 -0
- package/src/components/Drawer/index.tsx +2 -0
- package/src/components/Dropdown/Dropdown.css +177 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +73 -0
- package/src/components/Dropdown/Dropdown.test.tsx +88 -0
- package/src/components/Dropdown/Dropdown.tsx +88 -0
- package/src/components/Dropdown/__snapshots__/Dropdown.test.tsx.snap +141 -0
- package/src/components/Dropdown/index.tsx +2 -0
- package/src/components/Expandable/Expandable.css +15 -0
- package/src/components/Expandable/Expandable.stories.tsx +196 -0
- package/src/components/Expandable/Expandable.test.tsx +143 -0
- package/src/components/Expandable/Expandable.tsx +122 -0
- package/src/components/Expandable/__snapshots__/Expandable.test.tsx.snap +199 -0
- package/src/components/Expandable/helpers.ts +16 -0
- package/src/components/Expandable/index.tsx +2 -0
- package/src/components/InputBase/InputBase.stories.tsx +237 -0
- package/src/components/InputBase/InputBase.tsx +105 -0
- package/src/components/InputBase/index.tsx +3 -0
- package/src/components/InputBase/styles.module.css +96 -0
- package/src/components/Modal/Modal.css +95 -0
- package/src/components/Modal/Modal.stories.tsx +184 -0
- package/src/components/Modal/Modal.test.tsx +129 -0
- package/src/components/Modal/Modal.tsx +124 -0
- package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +17 -0
- package/src/components/Modal/index.tsx +2 -0
- package/src/components/Select/Select.css +134 -0
- package/src/components/Select/Select.stories.tsx +85 -0
- package/src/components/Select/Select.test.tsx +85 -0
- package/src/components/Select/Select.tsx +84 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +261 -0
- package/src/components/Select/index.tsx +2 -0
- package/src/components/Slider/Slider.css +194 -0
- package/src/components/Slider/Slider.stories.tsx +85 -0
- package/src/components/Slider/Slider.test.tsx +55 -0
- package/src/components/Slider/Slider.tsx +157 -0
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +419 -0
- package/src/components/Slider/index.tsx +2 -0
- package/src/components/Spin/Spin.css +31 -0
- package/src/components/Spin/Spin.stories.tsx +65 -0
- package/src/components/Spin/Spin.test.tsx +47 -0
- package/src/components/Spin/Spin.tsx +34 -0
- package/src/components/Spin/__snapshots__/Spin.test.tsx.snap +193 -0
- package/src/components/Spin/index.tsx +2 -0
- package/src/components/Table/Table.css +130 -0
- package/src/components/Table/Table.stories.tsx +274 -0
- package/src/components/Tooltip/Tooltip.css +160 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +136 -0
- package/src/components/Tooltip/Tooltip.test.tsx +110 -0
- package/src/components/Tooltip/Tooltip.tsx +46 -0
- package/src/components/Tooltip/__snapshots__/Tooltip.test.tsx.snap +163 -0
- package/src/components/Tooltip/index.tsx +2 -0
- package/src/components/definitions.stories.tsx +150 -0
- package/src/i18n/I18nWrapper.tsx +13 -0
- package/src/i18n/i18n.ts +34 -0
- package/src/icons/AI.tsx +38 -0
- package/src/icons/Alert.tsx +31 -0
- package/src/icons/ArrowUp.tsx +28 -0
- package/src/icons/Bug.tsx +81 -0
- package/src/icons/Chat.tsx +30 -0
- package/src/icons/ChevronDown.tsx +26 -0
- package/src/icons/ChevronLeft.tsx +28 -0
- package/src/icons/ChevronRight.tsx +28 -0
- package/src/icons/ChevronUp.tsx +24 -0
- package/src/icons/Clear.tsx +23 -0
- package/src/icons/Close.tsx +30 -0
- package/src/icons/Code.tsx +30 -0
- package/src/icons/Copy.tsx +30 -0
- package/src/icons/DeepThought.tsx +38 -0
- package/src/icons/Delete.tsx +23 -0
- package/src/icons/Document.tsx +52 -0
- package/src/icons/Download.tsx +23 -0
- package/src/icons/Edit.tsx +17 -0
- package/src/icons/Expand.tsx +23 -0
- package/src/icons/Eye.tsx +17 -0
- package/src/icons/EyeInvisible.tsx +24 -0
- package/src/icons/Facebook.tsx +23 -0
- package/src/icons/Feedback.tsx +27 -0
- package/src/icons/File.tsx +17 -0
- package/src/icons/FileExcel.tsx +23 -0
- package/src/icons/FilePdf.tsx +23 -0
- package/src/icons/FileWord.tsx +23 -0
- package/src/icons/Fullscreen.tsx +23 -0
- package/src/icons/FullscreenExit.tsx +23 -0
- package/src/icons/Group.tsx +30 -0
- package/src/icons/History.tsx +33 -0
- package/src/icons/Image.tsx +37 -0
- package/src/icons/Info.tsx +37 -0
- package/src/icons/Link.tsx +17 -0
- package/src/icons/Linkedin.tsx +23 -0
- package/src/icons/Loading.tsx +28 -0
- package/src/icons/Logout.tsx +33 -0
- package/src/icons/Mail.tsx +17 -0
- package/src/icons/MapMarker.tsx +26 -0
- package/src/icons/MenuHorizontal.tsx +29 -0
- package/src/icons/MenuVertical.tsx +29 -0
- package/src/icons/Message.tsx +23 -0
- package/src/icons/Microphone.tsx +23 -0
- package/src/icons/Minus.tsx +23 -0
- package/src/icons/MinusCircle.tsx +24 -0
- package/src/icons/PaperClip.tsx +23 -0
- package/src/icons/Picture.tsx +23 -0
- package/src/icons/Plus.tsx +18 -0
- package/src/icons/Preview.tsx +31 -0
- package/src/icons/Print.tsx +37 -0
- package/src/icons/QuestionHelp.tsx +34 -0
- package/src/icons/Refresh.tsx +30 -0
- package/src/icons/SelectIcon.tsx +28 -0
- package/src/icons/Send.tsx +17 -0
- package/src/icons/Setting.tsx +23 -0
- package/src/icons/Share.tsx +23 -0
- package/src/icons/Sound.tsx +23 -0
- package/src/icons/SoundDeactivated.tsx +27 -0
- package/src/icons/Telegram.tsx +26 -0
- package/src/icons/ThumbDown.tsx +29 -0
- package/src/icons/ThumbUp.tsx +29 -0
- package/src/icons/Translation.tsx +24 -0
- package/src/icons/Twitter.tsx +23 -0
- package/src/icons/Upload.tsx +34 -0
- package/src/icons/User.tsx +17 -0
- package/src/icons/Warning.tsx +27 -0
- package/src/icons/WhatsApp.tsx +24 -0
- package/src/icons/icons.stories.css +5 -0
- package/src/icons/icons.stories.tsx +110 -0
- package/src/icons/loading.css +14 -0
- package/src/index.ts +15 -0
- package/src/styles/utils.css +17 -0
- package/src/styles.css +4 -0
- package/src/theme/variables.css +110 -0
- package/src/vite-env.d.ts +6 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
.memori-modal {
|
|
2
|
+
position: relative;
|
|
3
|
+
z-index: 1000;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.memori-modal--backdrop {
|
|
7
|
+
position: fixed;
|
|
8
|
+
z-index: 40;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background-color: rgb(0 0 0 / 30%);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.memori-modal--container {
|
|
17
|
+
position: fixed;
|
|
18
|
+
z-index: 50;
|
|
19
|
+
inset: 0;
|
|
20
|
+
overflow-y: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.memori-modal--container-scrollable {
|
|
24
|
+
display: flex;
|
|
25
|
+
min-height: 100%;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.memori-modal--panel {
|
|
31
|
+
position: relative;
|
|
32
|
+
max-width: var(--memori-modal--width, 100%);
|
|
33
|
+
padding: 1.5rem;
|
|
34
|
+
border-radius: 10px;
|
|
35
|
+
margin-right: auto;
|
|
36
|
+
margin-left: auto;
|
|
37
|
+
background-color: #fff;
|
|
38
|
+
font-family: var(--memori-font-family);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@media (width >= 768px) {
|
|
42
|
+
.memori-modal--panel {
|
|
43
|
+
max-width: var(--memori-modal--width-md, 80%);
|
|
44
|
+
padding: 2rem 3rem;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.memori-modal--footer {
|
|
49
|
+
display: flex;
|
|
50
|
+
justify-content: flex-end;
|
|
51
|
+
margin-top: 1.5rem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.memori-modal--footer button + button {
|
|
55
|
+
margin-left: 0.5em;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.memori-modal--close {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 0;
|
|
61
|
+
right: 0;
|
|
62
|
+
padding: 0.5rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ease-out {
|
|
66
|
+
transition-timing-function: ease-out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ease-in {
|
|
70
|
+
transition-timing-function: ease-in;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.duration-300 {
|
|
74
|
+
transition-duration: 300ms;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.duration-200 {
|
|
78
|
+
transition-duration: 200ms;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.opacity-0 {
|
|
82
|
+
opacity: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.opacity-100 {
|
|
86
|
+
opacity: 1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.scale-95 {
|
|
90
|
+
transform: scale(0.95);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.scale-100 {
|
|
94
|
+
transform: scale(1);
|
|
95
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
3
|
+
import Modal, { type Props } from './Modal'
|
|
4
|
+
import Button from '../Button/Button'
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'UI/Modal',
|
|
8
|
+
component: Modal,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
title: {
|
|
12
|
+
control: {
|
|
13
|
+
type: 'text',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
description: {
|
|
17
|
+
control: {
|
|
18
|
+
type: 'text',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
loading: {
|
|
22
|
+
control: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
open: {
|
|
27
|
+
control: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
className: {
|
|
32
|
+
control: {
|
|
33
|
+
type: 'text',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
parameters: {
|
|
38
|
+
controls: { expanded: true },
|
|
39
|
+
},
|
|
40
|
+
render: (args: Props) => {
|
|
41
|
+
const [isOpen, setIsOpen] = React.useState(!!args.open || false)
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<Button onClick={() => setIsOpen(true)}>Click me</Button>
|
|
46
|
+
<Modal
|
|
47
|
+
{...args}
|
|
48
|
+
open={isOpen}
|
|
49
|
+
onClose={args.closable ? () => setIsOpen(false) : () => {}}
|
|
50
|
+
footer={args.footer}
|
|
51
|
+
>
|
|
52
|
+
{content}
|
|
53
|
+
</Modal>
|
|
54
|
+
</>
|
|
55
|
+
)
|
|
56
|
+
},
|
|
57
|
+
} satisfies Meta<typeof Modal>
|
|
58
|
+
|
|
59
|
+
export default meta
|
|
60
|
+
|
|
61
|
+
type Story = StoryObj<typeof meta>
|
|
62
|
+
|
|
63
|
+
const content = (
|
|
64
|
+
<>
|
|
65
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
|
66
|
+
<h3>Suspendisse a sodales nulla, sed semper nisi.</h3>
|
|
67
|
+
<p>Proin tincidunt enim in felis aliquet, a ultricies purus bibendum.</p>
|
|
68
|
+
<ul>
|
|
69
|
+
<li>Quisque in ultrices lectus.</li>
|
|
70
|
+
<li>Quisque in ultrices lectus.</li>
|
|
71
|
+
<li>Quisque in ultrices lectus.</li>
|
|
72
|
+
</ul>
|
|
73
|
+
<p>Nulla at urna diam.</p>
|
|
74
|
+
</>
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
const footer = (
|
|
78
|
+
<>
|
|
79
|
+
<Button primary>OK</Button>
|
|
80
|
+
<Button>Cancel</Button>
|
|
81
|
+
</>
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
const footerNonClosableModal = <Button primary>OK</Button>
|
|
85
|
+
|
|
86
|
+
export const Default: Story = {
|
|
87
|
+
args: {
|
|
88
|
+
open: false,
|
|
89
|
+
closable: true,
|
|
90
|
+
onClose: () => {},
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const Open: Story = {
|
|
95
|
+
args: {
|
|
96
|
+
open: true,
|
|
97
|
+
closable: true,
|
|
98
|
+
onClose: () => {},
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const WithTitle: Story = {
|
|
103
|
+
args: {
|
|
104
|
+
open: true,
|
|
105
|
+
closable: true,
|
|
106
|
+
onClose: () => {},
|
|
107
|
+
title: 'Modal Title',
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const WithTitleAndDescription: Story = {
|
|
112
|
+
args: {
|
|
113
|
+
open: true,
|
|
114
|
+
closable: true,
|
|
115
|
+
onClose: () => {},
|
|
116
|
+
title: 'Modal Title',
|
|
117
|
+
description: 'Modal Description',
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export const Loading: Story = {
|
|
122
|
+
args: {
|
|
123
|
+
open: true,
|
|
124
|
+
closable: true,
|
|
125
|
+
onClose: () => {},
|
|
126
|
+
title: 'Modal Title',
|
|
127
|
+
description: 'Modal Description',
|
|
128
|
+
loading: true,
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const WithFooter: Story = {
|
|
133
|
+
args: {
|
|
134
|
+
open: true,
|
|
135
|
+
closable: true,
|
|
136
|
+
onClose: () => {},
|
|
137
|
+
title: 'Modal Title',
|
|
138
|
+
description: 'Modal Description',
|
|
139
|
+
footer,
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const NonClosable: Story = {
|
|
144
|
+
args: {
|
|
145
|
+
open: true,
|
|
146
|
+
closable: false,
|
|
147
|
+
onClose: () => {},
|
|
148
|
+
title: 'Modal Title',
|
|
149
|
+
description: 'Modal Description',
|
|
150
|
+
footer: footerNonClosableModal,
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const WithALotOfContent: Story = {
|
|
155
|
+
args: {
|
|
156
|
+
open: true,
|
|
157
|
+
closable: true,
|
|
158
|
+
onClose: () => {},
|
|
159
|
+
title: 'Modal Title',
|
|
160
|
+
description: 'Modal Description',
|
|
161
|
+
footer,
|
|
162
|
+
},
|
|
163
|
+
render: (args: Props) => {
|
|
164
|
+
const [isOpen, setIsOpen] = React.useState(!!args.open || false)
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<>
|
|
168
|
+
<Button onClick={() => setIsOpen(true)}>Click me</Button>
|
|
169
|
+
<Modal
|
|
170
|
+
{...args}
|
|
171
|
+
open={isOpen}
|
|
172
|
+
onClose={args.closable ? () => setIsOpen(false) : () => {}}
|
|
173
|
+
footer={args.footer}
|
|
174
|
+
>
|
|
175
|
+
{content}
|
|
176
|
+
{content}
|
|
177
|
+
{content}
|
|
178
|
+
{content}
|
|
179
|
+
{content}
|
|
180
|
+
</Modal>
|
|
181
|
+
</>
|
|
182
|
+
)
|
|
183
|
+
},
|
|
184
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { expect, it, vi } from 'vitest'
|
|
3
|
+
import { render } from '@testing-library/react'
|
|
4
|
+
import Modal from './Modal'
|
|
5
|
+
import Button from '../Button/Button'
|
|
6
|
+
|
|
7
|
+
const content = (
|
|
8
|
+
<>
|
|
9
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
|
10
|
+
<h3>Suspendisse a sodales nulla, sed semper nisi.</h3>
|
|
11
|
+
<p>Proin tincidunt enim in felis aliquet, a ultricies purus bibendum.</p>
|
|
12
|
+
<ul>
|
|
13
|
+
<li>Quisque in ultrices lectus.</li>
|
|
14
|
+
<li>Quisque in ultrices lectus.</li>
|
|
15
|
+
<li>Quisque in ultrices lectus.</li>
|
|
16
|
+
</ul>
|
|
17
|
+
<p>Nulla at urna diam.</p>
|
|
18
|
+
</>
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const footer = (
|
|
22
|
+
<>
|
|
23
|
+
<Button primary>Ok</Button>
|
|
24
|
+
<Button>Cancel</Button>
|
|
25
|
+
</>
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
it('renders Modal unchanged', () => {
|
|
29
|
+
const { container } = render(
|
|
30
|
+
<Modal
|
|
31
|
+
open={false}
|
|
32
|
+
onClose={vi.fn()}
|
|
33
|
+
>
|
|
34
|
+
{content}
|
|
35
|
+
</Modal>,
|
|
36
|
+
)
|
|
37
|
+
expect(container).toMatchSnapshot()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('renders Modal open unchanged', () => {
|
|
41
|
+
const { container } = render(
|
|
42
|
+
<Modal
|
|
43
|
+
open={true}
|
|
44
|
+
onClose={vi.fn()}
|
|
45
|
+
>
|
|
46
|
+
{content}
|
|
47
|
+
</Modal>,
|
|
48
|
+
)
|
|
49
|
+
expect(container).toMatchSnapshot()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('renders Modal with title unchanged', () => {
|
|
53
|
+
const { container } = render(
|
|
54
|
+
<Modal
|
|
55
|
+
open={true}
|
|
56
|
+
onClose={vi.fn()}
|
|
57
|
+
title="Lorem ipsum"
|
|
58
|
+
>
|
|
59
|
+
{content}
|
|
60
|
+
</Modal>,
|
|
61
|
+
)
|
|
62
|
+
expect(container).toMatchSnapshot()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('renders Modal with description unchanged', () => {
|
|
66
|
+
const { container } = render(
|
|
67
|
+
<Modal
|
|
68
|
+
open={true}
|
|
69
|
+
onClose={vi.fn()}
|
|
70
|
+
description="Lorem ipsum dolor sit amet"
|
|
71
|
+
>
|
|
72
|
+
{content}
|
|
73
|
+
</Modal>,
|
|
74
|
+
)
|
|
75
|
+
expect(container).toMatchSnapshot()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('renders Modal loading unchanged', () => {
|
|
79
|
+
const { container } = render(
|
|
80
|
+
<Modal
|
|
81
|
+
open={true}
|
|
82
|
+
onClose={vi.fn()}
|
|
83
|
+
loading
|
|
84
|
+
>
|
|
85
|
+
{content}
|
|
86
|
+
</Modal>,
|
|
87
|
+
)
|
|
88
|
+
expect(container).toMatchSnapshot()
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('renders Modal with footer unchanged', () => {
|
|
92
|
+
const { container } = render(
|
|
93
|
+
<Modal
|
|
94
|
+
open={true}
|
|
95
|
+
onClose={vi.fn()}
|
|
96
|
+
footer={footer}
|
|
97
|
+
>
|
|
98
|
+
{content}
|
|
99
|
+
</Modal>,
|
|
100
|
+
)
|
|
101
|
+
expect(container).toMatchSnapshot()
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('renders Modal non closable unchanged', () => {
|
|
105
|
+
const { container } = render(
|
|
106
|
+
<Modal
|
|
107
|
+
open={true}
|
|
108
|
+
onClose={vi.fn()}
|
|
109
|
+
closable={false}
|
|
110
|
+
>
|
|
111
|
+
{content}
|
|
112
|
+
</Modal>,
|
|
113
|
+
)
|
|
114
|
+
expect(container).toMatchSnapshot()
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('renders Modal with custom widths unchanged', () => {
|
|
118
|
+
const { container } = render(
|
|
119
|
+
<Modal
|
|
120
|
+
open={true}
|
|
121
|
+
onClose={vi.fn()}
|
|
122
|
+
width="100%"
|
|
123
|
+
widthMd="90%"
|
|
124
|
+
>
|
|
125
|
+
{content}
|
|
126
|
+
</Modal>,
|
|
127
|
+
)
|
|
128
|
+
expect(container).toMatchSnapshot()
|
|
129
|
+
})
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { FC, JSX } from 'react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { Dialog, Transition } from '@headlessui/react'
|
|
4
|
+
import Spin from '../Spin/Spin'
|
|
5
|
+
import Button from '../Button/Button'
|
|
6
|
+
import Close from '../../icons/Close'
|
|
7
|
+
import { useTranslation } from 'react-i18next'
|
|
8
|
+
import cx from 'classnames'
|
|
9
|
+
|
|
10
|
+
import './Modal.css'
|
|
11
|
+
|
|
12
|
+
export interface Props {
|
|
13
|
+
open?: boolean
|
|
14
|
+
onClose: (value: boolean) => void
|
|
15
|
+
className?: string
|
|
16
|
+
title?: string | JSX.Element | React.ReactNode
|
|
17
|
+
description?: string | JSX.Element | React.ReactNode
|
|
18
|
+
children?: JSX.Element | React.ReactNode
|
|
19
|
+
footer?: JSX.Element | React.ReactNode
|
|
20
|
+
loading?: boolean
|
|
21
|
+
closable?: boolean
|
|
22
|
+
width?: string
|
|
23
|
+
widthMd?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const Modal: FC<Props> = ({
|
|
27
|
+
open = false,
|
|
28
|
+
onClose,
|
|
29
|
+
className,
|
|
30
|
+
title,
|
|
31
|
+
description,
|
|
32
|
+
children,
|
|
33
|
+
footer,
|
|
34
|
+
loading = false,
|
|
35
|
+
closable = true,
|
|
36
|
+
width = '100%',
|
|
37
|
+
widthMd = '100%',
|
|
38
|
+
}: Props) => {
|
|
39
|
+
const { t } = useTranslation()
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Transition
|
|
43
|
+
appear
|
|
44
|
+
show={open}
|
|
45
|
+
as={React.Fragment}
|
|
46
|
+
>
|
|
47
|
+
<Dialog
|
|
48
|
+
open={open}
|
|
49
|
+
onClose={onClose}
|
|
50
|
+
className={cx('memori-modal', className)}
|
|
51
|
+
>
|
|
52
|
+
<Transition.Child
|
|
53
|
+
as={React.Fragment}
|
|
54
|
+
enter="ease-out duration-300"
|
|
55
|
+
enterFrom="opacity-0"
|
|
56
|
+
enterTo="opacity-100"
|
|
57
|
+
leave="ease-in duration-200"
|
|
58
|
+
leaveFrom="opacity-100"
|
|
59
|
+
leaveTo="opacity-0"
|
|
60
|
+
>
|
|
61
|
+
<div className="memori-modal--backdrop" />
|
|
62
|
+
</Transition.Child>
|
|
63
|
+
<div className="memori-modal--container">
|
|
64
|
+
<div className="memori-modal--container-scrollable">
|
|
65
|
+
<Transition.Child
|
|
66
|
+
as={React.Fragment}
|
|
67
|
+
enter="ease-out duration-300"
|
|
68
|
+
enterFrom="opacity-0 scale-95"
|
|
69
|
+
enterTo="opacity-100 scale-100"
|
|
70
|
+
leave="ease-in duration-200"
|
|
71
|
+
leaveFrom="opacity-100 scale-100"
|
|
72
|
+
leaveTo="opacity-0 scale-95"
|
|
73
|
+
>
|
|
74
|
+
<Dialog.Panel className="memori-modal--panel">
|
|
75
|
+
<style
|
|
76
|
+
dangerouslySetInnerHTML={{
|
|
77
|
+
__html: `
|
|
78
|
+
.memori-modal--panel {
|
|
79
|
+
--memori-modal--width: ${width};
|
|
80
|
+
--memori-modal--width-md: ${widthMd};
|
|
81
|
+
}
|
|
82
|
+
`,
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
{closable && (
|
|
86
|
+
<div className="memori-modal--close">
|
|
87
|
+
<Button
|
|
88
|
+
ghost
|
|
89
|
+
padded
|
|
90
|
+
shape="circle"
|
|
91
|
+
icon={<Close />}
|
|
92
|
+
title={t('close') || 'Close'}
|
|
93
|
+
onClick={() => onClose(false)}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
<Spin spinning={loading}>
|
|
98
|
+
{title && (
|
|
99
|
+
<Dialog.Title className="memori-modal--title">
|
|
100
|
+
{title}
|
|
101
|
+
</Dialog.Title>
|
|
102
|
+
)}
|
|
103
|
+
{description && (
|
|
104
|
+
<Dialog.Description className="memori-modal--description">
|
|
105
|
+
{description}
|
|
106
|
+
</Dialog.Description>
|
|
107
|
+
)}
|
|
108
|
+
|
|
109
|
+
{children}
|
|
110
|
+
|
|
111
|
+
{footer && (
|
|
112
|
+
<div className="memori-modal--footer">{footer}</div>
|
|
113
|
+
)}
|
|
114
|
+
</Spin>
|
|
115
|
+
</Dialog.Panel>
|
|
116
|
+
</Transition.Child>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</Dialog>
|
|
120
|
+
</Transition>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default Modal
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`renders Modal loading unchanged 1`] = `<div />`;
|
|
4
|
+
|
|
5
|
+
exports[`renders Modal non closable unchanged 1`] = `<div />`;
|
|
6
|
+
|
|
7
|
+
exports[`renders Modal open unchanged 1`] = `<div />`;
|
|
8
|
+
|
|
9
|
+
exports[`renders Modal unchanged 1`] = `<div />`;
|
|
10
|
+
|
|
11
|
+
exports[`renders Modal with custom widths unchanged 1`] = `<div />`;
|
|
12
|
+
|
|
13
|
+
exports[`renders Modal with description unchanged 1`] = `<div />`;
|
|
14
|
+
|
|
15
|
+
exports[`renders Modal with footer unchanged 1`] = `<div />`;
|
|
16
|
+
|
|
17
|
+
exports[`renders Modal with title unchanged 1`] = `<div />`;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
.memori-select {
|
|
2
|
+
max-width: 240px;
|
|
3
|
+
min-height: 38px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.memori-select--button {
|
|
7
|
+
position: relative;
|
|
8
|
+
width: 100%;
|
|
9
|
+
max-width: 240px;
|
|
10
|
+
min-height: 38px;
|
|
11
|
+
padding: 0.5rem 2.5rem 0.5rem 0.75rem;
|
|
12
|
+
border: 1px solid #e5e7eb;
|
|
13
|
+
border-radius: 0.5rem;
|
|
14
|
+
background: transparent;
|
|
15
|
+
box-shadow:
|
|
16
|
+
rgb(0 0 0 / 0%) 0 0 0 0,
|
|
17
|
+
rgb(0 0 0 / 0%) 0 0 0 0,
|
|
18
|
+
rgb(0 0 0 / 10%) 0 4px 6px -1px,
|
|
19
|
+
rgb(0 0 0 / 10%) 0 2px 4px -2px;
|
|
20
|
+
color: var(--memori-text-color, #333);
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
font-family: var(--memori-font-family);
|
|
23
|
+
font-size: 16px;
|
|
24
|
+
text-align: left;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.memori-select--button:focus {
|
|
28
|
+
border-color: #cbd5e0;
|
|
29
|
+
box-shadow: 0 0 0 3px rgb(66 153 225 / 50%);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.memori-select--button:focus-visible {
|
|
33
|
+
border-color: #63b3ed;
|
|
34
|
+
box-shadow: 0 0 0 3px rgb(66 153 225 / 50%);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.memori-select--button:hover {
|
|
38
|
+
border-color: #e2e8f0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.memori-select--button:active {
|
|
42
|
+
border-color: #e2e8f0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.memori-select--button:disabled {
|
|
46
|
+
border-color: #e2e8f0;
|
|
47
|
+
background-color: #f7fafc;
|
|
48
|
+
color: #a0aec0;
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@media (width >= 640px) {
|
|
53
|
+
.memori-select--button {
|
|
54
|
+
font-size: 0.875rem;
|
|
55
|
+
line-height: 1.25rem;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.memori-select--label {
|
|
60
|
+
display: inline-block;
|
|
61
|
+
margin-bottom: 0.25rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.memori-select--value {
|
|
65
|
+
display: block;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
text-overflow: ellipsis;
|
|
68
|
+
white-space: nowrap;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.memori-select--value.memori-select--value-placeholder {
|
|
72
|
+
color: #a0aec0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.memori-select--icon {
|
|
76
|
+
position: absolute;
|
|
77
|
+
top: 0;
|
|
78
|
+
right: 0;
|
|
79
|
+
bottom: 0;
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
padding-right: 0.5rem;
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.memori-select--icon svg {
|
|
87
|
+
width: 1.25rem;
|
|
88
|
+
height: 1.25rem;
|
|
89
|
+
color: rgb(156 163 175/100%);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
ul.memori-select--options {
|
|
93
|
+
position: absolute;
|
|
94
|
+
z-index: 1;
|
|
95
|
+
overflow: auto;
|
|
96
|
+
width: 100%;
|
|
97
|
+
max-width: min(18rem, 30%);
|
|
98
|
+
max-height: 15rem;
|
|
99
|
+
padding: 0.25rem 0;
|
|
100
|
+
border-radius: 0.375rem;
|
|
101
|
+
margin: 0.25rem 0 0;
|
|
102
|
+
background: #fff;
|
|
103
|
+
box-shadow:
|
|
104
|
+
rgb(255 255 255) 0 0 0 0,
|
|
105
|
+
rgb(0 0 0 / 5%) 0 0 0 1px,
|
|
106
|
+
rgb(0 0 0 / 10%) 0 10px 15px -3px,
|
|
107
|
+
rgb(0 0 0 / 10%) 0 4px 6px -4px;
|
|
108
|
+
list-style: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@media (width >= 640px) {
|
|
112
|
+
.memori-select--options {
|
|
113
|
+
font-size: 0.875rem;
|
|
114
|
+
line-height: 1.25rem;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
li.memori-select--option {
|
|
119
|
+
position: relative;
|
|
120
|
+
padding: 0.5rem 1rem;
|
|
121
|
+
color: rgb(17 24 39/100%);
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
user-select: none;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
li.memori-select--option:hover,
|
|
127
|
+
li.memori-select--option:focus {
|
|
128
|
+
background-color: #f7fafc;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
li.memori-select--option:focus {
|
|
132
|
+
outline: 2px solid #63b3ed;
|
|
133
|
+
outline-offset: 2px;
|
|
134
|
+
}
|