mui-dialog 1.0.6
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/LICENSE +21 -0
- package/README.md +194 -0
- package/dist/fe-vi-dialog.es.js +751 -0
- package/dist/index.d.ts +125 -0
- package/package.json +110 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Virtual Internships
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# mui-dialog
|
|
2
|
+
|
|
3
|
+
A reusable dialog component for React applications built with Material-UI (MUI).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Using npm
|
|
9
|
+
npm install mui-dialog
|
|
10
|
+
|
|
11
|
+
# Using yarn
|
|
12
|
+
yarn add mui-dialog
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Built with Material-UI (MUI) components
|
|
18
|
+
- TypeScript support
|
|
19
|
+
- Multiple dialog types:
|
|
20
|
+
- Information
|
|
21
|
+
- Confirmation
|
|
22
|
+
- Input
|
|
23
|
+
- Customizable sizes and layouts
|
|
24
|
+
- Support for primary, secondary, and tertiary actions
|
|
25
|
+
- Responsive design
|
|
26
|
+
- Theme customization
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { ViDialog } from "mui-dialog";
|
|
32
|
+
import { MODAL_TYPES, INFORMATION_SUBTYPES } from "mui-dialog";
|
|
33
|
+
|
|
34
|
+
// Basic Information Dialog
|
|
35
|
+
const MyComponent = () => {
|
|
36
|
+
const [open, setOpen] = useState(false);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ViDialog
|
|
40
|
+
type={MODAL_TYPES.INFORMATION}
|
|
41
|
+
subtype={INFORMATION_SUBTYPES.ACKNOWLEDGEMENT}
|
|
42
|
+
open={open}
|
|
43
|
+
onClose={() => setOpen(false)}
|
|
44
|
+
title="Dialog Title"
|
|
45
|
+
description="This is a dialog description"
|
|
46
|
+
actions={{
|
|
47
|
+
primaryCtaTitle: "Confirm",
|
|
48
|
+
onPrimaryCtaClick: () => {
|
|
49
|
+
// Handle primary action
|
|
50
|
+
setOpen(false);
|
|
51
|
+
},
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{/* Optional content */}
|
|
55
|
+
</ViDialog>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Props
|
|
61
|
+
|
|
62
|
+
## Modal Types
|
|
63
|
+
|
|
64
|
+
| Type | Description | Subtypes | Allowed Sizes |
|
|
65
|
+
| -------------- | ------------------------------------ | ---------------------------------------- | ----------------- |
|
|
66
|
+
| `information` | For displaying information to users | `acknowledgement`, `progress`, `passive` | Varies by subtype |
|
|
67
|
+
| `confirmation` | For user confirmations and decisions | `default`, `destructive`, `nested` | `small` only |
|
|
68
|
+
| `input` | For collecting user input | `default`, `destructive` | All sizes |
|
|
69
|
+
|
|
70
|
+
### Subtype Details
|
|
71
|
+
|
|
72
|
+
#### Information Modal Subtypes
|
|
73
|
+
|
|
74
|
+
| Subtype | Description | Allowed Sizes | Dismissible |
|
|
75
|
+
| ----------------- | -------------------------------------- | ------------------------------- | ----------- |
|
|
76
|
+
| `acknowledgement` | For simple acknowledgements | `small` | `full` |
|
|
77
|
+
| `progress` | For showing progress or status updates | `small`, `medium`, `large` | `partial` |
|
|
78
|
+
| `passive` | For passive information display | `medium`, `large`, `extraLarge` | `full` |
|
|
79
|
+
|
|
80
|
+
#### Confirmation Modal Subtypes
|
|
81
|
+
|
|
82
|
+
| Subtype | Description | Allowed Sizes | Dismissible |
|
|
83
|
+
| ------------- | ------------------------ | ------------- | ----------- |
|
|
84
|
+
| `default` | Standard confirmation | `small` | `partial` |
|
|
85
|
+
| `destructive` | For destructive actions | `small` | `partial` |
|
|
86
|
+
| `nested` | For nested confirmations | `small` | `partial` |
|
|
87
|
+
|
|
88
|
+
#### Input Modal Subtypes
|
|
89
|
+
|
|
90
|
+
| Subtype | Description | Allowed Sizes | Dismissible |
|
|
91
|
+
| ------------- | ----------------------------- | ------------- | ----------- |
|
|
92
|
+
| `default` | Standard input | All sizes | `partial` |
|
|
93
|
+
| `destructive` | For destructive input actions | All sizes | `partial` |
|
|
94
|
+
|
|
95
|
+
## Props Reference
|
|
96
|
+
|
|
97
|
+
### Base Props
|
|
98
|
+
|
|
99
|
+
| Prop | Type | Required | Default | Description |
|
|
100
|
+
| ------------------ | ------------------------------------------------ | -------- | --------- | ------------------------------ |
|
|
101
|
+
| `type` | `"information" \| "confirmation" \| "input"` | Yes | - | Type of the modal |
|
|
102
|
+
| `subtype` | `string` | Yes | - | Subtype of the modal |
|
|
103
|
+
| `open` | `boolean` | Yes | - | Controls modal visibility |
|
|
104
|
+
| `onClose` | `() => void` | Yes | - | Callback when modal is closed |
|
|
105
|
+
| `title` | `string \| React.ReactNode` | No | - | Modal title |
|
|
106
|
+
| `subTitle` | `string \| React.ReactNode` | No | - | Modal subtitle |
|
|
107
|
+
| `description` | `string \| React.ReactNode` | No | - | Modal description |
|
|
108
|
+
| `children` | `React.ReactNode` | No | - | Additional content |
|
|
109
|
+
| `size` | `"small" \| "medium" \| "large" \| "extraLarge"` | No | `"small"` | Modal size |
|
|
110
|
+
| `wrapperClassName` | `string` | No | - | Custom class for modal wrapper |
|
|
111
|
+
| `showCloseIcon` | `boolean` | No | `true` | Show/hide close icon |
|
|
112
|
+
| `showDivider` | `boolean` | No | `true` | Show/hide divider |
|
|
113
|
+
| `showActions` | `boolean` | No | `true` | Show/hide action buttons |
|
|
114
|
+
|
|
115
|
+
### Action Props
|
|
116
|
+
|
|
117
|
+
| Prop | Type | Required | Default | Description |
|
|
118
|
+
| ------------------------ | ----------------- | -------- | ------- | ------------------------------------- |
|
|
119
|
+
| `primaryCtaTitle` | `string` | No | - | Primary button text |
|
|
120
|
+
| `secondaryCtaTitle` | `string` | No | - | Secondary button text |
|
|
121
|
+
| `tertiaryCtaTitle` | `string` | No | - | Tertiary button text |
|
|
122
|
+
| `isPrimaryCtaLoading` | `boolean` | No | `false` | Show loading state for primary button |
|
|
123
|
+
| `isPrimaryCtaDisabled` | `boolean` | No | `false` | Disable primary button |
|
|
124
|
+
| `isSecondaryCtaDisabled` | `boolean` | No | `false` | Disable secondary button |
|
|
125
|
+
| `isTertiaryCtaDisabled` | `boolean` | No | `false` | Disable tertiary button |
|
|
126
|
+
| `onPrimaryCtaClick` | `() => void` | No | - | Primary button click handler |
|
|
127
|
+
| `onSecondaryCtaClick` | `() => void` | No | - | Secondary button click handler |
|
|
128
|
+
| `onTertiaryCtaClick` | `() => void` | No | - | Tertiary button click handler |
|
|
129
|
+
| `tertiaryCtaStartIcon` | `React.ReactNode` | No | - | Icon for tertiary button |
|
|
130
|
+
|
|
131
|
+
## Size Breakpoints
|
|
132
|
+
|
|
133
|
+
| Size | Breakpoint | Max Width |
|
|
134
|
+
| ------------ | ---------- | --------- |
|
|
135
|
+
| `small` | `xs` | 600px |
|
|
136
|
+
| `medium` | `sm` | 900px |
|
|
137
|
+
| `large` | `md` | 1200px |
|
|
138
|
+
| `extraLarge` | `lg` | 1536px |
|
|
139
|
+
|
|
140
|
+
## Usage Example
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { ViDialog } from "mui-dialog";
|
|
144
|
+
|
|
145
|
+
// Input Modal
|
|
146
|
+
<ViDialog
|
|
147
|
+
type="input"
|
|
148
|
+
subtype="default"
|
|
149
|
+
open={true}
|
|
150
|
+
onClose={() => {}}
|
|
151
|
+
title="Input Required"
|
|
152
|
+
description="Please provide your input"
|
|
153
|
+
size="medium"
|
|
154
|
+
actions={{
|
|
155
|
+
primaryCtaTitle: "Submit",
|
|
156
|
+
secondaryCtaTitle: "Cancel",
|
|
157
|
+
onPrimaryCtaClick: () => {},
|
|
158
|
+
onSecondaryCtaClick: () => {},
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<input type="text" />
|
|
162
|
+
</ViDialog>;
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Modal Configuration
|
|
166
|
+
|
|
167
|
+
Each modal type and subtype has specific configurations for:
|
|
168
|
+
|
|
169
|
+
- Dismissibility: 'full' or 'partial'
|
|
170
|
+
- Allowed sizes: Array of allowed size options
|
|
171
|
+
|
|
172
|
+
These configurations are automatically enforced by the component to ensure consistent behavior across different use cases.
|
|
173
|
+
|
|
174
|
+
## Development
|
|
175
|
+
|
|
176
|
+
### Local Setup
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Install dependencies
|
|
180
|
+
yarn install
|
|
181
|
+
|
|
182
|
+
# Build package
|
|
183
|
+
yarn build
|
|
184
|
+
|
|
185
|
+
# Run tests
|
|
186
|
+
yarn test
|
|
187
|
+
|
|
188
|
+
# Run tests with coverage
|
|
189
|
+
yarn test:coverage
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
© [Virtual Internships]
|
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
!function(){"use strict";try{if("undefined"!=typeof document){var i=document.createElement("style");i.appendChild(document.createTextNode(".vi-dialog .close-icon{cursor:pointer;color:#717371}.vi-dialog .MuiPaper-root{border-radius:12px}.vi-dialog .divider{margin-top:28px;margin-bottom:-4px}.vi-dialog .vi-dialog-actions-wrapper{margin-top:28px;display:flex;justify-content:space-between;align-items:center}.vi-dialog .vi-dialog-actions-wrapper .tertiary-cta.destructive{color:#ed1d31;justify-self:flex-start}.vi-dialog .vi-dialog-actions-wrapper .vi-dialog-actions.medium{width:50%}.vi-dialog .vi-dialog-actions-wrapper .vi-dialog-actions.large{width:33%}.vi-dialog .vi-dialog-actions-wrapper .vi-dialog-actions.extra-large{width:25%}.vi-dialog .vi-dialog-actions{display:flex;align-items:center;justify-content:flex-end;gap:16px}.vi-dialog .vi-dialog-actions .vi-dialog-cta{width:-webkit-fill-available}.vi-dialog .vi-dialog-actions .tertiary-cta{padding:0}.vi-dialog .vi-dialog-actions .vi-dialog-cta.destructive{background-color:#ed1d31}.vi-dialog .vi-dialog-actions.without-tertiary{margin-top:28px}.vi-dialog .vi-dialog-actions.small{justify-content:center}.vi-dialog .vi-dialog-actions.without-tertiary.medium{max-width:50%;margin-left:50%}.vi-dialog .vi-dialog-actions.without-tertiary.large{max-width:33%;margin-left:67%}.vi-dialog .vi-dialog-actions.without-tertiary.extra-large{max-width:25%;margin-left:75%}.vi-dialog .vi-dialog-actions.with-tertiary-cta{max-width:100%;margin-left:0}.vi-dialog .vi-dialog-title{margin-bottom:28px}.vi-dialog .vi-dialog-title .description{margin-top:16px!important}.vi-dialog .vi-dialog-title.small{margin-bottom:16px}.vi-dialog .divider{margin-left:-24px;margin-right:-24px}@media only screen and (max-width: 600px){.vi-dialog .MuiPaper-root{margin:16px;width:calc(100% - 32px)}.vi-dialog .vi-dialog-actions-wrapper{flex-direction:column-reverse;gap:12px}.vi-dialog .vi-dialog-actions{flex-direction:column-reverse;width:100%!important;gap:12px}.vi-dialog .vi-dialog-actions.medium,.vi-dialog .vi-dialog-actions.large,.vi-dialog .vi-dialog-actions.extra-large{max-width:100%;margin-left:0}.vi-dialog.medium .MuiPaper-root,.vi-dialog.large .MuiPaper-root{margin:0;width:100%;height:100%;max-height:none;border-radius:0}}")),document.head.appendChild(i)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}}();
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import Dialog from '@mui/material/Dialog';
|
|
6
|
+
import Button from '@mui/material/Button';
|
|
7
|
+
import Typography from '@mui/material/Typography';
|
|
8
|
+
import { createSvgIcon } from '@mui/material/utils';
|
|
9
|
+
import Slide from '@mui/material/Slide';
|
|
10
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
11
|
+
import { useTheme, ThemeProvider } from '@mui/material/styles';
|
|
12
|
+
import { createTheme, Divider } from '@mui/material';
|
|
13
|
+
|
|
14
|
+
const CloseIcon = createSvgIcon(/*#__PURE__*/jsx("path", {
|
|
15
|
+
d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
|
16
|
+
}), 'Close');
|
|
17
|
+
|
|
18
|
+
let warnedOnce = false;
|
|
19
|
+
const warn = () => {
|
|
20
|
+
if (!warnedOnce) {
|
|
21
|
+
console.warn(['MUI: The LoadingButton component functionality is now part of the Button component from Material UI.', '', "You should use `import Button from '@mui/material/Button'`", "or `import { Button } from '@mui/material'`"].join('\n'));
|
|
22
|
+
warnedOnce = true;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @ignore - do not document.
|
|
28
|
+
*/
|
|
29
|
+
const LoadingButton = /*#__PURE__*/React.forwardRef(function DeprecatedLoadingButton(props, ref) {
|
|
30
|
+
warn();
|
|
31
|
+
return /*#__PURE__*/jsx(Button, {
|
|
32
|
+
ref: ref,
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
function getDefaultExportFromCjs (x) {
|
|
38
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* This method returns `undefined`.
|
|
43
|
+
*
|
|
44
|
+
* @static
|
|
45
|
+
* @memberOf _
|
|
46
|
+
* @since 2.3.0
|
|
47
|
+
* @category Util
|
|
48
|
+
* @example
|
|
49
|
+
*
|
|
50
|
+
* _.times(2, _.noop);
|
|
51
|
+
* // => [undefined, undefined]
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
var noop_1;
|
|
55
|
+
var hasRequiredNoop;
|
|
56
|
+
|
|
57
|
+
function requireNoop () {
|
|
58
|
+
if (hasRequiredNoop) return noop_1;
|
|
59
|
+
hasRequiredNoop = 1;
|
|
60
|
+
function noop() {
|
|
61
|
+
// No operation performed.
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
noop_1 = noop;
|
|
65
|
+
return noop_1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var noopExports = requireNoop();
|
|
69
|
+
const _noop = /*@__PURE__*/getDefaultExportFromCjs(noopExports);
|
|
70
|
+
|
|
71
|
+
const textStyles = {
|
|
72
|
+
fontWeight: {
|
|
73
|
+
semibold: 590,
|
|
74
|
+
regular: 400
|
|
75
|
+
},
|
|
76
|
+
letterSpacing: {
|
|
77
|
+
default: "normal"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const dialogTypography = {
|
|
82
|
+
fontFamily: "-apple-system,system-ui,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Fira Sans,Ubuntu,Oxygen,Oxygen Sans,Cantarell,Droid Sans,Apple Color Emoji,Segoe UI Emoji,Segoe UI Emoji,Segoe UI Symbol,Lucida Grande,Helvetica,Arial,sans-serif",
|
|
83
|
+
displayL: {
|
|
84
|
+
fontSize: "80px",
|
|
85
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
86
|
+
lineHeight: "92px",
|
|
87
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
88
|
+
},
|
|
89
|
+
displayM: {
|
|
90
|
+
fontSize: "40px",
|
|
91
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
92
|
+
lineHeight: "52px",
|
|
93
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
94
|
+
},
|
|
95
|
+
headingL: {
|
|
96
|
+
fontSize: "32px",
|
|
97
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
98
|
+
lineHeight: "44px",
|
|
99
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
100
|
+
},
|
|
101
|
+
headingM: {
|
|
102
|
+
fontSize: "28px",
|
|
103
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
104
|
+
lineHeight: "40px",
|
|
105
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
106
|
+
},
|
|
107
|
+
headingS: {
|
|
108
|
+
fontSize: "24px",
|
|
109
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
110
|
+
lineHeight: "36px",
|
|
111
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
112
|
+
},
|
|
113
|
+
semiBoldLabelL: {
|
|
114
|
+
fontSize: "20px",
|
|
115
|
+
lineHeight: "28px",
|
|
116
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
117
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
118
|
+
},
|
|
119
|
+
semiBoldLabelM: {
|
|
120
|
+
fontSize: "16px",
|
|
121
|
+
lineHeight: "24px",
|
|
122
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
123
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
124
|
+
},
|
|
125
|
+
semiBoldLabelS: {
|
|
126
|
+
fontSize: "14px",
|
|
127
|
+
lineHeight: "20px",
|
|
128
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
129
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
130
|
+
},
|
|
131
|
+
semiBoldLabelXs: {
|
|
132
|
+
fontSize: "12px",
|
|
133
|
+
lineHeight: "16px",
|
|
134
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
135
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
136
|
+
},
|
|
137
|
+
semiBoldLabelXxs: {
|
|
138
|
+
fontSize: "10px",
|
|
139
|
+
lineHeight: "14px",
|
|
140
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
141
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
142
|
+
},
|
|
143
|
+
regularLabelL: {
|
|
144
|
+
fontSize: "20px",
|
|
145
|
+
lineHeight: "28px",
|
|
146
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
147
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
148
|
+
},
|
|
149
|
+
regularLabelM: {
|
|
150
|
+
fontSize: "16px",
|
|
151
|
+
lineHeight: "24px",
|
|
152
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
153
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
154
|
+
},
|
|
155
|
+
regularLabelS: {
|
|
156
|
+
fontSize: "14px",
|
|
157
|
+
lineHeight: "20px",
|
|
158
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
159
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
160
|
+
},
|
|
161
|
+
regularLabelXs: {
|
|
162
|
+
fontSize: "12px",
|
|
163
|
+
lineHeight: "16px",
|
|
164
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
165
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
166
|
+
},
|
|
167
|
+
regularLabelXxs: {
|
|
168
|
+
fontSize: "10px",
|
|
169
|
+
lineHeight: "14px",
|
|
170
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
171
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
172
|
+
},
|
|
173
|
+
textXl: {
|
|
174
|
+
fontSize: "20px",
|
|
175
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
176
|
+
lineHeight: "28px",
|
|
177
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
178
|
+
},
|
|
179
|
+
textL: {
|
|
180
|
+
fontSize: "16px",
|
|
181
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
182
|
+
lineHeight: "24px",
|
|
183
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
184
|
+
},
|
|
185
|
+
textM: {
|
|
186
|
+
fontSize: "14px",
|
|
187
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
188
|
+
lineHeight: "20px",
|
|
189
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
190
|
+
},
|
|
191
|
+
subtextM: {
|
|
192
|
+
fontSize: "12px",
|
|
193
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
194
|
+
lineHeight: "16px",
|
|
195
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
196
|
+
},
|
|
197
|
+
subtextS: {
|
|
198
|
+
fontSize: "10px",
|
|
199
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
200
|
+
lineHeight: "14px",
|
|
201
|
+
letterSpacing: textStyles.letterSpacing.default
|
|
202
|
+
},
|
|
203
|
+
semiBoldLinkXL: {
|
|
204
|
+
fontSize: "20px",
|
|
205
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
206
|
+
lineHeight: "28px",
|
|
207
|
+
letterSpacing: textStyles.letterSpacing.default,
|
|
208
|
+
textDecoration: "underline"
|
|
209
|
+
},
|
|
210
|
+
semiBoldLinkL: {
|
|
211
|
+
fontSize: "16px",
|
|
212
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
213
|
+
lineHeight: "24px",
|
|
214
|
+
letterSpacing: textStyles.letterSpacing.default,
|
|
215
|
+
textDecoration: "underline"
|
|
216
|
+
},
|
|
217
|
+
semiBoldLinkM: {
|
|
218
|
+
fontSize: "14px",
|
|
219
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
220
|
+
lineHeight: "20px",
|
|
221
|
+
letterSpacing: textStyles.letterSpacing.default,
|
|
222
|
+
textDecoration: "underline"
|
|
223
|
+
},
|
|
224
|
+
semiBoldLinkS: {
|
|
225
|
+
fontSize: "12px",
|
|
226
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
227
|
+
lineHeight: "16px",
|
|
228
|
+
letterSpacing: textStyles.letterSpacing.default,
|
|
229
|
+
textDecoration: "underline"
|
|
230
|
+
},
|
|
231
|
+
semiBoldLinkXs: {
|
|
232
|
+
fontSize: "10px",
|
|
233
|
+
fontWeight: textStyles.fontWeight.semibold,
|
|
234
|
+
lineHeight: "14px",
|
|
235
|
+
letterSpacing: textStyles.letterSpacing.default,
|
|
236
|
+
textDecoration: "underline"
|
|
237
|
+
},
|
|
238
|
+
regularLinkXL: {
|
|
239
|
+
fontSize: "20px",
|
|
240
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
241
|
+
lineHeight: "20px",
|
|
242
|
+
letterSpacing: textStyles.letterSpacing.default,
|
|
243
|
+
textDecoration: "underline"
|
|
244
|
+
},
|
|
245
|
+
regularLinkL: {
|
|
246
|
+
fontSize: "16px",
|
|
247
|
+
fontWeight: textStyles.fontWeight.regular,
|
|
248
|
+
lineHeight: "24px",
|
|
249
|
+
letterSpacing: textStyles.letterSpacing.default,
|
|
250
|
+
textDecoration: "underline"
|
|
251
|
+
},
|
|
252
|
+
h1: {
|
|
253
|
+
fontSize: "26px",
|
|
254
|
+
fontWeight: 590,
|
|
255
|
+
lineHeight: "32px"
|
|
256
|
+
},
|
|
257
|
+
h2: {
|
|
258
|
+
fontSize: "22px",
|
|
259
|
+
fontWeight: 590,
|
|
260
|
+
lineHeight: "26px"
|
|
261
|
+
},
|
|
262
|
+
h3: {
|
|
263
|
+
fontSize: "17px",
|
|
264
|
+
fontWeight: 590,
|
|
265
|
+
lineHeight: "22px"
|
|
266
|
+
},
|
|
267
|
+
h4: {
|
|
268
|
+
fontSize: "15px",
|
|
269
|
+
fontWeight: 590,
|
|
270
|
+
lineHeight: "20px"
|
|
271
|
+
},
|
|
272
|
+
h5: {
|
|
273
|
+
fontSize: "14px",
|
|
274
|
+
fontWeight: 590,
|
|
275
|
+
lineHeight: "20px"
|
|
276
|
+
},
|
|
277
|
+
headline: {
|
|
278
|
+
fontSize: "13px",
|
|
279
|
+
fontWeight: 590,
|
|
280
|
+
lineHeight: "16px"
|
|
281
|
+
},
|
|
282
|
+
body: {
|
|
283
|
+
fontSize: "13px",
|
|
284
|
+
lineHeight: "16px",
|
|
285
|
+
fontWeight: 400
|
|
286
|
+
},
|
|
287
|
+
callout: {
|
|
288
|
+
fontSize: "13px",
|
|
289
|
+
fontWeight: 510,
|
|
290
|
+
lineHeight: "15px"
|
|
291
|
+
},
|
|
292
|
+
subHeadline1: {
|
|
293
|
+
fontSize: "14px",
|
|
294
|
+
lineHeight: "20px",
|
|
295
|
+
fontWeight: 400
|
|
296
|
+
},
|
|
297
|
+
subHeadline2: {
|
|
298
|
+
fontSize: "13px",
|
|
299
|
+
lineHeight: "20px",
|
|
300
|
+
fontWeight: 400
|
|
301
|
+
},
|
|
302
|
+
footNote: {
|
|
303
|
+
fontSize: "12px",
|
|
304
|
+
lineHeight: "13px",
|
|
305
|
+
fontWeight: 400
|
|
306
|
+
},
|
|
307
|
+
caption1: {
|
|
308
|
+
fontSize: "10px",
|
|
309
|
+
lineHeight: "13px",
|
|
310
|
+
fontWeight: 400
|
|
311
|
+
},
|
|
312
|
+
caption2: {
|
|
313
|
+
fontSize: "10px",
|
|
314
|
+
lineHeight: "13px",
|
|
315
|
+
fontWeight: 510
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
const muiTheme = createTheme({
|
|
319
|
+
palette: {
|
|
320
|
+
primary: {
|
|
321
|
+
main: "#1E221E",
|
|
322
|
+
contrastText: "#ffffff"
|
|
323
|
+
},
|
|
324
|
+
secondary: {
|
|
325
|
+
main: "#0A9083",
|
|
326
|
+
contrastText: "#000000"
|
|
327
|
+
},
|
|
328
|
+
error: {
|
|
329
|
+
main: "#ED1D31",
|
|
330
|
+
contrastText: "#ffffff"
|
|
331
|
+
},
|
|
332
|
+
warning: {
|
|
333
|
+
main: "#F3800D",
|
|
334
|
+
contrastText: "#000000"
|
|
335
|
+
},
|
|
336
|
+
info: {
|
|
337
|
+
main: "#0881EA",
|
|
338
|
+
contrastText: "#000000"
|
|
339
|
+
},
|
|
340
|
+
success: {
|
|
341
|
+
main: "#0AB22C",
|
|
342
|
+
contrastText: "#000000"
|
|
343
|
+
},
|
|
344
|
+
background: {
|
|
345
|
+
default: "#F7F9FC"
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
typography: dialogTypography,
|
|
349
|
+
components: {
|
|
350
|
+
MuiTypography: {
|
|
351
|
+
defaultProps: {
|
|
352
|
+
variantMapping: {
|
|
353
|
+
h1: "h1",
|
|
354
|
+
h2: "h2",
|
|
355
|
+
h3: "h3",
|
|
356
|
+
h4: "h4",
|
|
357
|
+
headline: "h5",
|
|
358
|
+
body: "span",
|
|
359
|
+
callout: "span",
|
|
360
|
+
subHeadline1: "span",
|
|
361
|
+
subHeadline2: "span",
|
|
362
|
+
footNote: "span",
|
|
363
|
+
caption1: "span",
|
|
364
|
+
caption2: "span"
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
MuiButton: {
|
|
369
|
+
defaultProps: {
|
|
370
|
+
disableElevation: true,
|
|
371
|
+
size: "large"
|
|
372
|
+
},
|
|
373
|
+
styleOverrides: {
|
|
374
|
+
root: {
|
|
375
|
+
textTransform: "none",
|
|
376
|
+
fontSize: "14px",
|
|
377
|
+
borderRadius: "8px"
|
|
378
|
+
},
|
|
379
|
+
text: {
|
|
380
|
+
textDecoration: "underline",
|
|
381
|
+
"&:hover": {
|
|
382
|
+
backgroundColor: "transparent",
|
|
383
|
+
textDecoration: "underline"
|
|
384
|
+
},
|
|
385
|
+
padding: "0px 8px",
|
|
386
|
+
textAlign: "left"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
MuiTab: {
|
|
391
|
+
styleOverrides: {
|
|
392
|
+
root: {
|
|
393
|
+
textTransform: "none",
|
|
394
|
+
fontSize: "14px"
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
MuiChip: {
|
|
399
|
+
defaultProps: {
|
|
400
|
+
size: "small"
|
|
401
|
+
},
|
|
402
|
+
styleOverrides: {
|
|
403
|
+
root: {
|
|
404
|
+
paddingLeft: "5px",
|
|
405
|
+
paddingRight: "5px"
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
MuiPaper: {
|
|
410
|
+
styleOverrides: {
|
|
411
|
+
root: {
|
|
412
|
+
borderRadius: "16px"
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
MuiCard: {
|
|
417
|
+
defaultProps: {
|
|
418
|
+
variant: "outlined"
|
|
419
|
+
},
|
|
420
|
+
styleOverrides: {
|
|
421
|
+
root: {
|
|
422
|
+
borderRadius: "16px"
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
MuiAutocomplete: {
|
|
427
|
+
styleOverrides: {
|
|
428
|
+
root: {
|
|
429
|
+
"& .MuiAutocomplete-inputRoot": {
|
|
430
|
+
paddingLeft: "14px"
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
MuiLink: {
|
|
436
|
+
styleOverrides: {
|
|
437
|
+
root: {
|
|
438
|
+
fontWeight: "bold",
|
|
439
|
+
"&:hover": {
|
|
440
|
+
cursor: "pointer"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
defaultProps: {
|
|
445
|
+
variant: "body"
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
MuiTextField: {
|
|
449
|
+
styleOverrides: {
|
|
450
|
+
root: {
|
|
451
|
+
"& .MuiInputBase-root": {
|
|
452
|
+
borderRadius: "8px"
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
MuiFormControl: {
|
|
458
|
+
styleOverrides: {
|
|
459
|
+
root: {
|
|
460
|
+
"& .MuiInputBase-root": {
|
|
461
|
+
borderRadius: "8px"
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
MuiDrawer: {
|
|
467
|
+
styleOverrides: {
|
|
468
|
+
paper: {
|
|
469
|
+
borderRadius: 0
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
const MODAL_TYPES = {
|
|
477
|
+
INFORMATION: "information",
|
|
478
|
+
CONFIRMATION: "confirmation",
|
|
479
|
+
INPUT: "input"
|
|
480
|
+
};
|
|
481
|
+
const INFORMATION_SUBTYPES = {
|
|
482
|
+
ACKNOWLEDGEMENT: "acknowledgement",
|
|
483
|
+
PROGRESS: "progress",
|
|
484
|
+
PASSIVE: "passive"
|
|
485
|
+
};
|
|
486
|
+
const CONFIRMATION_SUBTYPES = {
|
|
487
|
+
DEFAULT: "default",
|
|
488
|
+
DESTRUCTIVE: "destructive",
|
|
489
|
+
NESTED: "nested"
|
|
490
|
+
};
|
|
491
|
+
const INPUT_SUBTYPES = {
|
|
492
|
+
DEFAULT: "default",
|
|
493
|
+
DESTRUCTIVE: "destructive"
|
|
494
|
+
};
|
|
495
|
+
const MODAL_SIZES = {
|
|
496
|
+
SMALL: "small",
|
|
497
|
+
MEDIUM: "medium",
|
|
498
|
+
LARGE: "large",
|
|
499
|
+
EXTRA_LARGE: "extraLarge"
|
|
500
|
+
};
|
|
501
|
+
const TERTIARY_CTA_TYPES = {
|
|
502
|
+
DEFAULT: "default",
|
|
503
|
+
DESTRUCTIVE: "destructive"
|
|
504
|
+
};
|
|
505
|
+
const MODAL_CONFIGS = {
|
|
506
|
+
[MODAL_TYPES.INFORMATION]: {
|
|
507
|
+
[INFORMATION_SUBTYPES.ACKNOWLEDGEMENT]: {
|
|
508
|
+
DISMISSIBLE: "full",
|
|
509
|
+
ALLOWED_SIZES: [MODAL_SIZES.SMALL]
|
|
510
|
+
},
|
|
511
|
+
[INFORMATION_SUBTYPES.PROGRESS]: {
|
|
512
|
+
DISMISSIBLE: "partial",
|
|
513
|
+
ALLOWED_SIZES: [MODAL_SIZES.SMALL, MODAL_SIZES.MEDIUM, MODAL_SIZES.LARGE]
|
|
514
|
+
},
|
|
515
|
+
[INFORMATION_SUBTYPES.PASSIVE]: {
|
|
516
|
+
DISMISSIBLE: "full",
|
|
517
|
+
ALLOWED_SIZES: [MODAL_SIZES.MEDIUM, MODAL_SIZES.LARGE, MODAL_SIZES.EXTRA_LARGE]
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
[MODAL_TYPES.CONFIRMATION]: {
|
|
521
|
+
[CONFIRMATION_SUBTYPES.DEFAULT]: {
|
|
522
|
+
DISMISSIBLE: "partial",
|
|
523
|
+
ALLOWED_SIZES: [MODAL_SIZES.SMALL]
|
|
524
|
+
},
|
|
525
|
+
[CONFIRMATION_SUBTYPES.DESTRUCTIVE]: {
|
|
526
|
+
DISMISSIBLE: "partial",
|
|
527
|
+
ALLOWED_SIZES: [MODAL_SIZES.SMALL]
|
|
528
|
+
},
|
|
529
|
+
[CONFIRMATION_SUBTYPES.NESTED]: {
|
|
530
|
+
DISMISSIBLE: "partial",
|
|
531
|
+
ALLOWED_SIZES: [MODAL_SIZES.SMALL]
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
[MODAL_TYPES.INPUT]: {
|
|
535
|
+
[INPUT_SUBTYPES.DEFAULT]: {
|
|
536
|
+
DISMISSIBLE: "partial",
|
|
537
|
+
ALLOWED_SIZES: Object.values(MODAL_SIZES)
|
|
538
|
+
},
|
|
539
|
+
[INPUT_SUBTYPES.DESTRUCTIVE]: {
|
|
540
|
+
DISMISSIBLE: "partial",
|
|
541
|
+
ALLOWED_SIZES: Object.values(MODAL_SIZES)
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
const SIZE_TO_MAX_WIDTH = {
|
|
546
|
+
[MODAL_SIZES.SMALL]: "xs",
|
|
547
|
+
[MODAL_SIZES.MEDIUM]: "sm",
|
|
548
|
+
[MODAL_SIZES.LARGE]: "md",
|
|
549
|
+
[MODAL_SIZES.EXTRA_LARGE]: "lg"
|
|
550
|
+
};
|
|
551
|
+
const MODAL_SIZE_VS_CLASS_NAMES = {
|
|
552
|
+
[MODAL_SIZES.SMALL]: "small",
|
|
553
|
+
[MODAL_SIZES.MEDIUM]: "medium",
|
|
554
|
+
[MODAL_SIZES.LARGE]: "large",
|
|
555
|
+
[MODAL_SIZES.EXTRA_LARGE]: "extra-large"
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
const checkIfTertiaryCtaIsAllowed = (type, subtype, size) => {
|
|
559
|
+
if (type === MODAL_TYPES.CONFIRMATION) return false;
|
|
560
|
+
if (subtype === INFORMATION_SUBTYPES.ACKNOWLEDGEMENT) return false;
|
|
561
|
+
if (size === MODAL_SIZES.SMALL) return false;
|
|
562
|
+
return true;
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
const TransitionUp = forwardRef(
|
|
566
|
+
function Transition(props, ref) {
|
|
567
|
+
return /* @__PURE__ */ jsx(Slide, { direction: "up", ref, ...props });
|
|
568
|
+
}
|
|
569
|
+
);
|
|
570
|
+
const ViDialog = (props) => {
|
|
571
|
+
let parentTheme = useTheme();
|
|
572
|
+
parentTheme = {
|
|
573
|
+
...parentTheme,
|
|
574
|
+
typography: {
|
|
575
|
+
...parentTheme.typography,
|
|
576
|
+
...dialogTypography
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
const isMobile = useMediaQuery("(min-width:600px)");
|
|
580
|
+
const subtype = props.type === MODAL_TYPES.INFORMATION ? props.subtype : props.type === MODAL_TYPES.CONFIRMATION ? props.subtype : props.type === MODAL_TYPES.INPUT ? props.subtype : "default";
|
|
581
|
+
const {
|
|
582
|
+
wrapperClassName,
|
|
583
|
+
open,
|
|
584
|
+
type,
|
|
585
|
+
size,
|
|
586
|
+
title,
|
|
587
|
+
subTitle,
|
|
588
|
+
description,
|
|
589
|
+
onClose,
|
|
590
|
+
children,
|
|
591
|
+
actions,
|
|
592
|
+
showActions = true,
|
|
593
|
+
showDivider = true,
|
|
594
|
+
showCloseIcon = true,
|
|
595
|
+
tertiaryCtaType = "default",
|
|
596
|
+
...rest
|
|
597
|
+
} = props;
|
|
598
|
+
const {
|
|
599
|
+
primaryCtaTitle,
|
|
600
|
+
secondaryCtaTitle,
|
|
601
|
+
isPrimaryCtaLoading = false,
|
|
602
|
+
isPrimaryCtaDisabled = false,
|
|
603
|
+
isSecondaryCtaDisabled = false,
|
|
604
|
+
onPrimaryCtaClick = _noop,
|
|
605
|
+
onSecondaryCtaClick = _noop,
|
|
606
|
+
tertiaryCtaTitle,
|
|
607
|
+
tertiaryCtaStartIcon,
|
|
608
|
+
isTertiaryCtaLoading = false,
|
|
609
|
+
isTertiaryCtaDisabled = false,
|
|
610
|
+
onTertiaryCtaClick = _noop
|
|
611
|
+
} = actions || {};
|
|
612
|
+
const config = MODAL_CONFIGS[type][subtype] || MODAL_CONFIGS[type].default;
|
|
613
|
+
const defaultSize = config?.ALLOWED_SIZES[0] || MODAL_SIZES.SMALL;
|
|
614
|
+
const selectedSize = size && config?.ALLOWED_SIZES?.includes(size) ? size : defaultSize;
|
|
615
|
+
const showFooter = showActions && (primaryCtaTitle || secondaryCtaTitle);
|
|
616
|
+
const showFooterDivider = showDivider && (selectedSize === MODAL_SIZES.LARGE || selectedSize === MODAL_SIZES.EXTRA_LARGE);
|
|
617
|
+
const isTertiaryCtaAllowed = checkIfTertiaryCtaIsAllowed(
|
|
618
|
+
type,
|
|
619
|
+
subtype,
|
|
620
|
+
selectedSize
|
|
621
|
+
);
|
|
622
|
+
const showTertiaryCta = isTertiaryCtaAllowed && tertiaryCtaTitle;
|
|
623
|
+
const handleClose = () => {
|
|
624
|
+
if (config?.DISMISSIBLE === "full") {
|
|
625
|
+
onClose();
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
const currentTheme = parentTheme || muiTheme;
|
|
629
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme: currentTheme, children: /* @__PURE__ */ jsx(
|
|
630
|
+
Dialog,
|
|
631
|
+
{
|
|
632
|
+
TransitionComponent: isMobile ? TransitionUp : void 0,
|
|
633
|
+
className: `vi-dialog ${MODAL_SIZE_VS_CLASS_NAMES[selectedSize]} ${wrapperClassName}`,
|
|
634
|
+
open,
|
|
635
|
+
onClose: handleClose,
|
|
636
|
+
maxWidth: SIZE_TO_MAX_WIDTH[selectedSize],
|
|
637
|
+
fullWidth: true,
|
|
638
|
+
...rest,
|
|
639
|
+
children: /* @__PURE__ */ jsxs("div", { className: "p-24 h-fill", children: [
|
|
640
|
+
title && /* @__PURE__ */ jsxs(
|
|
641
|
+
"div",
|
|
642
|
+
{
|
|
643
|
+
className: `vi-dialog-title ${MODAL_SIZE_VS_CLASS_NAMES[selectedSize]}`,
|
|
644
|
+
children: [
|
|
645
|
+
/* @__PURE__ */ jsxs("div", { className: "d-f ai-c jc-sb", children: [
|
|
646
|
+
/* @__PURE__ */ jsxs("div", { className: "d-f flex-dir-col gap-8", children: [
|
|
647
|
+
/* @__PURE__ */ jsx(Typography, { variant: "semiBoldLabelL", children: title }),
|
|
648
|
+
subTitle && /* @__PURE__ */ jsx(Typography, { variant: "subtextM", children: subTitle })
|
|
649
|
+
] }),
|
|
650
|
+
showCloseIcon && /* @__PURE__ */ jsx(
|
|
651
|
+
CloseIcon,
|
|
652
|
+
{
|
|
653
|
+
fontSize: "small",
|
|
654
|
+
className: "close-icon",
|
|
655
|
+
"aria-label": "Close dialog",
|
|
656
|
+
onClick: onClose
|
|
657
|
+
}
|
|
658
|
+
)
|
|
659
|
+
] }),
|
|
660
|
+
description && /* @__PURE__ */ jsx(
|
|
661
|
+
Typography,
|
|
662
|
+
{
|
|
663
|
+
component: "div",
|
|
664
|
+
className: "description",
|
|
665
|
+
children: description
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
]
|
|
669
|
+
}
|
|
670
|
+
),
|
|
671
|
+
children,
|
|
672
|
+
showFooter && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
673
|
+
showFooterDivider && /* @__PURE__ */ jsx(Divider, { className: "divider" }),
|
|
674
|
+
showTertiaryCta ? /* @__PURE__ */ jsxs("div", { className: "vi-dialog-actions-wrapper", children: [
|
|
675
|
+
/* @__PURE__ */ jsx(
|
|
676
|
+
LoadingButton,
|
|
677
|
+
{
|
|
678
|
+
className: `tertiary-cta ${tertiaryCtaType === TERTIARY_CTA_TYPES.DESTRUCTIVE ? "destructive" : ""}`,
|
|
679
|
+
variant: "text",
|
|
680
|
+
onClick: onTertiaryCtaClick,
|
|
681
|
+
loading: isTertiaryCtaLoading,
|
|
682
|
+
disabled: isTertiaryCtaDisabled,
|
|
683
|
+
startIcon: tertiaryCtaStartIcon,
|
|
684
|
+
children: tertiaryCtaTitle
|
|
685
|
+
}
|
|
686
|
+
),
|
|
687
|
+
/* @__PURE__ */ jsxs(
|
|
688
|
+
"div",
|
|
689
|
+
{
|
|
690
|
+
className: `vi-dialog-actions ${MODAL_SIZE_VS_CLASS_NAMES[selectedSize]}`,
|
|
691
|
+
children: [
|
|
692
|
+
secondaryCtaTitle && /* @__PURE__ */ jsx(
|
|
693
|
+
Button,
|
|
694
|
+
{
|
|
695
|
+
className: "vi-dialog-cta",
|
|
696
|
+
variant: "outlined",
|
|
697
|
+
onClick: onSecondaryCtaClick,
|
|
698
|
+
disabled: isSecondaryCtaDisabled,
|
|
699
|
+
children: secondaryCtaTitle
|
|
700
|
+
}
|
|
701
|
+
),
|
|
702
|
+
primaryCtaTitle && /* @__PURE__ */ jsx(
|
|
703
|
+
LoadingButton,
|
|
704
|
+
{
|
|
705
|
+
className: `vi-dialog-cta ${subtype === "destructive" ? "destructive" : ""}`,
|
|
706
|
+
variant: "contained",
|
|
707
|
+
onClick: onPrimaryCtaClick,
|
|
708
|
+
loading: isPrimaryCtaLoading,
|
|
709
|
+
disabled: isPrimaryCtaDisabled,
|
|
710
|
+
children: primaryCtaTitle
|
|
711
|
+
}
|
|
712
|
+
)
|
|
713
|
+
]
|
|
714
|
+
}
|
|
715
|
+
)
|
|
716
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
717
|
+
"div",
|
|
718
|
+
{
|
|
719
|
+
className: `vi-dialog-actions without-tertiary ${MODAL_SIZE_VS_CLASS_NAMES[selectedSize]}`,
|
|
720
|
+
children: [
|
|
721
|
+
secondaryCtaTitle && /* @__PURE__ */ jsx(
|
|
722
|
+
Button,
|
|
723
|
+
{
|
|
724
|
+
className: "vi-dialog-cta",
|
|
725
|
+
variant: "outlined",
|
|
726
|
+
onClick: onSecondaryCtaClick,
|
|
727
|
+
disabled: isSecondaryCtaDisabled,
|
|
728
|
+
children: secondaryCtaTitle
|
|
729
|
+
}
|
|
730
|
+
),
|
|
731
|
+
primaryCtaTitle && /* @__PURE__ */ jsx(
|
|
732
|
+
LoadingButton,
|
|
733
|
+
{
|
|
734
|
+
className: `vi-dialog-cta ${subtype === "destructive" ? "destructive" : ""}`,
|
|
735
|
+
variant: "contained",
|
|
736
|
+
onClick: onPrimaryCtaClick,
|
|
737
|
+
loading: isPrimaryCtaLoading,
|
|
738
|
+
disabled: isPrimaryCtaDisabled,
|
|
739
|
+
children: primaryCtaTitle
|
|
740
|
+
}
|
|
741
|
+
)
|
|
742
|
+
]
|
|
743
|
+
}
|
|
744
|
+
)
|
|
745
|
+
] })
|
|
746
|
+
] })
|
|
747
|
+
}
|
|
748
|
+
) });
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
export { CONFIRMATION_SUBTYPES, INFORMATION_SUBTYPES, INPUT_SUBTYPES, MODAL_CONFIGS, MODAL_SIZES, MODAL_SIZE_VS_CLASS_NAMES, MODAL_TYPES, SIZE_TO_MAX_WIDTH, TERTIARY_CTA_TYPES, ViDialog };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Breakpoint } from '@mui/material';
|
|
2
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
export declare interface BaseModalProps {
|
|
5
|
+
wrapperClassName?: string;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
open: boolean;
|
|
8
|
+
showCloseIcon?: boolean;
|
|
9
|
+
title?: string | React.ReactNode;
|
|
10
|
+
subTitle?: string | React.ReactNode;
|
|
11
|
+
description?: string | React.ReactNode;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
actions?: IActions;
|
|
14
|
+
showDivider?: boolean;
|
|
15
|
+
showActions?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare const CONFIRMATION_SUBTYPES: {
|
|
19
|
+
readonly DEFAULT: "default";
|
|
20
|
+
readonly DESTRUCTIVE: "destructive";
|
|
21
|
+
readonly NESTED: "nested";
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export declare interface ConfirmationModalProps extends BaseModalProps {
|
|
25
|
+
type: typeof MODAL_TYPES.CONFIRMATION;
|
|
26
|
+
subtype: (typeof CONFIRMATION_SUBTYPES)[keyof typeof CONFIRMATION_SUBTYPES];
|
|
27
|
+
size?: ModalSize;
|
|
28
|
+
tertiaryCtaType?: (typeof TERTIARY_CTA_TYPES)[keyof typeof TERTIARY_CTA_TYPES];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare type ConfirmationSubtype = (typeof CONFIRMATION_SUBTYPES)[keyof typeof CONFIRMATION_SUBTYPES];
|
|
32
|
+
|
|
33
|
+
declare interface IActions {
|
|
34
|
+
primaryCtaTitle?: string;
|
|
35
|
+
secondaryCtaTitle?: string;
|
|
36
|
+
isPrimaryCtaLoading?: boolean;
|
|
37
|
+
isPrimaryCtaDisabled?: boolean;
|
|
38
|
+
isSecondaryCtaDisabled?: boolean;
|
|
39
|
+
onPrimaryCtaClick?: () => void;
|
|
40
|
+
onSecondaryCtaClick?: () => void;
|
|
41
|
+
tertiaryCtaTitle?: string;
|
|
42
|
+
tertiaryCtaStartIcon?: React.ReactNode;
|
|
43
|
+
isTertiaryCtaLoading?: boolean;
|
|
44
|
+
isTertiaryCtaDisabled?: boolean;
|
|
45
|
+
onTertiaryCtaClick?: () => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export declare const INFORMATION_SUBTYPES: {
|
|
49
|
+
readonly ACKNOWLEDGEMENT: "acknowledgement";
|
|
50
|
+
readonly PROGRESS: "progress";
|
|
51
|
+
readonly PASSIVE: "passive";
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export declare interface InformationModalProps extends BaseModalProps {
|
|
55
|
+
type: typeof MODAL_TYPES.INFORMATION;
|
|
56
|
+
subtype: (typeof INFORMATION_SUBTYPES)[keyof typeof INFORMATION_SUBTYPES];
|
|
57
|
+
size?: ModalSize;
|
|
58
|
+
tertiaryCtaType?: (typeof TERTIARY_CTA_TYPES)[keyof typeof TERTIARY_CTA_TYPES];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare type InformationSubtype = (typeof INFORMATION_SUBTYPES)[keyof typeof INFORMATION_SUBTYPES];
|
|
62
|
+
|
|
63
|
+
export declare const INPUT_SUBTYPES: {
|
|
64
|
+
readonly DEFAULT: "default";
|
|
65
|
+
readonly DESTRUCTIVE: "destructive";
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export declare interface InputModalProps extends BaseModalProps {
|
|
69
|
+
type: typeof MODAL_TYPES.INPUT;
|
|
70
|
+
subtype: (typeof INPUT_SUBTYPES)[keyof typeof INPUT_SUBTYPES];
|
|
71
|
+
size?: ModalSize;
|
|
72
|
+
tertiaryCtaType?: (typeof TERTIARY_CTA_TYPES)[keyof typeof TERTIARY_CTA_TYPES];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export declare type InputSubtype = (typeof INPUT_SUBTYPES)[keyof typeof INPUT_SUBTYPES];
|
|
76
|
+
|
|
77
|
+
export declare const MODAL_CONFIGS: Record<ModalType, ModalTypeConfig>;
|
|
78
|
+
|
|
79
|
+
export declare const MODAL_SIZE_VS_CLASS_NAMES: {
|
|
80
|
+
small: string;
|
|
81
|
+
medium: string;
|
|
82
|
+
large: string;
|
|
83
|
+
extraLarge: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export declare const MODAL_SIZES: {
|
|
87
|
+
readonly SMALL: "small";
|
|
88
|
+
readonly MEDIUM: "medium";
|
|
89
|
+
readonly LARGE: "large";
|
|
90
|
+
readonly EXTRA_LARGE: "extraLarge";
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export declare const MODAL_TYPES: {
|
|
94
|
+
readonly INFORMATION: "information";
|
|
95
|
+
readonly CONFIRMATION: "confirmation";
|
|
96
|
+
readonly INPUT: "input";
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
declare type ModalConfig = {
|
|
100
|
+
DISMISSIBLE: 'full' | 'partial';
|
|
101
|
+
ALLOWED_SIZES: ModalSize[];
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
declare type ModalProps = InformationModalProps | ConfirmationModalProps | InputModalProps;
|
|
105
|
+
|
|
106
|
+
export declare type ModalSize = (typeof MODAL_SIZES)[keyof typeof MODAL_SIZES];
|
|
107
|
+
|
|
108
|
+
export declare type ModalType = (typeof MODAL_TYPES)[keyof typeof MODAL_TYPES];
|
|
109
|
+
|
|
110
|
+
declare type ModalTypeConfig = {
|
|
111
|
+
[subtype: string]: ModalConfig;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export declare const SIZE_TO_MAX_WIDTH: Record<ModalSize, Breakpoint>;
|
|
115
|
+
|
|
116
|
+
export declare type SubtypeForType<T extends ModalType> = T extends typeof MODAL_TYPES.INFORMATION ? InformationSubtype : T extends typeof MODAL_TYPES.CONFIRMATION ? ConfirmationSubtype : T extends typeof MODAL_TYPES.INPUT ? InputSubtype : never;
|
|
117
|
+
|
|
118
|
+
export declare const TERTIARY_CTA_TYPES: {
|
|
119
|
+
DEFAULT: string;
|
|
120
|
+
DESTRUCTIVE: string;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export declare const ViDialog: (props: ModalProps) => JSX_2.Element;
|
|
124
|
+
|
|
125
|
+
export { }
|
package/package.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mui-dialog",
|
|
3
|
+
"description": "A reusable dialog component for React applications built with Material-UI (MUI).",
|
|
4
|
+
"author": "Victor de la Fouchardiere <victor.delafouchardiere@gmail.com> (https://github.com/viclafouch)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/viplatform/mui-dialog/issues"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/viplatform/mui-dialog#readme",
|
|
10
|
+
"version": "1.0.6",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"main": "./dist/mui-dialog.es.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/mui-dialog.es.js",
|
|
20
|
+
"default": "./dist/mui-dialog.es.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/viplatform/mui-dialog.git"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"react",
|
|
29
|
+
"typescript",
|
|
30
|
+
"mui",
|
|
31
|
+
"javascript",
|
|
32
|
+
"material"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "npm run lint && vite build",
|
|
36
|
+
"lint": "npx tsc --noEmit && eslint",
|
|
37
|
+
"lint:fix": "npm run lint --fix",
|
|
38
|
+
"storybook": "storybook dev -p 6006",
|
|
39
|
+
"build-storybook": "storybook build",
|
|
40
|
+
"test": "vitest",
|
|
41
|
+
"release": "standard-version",
|
|
42
|
+
"coverage": "vitest run --coverage",
|
|
43
|
+
"prepare": "husky",
|
|
44
|
+
"prepublishOnly": "npm run build"
|
|
45
|
+
},
|
|
46
|
+
"standard-version": {
|
|
47
|
+
"scripts": {
|
|
48
|
+
"prerelease": "npm run build"
|
|
49
|
+
},
|
|
50
|
+
"skip": {
|
|
51
|
+
"changelog": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@emotion/react": "^11.13.0",
|
|
56
|
+
"@emotion/styled": "^11.13.0",
|
|
57
|
+
"@mui/material": "^7.0.0",
|
|
58
|
+
"@types/react": "^18.0.0 || ^19.0.0",
|
|
59
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
60
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@types/react": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@emotion/react": "^11.13.0",
|
|
69
|
+
"@emotion/styled": "^11.13.0",
|
|
70
|
+
"@mui/icons-material": "^7.1.0",
|
|
71
|
+
"@mui/lab": "^7.0.0-beta.12",
|
|
72
|
+
"@mui/material": "^7.0.0",
|
|
73
|
+
"@types/react": "^18.0.0 || ^19.0.0",
|
|
74
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
75
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@emotion/react": "^11.14.0",
|
|
79
|
+
"@emotion/styled": "^11.14.0",
|
|
80
|
+
"@mui/material": "^7.0.2",
|
|
81
|
+
"@storybook/addon-actions": "^8.6.12",
|
|
82
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
83
|
+
"@storybook/addon-interactions": "^8.6.12",
|
|
84
|
+
"@storybook/addon-links": "^8.6.12",
|
|
85
|
+
"@storybook/react": "^8.6.12",
|
|
86
|
+
"@storybook/react-vite": "^8.6.12",
|
|
87
|
+
"@storybook/test": "^8.6.12",
|
|
88
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
89
|
+
"@testing-library/react": "^16.3.0",
|
|
90
|
+
"@testing-library/user-event": "^14.6.1",
|
|
91
|
+
"@types/lodash": "^4.17.17",
|
|
92
|
+
"@types/node": "^22.14.1",
|
|
93
|
+
"@types/react-dom": "^19.1.5",
|
|
94
|
+
"@viclafouch/eslint-config-viclafouch": "4.22.0",
|
|
95
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
96
|
+
"eslint": "^9.24.0",
|
|
97
|
+
"husky": "^9.1.7",
|
|
98
|
+
"jsdom": "^26.1.0",
|
|
99
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
100
|
+
"sass-embedded": "^1.89.0",
|
|
101
|
+
"standard-version": "^9.5.0",
|
|
102
|
+
"storybook": "^8.6.12",
|
|
103
|
+
"terser": "^5.39.2",
|
|
104
|
+
"typescript": "^5.8.3",
|
|
105
|
+
"vite": "^6.2.6",
|
|
106
|
+
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
107
|
+
"vite-plugin-dts": "^4.5.3",
|
|
108
|
+
"vitest": "^3.1.1"
|
|
109
|
+
}
|
|
110
|
+
}
|